]> gitweb.factorcode.org Git - factor.git/commitdiff
AMD64 fixes
authorslava <slava@factorcode.org>
Mon, 18 Dec 2006 02:25:43 +0000 (02:25 +0000)
committerslava <slava@factorcode.org>
Mon, 18 Dec 2006 02:25:43 +0000 (02:25 +0000)
Makefile
core/compiler/amd64/architecture.factor
core/compiler/test/stack-trace.factor
vm/cpu-amd64.S
vm/cpu-amd64.h
vm/run.c
vm/types.c

index d36bb83fb7638506e26f5ecd595adb4aeca8f57c..b3db92479c480125f55d609c6525779bf7c96c53 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ DISK_IMAGE = Factor-$(VERSION).dmg
 LIBPATH = -L/usr/X11R6/lib
 
 ifdef DEBUG
-       CFLAGS = -g
+       CFLAGS = -g -std=gnu99
        STRIP = touch
 else
        CFLAGS = -Wall -O3 -ffast-math -std=gnu99 $(SITE_CFLAGS)
index e8aeffbce6fd8e72de7bcad4eda4cd590b8b3004..43d833531cf60d917e41208c080435b8cf938223 100644 (file)
@@ -46,5 +46,4 @@ M: float-regs fastcall-regs vregs ;
 : %prologue ( n -- )
     \ stack-reserve set stack-reg stack-increment SUB ;
 
-: %epilogue ( -- )
-    stack-reg stack-increment ADD ;
+: %epilogue ( -- ) stack-reg stack-increment ADD ;
index de1c5c828c003d213d456d9633a8ef90fd5ac8fb..daf8afacc98d2a53bae631b61ba135e6991be3ec 100644 (file)
@@ -1,12 +1,28 @@
 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 ;
 : bar foo 4 ;
 : baz bar 5 ;
 \ baz compile
 [ 3 ] [ [ baz ] catch ] unit-test
-[ { foo bar baz } ] [
-    error-stack-trace get symbolic-stack-trace
-    [ second ] map [ ] subset
+[ { foo bar baz } ] [ nice-stack-trace ] unit-test
+
+: 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
index eb3c1009acf031a035c9938cc043a8b6ca1afb97..9d4946ae2c6cdbea04fc742ce66faafc9c13c935 100644 (file)
@@ -9,5 +9,4 @@ void *native_stack_pointer(void) */
        .globl MANGLE(native_stack_pointer)
 MANGLE(native_stack_pointer):
        mov %rsp,%rax
-       add $8,%rax
        ret
index 99318ab68758aa57a8f1e9d6269152b8b7a67b32..55d845c48b78f7d7f5d957fe7f186eadffd2b694 100644 (file)
@@ -8,10 +8,7 @@ INLINE void flush_icache(CELL start, CELL len) {}
 
 void *native_stack_pointer(void);
 
-typedef struct _F_STACK_FRAME {
-       struct _F_STACK_FRAME *previous;
-       CELL return_address;
-} F_STACK_FRAME;
+typedef CELL F_STACK_FRAME;
 
-#define PREVIOUS_FRAME(frame) (frame->previous)
-#define RETURN_ADDRESS(frame) (frame->return_address)
+#define PREVIOUS_FRAME(frame) (frame + 1)
+#define RETURN_ADDRESS(frame) (*(frame))
index a247ab9327f5f1282ef85552c7d430a0d7029b84..1cf4a55c2e00be6de96142ed31dac00a8735dafe 100644 (file)
--- a/vm/run.c
+++ b/vm/run.c
@@ -276,14 +276,16 @@ CELL allot_native_stack_trace(void)
                        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");
                        fflush(stderr);
                        break;
                }
 
-               frame = PREVIOUS_FRAME(frame);
+               frame = prev;
        }
 
        GROWABLE_TRIM(array);
index 387d12b08553f74d7c7ffac4f1887bb199234442..bbeb90ff8bf7fe3ed581810609be9e3408814c98 100644 (file)
@@ -46,8 +46,13 @@ F_ARRAY *allot_array(CELL type, F_FIXNUM capacity, CELL fill)
 /* size is in bytes this time */
 F_ARRAY *allot_byte_array(F_FIXNUM size)
 {
-       F_FIXNUM byte_size = (F_FIXNUM)(size + sizeof(CELL) - 1)
-               / (F_FIXNUM)sizeof(CELL);
+       if(size < 0)
+       {
+               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);
 }