Phase V6-HDR-0: C6-only headerless core 設計確定
- CURRENT_TASK.md: V6-HDR-0 セクション追加(4層 Box Theory) - SMALLOBJECT_CORE_V6_DESIGN.md: V6-HDR-0 設計方針追加 - REGIONID_V6_DESIGN.md: RegionIdBox 設計書新規作成 - smallobject_core_v6_box.h: SmallTlsLaneV6 型+TLS API 追加 - smallobject_core_v6.c: OBSERVE モード追加 - region_id_v6_box.h: RegionIdBox 型スケルトン - page_stats_v6_box.h: PageStatsV6 箱スケルトン - AGENTS.md: v6 研究箱ルールセクション追加 サニティベンチ: Mixed 42.1M, C6-heavy 25.0M(挙動不変確認) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -1,7 +1,10 @@
|
||||
// smallobject_core_v6.c - SmallObject Core v6 実装(Phase v6-3)
|
||||
// smallobject_core_v6.c - SmallObject Core v6 実装
|
||||
//
|
||||
// Phase V6-HDR-0: C6-only headerless core with OBSERVE mode
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "box/smallobject_core_v6_box.h"
|
||||
#include "box/smallobject_cold_iface_v6.h"
|
||||
#include "box/smallsegment_v6_box.h"
|
||||
@ -12,6 +15,31 @@
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
// OBSERVE Mode (V6-HDR-0)
|
||||
// ============================================================================
|
||||
// ENV: HAKMEM_SMALL_V6_OBSERVE=1 enables logging at free entry
|
||||
|
||||
#define V6_OBSERVE_UNINIT (-1)
|
||||
#define V6_OBSERVE_OFF 0
|
||||
#define V6_OBSERVE_ON 1
|
||||
|
||||
static int g_v6_observe = V6_OBSERVE_UNINIT;
|
||||
|
||||
static inline int small_v6_observe_enabled(void) {
|
||||
if (unlikely(g_v6_observe == V6_OBSERVE_UNINIT)) {
|
||||
const char* env = getenv("HAKMEM_SMALL_V6_OBSERVE");
|
||||
g_v6_observe = (env && env[0] == '1') ? V6_OBSERVE_ON : V6_OBSERVE_OFF;
|
||||
}
|
||||
return g_v6_observe == V6_OBSERVE_ON;
|
||||
}
|
||||
|
||||
/// Log free entry (called when OBSERVE=1)
|
||||
static void small_v6_observe_free(void* ptr, uint32_t class_idx, int tls_owned) {
|
||||
fprintf(stderr, "[V6_OBSERVE] free ptr=%p class=%u tls_owned=%d\n",
|
||||
ptr, class_idx, tls_owned);
|
||||
}
|
||||
|
||||
// TLS context
|
||||
static __thread struct SmallHeapCtxV6 g_small_heap_ctx_v6;
|
||||
static __thread int g_small_heap_ctx_v6_init = 0;
|
||||
@ -250,8 +278,14 @@ void small_free_fast_v6(void* ptr,
|
||||
// Convert USER pointer to BASE pointer
|
||||
void* base = SMALL_V6_BASE_FROM_USER(ptr);
|
||||
|
||||
// V6-HDR-0: OBSERVE mode logging (check TLS ownership first for log)
|
||||
int tls_owned = small_tls_owns_ptr_v6(ctx, ptr);
|
||||
if (unlikely(small_v6_observe_enabled())) {
|
||||
small_v6_observe_free(ptr, class_idx, tls_owned);
|
||||
}
|
||||
|
||||
// Fast path: TLS segment ownership + TLS push
|
||||
if (likely(small_tls_owns_ptr_v6(ctx, ptr))) {
|
||||
if (likely(tls_owned)) {
|
||||
// C6 TLS push
|
||||
if (class_idx == SMALL_V6_C6_CLASS_IDX && ctx->tls_count_c6 < SMALL_V6_TLS_CAP) {
|
||||
ctx->tls_freelist_c6[ctx->tls_count_c6++] = base;
|
||||
|
||||
Reference in New Issue
Block a user