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>
36 lines
901 B
Plaintext
36 lines
901 B
Plaintext
// Demonstrate JIT mutating opt-in via JitPolicyBox whitelist
|
|
// 1) Enable read_only → mutating hostcalls fallback (policy_denied_mutating)
|
|
// 2) Whitelist nyash.array.push_h → allow + execute
|
|
// Run:
|
|
// NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_HOSTCALL=1 NYASH_JIT_EVENTS=1 \
|
|
// ./target/release/nyash --backend vm examples/jit_policy_optin_mutating.nyash
|
|
|
|
box Helper {
|
|
birth() {}
|
|
add(a) {
|
|
a.push(1)
|
|
return a.length()
|
|
}
|
|
}
|
|
|
|
static box Main {
|
|
main() {
|
|
local P, H, A
|
|
P = new JitPolicyBox()
|
|
// Enable read-only first (deny mutating)
|
|
P.set("read_only", true)
|
|
|
|
H = new Helper()
|
|
A = new ArrayBox()
|
|
// This call will fallback by policy (observe events)
|
|
H.add(A)
|
|
|
|
// Opt-in: allow array.push_h through whitelist
|
|
P.setWhitelistCsv("nyash.array.push_h")
|
|
|
|
// This call will be allowed (observe allow event)
|
|
return H.add(A)
|
|
}
|
|
}
|
|
|