freeze: macro platform complete; default ON with profiles; env consolidation; docs + smokes\n\n- Profiles: --profile {lite|dev|ci|strict} (dev-like default for macros)\n- Macro paths: prefer NYASH_MACRO_PATHS (legacy envs deprecated with warnings)\n- Selfhost pre-expand: auto mode, PyVM-only, add smokes (array/map)\n- Docs: user-macros updated; new macro-profiles guide; AGENTS freeze note; CURRENT_TASK freeze\n- Compat: non-breaking; legacy envs print deprecation notices\n

This commit is contained in:
Selfhosting Dev
2025-09-19 22:27:59 +09:00
parent 811e3eb3f8
commit da32455afc
192 changed files with 6454 additions and 2973 deletions

View File

@ -0,0 +1,52 @@
# JIT Events JSON (v0.1)
最小のイベントJSONスキーマ。観測の足場として、値は安定キーのみを出力します。
- 出力形態: 1行 = 1 JSONJSONL
- 出力先: 標準出力 or `NYASH_JIT_EVENTS_PATH` で指定したファイル
- phase分離:
- compile: `phase: "lower"`明示opt-in: `NYASH_JIT_EVENTS_COMPILE=1`
- runtime: `phase: "execute"`既定ON可: `NYASH_JIT_EVENTS=1` または `NYASH_JIT_EVENTS_RUNTIME=1`
## フィールド(必須)
- kind: 文字列(例: "hostcall"
- function: 文字列(現状は "<jit>" で固定)
- phase: 文字列("lower" | "execute"
- id: シンボル名(例: "nyash.map.get_hh"
- decision: 文字列("allow" | "fallback"
- reason: 文字列("sig_ok" | "receiver_not_param" | "policy_denied_mutating" | "sig_mismatch" など)
- argc: 数値(観測引数数)
- arg_types: 文字列配列(例: ["Handle","I64"]
任意フィールド(存在時のみ)
- handle: 数値JITハンドル
- ms: 数値(処理時間ミリ秒)
## 出力例
compilelower:
```json
{"kind":"hostcall","function":"<jit>","id":"nyash.map.get_hh","decision":"allow","reason":"sig_ok","argc":2,"arg_types":["Handle","Handle"],"phase":"lower"}
```
runtimeexecute:
```json
{"kind":"hostcall","function":"<jit>","id":"nyash.array.push_h","decision":"fallback","reason":"policy_denied_mutating","argc":2,"arg_types":["Handle","I64"],"phase":"execute"}
```
trapexecute 中の失敗):
```json
{"kind":"trap","function":"<jit>","reason":"jit_execute_failed","ms":0,"phase":"execute"}
```
## 環境変数(抜粋)
- NYASH_JIT_EVENTS=1: 既定のruntime出力
- NYASH_JIT_EVENTS_COMPILE=1: compilelower出力
- NYASH_JIT_EVENTS_RUNTIME=1: runtime出力
- NYASH_JIT_EVENTS_PATH=path.jsonl: ファイルに追記
- NYASH_JIT_THRESHOLD未設定時: 観測ONで自動的に1が補われますRunner/DebugConfigBoxが補助
## 推奨の最小運用
- 現象確認: `NYASH_JIT_EVENTS=1`runtimeのみ
- 解析時のみcompile出力: `NYASH_JIT_EVENTS_COMPILE=1 NYASH_JIT_EVENTS_PATH=events.jsonl`
- HostCall系の例では `NYASH_JIT_HOSTCALL=1` を明示

View File

@ -0,0 +1,76 @@
JIT Stats JSON Schema — Version 1
=================================
This document describes the fields emitted in the JIT statistics JSON outputs (version=1).
Sources
- Unified JIT stats (VM-side): printed when `NYASH_JIT_STATS_JSON=1` (or CLI equivalent)
- Box API: `new JitStatsBox().toJson()` returns a compact JSON, `summary()` returns a pretty JSON summary (via VM dispatch)
Version
- `version`: number — Schema version (currently `1`)
Unified JIT Stats (JSON)
- `version`: number — Schema version (1)
- `sites`: number — Number of JIT call sites observed
- `compiled`: number — Count of functions compiled by the JIT
- `hits`: number — Sum of entries across all functions (hotness hits)
- `exec_ok`: number — Count of successful JIT executions
- `trap`: number — Count of JIT executions that trapped and fell back to VM
- `fallback_rate`: number — Ratio `trap / (exec_ok + trap)` (0 when denominator is 0)
- `handles`: number — Current number of live JIT handles in the registry
- `abi_mode`: string — `"i64_bool"` or `"b1_bool"` (when toolchain supports b1)
- `abi_b1_enabled`: boolean — Whether b1 ABI is requested by config
- `abi_b1_supported`: boolean — Whether current toolchain supports b1 in signatures
- `b1_norm_count`: number — Count of b1 normalizations (e.g., i64!=0 to b1)
- `ret_bool_hint_count`: number — Count of functions lowered with return-bool hint
- `phi_total_slots`: number — Total PHI slots encountered (always-on, LowerCore-based)
- `phi_b1_slots`: number — PHI slots classified as boolean (heuristics)
- `top5`: array of objects — Top hot functions
- `name`: string
- `hits`: number
- `compiled`: boolean
- `handle`: number (0 when not compiled)
Compact Box JSON — `JitStatsBox.toJson()`
- `version`: number — Schema version (1)
- `abi_mode`: string — Current ABI mode for booleans (see above)
- `abi_b1_enabled`: boolean — Whether b1 ABI is requested by config
- `abi_b1_supported`: boolean — Whether current toolchain supports b1 in signatures
- `b1_norm_count`: number — b1 normalizations count
- `ret_bool_hint_count`: number — return-bool hint count
- `phi_total_slots`: number — Total PHI slots (accumulated)
- `phi_b1_slots`: number — Boolean PHI slots (accumulated)
Summary Box JSON — `JitStatsBox.summary()`
- Pretty-printed JSON containing:
- All fields from `toJson()`
- `top5`: same structure as unified stats
Notes
- Counters reflect process-lifetime totals (reset only on process start).
- `phi_*` counters are accumulated per LowerCore invocation (function lower), independent of dump flags.
- `abi_mode` switches to `b1_bool` when toolchain support is detected and b1 ABI is enabled.
Examples
```
{
"version": 1,
"sites": 1,
"compiled": 0,
"hits": 1,
"exec_ok": 0,
"trap": 0,
"fallback_rate": 0.0,
"handles": 0,
"abi_mode": "i64_bool",
"abi_b1_enabled": false,
"abi_b1_supported": false,
"b1_norm_count": 0,
"ret_bool_hint_count": 0,
"phi_total_slots": 2,
"phi_b1_slots": 1,
"top5": [ { "name": "main", "hits": 1, "compiled": false, "handle": 0 } ]
}
```