From 0a30bd9218a4b757d42e333f89071c6fa4a0e5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Sat, 15 Nov 2014 07:14:47 +0100 Subject: [PATCH] compiler.cfg.stack-frame: stub docs and tests for vocab --- .../cfg/stack-frame/stack-frame-docs.factor | 33 +++++++++++++++++-- .../cfg/stack-frame/stack-frame-tests.factor | 19 +++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 basis/compiler/cfg/stack-frame/stack-frame-tests.factor diff --git a/basis/compiler/cfg/stack-frame/stack-frame-docs.factor b/basis/compiler/cfg/stack-frame/stack-frame-docs.factor index f284ce2b7c..cf2dfc01b9 100644 --- a/basis/compiler/cfg/stack-frame/stack-frame-docs.factor +++ b/basis/compiler/cfg/stack-frame/stack-frame-docs.factor @@ -1,10 +1,37 @@ -USING: help.markup help.syntax ; +USING: cpu.x86 help.markup help.syntax layouts math ; IN: compiler.cfg.stack-frame HELP: stack-frame -{ $class-description "Counts of, among other things, how much stack a compiled word needs. It has the following slots:" +{ $class-description "Counts of, among other things, how much stack a compiled word needs. The stack frame is organized in the following fashion:" + { $list + "Parameter space:" + "Allocation area: space for local allocations." + "Spill area: space for register spills." + { "Reserved stack space: only applicable on Windows x86.64. See " { $link reserved-stack-space } "." } + { "One final " { $link cell } " of padding." } + } + "The stack frame is also aligned to a 16 byte boundary. It has the following slots:" { $table { { $slot "total-size" } { "Total size of the stack frame." } } + { { $slot "allot-area-base" } { "Base offset of the allocation area." } } + { { $slot "allot-area-size" } { "Number of bytes requires for the allocation area." } } + { { $slot "allot-area-align" } { "This slot is always at least " { $link cell } " bytes." } } + { { $slot "spill-area-base" } { "Base offset for the spill area." } } { { $slot "spill-area-size" } { "Number of bytes requires for all spill slots." } } + { { $slot "spill-area-align" } { "This slot is always at least " { $link cell } " bytes." } } } -} ; +} +{ $see-also align-stack } ; + +HELP: (stack-frame-size) +{ $values { "stack-frame" stack-frame } { "n" integer } } +{ $description "Base stack frame size, without padding and alignment." } ; + +HELP: spill-offset +{ $values { "n" integer } { "offset" integer } } +{ $description "Offset in the current " { $link stack-frame } " to byte at index 'n' in the spill area." } ; + +ARTICLE: "compiler.cfg.stack-frame" "Stack frames" +"This vocab contains definitions for constructing stack frames." ; + +ABOUT: "compiler.cfg.stack-frame" diff --git a/basis/compiler/cfg/stack-frame/stack-frame-tests.factor b/basis/compiler/cfg/stack-frame/stack-frame-tests.factor new file mode 100644 index 0000000000..f40003426e --- /dev/null +++ b/basis/compiler/cfg/stack-frame/stack-frame-tests.factor @@ -0,0 +1,19 @@ +USING: accessors compiler.cfg compiler.cfg.build-stack-frame +compiler.cfg.stack-frame kernel namespaces tools.test ; +IN: compiler.cfg.stack-frame.tests + +{ + 112 + ! 112 37 + + 149 +} [ + 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 + [ spill-area-base>> ] + [ stack-frame set 37 spill-offset ] bi +] unit-test