perf: run 签名改 &Arc<CompiledModule>,顶层模块跨 run 共享——collect_flat_modules 顶层改 Arc::clone 消除逐 run 常量池深拷贝,全调用点 Arc 包装迁移

This commit is contained in:
2026-09-11 22:19:13 +00:00
parent 542236a15a
commit 3169e8f2f9
106 changed files with 391 additions and 189 deletions
+3 -1
View File
@@ -4,6 +4,8 @@
//! 对比顶层执行结果。**不经 `Compiler::compile`**(测试层直调底层函数)。顶层赋值 /
//! escaped 槽样例做字节码/IR 级断言,is_top_level 标志直接断言。
use std::sync::Arc;
use oxide_bytecode::opcode::OpCode;
use oxide_vm::vm::Vm;
use oxide_vm::JsValue;
@@ -23,7 +25,7 @@ fn run_source(src: &str, precise: bool) -> Result<JsValue, String> {
}
let module = oxide_ir::lower::lower(&ir).expect("lower failed");
let mut vm = Vm::new();
vm.run(&module)
vm.run(&Arc::new(module))
}
/// 结果规约成可断言形态:`(是否 Ok, 字符串化结果或错误消息)`。
+3 -1
View File
@@ -4,6 +4,8 @@
//! 对比顶层执行结果。副作用纯表读错 VM handler 也能被此兜底。
//! **不经 `Compiler::compile`**:测试层直调底层函数,不依赖编译器开关。
use std::sync::Arc;
use oxide_vm::vm::Vm;
use oxide_vm::JsValue;
@@ -19,7 +21,7 @@ fn run_source(src: &str, dce: bool) -> Result<JsValue, String> {
}
let module = oxide_ir::lower::lower(&ir).expect("lower failed");
let mut vm = Vm::new();
vm.run(&module)
vm.run(&Arc::new(module))
}
/// 结果规约成可断言形态:`(是否 Ok, 字符串化结果或错误消息)`。