]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.stacks.local: replace-sets values must be hash-sets (#1507)
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 16 Mar 2016 15:29:49 +0000 (16:29 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Wed, 16 Mar 2016 15:32:50 +0000 (16:32 +0100)
The compiler hang was because { D: 3 D: 2 } was unequal to { D: 2 D: 3
}, so using a set should fix that.

basis/compiler/cfg/stacks/local/local-docs.factor
basis/compiler/cfg/stacks/local/local-tests.factor
basis/compiler/cfg/stacks/local/local.factor

index c971ff54de9db9771e3d1142a3c3ff45397625f0..a6e3580633f31742408997f53ac87771ec261202 100644 (file)
@@ -50,7 +50,7 @@ HELP: replace-loc
 { $see-also replaces } ;
 
 HELP: replace-sets
-{ $var-description "An " { $link assoc } " that maps from basic blocks to stack locations." } ;
+{ $var-description "An " { $link assoc } " in which each key is a " { $link basic-block } " and each value a " { $link hash-set } " with locations that were replaced in that block." } ;
 
 HELP: replaces
 { $var-description "An " { $link assoc } " that maps from stack locations to virtual registers that were put on the stack." }
index b71a777c202ddc3c2d6a0ce1ad4e89ef147743c1..bb87ec54f1926803c348bad84acdd84e240257eb 100644 (file)
@@ -1,7 +1,8 @@
-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 make namespaces kernel tools.test ;
+USING: assocs compiler.cfg.instructions compiler.cfg.registers
+compiler.cfg.stacks.height compiler.cfg.stacks.local
+compiler.cfg.utilities compiler.test cpu.architecture kernel
+kernel.private make math namespaces sequences.private slots.private
+tools.test ;
 QUALIFIED: sets
 IN: compiler.cfg.stacks.local.tests
 
@@ -29,7 +30,7 @@ IN: compiler.cfg.stacks.local.tests
 ! end-local-analysis
 {
     HS{ }
-    { }
+    HS{ }
     HS{ }
 } [
     V{ } 137 insns>block
@@ -39,7 +40,7 @@ IN: compiler.cfg.stacks.local.tests
 ] cfg-unit-test
 
 {
-    { D: 3 }
+    HS{ D: 3 }
 } [
     V{ } 137 insns>block
     [ 0 0 rot record-stack-heights ]
@@ -115,3 +116,43 @@ IN: compiler.cfg.stacks.local.tests
 { H{ { D: -1 40 } } } [
     D: 1 inc-stack 40 D: 0 replace-loc replaces get
 ] cfg-unit-test
+
+! Compiling these words used to make the compiler hang due to a bug in
+! end-local-analysis. So the test is just to compile them and if it
+! doesn't hang, the bug is fixed! See #1507
+: my-new-key4 ( a i j -- i/j )
+    2over
+    slot
+    swap over
+    ! a i el j el
+    [
+        ! a i el j
+        swap
+        ! a i j el
+        77 eq?
+        [
+            rot drop and
+        ]
+        [
+            ! a i j
+            over or my-new-key4
+        ] if
+    ]
+    [
+        ! a i el j
+        2drop t
+        ! a i t
+        my-new-key4
+    ] if ; inline recursive
+
+: badword ( y -- )
+    0 swap dup
+    { integer object } declare
+    [
+        { array-capacity object } declare nip
+        1234 1234 pick
+        f
+        my-new-key4
+        set-slot
+    ]
+    curry (each-integer) ;
index 2e4b9ecddeed384b8e2489f4c34fd48b6b10f514..841f13e2c1a1ec4e885f260026ebd6d5f83c796b 100644 (file)
@@ -85,7 +85,7 @@ SYMBOLS: local-peek-set replaces ;
     [
         replaces get remove-redundant-replaces
         [ height-state get emit-changes ]
-        [ keys swap replace-sets get set-at ] bi
+        [ keys >hash-set swap replace-sets get set-at ] bi
     ]
     [ [ local-peek-set get ] dip peek-sets get set-at ]
     [ [ compute-local-kill-set ] keep kill-sets get set-at ] tri ;