about summary refs log tree commit diff stats
path: root/src/include
diff options
context:
space:
mode:
authorrajdakin <rajdakin@gmail.com>2023-12-31 15:49:57 +0100
committerGitHub <noreply@github.com>2023-12-31 15:49:57 +0100
commit5e9e1faedc97194e46f3fb4b3665ec416ce7efbf (patch)
tree27d345328502d82ede6c58e3d181d1f682bab255 /src/include
parentdba6a88341bacbf52d0f0c37117a04164afce9fa (diff)
downloadbox64-5e9e1faedc97194e46f3fb4b3665ec416ce7efbf.tar.gz
box64-5e9e1faedc97194e46f3fb4b3665ec416ce7efbf.zip
[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
Diffstat (limited to 'src/include')
-rw-r--r--src/include/custommem.h13
-rw-r--r--src/include/debug.h2
-rw-r--r--src/include/rbtree.h13
3 files changed, 18 insertions, 10 deletions
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 <stdint.h>
+
+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