From 29beabd6831dd51a1dd0a0cbf6c241a2ba45b612 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 20 Oct 2024 13:21:08 +0200 Subject: [PATCH] [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) --- docs/USAGE.md | 5 +++++ src/core.c | 10 ++++++++++ src/dynarec/arm64/dynarec_arm64_functions.c | 2 ++ src/include/debug.h | 1 + src/tools/rcfile.c | 2 ++ system/box64.box64rc | 1 + 6 files changed, 21 insertions(+) diff --git a/docs/USAGE.md b/docs/USAGE.md index fcc5a9827..bb7e974a2 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 157dd204c..89f0c78b8 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 6861eb114..bc41ebd97 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 9fb183b4c..2ebef55d8 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 abebd5239..5dd14dc4c 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 ad24fa5f0..9ad8464d9 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