SCI: Add callk stackframe directly in run_vm

svn-id: r44473
This commit is contained in:
Willem Jan Palenstijn 2009-09-30 00:13:59 +00:00
parent ff70b554ea
commit 77bd8d0bfb
2 changed files with 14 additions and 11 deletions

View File

@ -84,15 +84,7 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvoc
}
va_end(argp);
// Write "kernel" call to the stack, for debugging:
ExecStack *xstack;
xstack = add_exec_stack_entry(s, NULL_REG, NULL, NULL_REG, k_argc, k_argp - 1, 0, NULL_REG,
s->_executionStack.size()-1, SCI_XS_CALLEE_LOCALS);
// FIXME: With this hack, selector was set to -42 - kfunct, which has been changed, as we
// no longer pass the function number to each function (commit #44461). Therefore, this no
// longer works. A better alternative needs to be done to restore the previous functionality
xstack->selector = -42 + 1; // Evil debugging hack to identify kernel function
xstack->type = EXEC_STACK_TYPE_KERNEL;
// Now commit the actual function:
xstack = send_selector(s, object, object, stackframe, framesize, stackframe);
@ -102,8 +94,6 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvoc
run_vm(s, 0); // Start a new vm
s->_executionStack.pop_back(); // Get rid of the extra stack entry
return 0;
}

View File

@ -946,7 +946,21 @@ void run_vm(EngineState *s, int restoring) {
reg_t *argv = scriptState.xs->sp + 1;
if (!kfun.isDummy) {
// Add stack frame to indicate we're executing a callk.
// This is useful in debugger backtraces if this
// kernel function calls a script itself.
ExecStack *xstack;
xstack = add_exec_stack_entry(s, NULL_REG, NULL, NULL_REG, argc, argv - 1, 0, NULL_REG,
s->_executionStack.size()-1, SCI_XS_CALLEE_LOCALS);
// Debugging hack to identify kernel function
xstack->selector = -42 - opparams[0];
xstack->type = EXEC_STACK_TYPE_KERNEL;
// Call kernel function
s->r_acc = kfun.fun(s, argc, argv);
// Remove callk stack frame again
s->_executionStack.pop_back();
} else {
Common::String warningMsg = "Dummy function " + kfun.orig_name + "[";
warningMsg += warningMsg.printf("0x%x", opparams[0]);
@ -962,7 +976,6 @@ void run_vm(EngineState *s, int restoring) {
warning(warningMsg.c_str());
}
}
// Call kernel function
// Calculate xs again: The kernel function might
// have spawned a new VM