Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -175,6 +175,45 @@ namespace System.Runtime.CompilerServices
data = tmp;
}
// the whole method is just a copy of `public void Add (TKey key, TValue value)`
// the only difference it doesn't throw exceptions if the given key exists
// both methods will be merged once a wierd issue (broken acceptence test dev10_535767.cs) is resolved
public void AddOrUpdate (TKey key, TValue value)
{
if (key == default (TKey))
throw new ArgumentNullException ("Null key", "key");
lock (_lock) {
if (size >= data.Length * LOAD_FACTOR)
Rehash ();
int len = data.Length;
int idx,initial_idx;
int free_slot = -1;
idx = initial_idx = (RuntimeHelpers.GetHashCode (key) & int.MaxValue) % len;
do {
object k = data [idx].key;
if (k == null) {
if (free_slot == -1)
free_slot = idx;
break;
} else if (k == GC.EPHEMERON_TOMBSTONE && free_slot == -1) { //Add requires us to check for dupes :(
free_slot = idx;
} else if (k == key) {
free_slot = idx;
}
if (++idx == len) //Wrap around
idx = 0;
} while (idx != initial_idx);
data [free_slot].key = key;
data [free_slot].value = value;
++size;
}
}
public void Add (TKey key, TValue value)
{
@@ -199,7 +238,7 @@ namespace System.Runtime.CompilerServices
break;
} else if (k == GC.EPHEMERON_TOMBSTONE && free_slot == -1) { //Add requires us to check for dupes :(
free_slot = idx;
} else if (k == key) {
} else if (k == key) {
throw new ArgumentException ("Key already in the list", "key");
}
@@ -295,8 +334,10 @@ namespace System.Runtime.CompilerServices
// if you know for sure that either you won't run into dead locks or you need to live with the
// possiblity
//--------------------------------------------------------------------------------------------
#if !MONO
[System.Security.SecuritySafeCritical]
[FriendAccessAllowed]
#endif
internal TKey FindEquivalentKeyUnsafe(TKey key, out TValue value)
{
lock (_lock)
@@ -320,7 +361,7 @@ namespace System.Runtime.CompilerServices
// Clear all the key/value pairs
//--------------------------------------------------------------------------------------------
[System.Security.SecuritySafeCritical]
internal void Clear()
public void Clear()
{
lock (_lock)
{

View File

@@ -28,13 +28,14 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Runtime.ConstrainedExecution;
using System.Reflection;
namespace System.Runtime.CompilerServices
{
public static class RuntimeHelpers
public static partial class RuntimeHelpers
{
public delegate void TryCode (Object userData);
@@ -105,24 +106,24 @@ namespace System.Runtime.CompilerServices
return SufficientExecutionStack ();
}
[MonoTODO("Currently a no-op")]
// [MonoTODO("Currently a no-op")]
public static void ExecuteCodeWithGuaranteedCleanup (TryCode code, CleanupCode backoutCode, Object userData)
{
}
[MonoTODO("Currently a no-op")]
// [MonoTODO("Currently a no-op")]
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
public static void PrepareConstrainedRegions ()
{
}
[MonoTODO("Currently a no-op")]
// [MonoTODO("Currently a no-op")]
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
public static void PrepareConstrainedRegionsNoOP ()
{
}
[MonoTODO("Currently a no-op")]
// [MonoTODO("Currently a no-op")]
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
public static void ProbeForSufficientStack()
{
@@ -138,7 +139,7 @@ namespace System.Runtime.CompilerServices
// then adds that combination to e.g. AppDomain.DomainUnload, then the client is responsible
// for his own preparation.
[System.Security.SecurityCritical] // auto-generated_required
[MonoTODO("Currently a no-op")]
// [MonoTODO("Currently a no-op")]
public static void PrepareDelegate (Delegate d)
{
}
@@ -156,18 +157,17 @@ namespace System.Runtime.CompilerServices
// NOTE: that for the NGen case you can sidestep the required ReliabilityContract
// by using the [PrePrepareMethod] attribute.
[System.Security.SecurityCritical] // auto-generated_required
[ResourceExposure(ResourceScope.None)]
[MonoTODO("Currently a no-op")]
// [MonoTODO("Currently a no-op")]
public static void PrepareContractedDelegate(Delegate d)
{
}
[MonoTODO("Currently a no-op")]
// [MonoTODO("Currently a no-op")]
public static void PrepareMethod (RuntimeMethodHandle method)
{
}
[MonoTODO("Currently a no-op")]
// [MonoTODO("Currently a no-op")]
public static void PrepareMethod (RuntimeMethodHandle method, RuntimeTypeHandle[] instantiation)
{
}
@@ -188,5 +188,12 @@ namespace System.Runtime.CompilerServices
{
return !typeof (T).IsValueType || RuntimeTypeHandle.HasReferences ((typeof (T) as RuntimeType));
}
#if !NETCORE
public static object GetUninitializedObject (Type type)
{
return FormatterServices.GetUninitializedObject (type);
}
#endif
}
}

View File

@@ -36,7 +36,7 @@ using nint = System.Int32;
namespace System.Runtime.CompilerServices
{
static partial class Unsafe
unsafe static partial class Unsafe
{
public static ref T Add<T> (ref T source, int elementOffset)
{
@@ -133,6 +133,11 @@ namespace System.Runtime.CompilerServices
throw new NotImplementedException ();
}
public static void WriteUnaligned<T>(void* destination, T value)
{
throw new NotImplementedException ();
}
public static bool IsAddressGreaterThan<T>(ref T left, ref T right)
{
throw new NotImplementedException ();