Restore "direct" call optimization for DECORATE

This commit is contained in:
Randy Heit 2016-02-18 22:05:16 -06:00
parent ade780d810
commit b1098ede93
3 changed files with 18 additions and 22 deletions

View File

@ -277,7 +277,7 @@ static void FinishThingdef()
// Can we call this function directly without wrapping it in an
// anonymous function? e.g. Are we passing any parameters to it?
func = NULL;//tcall->Code->GetDirectFunction();
func = tcall->Code->GetDirectFunction();
if (func == NULL)
{
FCompileContext ctx(tcall->ActorClass);

View File

@ -835,9 +835,9 @@ public:
FxExpression *Resolve(FCompileContext&);
ExpEmit Emit(VMFunctionBuilder *build);
ExpEmit Emit(VMFunctionBuilder *build, bool tailcall);
unsigned GetArgCount() { return ArgList == NULL ? 0 : ArgList->Size(); }
VMFunction *GetVMFunction() { return Function->Variants[0].Implementation; }
VMFunction *GetDirectFunction();
unsigned GetArgCount() const { return ArgList == NULL ? 0 : ArgList->Size(); }
VMFunction *GetVMFunction() const { return Function->Variants[0].Implementation; }
bool IsDirectFunction();
};
//==========================================================================
@ -891,6 +891,7 @@ public:
FxReturnStatement(FxVMFunctionCall *call, const FScriptPosition &pos);
FxExpression *Resolve(FCompileContext&);
ExpEmit Emit(VMFunctionBuilder *build);
VMFunction *GetDirectFunction();
};
//==========================================================================

View File

@ -3202,24 +3202,6 @@ ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build, bool tailcall)
}
}
//==========================================================================
//
// FxVMFunctionCall :: GetDirectFunction
//
// If the function is not passed any explicit arguments, returns the
// function. Otherwise returns NULL.
//
//==========================================================================
VMFunction *FxVMFunctionCall::GetDirectFunction()
{
if (GetArgCount() == 0)
{
return GetVMFunction();
}
return NULL;
}
//==========================================================================
//
//
@ -3505,6 +3487,19 @@ ExpEmit FxReturnStatement::Emit(VMFunctionBuilder *build)
return ExpEmit();
}
VMFunction *FxReturnStatement::GetDirectFunction()
{
// If this return statement calls a function with no arguments,
// then it can be a "direct" function. That is, the DECORATE
// definition can call that function directly without wrapping
// it inside VM code.
if (Call != NULL && Call->GetArgCount() == 0)
{
return Call->GetVMFunction();
}
return NULL;
}
//==========================================================================
//
//==========================================================================