From 199fba7a9992cff85aac74587d3ce6df39b21756 Mon Sep 17 00:00:00 2001 From: Phil Dawes Date: Sat, 22 Aug 2009 10:50:52 +0100 Subject: [PATCH] converted box_* integer functions to use vm (x86 windows) --- vm/alien.cpp | 8 +++++--- vm/math.cpp | 50 ++++++++++++++++++++++++++++++-------------------- vm/math.hpp | 20 ++++++++++---------- 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/vm/alien.cpp b/vm/alien.cpp index da33c01df1..e2298630e1 100755 --- a/vm/alien.cpp +++ b/vm/alien.cpp @@ -103,12 +103,14 @@ void *alien_pointer() #define DEFINE_ALIEN_ACCESSOR(name,type,boxer,to) \ PRIMITIVE(alien_##name) \ { \ - boxer(*(type*)PRIMITIVE_GETVM()->alien_pointer()); \ + factorvm *myvm = PRIMITIVE_GETVM(); \ + myvm->boxer(*(type*)myvm->alien_pointer()); \ } \ PRIMITIVE(set_alien_##name) \ { \ - type *ptr = (type *)PRIMITIVE_GETVM()->alien_pointer(); \ - type value = PRIMITIVE_GETVM()->to(dpop()); \ + factorvm *myvm = PRIMITIVE_GETVM(); \ + type *ptr = (type *)myvm->alien_pointer(); \ + type value = myvm->to(dpop()); \ *ptr = value; \ } diff --git a/vm/math.cpp b/vm/math.cpp index 1bb8f0abe5..e6e1abf80a 100755 --- a/vm/math.cpp +++ b/vm/math.cpp @@ -638,9 +638,10 @@ void factorvm::box_signed_1(s8 n) dpush(tag_fixnum(n)); } -VM_C_API void box_signed_1(s8 n) +VM_C_API void box_signed_1(s8 n,factorvm *myvm) { - return vm->box_signed_1(n); + ASSERTVM(); + return VM_PTR->box_signed_1(n); } void factorvm::box_unsigned_1(u8 n) @@ -648,9 +649,10 @@ void factorvm::box_unsigned_1(u8 n) dpush(tag_fixnum(n)); } -VM_C_API void box_unsigned_1(u8 n) +VM_C_API void box_unsigned_1(u8 n,factorvm *myvm) { - return vm->box_unsigned_1(n); + ASSERTVM(); + return VM_PTR->box_unsigned_1(n); } void factorvm::box_signed_2(s16 n) @@ -658,9 +660,10 @@ void factorvm::box_signed_2(s16 n) dpush(tag_fixnum(n)); } -VM_C_API void box_signed_2(s16 n) +VM_C_API void box_signed_2(s16 n,factorvm *myvm) { - return vm->box_signed_2(n); + ASSERTVM(); + return VM_PTR->box_signed_2(n); } void factorvm::box_unsigned_2(u16 n) @@ -668,9 +671,10 @@ void factorvm::box_unsigned_2(u16 n) dpush(tag_fixnum(n)); } -VM_C_API void box_unsigned_2(u16 n) +VM_C_API void box_unsigned_2(u16 n,factorvm *myvm) { - return vm->box_unsigned_2(n); + ASSERTVM(); + return VM_PTR->box_unsigned_2(n); } void factorvm::box_signed_4(s32 n) @@ -678,9 +682,10 @@ void factorvm::box_signed_4(s32 n) dpush(allot_integer(n)); } -VM_C_API void box_signed_4(s32 n) +VM_C_API void box_signed_4(s32 n,factorvm *myvm) { - return vm->box_signed_4(n); + ASSERTVM(); + return VM_PTR->box_signed_4(n); } void factorvm::box_unsigned_4(u32 n) @@ -688,9 +693,10 @@ void factorvm::box_unsigned_4(u32 n) dpush(allot_cell(n)); } -VM_C_API void box_unsigned_4(u32 n) +VM_C_API void box_unsigned_4(u32 n,factorvm *myvm) { - return vm->box_unsigned_4(n); + ASSERTVM(); + return VM_PTR->box_unsigned_4(n); } void factorvm::box_signed_cell(fixnum integer) @@ -698,9 +704,10 @@ void factorvm::box_signed_cell(fixnum integer) dpush(allot_integer(integer)); } -VM_C_API void box_signed_cell(fixnum integer) +VM_C_API void box_signed_cell(fixnum integer,factorvm *myvm) { - return vm->box_signed_cell(integer); + ASSERTVM(); + return VM_PTR->box_signed_cell(integer); } void factorvm::box_unsigned_cell(cell cell) @@ -708,9 +715,10 @@ void factorvm::box_unsigned_cell(cell cell) dpush(allot_cell(cell)); } -VM_C_API void box_unsigned_cell(cell cell) +VM_C_API void box_unsigned_cell(cell cell,factorvm *myvm) { - return vm->box_unsigned_cell(cell); + ASSERTVM(); + return VM_PTR->box_unsigned_cell(cell); } void factorvm::box_signed_8(s64 n) @@ -721,9 +729,10 @@ void factorvm::box_signed_8(s64 n) dpush(tag_fixnum(n)); } -VM_C_API void box_signed_8(s64 n) +VM_C_API void box_signed_8(s64 n,factorvm *myvm) { - return vm->box_signed_8(n); + ASSERTVM(); + return VM_PTR->box_signed_8(n); } s64 factorvm::to_signed_8(cell obj) @@ -754,9 +763,10 @@ void factorvm::box_unsigned_8(u64 n) dpush(tag_fixnum(n)); } -VM_C_API void box_unsigned_8(u64 n) +VM_C_API void box_unsigned_8(u64 n,factorvm *myvm) { - return vm->box_unsigned_8(n); + ASSERTVM(); + return VM_PTR->box_unsigned_8(n); } u64 factorvm::to_unsigned_8(cell obj) diff --git a/vm/math.hpp b/vm/math.hpp index 8affd8edd2..11c43a01a1 100644 --- a/vm/math.hpp +++ b/vm/math.hpp @@ -65,16 +65,16 @@ VM_C_API float to_float(cell value, factorvm *vm); VM_C_API void box_double(double flo); VM_C_API double to_double(cell value, factorvm *vm); -VM_C_API void box_signed_1(s8 n); -VM_C_API void box_unsigned_1(u8 n); -VM_C_API void box_signed_2(s16 n); -VM_C_API void box_unsigned_2(u16 n); -VM_C_API void box_signed_4(s32 n); -VM_C_API void box_unsigned_4(u32 n); -VM_C_API void box_signed_cell(fixnum integer); -VM_C_API void box_unsigned_cell(cell cell); -VM_C_API void box_signed_8(s64 n); -VM_C_API void box_unsigned_8(u64 n); +VM_C_API void box_signed_1(s8 n, factorvm *vm); +VM_C_API void box_unsigned_1(u8 n, factorvm *vm); +VM_C_API void box_signed_2(s16 n, factorvm *vm); +VM_C_API void box_unsigned_2(u16 n, factorvm *vm); +VM_C_API void box_signed_4(s32 n, factorvm *vm); +VM_C_API void box_unsigned_4(u32 n, factorvm *vm); +VM_C_API void box_signed_cell(fixnum integer, factorvm *vm); +VM_C_API void box_unsigned_cell(cell cell, factorvm *vm); +VM_C_API void box_signed_8(s64 n, factorvm *vm); +VM_C_API void box_unsigned_8(u64 n, factorvm *vm); VM_C_API s64 to_signed_8(cell obj, factorvm *vm); VM_C_API u64 to_unsigned_8(cell obj, factorvm *vm);