]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.stacks.local: to simplify, end-local-analysis can take the block it...
authorBjörn Lindqvist <bjourne@gmail.com>
Tue, 31 Mar 2015 23:34:56 +0000 (01:34 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 29 Apr 2015 16:31:56 +0000 (09:31 -0700)
basis/compiler/cfg/builder/blocks/blocks.factor
basis/compiler/cfg/stacks/global/global.factor
basis/compiler/cfg/stacks/local/local-tests.factor
basis/compiler/cfg/stacks/local/local.factor

index 7935f950727577346a2053d070080cc1086149ba..752fce65343dcfca2dd69b7196fdf414a6249f91 100644 (file)
@@ -12,7 +12,7 @@ IN: compiler.cfg.builder.blocks
     begin-local-analysis ;
 
 : end-basic-block ( -- )
-    basic-block get [ end-local-analysis ] when
+    basic-block get [ end-local-analysis ] when*
     building off
     basic-block off ;
 
@@ -20,7 +20,7 @@ IN: compiler.cfg.builder.blocks
     <basic-block> basic-block get [ over connect-bbs ] when* set-basic-block ;
 
 : begin-basic-block ( -- )
-    basic-block get [ end-local-analysis ] when
+    basic-block get [ end-local-analysis ] when*
     (begin-basic-block) ;
 
 : emit-trivial-block ( quot -- )
@@ -50,7 +50,7 @@ IN: compiler.cfg.builder.blocks
         ##branch,
         end-local-analysis
         height-state get clone-height-state 2array
-    ] when ;
+    ] when* ;
 
 : with-branch ( quot -- pair/f )
     [ begin-branch call end-branch ] with-scope ; inline
index d1164f871a4c3c0f2477775a5124f497dba4210a..b1327169b91487ca5e44ea0a50529380fc65bfda 100644 (file)
@@ -1,9 +1,13 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs combinators compiler.cfg.dataflow-analysis
-compiler.cfg.stacks.local kernel ;
+compiler.cfg.stacks.local kernel namespaces ;
 IN: compiler.cfg.stacks.global
 
+: peek-set ( bb -- assoc ) peek-sets get at ;
+: replace-set ( bb -- assoc ) replace-sets get at ;
+: kill-set ( bb -- assoc ) kill-sets get at ;
+
 : transfer-peeked-locs ( assoc bb -- assoc' )
     [ replace-set assoc-diff ] [ peek-set assoc-union ] bi ;
 
index c7ea737f2bd20527624dde2bcef0d99c5412a0a4..a4cb7938a54caf09e94a18c9458d5ee824034cf5 100644 (file)
@@ -1,9 +1,41 @@
 USING: accessors assocs biassocs combinators compiler.cfg
 compiler.cfg.instructions compiler.cfg.registers compiler.cfg.stacks
 compiler.cfg.stacks.height compiler.cfg.stacks.local compiler.cfg.utilities
-compiler.test cpu.architecture namespaces kernel tools.test ;
+compiler.test cpu.architecture make namespaces kernel tools.test ;
 IN: compiler.cfg.stacks.local.tests
 
+! loc>vreg
+{ 1 } [
+    D 0 loc>vreg
+] cfg-unit-test
+
+! stack-changes
+{
+    {
+        T{ ##copy { dst 1 } { src 25 } { rep any-rep } }
+        T{ ##copy { dst 2 } { src 26 } { rep any-rep } }
+    }
+} [
+    { { D 0 25 } { R 0 26 } } stack-changes
+] cfg-unit-test
+
+! replace-loc
+{ 80 } [
+    80 D 77 replace-loc
+    D 77 peek-loc
+] cfg-unit-test
+
+! end-local-analysis
+{
+    H{ }
+    H{ }
+    H{ }
+} [
+    "foo" [ "eh" , end-local-analysis ] V{ } make drop
+    "foo" [ peek-sets ] [ replace-sets ] [ kill-sets ] tri [ get at ] 2tri@
+] cfg-unit-test
+
+! height-state
 {
     { { 3 3 } { 0 0 } }
 } [
@@ -23,23 +55,7 @@ IN: compiler.cfg.stacks.local.tests
     { { 0 4  } { 0 -2 } } height-state>insns
 ] unit-test
 
-{ 1 } [
-    D 0 loc>vreg
-] cfg-unit-test
 
-{
-    {
-        T{ ##copy { dst 1 } { src 25 } { rep any-rep } }
-        T{ ##copy { dst 2 } { src 26 } { rep any-rep } }
-    }
-} [
-    { { D 0 25 } { R 0 26 } } stack-changes
-] cfg-unit-test
-
-{ 80 } [
-    80 D 77 replace-loc
-    D 77 peek-loc
-] cfg-unit-test
 
 { H{ { D -1 40 } } } [
     D 1 inc-stack 40 D 0 replace-loc replace-mapping get
index 3d7e1198b5f0cbe197e1a633f02a37c51db7ad26..6c38dbad69b449f428107fe01a2798c507c1baa1 100644 (file)
@@ -84,15 +84,9 @@ SYMBOLS: local-peek-set local-replace-set replace-mapping ;
     replace-mapping get [ [ loc>vreg ] dip = not ] assoc-filter
     [ replace-mapping set ] [ keys unique local-replace-set set ] bi ;
 
-: end-local-analysis ( -- )
+: end-local-analysis ( basic-block -- )
     remove-redundant-replaces
     emit-changes
-    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 ;
-
-: peek-set ( bb -- assoc ) peek-sets get at ;
-: replace-set ( bb -- assoc ) replace-sets get at ;
-: kill-set ( bb -- assoc ) kill-sets get at ;
+    [ [ 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 ] tri ;