AMD64 fixes

darcs
slava 2006-12-18 02:25:43 +00:00
parent fdbcf006d3
commit 423a2f10fc
7 changed files with 36 additions and 18 deletions

View File

@ -9,7 +9,7 @@ DISK_IMAGE = Factor-$(VERSION).dmg
LIBPATH = -L/usr/X11R6/lib LIBPATH = -L/usr/X11R6/lib
ifdef DEBUG ifdef DEBUG
CFLAGS = -g CFLAGS = -g -std=gnu99
STRIP = touch STRIP = touch
else else
CFLAGS = -Wall -O3 -ffast-math -std=gnu99 $(SITE_CFLAGS) CFLAGS = -Wall -O3 -ffast-math -std=gnu99 $(SITE_CFLAGS)

View File

@ -46,5 +46,4 @@ M: float-regs fastcall-regs vregs ;
: %prologue ( n -- ) : %prologue ( n -- )
\ stack-reserve set stack-reg stack-increment SUB ; \ stack-reserve set stack-reg stack-increment SUB ;
: %epilogue ( -- ) : %epilogue ( -- ) stack-reg stack-increment ADD ;
stack-reg stack-increment ADD ;

View File

@ -1,12 +1,28 @@
IN: temporary IN: temporary
USING: errors compiler test namespaces sequences kernel-internals ; USING: errors compiler test namespaces sequences
kernel-internals kernel math ;
: nice-stack-trace
error-stack-trace get symbolic-stack-trace [ second ] map ;
: foo 3 throw 7 ; : foo 3 throw 7 ;
: bar foo 4 ; : bar foo 4 ;
: baz bar 5 ; : baz bar 5 ;
\ baz compile \ baz compile
[ 3 ] [ [ baz ] catch ] unit-test [ 3 ] [ [ baz ] catch ] unit-test
[ { foo bar baz } ] [ [ { foo bar baz } ] [ nice-stack-trace ] unit-test
error-stack-trace get symbolic-stack-trace
[ second ] map [ ] subset : bleh [ 3 + ] map [ 0 > ] subset ;
\ bleh compile
: stack-trace-contains? nice-stack-trace memq? ;
[ t ] [
[ { 1 "hi" } bleh ] catch drop \ + stack-trace-contains?
] unit-test
[ f t ] [
[ { C{ 1 2 } } bleh ] catch drop
\ + stack-trace-contains?
\ > stack-trace-contains?
] unit-test ] unit-test

View File

@ -9,5 +9,4 @@ void *native_stack_pointer(void) */
.globl MANGLE(native_stack_pointer) .globl MANGLE(native_stack_pointer)
MANGLE(native_stack_pointer): MANGLE(native_stack_pointer):
mov %rsp,%rax mov %rsp,%rax
add $8,%rax
ret ret

View File

@ -8,10 +8,7 @@ INLINE void flush_icache(CELL start, CELL len) {}
void *native_stack_pointer(void); void *native_stack_pointer(void);
typedef struct _F_STACK_FRAME { typedef CELL F_STACK_FRAME;
struct _F_STACK_FRAME *previous;
CELL return_address;
} F_STACK_FRAME;
#define PREVIOUS_FRAME(frame) (frame->previous) #define PREVIOUS_FRAME(frame) (frame + 1)
#define RETURN_ADDRESS(frame) (frame->return_address) #define RETURN_ADDRESS(frame) (*(frame))

View File

@ -276,14 +276,16 @@ CELL allot_native_stack_trace(void)
GROWABLE_ADD(array,cell); GROWABLE_ADD(array,cell);
} }
if(PREVIOUS_FRAME(frame) <= frame) F_STACK_FRAME *prev = PREVIOUS_FRAME(frame);
if(prev <= frame)
{ {
fprintf(stderr,"*** Unusual C stack layout (why?)\n"); fprintf(stderr,"*** Unusual C stack layout (why?)\n");
fflush(stderr); fflush(stderr);
break; break;
} }
frame = PREVIOUS_FRAME(frame); frame = prev;
} }
GROWABLE_TRIM(array); GROWABLE_TRIM(array);

View File

@ -46,8 +46,13 @@ F_ARRAY *allot_array(CELL type, F_FIXNUM capacity, CELL fill)
/* size is in bytes this time */ /* size is in bytes this time */
F_ARRAY *allot_byte_array(F_FIXNUM size) F_ARRAY *allot_byte_array(F_FIXNUM size)
{ {
F_FIXNUM byte_size = (F_FIXNUM)(size + sizeof(CELL) - 1) if(size < 0)
/ (F_FIXNUM)sizeof(CELL); {
general_error(ERROR_NEGATIVE_ARRAY_SIZE,allot_integer(size),F,true);
return NULL;
}
CELL byte_size = (size + sizeof(CELL) - 1) / sizeof(CELL);
return allot_array(BYTE_ARRAY_TYPE,byte_size,0); return allot_array(BYTE_ARRAY_TYPE,byte_size,0);
} }