|
|
22753f8cc3
|
fix(llvm): Phase 131-7 - Multi-pass vmap sync 修正(Branch bug 解消)
Phase 131-7: Multi-pass block lowering の vmap sync バグ修正
問題:
- Pass A (body instructions) が vmap_cur に値を保存
- Pass C (deferred terminators) が builder.vmap を参照
- → Pass A の値が Pass C に届かない
- → Branch condition が 0 に fallback → 無限ループ
修正:
- src/llvm_py/builders/block_lower.py (lines 237-248):
- PHI-only フィルタを削除
- 全ての値を global vmap に sync
変更ファイル:
- src/llvm_py/builders/block_lower.py: vmap sync 修正
- src/llvm_py/instructions/controlflow/branch.py: trace logging 追加
- src/llvm_py/instructions/unop.py: trace logging 追加
- src/llvm_py/llvm_builder.py: debug helpers 追加
- src/llvm_py/phi_wiring/wiring.py: trace logging 追加
- src/runner/modes/common_util/exec.rs: Python stdout 転送
結果:
- ✅ Branch bug 修正: ループが正しく終了
- ✅ 出力: 無限ループ → 3回で停止
- ❌ 新 bug 発見: ExternCall が null を受け取る(PHI 値の代わりに)
Next: Phase 131-8 (ExternCall argument handling 修正)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2025-12-14 07:38:21 +09:00 |
|
|
|
73613dcef0
|
feat(llvm): Phase 131-4 P1 完了 - PHI ordering 修正(multi-pass architecture)
Phase 131-4 P1: PHI After Terminator Bug 修正
問題:
- LLVM IR で PHI が terminator の後に出現(LLVM invariant 違反)
- Case B (loop_min_while.hako) が TAG-EMIT で失敗
修正:
- Multi-pass block lowering architecture 実装:
- Pass A: non-terminator instructions のみ emit
- Pass B: PHI finalization(block head に確実に配置)
- Pass C: deferred terminators を最後に emit
変更ファイル:
- src/llvm_py/builders/block_lower.py (~40行):
- lower_blocks() で terminator を defer
- lower_terminators() 新設(Pass C)
- _deferred_terminators dict で管理
- src/llvm_py/builders/function_lower.py (3行):
- Pass 順序更新: A→B→C
- src/llvm_py/instructions/ret.py (5行):
- _disable_phi_synthesis flag で Pass C 中の PHI 生成を抑制
テスト結果:
- Case B EMIT: ❌→✅ (修正成功)
- Case B LINK: ❌ (新 TAG-LINK: undefined nyash_console_log)
- Case A/B2: ✅ (退行なし)
箱化モジュール化:
- ✅ Multi-pass で責務分離
- ✅ Flag mechanism で構造的制御
- ✅ ハードコード禁止原則遵守
Next: Phase 131-5 (TAG-LINK 修正)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
2025-12-14 06:12:31 +09:00 |
|
|
|
419214a5a9
|
feat(naming): Python NamingHelper実装 - Rust NamingBoxのミラー完成
Phase 25.4 メンテナンス: Python LLVM側のNamingBox SSOT統一
## 📦 実装内容
### 1. Python NamingHelper作成
- 新規作成: `src/llvm_py/naming_helper.py`
- Rust `src/mir/naming.rs` と完全同一の意味論を実装
- 3つの関数:
- `encode_static_method(box_name, method, arity)` → "BoxName.method/arity"
- `canonical_box_name(raw)` → "main" → "Main"
- `normalize_static_global_name(func_name)` → "main._nop/0" → "Main._nop/0"
- doctest 9個全てPASS ✅
### 2. Python LLVM側の統一修正
- `instructions/boxcall.py:437` - f"Main.{method_name}/{arity}" → encode_static_method()
- `instructions/call.py:170-173` - traced_names タプル生成をNamingHelper経由に変更
- `pyvm/intrinsic.py:17, 50` - "Main.esc_json/1", "Main.dirname/1" → encode_static_method()
- `builders/entry.py:16` - 'Main.main/1' → encode_static_method("Main", "main", 1)
## 🎯 技術的成果
- **意味論一致**: Rust ↔ Python で完全同一の命名規則
- **保守性向上**: ハードコード4箇所 → NamingHelper一元管理
- **テスト完備**: doctest 9個でRust NamingBoxと同一動作を保証
## テスト結果
✅ python3 -m py_compile: 全ファイル構文OK
✅ python3 -m doctest naming_helper.py: 9 tests passed
## 参考
- Phase 25.4-A (Rust側): fa9cea51, bceb20ed
- Rust NamingBox SSOT: src/mir/naming.rs
🎉 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-21 09:38:49 +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 |
|
|
|
9e2fa1e36e
|
Phase 21.6 solidification: chain green (return/binop/loop/call); add Phase 21.7 normalization plan (methodize static boxes). Update CURRENT_TASK.md and docs.
|
2025-11-11 22:35:45 +09:00 |
|
|
|
7b1f791395
|
feat(phase21.5): Loop FORCE direct assembly + PHI/compare fixes
## Loop FORCE Direct Assembly ✅
- Added: Direct MIR assembly bypass when HAKO_MIR_BUILDER_LOOP_FORCE_JSONFRAG=1
- Implementation: Extracts limit from Program(JSON), generates minimal while-form
- Structure: entry(0) → loop(1) → body(2) → exit(3)
- PHI: i = {i0, entry} | {i_next, body}
- Location: tools/hakorune_emit_mir.sh:70-126
- Tag: [selfhost-direct:ok] Direct MIR assembly (FORCE=1)
## PHI/Compare Fixes (ny-llvmc) ✅
- Fixed: vmap maintenance for PHI results across instructions
- Fixed: PHI placeholder name consistency (bytes vs str)
- Fixed: ensure_phi_alloca creates unique placeholders per block
- Fixed: resolve_i64_strict properly looks up PHI results
- Files:
- src/llvm_py/phi_wiring/tagging.py
- src/llvm_py/phi_wiring/wiring.py
- src/llvm_py/instructions/compare.py
- src/llvm_py/resolver.py
## Testing Results
- VM backend: ✅ rc=10 (correct)
- Direct assembly MIR: ✅ Structurally correct
- Crate backend: ⚠️ PHI/compare issues (being investigated)
## Implementation Principles
- 既定挙動不変 (FORCE=1 gated)
- Dev toggle controlled
- Minimal diff, surgical changes
- Bypasses using resolution when FORCE=1
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-11 17:04:33 +09:00 |
|
|
|
f6c5dc9e43
|
Phase 22.x WIP: LLVM backend improvements + MIR builder enhancements
LLVM backend improvements:
- Add native LLVM backend support (NYASH_LLVM_BACKEND=native)
- Add crate backend selector with priority (crate > llvmlite)
- Add native_llvm_builder.py for native IR generation
- Add NYASH_LLVM_NATIVE_TRACE=1 for IR dump
MIR builder enhancements:
- Refactor lower_if_compare_* boxes for better code generation
- Refactor lower_return_* boxes for optimized returns
- Refactor lower_loop_* boxes for loop handling
- Refactor lower_method_* boxes for method calls
- Update pattern_util_box for better pattern matching
Smoke tests:
- Add phase2100 S3 backend selector tests (17 new tests)
- Add phase2120 native backend tests (4 new tests)
- Add phase2034 MIR builder internal tests (2 new tests)
- Add phase2211 TLV shim parity test
Documentation:
- Update ENV_VARS.md with LLVM backend variables
- Update CURRENT_TASK.md with progress
- Update README.md and CHANGELOG.md
Config:
- Add NYASH_LLVM_BACKEND env support in src/config/env.rs
- Update ny_mir_builder.sh for backend selection
- Update dispatch.rs for backend routing
Tools:
- Add tools/native_llvm_builder.py
- Update smokes/v2/profiles/quick/core/phase2100/run_all.sh
Known: Many Hako builder internal files modified for optimization
|
2025-11-09 23:40:36 +09:00 |
|
|
|
0455307418
|
refactor(phase-a): remove Cranelift/JIT backend legacy code (~373 lines)
Phase A cleanup - Safe deletions with zero risk:
## Deleted Files (6 files, 373 lines total)
1. Cranelift/JIT Backend (321 lines):
- src/runner/modes/cranelift.rs (45 lines)
- src/runner/modes/aot.rs (55 lines)
- src/runner/jit_direct.rs (152 lines)
- src/tests/core13_smoke_jit.rs (42 lines)
- src/tests/core13_smoke_jit_map.rs (27 lines)
2. Legacy MIR Builder (52 lines):
- src/mir/builder/exprs_legacy.rs
- Functionality inlined into exprs.rs (control flow constructs)
## Module Reference Cleanup
- src/backend/mod.rs: Removed cranelift feature gate exports
- src/runner/mod.rs: Removed jit_direct module reference
- src/runner/modes/mod.rs: Removed aot module reference
- src/mir/builder.rs: Removed exprs_legacy module
## Impact Analysis
- Build: Success (cargo build --release)
- Tests: All passing
- Risk Level: None (feature already archived, code unused)
- Related: Phase 15 JIT archival (archive/jit-cranelift/)
## BID Copilot Status
- Already removed in previous cleanup
- Not part of this commit
Total Reduction: 373 lines (~0.4% of codebase)
Next: Phase B - Dead code investigation
Related: #phase-21.0-cleanup
Part of: Legacy Code Cleanup Initiative
|
2025-11-06 22:34:18 +09:00 |
|
|
|
e326e787a4
|
release: v21.0.0 – Full Self‑Hosting (S1/S2/S3 complete)
- DoD met: S1/S2 determinism (const/compare/threeblock-collect), PRIMARY hv1 inline no-fallback, S3 (llvmlite+kernel) reps green
- Harness: v1→llvmlite direct, EXE links to libnyash_kernel.a
- Python LLVM builder fixes: cmp normalization, ret PHI synthesis, mir_call flat shape
- Using/alias polish (prod): modules-first; missing aliases added; duplicate using cleaned
- Docs: phase-21.0 COMPLETE; CurrentTask closed; release notes added
|
2025-11-06 16:59:34 +09:00 |
|
|
|
cb236b7f5a
|
json(vm): fix birth dispatch; unify constructor naming (Box.birth/N); JsonNode factories return JsonNodeInstance; quick: enable heavy JSON with probe; builder: NYASH_BUILDER_DEBUG_LIMIT guard; json_query_min(core) harness; docs/tasks updated
|
2025-09-27 08:45:25 +09:00 |
|
|
|
28c721d82b
|
feat: Phase 15.5 llvmlite革命達成!真の統一Call基盤完成
6種類Callee完全統一でデリゲート方式→真の統一実装へ革命的移行。
モックルート回避確立でセルフホスティング基盤強化完了。
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-09-24 02:11:59 +09:00 |
|
|
|
da32455afc
|
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
|
2025-09-19 22:27:59 +09:00 |
|
|
|
811e3eb3f8
|
feat: comprehensive development progress
- Pattern matching implementation extended in match_expr.rs
- CLI configuration structured with categorized groups (task recommendation completed)
- Python LLVM builder split into function_lower.py (task recommendation completed)
- parse_box_declaration massive function refactored (task recommendation completed)
- Phase 16 Macro Revolution comprehensive planning and documentation
- Archive legacy phase documentation for clean structure
- HTTP message box improvements and performance optimizations
- MIR builder enhancements and control flow improvements
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-09-19 15:11:57 +09:00 |
|
|
|
3c7a5de900
|
runner(cli): adopt CliConfig::as_groups across runner modules (dispatch/common/pipe_io/mir/bench). llvm-builder: extract ny_main wrapper to builders.entry; add optional env-gated function_lower delegation; keep default behavior unchanged
|
2025-09-19 14:29:02 +09:00 |
|