x86 compiled stack traces working
parent
5293a6c637
commit
c4ddcf54df
8
Makefile
8
Makefile
|
@ -12,7 +12,7 @@ ifdef DEBUG
|
||||||
CFLAGS = -g
|
CFLAGS = -g
|
||||||
STRIP = touch
|
STRIP = touch
|
||||||
else
|
else
|
||||||
CFLAGS = -Wall -O3 -ffast-math -fomit-frame-pointer $(SITE_CFLAGS)
|
CFLAGS = -Wall -O3 -ffast-math $(SITE_CFLAGS)
|
||||||
STRIP = strip
|
STRIP = strip
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -73,11 +73,11 @@ macosx-ppc: macosx-freetype
|
||||||
$(MAKE) $(BINARY) CONFIG=vm/Config.macosx.ppc
|
$(MAKE) $(BINARY) CONFIG=vm/Config.macosx.ppc
|
||||||
|
|
||||||
macosx-x86: macosx-freetype
|
macosx-x86: macosx-freetype
|
||||||
$(MAKE) $(BINARY) CONFIG=vm/Config.macosx
|
$(MAKE) $(BINARY) CONFIG=vm/Config.macosx.x86
|
||||||
|
|
||||||
linux-x86:
|
linux-x86:
|
||||||
$(MAKE) $(BINARY) CONFIG=vm/Config.linux
|
$(MAKE) $(BINARY) CONFIG=vm/Config.linux.x86
|
||||||
$(STRIP) $(BINARY)
|
# $(STRIP) $(BINARY)
|
||||||
|
|
||||||
linux-amd64:
|
linux-amd64:
|
||||||
$(MAKE) $(BINARY) CONFIG=vm/Config.linux.amd64
|
$(MAKE) $(BINARY) CONFIG=vm/Config.linux.amd64
|
||||||
|
|
|
@ -36,11 +36,11 @@ DEFER: literal-template ( literals -- template )
|
||||||
! Load a literal (immediate or indirect)
|
! Load a literal (immediate or indirect)
|
||||||
G: load-literal ( obj vreg -- ) 1 standard-combination ;
|
G: load-literal ( obj vreg -- ) 1 standard-combination ;
|
||||||
|
|
||||||
! Set up caller stack frame (PowerPC and AMD64)
|
! Set up caller stack frame
|
||||||
: %prologue ( n -- ) drop ; inline
|
DEFER: %prologue ( n -- )
|
||||||
|
|
||||||
! Tear down stack frame (PowerPC and AMD64)
|
! Tear down stack frame
|
||||||
: %epilogue ( -- ) ; inline
|
DEFER: %epilogue ( -- )
|
||||||
|
|
||||||
! Tail call another word
|
! Tail call another word
|
||||||
DEFER: %jump ( label -- )
|
DEFER: %jump ( label -- )
|
||||||
|
|
|
@ -96,6 +96,14 @@ M: immediate load-literal
|
||||||
M: object load-literal
|
M: object load-literal
|
||||||
v>operand load-indirect ;
|
v>operand load-indirect ;
|
||||||
|
|
||||||
|
: %prologue ( n -- )
|
||||||
|
drop
|
||||||
|
EBP PUSH
|
||||||
|
EBP ESP MOV ;
|
||||||
|
|
||||||
|
: %epilogue ( -- )
|
||||||
|
LEAVE ;
|
||||||
|
|
||||||
: (%call) ( label -- label )
|
: (%call) ( label -- label )
|
||||||
dup (compile) dup primitive? [ address-operand ] when ;
|
dup (compile) dup primitive? [ address-operand ] when ;
|
||||||
|
|
||||||
|
|
|
@ -323,6 +323,7 @@ M: label JUMPcc (JUMPcc) rel-label ;
|
||||||
: JLE HEX: 8e JUMPcc ;
|
: JLE HEX: 8e JUMPcc ;
|
||||||
: JG HEX: 8f JUMPcc ;
|
: JG HEX: 8f JUMPcc ;
|
||||||
|
|
||||||
|
: LEAVE ( -- ) HEX: c9 , ;
|
||||||
: RET ( -- ) HEX: c3 , ;
|
: RET ( -- ) HEX: c3 , ;
|
||||||
|
|
||||||
! Arithmetic
|
! Arithmetic
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
include vm/Config.linux
|
||||||
|
include vm/Config.x86
|
|
@ -0,0 +1,2 @@
|
||||||
|
include vm/Config.macosx
|
||||||
|
include vm/Config.x86
|
|
@ -2,3 +2,4 @@ CFLAGS += -DWINDOWS
|
||||||
LIBS = -lm
|
LIBS = -lm
|
||||||
PLAF_SUFFIX = .exe
|
PLAF_SUFFIX = .exe
|
||||||
PLAF_OBJS = vm/os-windows.o
|
PLAF_OBJS = vm/os-windows.o
|
||||||
|
include wm/Config.x86
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
PLAF_OBJS += vm/cpu-x86.o
|
|
@ -0,0 +1,6 @@
|
||||||
|
/* Callable from C as
|
||||||
|
void *native_stack_pointer(void) */
|
||||||
|
.globl native_stack_pointer
|
||||||
|
native_stack_pointer:
|
||||||
|
mov %ebp,%eax
|
||||||
|
ret
|
|
@ -6,12 +6,7 @@ CELL cards_offset;
|
||||||
|
|
||||||
INLINE void flush_icache(CELL start, CELL len) {}
|
INLINE void flush_icache(CELL start, CELL len) {}
|
||||||
|
|
||||||
INLINE void *native_stack_pointer(void)
|
void *native_stack_pointer(void);
|
||||||
{
|
|
||||||
void *ptr;
|
|
||||||
asm("mov %%ebp, %0" : "=r" (ptr));
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct _F_STACK_FRAME {
|
typedef struct _F_STACK_FRAME {
|
||||||
struct _F_STACK_FRAME *previous;
|
struct _F_STACK_FRAME *previous;
|
||||||
|
|
7
vm/run.c
7
vm/run.c
|
@ -263,13 +263,16 @@ CELL native_stack_trace(void)
|
||||||
|
|
||||||
while((CELL)frame < (CELL)stack_chain->native_stack_pointer)
|
while((CELL)frame < (CELL)stack_chain->native_stack_pointer)
|
||||||
{
|
{
|
||||||
fflush(stdout);
|
|
||||||
REGISTER_ARRAY(array);
|
REGISTER_ARRAY(array);
|
||||||
CELL cell = allot_cell((CELL)frame->return_address);
|
CELL cell = allot_cell((CELL)frame->return_address);
|
||||||
UNREGISTER_ARRAY(array);
|
UNREGISTER_ARRAY(array);
|
||||||
GROWABLE_ADD(array,cell);
|
GROWABLE_ADD(array,cell);
|
||||||
if((CELL)frame->previous <= (CELL)frame)
|
if((CELL)frame->previous <= (CELL)frame)
|
||||||
critical_error("C stack is busted",(CELL)frame);
|
{
|
||||||
|
fprintf(stderr,"Factor warning: unusual C stack layout\n");
|
||||||
|
fflush(stderr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
frame = frame->previous;
|
frame = frame->previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue