asm math functions pass vm ptr to overflow function in 3rd arg (X86.32)
parent
3ecff2c0eb
commit
deb7af70bb
|
@ -3,6 +3,7 @@ namespace factor
|
|||
|
||||
#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");
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#define ARG0 %eax
|
||||
#define ARG1 %edx
|
||||
#define ARG2 %ecx
|
||||
#define STACK_REG %esp
|
||||
#define DS_REG %esi
|
||||
#define RETURN_REG %eax
|
||||
|
|
|
@ -7,4 +7,5 @@ register cell ds asm("esi");
|
|||
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)))
|
||||
}
|
||||
|
|
|
@ -7,5 +7,5 @@ register cell ds asm("r14");
|
|||
register cell rs asm("r15");
|
||||
|
||||
#define VM_ASM_API VM_C_API
|
||||
|
||||
#define VM_ASM_API_OVERFLOW VM_C_API
|
||||
}
|
||||
|
|
10
vm/cpu-x86.S
10
vm/cpu-x86.S
|
@ -1,4 +1,5 @@
|
|||
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
|
||||
|
@ -8,7 +9,8 @@ DEF(void,primitive_fixnum_add,(void)):
|
|||
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
|
||||
|
@ -18,7 +20,8 @@ DEF(void,primitive_fixnum_subtract,(void)):
|
|||
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
|
||||
|
@ -28,6 +31,7 @@ DEF(void,primitive_fixnum_multiply,(void)):
|
|||
jo multiply_overflow
|
||||
mov DIV_RESULT,(DS_REG)
|
||||
ret
|
||||
|
||||
multiply_overflow:
|
||||
sar $3,ARITH_TEMP_1
|
||||
mov ARITH_TEMP_1,ARG0
|
||||
|
|
|
@ -842,7 +842,7 @@ inline void factorvm::overflow_fixnum_add(fixnum x, fixnum y)
|
|||
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);
|
||||
}
|
||||
|
@ -853,7 +853,7 @@ inline void factorvm::overflow_fixnum_subtract(fixnum x, fixnum 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);
|
||||
}
|
||||
|
@ -867,7 +867,7 @@ inline void factorvm::overflow_fixnum_multiply(fixnum x, fixnum 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);
|
||||
}
|
||||
|
|
|
@ -83,8 +83,8 @@ VM_C_API u64 to_unsigned_8(cell obj, factorvm *vm);
|
|||
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);
|
||||
|
||||
}
|
||||
|
|
|
@ -626,10 +626,10 @@ struct factorvm : factorvmdata {
|
|||
#ifdef FACTOR_SINGLE_THREADED_TESTING
|
||||
/* calls are dispatched as per multithreaded, but checked against singleton */
|
||||
extern factorvm *vm;
|
||||
#define PRIMITIVE_GETVM() ((factorvm*)myvm)
|
||||
#define PRIMITIVE_OVERFLOW_GETVM() vm
|
||||
#define VM_PTR myvm
|
||||
#define ASSERTVM() assert(vm==myvm)
|
||||
#define PRIMITIVE_GETVM() ((factorvm*)myvm)
|
||||
#define PRIMITIVE_OVERFLOW_GETVM() ASSERTVM(); myvm
|
||||
#define VM_PTR myvm
|
||||
#define SIGNAL_VM_PTR() tls_vm()
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue