diff --git a/core/box/tiny_front_config_box.h b/core/box/tiny_front_config_box.h index 1950ae17..cbb665e2 100644 --- a/core/box/tiny_front_config_box.h +++ b/core/box/tiny_front_config_box.h @@ -90,7 +90,7 @@ static inline int tiny_fastcache_enabled(void) { return g_fastcache_enable; } -static inline int sfc_cascade_enabled(void) { +static inline int tiny_sfc_enabled(void) { extern int g_sfc_enabled; return g_sfc_enabled; } @@ -104,7 +104,7 @@ static inline int tiny_tls_sll_enabled(void) { // These expand to actual function calls in normal mode #define TINY_FRONT_ULTRA_SLIM_ENABLED ultra_slim_mode_enabled() #define TINY_FRONT_HEAP_V2_ENABLED tiny_heap_v2_enabled() -#define TINY_FRONT_SFC_ENABLED sfc_cascade_enabled() +#define TINY_FRONT_SFC_ENABLED tiny_sfc_enabled() #define TINY_FRONT_FASTCACHE_ENABLED tiny_fastcache_enabled() #define TINY_FRONT_TLS_SLL_ENABLED tiny_tls_sll_enabled() #define TINY_FRONT_UNIFIED_GATE_ENABLED front_gate_unified_enabled() diff --git a/core/hakmem_tiny_free.inc b/core/hakmem_tiny_free.inc index b1cc9e81..db9c9359 100644 --- a/core/hakmem_tiny_free.inc +++ b/core/hakmem_tiny_free.inc @@ -229,7 +229,8 @@ void hak_tiny_free_with_slab(void* ptr, TinySlab* slab) { } // Front-V2: try to return to TLS magazine first (A/B, default OFF) - if (__builtin_expect(tiny_heap_v2_enabled() && class_idx <= 3, 0)) { + // Phase 7-Step8: Use config macro for dead code elimination in PGO mode + if (__builtin_expect(TINY_FRONT_HEAP_V2_ENABLED && class_idx <= 3, 0)) { void* base = (void*)((uint8_t*)ptr - 1); if (tiny_heap_v2_try_push(class_idx, base)) { tiny_debug_ring_record(TINY_RING_EVENT_FREE_FAST, (uint16_t)class_idx, ptr, slab_idx); diff --git a/core/tiny_alloc_fast.inc.h b/core/tiny_alloc_fast.inc.h index 1200addc..6f461573 100644 --- a/core/tiny_alloc_fast.inc.h +++ b/core/tiny_alloc_fast.inc.h @@ -270,7 +270,8 @@ static inline void* tiny_heap_v2_alloc_by_class(int class_idx) { // FIX: Ensure TLS is initialized before first magazine access tiny_heap_v2_ensure_init(); if (class_idx < 0 || class_idx > 3) return NULL; - if (!tiny_heap_v2_enabled()) return NULL; + // Phase 7-Step8: Use config macro for dead code elimination in PGO mode + if (!TINY_FRONT_HEAP_V2_ENABLED) return NULL; if (!tiny_heap_v2_class_enabled(class_idx)) return NULL; TinyHeapV2Mag* mag = &g_tiny_heap_v2_mag[class_idx]; @@ -424,11 +425,11 @@ static inline void* tiny_alloc_fast_pop(int class_idx) { } // Box 5-NEW: Layer 0 - Try SFC first (if enabled) - // Cache g_sfc_enabled in TLS to avoid global load on every allocation + // Phase 7-Step8: Use config macro for dead code elimination in PGO mode static __thread int sfc_check_done = 0; static __thread int sfc_is_enabled = 0; if (__builtin_expect(!sfc_check_done, 0)) { - sfc_is_enabled = g_sfc_enabled; + sfc_is_enabled = TINY_FRONT_SFC_ENABLED; sfc_check_done = 1; } @@ -674,7 +675,8 @@ static inline int tiny_alloc_fast_refill(int class_idx) { } // Only cascade if explicitly enabled AND we have refilled blocks in SLL - if (sfc_cascade_enabled && g_sfc_enabled && refilled > 0) { + // Phase 7-Step8: Use config macro for dead code elimination in PGO mode + if (sfc_cascade_enabled && TINY_FRONT_SFC_ENABLED && refilled > 0) { // Transfer half of refilled blocks to SFC (keep half in SLL for future) int sfc_target = refilled / 2; if (sfc_target > 0) { @@ -734,7 +736,8 @@ static inline void* tiny_alloc_fast(size_t size) { #if !HAKMEM_BUILD_RELEASE static __thread int debug_checked = 0; if (!debug_checked) { - int enabled = ultra_slim_mode_enabled(); + // Phase 7-Step8: Use config macro for dead code elimination in PGO mode + int enabled = TINY_FRONT_ULTRA_SLIM_ENABLED; if (enabled) { fprintf(stderr, "[TINY_ALLOC_FAST] Ultra SLIM gate: ENABLED (will use 4-layer path)\n"); } else {