about summary refs log tree commit diff stats
path: root/src/dynarec/dynarec_native_pass.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-05-15 14:45:27 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-05-15 14:45:27 +0200
commit07aacc9b08a29019b0f351dca18eec1f0fc9b32b (patch)
tree02b22cf7c363f3d33c0d4fe622595b3bbae1913c /src/dynarec/dynarec_native_pass.c
parent50325785f54ad0a4327ae905957e2f90c557bafd (diff)
downloadbox64-07aacc9b08a29019b0f351dca18eec1f0fc9b32b.tar.gz
box64-07aacc9b08a29019b0f351dca18eec1f0fc9b32b.zip
[DYNAREC] Small fixes to when to stop a block (fixes regression on EALauncher)
Diffstat (limited to 'src/dynarec/dynarec_native_pass.c')
-rw-r--r--src/dynarec/dynarec_native_pass.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/dynarec/dynarec_native_pass.c b/src/dynarec/dynarec_native_pass.c
index 39ee7a7b..2772a973 100644
--- a/src/dynarec/dynarec_native_pass.c
+++ b/src/dynarec/dynarec_native_pass.c
@@ -213,15 +213,14 @@ uintptr_t native_pass(dynarec_native_t* dyn, uintptr_t addr, int alternate, int
             }
         }
         #else
-        // check if block need to be stopped, because it's a 00 00 opcode or is out of readable space
-        int ok_to_continue = (getProtection(addr) && getProtection(addr+1));
-        if(ok && (!ok_to_continue || !(*(uint16_t*)addr))) {
-            if(box64_dynarec_dump) dynarec_log(LOG_NONE, "Stopping block at %p reason: %s\n", (void*)addr, ok_to_continue?"Address is not readable":"Next opcode is 00 00");
-            ok = ok_to_continue?0:-1;
+        // check if block need to be stopped, because it's a 00 00 opcode (unreadeable is already checked earlier)
+        if((ok>0) && !dyn->forward && !(*(uint8_t*)addr) && !(*(uint8_t*)(addr+1))) {
+            if(box64_dynarec_dump) dynarec_log(LOG_NONE, "Stopping block at %p reason: %s\n", (void*)addr, "Next opcode is 00 00");
+            ok = 0;
             need_epilog = 1;
         }
         if(dyn->forward) {
-            if(dyn->forward_to == addr && !need_epilog && ok_to_continue && ok>=0) {
+            if(dyn->forward_to == addr && !need_epilog && ok>=0) {
                 // we made it!
                 reset_n = get_first_jump(dyn, addr);
                 if(box64_dynarec_dump) dynarec_log(LOG_NONE, "Forward extend block for %d bytes %s%p -> %p (ninst %d - %d)\n", dyn->forward_to-dyn->forward, dyn->insts[dyn->forward_ninst].x64.has_callret?"(opt. call) ":"", (void*)dyn->forward, (void*)dyn->forward_to, reset_n, ninst);
@@ -303,15 +302,15 @@ uintptr_t native_pass(dynarec_native_t* dyn, uintptr_t addr, int alternate, int
             }
             #endif
         }
-        if(ok && dyn->insts[ninst].x64.has_callret)
+        if((ok>0) && dyn->insts[ninst].x64.has_callret)
             reset_n = -2;
         ++ninst;
         #if STEP == 0
         memset(&dyn->insts[ninst], 0, sizeof(instruction_native_t));
-        if(ok && (((box64_dynarec_bigblock<stopblock) && !isJumpTableDefault64((void*)addr))
+        if((ok>0) && (((box64_dynarec_bigblock<stopblock) && !isJumpTableDefault64((void*)addr))
             || (addr>=box64_nodynarec_start && addr<box64_nodynarec_end)))
         #else
-        if(ok && (ninst==dyn->size))
+        if((ok>0) && (ninst==dyn->size))
         #endif
         {
             #if STEP == 0