about summary refs log tree commit diff stats
path: root/src/custommem.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-11-09 14:02:38 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-11-09 14:02:45 +0100
commitc5ced39665e7ba2a09c936ffb4cf80ca4f843e28 (patch)
treea0e7992f703fc2c71dc60538d28bb8b8d15cb611 /src/custommem.c
parent7b2e77807dc46480986ddbbd053a5aa983e150d1 (diff)
downloadbox64-c5ced39665e7ba2a09c936ffb4cf80ca4f843e28.tar.gz
box64-c5ced39665e7ba2a09c936ffb4cf80ca4f843e28.zip
[DYNAREC] Only test page protection when needed (and using a fester way) (should address the performance regression of #2009)
Diffstat (limited to 'src/custommem.c')
-rw-r--r--src/custommem.c10
1 files changed, 10 insertions, 0 deletions
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);