]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg: Move tail call optimization to the end, compiler.tree: simplify finaliz...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 18 Jul 2009 03:57:28 +0000 (22:57 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 18 Jul 2009 03:57:28 +0000 (22:57 -0500)
basis/compiler/cfg/optimizer/optimizer.factor
basis/compiler/cfg/stack-analysis/stack-analysis-tests.factor
basis/compiler/tree/finalization/finalization.factor

index 1af0fcbc53df6392a425711b23aa1413a0361a9a..49a07de1e4ef761ea53283cf8a545a40a3a5c102 100644 (file)
@@ -28,7 +28,6 @@ SYMBOL: check-optimizer?
     ! Note that compute-predecessors has to be called several times.
     ! The passes that need this document it.
     [
-        optimize-tail-calls
         delete-useless-conditionals
         compute-predecessors
         split-branches
@@ -42,5 +41,6 @@ SYMBOL: check-optimizer?
         eliminate-dead-code
         eliminate-write-barriers
         eliminate-phis
+        optimize-tail-calls
         ?check
     ] with-scope ;
index 9fbf7acf7895e500521170273e2906aeb4f1257f..64e75aa7e954e129eb431c540793e8a534ec0d2b 100644 (file)
@@ -99,7 +99,7 @@ IN: compiler.cfg.stack-analysis.tests
 ! Correct height tracking
 [ t ] [
     [ pick [ <array> ] [ drop ] if swap ] test-stack-analysis eliminate-dead-code
-    reverse-post-order 4 swap nth
+    reverse-post-order 3 swap nth
     instructions>> [ ##peek? ] filter first2 [ loc>> ] [ loc>> ] bi*
     2array { D 1 D 0 } set=
 ] unit-test
@@ -170,9 +170,9 @@ IN: compiler.cfg.stack-analysis.tests
 ! Inserted ##peeks reference the wrong stack location
 [ t ] [
     [ [ "B" ] 2dip dup [ [ /mod ] dip ] when ] test-stack-analysis
-    eliminate-dead-code reverse-post-order 4 swap nth
+    eliminate-dead-code reverse-post-order 3 swap nth
     instructions>> [ ##peek? ] filter [ loc>> ] map
-    { D 0 D 1 } set=
+    { R 0 D 0 D 1 } set=
 ] unit-test
 
 [ D 0 ] [
index 4c17399c9550e3d64e567ef7336f902eea491d24..d1dd4e39a4b8adc4c41dd140f36476da9fcd74b4 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors sequences words memoize combinators
 classes classes.builtin classes.tuple math.partial-dispatch
@@ -17,23 +17,12 @@ IN: compiler.tree.finalization
 ! propagation since we need to see 'fixnum?' instead of
 ! 'tag 0 eq?' and so on, for semantic reasoning.
 
-! We also delete empty stack shuffles and copies to facilitate
-! tail call optimization in the code generator.
-
 GENERIC: finalize* ( node -- nodes )
 
 : finalize ( nodes -- nodes' ) [ finalize* ] map-nodes ;
 
 : splice-final ( quot -- nodes ) splice-quot finalize ;
 
-M: #copy finalize* drop f ;
-
-M: #shuffle finalize*
-    dup
-    [ [ in-d>> ] [ out-d>> ] [ mapping>> ] tri '[ _ at ] map sequence= ]
-    [ [ in-r>> ] [ out-r>> ] [ mapping>> ] tri '[ _ at ] map sequence= ]
-    bi and [ drop f ] when ;
-
 MEMO: cached-expansion ( word -- nodes )
     def>> splice-final ;