Inhibit assignment re-ordering

release
Slava Pestov 2007-10-06 22:52:55 -04:00
parent b07986d0d0
commit 038cbed6e6
3 changed files with 13 additions and 3 deletions

View File

@ -6,6 +6,11 @@ F_FASTCALL void save_callstack_bottom(F_STACK_FRAME *callstack_bottom)
stack_chain->callstack_bottom = callstack_bottom; stack_chain->callstack_bottom = callstack_bottom;
} }
__attribute__((noinline)) void save_callstack_top(F_STACK_FRAME *callstack_top)
{
stack_chain->callstack_top = callstack_top;
}
void iterate_callstack(CELL top, CELL bottom, CALLSTACK_ITER iterator) void iterate_callstack(CELL top, CELL bottom, CALLSTACK_ITER iterator)
{ {
F_STACK_FRAME *frame = (F_STACK_FRAME *)bottom - 1; F_STACK_FRAME *frame = (F_STACK_FRAME *)bottom - 1;

View File

@ -1,4 +1,5 @@
F_FASTCALL void save_callstack_bottom(F_STACK_FRAME *callstack_bottom); F_FASTCALL void save_callstack_bottom(F_STACK_FRAME *callstack_bottom);
__attribute__((noinline)) void save_callstack_top(F_STACK_FRAME *callstack_top);
#define FIRST_STACK_FRAME(stack) (F_STACK_FRAME *)((stack) + 1) #define FIRST_STACK_FRAME(stack) (F_STACK_FRAME *)((stack) + 1)
@ -8,6 +9,7 @@ void iterate_callstack(CELL top, CELL bottom, CALLSTACK_ITER iterator);
void iterate_callstack_object(F_CALLSTACK *stack, CALLSTACK_ITER iterator); void iterate_callstack_object(F_CALLSTACK *stack, CALLSTACK_ITER iterator);
F_STACK_FRAME *frame_successor(F_STACK_FRAME *frame); F_STACK_FRAME *frame_successor(F_STACK_FRAME *frame);
CELL frame_executing(F_STACK_FRAME *frame); CELL frame_executing(F_STACK_FRAME *frame);
CELL frame_scan(F_STACK_FRAME *frame);
CELL frame_type(F_STACK_FRAME *frame); CELL frame_type(F_STACK_FRAME *frame);
DECLARE_PRIMITIVE(callstack); DECLARE_PRIMITIVE(callstack);

View File

@ -16,19 +16,22 @@ Becomes
F_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; save_callstack_top(callstack_top);
... CODE ... ... CODE ...
} }
On x86, F_FASTCALL expands into a GCC declaration which forces the two On x86, F_FASTCALL expands into a GCC declaration which forces the two
parameters to be passed in registers. This simplifies the quotation compiler parameters to be passed in registers. This simplifies the quotation compiler
and support code in cpu-x86.S. */ and support code in cpu-x86.S.
We do the assignment of stack_chain->callstack_top in a ``noinline'' function
to inhibit assignment re-ordering. */
#define DEFINE_PRIMITIVE(name) \ #define DEFINE_PRIMITIVE(name) \
INLINE void primitive_##name##_impl(void); \ INLINE void primitive_##name##_impl(void); \
\ \
F_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; \ save_callstack_top(callstack_top); \
primitive_##name##_impl(); \ primitive_##name##_impl(); \
} \ } \
\ \