vm: load mega cache object before popping frame

Fixes #457 harder
db4
Joe Groff 2011-12-20 14:38:01 -08:00
parent 9b56fbb1c1
commit b6f323450f
5 changed files with 14 additions and 4 deletions

View File

@ -254,6 +254,12 @@ void factor_vm::print_callstack()
std::cout << "*** Context not initialized" << std::endl; 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 { struct padded_address {
cell value; cell value;

View File

@ -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> methods(methods_,parent);
data_root<array> cache(cache_,parent); data_root<array> cache(cache_,parent);
/* Load the object from the datastack. */ /* The object must be on the top of the datastack at this point. */
emit_with_literal(parent->special_objects[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
/* Do a cache lookup. */ /* Do a cache lookup. */
emit_with_literal(parent->special_objects[MEGA_LOOKUP],cache.value()); emit_with_literal(parent->special_objects[MEGA_LOOKUP],cache.value());

View File

@ -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], unwind_native_frames(special_objects[ERROR_HANDLER_QUOT],
ctx->callstack_top); 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. */ crash. */
else else
{ {

View File

@ -281,11 +281,15 @@ void quotation_jit::iterate_quotation()
/* Method dispatch */ /* Method dispatch */
if(mega_lookup_p(i,length)) 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); emit_epilog(safepoint, stack_frame);
tail_call = true; tail_call = true;
emit_mega_cache_lookup( emit_mega_cache_lookup(
array_nth(elements.untagged(),i), array_nth(elements.untagged(),i),
untag_fixnum(array_nth(elements.untagged(),i + 1)), index,
array_nth(elements.untagged(),i + 2)); array_nth(elements.untagged(),i + 2));
i += 3; i += 3;
} }

View File

@ -406,6 +406,7 @@ struct factor_vm
void print_datastack(); void print_datastack();
void print_retainstack(); void print_retainstack();
void print_callstack(); void print_callstack();
void print_callstack_object(callstack *obj);
void dump_cell(cell x); void dump_cell(cell x);
void dump_memory(cell from, cell to); void dump_memory(cell from, cell to);
template<typename Generation> void dump_generation(const char *name, Generation *gen); template<typename Generation> void dump_generation(const char *name, Generation *gen);