From 65ac00833a8b51fe9ea6f12ffdfadeb098a6c360 Mon Sep 17 00:00:00 2001
From: FICTURE7 <FICTURE7@gmail.com>
Date: Thu, 20 May 2021 16:31:45 +0400
Subject: Use branch instead of tailcall for recursive calls (#2282)

* Use branch instead of tailcall for recursive calls

Use a branch instead of doing a tailcall for recursive calls. This
avoids having to store the dispatch address, setting up the epilogue and
keeps guest registers in host registers for longer.

The rejit check is moved down into the entry block so that the rejit
behaviour remains the same as before.

* Set PTC version

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
---
 ARMeilleure/Instructions/InstEmitFlowHelper.cs | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'ARMeilleure/Instructions/InstEmitFlowHelper.cs')

diff --git a/ARMeilleure/Instructions/InstEmitFlowHelper.cs b/ARMeilleure/Instructions/InstEmitFlowHelper.cs
index f995ffa1..e1309a4e 100644
--- a/ARMeilleure/Instructions/InstEmitFlowHelper.cs
+++ b/ARMeilleure/Instructions/InstEmitFlowHelper.cs
@@ -144,7 +144,14 @@ namespace ARMeilleure.Instructions
         {
             bool isRecursive = immediate == context.EntryAddress;
 
-            EmitJumpTableBranch(context, Const(immediate), isRecursive);
+            if (isRecursive)
+            {
+                context.Branch(context.GetLabel(immediate));
+            }
+            else
+            {
+                EmitJumpTableBranch(context, Const(immediate), isJump: false);
+            }
         }
 
         private static void EmitNativeCall(ArmEmitterContext context, Operand nativeContextPtr, Operand funcAddr, bool isJump)
-- 
cgit v1.2.3-70-g09d2