compiler.cfg: Move tail call optimization to the end, compiler.tree: simplify finalization pass because of this
parent
b83f27af74
commit
5061db2a48
|
@ -28,7 +28,6 @@ SYMBOL: check-optimizer?
|
||||||
! Note that compute-predecessors has to be called several times.
|
! Note that compute-predecessors has to be called several times.
|
||||||
! The passes that need this document it.
|
! The passes that need this document it.
|
||||||
[
|
[
|
||||||
optimize-tail-calls
|
|
||||||
delete-useless-conditionals
|
delete-useless-conditionals
|
||||||
compute-predecessors
|
compute-predecessors
|
||||||
split-branches
|
split-branches
|
||||||
|
@ -42,5 +41,6 @@ SYMBOL: check-optimizer?
|
||||||
eliminate-dead-code
|
eliminate-dead-code
|
||||||
eliminate-write-barriers
|
eliminate-write-barriers
|
||||||
eliminate-phis
|
eliminate-phis
|
||||||
|
optimize-tail-calls
|
||||||
?check
|
?check
|
||||||
] with-scope ;
|
] with-scope ;
|
||||||
|
|
|
@ -99,7 +99,7 @@ IN: compiler.cfg.stack-analysis.tests
|
||||||
! Correct height tracking
|
! Correct height tracking
|
||||||
[ t ] [
|
[ t ] [
|
||||||
[ pick [ <array> ] [ drop ] if swap ] test-stack-analysis eliminate-dead-code
|
[ 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*
|
instructions>> [ ##peek? ] filter first2 [ loc>> ] [ loc>> ] bi*
|
||||||
2array { D 1 D 0 } set=
|
2array { D 1 D 0 } set=
|
||||||
] unit-test
|
] unit-test
|
||||||
|
@ -170,9 +170,9 @@ IN: compiler.cfg.stack-analysis.tests
|
||||||
! Inserted ##peeks reference the wrong stack location
|
! Inserted ##peeks reference the wrong stack location
|
||||||
[ t ] [
|
[ t ] [
|
||||||
[ [ "B" ] 2dip dup [ [ /mod ] dip ] when ] test-stack-analysis
|
[ [ "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
|
instructions>> [ ##peek? ] filter [ loc>> ] map
|
||||||
{ D 0 D 1 } set=
|
{ R 0 D 0 D 1 } set=
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ D 0 ] [
|
[ D 0 ] [
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel accessors sequences words memoize combinators
|
USING: kernel accessors sequences words memoize combinators
|
||||||
classes classes.builtin classes.tuple math.partial-dispatch
|
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
|
! propagation since we need to see 'fixnum?' instead of
|
||||||
! 'tag 0 eq?' and so on, for semantic reasoning.
|
! '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 )
|
GENERIC: finalize* ( node -- nodes )
|
||||||
|
|
||||||
: finalize ( nodes -- nodes' ) [ finalize* ] map-nodes ;
|
: finalize ( nodes -- nodes' ) [ finalize* ] map-nodes ;
|
||||||
|
|
||||||
: splice-final ( quot -- nodes ) splice-quot finalize ;
|
: 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 )
|
MEMO: cached-expansion ( word -- nodes )
|
||||||
def>> splice-final ;
|
def>> splice-final ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue