From c5ced39665e7ba2a09c936ffb4cf80ca4f843e28 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 9 Nov 2024 14:02:38 +0100 Subject: [DYNAREC] Only test page protection when needed (and using a fester way) (should address the performance regression of #2009) --- src/custommem.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/custommem.c') diff --git a/src/custommem.c b/src/custommem.c index 3f067148..3307335e 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -440,6 +440,7 @@ static uint32_t defered_prot_prot = 0; static sigset_t critical_prot = {0}; #define LOCK_PROT() sigset_t old_sig = {0}; pthread_sigmask(SIG_BLOCK, &critical_prot, &old_sig); mutex_lock(&mutex_prot) #define LOCK_PROT_READ() sigset_t old_sig = {0}; pthread_sigmask(SIG_BLOCK, &critical_prot, &old_sig); mutex_lock(&mutex_prot) +#define LOCK_PROT_FAST() mutex_lock(&mutex_prot) #define UNLOCK_PROT() if(defered_prot_p) { \ uintptr_t p = defered_prot_p; size_t sz = defered_prot_sz; uint32_t prot = defered_prot_prot; \ defered_prot_p = 0; \ @@ -451,6 +452,7 @@ static sigset_t critical_prot = {0}; mutex_unlock(&mutex_prot); \ } #define UNLOCK_PROT_READ() mutex_unlock(&mutex_prot); pthread_sigmask(SIG_SETMASK, &old_sig, NULL) +#define UNLOCK_PROT_FAST() mutex_unlock(&mutex_prot) #ifdef TRACE_MEMSTAT @@ -1642,6 +1644,14 @@ uint32_t getProtection(uintptr_t addr) return ret; } +uint32_t getProtection_fast(uintptr_t addr) +{ + LOCK_PROT_FAST(); + uint32_t ret = rb_get(memprot, addr); + UNLOCK_PROT_FAST(); + return ret; +} + int getMmapped(uintptr_t addr) { return rb_get(mmapmem, addr); -- cgit 1.4.1