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 new file mode 100644 index 0000000000..77b84ab6ad --- /dev/null +++ b/basis/compiler/cfg/build-stack-frame/build-stack-frame-docs.factor @@ -0,0 +1,19 @@ +USING: assocs compiler.cfg compiler.cfg.stack-frame help.markup help.syntax ; +IN: compiler.cfg.build-stack-frame + +ARTICLE: "compiler.cfg.build-stack-frame" "Computing stack frame size and layout" +"The " { $vocab-link "compiler.cfg.build-stack-frame" } " vocab builds stack frames for cfg:s." ; + +HELP: frame-required? +{ $var-description "Whether the word being compiled requires a stack frame or not. Most words does, but very simple words does not." } ; + +HELP: compute-stack-frame +{ $values { "cfg" cfg } { "stack-frame/f" 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 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 new file mode 100644 index 0000000000..760be82c09 --- /dev/null +++ b/basis/compiler/cfg/build-stack-frame/build-stack-frame-tests.factor @@ -0,0 +1,22 @@ +USING: accessors compiler.cfg compiler.cfg.build-stack-frame +compiler.cfg.instructions compiler.cfg.stack-frame kernel slots.syntax +tools.test ; +IN: compiler.cfg.build-stack-frame.tests + +{ + ! 91 8 align + 96 + ! 91 8 align 16 + + 112 + ! 91 8 align 16 + 16 8 align + cell + 16 align + 144 +} [ + T{ stack-frame + { params 91 } + { allot-area-align 8 } + { allot-area-size 10 } + { spill-area-align 8 } + { spill-area-size 16 } + } dup finalize-stack-frame + slots[ allot-area-base spill-area-base total-size ] +] unit-test