From 3e6afeb5134fc699158e8c4d1646a138a947a93d Mon Sep 17 00:00:00 2001 From: gdkchan Date: Thu, 21 Jun 2018 23:05:42 -0300 Subject: Fix some thread sync issues (#172) * Fix some thread sync issues * Remove some debug stuff * Ensure that writes to the mutex address clears the exclusive monitor --- ChocolArm64/Instruction/AInstEmitMemoryEx.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'ChocolArm64/Instruction/AInstEmitMemoryEx.cs') diff --git a/ChocolArm64/Instruction/AInstEmitMemoryEx.cs b/ChocolArm64/Instruction/AInstEmitMemoryEx.cs index a339bb69..ba8eeceb 100644 --- a/ChocolArm64/Instruction/AInstEmitMemoryEx.cs +++ b/ChocolArm64/Instruction/AInstEmitMemoryEx.cs @@ -48,6 +48,16 @@ namespace ChocolArm64.Instruction { AOpCodeMemEx Op = (AOpCodeMemEx)Context.CurrOp; + if (AccType.HasFlag(AccessType.Ordered)) + { + EmitBarrier(Context); + } + + if (AccType.HasFlag(AccessType.Exclusive)) + { + EmitMemoryCall(Context, nameof(AMemory.SetExclusive), Op.Rn); + } + Context.EmitLdarg(ATranslatedSub.MemoryArgIdx); Context.EmitLdint(Op.Rn); @@ -67,16 +77,6 @@ namespace ChocolArm64.Instruction Context.EmitStintzr(Op.Rt2); } - - if (AccType.HasFlag(AccessType.Exclusive)) - { - EmitMemoryCall(Context, nameof(AMemory.SetExclusive), Op.Rn); - } - - if (AccType.HasFlag(AccessType.Ordered)) - { - EmitBarrier(Context); - } } public static void Pfrm(AILEmitterCtx Context) @@ -150,7 +150,7 @@ namespace ChocolArm64.Instruction Context.EmitLdc_I8(0); Context.EmitStintzr(Op.Rs); - Clrex(Context); + EmitMemoryCall(Context, nameof(AMemory.ClearExclusiveForStore)); } Context.MarkLabel(LblEnd); -- cgit v1.2.3