Trying to get stack traces going on OS X, but won't compile without -fomit-frame-pointer

darcs
slava 2006-11-16 06:31:49 +00:00
parent a706915b1e
commit de1ebb9f1a
3 changed files with 16 additions and 9 deletions

View File

@ -5,14 +5,13 @@ USING: assembler errors kernel kernel-internals math namespaces ;
! OS X uses a different ABI. The stack must be 16-byte aligned.
: stack-increment \ stack-reserve get 16 align 16 + cell - ;
: stack-increment \ stack-reserve get 16 align 16 + 2 cells - ;
: %prologue ( n -- )
EBP PUSH
EBP ESP MOV
\ stack-reserve set stack-reg stack-increment SUB ;
: %epilogue ( -- )
stack-reg stack-increment ADD ;
: align-sub ( n -- )
dup 16 align swap - ESP swap SUB ;
@ -55,7 +54,7 @@ USING: assembler errors kernel kernel-internals math namespaces ;
: %box-struct ( n size -- )
over [
>r stack-increment + cell + r>
>r stack-increment + 2 cells + r>
"box_value_struct" struct-ptr/size
] [
nip 8 = [
@ -71,7 +70,7 @@ USING: assembler errors kernel kernel-internals math namespaces ;
#! frame, since %box sets one up to call the one-arg boxer
#! function. The size of this stack frame so far depends on
#! the reg-class of the boxer's arg.
16 swap reg-size - + stack-increment + cell + ;
16 swap reg-size - + stack-increment + 2 cells + ;
: (%box) ( n reg-class -- )
#! If n is f, push the return register onto the stack; we

View File

@ -1,2 +1,3 @@
include vm/Config.macosx
include vm/Config.x86
CFLAGS += -fomit-frame-pointer

View File

@ -1,6 +1,13 @@
#ifdef __APPLE__
#define MANGLE(sym) _##sym
#else
#define MANGLE(sym) sym
#endif
/* Callable from C as
void *native_stack_pointer(void) */
.globl native_stack_pointer
native_stack_pointer:
mov %ebp,%eax
.globl MANGLE(native_stack_pointer)
MANGLE(native_stack_pointer):
mov %esp,%eax
add $4,%ebp
ret