fix pessimism in optimizer reordering
When determing whether expressions can be reordered, a reference to a module-defined variable was considered unreorderable when it is known to have a value and no further mutation, but the value isn't constant across all runs.
This commit is contained in:
parent
21d925d1f0
commit
2dd29f7e3d
|
@ -1847,6 +1847,40 @@
|
|||
'(lambda (z)
|
||||
(list (list (z 2)) (list z))))
|
||||
|
||||
(test-comp '(module m racket/base
|
||||
;; Reference to a ready module-level variable shouldn't
|
||||
;; prevent let-values splitting
|
||||
(#%plain-module-begin
|
||||
(define z (random))
|
||||
(define (f)
|
||||
(let-values ([(a b) (values (cons 1 z) (cons 2 z))])
|
||||
(list a b)))))
|
||||
'(module m racket/base
|
||||
;; Reference to a ready module-level variable shouldn't
|
||||
;; prevent let-values splitting
|
||||
(#%plain-module-begin
|
||||
(define z (random))
|
||||
(define (f)
|
||||
(list (cons 1 z) (cons 2 z))))))
|
||||
|
||||
(test-comp '(module m racket/base
|
||||
;; Don't reorder references to a mutable variable
|
||||
(#%plain-module-begin
|
||||
(define z (random))
|
||||
(define (f)
|
||||
(let-values ([(a b) (values (cons 1 z) (cons 2 z))])
|
||||
(list a b)))
|
||||
(set! z 5)))
|
||||
'(module m racket/base
|
||||
;; Reference to a ready module-level variable shouldn't
|
||||
;; prevent let-values splitting
|
||||
(#%plain-module-begin
|
||||
(define z (random))
|
||||
(define (f)
|
||||
(list (cons 1 z) (cons 2 z)))
|
||||
(set! z 5)))
|
||||
#f)
|
||||
|
||||
(test-comp '(lambda (z)
|
||||
;; It's ok to reorder unsafe operations relative
|
||||
;; to each other:
|
||||
|
|
|
@ -341,9 +341,9 @@ int scheme_omittable_expr(Scheme_Object *o, int vals, int fuel, int resolved,
|
|||
if (vtype == scheme_compiled_toplevel_type) {
|
||||
note_match(1, vals, warn_info);
|
||||
if ((vals == 1) || (vals < 0)) {
|
||||
if (!no_id && (SCHEME_TOPLEVEL_FLAGS(o) & SCHEME_TOPLEVEL_FLAGS_MASK) >= SCHEME_TOPLEVEL_READY)
|
||||
if (!no_id && ((SCHEME_TOPLEVEL_FLAGS(o) & SCHEME_TOPLEVEL_FLAGS_MASK) >= SCHEME_TOPLEVEL_READY))
|
||||
return 1;
|
||||
else if ((SCHEME_TOPLEVEL_FLAGS(o) & SCHEME_TOPLEVEL_FLAGS_MASK) >= SCHEME_TOPLEVEL_CONST)
|
||||
else if ((SCHEME_TOPLEVEL_FLAGS(o) & SCHEME_TOPLEVEL_FLAGS_MASK) >= SCHEME_TOPLEVEL_FIXED)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user