compiler.cfg.build-stack-frame: fix tests.

db4
John Benediktsson 2014-12-12 15:22:22 -08:00
parent e576fb5fec
commit 1911b183a0
3 changed files with 13 additions and 7 deletions

View File

@ -16,4 +16,8 @@ HELP: compute-stack-frame
{ $description "Initializes a stack frame for a cfg, if it needs one." } { $description "Initializes a stack frame for a cfg, if it needs one." }
{ $see-also frame-required? } ; { $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" ABOUT: "compiler.cfg.build-stack-frame"

View File

@ -1,6 +1,5 @@
USING: accessors compiler.cfg compiler.cfg.build-stack-frame USING: compiler.cfg.build-stack-frame compiler.cfg.stack-frame
compiler.cfg.instructions compiler.cfg.stack-frame cpu.x86 kernel layouts cpu.x86 math slots.syntax tools.test ;
math slots.syntax system tools.test ;
IN: compiler.cfg.build-stack-frame.tests IN: compiler.cfg.build-stack-frame.tests
{ {
@ -17,7 +16,7 @@ IN: compiler.cfg.build-stack-frame.tests
{ allot-area-size 10 } { allot-area-size 10 }
{ spill-area-align 8 } { spill-area-align 8 }
{ spill-area-size 16 } { spill-area-size 16 }
} dup finalize-stack-frame } finalize-stack-frame
slots[ allot-area-base spill-area-base total-size ] slots[ allot-area-base spill-area-base total-size ]
! Exclude any reserved stack space 32 bytes on win64, 0 bytes ! Exclude any reserved stack space 32 bytes on win64, 0 bytes
! on all other platforms. ! on all other platforms.

View File

@ -56,6 +56,11 @@ M: insn compute-stack-frame* drop ;
[ allot-area-size>> + ] [ allot-area-size>> + ]
[ spill-area-align>> ] tri align ; [ 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 ;
: <stack-frame> ( cfg -- stack-frame ) : <stack-frame> ( cfg -- stack-frame )
stack-frame new stack-frame new
over spill-area-size>> >>spill-area-size 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-size get >>allot-area-size
allot-area-align get >>allot-area-align allot-area-align get >>allot-area-align
param-area-size get >>params param-area-size get >>params
dup calculate-allot-area-base >>allot-area-base finalize-stack-frame ;
dup calculate-spill-area-base >>spill-area-base
dup stack-frame-size >>total-size ;
: compute-stack-frame ( cfg -- stack-frame/f ) : compute-stack-frame ( cfg -- stack-frame/f )
[ [ instructions>> [ compute-stack-frame* ] each ] each-basic-block ] [ [ instructions>> [ compute-stack-frame* ] each ] each-basic-block ]