mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 18:51:13 +08:00
perf: run 签名改 &Arc<CompiledModule>,顶层模块跨 run 共享——collect_flat_modules 顶层改 Arc::clone 消除逐 run 常量池深拷贝,全调用点 Arc 包装迁移
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
//! on={object} vs off=42)。修复:graph.rs/rewrite.rs 对称 collect_own_escaped。
|
||||
//! 槽号 ≥ inherited_reg_start(param_layout.base)时触发,故用高压力变量推高槽号。
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_vm::vm::Vm;
|
||||
|
||||
fn run_source(src: &str, regalloc: bool) -> (bool, String) {
|
||||
@@ -33,7 +35,7 @@ fn run_source(src: &str, regalloc: bool) -> (bool, String) {
|
||||
Err(e) => return (false, format!("lower error: {e}")),
|
||||
};
|
||||
let mut vm = Vm::new();
|
||||
match vm.run(&module) {
|
||||
match vm.run(&Arc::new(module)) {
|
||||
Ok(v) => (true, v.to_string()),
|
||||
Err(e) => (false, e),
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
//! 同一 JS 源码走两条管线:parse → emit → dce(保守恒定)→(regalloc on/off)→ lower → run,
|
||||
//! 对比顶层执行结果。**不经 Compiler::compile**(测试层直调底层函数)。
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_bytecode::opcode::OpCode;
|
||||
use oxide_vm::vm::Vm;
|
||||
use oxide_vm::JsValue;
|
||||
@@ -29,7 +31,7 @@ fn run_source(src: &str, regalloc: bool) -> Result<JsValue, String> {
|
||||
let mut module = module;
|
||||
oxide_compiler::flatten::flatten_submodules(&mut module);
|
||||
let mut vm = Vm::new();
|
||||
vm.run(&module)
|
||||
vm.run(&Arc::new(module))
|
||||
}
|
||||
|
||||
/// 结果规约成可断言形态:`(是否 Ok, 字符串化结果或错误消息)`。
|
||||
|
||||
Reference in New Issue
Block a user