about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2024-12-13 15:12:18 +0800
committerGitHub <noreply@github.com>2024-12-13 08:12:18 +0100
commit5055866a5a9154c0f1700c2b44fc8c48142a29f3 (patch)
tree4af17ae9fae8984a6b2e9696934f33f10553171c /src
parent9f7d0c44043bb6e1c63d904c269db8307e94dfa7 (diff)
downloadbox64-5055866a5a9154c0f1700c2b44fc8c48142a29f3.tar.gz
box64-5055866a5a9154c0f1700c2b44fc8c48142a29f3.zip
[RV64_DYNAREC] Reinitialize sew after callret (#2148)
Diffstat (limited to 'src')
-rw-r--r--src/dynarec/rv64/dynarec_rv64_00_3.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/src/dynarec/rv64/dynarec_rv64_00_3.c b/src/dynarec/rv64/dynarec_rv64_00_3.c
index efdbfba2..35e9de8c 100644
--- a/src/dynarec/rv64/dynarec_rv64_00_3.c
+++ b/src/dynarec/rv64/dynarec_rv64_00_3.c
@@ -994,18 +994,10 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                     if (box64_dynarec_callret) {
                         SET_HASCALLRET();
                         // Push actual return address
-                        if (addr < (dyn->start + dyn->isize)) {
-                            // there is a next...
-                            j64 = (dyn->insts) ? (dyn->insts[ninst].epilog - (dyn->native_size)) : 0;
-                            AUIPC(x4, ((j64 + 0x800) >> 12) & 0xfffff);
-                            ADDI(x4, x4, j64 & 0xfff);
-                            MESSAGE(LOG_NONE, "\tCALLRET set return to +%di\n", j64 >> 2);
-                        } else {
-                            j64 = (dyn->insts) ? (GETMARK - (dyn->native_size)) : 0;
-                            AUIPC(x4, ((j64 + 0x800) >> 12) & 0xfffff);
-                            ADDI(x4, x4, j64 & 0xfff);
-                            MESSAGE(LOG_NONE, "\tCALLRET set return to +%di\n", j64 >> 2);
-                        }
+                        j64 = (dyn->insts) ? (GETMARK - (dyn->native_size)) : 0;
+                        AUIPC(x4, ((j64 + 0x800) >> 12) & 0xfffff);
+                        ADDI(x4, x4, j64 & 0xfff);
+                        MESSAGE(LOG_NONE, "\tCALLRET set return to +%di\n", j64 >> 2);
                         ADDI(xSP, xSP, -16);
                         SD(x4, xSP, 0);
                         SD(x2, xSP, 8);
@@ -1018,9 +1010,11 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                     else
                         j64 = addr + i32;
                     jump_to_next(dyn, j64, 0, ninst, rex.is32bits);
+                    MARK;
+                    if (box64_dynarec_callret && dyn->vector_sew != VECTOR_SEWNA)
+                        vector_vsetvli(dyn, ninst, x3, dyn->vector_sew, VECTOR_LMUL1, 1);
                     if (box64_dynarec_callret && addr >= (dyn->start + dyn->isize)) {
                         // jumps out of current dynablock...
-                        MARK;
                         j64 = getJumpTableAddress64(addr);
                         TABLE64(x4, j64);
                         LD(x4, x4, 0);
@@ -1488,28 +1482,21 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                     GETIP_(addr);
                     if (box64_dynarec_callret) {
                         SET_HASCALLRET();
-                        // Push actual return address
-                        if (addr < (dyn->start + dyn->isize)) {
-                            // there is a next...
-                            j64 = (dyn->insts) ? (dyn->insts[ninst].epilog - (dyn->native_size)) : 0;
-                            AUIPC(x4, ((j64 + 0x800) >> 12) & 0xfffff);
-                            ADDI(x4, x4, j64 & 0xfff);
-                            MESSAGE(LOG_NONE, "\tCALLRET set return to +%di\n", j64 >> 2);
-                        } else {
-                            j64 = (dyn->insts) ? (GETMARK - (dyn->native_size)) : 0;
-                            AUIPC(x4, ((j64 + 0x800) >> 12) & 0xfffff);
-                            ADDI(x4, x4, j64 & 0xfff);
-                            MESSAGE(LOG_NONE, "\tCALLRET set return to +%di\n", j64 >> 2);
-                        }
+                        j64 = (dyn->insts) ? (GETMARK - (dyn->native_size)) : 0;
+                        AUIPC(x4, ((j64 + 0x800) >> 12) & 0xfffff);
+                        ADDI(x4, x4, j64 & 0xfff);
+                        MESSAGE(LOG_NONE, "\tCALLRET set return to +%di\n", j64 >> 2);
                         ADDI(xSP, xSP, -16);
                         SD(x4, xSP, 0);
                         SD(xRIP, xSP, 8);
                     }
                     PUSH1z(xRIP);
                     jump_to_next(dyn, 0, ed, ninst, rex.is32bits);
+                    MARK;
+                    if (box64_dynarec_callret && dyn->vector_sew != VECTOR_SEWNA)
+                        vector_vsetvli(dyn, ninst, x3, dyn->vector_sew, VECTOR_LMUL1, 1);
                     if (box64_dynarec_callret && addr >= (dyn->start + dyn->isize)) {
                         // jumps out of current dynablock...
-                        MARK;
                         j64 = getJumpTableAddress64(addr);
                         TABLE64(x4, j64);
                         LD(x4, x4, 0);