Phase v11a-3: MID v3.5 Activation (Build Complete)

Integrated MID v3.5 into active code path, making it available for C5/C6/C7 routing.

Key Changes:
- Policy Box: Added SMALL_ROUTE_MID_V35 with ENV gates (HAKMEM_MID_V35_ENABLED, HAKMEM_MID_V35_CLASSES)
- HotBox: Implemented small_mid_v35_alloc/free with TLS-cached page allocation
- Front Gate: Wired MID_V35 routing into malloc_tiny_fast.h (priority: ULTRA > MID_V35 > V7)
- Build: Added core/smallobject_mid_v35.o to all object lists

Architecture:
- Slot sizes: C5=384B, C6=512B, C7=1024B
- Page size: 64KB (170/128/64 slots)
- Integration: ColdIface v2 (refill/retire), Stats v2 (observation), Learner v2 (dormant)

Status: Build successful, ready for A/B benchmarking
Next: Performance validation (C6-heavy, C5+C6-only, Mixed benchmarks)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-12-12 06:52:14 +09:00
parent 0dba67ba9d
commit 212739607a
8 changed files with 682 additions and 1955 deletions

View File

@ -47,6 +47,7 @@
#include "../box/smallobject_v6_env_box.h" // SmallObject v6 ENV control (Phase V6-HDR-2)
#include "../box/smallobject_hotbox_v7_box.h" // SmallObject HotBox v7 stub (Phase v7-1)
#include "../box/smallobject_policy_v7_box.h" // Phase v7-4: Policy Box
#include "../box/smallobject_mid_v35_box.h" // Phase v11a-3: MID v3.5 HotBox
#include "../box/tiny_c7_ultra_box.h" // C7 ULTRA stub (UF-1, delegates to v3)
#include "../box/tiny_c6_ultra_free_box.h" // Phase 4-2: C6 ULTRA-free (free-only, C6-only)
#include "../box/tiny_c5_ultra_free_box.h" // Phase 5-1/5-2: C5 ULTRA-free + alloc integration
@ -224,8 +225,18 @@ static inline void* malloc_tiny_fast(size_t size) {
}
}
// Phase v7-4: Check Policy Box for v7 routing (before switch)
// Phase v7-4: Check Policy Box for v7/MID_V35 routing (before switch)
const SmallPolicyV7* policy = small_policy_v7_snapshot();
// Phase v11a-3: MID v3.5 routing
if (policy->route_kind[class_idx] == SMALL_ROUTE_MID_V35) {
void* v35p = small_mid_v35_alloc(class_idx, size);
if (TINY_HOT_LIKELY(v35p != NULL)) {
return v35p;
}
// v35 returned NULL -> fallback to legacy
}
if (policy->route_kind[class_idx] == SMALL_ROUTE_V7) {
void* v7p = small_heap_alloc_fast_v7_stub(size, (uint8_t)class_idx);
if (TINY_HOT_LIKELY(v7p != NULL)) {
@ -378,6 +389,17 @@ static inline int free_tiny_fast(void* ptr) {
return 1;
}
// Phase v11a-3: Try MID v3.5 free for C5/C6/C7
// For v11a-3: simple ownership check (assumes current route)
// For v11b: will add proper segment-based ownership check
const SmallPolicyV7* policy_free = small_policy_v7_snapshot();
if ((class_idx >= 5 && class_idx <= 7) &&
policy_free->route_kind[class_idx] == SMALL_ROUTE_MID_V35) {
small_mid_v35_free(ptr, class_idx);
FREE_PATH_STAT_INC(smallheap_v7_fast); // Reuse counter for now
return 1;
}
// Phase v7-5b/v7-7: Always try V7 free for supported classes (C5/C6)
// V7 returns false if ptr is not in V7 segment.
// This is necessary because Learner may switch routes dynamically,