diff --git a/basis/cpu/x86/bootstrap.factor b/basis/cpu/x86/bootstrap.factor index 8949b24b1a..5bc5272ab4 100644 --- a/basis/cpu/x86/bootstrap.factor +++ b/basis/cpu/x86/bootstrap.factor @@ -252,7 +252,7 @@ big-endian off ! pop stack ds-reg bootstrap-cell SUB ! pass vm pointer - arg2 0 MOV rc-absolute-cell rt-vm jit-rel + arg2 0 MOV rc-absolute-cell rt-vm jit-rel ! call quotation arg quot-xt-offset [+] JMP ] \ (call) define-sub-primitive diff --git a/vm/cpu-x86.32.S b/vm/cpu-x86.32.S index 87a0e03f99..9d2bf082d1 100644 --- a/vm/cpu-x86.32.S +++ b/vm/cpu-x86.32.S @@ -79,6 +79,19 @@ DEF(void,set_x87_env,(const void*)): fldcw 2(%eax) ret +DEF(F_FASTCALL void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to, void *vm)): + mov CELL_SIZE(STACK_REG),NV_TEMP_REG /* stash vm ptr */ + /* clear x87 stack, but preserve rounding mode and exception flags */ + sub $2,STACK_REG + fnstcw (STACK_REG) + fninit + fldcw (STACK_REG) + /* rewind_to */ + mov ARG1,STACK_REG + mov NV_TEMP_REG,ARG1 + jmp *QUOT_XT_OFFSET(ARG0) + + #include "cpu-x86.S" #ifdef WINDOWS diff --git a/vm/cpu-x86.64.S b/vm/cpu-x86.64.S index 0da360e675..606c81c582 100644 --- a/vm/cpu-x86.64.S +++ b/vm/cpu-x86.64.S @@ -88,6 +88,7 @@ DEF(void,primitive_inline_cache_miss_tail,(void)): add $STACK_PADDING,%rsp jmp *%rax +<<<<<<< HEAD DEF(void,get_sse_env,(void*)): stmxcsr (%rdi) ret @@ -106,4 +107,14 @@ DEF(void,set_x87_env,(const void*)): fldcw 2(%rdi) ret +DEF(F_FASTCALL void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to, void *vm)): + /* clear x87 stack, but preserve rounding mode and exception flags */ + sub $2,STACK_REG + fnstcw (STACK_REG) + fninit + fldcw (STACK_REG) + /* rewind_to */ + mov ARG1,STACK_REG + jmp *QUOT_XT_OFFSET(ARG0) + #include "cpu-x86.S" diff --git a/vm/cpu-x86.S b/vm/cpu-x86.S index 384bd794c5..03f08fdabc 100644 --- a/vm/cpu-x86.S +++ b/vm/cpu-x86.S @@ -37,7 +37,6 @@ multiply_overflow: DEF(F_FASTCALL void,c_to_factor,(CELL quot, void *vm)): PUSH_NONVOLATILE mov ARG0,NV_TEMP_REG - //mov $35,ARG1 /* Create register shadow area for Win64 */ sub $32,STACK_REG @@ -57,16 +56,6 @@ DEF(F_FASTCALL void,c_to_factor,(CELL quot, void *vm)): POP_NONVOLATILE ret -DEF(F_FASTCALL void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to)): - /* clear x87 stack, but preserve rounding mode and exception flags */ - sub $2,STACK_REG - fnstcw (STACK_REG) - fninit - fldcw (STACK_REG) - /* rewind_to */ - mov ARG1,STACK_REG - jmp *QUOT_XT_OFFSET(ARG0) - DEF(F_FASTCALL void,lazy_jit_compile,(CELL quot, void *vm)): mov ARG1,NV_TEMP_REG /* stash vm ptr */ mov STACK_REG,ARG1 /* Save stack pointer */ diff --git a/vm/cpu-x86.hpp b/vm/cpu-x86.hpp index cf706a62b0..8fe0cc4b10 100644 --- a/vm/cpu-x86.hpp +++ b/vm/cpu-x86.hpp @@ -70,7 +70,7 @@ inline static unsigned int fpu_status(unsigned int status) /* Defined in assembly */ VM_ASM_API void c_to_factor(cell quot,void *vm); -VM_ASM_API void throw_impl(cell quot, stack_frame *rewind_to); +VM_ASM_API void throw_impl(cell quot, stack_frame *rewind_to, void *vm); VM_ASM_API void lazy_jit_compile(cell quot, void *vm); VM_C_API void set_callstack(stack_frame *to, diff --git a/vm/errors.cpp b/vm/errors.cpp index f2cab405a8..e1266cf608 100755 --- a/vm/errors.cpp +++ b/vm/errors.cpp @@ -78,7 +78,7 @@ void factorvm::throw_error(cell error, stack_frame *callstack_top) else callstack_top = stack_chain->callstack_top; - throw_impl(userenv[BREAK_ENV],callstack_top); + throw_impl(userenv[BREAK_ENV],callstack_top,this); } /* Error was thrown in early startup before error handler is set, just crash. */ @@ -167,7 +167,7 @@ void factorvm::fp_trap_error(unsigned int fpu_status, stack_frame *signal_callst inline void factorvm::vmprim_call_clear() { - throw_impl(dpop(),stack_chain->callstack_bottom); + throw_impl(dpop(),stack_chain->callstack_bottom,this); } PRIMITIVE(call_clear) diff --git a/vm/quotations.cpp b/vm/quotations.cpp index 34fe6a12a6..9654e2eff3 100755 --- a/vm/quotations.cpp +++ b/vm/quotations.cpp @@ -370,7 +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) { - return vm->lazy_jit_compile_impl(quot_,stack); + return VM_PTR->lazy_jit_compile_impl(quot_,stack); } inline void factorvm::vmprim_quot_compiled_p()