cs: change code generated for defining module variables
Makes a small difference in code + relocation sizes (about 1%)
This commit is contained in:
parent
df039c1b73
commit
595b62a038
|
@ -61,6 +61,7 @@
|
|||
variable-set!/check-undefined
|
||||
variable-ref
|
||||
variable-ref/no-check
|
||||
set-consistent-variables!/define
|
||||
make-instance-variable-reference
|
||||
jitified-extract-closed
|
||||
jitified-extract
|
||||
|
@ -870,6 +871,12 @@
|
|||
(define (variable-ref/no-check var)
|
||||
(variable-val var))
|
||||
|
||||
(define (set-consistent-variables!/define vars vals)
|
||||
(let loop ([i 0])
|
||||
(unless (fx= i (#%vector-length vars))
|
||||
(variable-set!/define (#%vector-ref vars i) (#%vector-ref vals i) 'consistent)
|
||||
(loop (fx+ i 1)))))
|
||||
|
||||
;; Find variables or values needed from an instance for a linklet's
|
||||
;; imports
|
||||
(define (extract-imported-variabless target-inst insts symss imports-abis accum)
|
||||
|
@ -1245,6 +1252,8 @@
|
|||
variable-set!/define
|
||||
variable-ref
|
||||
variable-ref/no-check
|
||||
variable-set!/define
|
||||
set-consistent-variables!/define
|
||||
make-instance-variable-reference
|
||||
unbox/check-undefined
|
||||
set-box!/check-undefined
|
||||
|
|
|
@ -228,9 +228,32 @@
|
|||
(let loop ([l l] [in-mut-l l] [accum-exprs null] [accum-ids null] [knowns knowns])
|
||||
(define mut-l (update-mutated-state! l in-mut-l mutated))
|
||||
(define (make-set-variables)
|
||||
(for/list ([id (in-list accum-ids)]
|
||||
#:when (hash-ref exports (unwrap id) #f))
|
||||
(make-set-variable id exports knowns mutated)))
|
||||
;; Resulting list of assinments will be reversed
|
||||
(cond
|
||||
[(or for-cify? for-interp?)
|
||||
(for/list ([id (in-list accum-ids)]
|
||||
#:when (hash-ref exports (unwrap id) #f))
|
||||
(make-set-variable id exports knowns mutated))]
|
||||
[else
|
||||
;; Group 'consistent variables in one `set-consistent-variables!/define` call
|
||||
(let loop ([accum-ids accum-ids] [consistent-ids null])
|
||||
(cond
|
||||
[(null? accum-ids)
|
||||
(make-set-consistent-variables consistent-ids exports knowns mutated)]
|
||||
[else
|
||||
(define id (car accum-ids))
|
||||
(define u-id (unwrap id))
|
||||
(cond
|
||||
[(hash-ref exports u-id #f)
|
||||
(cond
|
||||
[(eq? 'consistent (variable-constance u-id knowns mutated))
|
||||
(loop (cdr accum-ids) (cons id consistent-ids))]
|
||||
[else
|
||||
(append (make-set-consistent-variables consistent-ids exports knowns mutated)
|
||||
(cons (make-set-variable id exports knowns mutated)
|
||||
(loop (cdr accum-ids) '())))])]
|
||||
[else
|
||||
(loop (cdr accum-ids) consistent-ids)])]))]))
|
||||
(define (make-expr-defns es)
|
||||
(if (or for-interp? for-cify?)
|
||||
(reverse es)
|
||||
|
@ -402,6 +425,16 @@
|
|||
(define ex-id (id-to-variable int-id exports knowns mutated extra-variables))
|
||||
`(variable-set!/define ,ex-id ,id ',(variable-constance int-id knowns mutated)))
|
||||
|
||||
;; returns a list equilanet to a sequence of `variable-set!/define` forms
|
||||
(define (make-set-consistent-variables ids exports knowns mutated)
|
||||
(cond
|
||||
[(null? ids) null]
|
||||
[(null? (cdr ids)) (list (make-set-variable (car ids) exports knowns mutated))]
|
||||
[else
|
||||
(define ex-ids (for/list ([id (in-list ids)])
|
||||
(id-to-variable (unwrap id) exports knowns mutated #f)))
|
||||
`((set-consistent-variables!/define (vector ,@ex-ids) (vector ,@ids)))]))
|
||||
|
||||
(define (id-to-variable int-id exports knowns mutated extra-variables)
|
||||
(export-id
|
||||
(or (hash-ref exports int-id #f)
|
||||
|
|
Loading…
Reference in New Issue
Block a user