mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 03:01:12 +08:00
fix: try/finally 支持 break/continue/return 穿越 finally(completion 机制)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user