]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.stacks: kill set now includes all locations eliminated as a result of...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 1 Aug 2009 11:12:43 +0000 (06:12 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 1 Aug 2009 11:12:43 +0000 (06:12 -0500)
basis/compiler/cfg/stacks/global/global.factor
basis/compiler/cfg/stacks/local/local.factor
basis/compiler/cfg/stacks/stacks.factor

index 129d7e74cdc62910f7be2eddc9fb10ba7e7e2ade..2062815787bbe8bf1a97b4fa1f6b820d3c1993ca 100644 (file)
@@ -26,7 +26,7 @@ M: avail-analysis transfer-set drop [ peek-set ] [ replace-set ] bi assoc-union
 ! which are going to be overwritten.
 BACKWARD-ANALYSIS: kill
 
-M: kill-analysis transfer-set drop replace-set assoc-union ;
+M: kill-analysis transfer-set drop kill-set assoc-union ;
 
 ! Main word
 : compute-global-sets ( cfg -- cfg' )
index 754789042a079c063fb99d48a57e3b7c149fb81b..4d3ed36be9c941fe9b408971a84d0de6724f604e 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs kernel math namespaces sets make sequences
+USING: accessors assocs kernel math math.order namespaces sets make
+sequences combinators fry
 compiler.cfg
 compiler.cfg.hats
 compiler.cfg.instructions
@@ -12,14 +13,18 @@ IN: compiler.cfg.stacks.local
 ! Local stack analysis. We build local peek and replace sets for every basic
 ! block while constructing the CFG.
 
-SYMBOLS: peek-sets replace-sets ;
+SYMBOLS: peek-sets replace-sets kill-sets ;
 
 SYMBOL: locs>vregs
 
 : loc>vreg ( loc -- vreg ) locs>vregs get [ drop i ] cache ;
 : vreg>loc ( vreg -- loc/f ) locs>vregs get value-at ;
 
-TUPLE: current-height { d initial: 0 } { r initial: 0 } { emit-d initial: 0 } { emit-r initial: 0 } ;
+TUPLE: current-height
+{ d initial: 0 }
+{ r initial: 0 }
+{ emit-d initial: 0 }
+{ emit-r initial: 0 } ;
 
 SYMBOLS: local-peek-set local-replace-set replace-mapping ;
 
@@ -72,20 +77,32 @@ M: rs-loc translate-local-loc n>> current-height get r>> - <rs-loc> ;
         bi
     ] if ;
 
+: compute-local-kill-set ( -- assoc )
+    basic-block get current-height get
+    [ [ ds-heights get at dup ] [ d>> ] bi* [-] iota [ swap - <ds-loc> ] with map ]
+    [ [ rs-heights get at dup ] [ r>> ] bi* [-] iota [ swap - <rs-loc> ] with map ]
+    [ drop local-replace-set get at ] 2tri
+    [ append unique dup ] dip update ;
+
 : begin-local-analysis ( -- )
     H{ } clone local-peek-set set
     H{ } clone local-replace-set set
     H{ } clone replace-mapping set
-    current-height get 0 >>emit-d 0 >>emit-r drop
-    current-height get [ d>> ] [ r>> ] bi basic-block get record-stack-heights ;
+    current-height get
+    [ 0 >>emit-d 0 >>emit-r drop ]
+    [ [ d>> ] [ r>> ] bi basic-block get record-stack-heights ] bi ;
 
 : end-local-analysis ( -- )
     emit-changes
-    local-peek-set get basic-block get peek-sets get set-at
-    local-replace-set get basic-block get replace-sets get set-at ;
+    basic-block get {
+        [ [ local-peek-set get ] dip peek-sets get set-at ]
+        [ [ local-replace-set get ] dip replace-sets get set-at ]
+        [ [ compute-local-kill-set ] dip kill-sets get set-at ]
+    } cleave ;
 
 : clone-current-height ( -- )
     current-height [ clone ] change ;
 
 : peek-set ( bb -- assoc ) peek-sets get at ;
 : replace-set ( bb -- assoc ) replace-sets get at ;
+: kill-set ( bb -- assoc ) kill-sets get at ;
\ No newline at end of file
index 2683222fb8bc719e0c5eb7179dab3a04b186290d..1896b0a7fb5fb54e9b17657a7f12335f06cea695 100755 (executable)
@@ -13,6 +13,7 @@ IN: compiler.cfg.stacks
     H{ } clone rs-heights set
     H{ } clone peek-sets set
     H{ } clone replace-sets set
+    H{ } clone kill-sets set
     current-height new current-height set ;
 
 : end-stack-analysis ( -- )