TR for clause specialization: log syntax objects with location info.

original commit: cef7348e8de66d89baa612ad201054bc1656b197
This commit is contained in:
Vincent St-Amour 2013-10-08 15:54:50 -04:00
parent 61f436be0f
commit e1c1f270a5
8 changed files with 14 additions and 14 deletions

View File

@ -26,8 +26,8 @@
(define-syntax-class/specialize vector-expr
(typed-expr (disjoin Vector? HeterogeneousVector?)))
(define-syntax-rule (log-seq-opt opt-label)
(log-opt opt-label "Sequence type specialization."))
(define-syntax-rule (log-seq-opt opt-label stx)
(log-optimization opt-label "Sequence type specialization." stx))
(define-syntax-class make-sequence
(pattern op:id
@ -39,7 +39,7 @@
;; if we're iterating (with the for macros) over something we know is a list,
;; we can generate code that would be similar to if in-list had been used
(pattern (#%plain-app op:make-sequence _ l:list-expr)
#:do [(log-seq-opt "in-list")]
#:do [(log-seq-opt "in-list" #'l)]
#:with opt #'(let ((i l.opt))
(values unsafe-car unsafe-cdr i
(lambda (x) (not (null? x)))
@ -47,7 +47,7 @@
(lambda (x y) #t))))
;; idem for vectors
(pattern (#%plain-app op:make-sequence _ v:vector-expr)
#:do [(log-seq-opt "in-vector")]
#:do [(log-seq-opt "in-vector" #'v)]
#:with opt #'(let* ((i v.opt)
(len (unsafe-vector-length i)))
(values (lambda (x) (unsafe-vector-ref i x))
@ -58,7 +58,7 @@
(lambda (x y) #t))))
;; and (byte) strings
(pattern (#%plain-app op:make-sequence _ s:string-expr)
#:do [(log-seq-opt "in-string")]
#:do [(log-seq-opt "in-string" #'s)]
#:with opt #'(let* ((i s.opt)
(len (string-length i)))
(values (lambda (x) (string-ref i x))
@ -68,7 +68,7 @@
(lambda (x) #t)
(lambda (x y) #t))))
(pattern (#%plain-app op:make-sequence _ s:bytes-expr)
#:do [(log-seq-opt "in-bytes")]
#:do [(log-seq-opt "in-bytes" #'s)]
#:with opt #'(let* ((i s.opt)
(len (bytes-length i)))
(values (lambda (x) (bytes-ref i x))
@ -78,7 +78,7 @@
(lambda (x) #t)
(lambda (x y) #t))))
(pattern (#%plain-app op:make-sequence _ s:int-expr) ; one-arg in-range
#:do [(log-seq-opt "in-range")]
#:do [(log-seq-opt "in-range" #'s)]
#:with opt #'(let* ((end s.opt))
(values (lambda (x) x)
(lambda (x) (unsafe-fx+ 1 x))

View File

@ -21,7 +21,6 @@ TR info: dead-inf-comp.rkt 212:41 displayln -- hidden parameter
TR opt: dead-inf-comp.rkt 102:0 #%module-begin -- dead else branch
TR opt: dead-inf-comp.rkt 102:0 #%module-begin -- dead else branch
TR opt: dead-inf-comp.rkt 102:0 #%module-begin -- dead else branch
TR opt: dead-inf-comp.rkt 102:0 #%module-begin -- in-range
TR opt: dead-inf-comp.rkt 108:4 (quote dead) -- dead else branch
TR opt: dead-inf-comp.rkt 110:4 (quote dead) -- dead then branch
TR opt: dead-inf-comp.rkt 113:4 (quote dead) -- dead then branch
@ -60,6 +59,7 @@ TR opt: dead-inf-comp.rkt 212:0 (for: ((i (in-range 5 +inf.0 2)) (j 3)) (display
TR opt: dead-inf-comp.rkt 212:0 (for: ((i (in-range 5 +inf.0 2)) (j 3)) (displayln i)) -- dead else branch
TR opt: dead-inf-comp.rkt 212:0 (for: ((i (in-range 5 +inf.0 2)) (j 3)) (displayln i)) -- dead else branch
TR opt: dead-inf-comp.rkt 212:0 (for: ((i (in-range 5 +inf.0 2)) (j 3)) (displayln i)) -- dead else branch
TR opt: dead-inf-comp.rkt 212:36 3 -- in-range
END
#<<END
'live

View File

@ -2,7 +2,7 @@
#<<END
TR info: in-bytes.rkt 11:7 display -- hidden parameter
TR info: in-bytes.rkt 11:7 display -- hidden parameter
TR opt: in-bytes.rkt 8:0 #%module-begin -- in-bytes
TR opt: in-bytes.rkt 10:20 #"123" -- in-bytes
END
"495051"
#lang typed/scheme

View File

@ -2,7 +2,7 @@
#<<END
TR info: in-list.rkt 11:7 display -- hidden parameter
TR info: in-list.rkt 11:7 display -- hidden parameter
TR opt: in-list.rkt 8:0 #%module-begin -- in-list
TR opt: in-list.rkt 10:20 (quote (1 2 3)) -- in-list
END
"123"
#lang typed/scheme

View File

@ -2,7 +2,7 @@
#<<END
TR info: in-range.rkt 11:3 display -- hidden parameter
TR info: in-range.rkt 11:3 display -- hidden parameter
TR opt: in-range.rkt 8:0 #%module-begin -- in-range
TR opt: in-range.rkt 10:9 4 -- in-range
END
"0123"
#lang typed/scheme

View File

@ -2,7 +2,7 @@
#<<END
TR info: in-string.rkt 11:7 display -- hidden parameter
TR info: in-string.rkt 11:7 display -- hidden parameter
TR opt: in-string.rkt 8:0 #%module-begin -- in-string
TR opt: in-string.rkt 10:17 "123" -- in-string
END
"123"
#lang typed/scheme

View File

@ -2,7 +2,7 @@
#<<END
TR info: in-vector.rkt 11:7 display -- hidden parameter
TR info: in-vector.rkt 11:7 display -- hidden parameter
TR opt: in-vector.rkt 8:0 #%module-begin -- in-vector
TR opt: in-vector.rkt 10:20 (vector 1 2 3) -- in-vector
END
"123"
#lang typed/scheme

View File

@ -1,6 +1,5 @@
#;#;
#<<END
TR opt: unboxed-for.rkt 29:0 #%module-begin -- in-list
TR opt: unboxed-for.rkt 32:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- call to fun with unboxed args
TR opt: unboxed-for.rkt 32:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- fun -> unboxed fun
TR opt: unboxed-for.rkt 32:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unbox float-complex
@ -17,6 +16,7 @@ TR opt: unboxed-for.rkt 32:31 sum -- unboxed var -> table
TR opt: unboxed-for.rkt 32:53 0.0+0.0i -- unboxed literal
TR opt: unboxed-for.rkt 33:13 i -- unboxed complex variable
TR opt: unboxed-for.rkt 33:13 i -- unboxed complex variable
TR opt: unboxed-for.rkt 33:33 (quote (1.0+2.0i 2.0+4.0i)) -- in-list
TR opt: unboxed-for.rkt 34:11 sum -- leave var unboxed
TR opt: unboxed-for.rkt 34:6 (+ i sum) -- unboxed binary float complex
TR opt: unboxed-for.rkt 34:9 i -- leave var unboxed