From b02c602a89f81cdc11f2390f9d9767ab45bce268 Mon Sep 17 00:00:00 2001 From: Phil Dawes Date: Tue, 25 Aug 2009 07:55:51 +0100 Subject: [PATCH] added vm passing to some alien/boxing functions and added some vm asserts --- basis/cpu/x86/64/64.factor | 13 ++++++++++--- vm/alien.cpp | 10 +++++----- vm/data_gc.cpp | 1 + vm/math.cpp | 3 +++ vm/quotations.cpp | 1 + 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 46b1e9866f..a0ca3d17c7 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -74,9 +74,14 @@ M: x86.64 %prepare-unbox ( -- ) param-reg-1 R14 [] MOV 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 -- ) ! Call the unboxer - func f %alien-invoke + func %vm-invoke-2nd-arg ! Store the return value on the C stack if this is an ! alien-invoke, otherwise leave it the return register if ! 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 ] } } case ; + M: x86.64 %unbox-small-struct ( c-type -- ) ! 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 ! clobber it. R11 RAX MOV @@ -125,7 +131,7 @@ M:: x86.64 %box ( n rep func -- ) ] [ rep load-return-value ] if - func f %alien-invoke ; + func %vm-invoke-2nd-arg ; M: x86.64 %box-long-long ( n func -- ) [ 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 f %alien-invoke ; + M: x86.64 %vm-invoke-3rd-arg ( function -- ) param-reg-3 0 MOV rc-absolute-cell rt-vm rel-fixup f %alien-invoke ; diff --git a/vm/alien.cpp b/vm/alien.cpp index 9eb6da9784..829a7efeb6 100755 --- a/vm/alien.cpp +++ b/vm/alien.cpp @@ -226,7 +226,7 @@ char *factorvm::unbox_alien() 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(); } @@ -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) { - //printf("PHIL to_value_struct %d %d\n",vm,myvm);fflush(stdout); + ASSERTVM(); 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) { - //printf("PHIL box_value_struct %d %d\n",vm,myvm);fflush(stdout); + ASSERTVM(); 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) { - //printf("PHIL box_small_struct %d %d\n",vm,myvm);fflush(stdout); + ASSERTVM(); 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) { - //printf("PHIL box_medium_struct %d %d\n",vm,myvm);fflush(stdout); + ASSERTVM(); return VM_PTR->box_medium_struct(x1, x2, x3, x4, size); } diff --git a/vm/data_gc.cpp b/vm/data_gc.cpp index 5a7f34ca4b..c6cdd39853 100755 --- a/vm/data_gc.cpp +++ b/vm/data_gc.cpp @@ -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) { + ASSERTVM(); return VM_PTR->inline_gc(gc_roots_base,gc_roots_size); } diff --git a/vm/math.cpp b/vm/math.cpp index 8d213b391d..d6d824f7c0 100755 --- a/vm/math.cpp +++ b/vm/math.cpp @@ -620,6 +620,7 @@ fixnum factorvm::to_fixnum(cell tagged) VM_C_API fixnum to_fixnum(cell tagged,factorvm *myvm) { + ASSERTVM(); 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) { + ASSERTVM(); 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) { + ASSERTVM(); return VM_PTR->to_float(value); } diff --git a/vm/quotations.cpp b/vm/quotations.cpp index b28fb1d3a1..9c771129fc 100755 --- a/vm/quotations.cpp +++ b/vm/quotations.cpp @@ -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) { + ASSERTVM(); return VM_PTR->lazy_jit_compile_impl(quot_,stack); } -- 2.34.1