mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-27 12:11:12 +08:00
perf: run 签名改 &Arc<CompiledModule>,顶层模块跨 run 共享——collect_flat_modules 顶层改 Arc::clone 消除逐 run 常量池深拷贝,全调用点 Arc 包装迁移
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
//! 变化,说明双计机制已变——须对照 tests/stress/mem_object_graph.js 的基线
|
||||
//! (benchmark_baseline.json)复核后再更新本锚。
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_compiler::compiler::Compiler;
|
||||
use oxide_parser::Allocator;
|
||||
use oxide_vm::vm::Vm;
|
||||
@@ -32,7 +34,7 @@ fn run_module(source: &str) -> Vm {
|
||||
let program = oxide_parser::parse(&allocator, source).expect("parse");
|
||||
let module = Compiler::new().compile(&program).expect("compile");
|
||||
let mut vm = Vm::new();
|
||||
let result = vm.run(&module).expect("run");
|
||||
let result = vm.run(&Arc::new(module)).expect("run");
|
||||
assert_eq!(result.to_string(), "9", "root.left.id(2) + root.right.right.id(7)");
|
||||
vm
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user