protected override void WriteImplByRef(ref Object location, Object value, int mask) { CMSMarking.ReferenceCheck(ref location, value, mask); location = value; }
protected override void WriteImpl(UIntPtr *location, Object value, int mask) { CMSMarking.ReferenceCheck(location, value, mask); *location = Magic.addressOf(value); }
protected override Object AtomicCompareAndSwapImpl(ref Object loc, Object newVal, Object comp, int mask) { CMSMarking.ReferenceCheck(ref loc, newVal, 0); newVal = ForwardNullable(newVal); for (;;) { Object oldVal = loc; Object commitVal; if (oldVal == comp || ForwardNullable(oldVal) == ForwardNullable(comp)) { commitVal = newVal; } else { // still CAS but only to get a memory barrier commitVal = oldVal; } if (Interlocked.CompareExchange(ref loc, commitVal, oldVal) == oldVal) { return(oldVal); } } }
internal static void Mark(UIntPtr ptr) { if (CMSMarking.MarkIfNecessary(ptr) && fVerifyToSpaceMark && ptr != UIntPtr.Zero && !instance.IsInToSpace(ptr)) { VTable.DebugBreak(); } }
protected override Object AtomicSwapImpl(ref Object reference, Object value, int mask) { CMSMarking.ReferenceCheck(ref reference, value, mask); UIntPtr resultAddr = Interlocked.Exchange(Magic.toPointer(ref reference), Magic.addressOf(value)); return(Magic.fromAddress(resultAddr)); }
Object AtomicCompareAndSwapImpl(ref Object reference, Object newValue, Object comparand, int mask) { CMSMarking.ReferenceCheck(ref reference, newValue, mask); UIntPtr resultAddr = Interlocked.CompareExchange(Magic.toPointer(ref reference), Magic.addressOf(newValue), Magic.addressOf(comparand)); return(Magic.fromAddress(resultAddr)); }