From 64b269498685d0e02fb5561d733010426151c8ab Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 30 Jun 2018 14:11:45 -0600 Subject: [PATCH] jitify: reduce unnecessary variable indirections --- racket/src/schemify/jitify.rkt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/racket/src/schemify/jitify.rkt b/racket/src/schemify/jitify.rkt index 12c21b2e90..19c6f13fdc 100644 --- a/racket/src/schemify/jitify.rkt +++ b/racket/src/schemify/jitify.rkt @@ -146,8 +146,8 @@ (match v [`(variable-set! ,var-id ,id . ,_) (hash-set env (unwrap id) `(variable-ref ,(unwrap var-id)))] - [`(define ,_ (begin (variable-set! ,var-id ,id . ,_) (void))) - (hash-set env (unwrap id) `(variable-ref ,(unwrap var-id)))] + [`(define ,_ (begin (variable-set! . ,vs) (void))) + (loop `(variable-set! . ,vs) env)] [`(define ,id ,rhs) (plain-add-args env id)] [`(define-values ,ids ,rhs) (plain-add-args env ids)] [`(begin . ,vs) @@ -157,8 +157,13 @@ (let loop ([body body]) (for/list ([v (in-list body)]) (match v - [`(variable-set! ,var-id ,id . ,_) v] - [`(define ,_ (begin (variable-set! ,var-id ,id . ,_) (void))) v] + [`(variable-set! ,var-id ,id ',constance) + (when constance + ;; From now on, a direct reference is ok + (set! top-env (hash-set top-env (unwrap id) '#:direct))) + v] + [`(define ,_ (begin (variable-set! . ,vs) (void))) + (car (loop (list `(variable-set! . ,vs))))] [`(define ,id ,rhs) ;; If there's a direct reference to `id` in `rhs`, then ;; `id` must not be mutable