diff options
author | David Wrighton <davidwr@microsoft.com> | 2017-10-26 01:55:56 +0300 |
---|---|---|
committer | David Wrighton <davidwr@microsoft.com> | 2017-10-26 01:55:56 +0300 |
commit | 374b9d52ed3775cb4a2a8c4130d534dde4a3d6e7 (patch) | |
tree | 235e5d4eeae9eb6ed3a85703eead84e1dd8c007d /src/System.Private.TypeLoader | |
parent | 935484f5948ec7b34d6bcb7a2e1b6ea126e0a15d (diff) |
NonGenericConstrainedCallDesc incorrect key handling
- NonGenericConstrainedCallDesc.Get produces pointers which are incompatible based on the difference in the directConstrainedCall parameter, but that parameter was not used as part of the key into the global data structure that stored the NonGenericConstrainedCallDesc(s).
- Fix is to use two separate global dictionaries (one for when directConstrainedCall is true, and the other where its not)
[tfs-changeset: 1679215]
Diffstat (limited to 'src/System.Private.TypeLoader')
-rw-r--r-- | src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/ConstrainedCallSupport.cs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/ConstrainedCallSupport.cs b/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/ConstrainedCallSupport.cs index e24353fae..35b1c3b65 100644 --- a/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/ConstrainedCallSupport.cs +++ b/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/ConstrainedCallSupport.cs @@ -113,6 +113,7 @@ namespace Internal.Runtime.TypeLoader private static int s_resolveCallOnReferenceTypeCacheMissFunc; private static LowLevelDictionary<RuntimeTypeHandle, LowLevelList<IntPtr>> s_nonGenericConstrainedCallDescs = new LowLevelDictionary<RuntimeTypeHandle, LowLevelList<IntPtr>>(); + private static LowLevelDictionary<RuntimeTypeHandle, LowLevelList<IntPtr>> s_nonGenericConstrainedCallDescsDirect = new LowLevelDictionary<RuntimeTypeHandle, LowLevelList<IntPtr>>(); public static unsafe IntPtr GetDirectConstrainedCallPtr(RuntimeTypeHandle constraintType, RuntimeTypeHandle constrainedMethodType, int constrainedMethodSlot) { @@ -139,14 +140,16 @@ namespace Internal.Runtime.TypeLoader public static unsafe IntPtr Get(RuntimeTypeHandle constraintType, RuntimeTypeHandle constrainedMethodType, int constrainedMethodSlot, bool directConstrainedCall = false) { - lock (s_nonGenericConstrainedCallDescs) + LowLevelDictionary<RuntimeTypeHandle, LowLevelList<IntPtr>> nonGenericConstrainedCallDescsDirect = directConstrainedCall ? s_nonGenericConstrainedCallDescsDirect : s_nonGenericConstrainedCallDescs; + + lock (nonGenericConstrainedCallDescsDirect) { // Get list of constrained call descs associated with a given type LowLevelList<IntPtr> associatedCallDescs; - if (!s_nonGenericConstrainedCallDescs.TryGetValue(constraintType, out associatedCallDescs)) + if (!nonGenericConstrainedCallDescsDirect.TryGetValue(constraintType, out associatedCallDescs)) { associatedCallDescs = new LowLevelList<IntPtr>(); - s_nonGenericConstrainedCallDescs.Add(constraintType, associatedCallDescs); + nonGenericConstrainedCallDescsDirect.Add(constraintType, associatedCallDescs); } // Perform linear scan of associated call descs to see if one matches |