From a1163a700fce729d2dbe9f8ac77a54418394e6bd Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Wed, 4 Sep 2013 21:42:05 -0700 Subject: [PATCH] Cleanup box optimizations. original commit: 6c4ee2134804352dd1a8fd445c1e1a17915879f3 --- .../typed-racket/optimizer/box.rkt | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/box.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/box.rkt index e531f438..3dfcb666 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/box.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/box.rkt @@ -11,24 +11,16 @@ (provide box-opt-expr) -(define-syntax-class box-expr - #:commit - (pattern e:expr - #:when (match (type-of #'e) - [(tc-result1: (Box: _)) #t] - [_ #f]) - #:with opt ((optimize) #'e))) +(define-unsafe-syntax-class unbox) +(define-unsafe-syntax-class set-box!) (define-syntax-class box-op - #:commit - ;; we need the * versions of these unsafe operations to be chaperone-safe - (pattern (~literal unbox) #:with unsafe #'unsafe-unbox) - (pattern (~literal set-box!) #:with unsafe #'unsafe-set-box!)) + #:attributes (unsafe) + (pattern :unbox^) + (pattern :set-box!^)) (define-syntax-class box-opt-expr #:commit - (pattern (#%plain-app op:box-op b:box-expr new:expr ...) - #:with opt - (begin (log-optimization "box" "Box check elimination." this-syntax) - (add-disappeared-use #'op) - #`(op.unsafe b.opt #,@(stx-map (optimize) #'(new ...)))))) + (pattern (#%plain-app op:box-op b:opt-expr new:opt-expr ...) + #:do [(log-opt "box" "Box check elimination.")] + #:with opt #`(op.unsafe b.opt new.opt ...)))