From 5e9e1faedc97194e46f3fb4b3665ec416ce7efbf Mon Sep 17 00:00:00 2001 From: rajdakin Date: Sun, 31 Dec 2023 15:49:57 +0100 Subject: [MEMORY] Switched from a sparse array to a red-black tree (#1180) * [MEMORY] Switched from a sparse array to an RB tree * [RBTREE] Fixed the Android build --- src/include/custommem.h | 13 +++++-------- src/include/debug.h | 2 -- src/include/rbtree.h | 13 +++++++++++++ 3 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 src/include/rbtree.h (limited to 'src/include') diff --git a/src/include/custommem.h b/src/include/custommem.h index 60fabcea..363c3274 100644 --- a/src/include/custommem.h +++ b/src/include/custommem.h @@ -75,22 +75,19 @@ uintptr_t getJumpAddress64(uintptr_t addr); #define PROT_CUSTOM (PROT_DYNAREC | PROT_DYNAREC_R | PROT_NOPROT) #define PROT_WAIT 0xFF -void updateProtection(uintptr_t addr, size_t size, uint32_t prot); -void setProtection(uintptr_t addr, size_t size, uint32_t prot); -void setProtection_mmap(uintptr_t addr, size_t size, uint32_t prot); -void setProtection_elf(uintptr_t addr, size_t size, uint32_t prot); +void updateProtection(uintptr_t addr, size_t size, uint8_t prot); +void setProtection(uintptr_t addr, size_t size, uint8_t prot); +void setProtection_mmap(uintptr_t addr, size_t size, uint8_t prot); +void setProtection_elf(uintptr_t addr, size_t size, uint8_t prot); void freeProtection(uintptr_t addr, size_t size); void refreshProtection(uintptr_t addr); -uint32_t getProtection(uintptr_t addr); +uint8_t getProtection(uintptr_t addr); int getMmapped(uintptr_t addr); void loadProtectionFromMap(void); #ifdef DYNAREC void protectDB(uintptr_t addr, size_t size); void unprotectDB(uintptr_t addr, size_t size, int mark); // if mark==0, the blocks are not marked as potentially dirty int isprotectedDB(uintptr_t addr, size_t size); -int IsInHotPage(uintptr_t addr); -int AreaInHotPage(uintptr_t start, uintptr_t end); -void AddHotPage(uintptr_t addr); #endif void* find32bitBlock(size_t size); void* find31bitBlockNearHint(void* hint, size_t size, uintptr_t mask); diff --git a/src/include/debug.h b/src/include/debug.h index 4ce68cb9..08018633 100644 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -27,8 +27,6 @@ extern int box64_dynarec_callret; extern int box64_dynarec_bleeding_edge; extern int box64_dynarec_jvm; extern int box64_dynarec_tbb; -extern int box64_dynarec_hotpage; -extern int box64_dynarec_fastpage; extern int box64_dynarec_wait; extern int box64_dynarec_missing; extern int box64_dynarec_aligned_atomics; diff --git a/src/include/rbtree.h b/src/include/rbtree.h new file mode 100644 index 00000000..a624b5da --- /dev/null +++ b/src/include/rbtree.h @@ -0,0 +1,13 @@ +#include + +typedef struct rbtree rbtree; + +rbtree* init_rbtree(); +void delete_rbtree(rbtree *tree); + +uint8_t rb_get(rbtree *tree, uintptr_t addr); +int rb_get_end(rbtree* tree, uintptr_t addr, uint8_t* val, uintptr_t* end); +int rb_set(rbtree *tree, uintptr_t start, uintptr_t end, uint8_t data); +int rb_unset(rbtree *tree, uintptr_t start, uintptr_t end); + +void print_rbtree(const rbtree *tree); \ No newline at end of file -- cgit 1.4.1