diff options
| author | Yang Liu <liuyang22@iscas.ac.cn> | 2025-01-24 23:02:32 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-24 16:02:32 +0100 |
| commit | 3ec950726b61eb427cb4250a28125a2a791e3a6a (patch) | |
| tree | 55c78ae5f59e36c5497f95e2ac2d025504369736 /src | |
| parent | cec62dad4419ac9369c7ceb40311f27e834dfa34 (diff) | |
| download | box64-3ec950726b61eb427cb4250a28125a2a791e3a6a.tar.gz box64-3ec950726b61eb427cb4250a28125a2a791e3a6a.zip | |
[RV64_DYNAREC] Removed some TABLE64 usage (#2291)
Diffstat (limited to 'src')
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_00_3.c | 25 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_helper.h | 28 |
2 files changed, 22 insertions, 31 deletions
diff --git a/src/dynarec/rv64/dynarec_rv64_00_3.c b/src/dynarec/rv64/dynarec_rv64_00_3.c index 19d5d2b9..6777c7ac 100644 --- a/src/dynarec/rv64/dynarec_rv64_00_3.c +++ b/src/dynarec/rv64/dynarec_rv64_00_3.c @@ -463,11 +463,11 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int } else { GETIP(ip + 1); // read the 0xCC STORE_XEMU_CALL(x3); + ADDI(x3, xRIP, 8 + 8); // expected return address ADDI(x1, xEmu, (uint32_t)offsetof(x64emu_t, ip)); // setup addr as &emu->ip - CALL_S(x64Int3, -1, x1); + CALL_(x64Int3, -1, x3, x1, 0); LOAD_XEMU_CALL(); addr += 8 + 8; - TABLE64(x3, addr); // expected return address BNE_MARK(xRIP, x3); LW(x1, xEmu, offsetof(x64emu_t, quit)); CBZ_NEXT(x1); @@ -935,7 +935,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int if (!rex.is32bits && isNativeCall(dyn, addr + i32, rex.is32bits, &dyn->insts[ninst].natcall, &dyn->insts[ninst].retn)) tmp = dyn->insts[ninst].pass2choice = 3; else - tmp = dyn->insts[ninst].pass2choice = 0; + tmp = dyn->insts[ninst].pass2choice = i32 ? 0 : 1; #else tmp = dyn->insts[ninst].pass2choice; #endif @@ -947,7 +947,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int if (dyn->last_ip && (addr - dyn->last_ip < 0x800)) { ADDI(x2, xRIP, addr - dyn->last_ip); } else { - TABLE64(x2, addr); + MOV64x(x2, addr); } PUSH1(x2); MESSAGE(LOG_DUMP, "Native Call to %s (retn=%d)\n", GetNativeName(GetNativeFnc(dyn->insts[ninst].natcall - 1)), dyn->insts[ninst].retn); @@ -974,7 +974,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ADDI(x1, xEmu, (uint32_t)offsetof(x64emu_t, ip)); // setup addr as &emu->ip CALL_S(x64Int3, -1, x1); LOAD_XEMU_CALL(); - TABLE64(x3, dyn->insts[ninst].natcall); + MOV64x(x3, dyn->insts[ninst].natcall); ADDI(x3, x3, 2 + 8 + 8); BNE_MARK(xRIP, x3); // Not the expected address, exit dynarec block POP1(xRIP); // pop the return address @@ -986,8 +986,6 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ADD(xRSP, xRSP, x3); } } - TABLE64(x3, addr); - BNE_MARK(xRIP, x3); // Not the expected address again LW(x1, xEmu, offsetof(x64emu_t, quit)); CBZ_NEXT(x1); MARK; @@ -995,6 +993,11 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int dyn->last_ip = addr; } break; + case 1: + // this is call to next step, so just push the return address to the stack + MOV64x(x2, addr); + PUSH1z(x2); + break; default: if ((BOX64DRENV(dynarec_safeflags) > 1) || (ninst && dyn->insts[ninst - 1].x64.set_flags)) { READFLAGS(X_PEND); // that's suspicious @@ -1010,11 +1013,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int *ok = 0; }*/ - if (rex.is32bits) { - MOV32w(x2, addr); - } else { - TABLE64(x2, addr); - } + MOV64x(x2, addr); fpu_purgecache(dyn, ninst, 1, x1, x3, x4); PUSH1z(x2); if (BOX64DRENV(dynarec_callret)) { @@ -1042,7 +1041,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int if (BOX64DRENV(dynarec_callret) && addr >= (dyn->start + dyn->isize)) { // jumps out of current dynablock... j64 = getJumpTableAddress64(addr); - TABLE64(x4, j64); + MOV64x(x4, j64); LD(x4, x4, 0); BR(x4); } diff --git a/src/dynarec/rv64/dynarec_rv64_helper.h b/src/dynarec/rv64/dynarec_rv64_helper.h index ab7a6cc6..2b8a6d42 100644 --- a/src/dynarec/rv64/dynarec_rv64_helper.h +++ b/src/dynarec/rv64/dynarec_rv64_helper.h @@ -1107,33 +1107,25 @@ dyn->vector_sew = VECTOR_SEWNA; #if STEP < 2 -#define GETIP(A) TABLE64(0, 0) -#define GETIP_(A) TABLE64(0, 0) +#define GETIP(A) MOV64x(xRIP, A) +#define GETIP_(A) MOV64x(xRIP, A) #else // put value in the Table64 even if not using it for now to avoid difference between Step2 and Step3. Needs to be optimized later... #define GETIP(A) \ if (dyn->last_ip && ((A) - dyn->last_ip) < 2048) { \ uint64_t _delta_ip = (A) - dyn->last_ip; \ dyn->last_ip += _delta_ip; \ - if (_delta_ip) { \ - ADDI(xRIP, xRIP, _delta_ip); \ - } \ + if (_delta_ip) ADDI(xRIP, xRIP, _delta_ip); \ } else { \ dyn->last_ip = (A); \ - if (dyn->last_ip < 0xffffffff) { \ - MOV64x(xRIP, dyn->last_ip); \ - } else \ - TABLE64(xRIP, dyn->last_ip); \ + MOV64x(xRIP, (A)); \ } -#define GETIP_(A) \ - if (dyn->last_ip && ((A) - dyn->last_ip) < 2048) { \ - int64_t _delta_ip = (A) - dyn->last_ip; \ - if (_delta_ip) { ADDI(xRIP, xRIP, _delta_ip); } \ - } else { \ - if ((A) < 0xffffffff) { \ - MOV64x(xRIP, (A)); \ - } else \ - TABLE64(xRIP, (A)); \ +#define GETIP_(A) \ + if (dyn->last_ip && ((A) - dyn->last_ip) < 2048) { \ + int64_t _delta_ip = (A) - dyn->last_ip; \ + if (_delta_ip) ADDI(xRIP, xRIP, _delta_ip); \ + } else { \ + MOV64x(xRIP, (A)); \ } #endif #define CLEARIP() dyn->last_ip = 0 |