Trying to get stack traces going on OS X, but won't compile without -fomit-frame-pointer
parent
a706915b1e
commit
de1ebb9f1a
|
|
@ -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.
|
! 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 -- )
|
: %prologue ( n -- )
|
||||||
|
EBP PUSH
|
||||||
|
EBP ESP MOV
|
||||||
\ stack-reserve set stack-reg stack-increment SUB ;
|
\ stack-reserve set stack-reg stack-increment SUB ;
|
||||||
|
|
||||||
: %epilogue ( -- )
|
|
||||||
stack-reg stack-increment ADD ;
|
|
||||||
|
|
||||||
: align-sub ( n -- )
|
: align-sub ( n -- )
|
||||||
dup 16 align swap - ESP swap SUB ;
|
dup 16 align swap - ESP swap SUB ;
|
||||||
|
|
||||||
|
|
@ -55,7 +54,7 @@ USING: assembler errors kernel kernel-internals math namespaces ;
|
||||||
|
|
||||||
: %box-struct ( n size -- )
|
: %box-struct ( n size -- )
|
||||||
over [
|
over [
|
||||||
>r stack-increment + cell + r>
|
>r stack-increment + 2 cells + r>
|
||||||
"box_value_struct" struct-ptr/size
|
"box_value_struct" struct-ptr/size
|
||||||
] [
|
] [
|
||||||
nip 8 = [
|
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
|
#! frame, since %box sets one up to call the one-arg boxer
|
||||||
#! function. The size of this stack frame so far depends on
|
#! function. The size of this stack frame so far depends on
|
||||||
#! the reg-class of the boxer's arg.
|
#! 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 -- )
|
: (%box) ( n reg-class -- )
|
||||||
#! If n is f, push the return register onto the stack; we
|
#! If n is f, push the return register onto the stack; we
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
include vm/Config.macosx
|
include vm/Config.macosx
|
||||||
include vm/Config.x86
|
include vm/Config.x86
|
||||||
|
CFLAGS += -fomit-frame-pointer
|
||||||
|
|
|
||||||
13
vm/cpu-x86.S
13
vm/cpu-x86.S
|
|
@ -1,6 +1,13 @@
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#define MANGLE(sym) _##sym
|
||||||
|
#else
|
||||||
|
#define MANGLE(sym) sym
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Callable from C as
|
/* Callable from C as
|
||||||
void *native_stack_pointer(void) */
|
void *native_stack_pointer(void) */
|
||||||
.globl native_stack_pointer
|
.globl MANGLE(native_stack_pointer)
|
||||||
native_stack_pointer:
|
MANGLE(native_stack_pointer):
|
||||||
mov %ebp,%eax
|
mov %esp,%eax
|
||||||
|
add $4,%ebp
|
||||||
ret
|
ret
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue