From 693fff99049bc7d63459b2c444237ca532036b47 Mon Sep 17 00:00:00 2001 From: Fadi Hanna Date: Wed, 3 Aug 2016 18:00:49 -0700 Subject: 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. --- src/vm/genericdict.cpp | 52 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 19 deletions(-) (limited to 'src/vm/genericdict.cpp') 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; } -- cgit v1.2.3