Skip to content

Commit

Permalink
[DYNAREC] Introduce BOX64_DYNAREC_DIRTY and some profile to use it
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Jan 15, 2025
1 parent ec67556 commit 8432f7d
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,12 @@ Wait for FillBlock to be ready (FillBlock builds Dynarec blocks and is not multi
* 0 : Do not wait for FillBlock to ready and use Interpreter instead (might speedup a bit massive multithread or JIT programs).
* 1 : Wait for FillBlock to be ready. (default, mostly faster)

#### BOX64_DYNAREC_DIRTY *

Allow continue running a block that is unprotected and potentially dirty
* 0 : Do not allow conitnuing to run a dynablock that gets unprotected (default)
* 1 : Allow continue to run a dynablock that write data in the same page the code is. It can get faster loading time of some game but can also get unexpected crash.

### Detection

#### BOX64_DYNAREC_BLEEDING_EDGE *
Expand Down
7 changes: 7 additions & 0 deletions docs/box64.pod
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@ Behavior with FillBlock is not available (FillBlock build Dynarec blocks and is
* 0 : Dynarec will not wait for FillBlock to ready and use Interpreter instead (might speedup a bit massive multithread or JIT programs)
* 1 : Dynarec will wait for FillBlock to be ready (Default)

=item B<BOX64_DYNAREC_DIRTY>=I<0|1>

Allow continue running a block that is unprotected and potentially dirty

* 0 : Do not allow conitnuing to run a dynablock that gets unprotected (default)
* 1 : Allow continue to run a dynablock that write data in the same page the code is. It can get faster loading time of some game but can also get unexpected crash.

=item B<BOX64_DYNAREC_GDBJIT>=I<0|1|2>

The GDBJIT debugging support, only available with the compilation option GDBJIT=ON, enable it with gdb command: jit-reader-load /usr/local/lib/libbox64gdbjitreader.so.
Expand Down
10 changes: 10 additions & 0 deletions src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ int box64_dynarec_gdbjit = 0;
int box64_dynarec_df = 1;
int box64_dynarec_perf_map = 0;
int box64_dynarec_perf_map_fd = -1;
int box64_dynarec_dirty = 0;
#ifdef ARM64
int arm64_asimd = 0;
int arm64_aes = 0;
Expand Down Expand Up @@ -939,6 +940,15 @@ void LoadLogEnv()
if(!box64_dynarec_df)
printf_log(LOG_INFO, "Dynarec will not use/generate defered flags\n");
}
p = getenv("BOX64_DYNAREC_DIRTY");
if(p) {
if(strlen(p)==1) {
if(p[0]>='0' && p[0]<='1')
box64_dynarec_dirty = p[0]-'0';
}
if(box64_dynarec_dirty)
printf_log(LOG_INFO, "Dynarec will allow dirty block to continu running\n");
}
p = getenv("BOX64_DYNAREC_ALIGNED_ATOMICS");
if(p) {
if(strlen(p)==1) {
Expand Down
1 change: 1 addition & 0 deletions src/include/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extern int box64_dynarec_nativeflags;
extern int box64_dynarec_df;
extern int box64_dynarec_perf_map;
extern int box64_dynarec_perf_map_fd;
extern int box64_dynarec_dirty;
#ifdef ARM64
extern int arm64_asimd;
extern int arm64_aes;
Expand Down
2 changes: 1 addition & 1 deletion src/libtools/signals.c
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ void my_box64signalhandler(int32_t sig, siginfo_t* info, void * ucntx)
unprotectDB((uintptr_t)addr, 1, 1); // unprotect 1 byte... But then, the whole page will be unprotected
if(db) CheckHotPage((uintptr_t)addr);
int db_need_test = db?getNeedTest((uintptr_t)db->x64_addr):0;
if(db && ((addr>=db->x64_addr && addr<(db->x64_addr+db->x64_size)) || db_need_test)) {
if(db && ((addr>=db->x64_addr && addr<(db->x64_addr+db->x64_size)) || (db_need_test && !box64_dynarec_dirty))) {
emu = getEmuSignal(emu, p, db);
// dynablock got auto-dirty! need to get out of it!!!
if(emu->jmpbuf) {
Expand Down
2 changes: 2 additions & 0 deletions src/tools/rcfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ ENTRYSTRING_(BOX64_NODYNAREC, box64_nodynarec) \
ENTRYSTRING_(BOX64_DYNAREC_TEST, box64_dynarec_test) \
ENTRYBOOL(BOX64_DYNAREC_MISSING, box64_dynarec_missing) \
ENTRYBOOL(BOX64_DYNAREC_DF, box64_dynarec_df) \
ENTRYBOOL(BOX64_DYNAREC_DIRTY, box64_dynarec_dirty) \

#else
#define SUPER3() \
Expand Down Expand Up @@ -206,6 +207,7 @@ IGNORE(BOX64_NODYNAREC) \
IGNORE(BOX64_DYNAREC_TEST) \
IGNORE(BOX64_DYNAREC_MISSING) \
IGNORE(BOX64_DYNAREC_DF) \
IGNORE(BOX64_DYNAREC_DIRTY) \

#endif

Expand Down
33 changes: 33 additions & 0 deletions system/box64.box64rc
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,39 @@ BOX64_DYNAREC_STRONGMEM=1
[MMRX.exe]
BOX64_DYNAREC_STRONGMEM=1

[RockstarService.exe]
BOX64_DYNAREC_STRONGMEM=1
BOX64_DYNAREC_FASTNAN=0
BOX64_DYNAREC_FASTROUND=0
BOX64_DYNAREC_SAFEFLAGS=2
BOX64_DYNAREC_DIRTY=1

[SocialClubHelper.exe]
BOX64_DYNAREC_SAFEFLAGS=2
BOX64_DYNAREC_FASTNAN=0
BOX64_DYNAREC_FASTROUND=0
BOX64_DYNAREC_BIGBLOCK=3
BOX64_DYNAREC_CALLRET=1

[Launcher.exe]
#this is for Rockstar Launcher, but probably other launcher too...
BOX64_DYNAREC_STRONGMEM=1
BOX64_DYNAREC_SAFEFLAGS=2

[PlayGTAV.exe]
BOX64_DYNAREC_STRONGMEM=1
BOX64_DYNAREC_SAFEFLAGS=2
BOX64_DYNAREC_FASTNAN=0
BOX64_DYNAREC_FASTROUND=0

[GTA5.exe]
BOX64_DYNAREC_SAFEFLAGS=2
BOX64_DYNAREC_STRONGMEM=1
BOX64_DYNAREC_FASTNAN=0
BOX64_DYNAREC_FASTROUND=0
BOX64_DYNAREC_BIGBLOCK=3
BOX64_DYNAREC_CALLRET=1

[Risk of Rain 2.exe]
BOX64_DYNAREC_STRONGMEM=1

Expand Down

0 comments on commit 8432f7d

Please sign in to comment.