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:
@ -1,8 +1,9 @@
|
||||
// smallobject_cold_iface_v4.h - SmallObject HotHeap v4 Cold Interface (境界 API のみ)
|
||||
// smallobject_cold_iface_v4.h - SmallObject HotHeap v4 Cold Interface (Direct Functions)
|
||||
//
|
||||
// 役割:
|
||||
// - HotBox_v4 と Superslab/Warm/Remote を繋ぐ関数ポインタの箱を定義する。
|
||||
// - 実装は後続フェーズで追加し、いまは型と宣言だけを置く。
|
||||
// - HotBox_v4 と Superslab/Warm/Remote を繋ぐ Cold 側のインターフェース。
|
||||
// - 関数ポインタ(vtable)ではなく direct function で統一。
|
||||
// - Hot Box は以下の関数を直接呼び出す(callback ではなく)。
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
@ -10,17 +11,8 @@
|
||||
|
||||
#include "smallobject_hotbox_v4_box.h"
|
||||
|
||||
typedef struct SmallColdIfaceV4 {
|
||||
small_page_v4* (*refill_page)(small_heap_ctx_v4*, uint32_t class_idx);
|
||||
void (*retire_page)(small_heap_ctx_v4*, uint32_t class_idx, small_page_v4* page);
|
||||
bool (*remote_push)(small_page_v4* page, void* ptr, uint32_t self_tid);
|
||||
void (*remote_drain)(small_heap_ctx_v4*);
|
||||
} SmallColdIfaceV4;
|
||||
|
||||
// Cold iface accessor(実装は後続フェーズ)
|
||||
const SmallColdIfaceV4* small_cold_iface_v4_get(void);
|
||||
|
||||
// Direct function prototypes (Alternative API for direct calls, not yet implemented)
|
||||
// Cold path API: Direct functions (not function pointers)
|
||||
// Hot box から直接呼び出される Cold 側の実装。
|
||||
small_page_v4* small_cold_v4_refill_page(small_heap_ctx_v4* ctx, uint32_t class_idx);
|
||||
void small_cold_v4_retire_page(small_heap_ctx_v4* ctx, small_page_v4* page);
|
||||
bool small_cold_v4_remote_push(small_page_v4* page, void* ptr, uint32_t tid);
|
||||
|
||||
@ -15,10 +15,14 @@
|
||||
#define SMALLOBJECT_NUM_CLASSES TINY_NUM_CLASSES
|
||||
#endif
|
||||
|
||||
struct small_segment_v4;
|
||||
struct SmallSegment; // Forward declaration, defined in smallsegment_v4_box.h
|
||||
|
||||
// Page metadata for v4 HotBox
|
||||
typedef struct small_page_v4 {
|
||||
// ============================================================================
|
||||
// SmallObject v4 HotBox Type Definitions
|
||||
// ============================================================================
|
||||
|
||||
// SmallPageMeta: Page metadata for v4 HotBox
|
||||
typedef struct SmallPageMeta {
|
||||
void* freelist;
|
||||
uint16_t used;
|
||||
uint16_t capacity;
|
||||
@ -26,29 +30,28 @@ typedef struct small_page_v4 {
|
||||
uint8_t flags;
|
||||
uint32_t block_size;
|
||||
uint8_t* base;
|
||||
void* slab_ref; // Superslab / lease token (box境界で扱う)
|
||||
struct small_segment_v4* segment; // PF3: segment owner(NULLなら Tiny v1 経路)
|
||||
struct small_page_v4* next;
|
||||
} small_page_v4;
|
||||
void* slab_ref; // Superslab / lease token (box boundary)
|
||||
struct SmallSegment* segment; // Segment owner (NULL if Tiny v1 path)
|
||||
struct SmallPageMeta* next;
|
||||
} SmallPageMeta;
|
||||
|
||||
// Per-class heap state (current / partial / full lists)
|
||||
typedef struct small_class_heap_v4 {
|
||||
small_page_v4* current;
|
||||
small_page_v4* partial_head;
|
||||
small_page_v4* full_head;
|
||||
// SmallClassHeap: Per-class heap state (current / partial / full lists)
|
||||
typedef struct SmallClassHeap {
|
||||
SmallPageMeta* current;
|
||||
SmallPageMeta* partial_head;
|
||||
SmallPageMeta* full_head;
|
||||
uint32_t partial_count;
|
||||
} small_class_heap_v4;
|
||||
} SmallClassHeap;
|
||||
|
||||
// TLS heap context (per-thread)
|
||||
typedef struct small_heap_ctx_v4 {
|
||||
small_class_heap_v4 cls[SMALLOBJECT_NUM_CLASSES];
|
||||
} small_heap_ctx_v4;
|
||||
// SmallHeapCtx: TLS heap context (per-thread)
|
||||
typedef struct SmallHeapCtx {
|
||||
SmallClassHeap cls[SMALLOBJECT_NUM_CLASSES];
|
||||
} SmallHeapCtx;
|
||||
|
||||
// TLS accessor (実装は後続フェーズで追加)
|
||||
// SmallPageMeta を external で使う場合のエイリアス
|
||||
typedef small_page_v4 SmallPageMeta;
|
||||
typedef small_class_heap_v4 SmallClassHeap;
|
||||
typedef small_heap_ctx_v4 SmallHeapCtx;
|
||||
// Backward compatibility aliases (deprecated, use SmallXxx directly)
|
||||
typedef SmallPageMeta small_page_v4;
|
||||
typedef SmallClassHeap small_class_heap_v4;
|
||||
typedef SmallHeapCtx small_heap_ctx_v4;
|
||||
|
||||
small_heap_ctx_v4* small_heap_ctx_v4_get(void);
|
||||
|
||||
|
||||
@ -4,23 +4,29 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Forward declaration for SmallPageMeta
|
||||
struct small_page_v4;
|
||||
// Forward declaration
|
||||
struct SmallPageMeta;
|
||||
|
||||
// ============================================================================
|
||||
// SmallSegment: class_idx ごとに小さな segment を管理
|
||||
// 基本構造: base, page metadata array
|
||||
typedef struct small_segment_v4 {
|
||||
// ============================================================================
|
||||
|
||||
typedef struct SmallSegment {
|
||||
uintptr_t base; // Segment base address
|
||||
uint32_t num_pages; // Number of pages in segment
|
||||
uint32_t owner_tid; // Thread ID that owns this segment
|
||||
uint32_t magic; // Magic number for validation
|
||||
// Page metadata array (flexible, actual size depends on SMALL_PAGE_SIZE / SMALL_SEGMENT_SIZE)
|
||||
// struct small_page_v4* page_meta[];
|
||||
} small_segment_v4;
|
||||
// struct SmallPageMeta* page_meta[];
|
||||
} SmallSegment;
|
||||
|
||||
// API: Segment 取得・解放
|
||||
small_segment_v4* smallsegment_v4_acquire(int class_idx);
|
||||
void smallsegment_v4_release_if_empty(small_segment_v4* seg, void* page, int class_idx);
|
||||
// Backward compatibility alias
|
||||
typedef SmallSegment small_segment_v4;
|
||||
|
||||
// API: ページメタデータの取得
|
||||
struct small_page_v4* smallsegment_v4_page_meta_of(small_segment_v4* seg, void* ptr);
|
||||
// ============================================================================
|
||||
// API: Segment Management
|
||||
// ============================================================================
|
||||
|
||||
SmallSegment* smallsegment_v4_acquire(int class_idx);
|
||||
void smallsegment_v4_release_if_empty(SmallSegment* seg, void* page, int class_idx);
|
||||
struct SmallPageMeta* smallsegment_v4_page_meta_of(SmallSegment* seg, void* ptr);
|
||||
|
||||
Reference in New Issue
Block a user