refactor(mir): Separate KeepAlive/ReleaseStrong instructions (Phase 287)
Phase 287: KeepAlive/ReleaseStrong 命令分離
## 変更内容(2つの側面)
### 1. 命令セマンティクスの分離
- KeepAlive { values, drop_after: bool } を2命令に分離
- KeepAlive { values }: スコープ終了での生存維持(PURE)
- ReleaseStrong { values }: 変数上書き時の強参照解放(WRITE)
- 効果分析の明確化: PURE vs WRITE の境界確定
### 2. VM実行サポート
- handlers/mod.rs: KeepAlive → 完全 no-op
- handlers/mod.rs: ReleaseStrong → release_strong_refs() 呼び出し
- handlers/lifecycle.rs: handle_keepalive() 削除
## 影響範囲
- 10 ファイル修正(31箇所の出現を全変換)
- instruction.rs, builder.rs, lexical_scope.rs, methods.rs,
display.rs, printer_helpers.rs, query.rs, joinir_id_remapper.rs,
handlers/mod.rs, handlers/lifecycle.rs
## 検証
- 154/154 quick smoke PASS
- weak テスト回帰なし(weak_upgrade_fail, weak_basic)
- rg -n drop_after src → 0 件(完全除去確認)
- MIRダンプで release_strong/keepalive 正常表示
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -3,18 +3,9 @@ use std::collections::HashSet;
|
||||
use std::sync::Arc;
|
||||
|
||||
impl MirInterpreter {
|
||||
pub(super) fn handle_keepalive(
|
||||
&mut self,
|
||||
values: &[ValueId],
|
||||
drop_after: bool,
|
||||
) -> Result<(), VMError> {
|
||||
if drop_after {
|
||||
self.release_strong_refs(values);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn release_strong_refs(&mut self, values: &[ValueId]) {
|
||||
/// Phase 287: Release strong references for all values (including SSA aliases)
|
||||
/// This is called by ReleaseStrong instruction for variable overwrite semantics.
|
||||
pub(super) fn release_strong_refs(&mut self, values: &[ValueId]) {
|
||||
let mut arc_ptrs: HashSet<*const dyn NyashBox> = HashSet::new();
|
||||
|
||||
for value_id in values {
|
||||
|
||||
@ -135,8 +135,12 @@ impl MirInterpreter {
|
||||
| MirInstruction::BarrierWrite { .. }
|
||||
| MirInstruction::Barrier { .. }
|
||||
| MirInstruction::Safepoint => {}
|
||||
MirInstruction::KeepAlive { values, drop_after } => {
|
||||
self.handle_keepalive(values, *drop_after)?;
|
||||
// Phase 287: Lifecycle management
|
||||
MirInstruction::KeepAlive { .. } => {
|
||||
// No-op: KeepAlive only affects DCE/liveness analysis
|
||||
}
|
||||
MirInstruction::ReleaseStrong { values } => {
|
||||
self.release_strong_refs(values);
|
||||
}
|
||||
MirInstruction::Nop => {}
|
||||
other => {
|
||||
|
||||
Reference in New Issue
Block a user