- removed OP_TAIL.

The amount of support code for this minor optimization was quite large and this stood in the way of streamlining the VM's calling convention, so it was preferable to remove it before moving on.
This commit is contained in:
Christoph Oelckers 2018-11-18 07:43:03 +01:00
commit 629d329f22
9 changed files with 12 additions and 219 deletions

View file

@ -718,45 +718,6 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
pc += C; // Skip RESULTs
}
NEXTOP;
OP(TAIL_K):
ASSERTKA(a);
ptr = konsta[a].o;
goto Do_TAILCALL;
OP(TAIL):
ASSERTA(a);
ptr = reg.a[a];
Do_TAILCALL:
// Whereas the CALL instruction uses its third operand to specify how many return values
// it expects, TAIL ignores its third operand and uses whatever was passed to this Exec call.
assert(B <= f->NumParam);
assert(C <= MAX_RETURNS);
{
VMFunction *call = (VMFunction *)ptr;
if (call->VarFlags & VARF_Native)
{
try
{
VMCycles[0].Unclock();
auto r = static_cast<VMNativeFunction *>(call)->NativeCall(reg.param + f->NumParam - B, B, ret, numret);
VMCycles[0].Clock();
return r;
}
catch (CVMAbortException &err)
{
err.MaybePrintMessage();
err.stacktrace.AppendFormat("Called from %s\n", call->PrintableName.GetChars());
// PrintParameters(reg.param + f->NumParam - B, B);
throw;
}
}
else
{ // FIXME: Not a true tail call
auto sfunc = static_cast<VMScriptFunction *>(call);
return sfunc->ScriptCall(sfunc, reg.param + f->NumParam - B, B, ret, numret);
}
}
NEXTOP;
OP(RET):
if (B == REGT_NIL)
{ // No return values