VM: code_block::scan, make it so the method always returns -1 if scan can't be determined, part of the fix for #1265

db4
Björn Lindqvist 2015-01-04 15:30:04 +01:00
parent 8ee1f890f2
commit 11e906139b
2 changed files with 20 additions and 19 deletions

View File

@ -44,7 +44,13 @@ HELP: set-retainstack
HELP: callstack
{ $values { "callstack" callstack } }
{ $description "Outputs a copy of the call stack contents, with the top of the stack at the end of the vector. The stack frame of the caller word is " { $emphasis "not" } " included." } ;
{ $description "Outputs a copy of the call stack contents, with the top of the stack at the end of the vector. The stack frame of the caller word is " { $emphasis "not" } " included. Each group of three elements in the callstack is frame:"
{ $list
"The first element is the executing word or quotation."
"The second element is the executing quotation."
"The third element is the offset in the executing quotation, or -1 if the offset can't be determined."
}
} ;
HELP: set-callstack
{ $values { "callstack" callstack } }

View File

@ -9,26 +9,21 @@ cell code_block::owner_quot() const {
return executing.value();
}
/* If the code block is an unoptimized quotation, we can calculate the
scan offset. In all other cases -1 is returned. */
cell code_block::scan(factor_vm* vm, void* addr) const {
switch (type()) {
case code_block_unoptimized: {
tagged<object> obj(owner);
if (obj.type_p(WORD_TYPE))
obj = obj.as<word>()->def;
if (obj.type_p(QUOTATION_TYPE))
return tag_fixnum(
vm->quot_code_offset_to_scan(obj.value(), offset(addr)));
else
return false_object;
}
case code_block_optimized:
case code_block_pic:
return false_object;
default:
critical_error("Bad frame type", type());
return false_object;
if (type() != code_block_unoptimized) {
return tag_fixnum(-1);
}
tagged<object> obj(owner);
if (obj.type_p(WORD_TYPE))
obj = obj.as<word>()->def;
if (!obj.type_p(QUOTATION_TYPE))
return tag_fixnum(-1);
cell ofs = offset(addr);
return tag_fixnum(vm->quot_code_offset_to_scan(obj.value(), ofs));
}
cell factor_vm::compute_entry_point_address(cell obj) {