diff options
author | Fadi Hanna <fadim@microsoft.com> | 2016-08-03 18:00:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-03 18:00:49 -0700 |
commit | 693fff99049bc7d63459b2c444237ca532036b47 (patch) | |
tree | b6c9b7fdc517276f1480f6a9deb23c506ffc8fdd /src/vm/genericdict.cpp | |
parent | d18ddfda61efdfe4521d2dce816fa01021bf26a8 (diff) | |
download | coreclr-693fff99049bc7d63459b2c444237ca532036b47.tar.gz coreclr-693fff99049bc7d63459b2c444237ca532036b47.tar.bz2 coreclr-693fff99049bc7d63459b2c444237ca532036b47.zip |
Adding Support for FieldDescSlot generic dictionary entries for R2R generic code. (#6200)
This enables generic code with ldtoken instructions for fields on generic types to be compiled into R2R.
This change makes newer versions of the runtime compatible with older version R2R images,
but not vice-versa. Therefore, the major version is increased to 2 with this change.
This change adds more encodings to a R2R image without changing the format of any previously encoded
entity, and is backwards compatible.
Diffstat (limited to 'src/vm/genericdict.cpp')
-rw-r--r-- | src/vm/genericdict.cpp | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/src/vm/genericdict.cpp b/src/vm/genericdict.cpp index 70a4b8a627..4aca9e140b 100644 --- a/src/vm/genericdict.cpp +++ b/src/vm/genericdict.cpp @@ -690,6 +690,7 @@ Dictionary::PopulateEntry( switch (signatureKind) { case ENCODE_TYPE_HANDLE: kind = TypeHandleSlot; break; + case ENCODE_FIELD_HANDLE: kind = FieldDescSlot; break; case ENCODE_METHOD_HANDLE: kind = MethodDescSlot; break; case ENCODE_METHOD_ENTRY: kind = MethodEntrySlot; break; case ENCODE_VIRTUAL_ENTRY: kind = DispatchStubAddrSlot; break; @@ -1124,30 +1125,43 @@ Dictionary::PopulateEntry( case FieldDescSlot: { - TypeHandle th = ptr.GetTypeHandleThrowing( - pLookupModule, - &typeContext, - (nonExpansive ? ClassLoader::DontLoadTypes : ClassLoader::LoadTypes), - CLASS_LOADED, - FALSE, - NULL, - pZapSigContext); - if (th.IsNull()) + TypeHandle ownerType; + + if (isReadyToRunModule) { - _ASSERTE(nonExpansive); - return NULL; + FieldDesc* pField = ZapSig::DecodeField((Module*)pZapSigContext->pModuleContext, pZapSigContext->pInfoModule, ptr.GetPtr(), &typeContext, &ownerType); + _ASSERTE(!ownerType.IsNull()); + + if (!IsCompilationProcess()) + ownerType.AsMethodTable()->EnsureInstanceActive(); + + result = (CORINFO_GENERIC_HANDLE)pField; } - IfFailThrow(ptr.SkipExactlyOne()); + else + { + ownerType = ptr.GetTypeHandleThrowing( + pLookupModule, + &typeContext, + (nonExpansive ? ClassLoader::DontLoadTypes : ClassLoader::LoadTypes), + CLASS_LOADED, + FALSE, + NULL, + pZapSigContext); + if (ownerType.IsNull()) + { + _ASSERTE(nonExpansive); + return NULL; + } + IfFailThrow(ptr.SkipExactlyOne()); - DWORD fieldIndex; - IfFailThrow(ptr.GetData(&fieldIndex)); + DWORD fieldIndex; + IfFailThrow(ptr.GetData(&fieldIndex)); - if (!IsCompilationProcess()) - { - th.AsMethodTable()->EnsureInstanceActive(); - } + if (!IsCompilationProcess()) + ownerType.AsMethodTable()->EnsureInstanceActive(); - result = (CORINFO_GENERIC_HANDLE)th.AsMethodTable()->GetFieldDescByIndex(fieldIndex); + result = (CORINFO_GENERIC_HANDLE)ownerType.AsMethodTable()->GetFieldDescByIndex(fieldIndex); + } break; } |