Cleanup: Unify type naming and Cold Iface architecture
Refactoring: - Type naming: Rename small_page_v4 → SmallPageMeta, small_class_heap_v4 → SmallClassHeap, small_heap_ctx_v4 → SmallHeapCtx - Keep backward compatibility aliases for existing code - SmallSegment struct unified, clean forward declarations - Cold Iface: Remove vtable (SmallColdIfaceV4 struct) in favor of direct function calls - Simplify refill_page/retire_page to direct calls, not callbacks - smallobject_hotbox_v4.c: Update to call small_cold_v4_* functions directly Documentation: - Add docs/analysis/ENV_CLEANUP_CANDIDATES.md - Categorize ENVs: KEEP (production), RESEARCH (opt-in), DELETE (obsolete) - v2 code: Keep as research infrastructure (complete, safe, gated) - v4 code: Research scaffold for future mid-level allocator Build: - ビルド成功(警告のみ) - Backward compatible, all existing code still works 🤖 Generated with Claude Code Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -248,40 +248,24 @@ static void cold_retire_page_v4(small_heap_ctx_v4* hot_ctx, uint32_t class_idx,
|
||||
free(page);
|
||||
}
|
||||
|
||||
static const SmallColdIfaceV4 g_cold_iface_v4 = {
|
||||
.refill_page = cold_refill_page_v4,
|
||||
.retire_page = cold_retire_page_v4,
|
||||
.remote_push = NULL,
|
||||
.remote_drain = NULL,
|
||||
};
|
||||
|
||||
const SmallColdIfaceV4* small_cold_iface_v4_get(void) {
|
||||
return &g_cold_iface_v4;
|
||||
}
|
||||
|
||||
// Direct function stubs (phase v4-mid-0: delegates to iface)
|
||||
// Direct function implementations (phase v4-mid-0: cold_refill/retire を直接呼び出す)
|
||||
small_page_v4* small_cold_v4_refill_page(small_heap_ctx_v4* ctx, uint32_t class_idx) {
|
||||
const SmallColdIfaceV4* iface = small_cold_iface_v4_get();
|
||||
if (!iface || !iface->refill_page) return NULL;
|
||||
return iface->refill_page(ctx, class_idx);
|
||||
return cold_refill_page_v4(ctx, class_idx);
|
||||
}
|
||||
|
||||
void small_cold_v4_retire_page(small_heap_ctx_v4* ctx, small_page_v4* page) {
|
||||
const SmallColdIfaceV4* iface = small_cold_iface_v4_get();
|
||||
if (!iface || !iface->retire_page || !page) return;
|
||||
iface->retire_page(ctx, (uint32_t)page->class_idx, page);
|
||||
if (!page) return;
|
||||
cold_retire_page_v4(ctx, (uint32_t)page->class_idx, page);
|
||||
}
|
||||
|
||||
bool small_cold_v4_remote_push(small_page_v4* page, void* ptr, uint32_t tid) {
|
||||
const SmallColdIfaceV4* iface = small_cold_iface_v4_get();
|
||||
if (!iface || !iface->remote_push) return false;
|
||||
return iface->remote_push(page, ptr, tid);
|
||||
(void)page; (void)ptr; (void)tid;
|
||||
return false; // stub: not yet implemented
|
||||
}
|
||||
|
||||
void small_cold_v4_remote_drain(small_heap_ctx_v4* ctx) {
|
||||
const SmallColdIfaceV4* iface = small_cold_iface_v4_get();
|
||||
if (!iface || !iface->remote_drain) return;
|
||||
iface->remote_drain(ctx);
|
||||
(void)ctx;
|
||||
// stub: not yet implemented
|
||||
}
|
||||
|
||||
// Stub accessor for smallsegment_v4_page_meta_of
|
||||
@ -321,9 +305,8 @@ static small_page_v4* small_alloc_slow_v4(small_heap_ctx_v4* ctx, int class_idx)
|
||||
return from_partial;
|
||||
}
|
||||
|
||||
const SmallColdIfaceV4* cold = small_cold_iface_v4_get();
|
||||
if (!cold || !cold->refill_page) return NULL;
|
||||
small_page_v4* page = cold->refill_page(ctx, (uint32_t)class_idx);
|
||||
// Call direct Cold function (not vtable)
|
||||
small_page_v4* page = small_cold_v4_refill_page(ctx, (uint32_t)class_idx);
|
||||
if (!page) return NULL;
|
||||
h->current = page;
|
||||
return page;
|
||||
@ -400,7 +383,6 @@ void small_heap_free_fast_v4(small_heap_ctx_v4* ctx, int class_idx, void* ptr) {
|
||||
}
|
||||
|
||||
if (page->used == 0) {
|
||||
const SmallColdIfaceV4* cold = small_cold_iface_v4_get();
|
||||
if (loc != V4_LOC_CURRENT) {
|
||||
v4_unlink_from_list(h, loc, prev, page);
|
||||
}
|
||||
@ -417,11 +399,8 @@ void small_heap_free_fast_v4(small_heap_ctx_v4* ctx, int class_idx, void* ptr) {
|
||||
v4_page_push_partial(h, page);
|
||||
return;
|
||||
}
|
||||
if (cold && cold->retire_page) {
|
||||
cold->retire_page(ctx, (uint32_t)class_idx, page);
|
||||
} else {
|
||||
free(page);
|
||||
}
|
||||
// Call direct Cold function (not vtable)
|
||||
small_cold_v4_retire_page(ctx, page);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user