diff options
author | Fadi Hanna <fadim@microsoft.com> | 2017-07-27 03:57:26 +0300 |
---|---|---|
committer | Fadi Hanna <fadim@microsoft.com> | 2017-07-27 03:57:26 +0300 |
commit | 47220f754b3f07e85972c64c7f6392798d9b039f (patch) | |
tree | ededfd9230e0cd3d046dbe07b69c11146da28143 /src/System.Private.TypeLoader | |
parent | ab0c3c080ce646d9f4d38b927ad5ad83651c4c94 (diff) |
Delegate construction wasn't correctly working for all cases in USG code:
1) fixed calls to non-generic instance methods on structs to correctly use the unboxing stub
2) fixed calls to generic instance methods on structs to correctly unbox the thisPtr
3) fixed calls to non-generic instance methods on USG classes that do not require an instantiating argument (we were using a fat function pointer with a null dictionary component)
[tfs-changeset: 1668066]
Diffstat (limited to 'src/System.Private.TypeLoader')
2 files changed, 17 insertions, 5 deletions
diff --git a/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/CallConverterThunk.CallConversionInfo.cs b/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/CallConverterThunk.CallConversionInfo.cs index f28cae038..f76d0d2f6 100644 --- a/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/CallConverterThunk.CallConversionInfo.cs +++ b/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/CallConverterThunk.CallConversionInfo.cs @@ -66,6 +66,8 @@ namespace Internal.Runtime.TypeLoader case ThunkKind.StandardToStandardInstantiating: return "StandardToStandardInstantiating"; case ThunkKind.StandardToGenericInstantiating: return "StandardToGenericInstantiating"; case ThunkKind.StandardToGenericInstantiatingIfNotHasThis: return "StandardToGenericInstantiatingIfNotHasThis"; + case ThunkKind.StandardToGenericPassthruInstantiating: return "StandardToGenericPassthruInstantiating"; + case ThunkKind.StandardToGenericPassthruInstantiatingIfNotHasThis: return "StandardToGenericPassthruInstantiatingIfNotHasThis"; case ThunkKind.StandardToGeneric: return "StandardToGeneric"; case ThunkKind.GenericToStandard: return "GenericToStandard"; case ThunkKind.StandardUnboxing: return "StandardUnboxing"; diff --git a/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/genericdictionarycell.cs b/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/genericdictionarycell.cs index afe6066c7..05b4daaf3 100644 --- a/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/genericdictionarycell.cs +++ b/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/genericdictionarycell.cs @@ -712,7 +712,7 @@ namespace Internal.Runtime.TypeLoader } case TypeLoaderEnvironment.MethodAddressType.UniversalCanonical: { - if (Method.IsCanonicalMethod(CanonicalFormKind.Specific) && + if (Method.IsCanonicalMethod(CanonicalFormKind.Universal) && !NeedsDictionaryParameterToCallCanonicalVersion(Method) && !UniversalGenericParameterLayout.MethodSignatureHasVarsNeedingCallingConventionConverter( Method.GetTypicalMethodDefinition().Signature)) @@ -870,15 +870,25 @@ namespace Internal.Runtime.TypeLoader Debug.Assert(!MethodSignature.IsNativeLayoutSignature || (MethodSignature.NativeLayoutSignature() != IntPtr.Zero)); - CallConverterThunk.ThunkKind thunkKind; + CallConverterThunk.ThunkKind thunkKind = default(CallConverterThunk.ThunkKind); if (usgConverter) { if (genericMethod || containingTypeIsValueType) { - if (dictionary == IntPtr.Zero) - thunkKind = CallConverterThunk.ThunkKind.StandardToGenericPassthruInstantiating; + if (Method.UnboxingStub) + { + if (dictionary == IntPtr.Zero) + Environment.FailFast("Need standard to generic non-instantiating unboxing stub thunk kind"); + else + thunkKind = CallConverterThunk.ThunkKind.StandardUnboxingAndInstantiatingGeneric; + } else - thunkKind = CallConverterThunk.ThunkKind.StandardToGenericInstantiating; + { + if (dictionary == IntPtr.Zero) + thunkKind = CallConverterThunk.ThunkKind.StandardToGenericPassthruInstantiating; + else + thunkKind = CallConverterThunk.ThunkKind.StandardToGenericInstantiating; + } } else { |