diff options
author | Gaurav Khanna <gkhanna@microsoft.com> | 2015-12-17 02:32:35 +0300 |
---|---|---|
committer | Gaurav Khanna <gkhanna@microsoft.com> | 2015-12-17 04:13:43 +0300 |
commit | 2dbbf1417160d50325e099baa9187b87e65dd00c (patch) | |
tree | a062920a7f9ab3ead37eb90d1f51167fd8dcb77f /src/JitInterface | |
parent | 6cf6977b884f47d004972910af4a39e07be2df53 (diff) |
Fix HelloWorld RyuJIT OverflowException
Since Generics context is not yet supported, we were not setting the contextHandle in getCallInfo JITEE interface implementation. Thus, when JIT would get the calling details, it would get a bogus value for contextHandle and later pass on that values to other calls to the JITEE interface. In this case, initClass was being passed the bogus value that it attempted to operate upon assuming its a valid generics context and resulted in OverflowException.
This fix is to compute the contextHandle as expected.
Diffstat (limited to 'src/JitInterface')
-rw-r--r-- | src/JitInterface/src/CorInfoImpl.cs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/JitInterface/src/CorInfoImpl.cs b/src/JitInterface/src/CorInfoImpl.cs index c93f49dc8..4763d526b 100644 --- a/src/JitInterface/src/CorInfoImpl.cs +++ b/src/JitInterface/src/CorInfoImpl.cs @@ -379,6 +379,16 @@ namespace Internal.JitInterface } } + private CORINFO_CONTEXT_STRUCT* contextFromMethod(MethodDesc method) + { + return (CORINFO_CONTEXT_STRUCT*)(((ulong)ObjectToHandle(method)) | (ulong)CorInfoContextFlags.CORINFO_CONTEXTFLAGS_METHOD); + } + + private CORINFO_CONTEXT_STRUCT* contextFromType(TypeDesc type) + { + return (CORINFO_CONTEXT_STRUCT*)(((ulong)ObjectToHandle(type)) | (ulong)CorInfoContextFlags.CORINFO_CONTEXTFLAGS_CLASS); + } + private MethodDesc methodFromContext(CORINFO_CONTEXT_STRUCT* contextStruct) { if (((ulong)contextStruct & (ulong)CorInfoContextFlags.CORINFO_CONTEXTFLAGS_MASK) == (ulong)CorInfoContextFlags.CORINFO_CONTEXTFLAGS_CLASS) @@ -1843,9 +1853,17 @@ namespace Internal.JitInterface pResult.kind = CORINFO_CALL_KIND.CORINFO_CALL; pResult._nullInstanceCheck = (uint)(((flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_CALLVIRT) != 0) ? 1 : 0); - // TODO: Generics - // pResult.contextHandle; - // pResult._exactContextNeedsRuntimeLookup + // TODO: Support Generics + if (targetMethod.HasInstantiation) + { + pResult.contextHandle = contextFromMethod(targetMethod); + } + else + { + pResult.contextHandle = contextFromType(targetMethod.OwningType); + } + + pResult._exactContextNeedsRuntimeLookup = 0; // TODO: CORINFO_VIRTUALCALL_STUB // TODO: CORINFO_CALL_CODE_POINTER |