1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Include nfree in closure-ref, closure-set primcall params

* module/language/cps/closure-conversion.scm (convert-one): Add nfree to
the param.  This will help the wasm target.
* module/language/cps/effects-analysis.scm (closure-ref, closure-set!):
* module/language/cps/lower-primcalls.scm (closure-ref,closure-set!):
Adapt.
This commit is contained in:
Andy Wingo 2023-07-04 11:01:50 +02:00
parent 018c5b9ad9
commit d66c1c67a0
3 changed files with 10 additions and 6 deletions

View file

@ -526,7 +526,7 @@ Otherwise @var{var} is bound, so @var{k} is called with @var{var}."
(ref (cond
((not self-known?)
(build-exp
($primcall 'closure-ref idx (self))))
($primcall 'closure-ref `(,idx . ,nfree) (self))))
((= nfree 2)
(build-exp
($primcall (match idx (0 'car) (1 'cdr)) #f
@ -628,7 +628,7 @@ bound to @var{closure}, and continue to @var{k}."
((not known?)
(lambda (idx val)
(build-exp
($primcall 'closure-set! idx (closure val)))))
($primcall 'closure-set! `(,idx . ,count) (closure val)))))
((= count 2)
(lambda (idx val)
(match idx

View file

@ -483,8 +483,12 @@ the LABELS that are clobbered by the effects of LABEL."
((string-set! str idx cp) (&write-object &string))
((make-closure code) (&allocate &closure))
((closure-ref code) (&read-field &closure param))
((closure-set! code) (&write-field &closure param)))
((closure-ref code) (match param
((idx . nfree)
(&read-field &closure idx))))
((closure-set! code) (match param
((idx . nfree)
(&write-field &closure idx)))))
(define-primitive-effects* param
((allocate-words size) (&allocate (annotation->memory-kind param)))

View file

@ -551,7 +551,7 @@
($primcall 'allocate-words/immediate `(closure . ,nwords) ())))))
;; precondition: closure is closure, idx is in range
(define-primcall-lowerer (closure-ref cps k src idx (closure))
(define-primcall-lowerer (closure-ref cps k src (idx . nfree) (closure))
(let ((pos (+ idx 2)))
(with-cps cps
(build-term
@ -559,7 +559,7 @@
($primcall 'scm-ref/immediate `(closure . ,pos) (closure)))))))
;; precondition: closure is clodure, idx is in range
(define-primcall-lowerer (closure-set! cps k src idx (closure val))
(define-primcall-lowerer (closure-set! cps k src (idx . nfree) (closure val))
(let ((pos (+ idx 2)))
(with-cps cps
(build-term