]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/compiler/cfg/build-stack-frame/build-stack-frame.factor
factor: trim using lists
[factor.git] / basis / compiler / cfg / build-stack-frame / build-stack-frame.factor
index 99dc7661d3adfbe97abf28f29da0db467dfe80a4..96d4f881a8cb05b40f591169eba0028129fb3773 100644 (file)
@@ -1,31 +1,25 @@
 ! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors compiler.cfg.instructions compiler.cfg.rpo
-compiler.cfg.stack-frame cpu.architecture kernel layouts locals
-math math.order namespaces sequences ;
+USING: accessors compiler.cfg.instructions
+compiler.cfg.linearization cpu.architecture kernel layouts math
+math.order namespaces sequences ;
 IN: compiler.cfg.build-stack-frame
 
-SYMBOLS: param-area-size allot-area-size allot-area-align
-frame-required? ;
+SYMBOLS: param-area-size allot-area-size allot-area-align ;
 
-: frame-required ( -- ) frame-required? on ;
+GENERIC: compute-stack-frame* ( insn -- ? )
 
-GENERIC: compute-stack-frame* ( insn -- )
-
-M:: ##local-allot compute-stack-frame* ( insn -- )
-    frame-required
+M:: ##local-allot compute-stack-frame* ( insn -- ? )
     insn size>> :> s
     insn align>> :> a
     allot-area-align [ a max ] change
-    allot-area-size [ a align [ insn offset<< ] [ s + ] bi ] change ;
+    allot-area-size [ a align [ insn offset<< ] [ s + ] bi ] change ;
 
 M: alien-call-insn compute-stack-frame*
-    frame-required
-    stack-size>> param-area-size [ max ] change ;
+    stack-size>> param-area-size [ max ] change t ;
 
-: vm-frame-required ( -- )
-    frame-required
-    vm-stack-space param-area-size [ max ] change ;
+: vm-frame-required ( -- ? )
+    vm-stack-space param-area-size [ max ] change t ;
 
 M: ##call-gc compute-stack-frame* drop vm-frame-required ;
 M: ##box compute-stack-frame* drop vm-frame-required ;
@@ -34,17 +28,17 @@ M: ##box-long-long compute-stack-frame* drop vm-frame-required ;
 M: ##callback-inputs compute-stack-frame* drop vm-frame-required ;
 M: ##callback-outputs compute-stack-frame* drop vm-frame-required ;
 
-M: ##call compute-stack-frame* drop frame-required ;
-M: ##spill compute-stack-frame* drop frame-required ;
-M: ##reload compute-stack-frame* drop frame-required ;
+M: ##call compute-stack-frame* drop t ;
+M: ##spill compute-stack-frame* drop t ;
+M: ##reload compute-stack-frame* drop t ;
 
 M: ##float>integer compute-stack-frame*
-    drop integer-float-needs-stack-frame? [ frame-required ] when ;
+    drop integer-float-needs-stack-frame? ;
 
 M: ##integer>float compute-stack-frame*
-    drop integer-float-needs-stack-frame? [ frame-required ] when ;
+    drop integer-float-needs-stack-frame? ;
 
-M: insn compute-stack-frame* drop ;
+M: insn compute-stack-frame* drop ;
 
 : calculate-allot-area-base ( stack-frame -- n )
     [ params>> ] [ allot-area-align>> ] bi align ;
@@ -59,19 +53,14 @@ M: insn compute-stack-frame* drop ;
     dup calculate-spill-area-base >>spill-area-base
     dup stack-frame-size >>total-size ;
 
-: <stack-frame> ( cfg -- stack-frame )
-    stack-frame new
-        over spill-area-size>> >>spill-area-size
-        swap spill-area-align>> >>spill-area-align
+: compute-stack-frame ( cfg -- stack-frame/f )
+    dup cfg>insns f [ compute-stack-frame* or ] reduce [
+        stack-frame>>
         allot-area-size get >>allot-area-size
         allot-area-align get >>allot-area-align
         param-area-size get >>params
-        finalize-stack-frame ;
-
-: compute-stack-frame ( cfg -- stack-frame/f )
-    [ [ instructions>> [ compute-stack-frame* ] each ] each-basic-block ]
-    [ frame-required? get [ <stack-frame> ] [ drop f ] if ]
-    bi ;
+        finalize-stack-frame
+    ] [ drop f ] if ;
 
 : build-stack-frame ( cfg -- )
     0 param-area-size set