## 🎉 ChatGPT×Claude協働成果 - ✅ **GC機能復活**: vm-legacy削除で失われたGC機能を新実装で復活 - GCメトリクス追跡システム実装(alloc/collect/pause計測) - 3種類のGCモード対応(counting/mark_sweep/generational) - host_handles.rsでハンドル管理復活 - ✅ **VM整理とエイリアス追加**: 混乱していた名前を整理 - MirInterpreter = NyashVm = VM のエイリアス統一 - vm-legacyとインタープリターの違いを明確化 - 壊れていたvm.rsの互換性修復 - ✅ **スモークテスト整理**: v2構造でプラグイン/コア分離 - plugins/ディレクトリにプラグインテスト移動 - gc_metrics.sh, gc_mode_off.sh, async_await.sh追加 - _ensure_fixture.shでプラグイン事前ビルド確認 ## 📊 json_native調査結果 - **現状**: 25%完成(配列/オブジェクトパース未実装) - **将来性**: 並行処理でyyjson超えの可能性大 - 100KB以上のJSONで2-10倍速の可能性 - Nyash ABI実装後はゼロコピー最適化 - **判断**: 現時点では置換不可、将来の大きな足場 ## 🔍 技術的発見 - vm-legacy = 完全なVM実装(GC付き)だった - MirInterpreter = 現在のRust VM(712行、Arc使用) - 200行簡易JSONは既に削除済み(存在しない) ChatGPT爆速修復×Claude詳細調査の完璧な協働! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
61 lines
1.8 KiB
Rust
61 lines
1.8 KiB
Rust
//! GC hook abstractions for switchable runtime (Phase 10.4 preparation)
|
|
//!
|
|
//! Minimal, no-alloc, no-type-coupling interfaces that VM can call.
|
|
//! Default implementation is a no-op. Real collectors can plug later.
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub enum BarrierKind {
|
|
Read,
|
|
Write,
|
|
}
|
|
|
|
/// GC hooks that execution engines may call at key points.
|
|
/// Implementations must be Send + Sync for multi-thread preparation.
|
|
pub trait GcHooks: Send + Sync + std::any::Any {
|
|
/// Safe point for cooperative GC (e.g., poll or yield).
|
|
fn safepoint(&self) {}
|
|
/// Memory barrier hint for loads/stores.
|
|
fn barrier(&self, _kind: BarrierKind) {}
|
|
/// Allocation accounting (bytes are best-effort; may be 0 when unknown)
|
|
fn alloc(&self, _bytes: u64) {}
|
|
/// Optional counters snapshot for diagnostics. Default: None.
|
|
fn snapshot_counters(&self) -> Option<(u64, u64, u64)> {
|
|
None
|
|
}
|
|
}
|
|
|
|
/// Default no-op hooks.
|
|
pub struct NullGc;
|
|
|
|
impl GcHooks for NullGc {}
|
|
|
|
/// CountingGc is now a thin wrapper around the unified GcController.
|
|
pub struct CountingGc {
|
|
inner: crate::runtime::gc_controller::GcController,
|
|
}
|
|
|
|
impl CountingGc {
|
|
pub fn new() -> Self { Self::new_with_mode(crate::runtime::gc_mode::GcMode::RcCycle) }
|
|
pub fn new_with_mode(mode: crate::runtime::gc_mode::GcMode) -> Self {
|
|
Self { inner: crate::runtime::gc_controller::GcController::new(mode) }
|
|
}
|
|
pub fn snapshot(&self) -> (u64, u64, u64) {
|
|
self.inner.snapshot()
|
|
}
|
|
}
|
|
|
|
impl GcHooks for CountingGc {
|
|
fn safepoint(&self) {
|
|
self.inner.safepoint();
|
|
}
|
|
fn barrier(&self, kind: BarrierKind) {
|
|
self.inner.barrier(kind);
|
|
}
|
|
fn alloc(&self, bytes: u64) {
|
|
self.inner.alloc(bytes);
|
|
}
|
|
fn snapshot_counters(&self) -> Option<(u64, u64, u64)> {
|
|
Some(self.inner.snapshot())
|
|
}
|
|
}
|