fix: try/finally 支持 break/continue/return 穿越 finally(completion 机制)

This commit is contained in:
2026-08-08 12:38:25 +08:00
parent 6c29515624
commit cd214069cd
18 changed files with 529 additions and 39 deletions
+2
View File
@@ -71,6 +71,8 @@ fn is_terminator(op: OpCode) -> bool {
matches!(
op,
OpCode::JMP
| OpCode::BREAK
| OpCode::CONTINUE
| OpCode::JMP_IF_TRUE
| OpCode::JMP_IF_FALSE
| OpCode::JMP_IF_NULLISH
+1 -1
View File
@@ -25,7 +25,7 @@ pub(super) fn partition_blocks(f: &IRFunction) -> Vec<bool> {
// 跳转的 fallthrough 后继是块头:条件跳转否则 cond+then 融块、条件边丢失;
// 无条件 JMP 同样必须切块头——JMP 不 fallthrough,但其后继位置需成块边界,
// 否则 JMP 与后续指令融块、块尾判定错、Jump 边丢失(DCE 可达性误删目标块)。
if matches!(inst.op, OpCode::JMP | OpCode::JMP_IF_TRUE | OpCode::JMP_IF_FALSE | OpCode::JMP_IF_NULLISH) {
if matches!(inst.op, OpCode::JMP | OpCode::BREAK | OpCode::CONTINUE | OpCode::JMP_IF_TRUE | OpCode::JMP_IF_FALSE | OpCode::JMP_IF_NULLISH) {
heads[i + 1] = true;
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ pub(super) fn split_and_edges(f: &IRFunction, heads: &[bool]) -> (Vec<BasicBlock
continue;
}
match last.op {
OpCode::JMP => {
OpCode::JMP | OpCode::BREAK | OpCode::CONTINUE => {
if let Operand::Label(l) = last.b {
match f.label_pos.get(l as usize).and_then(|p| *p) {
Some(p) => {