Implement Phase 2: Headerless Allocator Support (Partial)

- Feature: Added HAKMEM_TINY_HEADERLESS toggle (A/B testing)
- Feature: Implemented Headerless layout logic (Offset=0)
- Refactor: Centralized layout definitions in tiny_layout_box.h
- Refactor: Abstracted pointer arithmetic in free path via ptr_conversion_box.h
- Verification: sh8bench passes in Headerless mode (No TLS_SLL_HDR_RESET)
- Known Issue: Regression in Phase 1 mode due to blind pointer conversion logic
This commit is contained in:
Moe Charm (CI)
2025-12-03 12:11:27 +09:00
parent 2f09f3cba8
commit c2716f5c01
18 changed files with 183 additions and 33 deletions

View File

@ -80,6 +80,7 @@ static inline int safe_header_probe(void* ptr) {
return -1;
}
#if HAKMEM_TINY_HEADER_CLASSIDX
// Safe to read header (same page guaranteed)
uint8_t* header_ptr = (uint8_t*)ptr - 1;
uint8_t header = *header_ptr;
@ -98,6 +99,9 @@ static inline int safe_header_probe(void* ptr) {
}
return class_idx;
#else
return -1;
#endif
}
// ========== Registry Lookup ==========
@ -200,6 +204,7 @@ ptr_classification_t classify_ptr(void* ptr) {
uint8_t magic = header & 0xF0;
// Fast path: Tiny allocation (magic = 0xa0) — guarded by Superslab registry
#if HAKMEM_TINY_HEADER_CLASSIDX
if (magic == HEADER_MAGIC) { // HEADER_MAGIC = 0xa0
int class_idx = header & HEADER_CLASS_MASK;
if (class_idx >= 0 && class_idx < TINY_NUM_CLASSES) {
@ -219,6 +224,7 @@ ptr_classification_t classify_ptr(void* ptr) {
}
}
}
#endif
#ifdef HAKMEM_POOL_TLS_PHASE1
// Fast path: Pool TLS allocation (magic = 0xb0)