c6edbaaf3a
feat(mir): Phase 63-6-1/2 MIR Phi type_hint field & JoinIR propagation
...
Phase 63-6-1: MirInstruction::Phi に type_hint フィールド追加
- Added `type_hint: Option<MirType>` field to Phi instruction
- Updated 21 files with type_hint initialization (all set to None for legacy paths)
- Pattern matching updated across codebase (11 files)
- Test code updated (basic_block.rs)
Phase 63-6-2: JoinIR→MIR Bridge で型ヒント伝播実装
- Modified convert.rs: Select → MIR now creates PHI with type_hint
- Removed Copy instructions from then/else blocks
- PHI instruction at merge block receives type_hint from JoinIR Select
- Test verification: ✅ Type hint propagation successful (Some(Integer))
Modified files:
- instruction.rs: Added type_hint field definition
- join_ir_vm_bridge/convert.rs: Select lowering with PHI + type_hint
- 19 other files: type_hint field initialization
Test results:
- ✅ test_type_hint_propagation_simple: Type hint = Some(Integer) confirmed
- ✅ 7/8 if_select tests passing (1 race condition, passes individually)
Next: Phase 63-6-3 (lifecycle.rs で型ヒント使用)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-30 04:35:40 +09:00
f9d100ce01
chore: Phase 25.1 完了 - LoopForm v2/Stage1 CLI/環境変数削減 + Phase 26-D からの変更
...
Phase 25.1 完了成果:
- ✅ LoopForm v2 テスト・ドキュメント・コメント完備
- 4ケース(A/B/C/D)完全テストカバレッジ
- 最小再現ケース作成(SSAバグ調査用)
- SSOT文書作成(loopform_ssot.md)
- 全ソースに [LoopForm] コメントタグ追加
- ✅ Stage-1 CLI デバッグ環境構築
- stage1_cli.hako 実装
- stage1_bridge.rs ブリッジ実装
- デバッグツール作成(stage1_debug.sh/stage1_minimal.sh)
- アーキテクチャ改善提案文書
- ✅ 環境変数削減計画策定
- 25変数の完全調査・分類
- 6段階削減ロードマップ(25→5、80%削減)
- 即時削除可能変数特定(NYASH_CONFIG/NYASH_DEBUG)
Phase 26-D からの累積変更:
- PHI実装改善(ExitPhiBuilder/HeaderPhiBuilder等)
- MIRビルダーリファクタリング
- 型伝播・最適化パス改善
- その他約300ファイルの累積変更
🎯 技術的成果:
- SSAバグ根本原因特定(条件分岐内loop変数変更)
- Region+next_iパターン適用完了(UsingCollectorBox等)
- LoopFormパターン文書化・テスト化完了
- セルフホスティング基盤強化
Co-Authored-By: Claude <noreply@anthropic.com >
Co-Authored-By: ChatGPT <noreply@openai.com >
Co-Authored-By: Task Assistant <task@anthropic.com >
2025-11-21 06:25:17 +09:00
525e59bc8d
feat(loop-phi): Add body-local variable PHI generation for Rust AST loops
...
Phase 25.1c/k: Fix ValueId undefined errors in loops with body-local variables
**Problem:**
- FuncScannerBox.scan_all_boxes/1 and BreakFinderBox._find_loops/2 had ValueId
undefined errors for variables declared inside loop bodies
- LoopFormBuilder only generated PHIs for preheader variables, missing body-locals
- Example: `local ch = s.substring(i, i+1)` inside loop → undefined on next iteration
**Solution:**
1. **Rust AST path** (src/mir/loop_builder.rs):
- Detect body-local variables by comparing body_end_vars vs current_vars
- Generate empty PHI nodes at loop header for body-local variables
- Seal PHIs with latch + continue snapshot inputs after seal_phis()
- Added HAKO_LOOP_PHI_TRACE=1 logging for debugging
2. **JSON v0 path** (already fixed in previous session):
- src/runner/json_v0_bridge/lowering/loop_.rs handles body-locals
- Uses same strategy but for JSON v0 bridge lowering
**Results:**
- ✅ FuncScannerBox.scan_all_boxes: 41 body-local PHIs generated
- ✅ Main.main (demo harness): 23 body-local PHIs generated
- ⚠️ Still some ValueId undefined errors remaining (exit PHI issue)
**Files changed:**
- src/mir/loop_builder.rs: body-local PHI generation logic
- lang/src/compiler/entry/func_scanner.hako: debug logging
- /tmp/stageb_funcscan_demo.hako: test harness
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-19 23:12:01 +09:00
dda65b94b7
Phase 21.7 normalization: optimization pre-work + bench harness expansion
...
- Add opt-in optimizations (defaults OFF)
- Ret purity verifier: NYASH_VERIFY_RET_PURITY=1
- strlen FAST enhancement for const handles
- FAST_INT gate for same-BB SSA optimization
- length cache for string literals in llvmlite
- Expand bench harness (tools/perf/microbench.sh)
- Add branch/call/stringchain/arraymap/chip8/kilo cases
- Auto-calculate ratio vs C reference
- Document in benchmarks/README.md
- Compiler health improvements
- Unify PHI insertion to insert_phi_at_head()
- Add NYASH_LLVM_SKIP_BUILD=1 for build reuse
- Runtime & safety enhancements
- Clarify Rust/Hako ownership boundaries
- Strengthen receiver localization (LocalSSA/pin/after-PHIs)
- Stop excessive PluginInvoke→BoxCall rewrites
- Update CURRENT_TASK.md, docs, and canaries
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-13 16:40:58 +09:00
a800acdb63
refactor: MIR instruction.rs 4-Phase大型リファクタリング完了(888→315行、64%削減)
...
Single Responsibility Principle適用による完全分離:
- Phase 1: テスト分離 → instruction/tests.rs (196行)
- Phase 2: Display実装分離 → instruction/display.rs (130行)
- Phase 3: メソッド実装分離 → instruction/methods.rs (247行)
- Phase 4: 統合テスト成功(全コンパイルエラー解決)
技術的成果:
- MirInstruction enumを単一責任に集中
- 各実装が独立して保守可能な構造
- EffectMask::read→READ修正も完了
- ビルド成功確認済み(警告のみ)
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-25 03:46:37 +09:00
868519c691
cleanup: MIRレガシーコード71行削除でJSON作業準備完了
...
Phase 15.5準備として、MIRコードベースの大規模クリーンアップを実施。
JSON centralization作業前の環境整備が完了しました。
削除内容(71行):
- コメントアウトされたimport文: 2行
- 不要なlegacy/removedコメント: 9行
- movedコメント大規模整理: 56行
- 開発用debugコード(eprintln!): 4行
安全性確認:
- 統一Call実装(NYASH_MIR_UNIFIED_CALL=1): 正常動作✅
- Legacy実装(NYASH_MIR_UNIFIED_CALL=0): 後方互換性維持✅
- JSON出力: mir_call形式で正常生成✅
Phase 15(80k→20k行削減)への貢献: 約0.09%
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-24 04:09:23 +09:00
81211c22ad
feat: MIR Call命令統一Phase 3.1-3.2完了!統一Call実装進行中
...
✨ Phase 3.1-3.2実装完了
- build_indirect_call_expressionでCallTarget::Value使用
- print関数をcall_global print()として統一
- build_function_callでemit_unified_call使用
- ExternCall(env.console.log)→Callee::Global(print)完全移行
🏗️ MIR統一基盤構築
- src/mir/definitions/call_unified.rs: 統一定義(297行)
- emit_unified_call()と便利メソッド3種実装
- NYASH_MIR_UNIFIED_CALL=1で段階移行制御
- VM実行器でCallee対応実装済み
📊 進捗状況(26%削減見込み)
- Phase 1-2: ✅ 基盤構築完了
- Phase 3.1-3.2: ✅ 基本関数統一完了
- Phase 3.3: 🔄 BoxCall統一中
- Phase 4: 📅 Python LLVM(最優先・63%削減)
- Phase 5: 📅 PyVM/VM統一
📚 ドキュメント更新
- CLAUDE.md: テストスクリプト参考集追加
- CURRENT_TASK.md: Phase 3進捗更新
- python-llvm-priority-rationale.md: 優先順位戦略文書化
- mir-call-unification-master-plan.md: スケジュール最新化
🎯 6種類→1種類: Call/BoxCall/PluginInvoke/ExternCall/NewBox/NewClosure → MirCall統一へ
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-24 01:05:44 +09:00
da78fc174b
selfhost/runtime: Stage 0-1 runner + MIR JSON loader (summary) with trace; compiler: scopebox/loopform prepass wiring (flags, child args); libs: add P1 standard boxes (console/string/array/map) as thin wrappers; runner: pass --box-pref via env; ops_calls dispatcher skeleton; docs: selfhost executor roadmap + scopebox/loopform notes; smokes: selfhost runner + identity prepasses; CURRENT_TASK: update plan and box lib schedule
2025-09-22 21:52:39 +09:00
c8063c9e41
pyvm: split op handlers into ops_core/ops_box/ops_ctrl; add ops_flow + intrinsic; delegate vm.py without behavior change
...
net-plugin: modularize constants (consts.rs) and sockets (sockets.rs); remove legacy commented socket code; fix unused imports
mir: move instruction unit tests to tests/mir_instruction_unit.rs (file lean-up); no semantic changes
runner/pyvm: ensure using pre-strip; misc docs updates
Build: cargo build ok; legacy cfg warnings remain as before
2025-09-21 08:53:00 +09:00
d99b941218
docs: add MIR13 mode doc and set PHI-off as default; bridge lowering split (if/loop/try); llvmlite resolver stabilization; curated runner default PHI-off; refresh CURRENT_TASK.md
2025-09-17 10:58:12 +09:00
adbb0201a9
chore(fmt): add legacy stubs and strip trailing whitespace to unblock cargo fmt
2025-09-17 07:43:07 +09:00
6488b0542e
Phase 12.7完了 + ChatGPT5によるVMリファクタリング
...
## 📚 Phase 12.7 ドキュメント整理
- ChatGPT5作成のANCP Token仕様書v1を整備
- フォルダ構造を機能別に再編成:
- ancp-specs/ : ANCP圧縮技法仕様
- grammar-specs/ : 文法改革仕様
- implementation/ : 実装計画
- ai-feedback/ : AIアドバイザーフィードバック
- 各フォルダにREADME.md作成で導線改善
## 🔧 ChatGPT5によるVMリファクタリング
- vm_instructions.rs (1927行) をモジュール分割:
- boxcall.rs : Box呼び出し処理
- call.rs : 関数呼び出し処理
- extern_call.rs : 外部関数処理
- function_new.rs : FunctionBox生成
- newbox.rs : Box生成処理
- plugin_invoke.rs : プラグイン呼び出し
- VM実行をファイル分割で整理:
- vm_state.rs : 状態管理
- vm_exec.rs : 実行エンジン
- vm_control_flow.rs : 制御フロー
- vm_gc.rs : GC処理
- plugin_loader_v2もモジュール化
## ✨ 新機能実装
- FunctionBox呼び出しのVM/MIR統一進捗
- ラムダ式のFunctionBox変換テスト追加
- 関数値の直接呼び出し基盤整備
次ステップ: ANCPプロトタイプ実装開始(Week 1)
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-09-04 03:41:02 +09:00
0976326a6e
🔧 ビルドエラー修正完了 - Phase 10.11継続中
...
主な修正:
- MirInstruction::PluginInvokeのパターンマッチ追加
- ChatGPT5による変更に対応
- 58個の警告(未使用import)は意図的(ビルトインBox削除中)
ビルド成功!Everything is Plugin革命進行中 🚀
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-30 02:04:00 +09:00
e21778c048
phase_9_79b_1: Add Unified Registry IDs + Builder Slotting\n- MIR BoxCall carries optional method_id (slot)\n- Slot registry with universal slots [0..3]\n- Builder resolves method_id when receiver type known\n- Printer shows method_id; backends updated\n- Update CURRENT_TASK + MIR spec note
2025-08-26 20:48:48 +09:00
bf4b87526e
phase(9.78h): stabilize MIR/VM pipeline
...
- Add MIR26 doc≡code sync test (tests/mir_instruction_set_sync.rs)
- Quiet snapshots; filter plugin/net logs; golden all green
- Delegate VM phi selection to LoopExecutor (borrow-safe)
- ResultBox migration: remove legacy box_trait::ResultBox paths
- VM BoxRef arithmetic fallbacks via toString().parse::<i64>()
- Bridge BoxCall(InstanceBox) to Class.method/arity in VM
- Fix Effects purity (READ -> readonly, not pure)
- Mark Catch as CONTROL to prevent DCE; Try/Catch test green
- Add env-gated debug logs (effects, verifier, mir-printer, trycatch, ref, bin)
- Update CURRENT_TASK with progress and next steps
2025-08-26 05:49:23 +09:00
fffbac9aac
feat: MIR TypeOp/WeakRef/Barrier PoC implementation
...
- Add TypeOpKind, WeakRefOp, BarrierOp enums for unified instructions
- Implement TypeOp instruction combining TypeCheck/Cast
- Implement WeakRef instruction combining WeakNew/WeakLoad
- Implement Barrier instruction combining BarrierRead/BarrierWrite
- Update VM to handle new unified instructions
- Update MIR printer for new instruction formats
- Add feature flags mir_typeop_poc and mir_refbarrier_unify_poc
- Maintain backward compatibility with legacy instructions
This is Phase 8.5 MIR instruction diet PoC implementation.
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-23 19:27:02 +09:00
bec0e9bc92
revert: 古いプラグインシステム実装前の状態に巻き戻し
...
- ソースコードをcommit 3f7d71fの状態に復元(古いプラグインシステム実装前)
- docsフォルダは最新の状態を維持(BID-FFI設計ドキュメント含む)
- nyashバイナリの基本動作確認済み
- BID-FFIシステムをクリーンに再実装する準備完了
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-18 08:34:19 +09:00
5b7ef32277
feat(phase-5.2): Complete backend cleanup - reject deprecated MIR instructions
...
Phase 5.2 of MIR 35→26 reduction project:
- VM backend: Reject all 17 deprecated instructions with proper error messages
- WASM backend: Reject deprecated instructions with migration guidance
- All deprecated instructions now properly handled in both backends
- Build successful with expected deprecation warnings
Deprecated instructions removed:
- UnaryOp → Use BinOp
- Load/Store → Use BoxFieldLoad/BoxFieldStore
- ArrayGet/ArraySet → Use BoxFieldLoad/BoxFieldStore or intrinsics
- Print/Debug → Use Call @print/@debug
- TypeCheck/Cast → Use Call @type_check/@cast
- Throw/Catch → Use Call @throw/@catch
- RefNew → References handled implicitly
- BarrierRead/BarrierWrite → Use AtomicFence
- FutureNew/FutureSet/Await → Use NewBox/BoxCall
- Copy/Nop → Not needed in final IR
2025-08-17 14:06:47 +09:00
3df87fb1ce
fix(phase-4.3c-3): Fix StringBox literal handling in MIR builder
...
Phase 4-3c-3 Complete: WASM host functions now correctly output string content
## Changes:
- Fixed MIR builder to handle StringBox with string literal arguments
- Special case for to generate proper string constants
- Removed debug output after successful verification
- WASM now correctly outputs "Hello MIR!" instead of "StringBox"
## Test Results:
- MIR generation: ✅ Generates correctly
- WASM compilation: ✅ String data correctly placed at offset 4096
- WASM execution: ✅ Outputs "Hello MIR\!" as expected
## Technical Details:
- Modified build_new_expression() to detect StringBox with literal arguments
- Generates Const instruction with actual string content
- Host function reads StringBox memory layout correctly
This completes the WASM string output functionality for Phase 4.
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-08-17 13:49:35 +09:00
2091462441
Implement Phase 9.7: ExternCall instruction and WASM runtime imports
...
Co-authored-by: moe-charm <217100418+moe-charm@users.noreply.github.com >
2025-08-14 08:56:39 +00:00
b59f0ee419
Phase 7.1: Add MIR instructions for async operations (FutureNew, FutureSet, Await)
...
Co-authored-by: moe-charm <217100418+moe-charm@users.noreply.github.com >
2025-08-13 11:46:01 +00:00
84d2aac8da
Implement Phase 6 Box reference operations in MIR/VM - RefNew/RefGet/RefSet/WeakNew/WeakLoad/Barrier*
...
Co-authored-by: moe-charm <217100418+moe-charm@users.noreply.github.com >
2025-08-13 09:45:22 +00:00
d3a85b2305
Implement Phase 5: Control flow & exceptions in MIR/VM - Core functionality complete
...
Co-authored-by: moe-charm <217100418+moe-charm@users.noreply.github.com >
2025-08-13 06:23:28 +00:00
2f3b453fcb
Implement Phase 1: MIR + VM backend with golden tests
...
Co-authored-by: moe-charm <217100418+moe-charm@users.noreply.github.com >
2025-08-13 05:59:10 +00:00
56af6c612f
Phase 3 Complete: Parser extended with weak field support
...
Co-authored-by: moe-charm <217100418+moe-charm@users.noreply.github.com >
2025-08-12 20:27:20 +00:00
774e0bb241
🚀 MIR Stage 1 Basic Infrastructure Complete - 20 Instructions + SSA + Effects
...
Co-authored-by: moe-charm <217100418+moe-charm@users.noreply.github.com >
2025-08-12 11:33:48 +00:00