about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-04-26 15:20:35 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-04-26 15:20:35 +0200
commitb184a184c456dcc32d016f16c335ac543a9e8273 (patch)
treee2c6a643effdb3c807b6c5f1ef2ed56717b40182 /src
parente5dcb3f1004b13b142491ace357c4d73cc71b689 (diff)
downloadbox64-b184a184c456dcc32d016f16c335ac543a9e8273.tar.gz
box64-b184a184c456dcc32d016f16c335ac543a9e8273.zip
[DYNAREC] Stop building a block if opcode is garbbage or not redeable (should help BIGBLOCK=2)
Diffstat (limited to 'src')
-rw-r--r--src/dynarec/dynarec_native_pass.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/dynarec/dynarec_native_pass.c b/src/dynarec/dynarec_native_pass.c
index 0288cbeb..d30b7593 100644
--- a/src/dynarec/dynarec_native_pass.c
+++ b/src/dynarec/dynarec_native_pass.c
@@ -213,8 +213,15 @@ 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 = (ok && 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 = 0;
+            need_epilog = 1;
+        }
         if(dyn->forward) {
-            if(dyn->forward_to == addr && !need_epilog) {
+            if(dyn->forward_to == addr && !need_epilog && ok_to_continue) {
                 // 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);