From bd0783fa856edd36461dd1dec7f2af769179181e Mon Sep 17 00:00:00 2001 From: tomoaki Date: Sat, 27 Dec 2025 00:31:29 +0900 Subject: [PATCH] docs(phase-285): Complete P4 Post-Completion documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 285 P4 Post-Completion activities (2025-12-27): 1. Phase 284 P2 Integration Fix (commit 225600b5f) - Fixed phase284_p2_return_in_loop_llvm (unreachable instruction) - Integration LLVM tests: 3/3 PASS (no FAIL remaining) 2. ret.py Box-First Refactoring (commits 32aa0ddf6, 5a88c4eb2) - Phase 1-2: UnreachableReturnHandlerBox + ReturnTypeAdjusterBox - Phase 3: StringBoxerBox + ReturnPhiSynthesizerBox - Reduced lower_return(): 166→117 lines (-29%) 3. Code Quality Improvements (4 commits) - LLVM exit code SSOT (d7c6df367) - nyash_kernel FFI split (798c193cb) - LLVM detection consolidation (1869396fd) - auto_detect.conf clarity (095213c58) Final status: - Integration LLVM tests: 3/3 PASS - Quick profile: 154/154 PASS - Current Focus: Phase 29y (post self-host, docs-first) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- docs/development/current/main/10-Now.md | 16 +++++- .../current/main/phases/phase-285/README.md | 50 ++++++++++++++++++- 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/docs/development/current/main/10-Now.md b/docs/development/current/main/10-Now.md index c633b1d3..3408922e 100644 --- a/docs/development/current/main/10-Now.md +++ b/docs/development/current/main/10-Now.md @@ -1,8 +1,8 @@ # Self Current Task — Now (main) -## Current Focus: Phase 29y(post self-host, docs-first)/ Phase 285 follow-ups +## Current Focus: Phase 29y(post self-host, docs-first) -Phase 285 の “weak + hidden root + LLVM one-pass(検出/設定含む)” は完了。次は post self-host の Phase 29y(MIR lifecycle vocab freeze相談)を docs-first で進める。 +Phase 285 の "weak + hidden root + LLVM one-pass(検出/設定含む)" は完全完了(P4 Post-Completion 含む)。次は post self-host の Phase 29y(MIR lifecycle vocab freeze相談)を docs-first で進める。 **2025-12-26: Phase 285 P2 完了** ✅ - weak の意味論(`weak ` + `weak_to_strong()` 成功)を integration smoke で固定 @@ -19,6 +19,18 @@ Phase 285 の “weak + hidden root + LLVM one-pass(検出/設定含む)” - `KeepAlive { values, drop_after }` を廃止し、`KeepAlive` / `ReleaseStrong` に命令分離(意図を MIR 語彙で明確化) - quick smoke 154/154 PASS 維持 +**2025-12-27: Phase 285 P4 Post-Completion** ✅ +- **Phase 284 P2 Integration Fix** (commit `225600b5f`) + - `phase284_p2_return_in_loop_llvm` FAIL 修正(unreachable instruction 使用) + - Integration LLVM tests: 3/3 PASS(FAIL 残りなし) +- **ret.py Box-First Refactoring** (commits `32aa0ddf6`, `5a88c4eb2`) + - Phase 1-2: UnreachableReturnHandlerBox + ReturnTypeAdjusterBox + - Phase 3: StringBoxerBox + ReturnPhiSynthesizerBox + - lower_return() 削減: 166→117 lines (-29%) +- **Code Quality Improvements** (commits `d7c6df367`, `798c193cb`, `1869396fd`, `095213c58`) + - LLVM exit code SSOT化、nyash_kernel FFI分割、LLVM検出集約、auto_detect.conf明確化 +- quick smoke 154/154 PASS 維持 + **2025-12-26: Phase 285 P0 完了** ✅ - 言語 SSOT との境界明文化(lifecycle.md, types.md) - 用語・禁止事項・VM/LLVM差分分類を固定 diff --git a/docs/development/current/main/phases/phase-285/README.md b/docs/development/current/main/phases/phase-285/README.md index 4002b8cc..ead4d7d3 100644 --- a/docs/development/current/main/phases/phase-285/README.md +++ b/docs/development/current/main/phases/phase-285/README.md @@ -90,11 +90,57 @@ MIR 命令を “スコープ維持 / 上書きdrop” に分離して、言語 **目的**: LLVM build でも quick 154/154 PASS(SKIP なし)。 -- `apps/tests/phase285_weak_basic.hako` は “upgrade succeeds while strong ref alive” のみに絞る(weak の最小意味論固定)。 +- `apps/tests/phase285_weak_basic.hako` は "upgrade succeeds while strong ref alive" のみに絞る(weak の最小意味論固定)。 - `tools/smokes/v2/profiles/quick/lifecycle/phase285_weak_basic_llvm.sh` は exit code をゲートにし、stdout 依存を避ける(LLVM harness はログが混入し得る)。 **補足(残課題)**: -- LLVM harness では “boxed integer handle vs integer literal” の比較が揺れる可能性があるため、weak_basic では field/value 比較を扱わない(別タスク化)。 +- LLVM harness では "boxed integer handle vs integer literal" の比較が揺れる可能性があるため、weak_basic では field/value 比較を扱わない(別タスク化)。 + +## P4 Post-Completion: Integration LLVM Tests & Code Quality (2025-12-27) + +**Phase 284 P2 Integration Fix** (commit `225600b5f`): +- **Problem**: `phase284_p2_return_in_loop_llvm` failing with LLVM type error + - MIR generates unreachable blocks with `{"op": "ret", "value": null}` + - LLVM error: `ret void` in `i64 main()` function +- **Solution**: Use `builder.unreachable()` for Fail-Fast principle + - Type-safe: Satisfies LLVM type checker without return value + - Fail-Fast: Immediate crash if unreachable block is executed + - File: `src/llvm_py/instructions/ret.py` (Lines 47-59) +- **Verification**: + - ✅ phase284_p2_return_in_loop_llvm: PASS (exit 7) + - ✅ phase285_p2_weak_upgrade_success_llvm: PASS (exit 2) + - ✅ phase285_p2_weak_upgrade_fail_llvm: PASS + - ✅ Quick profile: 154/154 PASS (no regression) + +**ret.py Box-First Refactoring** (commits `32aa0ddf6`, `5a88c4eb2`): +- **Phase 1-2**: Extract foundational Boxes + - `UnreachableReturnHandlerBox`: Unreachable block handling (Fail-Fast) + - `ReturnTypeAdjusterBox`: Type conversion (ptr↔int, width adjustment) + - Moved `import os, sys` to file header +- **Phase 3**: Strategic extraction + - `StringBoxerBox`: String pointer (i8*) to handle (i64) conversion + - `ReturnPhiSynthesizerBox`: PHI synthesis with zero-like detection + - Reduced `lower_return()`: 166→117 lines (-29%) + - Total: 205→352 lines (+102 for organization, +4 testable units) + +**Code Quality Improvements** (commits `d7c6df367`, `798c193cb`, `1869396fd`, `095213c58`): +1. **LLVM exit code SSOT** (`d7c6df367`): + - Removed unreliable stdout grep fallback + - Exit code primary validation (no log pollution) +2. **nyash_kernel FFI split** (`798c193cb`): + - Extracted `ffi/weak.rs` (74 lines) + - Reduced lib.rs: 1295→1221 lines (-5.7%) +3. **LLVM detection consolidation** (`1869396fd`): + - Created `can_run_llvm()` function (SSOT) + - Updated 9 test files to use unified detection +4. **auto_detect.conf clarity** (`095213c58`): + - `detect_optimal_config(profile)` with parameter + - Moved quick SSOT forcing inside function + +**Final Status**: +- Integration LLVM tests: 3/3 PASS (no FAIL remaining) +- Quick profile: 154/154 PASS +- Code quality: Box-First principles applied throughout **LLVM Details**: See [phase-285llvm-1.3-verification-report.md](phase-285llvm-1.3-verification-report.md) **Syntax Change**: Phase 285W-Syntax-0 migrates from `weak(x)` function call to `weak x` unary operator