Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configurator/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class ValueState:
("BOX64_DYNAREC_BIGBLOCK", "0"),
("BOX64_DYNAREC_SAFEFLAGS", "2"),
("BOX64_DYNAREC_STRONGMEM", "2"),
("BOX64_DYNAREC_CALLRET", "3"),
),
"safe": (
("BOX64_DYNAREC_BIGBLOCK", "0"),
Expand Down
2 changes: 1 addition & 1 deletion docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Optimize CALL/RET opcodes. Available in WowBox64.
* 0: Do not optimize CALL/RET, use jump table.
* 1: Try to optimize CALL/RET, skipping the jump table when possible.
* 2: Try to optimize CALL/RET, skipping the jump table when possible, adding code to handle return to dirty/modified block. Does not work on WowBox64. [Default]
* 3: Same as 2, with leaf call analysis that tries to duplicate leaf bodies into their callers. Only available for LoongArch for now.
* 3: Same as 2, but also track dynablock usage so blocks are not reclaimed while still in use.

### BOX64_DYNAREC_DF

Expand Down
2 changes: 1 addition & 1 deletion docs/USAGE_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ BOX64_DYNAREC_CALLRET=1
* 0: 不优化 CALL/RET,使用跳转表。
* 1: 尝试优化 CALL/RET,在可能的情况下跳过跳转表。
* 2: 尝试优化 CALL/RET,在可能的情况下跳过跳转表,同时增加对返回到脏/已修改代码块的代码的处理。在 WowBox64 上不可用。 [默认值]
* 3: 在 2 的基础上,对叶子函数进行分析,并将符合条件的叶子函数体复制到调用方。目前仅支持龙架构。
* 3: 在 2 的基础上,额外跟踪代码块的使用情况,避免回收仍在使用中的代码块。

### BOX64_DYNAREC_DF

Expand Down
2 changes: 1 addition & 1 deletion docs/box64.pod
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Optimize CALL/RET opcodes. Available in WowBox64.
* 0 : Do not optimize CALL/RET, use jump table.
* 1 : Try to optimize CALL/RET, skipping the jump table when possible.
* 2 : Try to optimize CALL/RET, skipping the jump table when possible, adding code to handle return to dirty/modified block. Does not work on WowBox64. [Default]
* 3 : Same as 2, with leaf call analysis that tries to duplicate leaf bodies into their callers. Only available for LoongArch for now.
* 3 : Same as 2, but also track dynablock usage so blocks are not reclaimed while still in use.


=item B<BOX64_DYNAREC_DF> =I<0|1>
Expand Down
2 changes: 1 addition & 1 deletion docs/gen/usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
},
{
"key": "3",
"description": "Same as 2, with leaf call analysis that tries to duplicate leaf bodies into their callers. Only available for LoongArch for now.",
"description": "Same as 2, but also track dynablock usage so blocks are not reclaimed while still in use.",
"default": false
}
]
Expand Down
2 changes: 1 addition & 1 deletion docs/gen/usage_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"0": "不优化 CALL/RET,使用跳转表。",
"1": "尝试优化 CALL/RET,在可能的情况下跳过跳转表。",
"2": "尝试优化 CALL/RET,在可能的情况下跳过跳转表,同时增加对返回到脏/已修改代码块的代码的处理。在 WowBox64 上不可用。",
"3": "在 2 的基础上,对叶子函数进行分析,并将符合条件的叶子函数体复制到调用方。目前仅支持龙架构。"
"3": "在 2 的基础上,额外跟踪代码块的使用情况,避免回收仍在使用中的代码块。"
}
},
"BOX64_DYNAREC_DF": {
Expand Down
6 changes: 3 additions & 3 deletions src/dynarec/arm64/dynarec_arm64_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void jump_to_epilog(dynarec_arm_t* dyn, uintptr_t ip, int reg, int ninst)
TABLE64C(x2, const_epilog);
SMEND();
CHECK_DFNONE(0);
if (BOX64DRENV(dynarec_callret) >= 2)
if (BOX64DRENV(dynarec_callret) >= 3)
doLeaveBlock(dyn, ninst, x4, x5, x6);
BR(x2);
}
Expand Down Expand Up @@ -421,7 +421,7 @@ void jump_to_next(dynarec_arm_t* dyn, uintptr_t ip, int reg, int ninst, int is32
if(reg!=x1) {
MOVx_REG(x1, xRIP);
}
if(BOX64DRENV(dynarec_callret) >= 2 && !dyn->insts[ninst].x64.has_callret)
if(BOX64DRENV(dynarec_callret) >= 3 && !dyn->insts[ninst].x64.has_callret)
doLeaveBlock(dyn, ninst, x4, x5, x6);
// #ifdef HAVE_TRACE
// The BLR form is only for gdb backtraces, but it breaks the
Expand All @@ -447,7 +447,7 @@ void ret_to_next(dynarec_arm_t* dyn, uintptr_t ip, int ninst, rex_t rex)
// pop the actual return address for ARM stack
LDPx_S7_postindex(xLR, x6, xSP, 16);
SUBx_REG(x6, x6, xRIP); // is it the right address?
if (BOX64DRENV(dynarec_callret) >= 2)
if (BOX64DRENV(dynarec_callret) >= 3)
doLeaveBlock(dyn, ninst, x4, x5, x3);
CBNZx(x6, 2*4);
RET(xLR);
Expand Down
4 changes: 3 additions & 1 deletion src/dynarec/dynablock.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,10 @@ int FreeRangeDynablock(dynablock_t* db, uintptr_t addr, uintptr_t size)
void dynablock_leave_runtime(dynablock_t* db)
{
if(!db) return;
if(BOX64ENV(dynarec_callret) < 2) return;
#ifdef HAVE_IN_USED
if(BOX64ENV(dynarec_callret) < 3) return;
__atomic_fetch_sub(&db->in_used, 1, __ATOMIC_ACQ_REL);
#endif
}

dynablock_t* CreateDBnoAlt(x64emu_t* emu, uintptr_t addr, int is32bits)
Expand Down
8 changes: 6 additions & 2 deletions src/dynarec/dynarec_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#define dynarec_native_t dynarec_arm_t
#define extcache_native_t neoncache_t

#define HAVE_IN_USED

#define ADDITIONNAL_DEFINITION() \
int fpuCacheNeedsTransform(dynarec_native_t* dyn, int ninst);

Expand Down Expand Up @@ -49,12 +51,12 @@ extern void arm64_next_invalid();
#define PRINT_OPCODE(C, A) arm64_print(C, A)
#elif defined(LA64)

#define HAVE_LEAFCALL

#define instruction_native_t instruction_la64_t
#define dynarec_native_t dynarec_la64_t
#define extcache_native_t lsxcache_t

#define HAVE_IN_USED

#define ADDITIONNAL_DEFINITION() \
int fpuCacheNeedsTransform(dynarec_native_t* dyn, int ninst);

Expand Down Expand Up @@ -98,6 +100,8 @@ extern void la64_next_invalid();
#define dynarec_native_t dynarec_rv64_t
#define extcache_native_t extcache_t

#define HAVE_IN_USED

#define ADDITIONNAL_DEFINITION() \
int fpuCacheNeedsTransform(dynarec_native_t* dyn, int ninst); \
int sewNeedsTransform(dynarec_rv64_t* dyn, int ninst);
Expand Down
Loading
Loading