Refactoring.

original commit: 957e856a14e4c8eb4e0a055ebae66a4d820eaa87
This commit is contained in:
Eric Dobson 2013-09-19 08:42:52 -07:00
parent dcedaf1174
commit 71d6323895
2 changed files with 16 additions and 15 deletions

View File

@ -396,8 +396,9 @@
(pattern (#%plain-app op:unboxed-fun args:expr ...)
;no need to optimize op
#:with (~var || (float-complex-call-site-opt-expr #'op.unboxed-info)) #'(op args ...)
#:do [(log-arity-raising-opt "call to fun with unboxed args")])
#:with (~var call (float-complex-call-site-opt-expr #'op.unboxed-info)) #'(args ...)
#:do [(log-arity-raising-opt "call to fun with unboxed args")]
#:with opt #'(let*-values (call.bindings ...) (op call.args ...)))
(pattern :float-complex-arith-opt-expr))
@ -478,24 +479,21 @@
#:with (boxed-binding ...) #'(binding-name)))
;; takes as argument a structure describing which arguments will be unboxed
;; and the optimized version of the operator. operators are optimized elsewhere
;; to benefit from local information
(define-syntax-class (float-complex-call-site-opt-expr unboxed-info)
#:commit
#:attributes (opt)
#:attributes ((bindings 1) (args 1))
;; call site of a function with unboxed parameters
;; the calling convention is: real parts of unboxed, imag parts, boxed
(pattern (op:expr args:expr ...)
(pattern (orig-args:expr ...)
#:with (unboxed-args ...) unboxed-info
#:with opt
(syntax-parse #'((unboxed-args args) ...)
#:with ((bindings ...) (args ...))
(syntax-parse #'((unboxed-args orig-args) ...)
[(e:possibly-unboxed ...)
(log-unboxing-opt "unboxed call site")
#`(let*-values (e.bindings ... ...)
(#%plain-app op
e.real-binding ... ...
e.imag-binding ... ...
e.boxed-binding ... ...))])))
#'((e.bindings ... ...)
(e.real-binding ... ...
e.imag-binding ... ...
e.boxed-binding ... ...))])))
(define-syntax-class/specialize float-complex-arith-opt-expr (float-complex-arith-expr* #t))

View File

@ -35,8 +35,11 @@
#:with (~var operator (unboxed-let-opt-expr-internal #t)) #'let-e
#:with loop-fun2:unboxed-fun #'loop-fun
#:do [(log-optimization "unboxed let loop" arity-raising-opt-msg #'loop-fun2)]
#:with (~var || (float-complex-call-site-opt-expr #'loop-fun2.unboxed-info))
#'(operator.opt args ...)))
#:with (~var call (float-complex-call-site-opt-expr #'loop-fun2.unboxed-info))
#'(args ...)
#:with opt #'(let*-values
(((op) operator.opt) call.bindings ...)
(op call.args ...))))
;; does the bulk of the work
;; detects which let bindings can be unboxed, same for arguments of let-bound