]> gitweb.factorcode.org Git - factor.git/commitdiff
added vm passing to some alien/boxing functions and added some vm asserts
authorPhil Dawes <phil@phildawes.net>
Tue, 25 Aug 2009 06:55:51 +0000 (07:55 +0100)
committerPhil Dawes <phil@phildawes.net>
Wed, 16 Sep 2009 07:20:10 +0000 (08:20 +0100)
basis/cpu/x86/64/64.factor
vm/alien.cpp
vm/data_gc.cpp
vm/math.cpp
vm/quotations.cpp

index 46b1e9866f1929af5b98dabef441d9bc0d792fea..a0ca3d17c70fb6127b0878798d7c76d5182e5b6c 100644 (file)
@@ -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 ;
index 9eb6da978482f400ab57786c5e7d9b68b94288f8..829a7efeb62d099ba2d8b7a09453694255b6c303 100755 (executable)
@@ -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);
 }
 
index 5a7f34ca4ba826cc0e26c29e02b771f53f2b7e9a..c6cdd398539ac870de87c097b5a94973365147c9 100755 (executable)
@@ -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);
 }
 
index 8d213b391dc8d2760833aee825fd5782921d9fe6..d6d824f7c03f7e5df33ed296bc758079ffb77efe 100755 (executable)
@@ -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);
 }
 
index b28fb1d3a1fc71b91dd3a8fdc496b5107e57f8c8..9c771129fcf1ba36c0717943f9b9cfa43b81b7c7 100755 (executable)
@@ -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);
 }