]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: load mega cache object before popping frame
authorJoe Groff <arcata@gmail.com>
Tue, 20 Dec 2011 22:38:01 +0000 (14:38 -0800)
committerJoe Groff <arcata@gmail.com>
Tue, 20 Dec 2011 22:38:01 +0000 (14:38 -0800)
Fixes #457 harder

vm/debug.cpp
vm/dispatch.cpp
vm/errors.cpp
vm/quotations.cpp
vm/vm.hpp

index e916fb83b78eadb68d7bcd3c2b28d23adf26d90c..bd5ac6aec95e6c423692572725c0d49a58761a6b 100755 (executable)
@@ -254,6 +254,12 @@ void factor_vm::print_callstack()
                std::cout << "*** Context not initialized" << std::endl;
 }
 
+void factor_vm::print_callstack_object(callstack *obj)
+{
+       stack_frame_printer printer(this);
+       iterate_callstack_object(obj,printer);
+}
+
 struct padded_address {
        cell value;
 
index 480da1fd035c80614e0c791eb30d2a21e1c68228..e8d19384cd79ab74d076b7a29d3abda21765dc19 100755 (executable)
@@ -148,8 +148,7 @@ void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index, cell cac
        data_root<array> methods(methods_,parent);
        data_root<array> cache(cache_,parent);
 
-       /* Load the object from the datastack. */
-       emit_with_literal(parent->special_objects[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
+       /* The object must be on the top of the datastack at this point. */
 
        /* Do a cache lookup. */
        emit_with_literal(parent->special_objects[MEGA_LOOKUP],cache.value());
index b7fd4488a89bda19b8727928ec07d3b1b275a7bd..ced151815669e11b519797856179f9348df7e853 100755 (executable)
@@ -78,7 +78,7 @@ void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2)
                unwind_native_frames(special_objects[ERROR_HANDLER_QUOT],
                        ctx->callstack_top);
        }
-       /* Error was thrown in early startup before error handler is set, just
+       /* Error was thrown in early startup before error handler is set, so just
        crash. */
        else
        {
index 190672945021fec88d58094b7ca6061221d42b73..5f44875559a480a2e2e34a493485aabd65847d0c 100755 (executable)
@@ -281,11 +281,15 @@ void quotation_jit::iterate_quotation()
                        /* Method dispatch */
                        if(mega_lookup_p(i,length))
                        {
+                               fixnum index = untag_fixnum(array_nth(elements.untagged(),i + 1));
+                               /* Load the object from the datastack, then remove our stack frame. */
+                               emit_with_literal(parent->special_objects[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
                                emit_epilog(safepoint, stack_frame);
                                tail_call = true;
+
                                emit_mega_cache_lookup(
                                        array_nth(elements.untagged(),i),
-                                       untag_fixnum(array_nth(elements.untagged(),i + 1)),
+                                       index,
                                        array_nth(elements.untagged(),i + 2));
                                i += 3;
                        }
index 70af2cc77b1f79ea44fe1b61e5170e08fbe2f01c..01f0a2afc209b66ff5aafd504b60b4c7578cc6be 100755 (executable)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -406,6 +406,7 @@ struct factor_vm
        void print_datastack();
        void print_retainstack();
        void print_callstack();
+       void print_callstack_object(callstack *obj);
        void dump_cell(cell x);
        void dump_memory(cell from, cell to);
        template<typename Generation> void dump_generation(const char *name, Generation *gen);