From b07986d0d09fa125c7984f15134dac0c88392af2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 6 Oct 2007 20:49:48 -0400 Subject: [PATCH 1/2] Once again, -fomit-frame-pointer on Windows is causing problems --- Makefile | 2 +- vm/Config.unix | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 11563a0698..378f96deae 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ CFLAGS = -Wall ifdef DEBUG CFLAGS += -g else - CFLAGS += -O3 -fomit-frame-pointer $(SITE_CFLAGS) + CFLAGS += -O3 $(SITE_CFLAGS) endif ifdef CONFIG diff --git a/vm/Config.unix b/vm/Config.unix index 831b3378d8..6400f4782d 100644 --- a/vm/Config.unix +++ b/vm/Config.unix @@ -1,3 +1,7 @@ +#ifndef DEBUG + C_FLAGS += -fomit-frame-pointer +#endif + EXE_SUFFIX = DLL_PREFIX = lib DLL_EXTENSION = .a From 038cbed6e6ed890573347bdc46a507762afef00a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 6 Oct 2007 22:52:55 -0400 Subject: [PATCH 2/2] Inhibit assignment re-ordering --- vm/callstack.c | 5 +++++ vm/callstack.h | 2 ++ vm/primitives.h | 9 ++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/vm/callstack.c b/vm/callstack.c index 901b1bbb0b..271c7d9aa1 100644 --- a/vm/callstack.c +++ b/vm/callstack.c @@ -6,6 +6,11 @@ F_FASTCALL void save_callstack_bottom(F_STACK_FRAME *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) { F_STACK_FRAME *frame = (F_STACK_FRAME *)bottom - 1; diff --git a/vm/callstack.h b/vm/callstack.h index 4d1dac9ffd..ff68a8ba26 100644 --- a/vm/callstack.h +++ b/vm/callstack.h @@ -1,4 +1,5 @@ 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) @@ -8,6 +9,7 @@ void iterate_callstack(CELL top, CELL bottom, CALLSTACK_ITER iterator); void iterate_callstack_object(F_CALLSTACK *stack, CALLSTACK_ITER iterator); F_STACK_FRAME *frame_successor(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); DECLARE_PRIMITIVE(callstack); diff --git a/vm/primitives.h b/vm/primitives.h index 2c0040f13f..811b473acd 100644 --- a/vm/primitives.h +++ b/vm/primitives.h @@ -16,19 +16,22 @@ Becomes F_FASTCALL void primitive_name(CELL word, F_STACK_FRAME *callstack_top) { - stack_chain->callstack_top = callstack_top; + save_callstack_top(callstack_top); ... CODE ... } 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. */ +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) \ INLINE void primitive_##name##_impl(void); \ \ 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(); \ } \ \