back out simple labels for now

cvs
Slava Pestov 2005-09-10 05:38:17 +00:00
parent 64b89e3e84
commit 1e92f8d31b
2 changed files with 9 additions and 37 deletions

View File

@ -5,8 +5,6 @@ USING: compiler-backend errors generic lists inference kernel
math namespaces prettyprint sequences math namespaces prettyprint sequences
strings words ; strings words ;
SYMBOL: simple-labels
GENERIC: linearize* ( node -- ) GENERIC: linearize* ( node -- )
: linearize ( dataflow -- linear ) : linearize ( dataflow -- linear )
@ -14,7 +12,6 @@ GENERIC: linearize* ( node -- )
#! stack flow information, and flattens conditionals into #! stack flow information, and flattens conditionals into
#! jumps and labels. #! jumps and labels.
[ [
{ } clone simple-labels set
%prologue , %prologue ,
linearize* linearize*
] { } make ; ] { } make ;
@ -25,41 +22,16 @@ M: f linearize* ( f -- ) drop ;
M: node linearize* ( node -- ) linearize-next ; M: node linearize* ( node -- ) linearize-next ;
: simple-label? ( #label -- ? )
#! A simple label only contains tail calls to itself.
dup node-param swap node-child [
dup #call-label? [
[ node-param = not ] keep node-successor #return? or
] [
2drop t
] ifte
] all-nodes-with? ;
: simple-label ( #label -- )
dup node-param %label , node-child linearize* ;
M: #label linearize* ( node -- ) M: #label linearize* ( node -- )
dup simple-label? [ <label> [
dup node-param simple-labels get push %return-to ,
dup simple-label dup node-param %label ,
] [ dup node-child linearize*
dup <label> [ %return-to , simple-label ] keep %label , ] keep %label ,
] ifte linearize-next ; linearize-next ;
: tail-call? ( node -- ? )
#! A #call to some other label or word, followed by a
#! #return from a simple label is not allowed to be
#! tail-call-optimized; indeed, that #return will not be
#! generated at all.
dup node-successor dup #return? [
swap node-param swap node-param
dup simple-labels get memq? not >r eq? r> or
] [
2drop f
] ifte ;
: ?tail-call ( node caller jumper -- next ) : ?tail-call ( node caller jumper -- next )
>r >r dup tail-call? [ >r >r dup node-successor #return? [
node-param r> drop r> execute , node-param r> drop r> execute ,
] [ ] [
dup node-param r> execute , r> drop linearize-next dup node-param r> execute , r> drop linearize-next
@ -116,4 +88,4 @@ M: #dispatch linearize* ( vtable -- )
M: #return linearize* ( node -- ) M: #return linearize* ( node -- )
#! Simple label returns do not count, since simple labels do #! Simple label returns do not count, since simple labels do
#! not push a stack frame on the C stack. #! not push a stack frame on the C stack.
node-param simple-labels get memq? [ %return , ] unless ; drop %return , ;

View File

@ -5,7 +5,7 @@ USING: generic kernel math-internals ;
UNION: real rational float ; UNION: real rational float ;
M: real abs dup 0 < [ neg ] when ; M: object abs dup 0 < [ neg ] when ;
M: real hashcode ( n -- n ) >fixnum ; M: real hashcode ( n -- n ) >fixnum ;