]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.stacks.*: use insn# as the key in the stack-record instead of the insn...
authorBjörn Lindqvist <bjourne@gmail.com>
Mon, 19 Jan 2015 10:08:06 +0000 (10:08 +0000)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 22 Jan 2015 20:17:21 +0000 (12:17 -0800)
basis/compiler/cfg/stacks/map/map.factor
basis/compiler/cfg/stacks/vacant/vacant.factor

index 0ad9a7e2ea4b2f40ebd80762607f87bf56b642db..10f62d4dc10b941cb894e4990a34c1692f9564cd 100644 (file)
@@ -1,6 +1,6 @@
 USING: accessors arrays assocs combinators compiler.cfg.dataflow-analysis
-compiler.cfg.instructions compiler.cfg.registers fry kernel math math.order
-namespaces sequences ;
+compiler.cfg.instructions compiler.cfg.linearization compiler.cfg.registers fry
+kernel math math.order namespaces sequences ;
 QUALIFIED: sets
 IN: compiler.cfg.stacks.map
 
@@ -61,9 +61,12 @@ FORWARD-ANALYSIS: map
 
 SYMBOL: stack-record
 
+: register-stack-state ( state insn -- )
+    insn#>> stack-record get 2dup at f assert= set-at ;
+
 M: map-analysis transfer-set ( in-set bb dfa -- out-set )
     drop instructions>> swap [
-        [ stack-record get set-at ] [ visit-insn ] 2bi
+        [ register-stack-state ] [ visit-insn ] 2bi
     ] reduce ;
 
 M: map-analysis ignore-block? ( bb dfa -- ? )
@@ -73,5 +76,10 @@ M: map-analysis ignore-block? ( bb dfa -- ? )
 M: map-analysis join-sets ( sets bb dfa -- set )
     2drop [ initial-state ] [ first ] if-empty ;
 
+: uniquely-number-instructions ( cfg -- )
+    cfg>insns [ swap insn#<< ] each-index ;
+
 : trace-stack-state ( cfg -- assoc )
-    H{ } clone stack-record set compute-map-sets stack-record get ;
+    H{ } clone stack-record set
+    [ uniquely-number-instructions ] [ compute-map-sets ] bi
+    stack-record get ;
index 002bbef51fe1f973fd28b759ebfba86e00b628ea..de9663dc98add1d776a057352d1fee9bbaac5e13 100644 (file)
@@ -1,5 +1,5 @@
 USING: accessors arrays assocs compiler.cfg.instructions
-compiler.cfg.stacks.map fry kernel math sequences ;
+compiler.cfg.linearization compiler.cfg.stacks.map fry kernel math sequences ;
 IN: compiler.cfg.stacks.vacant
 
 ! ! Utils
@@ -31,5 +31,5 @@ IN: compiler.cfg.stacks.vacant
     { >>scrub-d >>check-d >>scrub-r >>check-r } write-slots ;
 
 : fill-gc-maps ( cfg -- )
-    trace-stack-state [ drop gc-map-insn? ] assoc-filter
-    [ swap gc-map>> set-gc-map ] assoc-each ;
+    [ trace-stack-state ] [ cfg>insns [ gc-map-insn? ] filter ] bi
+    [ [ insn#>> of ] [ gc-map>> ] bi set-gc-map ] with each ;