about summary refs log tree commit diff stats
path: root/src/tools/rbtree.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Add O(1) early-out to eusing cached bounds (#2901)Chi-Kuan Chiu2025-08-051-2/+6
| | | | | | | | | | | | | | Add a fast-path in rb_get() and rb_get_64() that checks the tree’s cached leftmost->start and rightmost->end bounds before calling find_addr(). If the query address lies outside the address bounds, we return 0 immediately, avoiding an unnecessary tree walk. This mirrors the idea used in jserv/rbtree’s rb_cached_contains(), using cached min/max to short-circuit lookups. Behavior is unchanged (both functions still return 0 when not found); only negative lookups become cheaper. Co-authored-by: Jim Huang <jserv@ccns.ncku.edu.tw>
* Refine the naming scheme in rbtree (#2717)Chi-Kuan Chiu2025-06-091-22/+22
| | | | | | | | | | | | | Replaced all occurrences of `rb_get_righter` with `rb_get_rightmost` and `rb_get_lefter` with `rb_get_leftmost` for improved semantic clarity. Also updated related function declarations, definitions, and usage across: - rbtree.c - rbtree.h - custommem.c - dynablock.c - env.c - box64context.c
* [RBTREE] Fixed an edge case (#2562)rajdakin2025-04-221-1/+3
|
* [RBTREE] Cache boundary nodes and remove `add_range()` (#2557)Chi-Kuan Chiu2025-04-221-31/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Cache leftmost and rightmost node Add two fields to `rbtree`: `lefter` and `righter`, to cache the leftmost and rightmost nodes respectively. This eliminates the need for O(log N) traversals in `rb_get_lefter()` and `rb_get_righter()`. Motivated by the Linux kernel's use of cached pointers for `rb_first()` and `rb_last()`, this change improves efficiency of boundary queries by replacing repeated tree walks with direct pointer dereference. Experiment: running `chess.exe` with Box64 + Wine (#2511) - ~3,500 insertions into the tree - 607 lightweight cache updates (single assignment) - 397 full tree traversals avoided This results in reduced runtime overhead for boundary checks, with memory cost (+2 pointer per tree). Expected benefits increase in larger or more dynamic workloads. Ref: https://docs.kernel.org/core-api/rbtree.html * Remove redundant add_range() wrapper The function `add_range()` was only called when `tree->root == NULL`. In such cases, the while-loop inside `add_range()` never runs, resulting in a call to `add_range_next_to()` with `prev == NULL`. Replaced it with direct calls to `add_range_next_to(tree, NULL, ...)`.
* [DEBUG] Exposed a debug function to print an rbtreeptitSeb2025-04-201-20/+24
|
* Eliminated many compilation warnings (#2535)Yang Liu2025-04-151-1/+2
|
* [DYNAREC] Improved handling of db_size rbtreeptitSeb2025-04-091-0/+310
|
* Improved file map tracking, and use file map info in dynarec for bigblock ↵ptitSeb2025-01-271-0/+14
| | | | setting
* Added more rbtrees in dynarec managment, to speedup ↵ptitSeb2024-12-231-5/+39
| | | | FindDynablockFromNativeAddress function
* [TRACE] Use lower case hex on rbtreeptitSeb2024-11-171-6/+6
|
* [RBTREE] Unify naming and prevent unintended symbol exposure (#2005)Jim Huang2024-11-061-71/+70
| | | | | Red-black tree operations now consistently use the 'rbtree_' prefix, and internal functions remain unexposed. Tested on RV64GC, resulting in a 498-byte reduction in the .text section size.
* [rebree]The name of rbtree is set error. (#1984)zymayunyan2024-10-311-1/+1
|
* Improve debugging trace of rb_treeptitSeb2024-10-081-5/+7
|
* [DYNAREC] Improved trace a bitptitSeb2024-02-011-1/+1
|
* [DYNAREC] use an rbtree for dynablock size and max_db_size updateptitSeb2024-01-231-0/+14
|
* Ficxed an issue with rbtree rb_get_end utility functionptitSeb2024-01-161-3/+4
|
* [RBTREE] Reverted memory tracking to 32 bits (#1201)rajdakin2024-01-131-9/+9
|
* Fixed issue on rbtree on rb_get_end when end is another blockptitSeb2023-12-311-13/+19
|
* [MEMORY] Switched from a sparse array to a red-black tree (#1180)rajdakin2023-12-311-0/+894
* [MEMORY] Switched from a sparse array to an RB tree * [RBTREE] Fixed the Android build