Skip to content

Commit 3bf34a7

Browse files
committed
[DYNAREC] Try to limit number of times blocks are invalidated, especialy those on NEVERCLEAN pages
1 parent 2cc903b commit 3bf34a7

2 files changed

Lines changed: 5 additions & 35 deletions

File tree

src/custommem.c

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,36 +2483,6 @@ void neverprotectDB(uintptr_t addr, size_t size, int mark)
24832483
UNLOCK_PROT();
24842484
}
24852485

2486-
// Remove the NEVERCLEAN flag for an adress range
2487-
void unneverprotectDB(uintptr_t addr, size_t size)
2488-
{
2489-
dynarec_log(LOG_DEBUG, "unneverprotectDB %p -> %p\n", (void*)addr, (void*)(addr+size-1));
2490-
2491-
uintptr_t cur = addr&~(box64_pagesize-1);
2492-
uintptr_t end = ALIGN(addr+size);
2493-
2494-
LOCK_PROT();
2495-
while(cur!=end) {
2496-
uint32_t prot = 0, oprot;
2497-
uintptr_t bend = 0;
2498-
if (!rb_get_end(memprot, cur, &prot, &bend)) {
2499-
if(bend>=end) break;
2500-
else {
2501-
cur = bend;
2502-
continue;
2503-
}
2504-
}
2505-
oprot = prot;
2506-
if(bend>end)
2507-
bend = end;
2508-
prot &= ~PROT_NEVERCLEAN;
2509-
if (prot != oprot)
2510-
rb_set(memprot, cur, bend, prot);
2511-
cur = bend;
2512-
}
2513-
UNLOCK_PROT();
2514-
}
2515-
25162486
int isprotectedDB(uintptr_t addr, size_t size)
25172487
{
25182488
dynarec_log(LOG_DEBUG, "isprotectedDB %p -> %p => ", (void*)addr, (void*)(addr+size-1));
@@ -2671,16 +2641,17 @@ void updateProtection(uintptr_t addr, size_t size, uint32_t prot)
26712641
cur = bend;
26722642
continue;
26732643
}
2644+
uint32_t never = dyn & PROT_NEVERCLEAN;
26742645
#ifdef DYNAREC
2675-
if(check && ((prot ^ oprot) & PROT_EXEC)) { // prot_exec changed
2646+
if(check && ((prot ^ oprot) & PROT_EXEC) && !never) { // prot_exec changed
26762647
if(prot & PROT_EXEC) {
2677-
if(!IsAddrMappingLoadAndClean(cur))
2678-
addDBFromAddressRange(cur, bend-cur);
2648+
// no need to do anything
2649+
/*if(!IsAddrMappingLoadAndClean(cur))
2650+
addDBFromAddressRange(cur, bend-cur);*/
26792651
} else
26802652
cleanDBFromAddressRange(cur, bend-cur, (!prot)?1:0);
26812653
}
26822654
#endif
2683-
uint32_t never = dyn & PROT_NEVERCLEAN;
26842655
if(!(never)) {
26852656
if(dyn && (prot&PROT_WRITE)) { // need to remove the write protection from this block
26862657
dyn = PROT_DYNAREC;

src/include/custommem.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ void protectDB(uintptr_t addr, size_t size);
128128
void protectDBJumpTable(uintptr_t addr, size_t size, void* jump, void* ref);
129129
void unprotectDB(uintptr_t addr, size_t size, int mark); // if mark==0, the blocks are not marked as potentially dirty
130130
void neverprotectDB(uintptr_t addr, size_t size, int mark);
131-
void unneverprotectDB(uintptr_t addr, size_t size);
132131
int isprotectedDB(uintptr_t addr, size_t size);
133132
#endif
134133
void* find32bitBlock(size_t size);

0 commit comments

Comments
 (0)