vm: remove VM_ASM_API
parent
2b8521a326
commit
15eb8d1a0a
|
@ -53,10 +53,6 @@ M:: x86.32 %dispatch ( src temp -- )
|
||||||
[ align-code ]
|
[ align-code ]
|
||||||
bi ;
|
bi ;
|
||||||
|
|
||||||
! Registers for fastcall
|
|
||||||
: param-reg-1 ( -- reg ) EAX ;
|
|
||||||
: param-reg-2 ( -- reg ) EDX ;
|
|
||||||
|
|
||||||
M: x86.32 pic-tail-reg EBX ;
|
M: x86.32 pic-tail-reg EBX ;
|
||||||
|
|
||||||
M: x86.32 reserved-stack-space 4 cells ;
|
M: x86.32 reserved-stack-space 4 cells ;
|
||||||
|
@ -242,7 +238,8 @@ M: x86.32 %alien-indirect ( -- )
|
||||||
|
|
||||||
M: x86.32 %alien-callback ( quot -- )
|
M: x86.32 %alien-callback ( quot -- )
|
||||||
EAX swap %load-reference
|
EAX swap %load-reference
|
||||||
EDX %mov-vm-ptr
|
0 stack@ EAX MOV
|
||||||
|
4 save-vm-ptr
|
||||||
"c_to_factor" f %alien-invoke ;
|
"c_to_factor" f %alien-invoke ;
|
||||||
|
|
||||||
M: x86.32 %callback-value ( ctype -- )
|
M: x86.32 %callback-value ( ctype -- )
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2007, 2009 Slava Pestov.
|
! Copyright (C) 2007, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: bootstrap.image.private kernel namespaces system
|
USING: bootstrap.image.private kernel kernel.private namespaces
|
||||||
cpu.x86.assembler cpu.x86.assembler.operands layouts
|
system cpu.x86.assembler cpu.x86.assembler.operands layouts
|
||||||
vocabs parser compiler.constants sequences math math.private
|
vocabs parser compiler.constants sequences math math.private
|
||||||
generic.single.private ;
|
generic.single.private ;
|
||||||
IN: bootstrap.x86
|
IN: bootstrap.x86
|
||||||
|
@ -12,8 +12,6 @@ IN: bootstrap.x86
|
||||||
: shift-arg ( -- reg ) ECX ;
|
: shift-arg ( -- reg ) ECX ;
|
||||||
: div-arg ( -- reg ) EAX ;
|
: div-arg ( -- reg ) EAX ;
|
||||||
: mod-arg ( -- reg ) EDX ;
|
: mod-arg ( -- reg ) EDX ;
|
||||||
: arg1 ( -- reg ) EAX ;
|
|
||||||
: arg2 ( -- reg ) EDX ;
|
|
||||||
: temp0 ( -- reg ) EAX ;
|
: temp0 ( -- reg ) EAX ;
|
||||||
: temp1 ( -- reg ) EDX ;
|
: temp1 ( -- reg ) EDX ;
|
||||||
: temp2 ( -- reg ) ECX ;
|
: temp2 ( -- reg ) ECX ;
|
||||||
|
@ -67,6 +65,33 @@ IN: bootstrap.x86
|
||||||
jit-restore-context
|
jit-restore-context
|
||||||
] jit-primitive jit-define
|
] jit-primitive jit-define
|
||||||
|
|
||||||
|
[
|
||||||
|
! load from stack
|
||||||
|
EAX ds-reg [] MOV
|
||||||
|
! pop stack
|
||||||
|
ds-reg bootstrap-cell SUB
|
||||||
|
! load VM pointer
|
||||||
|
EDX 0 MOV 0 rc-absolute-cell jit-vm
|
||||||
|
]
|
||||||
|
[
|
||||||
|
|
||||||
|
! pass quotation
|
||||||
|
ESP [] EAX MOV
|
||||||
|
! pass VM pointer
|
||||||
|
ESP 4 [+] EDX MOV
|
||||||
|
! call XT
|
||||||
|
EAX quot-xt-offset [+] CALL
|
||||||
|
]
|
||||||
|
[
|
||||||
|
! pass quotation
|
||||||
|
ESP 4 [+] EAX MOV
|
||||||
|
! pass VM pointer
|
||||||
|
ESP 8 [+] EDX MOV
|
||||||
|
! jump to XT
|
||||||
|
EAX quot-xt-offset [+] JMP
|
||||||
|
]
|
||||||
|
\ (call) define-sub-primitive*
|
||||||
|
|
||||||
! Inline cache miss entry points
|
! Inline cache miss entry points
|
||||||
: jit-load-return-address ( -- )
|
: jit-load-return-address ( -- )
|
||||||
EBX ESP stack-frame-size bootstrap-cell - [+] MOV ;
|
EBX ESP stack-frame-size bootstrap-cell - [+] MOV ;
|
||||||
|
@ -103,7 +128,9 @@ IN: bootstrap.x86
|
||||||
ds-reg [] ECX MOV
|
ds-reg [] ECX MOV
|
||||||
[ JNO ]
|
[ JNO ]
|
||||||
[
|
[
|
||||||
ECX EBP MOV
|
ESP [] EAX MOV
|
||||||
|
ESP 4 [+] EDX MOV
|
||||||
|
ESP 8 [+] EBP MOV
|
||||||
[ 0 CALL ] dip f rc-relative jit-dlsym
|
[ 0 CALL ] dip f rc-relative jit-dlsym
|
||||||
]
|
]
|
||||||
jit-conditional ;
|
jit-conditional ;
|
||||||
|
@ -124,10 +151,10 @@ IN: bootstrap.x86
|
||||||
ds-reg [] EAX MOV
|
ds-reg [] EAX MOV
|
||||||
[ JNO ]
|
[ JNO ]
|
||||||
[
|
[
|
||||||
EAX ECX MOV
|
ECX tag-bits get SAR
|
||||||
EAX tag-bits get SAR
|
ESP [] ECX MOV
|
||||||
EDX EBX MOV
|
ESP 4 [+] EBX MOV
|
||||||
ECX EBP MOV
|
ESP 8 [+] EBP MOV
|
||||||
0 CALL "overflow_fixnum_multiply" f rc-relative jit-dlsym
|
0 CALL "overflow_fixnum_multiply" f rc-relative jit-dlsym
|
||||||
]
|
]
|
||||||
jit-conditional
|
jit-conditional
|
||||||
|
|
|
@ -120,30 +120,18 @@ big-endian off
|
||||||
|
|
||||||
[
|
[
|
||||||
! load from stack
|
! load from stack
|
||||||
arg1 ds-reg [] MOV
|
temp0 ds-reg [] MOV
|
||||||
! pop stack
|
|
||||||
ds-reg bootstrap-cell SUB
|
|
||||||
! pass vm pointer
|
|
||||||
arg2 0 MOV 0 rc-absolute-cell jit-vm
|
|
||||||
]
|
|
||||||
[ arg1 quot-xt-offset [+] CALL ]
|
|
||||||
[ arg1 quot-xt-offset [+] JMP ]
|
|
||||||
\ (call) define-sub-primitive*
|
|
||||||
|
|
||||||
[
|
|
||||||
! load from stack
|
|
||||||
arg1 ds-reg [] MOV
|
|
||||||
! pop stack
|
! pop stack
|
||||||
ds-reg bootstrap-cell SUB
|
ds-reg bootstrap-cell SUB
|
||||||
]
|
]
|
||||||
[ arg1 word-xt-offset [+] CALL ]
|
[ temp0 word-xt-offset [+] CALL ]
|
||||||
[ arg1 word-xt-offset [+] JMP ]
|
[ temp0 word-xt-offset [+] JMP ]
|
||||||
\ (execute) define-sub-primitive*
|
\ (execute) define-sub-primitive*
|
||||||
|
|
||||||
[
|
[
|
||||||
arg1 ds-reg [] MOV
|
temp0 ds-reg [] MOV
|
||||||
ds-reg bootstrap-cell SUB
|
ds-reg bootstrap-cell SUB
|
||||||
arg1 word-xt-offset [+] JMP
|
temp0 word-xt-offset [+] JMP
|
||||||
] jit-execute jit-define
|
] jit-execute jit-define
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
|
@ -73,7 +73,7 @@ void code_block_visitor<Visitor>::visit_object_code_block(object *obj)
|
||||||
if(q->code)
|
if(q->code)
|
||||||
parent->set_quot_xt(q,visitor(q->code));
|
parent->set_quot_xt(q,visitor(q->code));
|
||||||
else
|
else
|
||||||
q->xt = (void *)lazy_jit_compile;
|
q->xt = (void *)lazy_jit_compile_impl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CALLSTACK_TYPE:
|
case CALLSTACK_TYPE:
|
||||||
|
|
|
@ -225,11 +225,11 @@ DEF(void,throw_impl,(cell quot, F_STACK_FRAME *rewind_to, void *vm)):
|
||||||
mtlr r0
|
mtlr r0
|
||||||
JUMP_QUOT /* call the quotation */
|
JUMP_QUOT /* call the quotation */
|
||||||
|
|
||||||
DEF(void,lazy_jit_compile,(cell quot, void *vm)):
|
DEF(void,lazy_jit_compile_impl,(cell quot, void *vm)):
|
||||||
mr r5,r4 /* vm ptr is 3rd arg */
|
mr r5,r4 /* vm ptr is 3rd arg */
|
||||||
mr r4,r1 /* save stack pointer */
|
mr r4,r1 /* save stack pointer */
|
||||||
PROLOGUE
|
PROLOGUE
|
||||||
bl MANGLE(lazy_jit_compile_impl)
|
bl MANGLE(lazy_jit_compile)
|
||||||
EPILOGUE
|
EPILOGUE
|
||||||
JUMP_QUOT /* call the quotation */
|
JUMP_QUOT /* call the quotation */
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ namespace factor
|
||||||
{
|
{
|
||||||
|
|
||||||
#define FACTOR_CPU_STRING "ppc"
|
#define FACTOR_CPU_STRING "ppc"
|
||||||
#define VM_ASM_API VM_C_API
|
|
||||||
|
|
||||||
/* In the instruction sequence:
|
/* In the instruction sequence:
|
||||||
|
|
||||||
|
@ -80,7 +79,7 @@ inline static unsigned int fpu_status(unsigned int status)
|
||||||
/* Defined in assembly */
|
/* Defined in assembly */
|
||||||
VM_C_API void c_to_factor(cell quot, void *vm);
|
VM_C_API void c_to_factor(cell quot, void *vm);
|
||||||
VM_C_API void throw_impl(cell quot, void *new_stack, void *vm);
|
VM_C_API void throw_impl(cell quot, void *new_stack, void *vm);
|
||||||
VM_C_API void lazy_jit_compile(cell quot, void *vm);
|
VM_C_API void lazy_jit_compile_impl(cell quot, void *vm);
|
||||||
VM_C_API void flush_icache(cell start, cell len);
|
VM_C_API void flush_icache(cell start, cell len);
|
||||||
|
|
||||||
VM_C_API void set_callstack(
|
VM_C_API void set_callstack(
|
||||||
|
|
152
vm/cpu-x86.32.S
152
vm/cpu-x86.32.S
|
@ -1,50 +1,102 @@
|
||||||
#include "asm.h"
|
#include "asm.h"
|
||||||
|
|
||||||
#define ARG0 %eax
|
|
||||||
#define ARG1 %edx
|
|
||||||
#define ARG2 %ecx
|
|
||||||
#define STACK_REG %esp
|
|
||||||
#define DS_REG %esi
|
#define DS_REG %esi
|
||||||
#define RS_REG %edi
|
#define RS_REG %edi
|
||||||
#define RETURN_REG %eax
|
#define RETURN_REG %eax
|
||||||
|
|
||||||
#define NV0 %ebx
|
|
||||||
#define NV1 %ebp
|
|
||||||
|
|
||||||
#define CELL_SIZE 4
|
|
||||||
#define STACK_PADDING 12
|
|
||||||
|
|
||||||
#define PUSH_NONVOLATILE \
|
|
||||||
push %ebx ; \
|
|
||||||
push %ebp ; \
|
|
||||||
push %esi ; \
|
|
||||||
push %edi
|
|
||||||
|
|
||||||
#define POP_NONVOLATILE \
|
|
||||||
pop %edi ; \
|
|
||||||
pop %esi ; \
|
|
||||||
pop %ebp ; \
|
|
||||||
pop %ebx
|
|
||||||
|
|
||||||
#define QUOT_XT_OFFSET 12
|
#define QUOT_XT_OFFSET 12
|
||||||
|
|
||||||
|
DEF(void,c_to_factor,(cell quot, void *vm)):
|
||||||
|
/* Load parameters */
|
||||||
|
mov 4(%esp),%eax
|
||||||
|
mov 8(%esp),%edx
|
||||||
|
|
||||||
|
/* Save non-volatile registers */
|
||||||
|
push %ebx
|
||||||
|
push %ebp
|
||||||
|
push %esi
|
||||||
|
push %edi
|
||||||
|
|
||||||
|
/* Save old stack pointer and align */
|
||||||
|
mov %esp,%ebp
|
||||||
|
and $-16,%esp
|
||||||
|
push %ebp
|
||||||
|
|
||||||
|
/* Set up stack frame for the call to the boot quotation */
|
||||||
|
sub $4,%esp
|
||||||
|
push %edx
|
||||||
|
push %eax
|
||||||
|
|
||||||
|
/* Load context */
|
||||||
|
mov (%edx),%ecx
|
||||||
|
|
||||||
|
/* Load ctx->datastack */
|
||||||
|
mov 8(%ecx),DS_REG
|
||||||
|
|
||||||
|
/* Load ctx->retainstack */
|
||||||
|
mov 12(%ecx),RS_REG
|
||||||
|
|
||||||
|
/* Save ctx->callstack_bottom */
|
||||||
|
lea -4(%esp),%ebx
|
||||||
|
mov %ebx,4(%ecx)
|
||||||
|
|
||||||
|
/* Call quot-xt. Parameters are already on the stack */
|
||||||
|
call *QUOT_XT_OFFSET(%eax)
|
||||||
|
|
||||||
|
/* Tear down stack frame for the call to the boot quotation */
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
add $4,%esp
|
||||||
|
|
||||||
|
/* Undo stack alignment */
|
||||||
|
pop %ebp
|
||||||
|
mov %ebp,%esp
|
||||||
|
|
||||||
|
/* Load context */
|
||||||
|
mov (%edx),%ecx
|
||||||
|
|
||||||
|
/* Save ctx->datastack */
|
||||||
|
mov DS_REG,8(%ecx)
|
||||||
|
|
||||||
|
/* Save ctx->retainstack */
|
||||||
|
mov RS_REG,12(%ecx)
|
||||||
|
|
||||||
|
/* Restore non-volatile registers */
|
||||||
|
pop %edi
|
||||||
|
pop %esi
|
||||||
|
pop %ebp
|
||||||
|
pop %ebx
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
DEF(void,set_callstack,(void *vm, stack_frame *to, stack_frame *from, cell length, void *memcpy)):
|
DEF(void,set_callstack,(void *vm, stack_frame *to, stack_frame *from, cell length, void *memcpy)):
|
||||||
mov 4(%esp),%ebx /* vm */
|
/* load arguments */
|
||||||
|
mov 4(%esp),%ebx /* vm - to non-volatile register */
|
||||||
mov 8(%esp),%ebp /* to */
|
mov 8(%esp),%ebp /* to */
|
||||||
mov 12(%esp),%edx /* from */
|
mov 12(%esp),%edx /* from */
|
||||||
mov 16(%esp),%ecx /* length */
|
mov 16(%esp),%ecx /* length */
|
||||||
mov 20(%esp),%eax /* memcpy */
|
mov 20(%esp),%eax /* memcpy */
|
||||||
sub %ecx,%ebp /* compute new stack pointer */
|
|
||||||
|
/* compute new stack pointer */
|
||||||
|
sub %ecx,%ebp
|
||||||
mov %ebp,%esp
|
mov %ebp,%esp
|
||||||
|
|
||||||
|
/* call memcpy */
|
||||||
push %ecx /* pass length */
|
push %ecx /* pass length */
|
||||||
push %edx /* pass src */
|
push %edx /* pass src */
|
||||||
push %ebp /* pass dst */
|
push %ebp /* pass dst */
|
||||||
call *%eax /* call memcpy */
|
call *%eax
|
||||||
add $12,%esp /* pop args from the stack */
|
add $12,%esp
|
||||||
mov (%ebx),%ebx /* load context */
|
|
||||||
mov 8(%ebx),DS_REG /* load datastack */
|
/* load context */
|
||||||
mov 12(%ebx),RS_REG /* load retainstack */
|
mov (%ebx),%ecx
|
||||||
ret /* return _with new stack_ */
|
/* load datastack */
|
||||||
|
mov 8(%ecx),DS_REG
|
||||||
|
/* load retainstack */
|
||||||
|
mov 12(%ecx),RS_REG
|
||||||
|
|
||||||
|
/* return with new stack */
|
||||||
|
ret
|
||||||
|
|
||||||
DEF(void,throw_impl,(cell quot, void *new_stack, void *vm)):
|
DEF(void,throw_impl,(cell quot, void *new_stack, void *vm)):
|
||||||
/* clear x87 stack, but preserve rounding mode and exception flags */
|
/* clear x87 stack, but preserve rounding mode and exception flags */
|
||||||
|
@ -53,36 +105,50 @@ DEF(void,throw_impl,(cell quot, void *new_stack, void *vm)):
|
||||||
fninit
|
fninit
|
||||||
fldcw (%esp)
|
fldcw (%esp)
|
||||||
add $2,%esp
|
add $2,%esp
|
||||||
|
|
||||||
/* load quotation and vm parameters */
|
/* load quotation and vm parameters */
|
||||||
mov 4(%esp),%eax
|
mov 4(%esp),%eax
|
||||||
mov 12(%esp),%edx
|
mov 12(%esp),%edx
|
||||||
|
|
||||||
/* load new stack pointer */
|
/* load new stack pointer */
|
||||||
mov 8(%esp),%esp
|
mov 8(%esp),%esp
|
||||||
|
|
||||||
/* load context */
|
/* load context */
|
||||||
mov (%edx),%ebx
|
mov (%edx),%ecx
|
||||||
/* load datastack */
|
/* load datastack */
|
||||||
mov 8(%ebx),DS_REG
|
mov 8(%ecx),DS_REG
|
||||||
/* load retainstack */
|
/* load retainstack */
|
||||||
mov 12(%ebx),RS_REG
|
mov 12(%ecx),RS_REG
|
||||||
|
|
||||||
|
/* pass arguments to error handler */
|
||||||
|
mov %eax,4(%esp)
|
||||||
|
mov %edx,8(%esp)
|
||||||
|
|
||||||
/* call the error handler */
|
/* call the error handler */
|
||||||
jmp *QUOT_XT_OFFSET(%eax)
|
jmp *QUOT_XT_OFFSET(%eax)
|
||||||
|
|
||||||
DEF(VM_ASM_API void,lazy_jit_compile,(cell quot, void *vm)):
|
DEF(void,lazy_jit_compile_impl,(cell quot, void *vm)):
|
||||||
|
/* load arguments */
|
||||||
|
mov 4(%esp),%eax
|
||||||
|
mov 8(%esp),%edx
|
||||||
|
|
||||||
/* load context */
|
/* load context */
|
||||||
mov (ARG1),%ebx
|
mov (%edx),%ecx
|
||||||
|
/* save datastack */
|
||||||
|
mov DS_REG,8(%ecx)
|
||||||
|
/* save retainstack */
|
||||||
|
mov RS_REG,12(%ecx)
|
||||||
/* save callstack */
|
/* save callstack */
|
||||||
lea -4(%esp),%ebp
|
lea -4(%esp),%ebp
|
||||||
mov %ebp,(%ebx)
|
mov %ebp,(%ecx)
|
||||||
/* save datastack */
|
|
||||||
mov DS_REG,8(%ebx)
|
|
||||||
/* save retainstack */
|
|
||||||
mov RS_REG,12(%ebx)
|
|
||||||
/* compile quotation */
|
/* compile quotation */
|
||||||
sub $4,%esp
|
sub $4,%esp
|
||||||
push ARG1
|
push %edx
|
||||||
push ARG0
|
push %eax
|
||||||
call MANGLE(lazy_jit_compile_impl)
|
call MANGLE(lazy_jit_compile)
|
||||||
add $12,%esp
|
add $12,%esp
|
||||||
|
|
||||||
/* call quotation */
|
/* call quotation */
|
||||||
jmp *QUOT_XT_OFFSET(%eax)
|
jmp *QUOT_XT_OFFSET(%eax)
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,5 @@ namespace factor
|
||||||
{
|
{
|
||||||
|
|
||||||
#define FACTOR_CPU_STRING "x86.32"
|
#define FACTOR_CPU_STRING "x86.32"
|
||||||
#define VM_ASM_API VM_C_API __attribute__ ((regparm (3)))
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,52 @@
|
||||||
|
|
||||||
#define QUOT_XT_OFFSET 28
|
#define QUOT_XT_OFFSET 28
|
||||||
|
|
||||||
|
DEF(F_FASTCALL void,c_to_factor,(CELL quot, void *vm)):
|
||||||
|
PUSH_NONVOLATILE
|
||||||
|
mov ARG0,NV0
|
||||||
|
mov ARG1,NV1
|
||||||
|
|
||||||
|
push ARG0
|
||||||
|
push ARG1
|
||||||
|
|
||||||
|
/* Create register shadow area (required for Win64 only) */
|
||||||
|
sub $32,STACK_REG
|
||||||
|
|
||||||
|
/* Load context */
|
||||||
|
mov (NV1),ARG0
|
||||||
|
|
||||||
|
/* Save ctx->callstack_bottom */
|
||||||
|
lea -CELL_SIZE(STACK_REG),ARG1
|
||||||
|
mov ARG1,CELL_SIZE(ARG0)
|
||||||
|
|
||||||
|
/* Load ctx->datastack */
|
||||||
|
mov (CELL_SIZE * 2)(ARG0),DS_REG
|
||||||
|
|
||||||
|
/* Load ctx->retainstack */
|
||||||
|
mov (CELL_SIZE * 3)(ARG0),RS_REG
|
||||||
|
|
||||||
|
/* Call quot-xt */
|
||||||
|
mov NV0,ARG0
|
||||||
|
mov NV1,ARG1
|
||||||
|
call *QUOT_XT_OFFSET(ARG0)
|
||||||
|
|
||||||
|
/* Tear down register shadow area */
|
||||||
|
add $32,STACK_REG
|
||||||
|
|
||||||
|
/* Load context */
|
||||||
|
pop ARG1
|
||||||
|
pop ARG0
|
||||||
|
mov (ARG1),ARG0
|
||||||
|
|
||||||
|
/* Save ctx->datastack */
|
||||||
|
mov DS_REG,(CELL_SIZE * 2)(ARG0)
|
||||||
|
|
||||||
|
/* Save ctx->retainstack */
|
||||||
|
mov RS_REG,(CELL_SIZE * 3)(ARG0)
|
||||||
|
|
||||||
|
POP_NONVOLATILE
|
||||||
|
ret
|
||||||
|
|
||||||
/* We pass a function pointer to memcpy to work around a Mac OS X
|
/* We pass a function pointer to memcpy to work around a Mac OS X
|
||||||
ABI limitation which would otherwise require us to do a bizzaro PC-relative
|
ABI limitation which would otherwise require us to do a bizzaro PC-relative
|
||||||
trampoline to retrieve the function address */
|
trampoline to retrieve the function address */
|
||||||
|
@ -82,14 +128,14 @@ DEF(F_FASTCALL void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to, void *vm)):
|
||||||
fldcw (STACK_REG)
|
fldcw (STACK_REG)
|
||||||
/* rewind_to */
|
/* rewind_to */
|
||||||
mov ARG1,STACK_REG
|
mov ARG1,STACK_REG
|
||||||
mov ARG2,ARG1 /* make vm ptr 2nd arg in case quot_xt = lazy_jit_compile */
|
mov ARG2,ARG1 /* make vm ptr 2nd arg in case quot_xt = lazy_jit_compile_impl */
|
||||||
jmp *QUOT_XT_OFFSET(ARG0)
|
jmp *QUOT_XT_OFFSET(ARG0)
|
||||||
|
|
||||||
DEF(F_FASTCALL void,lazy_jit_compile,(CELL quot, void *vm)):
|
DEF(F_FASTCALL void,lazy_jit_compile_impl,(CELL quot, void *vm)):
|
||||||
mov ARG1,ARG2 /* vm is 3rd arg */
|
mov ARG1,ARG2 /* vm is 3rd arg */
|
||||||
mov STACK_REG,ARG1 /* Save stack pointer */
|
mov STACK_REG,ARG1 /* Save stack pointer */
|
||||||
sub $STACK_PADDING,STACK_REG
|
sub $STACK_PADDING,STACK_REG
|
||||||
call MANGLE(lazy_jit_compile_impl)
|
call MANGLE(lazy_jit_compile)
|
||||||
mov RETURN_REG,ARG0 /* No-op on 32-bit */
|
mov RETURN_REG,ARG0 /* No-op on 32-bit */
|
||||||
add $STACK_PADDING,STACK_REG
|
add $STACK_PADDING,STACK_REG
|
||||||
jmp *QUOT_XT_OFFSET(ARG0) /* Call the quotation */
|
jmp *QUOT_XT_OFFSET(ARG0) /* Call the quotation */
|
||||||
|
|
|
@ -2,6 +2,5 @@ namespace factor
|
||||||
{
|
{
|
||||||
|
|
||||||
#define FACTOR_CPU_STRING "x86.64"
|
#define FACTOR_CPU_STRING "x86.64"
|
||||||
#define VM_ASM_API VM_C_API
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
55
vm/cpu-x86.S
55
vm/cpu-x86.S
|
@ -1,58 +1,3 @@
|
||||||
DEF(F_FASTCALL void,c_to_factor,(CELL quot, void *vm)):
|
|
||||||
PUSH_NONVOLATILE
|
|
||||||
mov ARG0,NV0
|
|
||||||
mov ARG1,NV1
|
|
||||||
|
|
||||||
push ARG0
|
|
||||||
push ARG1
|
|
||||||
|
|
||||||
/* Save old stack pointer and align */
|
|
||||||
mov STACK_REG,ARG0
|
|
||||||
and $-16,STACK_REG
|
|
||||||
add $CELL_SIZE,STACK_REG
|
|
||||||
push ARG0
|
|
||||||
|
|
||||||
/* Create register shadow area (required for Win64 only) */
|
|
||||||
sub $32,STACK_REG
|
|
||||||
|
|
||||||
/* Load context */
|
|
||||||
mov (NV1),ARG0
|
|
||||||
|
|
||||||
/* Save ctx->callstack_bottom */
|
|
||||||
lea -CELL_SIZE(STACK_REG),ARG1
|
|
||||||
mov ARG1,CELL_SIZE(ARG0)
|
|
||||||
|
|
||||||
/* Load ctx->datastack */
|
|
||||||
mov (CELL_SIZE * 2)(ARG0),DS_REG
|
|
||||||
|
|
||||||
/* Load ctx->retainstack */
|
|
||||||
mov (CELL_SIZE * 3)(ARG0),RS_REG
|
|
||||||
|
|
||||||
/* Call quot-xt */
|
|
||||||
mov NV0,ARG0
|
|
||||||
mov NV1,ARG1
|
|
||||||
call *QUOT_XT_OFFSET(ARG0)
|
|
||||||
|
|
||||||
/* Tear down register shadow area */
|
|
||||||
add $32,STACK_REG
|
|
||||||
|
|
||||||
/* Undo stack alignment */
|
|
||||||
mov (STACK_REG),STACK_REG
|
|
||||||
|
|
||||||
/* Load context */
|
|
||||||
pop ARG1
|
|
||||||
pop ARG0
|
|
||||||
mov (ARG1),ARG0
|
|
||||||
|
|
||||||
/* Save ctx->datastack */
|
|
||||||
mov DS_REG,(CELL_SIZE * 2)(ARG0)
|
|
||||||
|
|
||||||
/* Save ctx->retainstack */
|
|
||||||
mov RS_REG,(CELL_SIZE * 3)(ARG0)
|
|
||||||
|
|
||||||
POP_NONVOLATILE
|
|
||||||
ret
|
|
||||||
|
|
||||||
/* cpu.x86.features calls this */
|
/* cpu.x86.features calls this */
|
||||||
DEF(bool,sse_version,(void)):
|
DEF(bool,sse_version,(void)):
|
||||||
mov $0x1,RETURN_REG
|
mov $0x1,RETURN_REG
|
||||||
|
|
|
@ -74,9 +74,9 @@ inline static unsigned int fpu_status(unsigned int status)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Defined in assembly */
|
/* Defined in assembly */
|
||||||
VM_ASM_API void c_to_factor(cell quot, void *vm);
|
VM_C_API void c_to_factor(cell quot, void *vm);
|
||||||
VM_C_API void throw_impl(cell quot, void *new_stack, void *vm);
|
VM_C_API void throw_impl(cell quot, void *new_stack, void *vm);
|
||||||
VM_ASM_API void lazy_jit_compile(cell quot, void *vm);
|
VM_C_API void lazy_jit_compile_impl(cell quot, void *vm);
|
||||||
|
|
||||||
VM_C_API void set_callstack(
|
VM_C_API void set_callstack(
|
||||||
void *vm,
|
void *vm,
|
||||||
|
|
|
@ -581,7 +581,7 @@ inline void factor_vm::overflow_fixnum_add(fixnum x, fixnum y)
|
||||||
untag_fixnum(x) + untag_fixnum(y))));
|
untag_fixnum(x) + untag_fixnum(y))));
|
||||||
}
|
}
|
||||||
|
|
||||||
VM_ASM_API void overflow_fixnum_add(fixnum x, fixnum y, factor_vm *parent)
|
VM_C_API void overflow_fixnum_add(fixnum x, fixnum y, factor_vm *parent)
|
||||||
{
|
{
|
||||||
parent->overflow_fixnum_add(x,y);
|
parent->overflow_fixnum_add(x,y);
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,7 @@ inline void factor_vm::overflow_fixnum_subtract(fixnum x, fixnum y)
|
||||||
untag_fixnum(x) - untag_fixnum(y))));
|
untag_fixnum(x) - untag_fixnum(y))));
|
||||||
}
|
}
|
||||||
|
|
||||||
VM_ASM_API void overflow_fixnum_subtract(fixnum x, fixnum y, factor_vm *parent)
|
VM_C_API void overflow_fixnum_subtract(fixnum x, fixnum y, factor_vm *parent)
|
||||||
{
|
{
|
||||||
parent->overflow_fixnum_subtract(x,y);
|
parent->overflow_fixnum_subtract(x,y);
|
||||||
}
|
}
|
||||||
|
@ -606,7 +606,7 @@ inline void factor_vm::overflow_fixnum_multiply(fixnum x, fixnum y)
|
||||||
ctx->replace(tag<bignum>(bignum_multiply(bx,by)));
|
ctx->replace(tag<bignum>(bignum_multiply(bx,by)));
|
||||||
}
|
}
|
||||||
|
|
||||||
VM_ASM_API void overflow_fixnum_multiply(fixnum x, fixnum y, factor_vm *parent)
|
VM_C_API void overflow_fixnum_multiply(fixnum x, fixnum y, factor_vm *parent)
|
||||||
{
|
{
|
||||||
parent->overflow_fixnum_multiply(x,y);
|
parent->overflow_fixnum_multiply(x,y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,8 +96,8 @@ VM_C_API u64 to_unsigned_8(cell obj, factor_vm *vm);
|
||||||
VM_C_API fixnum to_fixnum(cell tagged, factor_vm *vm);
|
VM_C_API fixnum to_fixnum(cell tagged, factor_vm *vm);
|
||||||
VM_C_API cell to_cell(cell tagged, factor_vm *vm);
|
VM_C_API cell to_cell(cell tagged, factor_vm *vm);
|
||||||
|
|
||||||
VM_ASM_API void overflow_fixnum_add(fixnum x, fixnum y, factor_vm *parent);
|
VM_C_API void overflow_fixnum_add(fixnum x, fixnum y, factor_vm *parent);
|
||||||
VM_ASM_API void overflow_fixnum_subtract(fixnum x, fixnum y, factor_vm *parent);
|
VM_C_API void overflow_fixnum_subtract(fixnum x, fixnum y, factor_vm *parent);
|
||||||
VM_ASM_API void overflow_fixnum_multiply(fixnum x, fixnum y, factor_vm *parent);
|
VM_C_API void overflow_fixnum_multiply(fixnum x, fixnum y, factor_vm *parent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,7 +307,7 @@ void factor_vm::primitive_array_to_quotation()
|
||||||
quot->array = ctx->peek();
|
quot->array = ctx->peek();
|
||||||
quot->cached_effect = false_object;
|
quot->cached_effect = false_object;
|
||||||
quot->cache_counter = false_object;
|
quot->cache_counter = false_object;
|
||||||
quot->xt = (void *)lazy_jit_compile;
|
quot->xt = (void *)lazy_jit_compile_impl;
|
||||||
quot->code = NULL;
|
quot->code = NULL;
|
||||||
ctx->replace(tag<quotation>(quot));
|
ctx->replace(tag<quotation>(quot));
|
||||||
}
|
}
|
||||||
|
@ -332,16 +332,16 @@ fixnum factor_vm::quot_code_offset_to_scan(cell quot_, cell offset)
|
||||||
return compiler.get_position();
|
return compiler.get_position();
|
||||||
}
|
}
|
||||||
|
|
||||||
cell factor_vm::lazy_jit_compile_impl(cell quot_)
|
cell factor_vm::lazy_jit_compile(cell quot_)
|
||||||
{
|
{
|
||||||
data_root<quotation> quot(quot_,this);
|
data_root<quotation> quot(quot_,this);
|
||||||
jit_compile_quot(quot.value(),true);
|
jit_compile_quot(quot.value(),true);
|
||||||
return quot.value();
|
return quot.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
VM_C_API cell lazy_jit_compile_impl(cell quot, factor_vm *parent)
|
VM_C_API cell lazy_jit_compile(cell quot, factor_vm *parent)
|
||||||
{
|
{
|
||||||
return parent->lazy_jit_compile_impl(quot);
|
return parent->lazy_jit_compile(quot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::primitive_quot_compiled_p()
|
void factor_vm::primitive_quot_compiled_p()
|
||||||
|
|
|
@ -27,6 +27,6 @@ struct quotation_jit : public jit {
|
||||||
void iterate_quotation();
|
void iterate_quotation();
|
||||||
};
|
};
|
||||||
|
|
||||||
VM_C_API cell lazy_jit_compile_impl(cell quot, factor_vm *parent);
|
VM_C_API cell lazy_jit_compile(cell quot, factor_vm *parent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -603,7 +603,7 @@ struct factor_vm
|
||||||
code_block *jit_compile_quot(cell owner_, cell quot_, bool relocating);
|
code_block *jit_compile_quot(cell owner_, cell quot_, bool relocating);
|
||||||
void jit_compile_quot(cell quot_, bool relocating);
|
void jit_compile_quot(cell quot_, bool relocating);
|
||||||
fixnum quot_code_offset_to_scan(cell quot_, cell offset);
|
fixnum quot_code_offset_to_scan(cell quot_, cell offset);
|
||||||
cell lazy_jit_compile_impl(cell quot);
|
cell lazy_jit_compile(cell quot);
|
||||||
void primitive_quot_compiled_p();
|
void primitive_quot_compiled_p();
|
||||||
|
|
||||||
//dispatch
|
//dispatch
|
||||||
|
|
Loading…
Reference in New Issue