]> gitweb.factorcode.org Git - factor.git/commitdiff
passing vm ptr to lazy_jit_compile mostly working
authorPhil Dawes <phil@phildawes.net>
Wed, 19 Aug 2009 18:02:12 +0000 (19:02 +0100)
committerPhil Dawes <phil@phildawes.net>
Wed, 16 Sep 2009 07:16:30 +0000 (08:16 +0100)
14 files changed:
basis/cpu/x86/32/32.factor
basis/cpu/x86/32/bootstrap.factor
basis/cpu/x86/64/unix/bootstrap.factor
basis/cpu/x86/64/winnt/bootstrap.factor
basis/cpu/x86/bootstrap.factor
vm/cpu-ppc.hpp
vm/cpu-x86.S
vm/cpu-x86.hpp
vm/os-genunix.cpp
vm/os-macosx.mm
vm/os-windows-ce.cpp
vm/os-windows-nt.cpp
vm/quotations.cpp
vm/quotations.hpp

index 3ec08d5507751b4ac676cc9511f7c9d5efeb7c43..a48528d3fdb49503048c6c70f33e05e4e17bd8d5 100755 (executable)
@@ -240,6 +240,7 @@ M: x86.32 %alien-callback ( quot -- )
     4 [
         EAX swap %load-reference
         EAX PUSH
+        param-reg-2 0 MOV rc-absolute-cell rt-vm rel-fixup 
         "c_to_factor" f %alien-invoke
     ] with-aligned-stack ;
 
index da55ea5ccdfb51f073c0d0a6f7b7840ab97f6f4f..afa7c245a07adf7c6dad5e5782cb6ff59c7a33e9 100644 (file)
@@ -12,6 +12,7 @@ IN: bootstrap.x86
 : div-arg ( -- reg ) EAX ;
 : mod-arg ( -- reg ) EDX ;
 : arg ( -- reg ) EAX ;
+: arg2 ( -- reg ) EDX ;
 : temp0 ( -- reg ) EAX ;
 : temp1 ( -- reg ) EDX ;
 : temp2 ( -- reg ) ECX ;
index b6d56840e26e85c2d194517f75c3b8825d087059..199fe8daf4a6c9c8dd815742aa2f2018f26d5c42 100644 (file)
@@ -6,6 +6,7 @@ IN: bootstrap.x86
 
 : stack-frame-size ( -- n ) 4 bootstrap-cells ;
 : arg ( -- reg ) RDI ;
+: arg2 ( -- reg ) RSI ;
 
 << "vocab:cpu/x86/64/bootstrap.factor" parse-file parsed >>
 call
index 0228082956a557288b6a8b63471051ac6fc70f78..72b9d27ca4b5fde7ccd75c048e0f1bfe0fbc39b8 100644 (file)
@@ -7,6 +7,7 @@ IN: bootstrap.x86
 
 : stack-frame-size ( -- n ) 8 bootstrap-cells ;
 : arg ( -- reg ) RCX ;
+: arg2 ( -- reg ) RDX ;
 
 << "vocab:cpu/x86/64/bootstrap.factor" parse-file parsed >>
 call
index 0dafc3d9c4d1cf5f84d08e8832673917a6d0b63c..8949b24b1a6ab909151a6f94f5052bd2eecab50e 100644 (file)
@@ -251,6 +251,8 @@ big-endian off
     arg ds-reg [] MOV
     ! pop stack
     ds-reg bootstrap-cell SUB
+    ! pass vm pointer
+    arg2 0 MOV rc-absolute-cell rt-vm jit-rel    
     ! call quotation
     arg quot-xt-offset [+] JMP
 ] \ (call) define-sub-primitive
index 2124e03350511e5e4ce14f1b85a5214cf1bfed16..495eb375ec6dd7fff3fa93aaa9baf64eceefd40b 100644 (file)
@@ -81,9 +81,9 @@ inline static unsigned int fpu_status(unsigned int status)
 }
 
 /* Defined in assembly */
-VM_ASM_API void c_to_factor(cell quot);
-VM_ASM_API void throw_impl(cell quot, stack_frame *rewind);
-VM_ASM_API void lazy_jit_compile(cell quot);
+VM_ASM_API void c_to_factor(cell quot, void *vm);
+VM_ASM_API void throw_impl(cell quot, stack_frame *rewind, void *vm);
+VM_ASM_API void lazy_jit_compile(cell quot, void *vm);
 VM_ASM_API void flush_icache(cell start, cell len);
 
 VM_ASM_API void set_callstack(stack_frame *to,
index d229b2cb79571187ec13ff2dba10a7b844fa21ef..384bd794c5209126beecce2b9ed2d0d2e4fd2a8b 100644 (file)
@@ -34,17 +34,19 @@ multiply_overflow:
        mov ARITH_TEMP_2,ARG1
        jmp MANGLE(overflow_fixnum_multiply)
 
-DEF(F_FASTCALL void,c_to_factor,(CELL quot)):
+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
 
        /* Save stack pointer */
        lea -CELL_SIZE(STACK_REG),ARG0
+       push ARG1  /* save vm ptr */
        call MANGLE(save_callstack_bottom)
-
+       pop ARG1
+       
        /* Call quot-xt */
        mov NV_TEMP_REG,ARG0
        call *QUOT_XT_OFFSET(ARG0)
@@ -65,10 +67,13 @@ DEF(F_FASTCALL void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to)):
        mov ARG1,STACK_REG                    
        jmp *QUOT_XT_OFFSET(ARG0)
 
-DEF(F_FASTCALL void,lazy_jit_compile,(CELL quot)):
+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 */
        sub $STACK_PADDING,STACK_REG
+       push NV_TEMP_REG             /* push vm ptr as arg3 */
        call MANGLE(lazy_jit_compile_impl)
+       pop NV_TEMP_REG
        mov RETURN_REG,ARG0          /* No-op on 32-bit */
        add $STACK_PADDING,STACK_REG
         jmp *QUOT_XT_OFFSET(ARG0)    /* Call the quotation */
index 4a37a1788969119797271b9586a9056ea992fe40..cf706a62b0d2c86277879a184a77ff671b7f07e3 100644 (file)
@@ -69,9 +69,9 @@ inline static unsigned int fpu_status(unsigned int status)
 }
 
 /* Defined in assembly */
-VM_ASM_API void c_to_factor(cell quot);
+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 lazy_jit_compile(cell quot);
+VM_ASM_API void lazy_jit_compile(cell quot, void *vm);
 
 VM_C_API void set_callstack(stack_frame *to,
                              stack_frame *from,
index 6cca455eb747381b0e2d6d7c6763861f51c3b0aa..29c3e79859dbada3061adc2cc053b200a22408e5 100644 (file)
@@ -5,7 +5,7 @@ namespace factor
 
 void c_to_factor_toplevel(cell quot)
 {
-       c_to_factor(quot);
+       c_to_factor(quot,vm);
 }
 
 void init_signals()
index c7e9c0bf6bd4ac6dc3f800742e53b3ed02cc40e7..865371b8ac431503a5183ce4f6ee5611ae218b56 100644 (file)
@@ -10,7 +10,7 @@ void c_to_factor_toplevel(cell quot)
        for(;;)
        {
 NS_DURING
-               c_to_factor(quot);
+               c_to_factor(quot,vm);
                NS_VOIDRETURN;
 NS_HANDLER
                dpush(vm->allot_alien(F,(cell)localException));
index 2e69a1eb5bab85f2d099085409fec25444a3c1ae..a3192b07f5fc9ebb3f0c276d40995c47db0201fd 100644 (file)
@@ -37,7 +37,7 @@ PRIMITIVE(os_envs)
 
 void c_to_factor_toplevel(cell quot)
 {
-       c_to_factor(quot);
+       c_to_factor(quot,vm);
 }
 
 void open_console() { }
index 26781ee4f9ae4ea03e994729546950777369025f..535e7b8640c5ec674ffd87f4c6b09272d4a6c400 100755 (executable)
@@ -62,7 +62,7 @@ void factorvm::c_to_factor_toplevel(cell quot)
 {
        if(!AddVectoredExceptionHandler(0, (PVECTORED_EXCEPTION_HANDLER)exception_handler))
                fatal_error("AddVectoredExceptionHandler failed", 0);
-       c_to_factor(quot);
+       c_to_factor(quot,this);
        RemoveVectoredExceptionHandler((void *)exception_handler);
 }
 
index b7bce0bfd76aef97f11539358fbaaf0d9f25b03b..34fe6a12a6759dedcaf4900d0d3e56a6d2e61f1a 100755 (executable)
@@ -368,7 +368,7 @@ cell factorvm::lazy_jit_compile_impl(cell quot_, stack_frame *stack)
        return quot.value();
 }
 
-VM_ASM_API cell 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);
 }
index 6c8b17db21fb5620dbeb5611a18df8e7d58291d2..ae24a522f9c1ce0e9316111a2fc43abae6bcf3a3 100755 (executable)
@@ -27,7 +27,7 @@ PRIMITIVE(jit_compile);
 PRIMITIVE(array_to_quotation);
 PRIMITIVE(quotation_xt);
 
-VM_ASM_API cell lazy_jit_compile_impl(cell quot, stack_frame *stack);
+VM_ASM_API cell lazy_jit_compile_impl(cell quot, stack_frame *stack, factorvm *myvm);
 
 PRIMITIVE(quot_compiled_p);