Imported Upstream version 6.8.0.73

Former-commit-id: d18deab1b47cfd3ad8cba82b3f37d00eec2170af
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-12-10 18:00:56 +00:00
parent bceda29824
commit 73ee7591e8
1043 changed files with 16271 additions and 22080 deletions

View File

@ -48,9 +48,29 @@ namespace System.Threading
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static int CompareExchange(ref int location1, int value, int comparand, ref bool succeeded);
[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static object CompareExchange(ref object location1, object value, object comparand);
extern static void CompareExchange (ref object location1, ref object value, ref object comparand, ref object result);
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
public static object CompareExchange (ref object location1, object value, object comparand)
{
// This avoids coop handles, esp. on the output which would be particularly inefficient.
// Passing everything by ref is equivalent to coop handles -- ref to locals at least.
//
// location1's treatment is unclear. But note that passing it by handle would be incorrect,
// as it would use a local alias, which the coop marshaling does, to avoid the unclarity here,
// that of a ref being to a managed frame vs. a native frame. Perhaps that could be revisited.
//
// So there a hole here, that of calling this function with location1 being in a native frame.
// Usually it will be to a field, static or not, and not even to managed stack.
//
// This is usually intrinsified. Ideally it is always intrinisified.
//
object result = null;
CompareExchange (ref location1, ref value, ref comparand, ref result);
return result;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static float CompareExchange(ref float location1, float value, float comparand);
@ -74,9 +94,19 @@ namespace System.Threading
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static int Exchange(ref int location1, int value);
[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static object Exchange(ref object location1, object value);
extern static void Exchange (ref object location1, ref object value, ref object result);
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
public static object Exchange (ref object location1, object value)
{
// See CompareExchange(object) for comments.
//
object result = null;
Exchange (ref location1, ref value, ref result);
return result;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static float Exchange(ref float location1, float value);
@ -92,9 +122,29 @@ namespace System.Threading
public extern static double CompareExchange(ref double location1, double value, double comparand);
[ComVisible (false)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
public extern static T CompareExchange<T> (ref T location1, T value, T comparand) where T:class;
[Intrinsic]
public static T CompareExchange<T> (ref T location1, T value, T comparand) where T : class
{
unsafe {
if (Unsafe.AsPointer (ref location1) == null)
throw new NullReferenceException ();
}
// Besides avoiding coop handles for efficiency,
// and correctness, this also appears needed to
// avoid an assertion failure in the runtime, related to
// coop handles over generics.
//
// See CompareExchange(object) for more comments.
//
// This is not entirely convincing due to lack of volatile.
//
T result = null;
// T : class so call the object overload.
CompareExchange (ref Unsafe.As<T, object> (ref location1), ref Unsafe.As<T, object>(ref value), ref Unsafe.As<T, object>(ref comparand), ref Unsafe.As<T, object>(ref result));
return result;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static long Exchange(ref long location1, long value);
@ -107,9 +157,23 @@ namespace System.Threading
public extern static double Exchange(ref double location1, double value);
[ComVisible (false)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
public extern static T Exchange<T> (ref T location1, T value) where T:class;
[Intrinsic]
public static T Exchange<T> (ref T location1, T value) where T : class
{
unsafe {
if (Unsafe.AsPointer (ref location1) == null)
throw new NullReferenceException ();
}
// See CompareExchange(T) for comments.
//
// This is not entirely convincing due to lack of volatile.
//
T result = null;
// T : class so call the object overload.
Exchange (ref Unsafe.As<T, object>(ref location1), ref Unsafe.As<T, object>(ref value), ref Unsafe.As<T, object>(ref result));
return result;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static long Read(ref long location);