Commit b2561558
b25615589c39Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
docs(promote): record (A) proc poly-cell attempt — coupled to (B) reentrant side-channel, net-negative alone (927->920), revert; correct sequencing notes
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- b25615589c39
- Parent
- b79049c02a8c
docs/promote-mode-plan.mdmodifiedView file
@@ -82,7 +82,12 @@
8282
- **自走バッチ(912→927、+15)**: masgn/pattern 系の box(pattern-match destructure+capture、leading-splat、cvar op-assign→`sp_poly_<op>`+inference 修正、begin/rescue tail box)+ **index/count 引数の一括 `emit_int_expr` 化**(array/string index・fetch・count・op-assign の `mrb_int _t=<idx>` 約25 site、poly のみ coerce で default 不変)+ bigint slot poly 代入→`sp_poly_as_bigint` + range/string-index builtin の poly arg coerce。各 commit は `g_promote_mode` 経路のみ変化、default 992/0/0 + optcarrot 59662 維持。8383
- **★罠(記録)**: `emit_tail_value` の `g_ret_type==POLY` 無条件 box は **explicit-return 経路と二重 box** で begin_rescue/forward_args_block を回帰(spot-test では PASS だが full-suite で発覚)→ revert。**共有 tail/return 経路の変更は full-suite 必須**(spot-test 不可)。8484
- **残 ERR=44 / FAIL=22 の構造的ブロッカー**:85-
1. **proc/closure の mrb_int ABI(closure-capture ~5 ERR + proc 6→0 等 FAIL)**: `sp_proc_call` の戻り値・args が mrb_int 固定。poly 値が proc 境界で truncate。poly-cell(sp_RbVal セル+`sp_cell_scan_rbval`)は実装途中まで行ったが、proc ABI 全体が mrb_int 前提なので **ABI を sp_RbVal 化する大改修が必要**(別案件、incremental coercion では不可)。試行ブランチ無し=未コミット破棄済。85+
1. **proc/closure の poly 対応(closure-capture ~5 ERR + proc 6→0 等 FAIL)— ★(A) 単独 land 不可を実証(2026-06-21)**:86+
- **proc ABI は表面 mrb_int だが poly side-channel を既に持つ**: `_sp_proc_poly_args[16]`(poly 引数)/`_sp_proc_poly_ret`(poly 戻り値)。proc 本体は `_proc_N(void*_cap, mrb_int argc, mrb_int *args)`。87+
- **(A) を実装・計測**: ①poly capture cell(`sp_RbVal *_cell_x` + `sp_cell_scan_rbval` + cap-struct フィールド `sp_RbVal*` + proc-capture 制限に poly 許可)②**proc local の `proc_ret` も widen**(本体 scope の ret は widen 済だが caller 側 `lv->proc_ret` が未 widen → `.call` が side-channel を読まず raw mrb_int=0 を返す)③`emit_proc_call_args` の int slot に `sp_poly_to_i` 公開(int proc param が args[k] を読むため)。88+
- **個別には proc_closure / case_local_in_lambda が PASS**になったが、**full-suite で 927→920(PASS -7, FAIL +9)に純減**。89+
- **真因 = (A) は (B) と結合**: `proc_ret` を widen すると多数の `.call` が side-channel を読むようになるが、**`_sp_proc_poly_ret` は単一グローバル(非再入)**。ネスト/再帰 proc 呼び出しが内側で外側のスロットを上書き → 既存 PASS が FAIL 化。**→ (A) を入れる前に (B) 再入対応(side-channel をスタック化、or 戻り値を呼び出し式内で即読み)が必須**。未コミット破棄済(927 維持)。90+
- **正しい順序 = (B) を先に**: `_sp_proc_poly_ret` を depth-indexed stack 化(or `({sp_proc_call(...); _sp_proc_poly_ret;})` で即時読みを保証)→ その上で (A) poly-cell + proc_ret widen + args int-slot 公開を入れる。これで初めて net-positive になるはず。**poly-cell/proc_ret-widen/args-slot の 3 点セット + (B) を一括で入れる**こと(部分適用は退行)。8691
2. **node-cache stale**: `emit_hash_key` 等が `comp_ntype(key)` の widen 前 int を読み coerce を飛ばす(int-keyed hash の poly key=bundle_class_06)。local read は `scope_local()->type` が正、generic ヘルパーは node 型依存。中央解決要。8792
3. **散在 one-off**: user `<=>`(`sp_*__lt_set_gt` の arg、`expected expression before sp_RbVal` 構造的)、bound-method `.call` 直接 dispatch の raw arg(sp_double/dbl/mix)、instance_exec break/next/trampoline_result の poly 結果→int、各種 builtin arg。8893
- **手法**: `/tmp/ptest.sh <name>`(単体)、`/tmp/perragg.sh`→`/tmp/perr4.txt`(全 ERR first-error)、`/tmp/ptest_lastc`(最後の cfile)。中央 coerce=`emit_int_expr`(poly→int)/`emit_float_expr`/`sp_poly_as_bigint`/`emit_boxed`+`emit_boxed_text`(→poly)/`emit_unbox_text`(poly→scalar)。