diff options
author | Yi Zhang <yzha@microsoft.com> | 2016-05-18 23:05:53 -0700 |
---|---|---|
committer | Yi Zhang <yzha@microsoft.com> | 2016-05-19 15:44:36 -0700 |
commit | aa08b53d25088dd9c2b7c9a8aa483b413906c7d4 (patch) | |
tree | 5853f6e09387551b36231ec34081b77a044ca0a7 /src/mscorlib | |
parent | e78338ef715dc6fd89d9cbd0bf93c7f88d211c20 (diff) | |
download | coreclr-aa08b53d25088dd9c2b7c9a8aa483b413906c7d4.tar.gz coreclr-aa08b53d25088dd9c2b7c9a8aa483b413906c7d4.tar.bz2 coreclr-aa08b53d25088dd9c2b7c9a8aa483b413906c7d4.zip |
Fix x86 only ICastable feature bug.
When we call ICastable.IsInstanceOfInterface, we treat RuntimeTypeHandle as a OBJECTREF, which is incorrect as-per x86 calling convention since RuntimeTypehandle is a struct that contains a RuntimeType ref field and needs to be passed in stack. Our VM simple call helpers CALL_MANAGED_METHOD doesn't handle this correctly (it does the simple thing that always assume all the arguments are passed in register first). I'm fixing this by using a static method that takes RuntimeType instead of RuntimeTypeHandle, then convert it to RuntimeTypehandle.
Also switch to use PREPARE_NONVIRTUAL_CALLSITE(METHODID) as per Jan's suggestion.
ICastable test is now enabled in x86 for both JITs.
Diffstat (limited to 'src/mscorlib')
-rw-r--r-- | src/mscorlib/model.CoreLib.xml | 4 | ||||
-rw-r--r-- | src/mscorlib/model.xml | 4 | ||||
-rw-r--r-- | src/mscorlib/src/System/Runtime/CompilerServices/ICastable.cs | 18 |
3 files changed, 26 insertions, 0 deletions
diff --git a/src/mscorlib/model.CoreLib.xml b/src/mscorlib/model.CoreLib.xml index 6ea5768f28..114b4505e6 100644 --- a/src/mscorlib/model.CoreLib.xml +++ b/src/mscorlib/model.CoreLib.xml @@ -5539,6 +5539,10 @@ <Member Name="IsInstanceOfInterface(System.RuntimeTypeHandle,System.Exception@)" /> <!-- EE --> <Member Name="GetImplType(System.RuntimeTypeHandle)" /> <!-- EE --> </Type> + <Type Name="System.Runtime.CompilerServices.ICastableHelpers"> + <Member Name="IsInstanceOfInterface(System.Runtime.CompilerServices.ICastable,System.RuntimeType,System.Exception@)" /> <!-- EE --> + <Member Name="GetImplType(System.Runtime.CompilerServices.ICastable,System.RuntimeType)" /> <!-- EE --> + </Type> <Type Name="System.Runtime.CompilerServices.IsExplicitlyDereferenced"> <!-- for MC++ --> </Type> <Type Name="System.Runtime.CompilerServices.IsImplicitlyDereferenced"> <!-- for MC++ --> diff --git a/src/mscorlib/model.xml b/src/mscorlib/model.xml index ef2774a9f3..671da7e1dd 100644 --- a/src/mscorlib/model.xml +++ b/src/mscorlib/model.xml @@ -5539,6 +5539,10 @@ <Member Name="IsInstanceOfInterface(System.RuntimeTypeHandle,System.Exception@)" /> <!-- EE --> <Member Name="GetImplType(System.RuntimeTypeHandle)" /> <!-- EE --> </Type> + <Type Name="System.Runtime.CompilerServices.ICastableHelpers"> + <Member Name="IsInstanceOfInterface(System.Runtime.CompilerServices.ICastable,System.RuntimeType, System.Exception@)" /> <!-- EE --> + <Member Name="GetImplType(System.Runtime.CompilerServices.ICastable,System.RuntimeType)" /> <!-- EE --> + </Type> <Type Name="System.Runtime.CompilerServices.IsExplicitlyDereferenced"> <!-- for MC++ --> </Type> <Type Name="System.Runtime.CompilerServices.IsImplicitlyDereferenced"> <!-- for MC++ --> diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/ICastable.cs b/src/mscorlib/src/System/Runtime/CompilerServices/ICastable.cs index bd04647332..7ba9434575 100644 --- a/src/mscorlib/src/System/Runtime/CompilerServices/ICastable.cs +++ b/src/mscorlib/src/System/Runtime/CompilerServices/ICastable.cs @@ -61,4 +61,22 @@ namespace System.Runtime.CompilerServices // IsInstanceOfInterface. RuntimeTypeHandle GetImplType(RuntimeTypeHandle interfaceType); } + + /// <summary> + /// Helpers that allows VM to call into ICastable methods without having to deal with RuntimeTypeHandle. + /// RuntimeTypeHandle is a struct and is always passed in stack in x86, which our VM call helpers don't + /// particularly like. + /// </summary> + class ICastableHelpers + { + internal static bool IsInstanceOfInterface(ICastable castable, RuntimeType type, out Exception castError) + { + return castable.IsInstanceOfInterface(new RuntimeTypeHandle(type), out castError); + } + + internal static RuntimeType GetImplType(ICastable castable, RuntimeType interfaceType) + { + return castable.GetImplType(new RuntimeTypeHandle(interfaceType)).GetRuntimeType(); + } + } } |