]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.stacks.*: possible fix for #1289
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 8 Apr 2015 06:08:17 +0000 (08:08 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 29 Apr 2015 16:31:56 +0000 (09:31 -0700)
instead of delaying outputting ##replace instructions to when they are
needed, output them directly in the block so that "holes" in the
stacks are avoided.

basis/compiler/cfg/builder/builder-tests.factor
basis/compiler/cfg/intrinsics/simd/simd-tests.factor
basis/compiler/cfg/stacks/finalize/finalize.factor
basis/compiler/cfg/stacks/local/local-tests.factor
basis/compiler/cfg/stacks/local/local.factor
extra/tools/gc-decode/gc-decode-tests.factor

index ac91bfe9876e6546852e1703fd8d1a8927045b37..c8c314c7772991ee951c034d601ccb645c33a6fd 100644 (file)
@@ -199,8 +199,7 @@ IN: compiler.cfg.builder.tests
 ] unit-test
 
 [ f ] [
-    [ 1000 [ ] times ]
-    [ [ ##peek? ] [ ##replace? ] bi or ] contains-insn?
+    [ 1000 [ ] times ] [ ##peek? ] contains-insn?
 ] unit-test
 
 [ f t ] [
index 2a1cf6aad76e5972889f913e8843623f6e07d264..8d5cc8b4dbd4cd2be2fc4a013b6f3187e138be0e 100644 (file)
@@ -55,8 +55,8 @@ IN: compiler.cfg.intrinsics.simd.tests
     [ 0 swap associate \ ds-heights pick set-at ]
     [ 0 swap associate \ rs-heights pick set-at ] tri
     initial-height-state \ height-state pick set-at
-    H{ } clone \ local-peek-set pick set-at
-    H{ } clone \ replace-mapping pick set-at
+    HS{ } clone \ local-peek-set pick set-at
+    H{ } clone \ replaces pick set-at
     H{ } <biassoc> \ locs>vregs pick set-at
     H{ } clone \ peek-sets pick set-at
     H{ } clone \ replace-sets pick set-at
index 210c9787729db95cf38b6dd5af1dcd1596a40c4c..9b26728fbca518c679923824b8a42e925fed9232 100644 (file)
@@ -27,8 +27,7 @@ ERROR: bad-peek dst loc ;
     [ dup n>> 0 < [ bad-peek ] [ ##peek, ] if ] each-insertion ;
 
 : insert-replaces ( from to -- )
-    [ inserting-replaces ] keep
-    [ dup n>> 0 < [ 2drop ] [ ##replace, ] if ] each-insertion ;
+    2drop ;
 
 : visit-edge ( from to -- )
     ! If both blocks are subroutine calls, don't bother
index c85f98110a99afae4a1a03c7f34932526c16bf4d..d9e5ab7ef5ab8d0bbaf6e381f2c016e2061cb8b4 100644 (file)
@@ -58,7 +58,11 @@ IN: compiler.cfg.stacks.local.tests
 
 ! emit-changes
 {
-    V{ T{ ##copy { dst 1 } { src 3 } { rep any-rep } } "eh" }
+    V{
+        T{ ##copy { dst 1 } { src 3 } { rep any-rep } }
+        T{ ##replace { src 1 } { loc D 0 } }
+        "eh"
+    }
 } [
     3 D 0 replace-loc [
         "eh",
index f8d9c7ec5b31eb6d43e5c546885837aebd22bbb3..f6d354dc623d68a5c79d5bffa9e56461f4b07d7a 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors arrays assocs combinators compiler.cfg
 compiler.cfg.instructions compiler.cfg.parallel-copy
 compiler.cfg.registers compiler.cfg.stacks.height
-hash-sets kernel make math math.order namespaces sequences sets ;
+fry hash-sets kernel make math math.order namespaces sequences sets ;
 FROM: namespaces => set ;
 IN: compiler.cfg.stacks.local
 
@@ -29,6 +29,9 @@ IN: compiler.cfg.stacks.local
 : translate-local-loc ( loc state -- loc' )
     [ clone ] dip over >loc< 0 1 ? rot nth first - >>n ;
 
+: untranslate-local-loc ( loc state -- loc' )
+    [ clone ] dip over >loc< 0 1 ? rot nth first + >>n ;
+
 : clone-height-state ( state -- state' )
     [ clone ] map ;
 
@@ -56,8 +59,15 @@ SYMBOLS: local-peek-set replaces ;
 : replaces>copy-insns ( replaces -- insns )
     [ [ loc>vreg ] dip ] assoc-map parallel-copy ;
 
+: replaces>replace-insns ( replaces height-state -- insns )
+    [ keys ] dip
+    '[ [ loc>vreg ] [ _ untranslate-local-loc ] bi f ##replace boa ] map
+    [ loc>> n>> 0 >= ] filter ;
+
 : changes>insns ( replaces height-state -- insns )
-    [ replaces>copy-insns ] [ height-state>insns ] bi* append ;
+    [ drop replaces>copy-insns ]
+    [ nip height-state>insns ]
+    [ replaces>replace-insns ] 2tri 3append ;
 
 : emit-changes ( replaces height-state -- )
     building get pop -rot changes>insns % , ;
index cb3a3df5f18d0a18e02b212fb76056367315a643..22041fca867e13ca8bdcf73f58ac71d25994458e 100644 (file)
@@ -24,14 +24,6 @@ IN: tools.gc-decode.tests
 { ?{ t t t t t t t t } } [ B{ 255 } byte-array>bit-array ] unit-test
 
 ! scrub-bits
-{ t } [
-    \ effects:<effect> word>gc-info scrub-bits
-    {
-        ?{ t t t f t t t t } ! 64-bit
-        ?{ t t t t f f f f f t t t t } ! 32-bit TODO
-    } member?
-] unit-test
-
 {
     { }
 } [