[gamecode] Return early if the entered function has no locals

As even the simplest v6p functions that take parameters but have no
local or temporary variables still have locals for the local copy of the
parameters, this is a both a good check for for the Ruamoko ISA as its
functions never have locals (everything's on the progs data stack), and
an optimization for v6p functions that have no params or locals (simple
getters (very rare?), most .ctor, etc).
This commit is contained in:
Bill Currie 2022-01-22 21:41:35 +09:00
parent 234f2212d6
commit 861e98725c
1 changed files with 8 additions and 4 deletions

View File

@ -229,6 +229,14 @@ PR_EnterFunction (progs_t *pr, bfunction_t *f)
PR_PushFrame (pr);
//Sys_Printf("%s:\n", PR_GetString(pr,f->name));
pr->pr_xfunction = f;
pr->pr_xstatement = f->first_statement - 1; // offset the st++
if (!f->locals) {
return;
}
if (f->numparms > 0) {
paramofs = f->parm_start;
for (i = 0; i < f->numparms; i++) {
@ -267,10 +275,6 @@ PR_EnterFunction (progs_t *pr, bfunction_t *f)
}
}
//Sys_Printf("%s:\n", PR_GetString(pr,f->name));
pr->pr_xfunction = f;
pr->pr_xstatement = f->first_statement - 1; // offset the st++
// save off any locals that the new function steps on
if (pr->localstack_used + f->locals > PR_LOCAL_STACK_SIZE)
PR_RunError (pr, "PR_EnterFunction: locals stack overflow");