mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 21:40:33 +02:00
All $values expressions go through allocate-values
* module/language/cps/slot-allocation.scm (allocate-slots): Make all $values expressions go through allocate-values, and refactor allocate-values.
This commit is contained in:
parent
c79f873eb1
commit
8a2d420f74
1 changed files with 33 additions and 19 deletions
|
@ -527,21 +527,38 @@ are comparable with eqv?. A tmp slot may be used."
|
||||||
(make-call-allocation proc-slot arg-moves))))))
|
(make-call-allocation proc-slot arg-moves))))))
|
||||||
|
|
||||||
(define (allocate-values label k uses pre-live post-live)
|
(define (allocate-values label k uses pre-live post-live)
|
||||||
(let* ((src-slots (map (cut vector-ref slots <>) uses))
|
(match (vector-ref contv (cfa-k-idx cfa k))
|
||||||
(dst-slots (match (vector-ref contv (cfa-k-idx cfa k))
|
(($ $ktail)
|
||||||
(($ $ktail)
|
(let* ((src-slots (map (cut vector-ref slots <>) uses))
|
||||||
(let ((tail-nlocals (1+ (length uses))))
|
(tail-nlocals (1+ (length uses)))
|
||||||
(bump-nlocals! tail-nlocals)
|
(dst-slots (cdr (iota tail-nlocals)))
|
||||||
(cdr (iota tail-nlocals))))
|
(moves (parallel-move src-slots dst-slots
|
||||||
(_
|
(compute-tmp-slot pre-live dst-slots))))
|
||||||
(let ((dst-vars (vector-ref defv (cfa-k-idx cfa k))))
|
(bump-nlocals! tail-nlocals)
|
||||||
(fold allocate! post-live dst-vars src-slots)
|
(hashq-set! call-allocations label
|
||||||
(map (cut vector-ref slots <>) dst-vars)))))
|
(make-call-allocation #f moves))))
|
||||||
(moves (parallel-move src-slots
|
(($ $kargs (_) (_))
|
||||||
dst-slots
|
;; When there is only one value in play, we allow the dst to be
|
||||||
(compute-tmp-slot pre-live dst-slots))))
|
;; hinted (see scan-for-hints). If the src doesn't have a
|
||||||
(hashq-set! call-allocations label
|
;; slot, then the actual slot for the dst would end up being
|
||||||
(make-call-allocation #f moves))))
|
;; decided by the call that uses it. Because we don't know the
|
||||||
|
;; slot, we can't really compute the parallel moves in that
|
||||||
|
;; case, so just bail and rely on the bytecode emitter to
|
||||||
|
;; handle the one-value case specially.
|
||||||
|
(match (cons uses (vector-ref defv (cfa-k-idx cfa k)))
|
||||||
|
(((src) . (dst))
|
||||||
|
(allocate! dst (vector-ref slots src) post-live))))
|
||||||
|
(($ $kargs)
|
||||||
|
(let* ((src-slots (map (cut vector-ref slots <>) uses))
|
||||||
|
(dst-vars (vector-ref defv (cfa-k-idx cfa k)))
|
||||||
|
(result-live (fold allocate! post-live dst-vars src-slots))
|
||||||
|
(dst-slots (map (cut vector-ref slots <>) dst-vars))
|
||||||
|
(moves (parallel-move src-slots dst-slots
|
||||||
|
(compute-tmp-slot (logior pre-live result-live)
|
||||||
|
'()))))
|
||||||
|
(hashq-set! call-allocations label
|
||||||
|
(make-call-allocation #f moves))))
|
||||||
|
(($ $kif) #f)))
|
||||||
|
|
||||||
(define (allocate-prompt label k handler nargs)
|
(define (allocate-prompt label k handler nargs)
|
||||||
(match (vector-ref contv (cfa-k-idx cfa handler))
|
(match (vector-ref contv (cfa-k-idx cfa handler))
|
||||||
|
@ -607,11 +624,8 @@ are comparable with eqv?. A tmp slot may be used."
|
||||||
(($ $continue k src ($ $call))
|
(($ $continue k src ($ $call))
|
||||||
(allocate-call label k uses live post-live))
|
(allocate-call label k uses live post-live))
|
||||||
(($ $continue k src ($ $primcall)) #t)
|
(($ $continue k src ($ $primcall)) #t)
|
||||||
;; We only need to make a call allocation if there
|
(($ $continue k src ($ $values))
|
||||||
;; are two or more values.
|
|
||||||
(($ $continue k src ($ $values (_ _ . _)))
|
|
||||||
(allocate-values label k uses live post-live))
|
(allocate-values label k uses live post-live))
|
||||||
(($ $continue k src ($ $values)) #t)
|
|
||||||
(($ $continue k src ($ $prompt escape? tag handler))
|
(($ $continue k src ($ $prompt escape? tag handler))
|
||||||
(allocate-prompt label k handler nargs))
|
(allocate-prompt label k handler nargs))
|
||||||
(_ #f)))
|
(_ #f)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue