@@ -2596,7 +2596,7 @@ BOOL COMDelegate::NeedsWrapperDelegate(MethodDesc* pTargetMD)
2596
2596
#ifdef _TARGET_ARM_
2597
2597
// For arm VSD expects r4 to contain the indirection cell. However r4 is a non-volatile register
2598
2598
// and its value must be preserved. So we need to erect a frame and store indirection cell in r4 before calling
2599
- // virtual stub dispatch. Erecting frame is already done by secure delegates so the secureDelegate infrastructure
2599
+ // virtual stub dispatch. Erecting frame is already done by secure delegates so the secureDelegate infrastructure
2600
2600
// can easliy be used for our purpose.
2601
2601
// set needsSecureDelegate flag in order to erect a frame. (Secure Delegate stub also loads the right value in r4)
2602
2602
if (!pTargetMD->IsStatic() && pTargetMD->IsVirtual() && !pTargetMD->GetMethodTable()->IsValueType())
@@ -2931,7 +2931,47 @@ PCODE COMDelegate::GetSecureInvoke(MethodDesc* pMD)
2931
2931
#ifdef FEATURE_CAS_POLICY
2932
2932
#error GetSecureInvoke not implemented
2933
2933
#else
2934
- UNREACHABLE();
2934
+ GCX_PREEMP();
2935
+
2936
+ MetaSig sig(pMD);
2937
+
2938
+ BOOL fReturnVal = !sig.IsReturnTypeVoid();
2939
+
2940
+ SigTypeContext emptyContext;
2941
+ ILStubLinker sl(pMD->GetModule(), pMD->GetSignature(), &emptyContext, pMD, TRUE, TRUE, FALSE);
2942
+
2943
+ ILCodeStream *pCode = sl.NewCodeStream(ILStubLinker::kDispatch);
2944
+
2945
+ // Load the "real" delegate
2946
+ pCode->EmitLoadThis();
2947
+ pCode->EmitLDFLD(pCode->GetToken(MscorlibBinder::GetField(FIELD__MULTICAST_DELEGATE__INVOCATION_LIST)));
2948
+
2949
+ // Load the arguments
2950
+ UINT paramCount = 0;
2951
+ while(paramCount < sig.NumFixedArgs())
2952
+ pCode->EmitLDARG(paramCount++);
2953
+
2954
+ // Call the delegate
2955
+ pCode->EmitCALL(pCode->GetToken(pMD), sig.NumFixedArgs(), fReturnVal);
2956
+
2957
+ // Return
2958
+ pCode->EmitRET();
2959
+
2960
+ PCCOR_SIGNATURE pSig;
2961
+ DWORD cbSig;
2962
+
2963
+ pMD->GetSig(&pSig,&cbSig);
2964
+
2965
+ MethodDesc* pStubMD =
2966
+ ILStubCache::CreateAndLinkNewILStubMethodDesc(pMD->GetLoaderAllocator(),
2967
+ pMD->GetMethodTable(),
2968
+ ILSTUB_SECUREDELEGATE_INVOKE,
2969
+ pMD->GetModule(),
2970
+ pSig, cbSig,
2971
+ NULL,
2972
+ &sl);
2973
+
2974
+ return Stub::NewStub(JitILStub(pStubMD))->GetEntryPoint();
2935
2975
#endif
2936
2976
}
2937
2977
#else // FEATURE_STUBS_AS_IL
0 commit comments