fix compiler handling of top-/module-level constants
The JIT and bytecode compiler disagreed on the definition of
"constant". Now there are two levels: "constant" means constant across
all instantiations, and "fixed" means constant for a given instantation.
The JIT uses this distinction to generate direct-primitive calls
or not. (Without the distinction, a direct jump to `reverse' could
be wrong, because `racket/base' might get instantiated with the
JIT disabled or not.)
Also, fixed a bug in the JIT's `vector-set!' code in the case that
the target vector is a top-/module-level reference that is ready,
fixed, or constant.
original commit: 7eb2042bd9
This commit is contained in:
parent
eec721ff4c
commit
053734c4c8
|
@ -186,7 +186,7 @@
|
|||
[(struct def-values (ids rhs))
|
||||
`(define-values ,(map (lambda (tl)
|
||||
(match tl
|
||||
[(struct toplevel (depth pos const? mutated?))
|
||||
[(struct toplevel (depth pos const? set-const?))
|
||||
(list-ref/protect (glob-desc-vars globs) pos 'def-vals)]))
|
||||
ids)
|
||||
,(decompile-expr rhs globs stack closed))]
|
||||
|
@ -250,9 +250,13 @@
|
|||
(match expr
|
||||
[(struct toplevel (depth pos const? ready?))
|
||||
(let ([id (list-ref/protect (glob-desc-vars globs) pos 'toplevel)])
|
||||
(if (or no-check? const? ready?)
|
||||
id
|
||||
`(#%checked ,id)))]))
|
||||
(cond
|
||||
[no-check? id]
|
||||
[(and (not const?) (not ready?))
|
||||
`(#%checked ,id)]
|
||||
#;[(and const? ready?) `(#%const ,id)]
|
||||
#;[const? `(#%iconst ,id)]
|
||||
[else id]))]))
|
||||
|
||||
(define (decompile-expr expr globs stack closed)
|
||||
(match expr
|
||||
|
|
|
@ -554,8 +554,8 @@
|
|||
(if (or const? ready?)
|
||||
(cons pos
|
||||
(bitwise-ior
|
||||
(if const? #x1 0)
|
||||
(if ready? #x2 0)))
|
||||
(if const? #x2 0)
|
||||
(if ready? #x1 0)))
|
||||
pos))
|
||||
out)]
|
||||
[(struct topsyntax (depth pos midpt))
|
||||
|
|
|
@ -33,10 +33,13 @@
|
|||
;; Bytecode unmarshalers for various forms
|
||||
|
||||
(define (read-toplevel v)
|
||||
(define SCHEME_TOPLEVEL_CONST #x01)
|
||||
(define SCHEME_TOPLEVEL_READY #x02)
|
||||
(define SCHEME_TOPLEVEL_CONST #x02)
|
||||
(define SCHEME_TOPLEVEL_READY #x01)
|
||||
(match v
|
||||
[(cons depth (cons pos flags))
|
||||
;; In the VM, the two flag bits are actually interpreted
|
||||
;; as a number when the toplevel is a reference, but we
|
||||
;; interpret the bits as flags here for backward compatibility.
|
||||
(make-toplevel depth pos
|
||||
(positive? (bitwise-and flags SCHEME_TOPLEVEL_CONST))
|
||||
(positive? (bitwise-and flags SCHEME_TOPLEVEL_READY)))]
|
||||
|
|
Loading…
Reference in New Issue
Block a user