Phase 10.10: GC Switchable Runtime & Unified Debug System 実装完了
Phase 10.10の主要実装: - GcConfigBox: GC設定の実行時制御(counting/trace/barrier_strict) - DebugConfigBox: デバッグ設定の統一管理(JIT events/stats/dump/dot) - メソッドディスパッチ: system_methods.rsで両Boxのメソッド実装 - CountingGC動作確認: write_barriers正常カウント(VM実行時) 技術的詳細: - BoxCore/BoxBase統一アーキテクチャを活用 - setFlag/getFlag/apply/summaryメソッドで統一API提供 - 環境変数経由でVM/JITランタイムと連携 - GcConfigBox.apply()は次回実行から有効(ランタイム作成前に環境変数参照) テスト済み: - examples/gc_counting_demo.nyash: CountingGCの動作確認 - write_barriers=3でArray.push/set, Map.setを正しくカウント - NYASH_GC_TRACE=1でGC統計出力確認 Box-First哲学の体現: 設定も制御も観測もすべてBox! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
34
examples/gc_counting_demo.nyash
Normal file
34
examples/gc_counting_demo.nyash
Normal file
@ -0,0 +1,34 @@
|
||||
// GC Counting demo (VM path) — verifies CountingGc counters and barrier sites
|
||||
// Run:
|
||||
// ./target/release/nyash --backend vm examples/gc_counting_demo.nyash
|
||||
// Expect (with trace): [GC] counters: safepoints>0 read_barriers>=0 write_barriers>=0
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
// Turn on Counting GC + trace via Box-First path
|
||||
local G
|
||||
G = new GcConfigBox()
|
||||
G = G.setFlag("counting", true)
|
||||
G = G.setFlag("trace", true)
|
||||
G.apply()
|
||||
|
||||
// Make sure we don't engage JIT path for this demo (VM baseline)
|
||||
// If needed, you can set NYASH_JIT_EXEC=0 in the environment.
|
||||
|
||||
// Perform some mutating ops to hit write barriers on the VM path
|
||||
local A, M
|
||||
A = new ArrayBox()
|
||||
A.push(1)
|
||||
A.set(0, 2)
|
||||
|
||||
M = new MapBox()
|
||||
M.set("k", "v")
|
||||
|
||||
// Simple read ops (should register read barriers on some implementations)
|
||||
print(A.length())
|
||||
print(M.size())
|
||||
|
||||
return "done"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user