diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2025-10-19 14:42:59 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2025-10-19 14:42:59 +0200 |
| commit | ed267b1a05264dc9f28619812aac3d4c5d702a93 (patch) | |
| tree | d099df6071315be470bbdac8a4452c6e6b590d49 | |
| parent | 609d5c27b2b2c344a57eec93d8b3078cd61e3b30 (diff) | |
| download | box64-ed267b1a05264dc9f28619812aac3d4c5d702a93.tar.gz box64-ed267b1a05264dc9f28619812aac3d4c5d702a93.zip | |
[LA64] Use alternate code for unaligned CMPXCHG8B in interpreter
| -rw-r--r-- | src/emu/x64runf0.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/emu/x64runf0.c b/src/emu/x64runf0.c index 1d8d05b5..2e88d93a 100644 --- a/src/emu/x64runf0.c +++ b/src/emu/x64runf0.c @@ -861,8 +861,28 @@ uintptr_t RunF0(x64emu_t *emu, rex_t rex, uintptr_t addr) } } while(tmp32s); #endif - } else + } else { if(((uintptr_t)ED)&0x7) { + #ifdef __loongarch64 + tmp64u = R_EAX | (((uint64_t)R_EDX)<<32); + tmp64u2 = R_EBX | (((uint64_t)R_ECX)<<32); + do { + uint64_t tmp64u3 = native_lock_read_dd((void*)(((uintptr_t)ED)&~7LL)); + uint64_t tmp64u4 = ED->q[0]; + if(tmp64u4==tmp64u) { + tmp32s = native_lock_write_dd((void*)(((uintptr_t)ED)&~7LL), tmp64u2); + if(!tmp32s) { + native_lock_store_dd(ED, tmp64u2); + SET_FLAG(F_ZF); + } + } else { + tmp32s = 0; + CLEAR_FLAG(F_ZF); + R_RAX = tmp64u4&0xffffffff; + R_RDX = (tmp64u4>>32)&0xffffffff; + } + } while(tmp32s); + #else tmp64u = R_EAX | (((uint64_t)R_EDX)<<32); do { native_lock_get_b(ED); @@ -879,6 +899,7 @@ uintptr_t RunF0(x64emu_t *emu, rex_t rex, uintptr_t addr) tmp32s = 0; } } while(tmp32s); + #endif } else { tmp64u = R_EAX | (((uint64_t)R_EDX)<<32); tmp64u2 = R_EBX | (((uint64_t)R_ECX)<<32); @@ -891,6 +912,7 @@ uintptr_t RunF0(x64emu_t *emu, rex_t rex, uintptr_t addr) R_RDX = (tmp64u2>>32)&0xffffffff; } } + } #else pthread_mutex_lock(&my_context->mutex_lock); if(rex.w) { |