Rewrite compound pair operation optimization.

Previous version replaced calls to, e.g., `cadr` with calls to `cdr`
then `car`, called the typechecker to populate the type table, then
optimized the exploded operations. The call to the typechecker failed
on open terms, limiting the applicability of the optimization, and was
just generally brittle.

The new version instead explodes operations, then optimizes them inside
out for as long as the argument's type guarantees it's safe. This works
on open terms, and should be more robust.
This commit is contained in:
Vincent St-Amour 2015-08-14 16:43:37 -05:00
parent c5a75df00c
commit e997f02095
7 changed files with 180 additions and 133 deletions

View File

@ -6,7 +6,7 @@
(for-syntax racket/base syntax/parse racket/syntax)
"../utils/utils.rkt"
(rep type-rep)
(types type-table utils base-abbrev)
(types type-table utils base-abbrev resolve subtype)
(typecheck typechecker)
(optimizer utils logging))
@ -25,10 +25,7 @@
(define (has-pair-type? e)
(and (subtypeof? e (-pair Univ Univ))
;; sometimes composite operations end up with Nothing as result type,
;; not sure why. TODO investigate
(not (isoftype? e -Bottom))))
(subtypeof? e (-pair Univ Univ)))
;; can't do the above for mpairs, as they are invariant
(define (has-mpair-type? e)
(match (type-of e) ; type of the operand
@ -67,25 +64,12 @@
;; change the source location of a given syntax object
(define (relocate stx loc-stx)
(define ((relocate loc-stx) stx)
(datum->syntax stx (syntax->datum stx) loc-stx stx stx))
;; if the equivalent sequence of cars and cdrs is guaranteed not to fail,
;; we can optimize
;; accessors is a list of syntax objects, all #'car or #'cdr
(define (gen-alt accessors op arg stx)
(define (gen-alt-helper accessors)
(for/fold [(accum arg)] [(acc (reverse accessors))]
(quasisyntax/loc stx (#%plain-app #,(relocate acc op) #,accum))))
(let ((ty (type-of stx))
(obj (gen-alt-helper accessors)))
;; we're calling the typechecker, but this is just a shortcut, we're
;; still conceptually single pass (we're not iterating). we could get
;; the same result by statically destructing the types.
(tc-expr/check obj ty)
obj))
(define-syntax gen-pair-derived-expr
(syntax-parser
[(_ name:id (orig:id seq ...) ...)
@ -96,8 +80,9 @@
(define-literal-syntax-class lit-class-name (orig))
(define-syntax-class syntax-class-name
#:commit
#:attributes (arg alt)
(pattern (#%plain-app (~var op lit-class-name) arg)
#:with alt (gen-alt (list seq ...) #'op #'arg this-syntax)))) ...
#:with alt (map (relocate #'op) (list seq ...))))) ...
(define-merged-syntax-class name (syntax-class-name ...)))]))
(gen-pair-derived-expr pair-derived-expr
@ -144,5 +129,30 @@
(define-syntax-class pair-derived-opt-expr
#:commit
(pattern e:pair-derived-expr
#:with e*:pair-opt-expr #'e.alt
#:with opt #'e*.opt))
#:with opt
;; optimize alt inside-out, as long as it's safe to
(let-values
([(t res)
(for/fold ([t (match (type-of #'e.arg)
[(tc-result1: t) t])]
[res #'e.arg])
([accessor (in-list (reverse (syntax->list #'e.alt)))])
(cond
[(subtype t (-pair Univ Univ)) ; safe to optimize this one layer
(syntax-parse accessor
[op:pair-op
(log-pair-opt)
(values
(match (resolve t)
[(Pair: a d) ; peel off one layer of the type
(syntax-parse #'op
[:car^ a]
[:cdr^ d])]
[_ ; not a pair type, give up on optimizing more
#f])
#`(op.unsafe #,res))])]
[else ; unsafe, just rebuild the rest of the accessors
(log-pair-missed-opt accessor #'e.arg)
(values t ; stays unsafe from now on
#`(#,accessor #,res))]))])
res)))

View File

@ -0,0 +1,36 @@
#;#;
#<<END
TR missed opt: derived-pair-open-terms.rkt 12:3 first -- car/cdr on a potentially empty list -- caused by: 12:9 x
TR missed opt: derived-pair-open-terms.rkt 16:3 rest -- car/cdr on a potentially empty list -- caused by: 16:8 x
TR missed opt: derived-pair-open-terms.rkt 20:3 cddr -- car/cdr on a potentially empty list -- caused by: 20:8 x
TR opt: derived-pair-open-terms.rkt 20:3 cddr -- pair
TR opt: derived-pair-open-terms.rkt 4:3 cadr -- pair
TR opt: derived-pair-open-terms.rkt 4:3 cadr -- pair
TR opt: derived-pair-open-terms.rkt 8:3 caddr -- pair
TR opt: derived-pair-open-terms.rkt 8:3 caddr -- pair
TR opt: derived-pair-open-terms.rkt 8:3 caddr -- pair
END
""
#lang typed/racket #:optimize
#reader typed-racket-test/optimizer/reset-port
(: f ((List Integer Integer Integer) -> Integer))
(define (f x)
(cadr x))
(: g ((List Integer Integer Integer) -> Integer))
(define (g x)
(caddr x))
(: h ((Listof Integer) -> Integer))
(define (h x)
(first x)) ; unsafe
(: i ((Listof Integer) -> (Listof Integer)))
(define (i x)
(rest x)) ; unsafe
(: j ((cons Integer (Listof Integer)) -> (Listof Integer)))
(define (j x)
(cddr x)) ; partially safe

View File

@ -1,13 +1,13 @@
#;#;
#<<END
TR opt: derived-pair.rkt 2:0 (caar (cons (cons 1 2) 3)) -- pair
TR opt: derived-pair.rkt 2:0 (caar (cons (cons 1 2) 3)) -- pair
TR opt: derived-pair.rkt 3:0 (cadr (cons 1 (cons 2 3))) -- pair
TR opt: derived-pair.rkt 3:0 (cadr (cons 1 (cons 2 3))) -- pair
TR opt: derived-pair.rkt 4:0 (cdar (cons (cons 1 2) 3)) -- pair
TR opt: derived-pair.rkt 4:0 (cdar (cons (cons 1 2) 3)) -- pair
TR opt: derived-pair.rkt 5:0 (cddr (cons 1 (cons 2 3))) -- pair
TR opt: derived-pair.rkt 5:0 (cddr (cons 1 (cons 2 3))) -- pair
TR opt: derived-pair.rkt 2:1 caar -- pair
TR opt: derived-pair.rkt 2:1 caar -- pair
TR opt: derived-pair.rkt 3:1 cadr -- pair
TR opt: derived-pair.rkt 3:1 cadr -- pair
TR opt: derived-pair.rkt 4:1 cdar -- pair
TR opt: derived-pair.rkt 4:1 cdar -- pair
TR opt: derived-pair.rkt 5:1 cddr -- pair
TR opt: derived-pair.rkt 5:1 cddr -- pair
END
#<<END
1

View File

@ -1,29 +1,29 @@
#;#;
#<<END
TR opt: derived-pair2.rkt 2:0 (caaar (cons (cons (cons 1 2) 3) 4)) -- pair
TR opt: derived-pair2.rkt 2:0 (caaar (cons (cons (cons 1 2) 3) 4)) -- pair
TR opt: derived-pair2.rkt 2:0 (caaar (cons (cons (cons 1 2) 3) 4)) -- pair
TR opt: derived-pair2.rkt 3:0 (caadr (cons 1 (cons (cons 2 3) 4))) -- pair
TR opt: derived-pair2.rkt 3:0 (caadr (cons 1 (cons (cons 2 3) 4))) -- pair
TR opt: derived-pair2.rkt 3:0 (caadr (cons 1 (cons (cons 2 3) 4))) -- pair
TR opt: derived-pair2.rkt 4:0 (cadar (cons (cons 1 (cons 2 3)) 4)) -- pair
TR opt: derived-pair2.rkt 4:0 (cadar (cons (cons 1 (cons 2 3)) 4)) -- pair
TR opt: derived-pair2.rkt 4:0 (cadar (cons (cons 1 (cons 2 3)) 4)) -- pair
TR opt: derived-pair2.rkt 5:0 (caddr (cons 1 (cons 2 (cons 3 4)))) -- pair
TR opt: derived-pair2.rkt 5:0 (caddr (cons 1 (cons 2 (cons 3 4)))) -- pair
TR opt: derived-pair2.rkt 5:0 (caddr (cons 1 (cons 2 (cons 3 4)))) -- pair
TR opt: derived-pair2.rkt 6:0 (cdaar (cons (cons (cons 1 2) 3) 4)) -- pair
TR opt: derived-pair2.rkt 6:0 (cdaar (cons (cons (cons 1 2) 3) 4)) -- pair
TR opt: derived-pair2.rkt 6:0 (cdaar (cons (cons (cons 1 2) 3) 4)) -- pair
TR opt: derived-pair2.rkt 7:0 (cdadr (cons 1 (cons (cons 2 3) 4))) -- pair
TR opt: derived-pair2.rkt 7:0 (cdadr (cons 1 (cons (cons 2 3) 4))) -- pair
TR opt: derived-pair2.rkt 7:0 (cdadr (cons 1 (cons (cons 2 3) 4))) -- pair
TR opt: derived-pair2.rkt 8:0 (cddar (cons (cons 1 (cons 2 3)) 4)) -- pair
TR opt: derived-pair2.rkt 8:0 (cddar (cons (cons 1 (cons 2 3)) 4)) -- pair
TR opt: derived-pair2.rkt 8:0 (cddar (cons (cons 1 (cons 2 3)) 4)) -- pair
TR opt: derived-pair2.rkt 9:0 (cdddr (cons 1 (cons 2 (cons 3 4)))) -- pair
TR opt: derived-pair2.rkt 9:0 (cdddr (cons 1 (cons 2 (cons 3 4)))) -- pair
TR opt: derived-pair2.rkt 9:0 (cdddr (cons 1 (cons 2 (cons 3 4)))) -- pair
TR opt: derived-pair2.rkt 2:1 caaar -- pair
TR opt: derived-pair2.rkt 2:1 caaar -- pair
TR opt: derived-pair2.rkt 2:1 caaar -- pair
TR opt: derived-pair2.rkt 3:1 caadr -- pair
TR opt: derived-pair2.rkt 3:1 caadr -- pair
TR opt: derived-pair2.rkt 3:1 caadr -- pair
TR opt: derived-pair2.rkt 4:1 cadar -- pair
TR opt: derived-pair2.rkt 4:1 cadar -- pair
TR opt: derived-pair2.rkt 4:1 cadar -- pair
TR opt: derived-pair2.rkt 5:1 caddr -- pair
TR opt: derived-pair2.rkt 5:1 caddr -- pair
TR opt: derived-pair2.rkt 5:1 caddr -- pair
TR opt: derived-pair2.rkt 6:1 cdaar -- pair
TR opt: derived-pair2.rkt 6:1 cdaar -- pair
TR opt: derived-pair2.rkt 6:1 cdaar -- pair
TR opt: derived-pair2.rkt 7:1 cdadr -- pair
TR opt: derived-pair2.rkt 7:1 cdadr -- pair
TR opt: derived-pair2.rkt 7:1 cdadr -- pair
TR opt: derived-pair2.rkt 8:1 cddar -- pair
TR opt: derived-pair2.rkt 8:1 cddar -- pair
TR opt: derived-pair2.rkt 8:1 cddar -- pair
TR opt: derived-pair2.rkt 9:1 cdddr -- pair
TR opt: derived-pair2.rkt 9:1 cdddr -- pair
TR opt: derived-pair2.rkt 9:1 cdddr -- pair
END
#<<END
1

View File

@ -1,69 +1,69 @@
#;#;
#<<END
TR opt: derived-pair3.rkt 10:0 (cdaaar (cons (cons (cons (cons 1 2) 3) 4) 5)) -- pair
TR opt: derived-pair3.rkt 10:0 (cdaaar (cons (cons (cons (cons 1 2) 3) 4) 5)) -- pair
TR opt: derived-pair3.rkt 10:0 (cdaaar (cons (cons (cons (cons 1 2) 3) 4) 5)) -- pair
TR opt: derived-pair3.rkt 10:0 (cdaaar (cons (cons (cons (cons 1 2) 3) 4) 5)) -- pair
TR opt: derived-pair3.rkt 11:0 (cdaadr (cons 1 (cons (cons (cons 2 3) 4) 5))) -- pair
TR opt: derived-pair3.rkt 11:0 (cdaadr (cons 1 (cons (cons (cons 2 3) 4) 5))) -- pair
TR opt: derived-pair3.rkt 11:0 (cdaadr (cons 1 (cons (cons (cons 2 3) 4) 5))) -- pair
TR opt: derived-pair3.rkt 11:0 (cdaadr (cons 1 (cons (cons (cons 2 3) 4) 5))) -- pair
TR opt: derived-pair3.rkt 12:0 (cdadar (cons (cons 1 (cons (cons 2 3) 4)) 5)) -- pair
TR opt: derived-pair3.rkt 12:0 (cdadar (cons (cons 1 (cons (cons 2 3) 4)) 5)) -- pair
TR opt: derived-pair3.rkt 12:0 (cdadar (cons (cons 1 (cons (cons 2 3) 4)) 5)) -- pair
TR opt: derived-pair3.rkt 12:0 (cdadar (cons (cons 1 (cons (cons 2 3) 4)) 5)) -- pair
TR opt: derived-pair3.rkt 13:0 (cdaddr (cons 1 (cons 2 (cons (cons 3 4) 5)))) -- pair
TR opt: derived-pair3.rkt 13:0 (cdaddr (cons 1 (cons 2 (cons (cons 3 4) 5)))) -- pair
TR opt: derived-pair3.rkt 13:0 (cdaddr (cons 1 (cons 2 (cons (cons 3 4) 5)))) -- pair
TR opt: derived-pair3.rkt 13:0 (cdaddr (cons 1 (cons 2 (cons (cons 3 4) 5)))) -- pair
TR opt: derived-pair3.rkt 14:0 (cddaar (cons (cons (cons 1 (cons 2 3)) 4) 5)) -- pair
TR opt: derived-pair3.rkt 14:0 (cddaar (cons (cons (cons 1 (cons 2 3)) 4) 5)) -- pair
TR opt: derived-pair3.rkt 14:0 (cddaar (cons (cons (cons 1 (cons 2 3)) 4) 5)) -- pair
TR opt: derived-pair3.rkt 14:0 (cddaar (cons (cons (cons 1 (cons 2 3)) 4) 5)) -- pair
TR opt: derived-pair3.rkt 15:0 (cddadr (cons 1 (cons (cons 2 (cons 3 4)) 5))) -- pair
TR opt: derived-pair3.rkt 15:0 (cddadr (cons 1 (cons (cons 2 (cons 3 4)) 5))) -- pair
TR opt: derived-pair3.rkt 15:0 (cddadr (cons 1 (cons (cons 2 (cons 3 4)) 5))) -- pair
TR opt: derived-pair3.rkt 15:0 (cddadr (cons 1 (cons (cons 2 (cons 3 4)) 5))) -- pair
TR opt: derived-pair3.rkt 16:0 (cdddar (cons (cons 1 (cons 2 (cons 3 4))) 5)) -- pair
TR opt: derived-pair3.rkt 16:0 (cdddar (cons (cons 1 (cons 2 (cons 3 4))) 5)) -- pair
TR opt: derived-pair3.rkt 16:0 (cdddar (cons (cons 1 (cons 2 (cons 3 4))) 5)) -- pair
TR opt: derived-pair3.rkt 16:0 (cdddar (cons (cons 1 (cons 2 (cons 3 4))) 5)) -- pair
TR opt: derived-pair3.rkt 17:0 (cddddr (cons 1 (cons 2 (cons 3 (cons 4 5))))) -- pair
TR opt: derived-pair3.rkt 17:0 (cddddr (cons 1 (cons 2 (cons 3 (cons 4 5))))) -- pair
TR opt: derived-pair3.rkt 17:0 (cddddr (cons 1 (cons 2 (cons 3 (cons 4 5))))) -- pair
TR opt: derived-pair3.rkt 17:0 (cddddr (cons 1 (cons 2 (cons 3 (cons 4 5))))) -- pair
TR opt: derived-pair3.rkt 2:0 (caaaar (cons (cons (cons (cons 1 2) 3) 4) 5)) -- pair
TR opt: derived-pair3.rkt 2:0 (caaaar (cons (cons (cons (cons 1 2) 3) 4) 5)) -- pair
TR opt: derived-pair3.rkt 2:0 (caaaar (cons (cons (cons (cons 1 2) 3) 4) 5)) -- pair
TR opt: derived-pair3.rkt 2:0 (caaaar (cons (cons (cons (cons 1 2) 3) 4) 5)) -- pair
TR opt: derived-pair3.rkt 3:0 (caaadr (cons 1 (cons (cons (cons 2 3) 4) 5))) -- pair
TR opt: derived-pair3.rkt 3:0 (caaadr (cons 1 (cons (cons (cons 2 3) 4) 5))) -- pair
TR opt: derived-pair3.rkt 3:0 (caaadr (cons 1 (cons (cons (cons 2 3) 4) 5))) -- pair
TR opt: derived-pair3.rkt 3:0 (caaadr (cons 1 (cons (cons (cons 2 3) 4) 5))) -- pair
TR opt: derived-pair3.rkt 4:0 (caadar (cons (cons 1 (cons (cons 2 3) 4)) 5)) -- pair
TR opt: derived-pair3.rkt 4:0 (caadar (cons (cons 1 (cons (cons 2 3) 4)) 5)) -- pair
TR opt: derived-pair3.rkt 4:0 (caadar (cons (cons 1 (cons (cons 2 3) 4)) 5)) -- pair
TR opt: derived-pair3.rkt 4:0 (caadar (cons (cons 1 (cons (cons 2 3) 4)) 5)) -- pair
TR opt: derived-pair3.rkt 5:0 (caaddr (cons 1 (cons 2 (cons (cons 3 4) 5)))) -- pair
TR opt: derived-pair3.rkt 5:0 (caaddr (cons 1 (cons 2 (cons (cons 3 4) 5)))) -- pair
TR opt: derived-pair3.rkt 5:0 (caaddr (cons 1 (cons 2 (cons (cons 3 4) 5)))) -- pair
TR opt: derived-pair3.rkt 5:0 (caaddr (cons 1 (cons 2 (cons (cons 3 4) 5)))) -- pair
TR opt: derived-pair3.rkt 6:0 (cadaar (cons (cons (cons 1 (cons 2 3)) 4) 5)) -- pair
TR opt: derived-pair3.rkt 6:0 (cadaar (cons (cons (cons 1 (cons 2 3)) 4) 5)) -- pair
TR opt: derived-pair3.rkt 6:0 (cadaar (cons (cons (cons 1 (cons 2 3)) 4) 5)) -- pair
TR opt: derived-pair3.rkt 6:0 (cadaar (cons (cons (cons 1 (cons 2 3)) 4) 5)) -- pair
TR opt: derived-pair3.rkt 7:0 (cadadr (cons 1 (cons (cons 2 (cons 3 4)) 5))) -- pair
TR opt: derived-pair3.rkt 7:0 (cadadr (cons 1 (cons (cons 2 (cons 3 4)) 5))) -- pair
TR opt: derived-pair3.rkt 7:0 (cadadr (cons 1 (cons (cons 2 (cons 3 4)) 5))) -- pair
TR opt: derived-pair3.rkt 7:0 (cadadr (cons 1 (cons (cons 2 (cons 3 4)) 5))) -- pair
TR opt: derived-pair3.rkt 8:0 (caddar (cons (cons 1 (cons 2 (cons 3 4))) 5)) -- pair
TR opt: derived-pair3.rkt 8:0 (caddar (cons (cons 1 (cons 2 (cons 3 4))) 5)) -- pair
TR opt: derived-pair3.rkt 8:0 (caddar (cons (cons 1 (cons 2 (cons 3 4))) 5)) -- pair
TR opt: derived-pair3.rkt 8:0 (caddar (cons (cons 1 (cons 2 (cons 3 4))) 5)) -- pair
TR opt: derived-pair3.rkt 9:0 (cadddr (cons 1 (cons 2 (cons 3 (cons 4 5))))) -- pair
TR opt: derived-pair3.rkt 9:0 (cadddr (cons 1 (cons 2 (cons 3 (cons 4 5))))) -- pair
TR opt: derived-pair3.rkt 9:0 (cadddr (cons 1 (cons 2 (cons 3 (cons 4 5))))) -- pair
TR opt: derived-pair3.rkt 9:0 (cadddr (cons 1 (cons 2 (cons 3 (cons 4 5))))) -- pair
TR opt: derived-pair3.rkt 10:1 cdaaar -- pair
TR opt: derived-pair3.rkt 10:1 cdaaar -- pair
TR opt: derived-pair3.rkt 10:1 cdaaar -- pair
TR opt: derived-pair3.rkt 10:1 cdaaar -- pair
TR opt: derived-pair3.rkt 11:1 cdaadr -- pair
TR opt: derived-pair3.rkt 11:1 cdaadr -- pair
TR opt: derived-pair3.rkt 11:1 cdaadr -- pair
TR opt: derived-pair3.rkt 11:1 cdaadr -- pair
TR opt: derived-pair3.rkt 12:1 cdadar -- pair
TR opt: derived-pair3.rkt 12:1 cdadar -- pair
TR opt: derived-pair3.rkt 12:1 cdadar -- pair
TR opt: derived-pair3.rkt 12:1 cdadar -- pair
TR opt: derived-pair3.rkt 13:1 cdaddr -- pair
TR opt: derived-pair3.rkt 13:1 cdaddr -- pair
TR opt: derived-pair3.rkt 13:1 cdaddr -- pair
TR opt: derived-pair3.rkt 13:1 cdaddr -- pair
TR opt: derived-pair3.rkt 14:1 cddaar -- pair
TR opt: derived-pair3.rkt 14:1 cddaar -- pair
TR opt: derived-pair3.rkt 14:1 cddaar -- pair
TR opt: derived-pair3.rkt 14:1 cddaar -- pair
TR opt: derived-pair3.rkt 15:1 cddadr -- pair
TR opt: derived-pair3.rkt 15:1 cddadr -- pair
TR opt: derived-pair3.rkt 15:1 cddadr -- pair
TR opt: derived-pair3.rkt 15:1 cddadr -- pair
TR opt: derived-pair3.rkt 16:1 cdddar -- pair
TR opt: derived-pair3.rkt 16:1 cdddar -- pair
TR opt: derived-pair3.rkt 16:1 cdddar -- pair
TR opt: derived-pair3.rkt 16:1 cdddar -- pair
TR opt: derived-pair3.rkt 17:1 cddddr -- pair
TR opt: derived-pair3.rkt 17:1 cddddr -- pair
TR opt: derived-pair3.rkt 17:1 cddddr -- pair
TR opt: derived-pair3.rkt 17:1 cddddr -- pair
TR opt: derived-pair3.rkt 2:1 caaaar -- pair
TR opt: derived-pair3.rkt 2:1 caaaar -- pair
TR opt: derived-pair3.rkt 2:1 caaaar -- pair
TR opt: derived-pair3.rkt 2:1 caaaar -- pair
TR opt: derived-pair3.rkt 3:1 caaadr -- pair
TR opt: derived-pair3.rkt 3:1 caaadr -- pair
TR opt: derived-pair3.rkt 3:1 caaadr -- pair
TR opt: derived-pair3.rkt 3:1 caaadr -- pair
TR opt: derived-pair3.rkt 4:1 caadar -- pair
TR opt: derived-pair3.rkt 4:1 caadar -- pair
TR opt: derived-pair3.rkt 4:1 caadar -- pair
TR opt: derived-pair3.rkt 4:1 caadar -- pair
TR opt: derived-pair3.rkt 5:1 caaddr -- pair
TR opt: derived-pair3.rkt 5:1 caaddr -- pair
TR opt: derived-pair3.rkt 5:1 caaddr -- pair
TR opt: derived-pair3.rkt 5:1 caaddr -- pair
TR opt: derived-pair3.rkt 6:1 cadaar -- pair
TR opt: derived-pair3.rkt 6:1 cadaar -- pair
TR opt: derived-pair3.rkt 6:1 cadaar -- pair
TR opt: derived-pair3.rkt 6:1 cadaar -- pair
TR opt: derived-pair3.rkt 7:1 cadadr -- pair
TR opt: derived-pair3.rkt 7:1 cadadr -- pair
TR opt: derived-pair3.rkt 7:1 cadadr -- pair
TR opt: derived-pair3.rkt 7:1 cadadr -- pair
TR opt: derived-pair3.rkt 8:1 caddar -- pair
TR opt: derived-pair3.rkt 8:1 caddar -- pair
TR opt: derived-pair3.rkt 8:1 caddar -- pair
TR opt: derived-pair3.rkt 8:1 caddar -- pair
TR opt: derived-pair3.rkt 9:1 cadddr -- pair
TR opt: derived-pair3.rkt 9:1 cadddr -- pair
TR opt: derived-pair3.rkt 9:1 cadddr -- pair
TR opt: derived-pair3.rkt 9:1 cadddr -- pair
END
#<<END
1

View File

@ -1,7 +1,9 @@
#;#;
#<<END
TR missed opt: invalid-derived-pair.rkt 10:6 (cadr x) -- car/cdr on a potentially empty list -- caused by: 10:6 (cadr x)
TR missed opt: invalid-derived-pair.rkt 5:2 (cadr x) -- car/cdr on a potentially empty list -- caused by: 5:2 (cadr x)
TR missed opt: invalid-derived-pair.rkt 10:7 cadr -- car/cdr on a potentially empty list -- caused by: 10:12 x
TR missed opt: invalid-derived-pair.rkt 5:3 cadr -- car/cdr on a potentially empty list -- caused by: 5:8 x
TR missed opt: invalid-derived-pair.rkt 5:3 cadr -- car/cdr on a potentially empty list -- caused by: 5:8 x
TR opt: invalid-derived-pair.rkt 10:7 cadr -- pair
END
""
#lang typed/racket #:optimize

View File

@ -1,18 +1,17 @@
#;#;
#<<END
TR opt: list.rkt 3:0 (first l) -- pair
TR opt: list.rkt 4:0 (rest l) -- pair
TR opt: list.rkt 5:0 (second l) -- pair
TR opt: list.rkt 5:0 (second l) -- pair
TR opt: list.rkt 6:0 (rest (rest l)) -- pair
TR opt: list.rkt 6:6 (rest l) -- pair
TR opt: list.rkt 7:0 (third l) -- pair
TR opt: list.rkt 7:0 (third l) -- pair
TR opt: list.rkt 7:0 (third l) -- pair
TR opt: list.rkt 8:0 (fourth l) -- pair
TR opt: list.rkt 8:0 (fourth l) -- pair
TR opt: list.rkt 8:0 (fourth l) -- pair
TR opt: list.rkt 8:0 (fourth l) -- pair
TR opt: list.rkt 3:1 first -- pair
TR opt: list.rkt 4:1 rest -- pair
TR opt: list.rkt 5:1 second -- pair
TR opt: list.rkt 5:1 second -- pair
TR opt: list.rkt 6:1 rest -- pair
TR opt: list.rkt 7:1 third -- pair
TR opt: list.rkt 7:1 third -- pair
TR opt: list.rkt 7:1 third -- pair
TR opt: list.rkt 8:1 fourth -- pair
TR opt: list.rkt 8:1 fourth -- pair
TR opt: list.rkt 8:1 fourth -- pair
TR opt: list.rkt 8:1 fourth -- pair
END
#<<END
1