mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 21:40:33 +02:00
Shuffle the first return value from truncating calls
* module/language/cps/slot-allocation.scm (allocate-slots): For truncating calls, shuffle the first return value (if any). Avoids frame size growth due to sparse locals, pegged where they were left by procedure call returns. With this patch, eval with $ktrunc nodes goes from 31 locals to 18 (similar to the size before adding $ktrunc nodes).
This commit is contained in:
parent
8a2d420f74
commit
ad4f6be137
1 changed files with 11 additions and 2 deletions
|
@ -497,8 +497,17 @@ are comparable with eqv?. A tmp slot may be used."
|
||||||
(result-vars (vector-ref defv (cfa-k-idx cfa kargs)))
|
(result-vars (vector-ref defv (cfa-k-idx cfa kargs)))
|
||||||
(value-slots (map (cut + proc-slot 1 <>)
|
(value-slots (map (cut + proc-slot 1 <>)
|
||||||
(iota (length result-vars))))
|
(iota (length result-vars))))
|
||||||
(result-live (fold allocate!
|
;; Shuffle the first result down to the lowest slot, and
|
||||||
post-live result-vars value-slots))
|
;; leave any remaining results where they are. This
|
||||||
|
;; strikes a balance between avoiding shuffling,
|
||||||
|
;; especially for unused extra values, and avoiding
|
||||||
|
;; frame size growth due to sparse locals.
|
||||||
|
(result-live (match (cons result-vars value-slots)
|
||||||
|
((() . ()) post-live)
|
||||||
|
(((var . vars) . (slot . slots))
|
||||||
|
(fold allocate!
|
||||||
|
(allocate! var #f post-live)
|
||||||
|
vars slots))))
|
||||||
(result-slots (map (cut vector-ref slots <>) result-vars))
|
(result-slots (map (cut vector-ref slots <>) result-vars))
|
||||||
;; Filter out unused results.
|
;; Filter out unused results.
|
||||||
(value-slots (filter-map (lambda (val result) (and result val))
|
(value-slots (filter-map (lambda (val result) (and result val))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue