- refactored the scope check for VirtualScope calls.

It now uses a dedicated opcode instead of piggybacking on OP_CALL and it passes data that is closer to the VM. Symbols should be avoided at this level.
It also will skip the scope instruction if the code generator detects that both calling function and the self pointer type have the same scope, this assumes that subclasses cannot flip between UI and Play.
This commit is contained in:
Christoph Oelckers 2017-03-07 22:17:48 +01:00
commit e2f3a09dd0
5 changed files with 33 additions and 35 deletions

View file

@ -648,6 +648,13 @@ begin:
reg.a[a] = p->Virtuals[C];
}
NEXTOP;
OP(SCOPE) :
{
ASSERTA(a); ASSERTA(C);
FScopeBarrier::ValidateCall(((DObject*)a)->GetClass(), (VMFunction*)C, B);
}
NEXTOP;
OP(CALL_K):
ASSERTKA(a);
assert(konstatag[a] == ATAG_OBJECT);
@ -665,19 +672,6 @@ begin:
int numret;
b = B;
#if 0
// [ZZ] hax!
if (call->BarrierSide == 3) // :( - this is Side_Virtual. Side_Virtual should receive special arguments.
{
PFunction* calledfunc = (PFunction*)(reg.param + f->NumParam - b)[0].a;
PFunction* callingfunc = (PFunction*)(reg.param + f->NumParam - b)[1].a;
DObject* dobj = (DObject*)(reg.param + f->NumParam - b)[2].a; // this is the self pointer. it should be in, since Side_Virtual functions are always non-static methods.
PClass* selftype = dobj->GetClass();
FScopeBarrier::ValidateCall(calledfunc, callingfunc, selftype);
b -= 2;
}
#endif
FillReturns(reg, f, returns, pc+1, C);
if (call->VarFlags & VARF_Native)
{