aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Translation
diff options
context:
space:
mode:
Diffstat (limited to 'ChocolArm64/Translation')
-rw-r--r--ChocolArm64/Translation/AILEmitterCtx.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/ChocolArm64/Translation/AILEmitterCtx.cs b/ChocolArm64/Translation/AILEmitterCtx.cs
index 3fa46e96..40e33ba8 100644
--- a/ChocolArm64/Translation/AILEmitterCtx.cs
+++ b/ChocolArm64/Translation/AILEmitterCtx.cs
@@ -110,6 +110,8 @@ namespace ChocolArm64.Translation
if (OpcIndex == 0)
{
MarkLabel(GetLabel(CurrBlock.Position));
+
+ EmitSynchronization();
}
CurrOp.Emitter(this);
@@ -117,6 +119,25 @@ namespace ChocolArm64.Translation
ILBlock.Add(new AILBarrier());
}
+ private void EmitSynchronization()
+ {
+ EmitLdarg(ATranslatedSub.StateArgIdx);
+
+ EmitPrivateCall(typeof(AThreadState), nameof(AThreadState.Synchronize));
+
+ EmitLdc_I4(0);
+
+ AILLabel LblContinue = new AILLabel();
+
+ Emit(OpCodes.Bne_Un_S, LblContinue);
+
+ EmitLdc_I8(0);
+
+ Emit(OpCodes.Ret);
+
+ MarkLabel(LblContinue);
+ }
+
public bool TryOptEmitSubroutineCall()
{
if (CurrBlock.Next == null)