Commit de224e17
de224e1797e8Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
docs(promote): mark proc/closure poly support SOLVED via proc_ret post-widen fixpoint + node-cache refresh (no ABI change); 932
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- de224e1797e8
- Parent
- 190998ceb5a8
docs/promote-mode-plan.mdmodifiedView file
@@ -91,8 +91,12 @@
9191
- **失敗方向①(naive widen=全 proc_ret→poly)**: `->(a,b){a+b}`(a,b は block-param 除外で int、本体は `return sp_int_add`=**int return**)で caller が side-channel(未設定)を読み 0。multi_arg_lambda 等 **11 lambda が退行**。9292
- **失敗方向②(literal 限定で proc_ret 再計算=`proc_ret_of`)**: multi_arg は直る(本体 int→proc_ret int)が、**`c = make_counter()`(メソッドが返す proc)** は proc_ret が make_counter の `ret_proc_ret`(未 widen=int)由来で、literal ループが取りこぼし → proc_closure が再退行。9393
- **= proc_ret は複数サイトの fixpoint**(`x=proc{}` analyze_pass.c:1124 / proc param :1218 / method `ret_proc_ret` :3719 / compose・to_proc)。**widen 後にこの fixpoint 全体を再収束させる必要**があり、naive widen も部分再計算も不可。`proc_node_ret`=本体最終式の infer(`analyze_util.c:334`)。94-
- **正しい実装(未着手)= (i) widen 後に proc_ret 伝播 fixpoint を再実行**(全 3 サイト + ret_proc_ret を本体 ret から再導出して収束)、**かつ (ii) side-channel の再入性も確認**(naive widen 時の 920 退行は①が主因と判明したので (B) 単独要否は再評価要)、**+ (A) poly-cell + args int-slot 公開**。**3 点を一括**。perf: 各 proc 呼びの boxing 増、optcarrot gate 必須。95-
- **代替(よりクリーン)= proc ABI を `sp_RbVal` 化**(`_proc_N(...)->sp_RbVal`、side-channel 全廃、`sp_proc_call`/compose/curry/bound-method の足並み)。proc_ret 分岐自体が消え fixpoint 不整合が原理的に起きない。perf 影響(sp_RbVal[16] スタック)を optcarrot で測定。**これが本命の恒久解。**94+
- **★★解決済み(ed0c0d68, 927→932, 回帰0)= option 1(ABI 変更不要)**:95+
- ①**poly capture cell**: `sp_RbVal *_cell_x` + `sp_cell_scan_rbval`(sp_gc.h)+ cap-struct フィールド `sp_RbVal*`(codegen.c)+ proc-capture 制限に TY_POLY 許可。read/write 既存経路で OK(lvalue deref + emit_assign の poly box arm)。96+
- ②**args int-slot 公開**: `emit_proc_call_args` で poly arg を `sp_poly_to_i` で int slot にも置く(int proc param=block-param 除外 が args[k] を読むため)。97+
- ③**proc_ret/ret_proc_ret の post-widen focused fixpoint**(analyze.c, finalize infer の後):method scope ret_proc_ret(proc_ret_of で本体から)+ `x=proc{}`/`x=factory()` の proc_ret を収束ループで再導出。**proc-return metadata のみ更新、widen slot 型は不変。**98+
- **★決め手 = fixpoint 後に `for id: infer_type(c,id)` で node-type cache を再構築**。codegen の `.call` は `comp_ntype(call node)`(node cache)を読むので、proc_ret を更新しても cache が stale だと `.call` が古い int slot 経路を出す。再 infer は scope local 型を読むだけで変えないので widen 不変。99+
- 結果: proc / proc_closure / case_local_in_lambda / enum_for_each / lowered_block_given が緑、**proc の 6→0 FAIL も解消**。当初推測の「side-channel 非再入」「ABI 全面改修」は**いずれも不要だった**(真因は node-cache の refresh 漏れ)。96100
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 型依存。中央解決要。97101
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。98102
- **手法**: `/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)。