- 4つ目の実行方式としてAOT(Ahead-of-Time)コンパイルを文書化 - MIR→WASM→.cwasm のコンパイルパイプラインを説明 - wasm-backend featureでのビルド方法を明記 - 現在の実装状況(完全なスタンドアロン実行ファイルはTODO)を記載 - CLAUDE.mdのWASM説明も3種類(Rust→WASM、Nyash→WASM、Nyash→AOT)に更新 - CURRENT_TASK.mdにPhase 10.9/10.10の完了項目を追加 ChatGPT5さんのAOT試行に対応した適切なドキュメント配置を実施 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
45 lines
1.2 KiB
Plaintext
45 lines
1.2 KiB
Plaintext
// JitPolicy whitelist demo with DebugConfigBox event setup.
|
|
// Goal: show fallback on read_only, then allow after whitelist.
|
|
// Run (Cranelift enabled recommended):
|
|
// cargo build --release -j32 --features cranelift-jit
|
|
// NYASH_JIT_HOSTCALL=1 ./target/release/nyash --backend vm examples/jit_policy_whitelist_demo.nyash
|
|
// Check events file:
|
|
// cat policy_events.jsonl # contains phase=lower/execute decisions
|
|
|
|
box Helper {
|
|
birth() {}
|
|
add(a) {
|
|
a.push(1)
|
|
return a.length()
|
|
}
|
|
}
|
|
|
|
static box Main {
|
|
main() {
|
|
// Enable compile-time events and output path via DebugConfigBox
|
|
local D
|
|
D = new DebugConfigBox()
|
|
D = D.setFlag("jit_events_compile", true)
|
|
D = D.setFlag("jit_events_runtime", true)
|
|
D = D.setPath("jit_events_path", "policy_events.jsonl")
|
|
D.apply()
|
|
|
|
// Prepare JIT policy: read_only first
|
|
local P
|
|
P = new JitPolicyBox()
|
|
P.set("read_only", true)
|
|
|
|
// Prepare data and helper
|
|
local H, A
|
|
H = new Helper()
|
|
A = new ArrayBox()
|
|
|
|
// 1st call: should fallback by policy (mutating denied)
|
|
H.add(A)
|
|
|
|
// Whitelist push_h and retry (expect allow)
|
|
P.addWhitelist("nyash.array.push_h")
|
|
return H.add(A)
|
|
}
|
|
}
|