Files
hakmem/archive/ss_legacy_backend_box.h
Moe Charm (CI) 5582cbc22c Refactor: Unified allocation macros + header validation
1. Archive unused backend files (ss_legacy/unified_backend_box.c/h)
   - These files were not linked in the build
   - Moved to archive/ to reduce confusion

2. Created HAK_RET_ALLOC_BLOCK macro for SuperSlab allocations
   - Replaces superslab_return_block() function
   - Consistent with existing HAK_RET_ALLOC pattern
   - Single source of truth for header writing
   - Defined in hakmem_tiny_superslab_internal.h

3. Added header validation on TLS SLL push
   - Detects blocks pushed without proper header
   - Enabled via HAKMEM_TINY_SLL_VALIDATE_HDR=1 (release)
   - Always on in debug builds
   - Logs first 10 violations with backtraces

Benefits:
- Easier to track allocation paths
- Catches header bugs at push time
- More maintainable macro-based design

Note: Larson bug still reproduces - header corruption occurs
before push validation can catch it.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 05:37:24 +09:00

44 lines
1.6 KiB
C

// Box: Legacy Backend (Phase 12)
// Purpose: Per-class SuperSlabHead backend (legacy implementation)
//
// Responsibilities:
// - Maintain per-class SuperSlabHead (g_superslab_heads)
// - Initialize SuperSlabHead for a class
// - Expand SuperSlabHead by allocating new chunks
// - Find chunk for a pointer (chunk walk)
// - Legacy hint box (per-thread, per-class bump allocation)
//
// Dependencies:
// - ss_allocation_box (superslab_allocate, superslab_free, superslab_init_slab)
// - hakmem_tiny_config (g_tiny_class_sizes)
//
// API:
// - init_superslab_head() - initialize SuperSlabHead for a class
// - expand_superslab_head() - expand SuperSlabHead by allocating new chunk
// - find_chunk_for_ptr() - find chunk for a pointer
// - hak_tiny_alloc_superslab_backend_legacy() - per-class backend
// - hak_tiny_alloc_superslab_backend_hint() - hint optimization
// - hak_tiny_ss_hint_record() - hint recording
#ifndef SS_LEGACY_BACKEND_BOX_H
#define SS_LEGACY_BACKEND_BOX_H
#include "hakmem_tiny_superslab.h"
// Global per-class SuperSlabHeads
extern SuperSlabHead* g_superslab_heads[TINY_NUM_CLASSES_SS];
// SuperSlabHead management
SuperSlabHead* init_superslab_head(int class_idx);
int expand_superslab_head(SuperSlabHead* head);
SuperSlab* find_chunk_for_ptr(void* ptr, int class_idx);
// Legacy backend API
void* hak_tiny_alloc_superslab_backend_legacy(int class_idx);
// Hint box (optional optimization)
void* hak_tiny_alloc_superslab_backend_hint(int class_idx);
void hak_tiny_ss_hint_record(int class_idx, SuperSlab* ss, int slab_idx);
#endif // SS_LEGACY_BACKEND_BOX_H