]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix runtime compile warnings; working on native stack traces again
authorslava <slava@factorcode.org>
Sun, 17 Dec 2006 22:40:21 +0000 (22:40 +0000)
committerslava <slava@factorcode.org>
Sun, 17 Dec 2006 22:40:21 +0000 (22:40 +0000)
12 files changed:
vm/bignumint.h
vm/cpu-amd64.h
vm/cpu-ppc.h
vm/cpu-x86.h
vm/data_gc.c
vm/os-linux-ppc.h [new file with mode: 0644]
vm/os-macosx-ppc.h
vm/platform.h
vm/run.c
vm/stack.c
vm/stack.h
vm/types.c

index cb6a42b5f765a810e6bdbc0cadb77c865841accf..aacde5d195f18fe83514c1eb6c2278fe4c7c9538 100644 (file)
@@ -46,7 +46,7 @@ typedef F_FIXNUM bignum_digit_type;
 typedef F_FIXNUM bignum_length_type;
 
 /* BIGNUM_TO_POINTER casts a bignum object to a digit array pointer. */
-#define BIGNUM_TO_POINTER(bignum) ((CELL*)AREF(bignum,0))
+#define BIGNUM_TO_POINTER(bignum) ((bignum_digit_type *)AREF(bignum,0))
 
 /* BIGNUM_EXCEPTION is invoked to handle assertion violations. */
 #define BIGNUM_EXCEPTION abort
index 7e75bdc0e0651a7d3e241a102b135446534e98de..99318ab68758aa57a8f1e9d6269152b8b7a67b32 100644 (file)
@@ -10,5 +10,8 @@ void *native_stack_pointer(void);
 
 typedef struct _F_STACK_FRAME {
        struct _F_STACK_FRAME *previous;
-       CELL *return_address;
+       CELL return_address;
 } F_STACK_FRAME;
+
+#define PREVIOUS_FRAME(frame) (frame->previous)
+#define RETURN_ADDRESS(frame) (frame->return_address)
index 8d8f2bace368f1e40cdfa89d475aa947120faa85..3e4a0f32140a94404c6000e18724cdc2b8abde4e 100644 (file)
@@ -7,3 +7,6 @@ register CELL cards_offset asm("r16");
 void flush_icache(CELL start, CELL len);
 
 void *native_stack_pointer(void);
+
+#define PREVIOUS_FRAME(frame) (frame->previous)
+#define RETURN_ADDRESS(frame) (frame->return_address)
index ee0472f9f78a7ace8e390e1652f5f225a7072cad..51e511f53f4aea4353a947f74874e15ccbc27627 100644 (file)
@@ -8,7 +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 + 1)
+#define RETURN_ADDRESS(frame) (*(frame))
index bbd0310b11c1e1cf0d754ddcfc5efa39d2f5bcdb..f11a1c416ebfd7c286b444ea47bfc3eaa8e7c85b 100644 (file)
@@ -311,7 +311,7 @@ the user environment and extra roots registered with REGISTER_ROOT */
 void collect_roots(void)
 {
        int i;
-       F_STACKS *stacks;
+       F_CONTEXT *stacks;
 
        copy_handle(&T);
        copy_handle(&bignum_zero);
diff --git a/vm/os-linux-ppc.h b/vm/os-linux-ppc.h
new file mode 100644 (file)
index 0000000..4dae4c6
--- /dev/null
@@ -0,0 +1,4 @@
+typedef struct _F_STACK_FRAME {
+       struct _F_STACK_FRAME *previous;
+       CELL return_address;
+} F_STACK_FRAME;
index 36706ba8cea164ffc55a9fea434b65f53b473574..d1ac388a42ec9eb36c04196cac63f57d55b913ce 100644 (file)
@@ -1,7 +1,7 @@
 typedef struct _F_STACK_FRAME {
        struct _F_STACK_FRAME *previous;
        CELL padding1;
-       CELL *return_address;
+       CELL return_address;
        CELL padding2;
 } F_STACK_FRAME;
 
index 5d125c45356c3dfecbd0f1b010522d47f6104b28..d892e7c98c27e87f2711157a627636fe20099447 100644 (file)
                #ifdef __FreeBSD__
                        #include "os-freebsd.h"
                #elif defined(linux)
-                               #include "os-linux.h"
+                       #ifdef FACTOR_PPC
+                               #include "os-linux-ppc.h"
+                       #endif
+
+                       #include "os-linux.h"
                #elif defined(__sun)
                        #include "os-solaris.h"
                #else
index ca3b476dc9fdb6aebdb553ffb67e866a86a26aa4..a247ab9327f5f1282ef85552c7d430a0d7029b84 100644 (file)
--- a/vm/run.c
+++ b/vm/run.c
@@ -263,19 +263,27 @@ CELL allot_native_stack_trace(void)
        F_STACK_FRAME *frame = native_stack_pointer();
        GROWABLE_ARRAY(array);
 
-       while((CELL)frame < (CELL)stack_chain->native_stack_pointer)
+       while(frame < stack_chain->native_stack_pointer)
        {
-               REGISTER_ARRAY(array);
-               CELL cell = allot_cell((CELL)frame->return_address);
-               UNREGISTER_ARRAY(array);
-               GROWABLE_ADD(array,cell);
-               if((CELL)frame->previous <= (CELL)frame)
+               CELL return_address = RETURN_ADDRESS(frame);
+
+               if(return_address >= compiling.base
+                       && return_address <= compiling.limit)
                {
-                       fprintf(stderr,"Factor warning: unusual C stack layout\n");
+                       REGISTER_ARRAY(array);
+                       CELL cell = allot_cell(return_address);
+                       UNREGISTER_ARRAY(array);
+                       GROWABLE_ADD(array,cell);
+               }
+
+               if(PREVIOUS_FRAME(frame) <= frame)
+               {
+                       fprintf(stderr,"*** Unusual C stack layout (why?)\n");
                        fflush(stderr);
                        break;
                }
-               frame = frame->previous;
+
+               frame = PREVIOUS_FRAME(frame);
        }
 
        GROWABLE_TRIM(array);
@@ -288,7 +296,7 @@ void throw_error(CELL error, bool keep_stacks)
        early_error(error);
 
        REGISTER_ROOT(error);
-       thrown_native_stack_trace = F; /* allot_native_stack_trace(); */
+       thrown_native_stack_trace = allot_native_stack_trace();
        UNREGISTER_ROOT(error);
 
        throwing = true;
index d9008beaca4b33d1f3ee3a3e848138cafd2f2e74..e23e632eb3bf5e52652058157d04117c2576d380 100644 (file)
@@ -43,7 +43,7 @@ void save_stacks(void)
 /* called on entry into a compiled callback */
 void nest_stacks(void)
 {
-       F_STACKS *new_stacks = safe_malloc(sizeof(F_STACKS));
+       F_CONTEXT *new_stacks = safe_malloc(sizeof(F_CONTEXT));
        
        /* note that these register values are not necessarily valid stack
        pointers. they are merely saved non-volatile registers, and are
@@ -101,7 +101,7 @@ void unnest_stacks(void)
 
        extra_roots = stack_chain->extra_roots;
 
-       F_STACKS *old_stacks = stack_chain;
+       F_CONTEXT *old_stacks = stack_chain;
        stack_chain = old_stacks->next;
        free(old_stacks);
 }
index 037a57016fe7574457d84f339206f587463a2cb2..e5d5395911eadea942fb82510d67e5b58fe42eb8 100644 (file)
@@ -1,4 +1,4 @@
-typedef struct _F_STACKS {
+typedef struct _F_CONTEXT {
        /* current datastack top pointer */
        CELL data;
        /* saved contents of ds register on entry to callback */
@@ -35,15 +35,15 @@ typedef struct _F_STACKS {
        CELL extra_roots;
 
        /* C stack pointer on entry */
-       void *native_stack_pointer;
+       F_STACK_FRAME *native_stack_pointer;
 
        /* error handler longjmp buffer */
        JMP_BUF toplevel;
 
-       struct _F_STACKS *next;
-} F_STACKS;
+       struct _F_CONTEXT *next;
+} F_CONTEXT;
 
-F_STACKS *stack_chain;
+F_CONTEXT *stack_chain;
 
 CELL ds_size, rs_size, cs_size;
 
index 0e79c08f10269349fdba023a65ffa7c0e3b565bf..387d12b08553f74d7c7ffac4f1887bb199234442 100644 (file)
@@ -245,15 +245,15 @@ void primitive_resize_string(void)
        void primitive_memory_to_##type##_string(void) \
        { \
                CELL length = unbox_unsigned_cell(); \
-               type *string = (type*)unbox_unsigned_cell(); \
+               const type *string = (const type*)unbox_unsigned_cell(); \
                dpush(tag_object(memory_to_##type##_string(string,length))); \
        } \
        F_STRING *from_##type##_string(const type *str) \
        { \
                CELL length = 0; \
-               type *scan = str; \
+               const type *scan = str; \
                while(*scan++) length++; \
-               return memory_to_##type##_string((type*)str,length); \
+               return memory_to_##type##_string(str,length); \
        } \
        void box_##type##_string(const type *str) \
        { \