#define FACTOR_CPU_STRING "ppc"
#define VM_ASM_API VM_C_API
+#define VM_ASM_API_OVERFLOW VM_C_API
register cell ds asm("r13");
register cell rs asm("r14");
#define ARG0 %eax
#define ARG1 %edx
+#define ARG2 %ecx
#define STACK_REG %esp
#define DS_REG %esi
#define RETURN_REG %eax
register cell rs asm("edi");
#define VM_ASM_API VM_C_API __attribute__ ((regparm (2)))
+#define VM_ASM_API_OVERFLOW VM_C_API __attribute__ ((regparm (3)))
}
register cell rs asm("r15");
#define VM_ASM_API VM_C_API
-
+#define VM_ASM_API_OVERFLOW VM_C_API
}
-DEF(void,primitive_fixnum_add,(void)):
+DEF(void,primitive_fixnum_add,(void *myvm)):
+ mov ARG0, ARG2 /* save vm ptr for overflow */
mov (DS_REG),ARG0
mov -CELL_SIZE(DS_REG),ARG1
sub $CELL_SIZE,DS_REG
mov ARITH_TEMP_1,(DS_REG)
ret
-DEF(void,primitive_fixnum_subtract,(void)):
+DEF(void,primitive_fixnum_subtract,(void *myvm)):
+ mov ARG0, ARG2 /* save vm ptr for overflow */
mov (DS_REG),ARG1
mov -CELL_SIZE(DS_REG),ARG0
sub $CELL_SIZE,DS_REG
mov ARITH_TEMP_1,(DS_REG)
ret
-DEF(void,primitive_fixnum_multiply,(void)):
+DEF(void,primitive_fixnum_multiply,(void *myvm)):
+ mov ARG0, ARG2 /* save vm ptr for overflow */
mov (DS_REG),ARITH_TEMP_1
mov ARITH_TEMP_1,DIV_RESULT
mov -CELL_SIZE(DS_REG),ARITH_TEMP_2
jo multiply_overflow
mov DIV_RESULT,(DS_REG)
ret
+
multiply_overflow:
sar $3,ARITH_TEMP_1
mov ARITH_TEMP_1,ARG0
untag_fixnum(x) + untag_fixnum(y))));
}
-VM_ASM_API void overflow_fixnum_add(fixnum x, fixnum y, factorvm *myvm)
+VM_ASM_API_OVERFLOW void overflow_fixnum_add(fixnum x, fixnum y, factorvm *myvm)
{
return PRIMITIVE_OVERFLOW_GETVM()->overflow_fixnum_add(x,y);
}
untag_fixnum(x) - untag_fixnum(y))));
}
-VM_ASM_API void overflow_fixnum_subtract(fixnum x, fixnum y, factorvm *myvm)
+VM_ASM_API_OVERFLOW void overflow_fixnum_subtract(fixnum x, fixnum y, factorvm *myvm)
{
return PRIMITIVE_OVERFLOW_GETVM()->overflow_fixnum_subtract(x,y);
}
drepl(tag<bignum>(bignum_multiply(bx,by)));
}
-VM_ASM_API void overflow_fixnum_multiply(fixnum x, fixnum y, factorvm *myvm)
+VM_ASM_API_OVERFLOW void overflow_fixnum_multiply(fixnum x, fixnum y, factorvm *myvm)
{
return PRIMITIVE_OVERFLOW_GETVM()->overflow_fixnum_multiply(x,y);
}
VM_C_API fixnum to_fixnum(cell tagged, factorvm *vm);
VM_C_API cell to_cell(cell tagged, factorvm *vm);
-VM_ASM_API void overflow_fixnum_add(fixnum x, fixnum y, factorvm *vm);
-VM_ASM_API void overflow_fixnum_subtract(fixnum x, fixnum y, factorvm *vm);
-VM_ASM_API void overflow_fixnum_multiply(fixnum x, fixnum y, factorvm *vm);
+VM_ASM_API_OVERFLOW void overflow_fixnum_add(fixnum x, fixnum y, factorvm *vm);
+VM_ASM_API_OVERFLOW void overflow_fixnum_subtract(fixnum x, fixnum y, factorvm *vm);
+VM_ASM_API_OVERFLOW void overflow_fixnum_multiply(fixnum x, fixnum y, factorvm *vm);
}
#ifdef FACTOR_SINGLE_THREADED_TESTING
/* calls are dispatched as per multithreaded, but checked against singleton */
extern factorvm *vm;
+ #define ASSERTVM() assert(vm==myvm)
#define PRIMITIVE_GETVM() ((factorvm*)myvm)
- #define PRIMITIVE_OVERFLOW_GETVM() vm
+ #define PRIMITIVE_OVERFLOW_GETVM() ASSERTVM(); myvm
#define VM_PTR myvm
- #define ASSERTVM() assert(vm==myvm)
#define SIGNAL_VM_PTR() tls_vm()
#endif