about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-10-20 13:21:08 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-10-20 13:21:08 +0200
commit29beabd6831dd51a1dd0a0cbf6c241a2ba45b612 (patch)
treed2d2179fb61de42ba583b1893d4821fa95a32aa4
parent80c346060f66f4dba261fae348bd9cf4cc4578d7 (diff)
downloadbox64-29beabd6831dd51a1dd0a0cbf6c241a2ba45b612.tar.gz
box64-29beabd6831dd51a1dd0a0cbf6c241a2ba45b612.zip
[ARM64_DYNAREC] Added BOX64_DYNAREC_NATIVEFLAGS to disable the use of native flags, as there is still a bug or two in that mode (for #1947)
-rw-r--r--docs/USAGE.md5
-rw-r--r--src/core.c10
-rw-r--r--src/dynarec/arm64/dynarec_arm64_functions.c2
-rw-r--r--src/include/debug.h1
-rw-r--r--src/tools/rcfile.c2
-rw-r--r--system/box64.box64rc1
6 files changed, 21 insertions, 0 deletions
diff --git a/docs/USAGE.md b/docs/USAGE.md
index fcc5a982..bb7e974a 100644
--- a/docs/USAGE.md
+++ b/docs/USAGE.md
@@ -204,6 +204,11 @@ Generated code for aligned atomics only
 * 0 : The code generated can handle unaligned atomics (Default)

 * 1 : Generated code only for aligned atomics (faster and less code generated, but will SEGBUS if LOCK prefix is unused on unaligned data)

 

+#### BOX64_DYNAREC_NATIVEFLAGS *

+Generate code will use native flags if possible

+* 0 : The code generated whill not use native flags even when possible

+* 1 : Generated code will use native flags when possible (Arm64 only for now) (Default)

+

 #### BOX64_DYNAREC_BLEEDING_EDGE *

 Detect MonoBleedingEdge and apply conservative settings

 * 0 : Don't detect MonoBleedingEdge

diff --git a/src/core.c b/src/core.c
index 157dd204..89f0c78b 100644
--- a/src/core.c
+++ b/src/core.c
@@ -90,6 +90,7 @@ int box64_dynarec_tbb = 1;
 int box64_dynarec_wait = 1;
 int box64_dynarec_missing = 0;
 int box64_dynarec_aligned_atomics = 0;
+int box64_dynarec_nativeflags = 1;
 uintptr_t box64_nodynarec_start = 0;
 uintptr_t box64_nodynarec_end = 0;
 uintptr_t box64_dynarec_test_start = 0;
@@ -883,6 +884,15 @@ void LoadLogEnv()
         if(box64_dynarec_aligned_atomics)
             printf_log(LOG_INFO, "Dynarec will generate only aligned atomics code\n");
     }
+    p = getenv("BOX64_DYNAREC_NATIVEFLAGS");
+    if(p) {
+        if(strlen(p)==1) {
+            if(p[0]>='0' && p[0]<='1')
+                box64_dynarec_nativeflags = p[0]-'0';
+        }
+        if(!box64_dynarec_nativeflags)
+            printf_log(LOG_INFO, "Dynarec will not use native flags if possible\n");
+    }
     p = getenv("BOX64_DYNAREC_MISSING");
     if(p) {
         if(strlen(p)==1) {
diff --git a/src/dynarec/arm64/dynarec_arm64_functions.c b/src/dynarec/arm64/dynarec_arm64_functions.c
index 6861eb11..bc41ebd9 100644
--- a/src/dynarec/arm64/dynarec_arm64_functions.c
+++ b/src/dynarec/arm64/dynarec_arm64_functions.c
@@ -972,6 +972,8 @@ static void propagateNativeFlags(dynarec_native_t* dyn, int ninst)
 
 void updateNatveFlags(dynarec_native_t* dyn)
 {
+    if(!box64_dynarec_nativeflags)
+        return;
     // backward check if native flags are used
     for(int ninst=dyn->size-1; ninst>=0; --ninst)
         if(dyn->insts[ninst].use_nat_flags) {
diff --git a/src/include/debug.h b/src/include/debug.h
index 9fb183b4..2ebef55d 100644
--- a/src/include/debug.h
+++ b/src/include/debug.h
@@ -38,6 +38,7 @@ extern int box64_dynarec_tbb;
 extern int box64_dynarec_wait;
 extern int box64_dynarec_missing;
 extern int box64_dynarec_aligned_atomics;
+extern int box64_dynarec_nativeflags;
 #ifdef ARM64
 extern int arm64_asimd;
 extern int arm64_aes;
diff --git a/src/tools/rcfile.c b/src/tools/rcfile.c
index abebd523..5dd14dc4 100644
--- a/src/tools/rcfile.c
+++ b/src/tools/rcfile.c
@@ -167,6 +167,7 @@ ENTRYBOOL(BOX64_DYNAREC_TBB, box64_dynarec_tbb)                     \
 IGNORE(BOX64_DYNAREC_HOTPAGE)                                       \
 IGNORE(BOX64_DYNAREC_FASTPAGE)                                      \
 ENTRYBOOL(BOX64_DYNAREC_ALIGNED_ATOMICS, box64_dynarec_aligned_atomics) \
+ENTRYBOOL(BOX64_DYNAREC_NATIVEFLAGS, box64_dynarec_nativeflags)     \
 ENTRYBOOL(BOX64_DYNAREC_WAIT, box64_dynarec_wait)                   \
 ENTRYSTRING_(BOX64_NODYNAREC, box64_nodynarec)                      \
 ENTRYSTRING_(BOX64_DYNAREC_TEST, box64_dynarec_test)                \
@@ -192,6 +193,7 @@ IGNORE(BOX64_DYNAREC_TBB)                                           \
 IGNORE(BOX64_DYNAREC_HOTPAGE)                                       \
 IGNORE(BOX64_DYNAREC_FASTPAGE)                                      \
 IGNORE(BOX64_DYNAREC_ALIGNED_ATOMICS)                               \
+IGNORE(BOX64_DYNAREC_NATIVEFLAGS)                                   \
 IGNORE(BOX64_DYNAREC_WAIT)                                          \
 IGNORE(BOX64_NODYNAREC)                                             \
 IGNORE(BOX64_DYNAREC_TEST)                                          \
diff --git a/system/box64.box64rc b/system/box64.box64rc
index ad24fa5f..9ad8464d 100644
--- a/system/box64.box64rc
+++ b/system/box64.box64rc
@@ -431,6 +431,7 @@ BOX64_DYNAREC_STRONGMEM=1
 BOX64_DYNAREC_BIGBLOCK=3
 BOX64_DYNAREC_CALLRET=1
 BOX64_DYNAREC_SAFEFLAGS=0
+BOX64_DYNAREC_NATIVEFLAGS=0
 
 [Sunblaze.exe]
 BOX64_DYNAREC_STRONGMEM=1