Files
hakorune/docs/private/roadmap/phases/phase-20.21/PLAN.md

42 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Plan — Phase 20.21Manual Memory Management / CABI
マイルストーン
- M1: libc ベースの hako_alloc/freerealloc は任意)
- M2: Opaque HandleHakoHandleretain/releaseatomic
- M3: SSOT ドキュメント(所有権/並行性/失敗時挙動)
- M4: スモークalloc/free, retain/release, 二重解放Fail, NULL 安全)
- M5: hakmem 差し替え導線ENV ガードのみ、実装は次フェーズ可)
タスク詳細
1) API スケルトン(ヘッダ & 実装・最小)
- include/hako_mem.h生成 or 手書き)
- void* hako_alloc(size_t);
- void hako_free(void*);
- typedef uint64_t HakoHandle; HakoHandle hako_retain(HakoHandle); void hako_release(HakoHandle);
- src/abi/c/mem_libc.clibc 実装)
- ENV: HAKO_C_ABI_ALLOC={libc|hakmem}(既定 libc, 未対応値は Fail
2) retain/releaseatomic
- 参照カウントテーブルハンドル→rcを内部に保持最小実装
- 0 → free で解放(ハンドルの登録解除)
- 再入/並行性はatomicスピンロックで最小実装将来改善
3) SSOT ドキュ
- docs/development/abi/README.md に Memory Ownership Rules を追記
- FailFast 文言double freeunknown handleallocator mismatchを固定
4) スモーク
- alloc/write/free 正常ケース
- double free → 失敗タグrc!=0
- retain/release の基本rc 増減、0到達で解放
- 任意ASan/Valgrind 実行のガイド
5) hakmem 導線
- ENV のみ(実装は次)。切替点・責務・将来の整合を README に明記
リスクと対策
- 二重解放unknown handle → FailFast安定タグ
- 競合 → atomic最小ロック、将来は hazard pointers 等で最適化
- ABI 変更 → _copy と _borrow を命名で分離(本フェーズは _copy のみ)