about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-02-16 16:14:37 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-02-16 16:14:37 +0100
commit6f3d636226f2aef19362655e841236dc97bb1116 (patch)
treec030fbe9cda962fbef6d9f85ad686690ba3715a5 /src
parentf03792619a6137f7d72e370a9118061cae16bf10 (diff)
downloadbox64-6f3d636226f2aef19362655e841236dc97bb1116.tar.gz
box64-6f3d636226f2aef19362655e841236dc97bb1116.zip
[DYNAREC] Added BOX64_DYNAREC_WAIT env. var. (Default to 1)
Diffstat (limited to 'src')
-rwxr-xr-xsrc/dynarec/dynablock.c10
-rwxr-xr-xsrc/include/debug.h1
-rwxr-xr-xsrc/main.c10
-rw-r--r--src/tools/rcfile.c2
4 files changed, 21 insertions, 2 deletions
diff --git a/src/dynarec/dynablock.c b/src/dynarec/dynablock.c
index 1ce5708b..c1cd9bd3 100755
--- a/src/dynarec/dynablock.c
+++ b/src/dynarec/dynablock.c
@@ -162,8 +162,14 @@ static dynablock_t* internalDBGetBlock(x64emu_t* emu, uintptr_t addr, uintptr_t
     if(block || !create)
         return block;
 
-    if(need_lock)
-        mutex_lock(&my_context->mutex_dyndump);
+    if(need_lock) {
+        if(box64_dynarec_wait) {
+            mutex_lock(&my_context->mutex_dyndump);
+        } else {
+            if(mutex_trylock(&my_context->mutex_dyndump))   // FillBlock not available for now
+                return NULL;
+        }
+    }
     
     block = getDB(addr);    // just in case
     if(block) {
diff --git a/src/include/debug.h b/src/include/debug.h
index ed729868..7251c728 100755
--- a/src/include/debug.h
+++ b/src/include/debug.h
@@ -23,6 +23,7 @@ extern int box64_dynarec_safeflags;
 extern int box64_dynarec_callret;
 extern int box64_dynarec_bleeding_edge;
 extern int box64_dynarec_hotpage;
+extern int box64_dynarec_wait;
 #ifdef ARM64
 extern int arm64_asimd;
 extern int arm64_aes;
diff --git a/src/main.c b/src/main.c
index 863f40a3..6df6c8b1 100755
--- a/src/main.c
+++ b/src/main.c
@@ -58,6 +58,7 @@ int box64_dynarec_safeflags = 1;
 int box64_dynarec_callret = 0;
 int box64_dynarec_hotpage = 16;
 int box64_dynarec_bleeding_edge = 1;
+int box64_dynarec_wait = 1;
 uintptr_t box64_nodynarec_start = 0;
 uintptr_t box64_nodynarec_end = 0;
 #ifdef ARM64
@@ -540,6 +541,15 @@ void LoadLogEnv()
         if(!box64_dynarec_bleeding_edge)
             printf_log(LOG_INFO, "Dynarec will not detect MonoBleedingEdge\n");
     }
+    p = getenv("BOX64_DYNAREC_WAIT");
+    if(p) {
+        if(strlen(p)==1) {
+            if(p[0]>='0' && p[0]<='1')
+                box64_dynarec_wait = p[0]-'0';
+        }
+        if(!box64_dynarec_wait)
+            printf_log(LOG_INFO, "Dynarec will not wait for FillBlock to ready and use Interpreter instead\n");
+    }
     p = getenv("BOX64_DYNAREC_HOTPAGE");
     if(p) {
         int val = -1;
diff --git a/src/tools/rcfile.c b/src/tools/rcfile.c
index ebae7a68..ac6267ec 100644
--- a/src/tools/rcfile.c
+++ b/src/tools/rcfile.c
@@ -111,6 +111,7 @@ ENTRYINT(BOX64_DYNAREC_SAFEFLAGS, box64_dynarec_safeflags, 0, 2, 2) \
 ENTRYBOOL(BOX64_DYNAREC_CALLRET, box64_dynarec_callret)             \
 ENTRYBOOL(BOX64_DYNAREC_BLEEDING_EDGE, box64_dynarec_bleeding_edge) \
 ENTRYINT(BOX64_DYNAREC_HOTPAGE, box64_dynarec_hotpage, 0, 255, 8)   \
+ENTRYBOOL(box64_dynarec_wait, box64_dynarec_wait)                   \
 ENTRYSTRING_(BOX64_NODYNAREC, box64_nodynarec)                      \
 
 #else
@@ -127,6 +128,7 @@ IGNORE(BOX64_DYNAREC_SAFEFLAGS)                                     \
 IGNORE(BOX64_DYNAREC_CALLRET)                                       \
 IGNORE(BOX64_DYNAREC_BLEEDING_EDGE)                                 \
 IGNORE(BOX64_DYNAREC_HOTPAGE)                                       \
+IGNORE(BOX64_DYNAREC_wait)                                          \
 IGNORE(BOX64_NODYNAREC)                                             \
 
 #endif