From 268f892343c23e94f01bf1db6bad2e55b8ca2a21 Mon Sep 17 00:00:00 2001 From: "Moe Charm (CI)" Date: Thu, 4 Dec 2025 11:19:56 +0900 Subject: [PATCH] Centralize layout calculations: Use tiny_user_offset() instead of hardcoded -1 offset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Modified core/tiny_free_fast.inc.h to use tiny_user_offset(legacy_class) - Eliminates hardcoded -1 offset in legacy TinySlab free path - Aligns with layout box refactoring: single source of truth in tiny_layout_box.h - Verified: smoke test passes, sh8bench runs for 120+ seconds without segfault This completes the layout box consolidation migration for the free fast path. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- core/tiny_free_fast.inc.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/tiny_free_fast.inc.h b/core/tiny_free_fast.inc.h index 2858428b..f5fa5c09 100644 --- a/core/tiny_free_fast.inc.h +++ b/core/tiny_free_fast.inc.h @@ -241,8 +241,10 @@ static inline void tiny_free_fast(void* ptr) { // 2. Legacy TinySlab-backed pointer? TinySlab* slab = hak_tiny_owner_slab(ptr); if (__builtin_expect(slab != NULL, 0)) { - // Convert USER → BASE (for Legacy path) - void* base_legacy = (void*)((uint8_t*)ptr - 1); + // Convert USER → BASE (for Legacy path) using centralized layout + int legacy_class = slab->class_idx; + size_t user_off = tiny_user_offset(legacy_class); + void* base_legacy = (void*)((uint8_t*)ptr - user_off); // Box 6 Boundary: Try same-thread fast path // CRITICAL: Pass BASE pointer (already converted above)