]> gitweb.factorcode.org Git - factor.git/commitdiff
callstack>array was keeping an uninitialized array around across potential GCs; add...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 17 May 2009 23:18:07 +0000 (18:18 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 17 May 2009 23:18:07 +0000 (18:18 -0500)
vm/callstack.cpp
vm/local_roots.hpp

index 4ef6db10bd1dc4b9db3fc8e14e214ce51bf6769f..608a5c39e5c1b0d777408e2b4158ec39b20e3349 100755 (executable)
@@ -92,7 +92,9 @@ cell frame_executing(stack_frame *frame)
        else
        {
                array *literals = untag<array>(compiled->literals);
-               return array_nth(literals,0);
+               cell executing = array_nth(literals,0);
+               check_data_pointer((object *)executing);
+               return executing;
        }
 }
 
@@ -102,6 +104,7 @@ stack_frame *frame_successor(stack_frame *frame)
        return (stack_frame *)((cell)frame - frame->size);
 }
 
+/* Allocates memory */
 cell frame_scan(stack_frame *frame)
 {
        if(frame_type(frame) == QUOTATION_TYPE)
@@ -133,12 +136,12 @@ struct stack_frame_counter {
 
 struct stack_frame_accumulator {
        cell index;
-       array *frames;
-       stack_frame_accumulator(cell count) : index(0), frames(allot_array_internal<array>(count)) {}
+       gc_root<array> frames;
+       stack_frame_accumulator(cell count) : index(0), frames(allot_array(count,F)) {}
        void operator()(stack_frame *frame)
        {
-               set_array_nth(frames,index++,frame_executing(frame));
-               set_array_nth(frames,index++,frame_scan(frame));
+               set_array_nth(frames.untagged(),index++,frame_executing(frame));
+               set_array_nth(frames.untagged(),index++,frame_scan(frame));
        }
 };
 
@@ -154,7 +157,7 @@ PRIMITIVE(callstack_to_array)
        stack_frame_accumulator accum(counter.count);
        iterate_callstack_object(callstack.untagged(),accum);
 
-       dpush(tag<array>(accum.frames));
+       dpush(accum.frames.value());
 }
 
 stack_frame *innermost_stack_frame(callstack *stack)
index e074d999e7f221b17066a2ed8d8661d52b7919d4..4cee1c8e092c43b75548332606cb56801ea2fa27 100644 (file)
@@ -12,7 +12,7 @@ DEFPUSHPOP(gc_local_,gc_locals)
 template <typename T>
 struct gc_root : public tagged<T>
 {
-       void push() { gc_local_push((cell)this); }
+       void push() { check_tagged_pointer(tagged<T>::value()); gc_local_push((cell)this); }
        
        explicit gc_root(cell value_) : tagged<T>(value_) { push(); }
        explicit gc_root(T *value_) : tagged<T>(value_) { push(); }