added vm passing to some alien/boxing functions and added some vm asserts
parent
d7e2f770c0
commit
26586c24f0
|
@ -74,9 +74,14 @@ M: x86.64 %prepare-unbox ( -- )
|
||||||
param-reg-1 R14 [] MOV
|
param-reg-1 R14 [] MOV
|
||||||
R14 cell SUB ;
|
R14 cell SUB ;
|
||||||
|
|
||||||
|
: %vm-invoke-2nd-arg ( function -- )
|
||||||
|
param-reg-2 0 MOV rc-absolute-cell rt-vm rel-fixup
|
||||||
|
f %alien-invoke ;
|
||||||
|
|
||||||
|
|
||||||
M:: x86.64 %unbox ( n rep func -- )
|
M:: x86.64 %unbox ( n rep func -- )
|
||||||
! Call the unboxer
|
! Call the unboxer
|
||||||
func f %alien-invoke
|
func %vm-invoke-2nd-arg
|
||||||
! Store the return value on the C stack if this is an
|
! Store the return value on the C stack if this is an
|
||||||
! alien-invoke, otherwise leave it the return register if
|
! alien-invoke, otherwise leave it the return register if
|
||||||
! this is the end of alien-callback
|
! this is the end of alien-callback
|
||||||
|
@ -92,9 +97,10 @@ M: x86.64 %unbox-long-long ( n func -- )
|
||||||
{ float-regs [ float-regs get pop swap MOVSD ] }
|
{ float-regs [ float-regs get pop swap MOVSD ] }
|
||||||
} case ;
|
} case ;
|
||||||
|
|
||||||
|
|
||||||
M: x86.64 %unbox-small-struct ( c-type -- )
|
M: x86.64 %unbox-small-struct ( c-type -- )
|
||||||
! Alien must be in param-reg-1.
|
! Alien must be in param-reg-1.
|
||||||
"alien_offset" f %alien-invoke
|
"alien_offset" %vm-invoke-2nd-arg
|
||||||
! Move alien_offset() return value to R11 so that we don't
|
! Move alien_offset() return value to R11 so that we don't
|
||||||
! clobber it.
|
! clobber it.
|
||||||
R11 RAX MOV
|
R11 RAX MOV
|
||||||
|
@ -125,7 +131,7 @@ M:: x86.64 %box ( n rep func -- )
|
||||||
] [
|
] [
|
||||||
rep load-return-value
|
rep load-return-value
|
||||||
] if
|
] if
|
||||||
func f %alien-invoke ;
|
func %vm-invoke-2nd-arg ;
|
||||||
|
|
||||||
M: x86.64 %box-long-long ( n func -- )
|
M: x86.64 %box-long-long ( n func -- )
|
||||||
[ int-rep ] dip %box ;
|
[ int-rep ] dip %box ;
|
||||||
|
@ -176,6 +182,7 @@ M: x86.64 %vm-invoke-1st-arg ( function -- )
|
||||||
param-reg-1 0 MOV rc-absolute-cell rt-vm rel-fixup
|
param-reg-1 0 MOV rc-absolute-cell rt-vm rel-fixup
|
||||||
f %alien-invoke ;
|
f %alien-invoke ;
|
||||||
|
|
||||||
|
|
||||||
M: x86.64 %vm-invoke-3rd-arg ( function -- )
|
M: x86.64 %vm-invoke-3rd-arg ( function -- )
|
||||||
param-reg-3 0 MOV rc-absolute-cell rt-vm rel-fixup
|
param-reg-3 0 MOV rc-absolute-cell rt-vm rel-fixup
|
||||||
f %alien-invoke ;
|
f %alien-invoke ;
|
||||||
|
|
10
vm/alien.cpp
10
vm/alien.cpp
|
@ -226,7 +226,7 @@ char *factorvm::unbox_alien()
|
||||||
|
|
||||||
VM_C_API char *unbox_alien(factorvm *myvm)
|
VM_C_API char *unbox_alien(factorvm *myvm)
|
||||||
{
|
{
|
||||||
//printf("PHIL unbox_alien %d %d\n",vm,myvm);fflush(stdout);
|
ASSERTVM();
|
||||||
return VM_PTR->unbox_alien();
|
return VM_PTR->unbox_alien();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ void factorvm::to_value_struct(cell src, void *dest, cell size)
|
||||||
|
|
||||||
VM_C_API void to_value_struct(cell src, void *dest, cell size, factorvm *myvm)
|
VM_C_API void to_value_struct(cell src, void *dest, cell size, factorvm *myvm)
|
||||||
{
|
{
|
||||||
//printf("PHIL to_value_struct %d %d\n",vm,myvm);fflush(stdout);
|
ASSERTVM();
|
||||||
return VM_PTR->to_value_struct(src,dest,size);
|
return VM_PTR->to_value_struct(src,dest,size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ void factorvm::box_value_struct(void *src, cell size)
|
||||||
|
|
||||||
VM_C_API void box_value_struct(void *src, cell size,factorvm *myvm)
|
VM_C_API void box_value_struct(void *src, cell size,factorvm *myvm)
|
||||||
{
|
{
|
||||||
//printf("PHIL box_value_struct %d %d\n",vm,myvm);fflush(stdout);
|
ASSERTVM();
|
||||||
return VM_PTR->box_value_struct(src,size);
|
return VM_PTR->box_value_struct(src,size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ void factorvm::box_small_struct(cell x, cell y, cell size)
|
||||||
|
|
||||||
VM_C_API void box_small_struct(cell x, cell y, cell size, factorvm *myvm)
|
VM_C_API void box_small_struct(cell x, cell y, cell size, factorvm *myvm)
|
||||||
{
|
{
|
||||||
//printf("PHIL box_small_struct %d %d\n",vm,myvm);fflush(stdout);
|
ASSERTVM();
|
||||||
return VM_PTR->box_small_struct(x,y,size);
|
return VM_PTR->box_small_struct(x,y,size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ void factorvm::box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size)
|
||||||
|
|
||||||
VM_C_API void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size, factorvm *myvm)
|
VM_C_API void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size, factorvm *myvm)
|
||||||
{
|
{
|
||||||
//printf("PHIL box_medium_struct %d %d\n",vm,myvm);fflush(stdout);
|
ASSERTVM();
|
||||||
return VM_PTR->box_medium_struct(x1, x2, x3, x4, size);
|
return VM_PTR->box_medium_struct(x1, x2, x3, x4, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -707,6 +707,7 @@ void factorvm::inline_gc(cell *gc_roots_base, cell gc_roots_size)
|
||||||
|
|
||||||
VM_ASM_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factorvm *myvm)
|
VM_ASM_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factorvm *myvm)
|
||||||
{
|
{
|
||||||
|
ASSERTVM();
|
||||||
return VM_PTR->inline_gc(gc_roots_base,gc_roots_size);
|
return VM_PTR->inline_gc(gc_roots_base,gc_roots_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -620,6 +620,7 @@ fixnum factorvm::to_fixnum(cell tagged)
|
||||||
|
|
||||||
VM_C_API fixnum to_fixnum(cell tagged,factorvm *myvm)
|
VM_C_API fixnum to_fixnum(cell tagged,factorvm *myvm)
|
||||||
{
|
{
|
||||||
|
ASSERTVM();
|
||||||
return VM_PTR->to_fixnum(tagged);
|
return VM_PTR->to_fixnum(tagged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,6 +631,7 @@ cell factorvm::to_cell(cell tagged)
|
||||||
|
|
||||||
VM_C_API cell to_cell(cell tagged, factorvm *myvm)
|
VM_C_API cell to_cell(cell tagged, factorvm *myvm)
|
||||||
{
|
{
|
||||||
|
ASSERTVM();
|
||||||
return VM_PTR->to_cell(tagged);
|
return VM_PTR->to_cell(tagged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,6 +809,7 @@ float factorvm::to_float(cell value)
|
||||||
|
|
||||||
VM_C_API float to_float(cell value,factorvm *myvm)
|
VM_C_API float to_float(cell value,factorvm *myvm)
|
||||||
{
|
{
|
||||||
|
ASSERTVM();
|
||||||
return VM_PTR->to_float(value);
|
return VM_PTR->to_float(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -370,6 +370,7 @@ cell factorvm::lazy_jit_compile_impl(cell quot_, stack_frame *stack)
|
||||||
|
|
||||||
VM_ASM_API cell lazy_jit_compile_impl(cell quot_, stack_frame *stack, factorvm *myvm)
|
VM_ASM_API cell lazy_jit_compile_impl(cell quot_, stack_frame *stack, factorvm *myvm)
|
||||||
{
|
{
|
||||||
|
ASSERTVM();
|
||||||
return VM_PTR->lazy_jit_compile_impl(quot_,stack);
|
return VM_PTR->lazy_jit_compile_impl(quot_,stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue