Change FASTCALL to F_FASTCALL

Move impl functions to run.c
Fix win32 SEH
release
U-3ADF\Administrator 2007-09-26 19:39:20 +02:00
parent 26c9fbd509
commit d6d7f6771a
13 changed files with 47 additions and 53 deletions

View File

@ -1,5 +1,5 @@
#define FACTOR_CPU_STRING "ppc"
#define FASTCALL
#define F_FASTCALL
register CELL ds asm("r14");
register CELL rs asm("r15");

View File

@ -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)))

View File

@ -3,4 +3,4 @@
register CELL ds asm("r14");
register CELL rs asm("r15");
#define FASTCALL
#define F_FASTCALL

View File

@ -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,37 +17,37 @@ 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

View File

@ -22,11 +22,11 @@ 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);
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);
void set_callstack(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy);

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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)

View File

@ -199,7 +199,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);
@ -246,6 +246,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());

View File

@ -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);

View File

@ -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;
}

View File

@ -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);