compiler.cfg.builder: don't make basic blocks after terminating calls

db4
Slava Pestov 2009-05-25 19:16:36 -05:00
parent 2322f30df2
commit a2b982e247
2 changed files with 7 additions and 5 deletions

View File

@ -84,6 +84,7 @@ GENERIC: emit-node ( node -- next )
: emit-call ( word height -- next ) : emit-call ( word height -- next )
{ {
{ [ over loops get key? ] [ drop loops get at local-recursive-call ] } { [ over loops get key? ] [ drop loops get at local-recursive-call ] }
{ [ terminate-call? ] [ ##call stop-iterating ] }
{ [ tail-call? not ] [ ##call ##branch begin-basic-block iterate-next ] } { [ tail-call? not ] [ ##call ##branch begin-basic-block iterate-next ] }
{ [ dup current-label get eq? ] [ 2drop first-basic-block get local-recursive-call ] } { [ dup current-label get eq? ] [ 2drop first-basic-block get local-recursive-call ] }
[ drop ##epilogue ##jump stop-iterating ] [ drop ##epilogue ##jump stop-iterating ]
@ -102,6 +103,7 @@ GENERIC: emit-node ( node -- next )
: emit-loop ( node -- next ) : emit-loop ( node -- next )
##loop-entry ##loop-entry
##branch
begin-basic-block begin-basic-block
[ label>> id>> remember-loop ] [ child>> emit-nodes ] bi [ label>> id>> remember-loop ] [ child>> emit-nodes ] bi
iterate-next ; iterate-next ;

View File

@ -37,9 +37,9 @@ DEFER: (tail-call?)
: tail-call? ( -- ? ) : tail-call? ( -- ? )
node-stack get [ node-stack get [
rest-slice rest-slice
[ t ] [ [ t ] [ (tail-call?) ] if-empty
[ (tail-call?) ]
[ first #terminate? not ]
bi and
] if-empty
] all? ; ] all? ;
: terminate-call? ( -- ? )
node-stack get peek
rest-slice [ f ] [ first #terminate? ] if-empty ;