mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-27 04:01:11 +08:00
feat: 逐指令 trace 补 pc 并加 eval/run --trace 旗标
This commit is contained in:
@@ -350,6 +350,10 @@ pub struct Vm {
|
||||
pub(crate) saved_flat_id_stack: Vec<u32>,
|
||||
/// 帧切换时暂存调用方表代际的栈(与 saved_flat_id_stack 同步 push/pop)。
|
||||
pub(crate) saved_table_gen_stack: Vec<u32>,
|
||||
/// 逐指令 trace 开关:开启时 dispatch 主循环对每条指令向 stderr 写一行
|
||||
/// `pc + opcode + 操作数`。运行时开关,旁路 tracing 级别上限(release
|
||||
/// 构建可用);默认关闭,关闭时热路径仅一次 bool 比较,零输出零分配。
|
||||
pub trace_instructions: bool,
|
||||
}
|
||||
|
||||
impl Drop for Vm {
|
||||
@@ -413,6 +417,12 @@ impl Vm {
|
||||
self.regs[idx as usize] = val;
|
||||
}
|
||||
|
||||
/// 设置逐指令 trace 开关(开启后 dispatch 主循环逐指令向 stderr 写
|
||||
/// `pc + opcode + 操作数` 行,pc 为字节码 word 序号,与反汇编 offset 同单位)。
|
||||
pub fn set_instruction_trace(&mut self, on: bool) {
|
||||
self.trace_instructions = on;
|
||||
}
|
||||
|
||||
/// 只读访问 VM 的 epoch arena。
|
||||
pub fn epoch(&self) -> &Epoch {
|
||||
&self.epoch
|
||||
|
||||
Reference in New Issue
Block a user