Skip to content

Commit

Permalink
[DYNAREC] Track if a dynablock is for 32bits code (for future use)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Sep 17, 2024
1 parent 59217cc commit 7d77a4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/dynarec/dynablock_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ typedef struct dynablock_s {
void* block; // block-sizeof(void*) == self
void* actual_block; // the actual start of the block (so block-sizeof(void*))
struct dynablock_s* previous; // a previous block that might need to be freed
int size;
void* x64_addr;
uintptr_t x64_size;
int size;
uint32_t hash;
uint8_t done;
uint8_t gone;
uint8_t always_test;
uint8_t dirty; // if need to be tested as soon as it's created
uint8_t always_test:1;
uint8_t is32bits:1;
int isize;
instsize_t* instsize;
void* jmpnext; // a branch jmpnext code when block is marked
Expand Down
10 changes: 6 additions & 4 deletions src/dynarec/dynarec_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ uintptr_t native_pass1(dynarec_native_t* dyn, uintptr_t addr, int alternate, int
uintptr_t native_pass2(dynarec_native_t* dyn, uintptr_t addr, int alternate, int is32bits);
uintptr_t native_pass3(dynarec_native_t* dyn, uintptr_t addr, int alternate, int is32bits);

void* CreateEmptyBlock(dynablock_t* block, uintptr_t addr) {
void* CreateEmptyBlock(dynablock_t* block, uintptr_t addr, int is32bits) {
block->isize = 0;
block->done = 0;
size_t sz = 4*sizeof(void*);
Expand All @@ -529,6 +529,7 @@ void* CreateEmptyBlock(dynablock_t* block, uintptr_t addr) {
block->actual_block = actual_p;
block->block = p;
block->jmpnext = p;
block->is32bits = is32bits;
*(dynablock_t**)actual_p = block;
*(void**)(p+2*sizeof(void*)) = native_epilog;
CreateJmpNext(block->jmpnext, p+2*sizeof(void*));
Expand All @@ -553,7 +554,7 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bit
*/
if(addr>=box64_nodynarec_start && addr<box64_nodynarec_end) {
dynarec_log(LOG_INFO, "Create empty block in no-dynarec zone\n");
return CreateEmptyBlock(block, addr);
return CreateEmptyBlock(block, addr, is32bits);
}
if(current_helper) {
dynarec_log(LOG_DEBUG, "Canceling dynarec FillBlock at %p as another one is going on\n", (void*)addr);
Expand Down Expand Up @@ -586,7 +587,7 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bit
if(!helper.size) {
dynarec_log(LOG_INFO, "Warning, null-sized dynarec block (%p)\n", (void*)addr);
CancelBlock64(0);
return CreateEmptyBlock(block, addr);
return CreateEmptyBlock(block, addr, is32bits);
}
if(!isprotectedDB(addr, 1)) {
dynarec_log(LOG_INFO, "Warning, write on current page on pass0, aborting dynablock creation (%p)\n", (void*)addr);
Expand Down Expand Up @@ -676,7 +677,7 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bit
// NULL block after removing dead code, how is that possible?
dynarec_log(LOG_INFO, "Warning, null-sized dynarec block after trimming dead code (%p)\n", (void*)addr);
CancelBlock64(0);
return CreateEmptyBlock(block, addr);
return CreateEmptyBlock(block, addr, is32bits);
}
updateYmm0s(&helper, 0, 0);

Expand Down Expand Up @@ -755,6 +756,7 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bit
block->jmpnext = next+sizeof(void*);
block->always_test = helper.always_test;
block->dirty = block->always_test;
block->is32bits = is32bits;
*(dynablock_t**)next = block;
*(void**)(next+3*sizeof(void*)) = native_next;
CreateJmpNext(block->jmpnext, next+3*sizeof(void*));
Expand Down

0 comments on commit 7d77a4b

Please sign in to comment.