Files
hakorune/examples/ny_bench_f64.nyash
Moe Charm e54561e69f Phase 10.7 - JIT統計とイベント機能の完成
主要な実装:
- PHI(b1)統計追跡: phi_total_slots/phi_b1_slotsをJSON出力
- 関数単位統計API: JitStatsBox.perFunction()で詳細統計取得
- JITイベントシステム: compile/execute/fallback/trapをJSONL形式で記録
- Store/Load命令対応: ローカル変数を含む関数のJIT実行が可能に

新しいBox:
- JitStatsBox: JIT統計の取得
- JitConfigBox: JIT設定の管理(将来用)
- JitEventsBox: イベントのJSONL出力(将来用)
- JitPolicyBox: 実行ポリシー管理(将来用)

CLI拡張:
- --jit-exec, --jit-stats, --jit-dump等のフラグ追加
- --jit-directモードでの独立JIT実行
- NYASH_JIT_*環境変数によるきめ細かい制御

ドキュメント:
- Phase 10.7実装計画の詳細化
- Phase 10.9 (ビルトインBox JIT) の計画追加
- JIT統計JSONスキーマ v1の仕様化

ChatGPT5との共同開発により、JIT基盤が大幅に強化されました。
次はPhase 10.9でビルトインBoxのJIT対応を進め、
Python統合(Phase 10.1)への道を開きます。

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-28 09:26:58 +09:00

54 lines
1.2 KiB
Plaintext

// f64 micro benchmark (Cranelift JIT)
// Requirements:
// - Build with: cargo build --release --features cranelift-jit
// - Run with: NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_NATIVE_F64=1 \
// ./target/release/nyash --backend vm examples/ny_bench_f64.nyash
// Notes:
// - VM backend alone may not support f64 BinOp/Compare; use JIT as above.
static box Main {
main() {
local ITER, timer
ITER = 200000
timer = new TimerBox()
print("\n=== f64 Micro Bench (ITER=" + ITER + ") ===")
// 1) f64 add/mul loop
local i, x, y, z, t0, t1, ms, ops
i = 0
x = 1.5
y = 2.25
t0 = timer.now()
loop(i < ITER) {
z = x + y
x = z * 1.000001
i = i + 1
}
t1 = timer.now()
ms = t1 - t0
ops = (ITER * 1000.0) / ms
print("[f64_addmul] elapsed_ms=" + ms + ", ops/sec=" + ops)
// 2) f64 compare loop
local c
i = 0
x = 10.0
y = 9.5
t0 = timer.now()
loop(i < ITER) {
c = x > y
y = y + 0.000001
i = i + 1
}
t1 = timer.now()
ms = t1 - t0
ops = (ITER * 1000.0) / ms
print("[f64_compare] elapsed_ms=" + ms + ", ops/sec=" + ops)
print("\nDone (f64).")
return 0
}
}