]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/compiler/cfg/build-stack-frame/build-stack-frame.factor
FFI rewrite part 5: return value boxing and callback parameter boxing now uses vregs...
[factor.git] / basis / compiler / cfg / build-stack-frame / build-stack-frame.factor
index 747e0f54cfe0c51a4ba00776727a60e35da04a3b..1fc9e5ed7846b0a976604ed7fc044847514b6fd3 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces accessors math.order assocs kernel sequences
+USING: namespaces accessors math math.order assocs kernel sequences
 combinators classes words cpu.architecture layouts compiler.cfg
 compiler.cfg.rpo compiler.cfg.instructions
 compiler.cfg.registers compiler.cfg.stack-frame ;
@@ -17,13 +17,15 @@ GENERIC: compute-stack-frame* ( insn -- )
 M: ##stack-frame compute-stack-frame*
     stack-frame>> request-stack-frame ;
 
-M: ##call compute-stack-frame* drop frame-required? on ;
-
 M: ##call-gc compute-stack-frame*
     drop
     frame-required? on
     stack-frame new t >>calls-vm? request-stack-frame ;
 
+M: ##call compute-stack-frame* drop frame-required? on ;
+
+M: ##alien-callback compute-stack-frame* drop frame-required? on ;
+
 M: insn compute-stack-frame*
     class "frame-required?" word-prop
     [ frame-required? on ] when ;
@@ -31,10 +33,10 @@ M: insn compute-stack-frame*
 : initial-stack-frame ( -- stack-frame )
     stack-frame new cfg get spill-area-size>> >>spill-area-size ;
 
-: compute-stack-frame ( insns -- )
-    frame-required? off
+: compute-stack-frame ( cfg -- )
     initial-stack-frame stack-frame set
-    [ instructions>> [ compute-stack-frame* ] each ] each-basic-block
+    [ spill-area-size>> 0 > frame-required? set ]
+    [ [ instructions>> [ compute-stack-frame* ] each ] each-basic-block ] bi
     stack-frame get dup stack-frame-size >>total-size drop ;
 
 : build-stack-frame ( cfg -- cfg )