diff --git a/CodeGen/AtomWeaverV2.cs b/CodeGen/AtomWeaverV2.cs index 6eda055..b93aa63 100644 --- a/CodeGen/AtomWeaverV2.cs +++ b/CodeGen/AtomWeaverV2.cs @@ -288,7 +288,6 @@ private struct AtomSetterMethodWeaver private PropertyDefinition _property; private Instruction _nullCheckEndInstruction; - private Instruction _preReturnInstruction; private MethodReference _compAndInvalidateMethod; private MethodReference _throwIfDisposedMethod; @@ -299,7 +298,6 @@ public AtomSetterMethodWeaver(AtomWeaverV2 weaver, PropertyDefinition property, _property = property; _nullCheckEndInstruction = Instruction.Create(OpCodes.Nop); - _preReturnInstruction = Instruction.Create(OpCodes.Nop); var propertyType = property.PropertyType; _compAndInvalidateMethod = @@ -314,8 +312,6 @@ public void Weave() var index = 0; Prepend(ref index, instructions); - body.Instructions.Insert(body.Instructions.Count - 1, _preReturnInstruction); - body.OptimizeMacros(); } @@ -331,14 +327,15 @@ private void Prepend(ref int ind, IList il) il.Insert(ind++, Instruction.Create(OpCodes.Ldfld, _atomField)); il.Insert(ind++, Instruction.Create(OpCodes.Brfalse, _nullCheckEndInstruction)); - // atom.Invalidate() + // if (atom.CompareAndInvalidate()) goto nullCheckEnd; il.Insert(ind++, Instruction.Create(OpCodes.Ldarg_0)); il.Insert(ind++, Instruction.Create(OpCodes.Ldfld, _atomField)); il.Insert(ind++, Instruction.Create(OpCodes.Ldarg_1)); il.Insert(ind++, Instruction.Create(OpCodes.Callvirt, _compAndInvalidateMethod)); il.Insert(ind++, Instruction.Create(OpCodes.Brtrue, _nullCheckEndInstruction)); - il.Insert(ind++, Instruction.Create(OpCodes.Br, _preReturnInstruction)); + // return; + il.Insert(ind++, Instruction.Create(OpCodes.Ret)); il.Insert(ind++, _nullCheckEndInstruction); }