parent
07ba1de580
commit
9a0ac0e975
|
@ -361,19 +361,23 @@ cell 8 = [
|
|||
|
||||
[ ] [ B{ 1 2 3 4 5 } malloc-byte-array "b" set ] unit-test
|
||||
|
||||
[ 3 ] [ "b" get 2 [ alien-unsigned-1 ] compile-1 ] unit-test
|
||||
[ 3 ] [ "b" get [ { simple-alien } declare 2 alien-unsigned-1 ] compile-1 ] unit-test
|
||||
[ 3 ] [ "b" get 2 [ { simple-alien fixnum } declare alien-unsigned-1 ] compile-1 ] unit-test
|
||||
[ 3 ] [ "b" get 2 [ { simple-c-ptr fixnum } declare alien-unsigned-1 ] compile-1 ] unit-test
|
||||
"b" get [
|
||||
[ 3 ] [ "b" get 2 [ alien-unsigned-1 ] compile-1 ] unit-test
|
||||
[ 3 ] [ "b" get [ { simple-alien } declare 2 alien-unsigned-1 ] compile-1 ] unit-test
|
||||
[ 3 ] [ "b" get 2 [ { simple-alien fixnum } declare alien-unsigned-1 ] compile-1 ] unit-test
|
||||
[ 3 ] [ "b" get 2 [ { simple-c-ptr fixnum } declare alien-unsigned-1 ] compile-1 ] unit-test
|
||||
|
||||
[ ] [ "b" get free ] unit-test
|
||||
[ ] [ "b" get free ] unit-test
|
||||
] when
|
||||
|
||||
[ ] [ "hello world" malloc-char-string "s" set ] unit-test
|
||||
[ t ] [ "hello world" malloc-char-string "s" set ] unit-test
|
||||
|
||||
[ "hello world" ] [ "s" get <void*> [ { byte-array } declare *void* ] compile-1 alien>char-string ] unit-test
|
||||
[ "hello world" ] [ "s" get <void*> [ { simple-c-ptr } declare *void* ] compile-1 alien>char-string ] unit-test
|
||||
"s" get [
|
||||
[ "hello world" ] [ "s" get <void*> [ { byte-array } declare *void* ] compile-1 alien>char-string ] unit-test
|
||||
[ "hello world" ] [ "s" get <void*> [ { simple-c-ptr } declare *void* ] compile-1 alien>char-string ] unit-test
|
||||
|
||||
[ ] [ "s" get free ] unit-test
|
||||
[ ] [ "s" get free ] unit-test
|
||||
] when
|
||||
|
||||
[ ALIEN: 1234 ] [ ALIEN: 1234 [ { simple-alien } declare <void*> ] compile-1 *void* ] unit-test
|
||||
[ ALIEN: 1234 ] [ ALIEN: 1234 [ { simple-c-ptr } declare <void*> ] compile-1 *void* ] unit-test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#define FACTOR_CPU_STRING "ppc"
|
||||
#define FASTCALL
|
||||
#define F_FASTCALL
|
||||
|
||||
register CELL ds asm("r14");
|
||||
register CELL rs asm("r15");
|
||||
|
|
|
@ -3,4 +3,5 @@
|
|||
register CELL ds asm("esi");
|
||||
register CELL rs asm("edi");
|
||||
|
||||
#define FASTCALL __attribute__ ((regparm (2)))
|
||||
#define F_FASTCALL __attribute__ ((regparm (2)))
|
||||
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
register CELL ds asm("r14");
|
||||
register CELL rs asm("r15");
|
||||
|
||||
#define FASTCALL
|
||||
#define F_FASTCALL
|
||||
|
|
16
vm/cpu-x86.S
16
vm/cpu-x86.S
|
@ -2,7 +2,7 @@
|
|||
mov QUOT_XT_OFFSET(ARG0),XT_REG ; /* Load quot-xt */ \
|
||||
jmp *XT_REG /* Jump to quot-xt */
|
||||
|
||||
DEF(FASTCALL void,c_to_factor,(CELL quot)):
|
||||
DEF(F_FASTCALL void,c_to_factor,(CELL quot)):
|
||||
PUSH_NONVOLATILE
|
||||
push ARG0 /* Save quot */
|
||||
|
||||
|
@ -17,38 +17,38 @@ DEF(FASTCALL void,c_to_factor,(CELL quot)):
|
|||
POP_NONVOLATILE
|
||||
ret
|
||||
|
||||
DEF(FASTCALL void,undefined,(CELL word)):
|
||||
DEF(F_FASTCALL void,undefined,(CELL word)):
|
||||
mov STACK_REG,ARG1 /* Pass callstack pointer */
|
||||
jmp MANGLE(undefined_error) /* This throws an error */
|
||||
|
||||
DEF(FASTCALL void,dosym,(CELL word)):
|
||||
DEF(F_FASTCALL void,dosym,(CELL word)):
|
||||
add $CELL_SIZE,DS_REG /* Increment stack pointer */
|
||||
mov ARG0,(DS_REG) /* Store word on stack */
|
||||
ret
|
||||
|
||||
/* Here we have two entry points. The first one is taken when profiling is
|
||||
enabled */
|
||||
DEF(FASTCALL void,docol_profiling,(CELL word)):
|
||||
DEF(F_FASTCALL void,docol_profiling,(CELL word)):
|
||||
add $CELL_SIZE,PROFILING_OFFSET(ARG0) /* Increment profile-count slot */
|
||||
DEF(FASTCALL void,docol,(CELL word)):
|
||||
DEF(F_FASTCALL void,docol,(CELL word)):
|
||||
mov WORD_DEF_OFFSET(ARG0),ARG0 /* Load word-def slot */
|
||||
JUMP_QUOT
|
||||
|
||||
/* We must pass the XT to the quotation in ECX. */
|
||||
DEF(FASTCALL void,primitive_call,(void)):
|
||||
DEF(F_FASTCALL void,primitive_call,(void)):
|
||||
mov (DS_REG),ARG0 /* Load quotation from data stack */
|
||||
sub $CELL_SIZE,DS_REG /* Pop data stack */
|
||||
JUMP_QUOT
|
||||
|
||||
/* We pass the word in EAX and the XT in ECX. Don't mess up EDX, it's the
|
||||
callstack top parameter to primitives. */
|
||||
DEF(FASTCALL void,primitive_execute,(void)):
|
||||
DEF(F_FASTCALL void,primitive_execute,(void)):
|
||||
mov (DS_REG),ARG0 /* Load word from data stack */
|
||||
sub $CELL_SIZE,DS_REG /* Pop data stack */
|
||||
mov WORD_XT_OFFSET(ARG0),XT_REG /* Load word-xt slot */
|
||||
jmp *XT_REG /* Go */
|
||||
|
||||
DEF(FASTCALL void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to)):
|
||||
DEF(F_FASTCALL void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to)):
|
||||
mov ARG1,STACK_REG /* rewind_to */
|
||||
JUMP_QUOT
|
||||
|
||||
|
|
14
vm/cpu-x86.h
14
vm/cpu-x86.h
|
@ -22,12 +22,12 @@ typedef struct _F_STACK_FRAME
|
|||
|
||||
INLINE void flush_icache(CELL start, CELL len) {}
|
||||
|
||||
FASTCALL void c_to_factor(CELL quot);
|
||||
FASTCALL void throw_impl(CELL quot, F_STACK_FRAME *rewind_to);
|
||||
FASTCALL void undefined(CELL word);
|
||||
FASTCALL void dosym(CELL word);
|
||||
FASTCALL void docol_profiling(CELL word);
|
||||
FASTCALL void docol(CELL word);
|
||||
FASTCALL void lazy_jit_compile(CELL quot);
|
||||
F_FASTCALL void c_to_factor(CELL quot);
|
||||
F_FASTCALL void throw_impl(CELL quot, F_STACK_FRAME *rewind_to);
|
||||
F_FASTCALL void undefined(CELL word);
|
||||
F_FASTCALL void dosym(CELL word);
|
||||
F_FASTCALL void docol_profiling(CELL word);
|
||||
F_FASTCALL void docol(CELL word);
|
||||
F_FASTCALL void lazy_jit_compile(CELL quot);
|
||||
|
||||
void set_callstack(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy);
|
||||
|
|
2
vm/jit.c
2
vm/jit.c
|
@ -34,7 +34,7 @@ bool jit_stack_frame_p(F_ARRAY *array)
|
|||
return false;
|
||||
}
|
||||
|
||||
FASTCALL CELL jit_compile(CELL tagged, F_STACK_FRAME *stack)
|
||||
F_FASTCALL CELL jit_compile(CELL tagged, F_STACK_FRAME *stack)
|
||||
{
|
||||
stack_chain->callstack_top = stack;
|
||||
|
||||
|
|
2
vm/jit.h
2
vm/jit.h
|
@ -1,2 +1,2 @@
|
|||
DLLEXPORT FASTCALL CELL jit_compile(CELL tagged, F_STACK_FRAME *stack);
|
||||
DLLEXPORT F_FASTCALL CELL jit_compile(CELL tagged, F_STACK_FRAME *stack);
|
||||
XT quot_offset_to_pc(F_QUOTATION *quot, F_FIXNUM offset);
|
||||
|
|
10
vm/os-unix.c
10
vm/os-unix.c
|
@ -179,11 +179,6 @@ INLINE F_STACK_FRAME *uap_stack_pointer(void *uap)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void memory_signal_handler_impl(void)
|
||||
{
|
||||
memory_protection_error(signal_fault_addr,signal_callstack_top);
|
||||
}
|
||||
|
||||
void memory_signal_handler(int signal, siginfo_t *siginfo, void *uap)
|
||||
{
|
||||
signal_fault_addr = (CELL)siginfo->si_addr;
|
||||
|
@ -191,11 +186,6 @@ void memory_signal_handler(int signal, siginfo_t *siginfo, void *uap)
|
|||
UAP_PROGRAM_COUNTER(uap) = (CELL)memory_signal_handler_impl;
|
||||
}
|
||||
|
||||
void misc_signal_handler_impl(void)
|
||||
{
|
||||
signal_error(signal_number,signal_callstack_top);
|
||||
}
|
||||
|
||||
void misc_signal_handler(int signal, siginfo_t *siginfo, void *uap)
|
||||
{
|
||||
signal_number = signal;
|
||||
|
|
|
@ -27,10 +27,11 @@ long exception_handler(PEXCEPTION_POINTERS pe)
|
|||
{
|
||||
PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)pe->ExceptionRecord;
|
||||
CONTEXT *c = (CONTEXT*)pe->ContextRecord;
|
||||
void *signal_callstack_top = NULL;
|
||||
|
||||
if(in_code_heap_p(c->Eip))
|
||||
signal_callstack_top = (void*)c->Esp;
|
||||
else
|
||||
signal_callstack_top = NULL;
|
||||
|
||||
if(e->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
|
||||
{
|
||||
|
@ -58,18 +59,3 @@ void c_to_factor_toplevel(CELL quot)
|
|||
c_to_factor(quot);
|
||||
RemoveVectoredExceptionHandler((void*)exception_handler);
|
||||
}
|
||||
|
||||
void memory_signal_handler_impl(void)
|
||||
{
|
||||
memory_protection_error(signal_fault_addr,signal_callstack_top);
|
||||
}
|
||||
|
||||
void divide_by_zero_signal_handler_impl(void)
|
||||
{
|
||||
general_error(ERROR_DIVIDE_BY_ZERO,F,F,signal_callstack_top);
|
||||
}
|
||||
|
||||
void misc_signal_handler_impl(void)
|
||||
{
|
||||
signal_error(signal_number,signal_callstack_top);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ typedef char F_SYMBOL;
|
|||
#define FACTOR_DLL L"factor-nt.dll"
|
||||
#define FACTOR_DLL_NAME "factor-nt.dll"
|
||||
|
||||
void c_to_factor_toplevel(CELL quot);
|
||||
|
||||
CELL signal_number;
|
||||
CELL signal_fault_addr;
|
||||
void *signal_callstack_top;
|
||||
|
|
|
@ -14,19 +14,19 @@ DEFINE_PRIMITIVE(name)
|
|||
|
||||
Becomes
|
||||
|
||||
FASTCALL void primitive_name(CELL word, F_STACK_FRAME *callstack_top)
|
||||
F_FASTCALL void primitive_name(CELL word, F_STACK_FRAME *callstack_top)
|
||||
{
|
||||
stack_chain->callstack_top = callstack_top;
|
||||
... CODE ...
|
||||
}
|
||||
|
||||
On x86, FASTCALL expands into a GCC declaration which forces the two parameters
|
||||
to be passed in registers. This simplifies the quotation compiler and support
|
||||
code in cpu-x86.S. */
|
||||
On x86, F_FASTCALL expands into a GCC declaration which forces the two
|
||||
parameters to be passed in registers. This simplifies the quotation compiler
|
||||
and support code in cpu-x86.S. */
|
||||
#define DEFINE_PRIMITIVE(name) \
|
||||
INLINE void primitive_##name##_impl(void); \
|
||||
\
|
||||
FASTCALL void primitive_##name(CELL word, F_STACK_FRAME *callstack_top) \
|
||||
F_FASTCALL void primitive_##name(CELL word, F_STACK_FRAME *callstack_top) \
|
||||
{ \
|
||||
stack_chain->callstack_top = callstack_top; \
|
||||
primitive_##name##_impl(); \
|
||||
|
@ -36,4 +36,4 @@ code in cpu-x86.S. */
|
|||
|
||||
/* Prototype for header files */
|
||||
#define DECLARE_PRIMITIVE(name) \
|
||||
FASTCALL void primitive_##name(CELL word, F_STACK_FRAME *callstack_top)
|
||||
F_FASTCALL void primitive_##name(CELL word, F_STACK_FRAME *callstack_top)
|
||||
|
|
17
vm/run.c
17
vm/run.c
|
@ -197,7 +197,7 @@ void not_implemented_error(void)
|
|||
}
|
||||
|
||||
/* This function is called from the undefined function in cpu_*.S */
|
||||
FASTCALL void undefined_error(CELL word, F_STACK_FRAME *callstack_top)
|
||||
F_FASTCALL void undefined_error(CELL word, F_STACK_FRAME *callstack_top)
|
||||
{
|
||||
stack_chain->callstack_top = callstack_top;
|
||||
general_error(ERROR_UNDEFINED_WORD,word,F,NULL);
|
||||
|
@ -244,6 +244,21 @@ void divide_by_zero_error(F_STACK_FRAME *native_stack)
|
|||
general_error(ERROR_DIVIDE_BY_ZERO,F,F,native_stack);
|
||||
}
|
||||
|
||||
void memory_signal_handler_impl(void)
|
||||
{
|
||||
memory_protection_error(signal_fault_addr,signal_callstack_top);
|
||||
}
|
||||
|
||||
void divide_by_zero_signal_handler_impl(void)
|
||||
{
|
||||
divide_by_zero_error(signal_callstack_top);
|
||||
}
|
||||
|
||||
void misc_signal_handler_impl(void)
|
||||
{
|
||||
signal_error(signal_number,signal_callstack_top);
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(throw)
|
||||
{
|
||||
uncurry(dpop());
|
||||
|
|
2
vm/run.h
2
vm/run.h
|
@ -197,7 +197,7 @@ void signal_error(int signal, F_STACK_FRAME *native_stack);
|
|||
void type_error(CELL type, CELL tagged);
|
||||
void not_implemented_error(void);
|
||||
|
||||
FASTCALL void undefined_error(CELL word, F_STACK_FRAME *callstack_top);
|
||||
F_FASTCALL void undefined_error(CELL word, F_STACK_FRAME *callstack_top);
|
||||
|
||||
DECLARE_PRIMITIVE(throw);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ void fix_stacks(void)
|
|||
}
|
||||
|
||||
/* called before entry into Factor code. */
|
||||
FASTCALL void save_callstack_bottom(F_STACK_FRAME *callstack_bottom)
|
||||
F_FASTCALL void save_callstack_bottom(F_STACK_FRAME *callstack_bottom)
|
||||
{
|
||||
stack_chain->callstack_bottom = callstack_bottom;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ CELL ds_size, rs_size;
|
|||
void reset_datastack(void);
|
||||
void reset_retainstack(void);
|
||||
void fix_stacks(void);
|
||||
FASTCALL void save_callstack_bottom(F_STACK_FRAME *callstack_bottom);
|
||||
F_FASTCALL void save_callstack_bottom(F_STACK_FRAME *callstack_bottom);
|
||||
DLLEXPORT void save_stacks(void);
|
||||
DLLEXPORT void nest_stacks(void);
|
||||
DLLEXPORT void unnest_stacks(void);
|
||||
|
|
Loading…
Reference in New Issue