classes.struct fry kernel layouts locals math namespaces
sequences sequences.generalizations system
compiler.cfg.builder.alien.params compiler.cfg.hats
-compiler.cfg.registers compiler.cfg.instructions cpu.architecture ;
+compiler.cfg.registers compiler.cfg.instructions
+compiler.cfg.intrinsics.allot cpu.architecture ;
IN: compiler.cfg.builder.alien.boxing
SYMBOL: struct-return-area
<gc-map> ^^box-long-long ;
M: struct-c-type box
- '[ _ heap-size <gc-map> ^^allot-byte-array dup ^^unbox-byte-array ] 2dip
+ '[ _ heap-size emit-allot-byte-array dup ^^unbox-byte-array ] 2dip
implode-struct ;
GENERIC: box-parameter ( vregs reps c-type -- dst )
seen-allocation? [ call-index , ] when
insn-index 1 + f ;
+M: ##callback-inputs gc-check-offsets* gc-check-here ;
M: ##phi gc-check-offsets* gc-check-here ;
M: gc-map-insn gc-check-offsets* gc-check-here ;
M: ##allocation gc-check-offsets* 3drop t ;
use: src1/int-rep src2/int-rep
literal: boxer gc-map ;
-FLUSHABLE-INSN: ##allot-byte-array
-def: dst/tagged-rep
-literal: size gc-map ;
-
! Alien call inputs and outputs are arrays of triples with shape
! { vreg rep stack#/reg }
##call-gc
##box
##box-long-long
-##allot-byte-array
factor-call-insn ;
M: gc-map-insn clone call-next-method [ clone ] change-gc-map ;
##binary-float-function
##unbox
##box
-##box-long-long
-##allot-byte-array ;
+##box-long-long ;
! Instructions that have complex expansions and require that the
! output registers are not equal to any of the input registers
16 + byte-array ^^allot ;
: emit-allot-byte-array ( len -- dst )
- ds-drop
dup ^^allot-byte-array
[ byte-array store-length ] [ ds-push ] [ ] tri ;
: emit-(byte-array) ( node -- )
dup node-input-infos first literal>> dup expand-(byte-array)?
- [ nip emit-allot-byte-array drop ] [ drop emit-primitive ] if ;
+ [ nip ds-drop emit-allot-byte-array drop ] [ drop emit-primitive ] if ;
:: zero-byte-array ( len reg -- )
0 ^^load-literal :> elt
:: emit-<byte-array> ( node -- )
node node-input-infos first literal>> dup expand-<byte-array>? [
:> len
+ ds-drop
len emit-allot-byte-array :> reg
len reg zero-byte-array
] [ drop node emit-primitive ] if ;
compiler.cfg.debugger
compiler.cfg.def-use
compiler.cfg.comparisons
+compiler.cfg.ssa.destruction
compiler.cfg.linear-scan
compiler.cfg.linear-scan.numbering
compiler.cfg.linear-scan.live-intervals
check-allocation? on
check-numbering? on
+! Live interval calculation
+
+! A value is defined and never used; make sure it has the right
+! live range
+V{
+ T{ ##load-integer f 1 0 }
+ T{ ##replace-imm f D 0 "hi" }
+ T{ ##branch }
+} 0 test-bb
+
+: test-live-intervals ( -- )
+ cfg new 0 get >>entry
+ [ cfg set ] [ number-instructions ] [ compute-live-intervals ] tri
+ 2drop ;
+
+[ ] [
+ H{
+ { 1 int-rep }
+ } representations set
+ H{
+ { 1 1 }
+ } leader-map set
+ test-live-intervals
+] unit-test
+
+[ 0 0 ] [
+ 1 live-intervals get at [ start>> ] [ end>> ] bi
+] unit-test
+
+! Live range and interval splitting
[
{ T{ live-range f 1 10 } T{ live-range f 15 15 } }
{ T{ live-range f 16 20 } }
CODEGEN: ##local-allot %local-allot
CODEGEN: ##box %box
CODEGEN: ##box-long-long %box-long-long
-CODEGEN: ##allot-byte-array %allot-byte-array
CODEGEN: ##alien-invoke %alien-invoke
CODEGEN: ##alien-indirect %alien-indirect
CODEGEN: ##alien-assembly %alien-assembly
HOOK: %box-long-long cpu ( dst src1 src2 func gc-map -- )
-HOOK: %allot-byte-array cpu ( dst size gc-map -- )
-
HOOK: %save-context cpu ( temp1 temp2 -- )
HOOK: %c-invoke cpu ( symbols dll gc-map -- )
func f gc-map %c-invoke
dst EAX tagged-rep %copy ;
-M:: x86.32 %allot-byte-array ( dst size gc-map -- )
- 4 save-vm-ptr
- 0 stack@ size MOV
- "allot_byte_array" f gc-map %c-invoke
- dst EAX tagged-rep %copy ;
-
M: x86.32 %c-invoke
[ 0 CALL rc-relative rel-dlsym ] dip gc-map-here ;
func f gc-map %c-invoke
dst int-rep %load-return ;
-M:: x86.64 %allot-byte-array ( dst size gc-map -- )
- param-reg-0 size MOV
- param-reg-1 %mov-vm-ptr
- "allot_byte_array" f gc-map %c-invoke
- dst int-rep %load-return ;
-
M: x86.64 %c-invoke
[ R11 0 MOV rc-absolute-cell rel-dlsym R11 CALL ] dip
gc-map-here ;
return array;
}
-VM_C_API cell allot_byte_array(cell size, factor_vm *parent)
-{
- return tag<byte_array>(parent->allot_byte_array(size));
-}
-
void factor_vm::primitive_byte_array()
{
cell size = unbox_array_size();
return data;
}
-VM_C_API cell allot_byte_array(cell size, factor_vm *parent);
-
}