Phase 19-3b: pass down env snapshot in hot paths
This commit is contained in:
@ -21,18 +21,11 @@
|
||||
// - Returns: void (always succeeds or falls back to tiny_hot_free_fast)
|
||||
//
|
||||
__attribute__((always_inline))
|
||||
static inline void tiny_legacy_fallback_free_base(void* base, uint32_t class_idx) {
|
||||
// Phase 4 E1: Use ENV snapshot when enabled (consolidates 3 TLS reads → 1)
|
||||
const TinyFrontV3Snapshot* front_snap;
|
||||
bool metadata_cache_on;
|
||||
if (__builtin_expect(hakmem_env_snapshot_enabled(), 0)) {
|
||||
const HakmemEnvSnapshot* env = hakmem_env_snapshot();
|
||||
front_snap = env->tiny_front_v3_enabled ? tiny_front_v3_snapshot_get() : NULL;
|
||||
metadata_cache_on = env->tiny_metadata_cache_eff; // Uses effective (cache && !learner)
|
||||
} else {
|
||||
front_snap = __builtin_expect(tiny_front_v3_enabled(), 0) ? tiny_front_v3_snapshot_get() : NULL;
|
||||
metadata_cache_on = tiny_metadata_cache_enabled();
|
||||
}
|
||||
static inline void tiny_legacy_fallback_free_base_with_env(void* base, uint32_t class_idx, const HakmemEnvSnapshot* env) {
|
||||
const TinyFrontV3Snapshot* front_snap =
|
||||
env ? (env->tiny_front_v3_enabled ? tiny_front_v3_snapshot_get() : NULL)
|
||||
: (__builtin_expect(tiny_front_v3_enabled(), 0) ? tiny_front_v3_snapshot_get() : NULL);
|
||||
const bool metadata_cache_on = env ? env->tiny_metadata_cache_eff : tiny_metadata_cache_enabled();
|
||||
|
||||
// Phase 3 C2 Patch 2: First page cache hint (optional fast-path)
|
||||
// Check if pointer is in cached page (avoids metadata lookup in future optimizations)
|
||||
@ -64,4 +57,10 @@ static inline void tiny_legacy_fallback_free_base(void* base, uint32_t class_idx
|
||||
tiny_hot_free_fast(class_idx, base);
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline void tiny_legacy_fallback_free_base(void* base, uint32_t class_idx) {
|
||||
const HakmemEnvSnapshot* env = hakmem_env_snapshot_enabled() ? hakmem_env_snapshot() : NULL;
|
||||
tiny_legacy_fallback_free_base_with_env(base, class_idx, env);
|
||||
}
|
||||
|
||||
#endif // HAKMEM_TINY_LEGACY_FALLBACK_BOX_H
|
||||
|
||||
Reference in New Issue
Block a user