Commit Graph

401 Commits

Author SHA1 Message Date
f1fa182a4b AotPrep collections_hot matmul tuning and bench tweaks 2025-11-14 13:36:20 +09:00
13f21334c9 fix(aot): resolve copy chains in PHI propagation for deep loop coverage
Fix CollectionsHot type_table to resolve copy chains when propagating types
through PHI nodes, enabling ArrayBox optimization in deeply nested loops (matmul).

**Root Cause:**
- PHI incoming values were checked directly in type_table
- Copy chains (e.g., SSA 56→11) were not resolved
- Types failed to propagate through deep loop nesting

**Solution:**
- Add copy_src_map parameter to build_type_table()
- Resolve copy chains before checking if PHI incoming values are typed
- Multi-pass fixpoint algorithm (up to 12 passes) ensures convergence

**Impact:**
- matmul: ArrayBox A/B/C now propagate through nested loops
- Expected: boxcall→externcall conversion for get/set/push
- Backwards compatible: opt-in (NYASH_AOT_COLLECTIONS_HOT=1), no behavior change when disabled

**Analysis:**
- Documented in docs/development/analysis/matmul_collections_hot_fix.md
- Box→SSA flow traced: A(dst=2)→...→71(get), B(dst=3)→...→73(get), C(dst=4)→...→105(set)

**Testing:** Pending verification due to VM step budget constraints

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-14 06:54:56 +09:00
8b44c5009f fix(mir): fix else block scope bug - PHI materialization order
Root Cause:
- Else blocks were not propagating variable assignments to outer scope
- Bug 1 (if_form.rs): PHI materialization happened before variable_map reset,
  causing PHI nodes to be lost
- Bug 2 (phi.rs): Variable merge didn't check if else branch modified variables

Changes:
- src/mir/builder/if_form.rs:93-127
  - Reordered: reset variable_map BEFORE materializing PHI nodes
  - Now matches then-branch pattern (reset → materialize → execute)
  - Applied to both "else" and "no else" branches for consistency
- src/mir/builder/phi.rs:137-154
  - Added else_modified_var check to detect variable modifications
  - Use modified value from else_var_map_end_opt when available
  - Fall back to pre-if value only when truly not modified

Test Results:
 Simple block: { x=42 } → 42
 If block: if 1 { x=42 } → 42
 Else block: if 0 { x=99 } else { x=42 } → 42 (FIXED!)
 Stage-B body extraction: "return 42" correctly extracted (was null)

Impact:
- Else block variable assignments now work correctly
- Stage-B compiler body extraction restored
- Selfhost builder path can now function
- Foundation for Phase 21.x progress

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-13 20:16:20 +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
52b62c5772 feat(phase21.5): Stage-B parser loop fix + delegate path stabilization
## 修正内容

### 1. Stage-B パーサー修正(偶然の回避)
- **ファイル**:
  - `lang/src/compiler/parser/expr/parser_expr_box.hako`
  - `lang/src/compiler/parser/stmt/parser_control_box.hako`
- **問題**: ネストループで gpos が正しく進まず、loop の cond/body が壊れる
- **回避策**: new 式のメソッドチェーン処理追加で別ループを導入
- **結果**: MIR 生成が変わって VM gpos バグを回避

### 2. delegate パス動作確認
- **テスト**: `/tmp/loop_min.hako` → rc=10 
- **MIR構造**: 正しい PHI/compare/binop を生成
- **チェーン**: hakorune parser → Rust delegate → LLVM EXE 完動

### 3. ドキュメント追加
- `docs/development/analysis/` - delegate 分析
- `docs/development/guides/` - ループテストガイド
- `docs/development/testing/` - Stage-B 検証報告

### 4. カナリーテスト追加
- `tools/smokes/v2/profiles/quick/core/phase2100/` 配下に複数追加
- emit_boxcall_length_canary_vm.sh
- stageb_parser_loop_json_canary_vm.sh
- 他

### 受け入れ基準
-  delegate パス: rc=10 返す
-  FORCE パス: rc=10 返す(既存)
-  MIR 構造: 正しい PHI incoming と compare
-  既定挙動: 不変(dev トグルのみ)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 21:24:51 +09:00
b9e9c967fb feat(phase21.5): Fix --emit-mir-json BoxCall emission + EXE staging docs
## Task 2: BoxCall Emission Fix 
- Fix: --emit-mir-json now properly emits boxcall for method calls when NYASH_MIR_UNIFIED_CALL=0
- Root cause: v0 format fallback wasn't inspecting Callee::Method enum
- Implementation: Added proper v0 boxcall emission with dst_type hints
- Location: src/runner/mir_json_emit.rs:329-368
- Preserves: All default behavior, only affects explicit NYASH_MIR_UNIFIED_CALL=0

## Task 4: Documentation Updates 
- Added: selfhost_exe_stageb_quick_guide.md (comprehensive usage guide)
- Added: selfhost_exe_stageb_verification_report.md (test results)
- Updated: tools/selfhost_exe_stageb.sh with prerequisite comments
- Documented: EXE test timeout recommendations (--timeout 120)
- Documented: NYASH_EXE_ARGV=1 usage with ensure_ny_main/argv_get
- Added: Phase 2034 emit_boxcall_length canary test

## Implementation Principles
- 既定挙動不変 (Default behavior unchanged)
- 最小差分 (Minimal diff)
- ロールバック容易 (Easy rollback via clear else-if block)
- Dev toggle guarded (NYASH_MIR_UNIFIED_CALL=0 explicit activation)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 03:28:01 +09:00
07a254fc0d feat(phase21.5): MirBuilder optimization prep + crate EXE infrastructure
Phase 21.5 optimization readiness - C-level performance target:
- MirBuilder: JsonFrag purify toggle (HAKO_MIR_BUILDER_JSONFRAG_PURIFY=1)
- Normalizer: extended f64 canonicalization + dedupe improvements
- loop_opts_adapter: JsonFrag path refinement for crate EXE compatibility

Infrastructure improvements:
- provider_registry: add diagnostics + ring-1 providers (array/console/map/path)
- mir_interpreter: add normalization/purify feature gates
- tools/selfhost_exe_stageb.sh: new end-to-end Stage-B→crate EXE pipeline
- tools/perf/microbench.sh: performance measurement tooling

Smoke tests (phase2100):
- Extend timeout 15s→120s for heavy crate EXE builds
- Add stageb_loop_jsonfrag_crate_exe_canary_vm.sh (target test)
- Add s3_backend_selector_crate_exe_vm_parity_return42_canary_vm.sh

Documentation:
- ENV_VARS.md: add Phase 21.5 optimization toggles
- README updates: clarify crate backend strategy
- phase215-optimization.md: new optimization roadmap

This commit sets the stage for Phase 21.5 critical optimization:
achieving C-level performance to decide hakorune's future viability.
2025-11-11 02:07:12 +09:00
ece91306b7 mirbuilder: integrate Normalizer (toggle), add tag-quiet mode, share f64 canonicalization; expand canaries; doc updates for quick timeout + dev toggles; Phase 21.5 optimization readiness 2025-11-10 23:17:46 +09:00
6055d53eff feat(phase21.5/22.1): MirBuilder JsonFrag refactor + FileBox ring-1 + registry tests
Phase 21.5 (AOT/LLVM Optimization Prep)
- FileBox ring-1 (core-ro) provider: priority=-100, always available, no panic path
  - src/runner/modes/common_util/provider_registry.rs: CoreRoFileProviderFactory
  - Auto-registers at startup, eliminates fallback panic structurally
- StringBox fast path prototypes (length/size optimization)
- Performance benchmarks (C/Python/Hako comparison baseline)

Phase 22.1 (JsonFrag Unification)
- JsonFrag.last_index_of_from() for backward search (VM fallback)
- Replace hand-written lastIndexOf in lower_loop_sum_bc_box.hako
- SentinelExtractorBox for Break/Continue pattern extraction

MirBuilder Refactor (Box → JsonFrag Migration)
- 20+ lower_*_box.hako: Box-heavy → JsonFrag text assembly
- MirBuilderMinBox: lightweight using set for dev env
- Registry-only fast path with [registry:*] tag observation
- pattern_util_box.hako: enhanced pattern matching

Dev Environment & Testing
- Dev toggles: SMOKES_DEV_PREINCLUDE=1 (point-enable), HAKO_MIR_BUILDER_SKIP_LOOPS=1
- phase2160: registry opt-in tests (array/map get/set/push/len) - content verification
- phase2034: rc-dependent → token grep (grep -F based validation)
- run_quick.sh: fast smoke testing harness
- ENV documentation: docs/ENV_VARS.md

Test Results
 quick phase2034: ALL GREEN (MirBuilder internal patterns)
 registry phase2160: ALL GREEN (array/map get/set/push/len)
 rc-dependent tests → content token verification complete
 PREINCLUDE policy: default OFF, point-enable only where needed

Technical Notes
- No INCLUDE by default (maintain minimalism)
- FAIL_FAST=0 in Bring-up contexts only (explicit dev toggles)
- Tag-based route observation ([mirbuilder/min:*], [registry:*])
- MIR structure validation (not just rc parity)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 19:42:42 +09:00
b0898fcd7b docs: expand LLVM backend ENV vars documentation
Phase 22.x: add NYASH_LLVM_NATIVE_TRACE and expand NYASH_LLVM_BACKEND
- Add auto mode with llvmlite→crate fallback priority
- Add NYASH_LLVM_NATIVE_TRACE=1 for native IR stderr dump
- Clarify each backend option (llvmlite/crate/native)
2025-11-09 23:44:16 +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
981ddd890c Phase 22.1 WIP: SSOT resolver + TLV infrastructure + Hako MIR builder setup
Setup infrastructure for Phase 22.1 (TLV C shim & Resolver SSOT):

Core changes:
- Add nyash_tlv, nyash_c_core, nyash_kernel_min_c crates (opt-in)
- Implement SSOT resolver bridge (src/using/ssot_bridge.rs)
- Add HAKO_USING_SSOT=1 / HAKO_USING_SSOT_HAKO=1 env support
- Add HAKO_TLV_SHIM=1 infrastructure (requires --features tlv-shim)

MIR builder improvements:
- Fix using/alias consistency in Hako MIR builder
- Add hako.mir.builder.internal.{prog_scan,pattern_util} to nyash.toml
- Normalize LLVM extern calls: nyash.console.* → nyash_console_*

Smoke tests:
- Add phase2211 tests (using_ssot_hako_parity_canary_vm.sh)
- Add phase2220, phase2230, phase2231 test structure
- Add phase2100 S3 backend selector tests
- Improve test_runner.sh with quiet/timeout controls

Documentation:
- Add docs/ENV_VARS.md (Phase 22.1 env vars reference)
- Add docs/development/runtime/C_CORE_ABI.md
- Update de-rust-roadmap.md with Phase 22.x details

Tools:
- Add tools/hakorune_emit_mir.sh (Hako-first MIR emission wrapper)
- Add tools/tlv_roundtrip_smoke.sh placeholder
- Improve ny_mir_builder.sh with better backend selection

Known issues (to be fixed):
- Parser infinite loop in static method parameter parsing
- Stage-B output contamination with "RC: 0" (needs NYASH_JSON_ONLY=1)
- phase2211/using_ssot_hako_parity_canary_vm.sh fork bomb (needs recursion guard)

Next steps: Fix parser infinite loop + Stage-B quiet mode for green tests
2025-11-09 15:11:18 +09:00
5d2cd5bad0 de-rust phase-0: archive Rust LLVM backend to archive/rust-llvm-backend (RESTORE documented); defaults unaffected 2025-11-09 01:00:43 +09:00
024a4fecb7 phase-21.9: add De‑Rust roadmap + phase plan; stage archive script for Rust LLVM backend (no move yet) 2025-11-09 00:57:10 +09:00
fa3091061d trace: add execution route visibility + debug passthrough; phase2170 canaries; docs
- Add HAKO_TRACE_EXECUTION to trace executor route
  - Rust hv1_inline: stderr [trace] executor: hv1_inline (rust)
  - Hakovm dispatcher: stdout [trace] executor: hakovm (hako)
  - test_runner: trace lines for hv1_inline/core/hakovm routes
- Add HAKO_VERIFY_SHOW_LOGS and HAKO_DEBUG=1 (enables both)
  - verify_v1_inline_file() log passthrough with numeric rc extraction
  - test_runner exports via HAKO_DEBUG
- Canary expansion under phase2170 (state spec)
  - Array: push×5/10 → size, len/length alias, per‑recv/global, flow across blocks
  - Map: set dup-key non-increment, value_state get/has
  - run_all.sh: unify, remove SKIPs; all PASS
- Docs
  - ENV_VARS.md: add Debug/Tracing toggles and examples
  - PLAN.md/CURRENT_TASK.md: mark 21.7 green, add Quickstart lines

All changes gated by env vars; default behavior unchanged.
2025-11-08 23:45:29 +09:00
bf185ec2b2 Update docs/private submodule: Phase 21.5 plan
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 17:05:57 +09:00
50ac8af2b8 Phase 21.4 Complete: FileBox SSOT + Analyzer Stabilization (7 Tasks)
 Task 1: Fallback Guarantee (create_box failure → ring1/core-ro auto fallback)
- Three-tier fallback system: plugin → builtin → core-ro
- Mode control: auto/plugin-only/core-ro
- New: src/box_factory/builtin_impls/file_box.rs
- New: tools/test_filebox_fallback_smoke.sh

 Task 2: Provider Registration SSOT (static/dynamic/core-ro unified)
- ProviderFactory trait with priority-based selection
- Global registry PROVIDER_FACTORIES implementation
- Priority: dynamic(100) > builtin(10) > core-ro(0)
- New: src/boxes/file/builtin_factory.rs
- New: tools/smoke_provider_modes.sh

 Task 3: FileBox Publication Unification
- Verified: basic/file_box.rs already minimized (11 lines)
- Perfect re-export pattern maintained

 Task 4: ENV Unification (FILEBOX_MODE/DISABLE_PLUGINS priority)
- Removed auto-setting of NYASH_USE_PLUGIN_BUILTINS
- Removed auto-setting of NYASH_PLUGIN_OVERRIDE_TYPES
- Added deprecation warnings with migration guide
- ENV hierarchy: DISABLE_PLUGINS > BOX_FACTORY_POLICY > FILEBOX_MODE

 Task 5: Error Log Visibility (Analyzer rule execution errors to stderr)
- Added [rule/exec] logging before IR-based rule execution
- Format: [rule/exec] HC012 (dead_static_box) <filepath>
- VM errors now traceable via stderr output

 Task 6: Unnecessary Using Removal (14 rules Str alias cleanup)
- Removed unused `using ... as Str` from 14 rule files
- All rules use local _itoa() helper instead
- 14 lines of dead code eliminated

 Task 7: HC017 Skip & TODO Documentation (UTF-8 support required)
- Enhanced run_tests.sh with clear skip message
- Added "Known Limitations" section to README.md
- Technical requirements documented (3 implementation options)
- Re-enable timeline: Phase 22 (Unicode Support Phase)

📊 Test Results:
- Analyzer: 10 tests PASS, 1 skipped (HC017)
- FileBox fallback: All 3 modes PASS
- Provider modes: All 4 modes PASS
- Build: Success (0 errors, 0 warnings)

🎯 Key Achievements:
- 28 files modified/created
- Three-Tier Fallback System (stability)
- SSOT Provider Registry (extensibility)
- ENV unification (operational clarity)
- Error visibility (debugging efficiency)
- Code cleanup (maintainability)
- Comprehensive documentation (Phase 22 ready)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 17:04:21 +09:00
772149c86d Analyzer安定化完了: NYASH_DISABLE_PLUGINS=1復元 + plugin無効化根治
## 修正内容
1. **hako_check.sh/run_tests.sh**: NYASH_DISABLE_PLUGINS=1 + NYASH_BOX_FACTORY_POLICY=builtin_first追加
2. **src/box_factory/plugin.rs**: NYASH_DISABLE_PLUGINS=1チェック追加
3. **src/box_factory/mod.rs**: plugin shortcut pathでNYASH_DISABLE_PLUGINS尊重
4. **tools/hako_check/render/graphviz.hako**: smart quotes修正(parse error解消)

## 根本原因
- NYASH_USE_PLUGIN_BUILTINS=1が自動設定され、ArrayBox/MapBoxがplugin経由で生成を試行
- bid/registry.rsで"Plugin loading temporarily disabled"の状態でも試行されエラー
- mod.rs:272のshortcut pathがNYASH_DISABLE_PLUGINSを無視していた

## テスト結果
- 10/11 PASS(HC011,13-18,21-22,31)
- HC012: 既存issue(JSON安定化未完)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 15:49:25 +09:00
cef820596f FileBox SSOT設計移行完了: Provider Pattern実装
## 🎯 目的
FileBoxをSSOT(Single Source of Truth)設計に移行し、
static/dynamic/builtin providerを統一的に扱える基盤を構築。

##  実装完了(7タスク)

### 1. Provider Lock Global
**File**: `src/runtime/provider_lock.rs`
- `FILEBOX_PROVIDER: OnceLock<Arc<dyn FileIo>>` 追加
- `set_filebox_provider()` / `get_filebox_provider()` 実装

### 2. VM初期化時のProvider選択
**File**: `src/runner/modes/vm.rs`
- `execute_vm_mode()` 冒頭でprovider選択・登録
- ENV(`NYASH_FILEBOX_MODE`, `NYASH_DISABLE_PLUGINS`)対応

### 3. CoreRoFileIo完全実装
**File**: `src/boxes/file/core_ro.rs` (NEW)
- Read-onlyファイルI/O実装
- Thread-safe: `RwLock<Option<File>>`
- Newline正規化(CRLF→LF)

### 4. FileBox委譲化
**File**: `src/boxes/file/mod.rs`
- 直接`std::fs::File`使用 → `Arc<dyn FileIo>` provider委譲
- 全メソッドをprovider経由に変更
- Fail-Fast: write/delete等の非対応操作は明確エラー

### 5. basic/file_box.rs Deprecate
**File**: `src/boxes/file/basic/file_box.rs`
- 120行 → 12行に削減
- `#[deprecated]` マーク + 再エクスポート
- 後方互換性維持

### 6. Feature Flag追加
**File**: `Cargo.toml`
- `builtin-filebox = []` feature追加

### 7. Provider抽象・選択ロジック
**Files**:
- `src/boxes/file/provider.rs` (NEW) - FileIo trait定義
- `src/boxes/file/box_shim.rs` (NEW) - 薄いラッパー
- `src/runner/modes/common_util/provider_registry.rs` (NEW) - 選択ロジック

## 📊 アーキテクチャ進化

**Before**:
```
FileBox (mod.rs) ──直接使用──> std::fs::File
FileBox (basic/)  ──直接使用──> std::fs
```

**After**:
```
FileBox ──委譲──> Arc<dyn FileIo> ──実装──> CoreRoFileIo
                                        ├──> PluginFileIo (future)
                                        └──> BuiltinFileIo (future)
```

## 🔧 技術的成果

1. **Thread Safety**: `RwLock<Option<File>>` で並行アクセス安全
2. **Fail-Fast**: 非対応操作は明確エラー(silent failure無し)
3. **後方互換性**: deprecated re-exportで既存コード維持
4. **環境制御**: `NYASH_FILEBOX_MODE` でランタイム切替

## 📝 環境変数

- `NYASH_FILEBOX_MODE=auto|core-ro|plugin-only`
  - `auto`: プラグインあれば使用、なければCoreRoにフォールバック
  - `core-ro`: 強制的にCoreRo(read-only)
  - `plugin-only`: プラグイン必須(なければFail-Fast)
- `NYASH_DISABLE_PLUGINS=1`: 強制的にcore-roモード

## 🎯 次のステップ(Future)

- [ ] Dynamic統合(plugin_loaderとの連携)
- [ ] BuiltinFileIo実装(feature builtin-filebox)
- [ ] Write/Delete等の操作対応(provider拡張)

## 📚 ドキュメント

- 詳細仕様: `docs/development/runtime/FILEBOX_PROVIDER.md`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 15:13:22 +09:00
647e15d12e Update docs/private submodule: Phase 21.4 plan
Phase 21.4詳細実装計画追加

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 21:04:22 +09:00
b8fbbafc0c Update docs/private submodule: Phase 21.2-21.5 planning
Phase 21.2-21.5計画ドキュメント追加
- Phase 21.2: VM Adapter正規実装(完了)
- Phase 21.3-21.5: Checker/Parser/Integration計画

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 19:33:35 +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
8b6cbd8f70 chore: update docs/private submodule to latest 2025-11-06 17:36:22 +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
77d4fd72b3 phase: 20.49 COMPLETE; 20.50 Flow+String minimal reps; 20.51 selfhost v0/v1 minimal (Option A/B); hv1-inline binop/unop/copy; docs + run_all + CURRENT_TASK -> 21.0 2025-11-06 15:41:52 +09:00
44a5158a14 hv1: early-exit at main (no plugin init); tokenizer: Stage-3 single-quote + full escapes (\/ \b \f \' \r fix); builder: route BinOp via SSOT emit_binop_to_dst; hv1 verify canary route (builder→Core); docs: phase-20.39 updates 2025-11-04 20:46:43 +09:00
ab81564174 phase-20.39 step1: introduce typed IR shadow in hv1 dispatcher; step2: remove hv1 include fallback from verify (direct route only); add IR types module export; docs+current_task updated 2025-11-04 16:45:01 +09:00
30aa39f50b hv1 verify: add direct route (env JSON) and clean inline path; fix v1 phi incoming order; make test_runner use hv1 direct; add phase2037 phi canaries; load modules.workspace exports for alias; update docs (phase-20.38, source extensions) and CURRENT_TASK 2025-11-04 16:33:04 +09:00
a4f30ae827 Phase 20.34: expand MirBuilder internal library with comprehensive lowering boxes; add pattern registry and program scanning infrastructure; implement internal lowerers for if/loop/return patterns; add dev tools and comprehensive canary tests; update VM boxes and host providers for internal delegation; wire phase2034 test suite with 30+ canary scripts covering internal lowering scenarios
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2025-11-03 16:09:19 +09:00
ff62eb0d97 refactor(lang): comprehensive boxification and deduplication
Phase 1-4 Complete:
- Remove legacy archive folder (4 files, ~200 lines eliminated)
- Unify Handler pattern via CoreHandlerBaseBox (5 handlers simplified)
- Create InstFieldExtractorBox for common JSON field extraction
- Reorganize tests into unit/integration/regression categories

Impact:
- Code reduction: 400-600 lines (15-20%)
- Improved maintainability through unified design patterns
- Better test organization and structure
- Enhanced consistency following box-first principles
2025-11-02 12:30:30 +09:00
756af0da6c Phase 20.33: migrate docs to lang compiler entry; add Bridge canonicalize canary skeletons (opt-in); dep_tree.sh fail-fast legacy path; Gate-C OOB strict already present 2025-11-01 19:01:55 +09:00
c331296552 P0/P1/P2: quick緑化と境界/検証強化\n\n- P0: json_lint_vm を quick で opt-in 化(既定は SKIP)し、builder デバッグノイズは filter_noise で抑制\n- P1: ArrayBox に OOB Strict タグを導入(HAKO_OOB_STRICT/NYASH_OOB_STRICT)+ Stage‑B OOB 観測カナリア整備\n- P2: Bridge/LLVM self まわりの検証を opt-in スモークで拡充(self_param_*)。ドキュメント/PLAN/CHECKLIST/SSOT を更新 2025-11-01 17:39:36 +09:00
eef6fca8cd docs(loops): LoopForm SSOT設計ノートを追加し、Bridge側ループ降下にPHI到達検証を導入(debug時)。\n\n- 新規: docs/development/architecture/loops/loopform_ssot.md\n- 修正: src/runner/json_v0_bridge/lowering/loop_.rs に debug_verify_phi_inputs 呼び出しを追加\n- 方針: Direct MIR は既に phi_core を使用。Bridge は段階的に LoopPhiOps アダプタでSSOTに寄せる 2025-11-01 16:37:16 +09:00
01b4417c5d docs(llvm/vm): 静的Box(self)規約を明文化 + Bridgeトグル追記; Gate‑C/Core 現状反映; CURRENT_TASK 更新。\n\n- 新規: docs/development/architecture/llvm/static_box_singleton.md\n- 追記: lang/src/vm/README.md に self 先頭規約/互換トグルを明記\n- 追記: CURRENT_TASK に本更新を記録\n- phase-20.33/CHECKLIST にドキュメント完了チェックを追加\n- bak フォルダはリポジトリ直下に存在せず(削除対象なし)\n\n併せて未コミット差分をスナップショット(Rust 層の前作業含む) 2025-11-01 16:31:48 +09:00
6a452b2dca fix(mir): PHI検証panic修正 - update_cfg()を検証前に呼び出し
A案実装: debug_verify_phi_inputs呼び出し前にCFG predecessorを更新

修正箇所(7箇所):
- src/mir/builder/phi.rs:50, 73, 132, 143
- src/mir/builder/ops.rs:273, 328, 351

根本原因:
- Branch/Jump命令でsuccessorは即座に更新
- predecessorはupdate_cfg()で遅延再構築
- PHI検証が先に実行されてpredecessor未更新でpanic

解決策:
- 各debug_verify_phi_inputs呼び出し前に
  if let Some(func) = self.current_function.as_mut() {
      func.update_cfg();
  }
  を挿入してCFGを同期

影響: if/else文、論理演算子(&&/||)のPHI生成が正常動作
2025-11-01 13:28:56 +09:00
a38aa7b417 feat(phase33): mir_call.hako Stages 2-4 complete - 全段階実装完了 🎉
Stage 2: CallEmitBox拡張 (+12 lines)
- make_mir_call_closure(params, captures, me_capture, dst)
- make_mir_call_value(func_vid, arg_ids, dst)

Stage 3: mir_call.hako簡略化 (208→164 lines, -21.2%)
- CallEmitBox完全活用により手動JSON生成を削除
- 74.4%削減達成 (Python 641→Hakorune 164 lines)

Stage 4: Smoke Tests追加 (+102 lines)
- closure_simple.hako: Closure callee typeテスト
- value_simple.hako: Value callee typeテスト

Phase 33 Final Achievement:
 10/10 instructions 完全実装 (100%)
  - Phase v0: const, binop, compare, ret (4/4)
  - Phase v1: branch, jump, copy (3/3)
  - Phase v2-A: phi (1/1)
  - Phase v2-B: loopform (1/1)
  - Phase v2-C: mir_call (1/1) ← NEW!

Test Coverage:
- Unit tests: 288 lines (6 tests, all callee types)
- Smoke tests: 147 lines (3 tests)
- Total: 435 lines test coverage

🚀 Python → Hakorune Script 移行 100% 完了!
2025-11-01 09:05:02 +09:00
e5331c87b0 docs(phase33): update submodule - Stage 1 completion report added 2025-11-01 08:56:08 +09:00
ac797553cf docs(phase33): Update submodule with Phase v2-B loopform documentation
Submodule commit d8785d4:
- PHASE_V2_LOOPFORM_PLAN.md (519 lines)
- PHASE_V2_LOOPFORM_STAGE1_COMPLETE.md (365 lines)
- PHASE_V2_LOOPFORM_STAGE2_COMPLETE.md (421 lines)
- PHASE_V2_LOOPFORM_COMPLETE.md (396 lines)

Total: 1,701 lines of comprehensive Phase 33 documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 08:41:15 +09:00
967cf9019c submodule: restore docs/private as proper submodule; drop stray gitlinks (nekocode-rust, nyash-lang-papers) from index 2025-11-01 07:38:40 +09:00
a87ea2636c docs: clarify static box method arity (implicit self) and plan fix in Phase 20.33; expand Bridge singleton injection spec; update checklist 2025-11-01 07:07:29 +09:00
eabeb69d77 docs(phase-20.33): update Gate-C(Core) status (v1→MIR interpreter), mark parity smokes done; clean up wording\nchore: remove unused bak/ (external backup kept)\nsmokes: add Gate-C v1 file/pipe opt-in canaries; env toggles documented\nrunner: include json_v1_bridge + bridge toggles (singleton/phi) wiring 2025-11-01 07:02:04 +09:00
cac22c1a87 Runner: canonicalize json-file input via core_bridge when HAKO_NYVM_CORE=1 2025-11-01 05:19:10 +09:00
4f4ee948e0 Stage-B: add --v1-compat opt-in path and smoke 2025-11-01 03:56:25 +09:00
1f415e733c Stage-B: route FlowEntry context (using/extern) and default Stage-B entry 2025-11-01 03:03:51 +09:00
978bb4a5c6 runner: add NyVM wrapper core_bridge (canonicalize/dump) + opt-in wrapper canary; export module in common_util 2025-11-01 02:51:49 +09:00
5597b78f0d docs(phase-20.33): Stage‑B Hakorune compiler plan (scope/milestones/criteria) 2025-11-01 01:49:42 +09:00
8b71f25dd4 Stage-A selfhost emitter fixes and LLVM opt toggle 2025-10-31 23:16:27 +09:00
5e3d9e7ae4 restore(lang/compiler): bring back lang/src/compiler from e917d400; add Hako index canaries and docs; implement Rust-side index operator (Array/Map get/set) with Fail‑Fast diagnostics
- restore: lang/src/compiler/** (parser/emit/builder/pipeline_v2) from e917d400
- docs: docs/development/selfhosting/index-operator-hako.md
- smokes(hako): tools/smokes/v2/profiles/quick/core/index_operator_hako.sh (opt-in)
- smokes(vm): adjust index_operator_vm.sh for semicolon gate + stable error text
- rust/parser: allow IndexExpr and assignment LHS=Index; postfix parse LBRACK chain
- rust/builder: lower arr/map index to BoxCall get/set; annotate array/map literals; Fail‑Fast for unsupported types
- CURRENT_TASK: mark Rust side done; add Hako tasks checklist

Note: files disappeared likely due to branch FF to a lineage without lang/src/compiler; no explicit delete commit found. Added anchor checks and suggested CI guard in follow-up.
2025-10-31 20:18:39 +09:00
86fd03afe8 docs(specs): add Index Operator design; CURRENT_TASK: plan for Phase‑20.31 small-scope bring‑up 2025-10-31 19:35:47 +09:00