diff options
author | David Wrighton <davidwr@microsoft.com> | 2017-05-26 02:53:58 +0300 |
---|---|---|
committer | David Wrighton <davidwr@microsoft.com> | 2017-05-26 02:53:58 +0300 |
commit | dd2b395c6db670fd2a7a33abfa7e05d12994069c (patch) | |
tree | 9cf097dbf5a54e95399869532eab5a91c6dab466 /src/System.Private.Reflection.Execution | |
parent | e2192561f23d1b98627e00403eb75516342da75d (diff) |
Add support for Open instance delegate on valuetype methods
- Generalize the ability to get an non-unboxing function pointer from an unboxing stub function pointer from being part of constrainedcall support to being general purpose.
- Add path thru OpenMethodResolver which uses the above generalization
- Adjust parameter checking around delegate construction from a MethodInfo to be correct in this case
- Tweak calling convention converter to avoid asserts that would fire in this case, and to use the value in the ref parameter directly.
- A minor refactoring of CallingConventions.cs to make TypeHandle creation involving byref EETypes correct, and to provide an external to typeloader api which can express if a type is to be returned via a retbuffer. This change is not used in the current code, but the factoring appears to be an improvement
[tfs-changeset: 1659735]
Diffstat (limited to 'src/System.Private.Reflection.Execution')
2 files changed, 12 insertions, 2 deletions
diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/MethodInvokers/InstanceMethodInvoker.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/MethodInvokers/InstanceMethodInvoker.cs index 9d8f1a123..208ca22fe 100644 --- a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/MethodInvokers/InstanceMethodInvoker.cs +++ b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/MethodInvokers/InstanceMethodInvoker.cs @@ -50,9 +50,19 @@ namespace Internal.Reflection.Execution.MethodInvokers { if (isOpen) { + MethodInfo methodInfo = (MethodInfo)MethodInvokeInfo.MethodInfo; + + short resolveType = OpenMethodResolver.OpenNonVirtualResolve; + + if (methodInfo.DeclaringType.IsValueType && !methodInfo.IsStatic) + { + // Open instance method for valuetype + resolveType = OpenMethodResolver.OpenNonVirtualResolveLookthruUnboxing; + } + return RuntimeAugments.CreateDelegate( delegateType, - new OpenMethodResolver(_declaringTypeHandle, MethodInvokeInfo.LdFtnResult, default(GCHandle), 0).ToIntPtr(), + new OpenMethodResolver(_declaringTypeHandle, MethodInvokeInfo.LdFtnResult, default(GCHandle), 0, resolveType).ToIntPtr(), target, isStatic: isStatic, isOpen: isOpen); diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs index 5f2d2c4e2..eccf479f6 100644 --- a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs +++ b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs @@ -40,7 +40,7 @@ namespace Internal.Reflection.Extensions.NonPortable if (isOpenResolver) { OpenMethodResolver* resolver = (OpenMethodResolver*)originalLdFtnResult; - if (resolver->ResolverType == OpenMethodResolver.OpenNonVirtualResolve) + if (resolver->IsOpenNonVirtualResolve) { originalLdFtnResult = resolver->CodePointer; // And go on to do normal ldftn processing. |