2008-11-17 18:29:00 -05:00
|
|
|
//
|
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2008-03-05 09:52:00 -05:00
|
|
|
/*******************************************************************/
|
|
|
|
/* WARNING */
|
|
|
|
/* This file should be identical in the Bartok and Singularity */
|
|
|
|
/* depots. Master copy resides in Bartok Depot. Changes should be */
|
|
|
|
/* made to Bartok Depot and propagated to Singularity Depot. */
|
|
|
|
/*******************************************************************/
|
|
|
|
|
|
|
|
namespace System.GCs {
|
|
|
|
|
|
|
|
using Microsoft.Bartok.Runtime;
|
|
|
|
using System.Runtime.CompilerServices;
|
2008-11-17 18:29:00 -05:00
|
|
|
using System.Threading;
|
2008-03-05 09:52:00 -05:00
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
//[NoBarriers]
|
|
|
|
internal unsafe class EmptyWriteBarrier : RefWriteBarrier
|
2008-03-05 09:52:00 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
internal static EmptyWriteBarrier instance;
|
2008-11-17 18:29:00 -05:00
|
|
|
|
|
|
|
[NoBarriers]
|
2008-03-05 09:52:00 -05:00
|
|
|
internal static new void Initialize() {
|
|
|
|
EmptyWriteBarrier.instance = (EmptyWriteBarrier)
|
|
|
|
BootstrapMemory.Allocate(typeof(EmptyWriteBarrier));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Inline]
|
2008-11-17 18:29:00 -05:00
|
|
|
protected override void CopyStructImpl(Object srcObj,
|
|
|
|
Object dstObj,
|
|
|
|
VTable vtable,
|
2008-03-05 09:52:00 -05:00
|
|
|
UIntPtr srcPtr,
|
|
|
|
UIntPtr dstPtr)
|
|
|
|
{
|
|
|
|
CopyStructNoBarrier(vtable, srcPtr, dstPtr);
|
|
|
|
}
|
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
[NoBarriers]
|
2008-03-05 09:52:00 -05:00
|
|
|
[Inline]
|
|
|
|
protected override Object AtomicSwapImpl(ref Object reference,
|
2008-11-17 18:29:00 -05:00
|
|
|
Object value,
|
|
|
|
int mask)
|
2008-03-05 09:52:00 -05:00
|
|
|
{
|
2008-11-17 18:29:00 -05:00
|
|
|
return Interlocked.Exchange(ref reference, value);
|
2008-03-05 09:52:00 -05:00
|
|
|
}
|
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
[NoBarriers]
|
2008-03-05 09:52:00 -05:00
|
|
|
[Inline]
|
|
|
|
protected override
|
|
|
|
Object AtomicCompareAndSwapImpl(ref Object reference,
|
|
|
|
Object newValue,
|
2008-11-17 18:29:00 -05:00
|
|
|
Object comparand,
|
|
|
|
int mask)
|
2008-03-05 09:52:00 -05:00
|
|
|
{
|
2008-11-17 18:29:00 -05:00
|
|
|
return Interlocked.CompareExchange(ref reference,
|
|
|
|
newValue,
|
|
|
|
comparand);
|
2008-03-05 09:52:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
[Inline]
|
|
|
|
protected override void CloneImpl(Object srcObject, Object dstObject)
|
|
|
|
{
|
|
|
|
CloneNoBarrier(srcObject, dstObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 'offset' is not relative to the lower bound, but is a count
|
|
|
|
// of elements from the first element in the array.
|
|
|
|
[Inline]
|
|
|
|
protected override void ArrayZeroImpl(Array array,
|
|
|
|
int offset,
|
|
|
|
int length)
|
|
|
|
{
|
|
|
|
ArrayZeroNoBarrier(array, offset, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 'offset' is not relative to the lower bound, but is a count
|
|
|
|
// of elements from the first element in the array.
|
|
|
|
[Inline]
|
|
|
|
protected override void ArrayCopyImpl(Array srcArray, int srcOffset,
|
|
|
|
Array dstArray, int dstOffset,
|
|
|
|
int length)
|
|
|
|
{
|
|
|
|
ArrayCopyNoBarrier(srcArray, srcOffset,
|
|
|
|
dstArray, dstOffset,
|
|
|
|
length);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Inline]
|
2008-11-17 18:29:00 -05:00
|
|
|
protected override void WriteImpl(UIntPtr *location,
|
|
|
|
Object value,
|
|
|
|
int mask)
|
2008-03-05 09:52:00 -05:00
|
|
|
{
|
|
|
|
*location = Magic.addressOf(value);
|
|
|
|
}
|
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
[Inline]
|
|
|
|
[NoBarriers]
|
|
|
|
protected override void WriteImplByRef(ref Object location,
|
|
|
|
Object value,
|
|
|
|
int mask)
|
|
|
|
{
|
|
|
|
location = value;
|
|
|
|
}
|
|
|
|
|
2008-03-05 09:52:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|