: call-height ( #call -- n )
[ out-d>> length ] [ in-d>> length ] bi - ;
+: emit-call-block ( word height -- )
+ dup adjust-d ##call, make-kill-block ;
+
: emit-primitive ( node -- )
[
- [ word>> ##call, ]
- [ call-height adjust-d ] bi
- make-kill-block
+ [ word>> ] [ call-height ] bi emit-call-block
] emit-trivial-block ;
: begin-branch ( -- )
! emit-call
{
- V{ T{ ##call { word print } } T{ ##branch } }
+ V{ T{ ##call { word print } { height 4 } } T{ ##branch } }
} [
[ \ print 4 emit-call ] V{ } make drop
basic-block get successors>> first instructions>>
over loops get key?
[ drop loops get at emit-loop-call ]
[
- [
- [ ##call, ] [ adjust-d ] bi*
- make-kill-block
- ] emit-trivial-block
+ [ emit-call-block ] emit-trivial-block
] if ;
! #recursive
! Subroutine calls
INSN: ##call
-literal: word ;
+literal: word height ;
INSN: ##jump
literal: word ;
: emit-overflow-case ( word -- final-bb )
[
- ##call,
- -1 adjust-d
- make-kill-block
+ -1 emit-call-block
] with-branch ;
: emit-fixnum-overflow-op ( quot word -- )
IN: compiler.codegen.tests
[ ] [ [ ] with-fixup drop ] unit-test
-[ ] [ [ \ + %call ] with-fixup drop ] unit-test
+[ ] [ [ \ + 0 %call ] with-fixup drop ] unit-test
[ ] [ [ <label> dup define-label dup resolve-label %jump-label ] with-fixup drop ] unit-test
[ ] [ [ <label> dup define-label dup resolve-label B{ 0 0 0 0 } % rc-absolute-cell label-fixup ] with-fixup drop ] unit-test
: init-cfg-test ( -- )
reset-vreg-counter begin-stack-analysis
<basic-block> dup basic-block set begin-local-analysis
+ H{ } clone representations set
H{ } clone replaces set ;
: cfg-unit-test ( result quot -- )
HOOK: %inc cpu ( loc -- )
HOOK: stack-frame-size cpu ( stack-frame -- n )
-HOOK: %call cpu ( word -- )
+HOOK: %call cpu ( word height -- )
HOOK: %jump cpu ( word -- )
HOOK: %jump-label cpu ( label -- )
HOOK: %return cpu ( -- )
factor-area-size +
16 align ;
-M: ppc %call ( word -- )
- 0 BL rc-relative-ppc-3-pc rel-word-pic ;
+M: ppc %call ( word height -- )
+ drop 0 BL rc-relative-ppc-3-pc rel-word-pic ;
: instrs ( n -- b ) 4 * ; inline
} case ;
M: ppc %call-gc ( gc-map -- )
- \ minor-gc %call gc-map-here ;
+ \ minor-gc 0 %call gc-map-here ;
M:: ppc %prologue ( stack-size -- )
0 MFLR
M: x86 %inc ( loc -- )
[ n>> ] [ ds-loc? ds-reg rs-reg ? ] bi (%inc) ;
-M: x86 %call ( word -- ) 0 CALL rc-relative rel-word-pic ;
+M: x86 %call ( word height -- ) drop 0 CALL rc-relative rel-word-pic ;
: xt-tail-pic-offset ( -- n )
#! See the comment in vm/cpu-x86.hpp
n>> spill-offset special-offset cell + cell /i ;
M: x86 %call-gc ( gc-map -- )
- \ minor-gc %call
+ \ minor-gc 0 %call
gc-map-here ;
M: x86 %alien-global ( dst symbol library -- )