mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
[ruamoko] Preserve the stack in obj_msg_sendv
obj_msg_sendv needs to push the parameters onto the stack for Ruamoko progs, but this causes problems because PR_CallFunction winds up recording the wrong stack pointer for progs functions, and nothing restores the stack for builtins. The handling is basically the same as for the return pointer.
This commit is contained in:
parent
b6a8a93cc3
commit
cdc3c9822d
1 changed files with 14 additions and 1 deletions
|
@ -1430,6 +1430,11 @@ rua_obj_msg_sendv (progs_t *pr)
|
|||
// replace them
|
||||
count -= 2;
|
||||
params += 2 * pr->pr_param_size;
|
||||
pr_ptr_t saved_stack = 0;
|
||||
int sendv_depth = pr->pr_depth;
|
||||
if (pr->globals.stack) {
|
||||
saved_stack = *pr->globals.stack;
|
||||
}
|
||||
PR_RESET_PARAMS (pr);
|
||||
P_POINTER (pr, 0) = obj;
|
||||
P_POINTER (pr, 1) = sel;
|
||||
|
@ -1437,7 +1442,15 @@ rua_obj_msg_sendv (progs_t *pr)
|
|||
memcpy (&P_INT (pr, 2), params,
|
||||
count * sizeof (pr_type_t) * pr->pr_param_size);
|
||||
}
|
||||
PR_CallFunction (pr, imp, pr->pr_return);
|
||||
if (PR_CallFunction (pr, imp, pr->pr_return)) {
|
||||
// the call is to a progs function so a frame was pushed, ensure
|
||||
// the stack pointer is restored on return
|
||||
// if there's no stack, then the following is effectively a noop
|
||||
pr->pr_stack[sendv_depth].stack_ptr = saved_stack;
|
||||
} else if (pr->globals.stack) {
|
||||
// the call was to a builtin, restore the stack
|
||||
*pr->globals.stack = saved_stack;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue