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 ed964b5e2b
commit 31ca1dd5db
8 changed files with 105 additions and 9 deletions
+1
View File
@@ -674,6 +674,7 @@ mod tests {
OpCode::TRY_BEGIN,
OpCode::TRY_END,
OpCode::TRY_FINALLY_BEGIN,
OpCode::TRY_FINALLY_ENTER,
OpCode::TRY_FINALLY_END,
OpCode::FOR_IN_CLEANUP,
OpCode::FOR_OF_CLOSE,
+5
View File
@@ -382,6 +382,11 @@ impl Inst {
pub fn try_finally_begin(label: LabelId) -> Self {
Self::new(OpCode::TRY_FINALLY_BEGIN, Operand::None, Operand::None, Operand::Label(label))
}
/// finally 体入口标记:运行时置位对应 try handler 的 `finally_active`。
pub fn try_finally_enter() -> Self {
Self::new(OpCode::TRY_FINALLY_ENTER, Operand::None, Operand::None, Operand::None)
}
}
/// spread 调用系 ext 构造:首字打包 `nstatic | (nspread << 8)`,后续按源码求值序排列