bytecode optimizer: allow inline of unsafe-undefined

Restores some function inlining that was lost by the change to
optional-argument expansion.
This commit is contained in:
Matthew Flatt 2018-05-12 07:07:38 -06:00
parent bbbdee2853
commit 44b8e56ed0
2 changed files with 18 additions and 0 deletions

View File

@ -4319,6 +4319,23 @@
(test-comp '(lambda () (bytes=? #"123" #"456")) (test-comp '(lambda () (bytes=? #"123" #"456"))
'(lambda () #f)) '(lambda () #f))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check inlining with optional arguments
(test-comp '(lambda (x)
(define (f z [y 2])
(+ z y))
(f x))
'(lambda (x)
(+ x 2)))
(test-comp '(lambda (x)
(define (f z [y (+ 1 1)])
(+ z y))
(f x))
'(lambda (x)
(+ x 2)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check that the type information is shifted in the ;; Check that the type information is shifted in the
;; right direction while inlining. ;; right direction while inlining.

View File

@ -2269,6 +2269,7 @@ int scheme_ir_duplicate_ok(Scheme_Object *fb, int cross_linklet)
{ {
return (SCHEME_VOIDP(fb) return (SCHEME_VOIDP(fb)
|| SAME_OBJ(fb, scheme_true) || SAME_OBJ(fb, scheme_true)
|| SAME_OBJ(fb, scheme_undefined)
|| SCHEME_FALSEP(fb) || SCHEME_FALSEP(fb)
|| (SCHEME_SYMBOLP(fb) || (SCHEME_SYMBOLP(fb)
&& (!cross_linklet || (!SCHEME_SYM_WEIRDP(fb) && (!cross_linklet || (!SCHEME_SYM_WEIRDP(fb)