diff options
author | dotnet-bot <dotnet-bot@microsoft.com> | 2017-08-29 21:09:17 +0300 |
---|---|---|
committer | dotnet-bot <dotnet-bot@microsoft.com> | 2017-08-29 21:09:17 +0300 |
commit | d1b6380ebc6537d5894a3a006a894f5aebf28a68 (patch) | |
tree | e660c8dc12dd651a1f566c413358f8ad57f60625 /src/System.Private.TypeLoader | |
parent | c858c8cea81407585cd1da140d96833ca6ccc87b (diff) |
ProjectX: Enable dynamic construction of the floating generic dictionary
Changes include
1.The type loader API change to specific which base class's dictionary needs to be updated
2. Codegen work for calling the API
3. Specifying the image section for dictionary node
4. Fixing a bug in the symbol creating of tls_index
[tfs-changeset: 1672150]
Diffstat (limited to 'src/System.Private.TypeLoader')
-rw-r--r-- | src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.cs | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.cs b/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.cs index 5585980d9..00015f164 100644 --- a/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.cs +++ b/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.cs @@ -86,9 +86,9 @@ namespace Internal.Runtime.TypeLoader return TypeLoaderEnvironment.Instance.TryGetArrayTypeForElementType(elementTypeHandle, isMdArray, rank, out arrayTypeHandle); } - public override IntPtr UpdateFloatingDictionary(IntPtr context, bool isTypeContext) + public override IntPtr UpdateFloatingDictionary(IntPtr context, IntPtr dictionaryPtr) { - return TypeLoaderEnvironment.Instance.UpdateFloatingDictionary(context, isTypeContext); + return TypeLoaderEnvironment.Instance.UpdateFloatingDictionary(context, dictionaryPtr); } public override IEnumerable<TypeManagerHandle> GetLoadedModules() @@ -525,21 +525,31 @@ namespace Internal.Runtime.TypeLoader } } - public unsafe IntPtr UpdateFloatingDictionary(IntPtr context, bool isTypeContext) + public unsafe IntPtr UpdateFloatingDictionary(IntPtr context, IntPtr dictionaryPtr) { - IntPtr dictionaryPtr; + IntPtr newFloatingDictionary; + bool isNewlyAllocatedDictionary; + bool isTypeContext = context != dictionaryPtr; + if (isTypeContext) { EEType* pEEType = (EEType*)context.ToPointer(); - dictionaryPtr = EETypeCreator.GetDictionary(pEEType); - } - else - { - dictionaryPtr = context; + IntPtr curDictPtr = EETypeCreator.GetDictionary(pEEType); + + // Look for the exact base type that owns the dictionary. We may be having + // a virtual method run on a derived type and the generic lookup are performed + // on the base type's dictionary. + while (curDictPtr != dictionaryPtr) + { + pEEType = pEEType->BaseType; + Debug.Assert(pEEType != null); + curDictPtr = EETypeCreator.GetDictionary(pEEType); + Debug.Assert(curDictPtr != IntPtr.Zero); + } + + context = (IntPtr)pEEType; } - IntPtr newFloatingDictionary; - bool isNewlyAllocatedDictionary; using (LockHolder.Hold(_typeLoaderLock)) { // Check if some other thread already allocated a floating dictionary and updated the fixed portion |