]> gitweb.factorcode.org Git - factor.git/commitdiff
vm ptr passed to primitives on X86.32 (other cpus still use singleton vm ptr)
authorPhil Dawes <phil@phildawes.net>
Tue, 18 Aug 2009 19:49:22 +0000 (20:49 +0100)
committerPhil Dawes <phil@phildawes.net>
Wed, 16 Sep 2009 07:16:30 +0000 (08:16 +0100)
basis/cpu/x86/32/bootstrap.factor
vm/cpu-x86.32.hpp
vm/master.hpp
vm/primitives.hpp

index 674cc817d7a6e83a03cbddc56ab0c89f6377acc0..da55ea5ccdfb51f073c0d0a6f7b7840ab97f6f4f 100644 (file)
@@ -27,6 +27,8 @@ IN: bootstrap.x86
     temp0 0 [] MOV rc-absolute-cell rt-stack-chain jit-rel
     ! save stack pointer
     temp0 [] stack-reg MOV
+    ! pass vm ptr to primitive
+    EAX 0 MOV rc-absolute-cell rt-vm jit-rel
     ! call the primitive
     0 JMP rc-relative rt-primitive jit-rel
 ] jit-primitive jit-define
index 902b33b0b4371cdbf5617c6243ea956d6cae12f4..351865f776183d8c1e1c005eb4e03815dda5aef7 100644 (file)
@@ -7,5 +7,4 @@ register cell ds asm("esi");
 register cell rs asm("edi");
 
 #define VM_ASM_API VM_C_API __attribute__ ((regparm (2)))
-
 }
index c5c14e6999e3e9f0e3a7b30085878a5af2e44174..bf60d1e4f6c533322a664b77d0ed5b5a0481aee6 100755 (executable)
@@ -35,8 +35,8 @@
 
 /* Factor headers */
 #include "layouts.hpp"
-#include "primitives.hpp"
 #include "platform.hpp"
+#include "primitives.hpp"
 #include "stacks.hpp"
 #include "segments.hpp"
 #include "contexts.hpp"
index c7534ec1ccd519b5686cefa6a1a1dbbce9cd2216..c6d704ffc74e0cd99a4c867b3dd5f53c1f9c1fc9 100644 (file)
@@ -1,9 +1,15 @@
 namespace factor
 {
 
-extern "C" typedef void (*primitive_type)();
-extern const primitive_type primitives[];
+#if defined(FACTOR_X86)
+  extern "C" __attribute__ ((regparm (1))) typedef void (*primitive_type)(void *myvm);
+  #define PRIMITIVE(name) extern "C" __attribute__ ((regparm (1)))  void primitive_##name(void *myvm)
+  #define PRIMITIVE_GETVM() ((factorvm*)myvm)
+#else
+  extern "C" typedef void (*primitive_type)(void *myvm);
+  #define PRIMITIVE(name) extern "C" void primitive_##name(void *myvm)
+  #define PRIMITIVE_GETVM() vm
+#endif
 
-#define PRIMITIVE(name) extern "C" void primitive_##name()
-#define PRIMITIVE_GETVM() vm
+extern const primitive_type primitives[];
 }