fix: finally 体直落进入时置位 finally_active 防完成穿越计数错乱

catch 体正常结束后指令直落入 finally 体,此前 finally_active 未被置位,
finally 内 break/continue/return/throw 触发未进入分支导致 finally 体重复
执行、完成计数错乱。新增无操作数标记指令 TRY_FINALLY_ENTER,在 finally
体入口统一置位栈顶 handler 的 finally_active,覆盖 JMP/直落/unwind/完成
穿越/挂起恢复全部进入路径,并删除 control_flow.rs 中对跳转目标匹配的
脆弱栈顶检测。
This commit is contained in:
2026-08-15 07:47:54 +08:00
parent 63f827432d
commit abeab6f216
8 changed files with 105 additions and 9 deletions
@@ -9,13 +9,6 @@ impl Vm {
pub(crate) fn dispatch_jmp(&mut self, instr: Instr) {
let offset = opcode::offset16(instr) as isize;
let target = ((self.pc as isize) + offset - 1) as usize;
// try 体正常完成跳入 finally(`JMP finally_pc`):标记 handler 进入 finally 体,
// 供 break/continue/return/异常判定覆盖语义。
if let Some(h) = self.try_stack.last_mut() {
if h.frame_depth == self.frames.len() && h.finally_pc == Some(target) {
h.finally_active = true;
}
}
vm_trace!("JMP offset={}", offset);
self.pc = target;
}