From 57011aed515ea1bcb10213b9ce417c04c42ebae1 Mon Sep 17 00:00:00 2001 From: Phil Dawes Date: Tue, 18 Aug 2009 20:49:22 +0100 Subject: [PATCH] vm ptr passed to primitives on X86.32 (other cpus still use singleton vm ptr) --- basis/cpu/x86/32/bootstrap.factor | 2 ++ vm/cpu-x86.32.hpp | 1 - vm/master.hpp | 2 +- vm/primitives.hpp | 14 ++++++++++---- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor index 674cc817d7..da55ea5ccd 100644 --- a/basis/cpu/x86/32/bootstrap.factor +++ b/basis/cpu/x86/32/bootstrap.factor @@ -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 diff --git a/vm/cpu-x86.32.hpp b/vm/cpu-x86.32.hpp index 902b33b0b4..351865f776 100644 --- a/vm/cpu-x86.32.hpp +++ b/vm/cpu-x86.32.hpp @@ -7,5 +7,4 @@ register cell ds asm("esi"); register cell rs asm("edi"); #define VM_ASM_API VM_C_API __attribute__ ((regparm (2))) - } diff --git a/vm/master.hpp b/vm/master.hpp index c5c14e6999..bf60d1e4f6 100755 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -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" diff --git a/vm/primitives.hpp b/vm/primitives.hpp index c7534ec1cc..c6d704ffc7 100644 --- a/vm/primitives.hpp +++ b/vm/primitives.hpp @@ -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[]; }