From 002033281031e63444dc8d30586bd6c3b4163635 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 21 Mar 2019 18:12:49 -0600 Subject: [PATCH] raco demod: discard unusable macro implementations Prune away "phase -1" macro registrations, because they're useless, and because the expander's evaluation of linklets now actively rejects them. --- .../compiler/demodularizer/gc.rkt | 14 ++++++++++--- .../compiler/demodularizer/merge.rkt | 20 ++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/pkgs/compiler-lib/compiler/demodularizer/gc.rkt b/pkgs/compiler-lib/compiler/demodularizer/gc.rkt index a2c1fad191..fd90353235 100644 --- a/pkgs/compiler-lib/compiler/demodularizer/gc.rkt +++ b/pkgs/compiler-lib/compiler/demodularizer/gc.rkt @@ -92,7 +92,14 @@ [(closure code gen-id) #t] [(inline-variant direct inline) #t] [(case-lam name clauses) #t] - [_ (lam? b)])) + [(let-one rhs body type unused?) + (and (pure? rhs) + (pure? body))] + [(seq forms) + (for/and ([form (in-list forms)]) + (pure? form))] + [_ (or (lam? b) + (void? b))])) (for ([b (in-list body)]) (match b @@ -114,7 +121,8 @@ (unless (or assume-pure? (pure? rhs)) (used-rhs!))] - [_ (used! b)])) + [_ (unless (pure? b) + (used! b))])) ;; Anything not marked as used at this point can be dropped (define new-internals @@ -152,7 +160,7 @@ [(def-values ids rhs) (for/or ([id (in-list ids)]) (eq? 'used (hash-ref used (toplevel-pos id) #f)))] - [else (not (void? b))])) + [else (not (pure? b))])) b)) (define new-body (remap-positions used-body diff --git a/pkgs/compiler-lib/compiler/demodularizer/merge.rkt b/pkgs/compiler-lib/compiler/demodularizer/merge.rkt index 4502defb09..ef14f1688a 100644 --- a/pkgs/compiler-lib/compiler/demodularizer/merge.rkt +++ b/pkgs/compiler-lib/compiler/demodularizer/merge.rkt @@ -120,15 +120,25 @@ #:application-hook (lambda (rator rands remap) ;; Check for a `(.get-syntax-literal! ')` call + ;; or a `(.set-transformer! ' )` call (cond [(and (toplevel? rator) (let ([i (hash-ref pos-to-name/import (toplevel-pos rator))]) (and (import? i) - (eqv? syntax-literals-pos (import-pos i))))) - ;; This is a `(.get-syntax-literal! ')` call - (application (remap rator) - ;; To support syntax objects, change the offset - rands)] + i))) + => (lambda (i) + (cond + [(and any-syntax-literals? + (eqv? syntax-literals-pos (import-pos i))) + ;; This is a `(.get-syntax-literal! ')` call + (application (remap rator) + ;; To support syntax objects, change the offset + rands)] + [(and any-transformer-registers? + (eqv? transformer-register-pos (import-pos i))) + ;; This is a `(.set-transformer! ' )` call + (void)] + [else #f]))] [else #f])))))) (values body