2025-12-10 17:58:42 +09:00
|
|
|
// smallobject_hotbox_v4_box.h - SmallObject HotHeap v4 (型スケルトン)
|
|
|
|
|
//
|
|
|
|
|
// 役割:
|
|
|
|
|
// - v4 のページ / クラス / TLS コンテキスト型と API 宣言だけを定義する箱。
|
|
|
|
|
// - 挙動はまだ v3/v1 のまま。alloc/free 本体は後続フェーズで実装する。
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2025-12-10 19:14:38 +09:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdint.h>
|
2025-12-10 17:58:42 +09:00
|
|
|
|
|
|
|
|
#include "tiny_geometry_box.h"
|
|
|
|
|
|
|
|
|
|
#ifndef SMALLOBJECT_NUM_CLASSES
|
|
|
|
|
#define SMALLOBJECT_NUM_CLASSES TINY_NUM_CLASSES
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-12-10 23:30:32 +09:00
|
|
|
struct SmallSegment; // Forward declaration, defined in smallsegment_v4_box.h
|
2025-12-10 22:57:26 +09:00
|
|
|
|
2025-12-10 23:30:32 +09:00
|
|
|
// ============================================================================
|
|
|
|
|
// SmallObject v4 HotBox Type Definitions
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
// SmallPageMeta: Page metadata for v4 HotBox
|
|
|
|
|
typedef struct SmallPageMeta {
|
2025-12-10 17:58:42 +09:00
|
|
|
void* freelist;
|
|
|
|
|
uint16_t used;
|
|
|
|
|
uint16_t capacity;
|
|
|
|
|
uint8_t class_idx;
|
|
|
|
|
uint8_t flags;
|
|
|
|
|
uint32_t block_size;
|
|
|
|
|
uint8_t* base;
|
2025-12-10 23:30:32 +09:00
|
|
|
void* slab_ref; // Superslab / lease token (box boundary)
|
|
|
|
|
struct SmallSegment* segment; // Segment owner (NULL if Tiny v1 path)
|
|
|
|
|
struct SmallPageMeta* next;
|
|
|
|
|
} SmallPageMeta;
|
|
|
|
|
|
|
|
|
|
// SmallClassHeap: Per-class heap state (current / partial / full lists)
|
|
|
|
|
typedef struct SmallClassHeap {
|
|
|
|
|
SmallPageMeta* current;
|
|
|
|
|
SmallPageMeta* partial_head;
|
|
|
|
|
SmallPageMeta* full_head;
|
2025-12-10 17:58:42 +09:00
|
|
|
uint32_t partial_count;
|
2025-12-10 23:30:32 +09:00
|
|
|
} SmallClassHeap;
|
|
|
|
|
|
|
|
|
|
// SmallHeapCtx: TLS heap context (per-thread)
|
|
|
|
|
typedef struct SmallHeapCtx {
|
|
|
|
|
SmallClassHeap cls[SMALLOBJECT_NUM_CLASSES];
|
|
|
|
|
} SmallHeapCtx;
|
|
|
|
|
|
2025-12-11 01:44:08 +09:00
|
|
|
// SmallC6FastState: TLS fastlist state for C6 (Phase v4-mid-6)
|
|
|
|
|
typedef struct SmallC6FastState {
|
|
|
|
|
void* freelist; // C6 fastlist head
|
|
|
|
|
void* page_base; // Current C6 page base address
|
|
|
|
|
uint32_t used; // Usage count (synced to page->used on switch)
|
|
|
|
|
uint32_t capacity; // Page capacity
|
|
|
|
|
SmallPageMeta* meta; // Back-pointer to page metadata
|
|
|
|
|
} SmallC6FastState;
|
|
|
|
|
|
2025-12-10 23:30:32 +09:00
|
|
|
// Backward compatibility aliases (deprecated, use SmallXxx directly)
|
|
|
|
|
typedef SmallPageMeta small_page_v4;
|
|
|
|
|
typedef SmallClassHeap small_class_heap_v4;
|
|
|
|
|
typedef SmallHeapCtx small_heap_ctx_v4;
|
2025-12-10 23:23:07 +09:00
|
|
|
|
2025-12-10 17:58:42 +09:00
|
|
|
small_heap_ctx_v4* small_heap_ctx_v4_get(void);
|
|
|
|
|
|
|
|
|
|
// Hot path API (C7-only stub; later phases will expand)
|
|
|
|
|
void* small_heap_alloc_fast_v4(small_heap_ctx_v4* ctx, int class_idx);
|
|
|
|
|
void small_heap_free_fast_v4(small_heap_ctx_v4* ctx, int class_idx, void* ptr);
|
2025-12-10 19:14:38 +09:00
|
|
|
int smallobject_hotbox_v4_can_own(int class_idx, void* ptr);
|