diff --git a/basis/compiler/cfg/build-stack-frame/build-stack-frame-docs.factor b/basis/compiler/cfg/build-stack-frame/build-stack-frame-docs.factor index 0c45b68201..f3a0a989a1 100644 --- a/basis/compiler/cfg/build-stack-frame/build-stack-frame-docs.factor +++ b/basis/compiler/cfg/build-stack-frame/build-stack-frame-docs.factor @@ -16,4 +16,8 @@ HELP: compute-stack-frame { $description "Initializes a stack frame for a cfg, if it needs one." } { $see-also frame-required? } ; +HELP: finalize-stack-frame +{ $values { "stack-frame" stack-frame } } +{ $description "Calculates and stores the " { $slot "allot-area-base" } ", " { $slot "spill-area-base" } " and " { $slot "total-size" } " slots of a stack frame." } ; + ABOUT: "compiler.cfg.build-stack-frame" diff --git a/basis/compiler/cfg/build-stack-frame/build-stack-frame-tests.factor b/basis/compiler/cfg/build-stack-frame/build-stack-frame-tests.factor index a585400eae..c60a44ab53 100644 --- a/basis/compiler/cfg/build-stack-frame/build-stack-frame-tests.factor +++ b/basis/compiler/cfg/build-stack-frame/build-stack-frame-tests.factor @@ -1,6 +1,5 @@ -USING: accessors compiler.cfg compiler.cfg.build-stack-frame -compiler.cfg.instructions compiler.cfg.stack-frame cpu.x86 kernel layouts -math slots.syntax system tools.test ; +USING: compiler.cfg.build-stack-frame compiler.cfg.stack-frame +cpu.x86 math slots.syntax tools.test ; IN: compiler.cfg.build-stack-frame.tests { @@ -17,7 +16,7 @@ IN: compiler.cfg.build-stack-frame.tests { allot-area-size 10 } { spill-area-align 8 } { spill-area-size 16 } - } dup finalize-stack-frame + } finalize-stack-frame slots[ allot-area-base spill-area-base total-size ] ! Exclude any reserved stack space 32 bytes on win64, 0 bytes ! on all other platforms. diff --git a/basis/compiler/cfg/build-stack-frame/build-stack-frame.factor b/basis/compiler/cfg/build-stack-frame/build-stack-frame.factor index 6b7eb4546e..7ea0e71f2c 100644 --- a/basis/compiler/cfg/build-stack-frame/build-stack-frame.factor +++ b/basis/compiler/cfg/build-stack-frame/build-stack-frame.factor @@ -56,6 +56,11 @@ M: insn compute-stack-frame* drop ; [ allot-area-size>> + ] [ spill-area-align>> ] tri align ; +: finalize-stack-frame ( stack-frame -- stack-frame ) + dup calculate-allot-area-base >>allot-area-base + dup calculate-spill-area-base >>spill-area-base + dup stack-frame-size >>total-size ; + : ( cfg -- stack-frame ) stack-frame new over spill-area-size>> >>spill-area-size @@ -63,9 +68,7 @@ M: insn compute-stack-frame* drop ; allot-area-size get >>allot-area-size allot-area-align get >>allot-area-align param-area-size get >>params - dup calculate-allot-area-base >>allot-area-base - dup calculate-spill-area-base >>spill-area-base - dup stack-frame-size >>total-size ; + finalize-stack-frame ; : compute-stack-frame ( cfg -- stack-frame/f ) [ [ instructions>> [ compute-stack-frame* ] each ] each-basic-block ]