From 0176c29ec29901c8f3f3bb9c30bdb3544abacb51 Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Sun, 12 Mar 2017 12:03:41 +0200 Subject: [PATCH] Will not emit OP_SCOPE if self type can be checked at compile time. --- src/scripting/backend/codegen.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index 76414e2353..0ea6517da1 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -8815,8 +8815,12 @@ ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build) if (outerside == FScopeBarrier::Side_Virtual) outerside = FScopeBarrier::SideFromObjectFlags(CallingFunction->OwningClass->ObjectFlags); - // Check the self object against the calling function's flags at run time - build->Emit(OP_SCOPE, selfemit.RegNum, outerside + 1, build->GetConstantAddress(vmfunc, ATAG_OBJECT)); + // [ZZ] only emit if target side cannot be checked at compile time. + if (selfside == FScopeBarrier::Side_PlainData) + { + // Check the self object against the calling function's flags at run time + build->Emit(OP_SCOPE, selfemit.RegNum, outerside + 1, build->GetConstantAddress(vmfunc, ATAG_OBJECT)); + } } if (selfemit.Fixed && selfemit.Target)