diff --git a/vm/debug.cpp b/vm/debug.cpp index e916fb83b7..bd5ac6aec9 100755 --- a/vm/debug.cpp +++ b/vm/debug.cpp @@ -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; diff --git a/vm/dispatch.cpp b/vm/dispatch.cpp index 480da1fd03..e8d19384cd 100755 --- a/vm/dispatch.cpp +++ b/vm/dispatch.cpp @@ -148,8 +148,7 @@ void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index, cell cac data_root methods(methods_,parent); data_root 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()); diff --git a/vm/errors.cpp b/vm/errors.cpp index b7fd4488a8..ced1518156 100755 --- a/vm/errors.cpp +++ b/vm/errors.cpp @@ -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 { diff --git a/vm/quotations.cpp b/vm/quotations.cpp index 1906729450..5f44875559 100755 --- a/vm/quotations.cpp +++ b/vm/quotations.cpp @@ -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; } diff --git a/vm/vm.hpp b/vm/vm.hpp index 70af2cc77b..01f0a2afc2 100755 --- 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 void dump_generation(const char *name, Generation *gen);