compiler.cfg.builder: annotate calls with height changes, once again

db4
Slava Pestov 2009-07-18 23:08:53 -05:00
parent ec1407bdae
commit 605b37a949
5 changed files with 20 additions and 14 deletions

View File

@ -63,15 +63,18 @@ GENERIC: emit-node ( node -- )
basic-block get successors>> push
basic-block off ;
: emit-call ( word -- )
dup loops get key?
[ loops get at emit-loop-call ]
: emit-call ( word height -- )
over loops get key?
[ drop loops get at emit-loop-call ]
[ ##call ##branch begin-basic-block ]
if ;
! #recursive
: recursive-height ( #recursive -- n )
[ label>> return>> in-d>> length ] [ in-d>> length ] bi - ;
: emit-recursive ( #recursive -- )
[ label>> id>> emit-call ]
[ [ label>> id>> ] [ recursive-height ] bi emit-call ]
[ [ child>> ] [ label>> word>> ] [ label>> id>> ] tri (build-cfg) ] bi ;
: remember-loop ( label -- )
@ -133,10 +136,10 @@ M: #dispatch emit-node
! #call
M: #call emit-node
dup word>> dup "intrinsic" word-prop
[ emit-intrinsic ] [ nip emit-call ] if ;
[ emit-intrinsic ] [ swap call-height emit-call ] if ;
! #call-recursive
M: #call-recursive emit-node label>> id>> emit-call ;
M: #call-recursive emit-node [ label>> id>> ] [ call-height ] bi emit-call ;
! #push
M: #push emit-node

View File

@ -17,14 +17,14 @@ M: insn ds-height-change drop 0 ;
M: ##inc-d ds-height-change n>> ;
! XXX
! M: ##call ds-height-change height>> ;
M: ##call ds-height-change height>> ;
M: ##call ds-height-change drop 0 ;
: alien-node-height ( node -- )
params>> [ out-d>> length ] [ in-d>> length ] bi - ;
M: ##alien-invoke ds-height-change height>> ;
M: ##alien-invoke ds-height-change alien-node-height ;
M: ##alien-indirect ds-height-change height>> ;
M: ##alien-indirect ds-height-change alien-node-height ;
GENERIC: rs-height-change ( insn -- n )

View File

@ -53,7 +53,7 @@ INSN: ##inc-r { n integer } ;
! Subroutine calls
INSN: ##stack-frame stack-frame ;
INSN: ##call word ;
INSN: ##call word { height integer } ;
INSN: ##jump word ;
INSN: ##return ;

View File

@ -65,7 +65,7 @@ IN: compiler.cfg.intrinsics.fixnum
[ -2 ##inc-d ds-push ] with-branch ;
: emit-overflow-case ( word -- final-bb )
[ ##call ] with-branch ;
[ -1 ##call ] with-branch ;
: emit-fixnum-overflow-op ( quot word -- )
[ [ D 1 ^^peek D 0 ^^peek ] dip call ] dip

View File

@ -33,8 +33,11 @@ IN: compiler.cfg.utilities
building off
basic-block off ;
: call-height ( #call -- n )
[ out-d>> length ] [ in-d>> length ] bi - ;
: emit-primitive ( node -- )
word>> ##call ##branch begin-basic-block ;
[ word>> ] [ call-height ] bi ##call ##branch begin-basic-block ;
: with-branch ( quot -- final-bb )
[