feat(ring0): Phase 102 MemApi Bridge Skeleton - StdMem実装

- Add StdMem struct (stdlib alloc/free based)
- Update default_ring0() to use StdMem instead of NoopMem
- Keep NoopMem for compatibility and testing
- Add unit tests for StdMem allocation/stats
- Update docs (phase-85-ring0-runtime/README.md, ring0-inventory.md)

Note: This is a skeleton implementation. Full MemStats tracking
(including freed size) will be added in Phase 102B with hakmem bridge.

Files modified:
- src/runtime/ring0/std_impls.rs
- src/runtime/ring0/mod.rs
- docs/development/current/main/phase-85-ring0-runtime/README.md
- docs/development/current/main/ring0-inventory.md
This commit is contained in:
nyash-codex
2025-12-03 13:42:05 +09:00
parent 0c527dcd22
commit 262de28c6b
4 changed files with 249 additions and 3 deletions

View File

@ -4,7 +4,7 @@
This document provides an inventory of Ring0.log infrastructure and categorizes the remaining println!/eprintln! call sites across the codebase. This inventory serves as the foundation for future migration planning.
**Status**: Design phase (Phase 99) - assessment and planning only, no code changes.
**Status**: Phase 101-B in progress — planning baseline plus partial internal/dev migration to Ring0.log (113 call sites converted across 5 batches).
---
@ -155,6 +155,35 @@ This document provides an inventory of Ring0.log infrastructure and categorizes
---
### Phase 101-B Update (2025-12-04)
- internal/dev ログ 26 箇所を Ring0.log 化stderr ノイズ削減)[第1バッチ]
- runtime: provider_lock.rs, type_meta.rs, deprecations.rs, leak_tracker.rs, plugin_loader_unified.rs
- plugin loader v2: loader/config.rs, loader/library.rs, loader/metadata.rs, instance_manager.rs, ffi_bridge.rs
- internal/dev ログ 21 箇所を追加で Ring0.log 化 [第2バッチ]
- runtime: provider_verify.rs, scheduler.rs, gc_controller.rs, box_registry.rs
- plugin loader v2: loader/specs.rsTypeBox ABI/trace
- runner: runner/trace.rscli_verbose トレース)
- mir: mir/verification.rsNYASH_BREAKFINDER_SSA_TRACE / NYASH_DEBUG_VERIFIER
- internal/dev ログ 20 箇所を追加で Ring0.log 化 [第3バッチ]
- mir core: basic_block.rsinsert-after-phis trace、control_form.rs、hints.rs、effect.rs、printer.rs、optimizer.rs
- internal/dev ログ 26 箇所を追加で Ring0.log 化 [第4バッチ]
- mir builder/region: loop_builder/phi_ops.rs、builder/type_registry.rs、region/observer.rs
- plugin loader v2: enabled/extern_functions.rscall/console trace、enabled/types.rsfinalize trace
- internal/dev ログ 20 箇所を追加で Ring0.log 化 [第5バッチ]
- mir loop_builder JoinIR 系: joinir_if_phi_selector.rsdry-run trace、control.rsLoopForm debug
- mir builder observe: observe/types.rsNYASH_MIR_TYPE_TRACE、observe/resolve.rsNYASH_DEBUG_KPI_KNOWN
- joinir VM bridge: join_ir_vm_bridge_dispatch/exec_routes.rsrun_generic_joinir_route trace
- plugin loader v2: enabled/extern_functions.rsNYASH_DEBUG_TRACE / runtime_checkpoint_trace / NYASH_BOX_INTROSPECT_TRACE
- 役目: internal/diagnostic ログの責務を Ring0.log に寄せ、ConsoleService とテスト出力を分離
- 残件概算:
- dev-debug: ~475495 箇所Phase 101-A の 34 箇所 + 5バッチ合計 113 箇所以外の残り)
- internal: ~699 箇所812 から 113 箇所控除のラフ値)
- test: ~299 箇所(方針どおり維持)
- hack_check (.hako) は別フェーズで扱うRust 側とは切り離し)
---
## Section 3: Ring0.log Expansion Plan (Sketch)
### Future Directions (Not Implemented)
@ -460,6 +489,24 @@ rg 'impl.*LogApi' --type rust
---
### Phase 102: MemApi Bridge Skeleton (COMPLETED)
**Completed Tasks**:
- ✅ StdMem implementation (stdlib alloc/free)
- ✅ default_ring0() unified to use StdMem
- ✅ Unit tests for StdMem allocation and statistics
- ✅ NoopMem retained for compatibility
**Status**: Skeleton ready for Phase 102B (hakmem bridge integration)
**Files Modified**:
- src/runtime/ring0/std_impls.rs (added StdMem)
- src/runtime/ring0/mod.rs (updated default_ring0, exports)
- docs/development/current/main/phase-85-ring0-runtime/README.md (added Phase 102 section)
- docs/development/current/main/ring0-inventory.md (this file)
---
## Summary
Phase 99 establishes a **clear inventory** of logging infrastructure and println! call sites:
@ -469,4 +516,6 @@ Phase 99 establishes a **clear inventory** of logging infrastructure and println
3. **Migration strategy**: Phased approach starting with user-facing messages
4. **Success criteria**: Clear metrics for each phase
**Phase 102**: StdMem implementation complete, preparing for hakmem integration.
**Next Steps**: Phase 100+ will implement gradual migrations based on this inventory.