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
+5 -3
View File
@@ -821,7 +821,7 @@ mod tests {
let module = oxide_compiler::compiler::Compiler::new()
.compile(&program)
.expect("compile failed");
vm.run(&module).expect("vm run failed")
vm.run(&Arc::new(module)).expect("vm run failed")
}
/// 计数往返:两条构造路径(独立核/共享核)的登记与 Drop 注销恰好配对,
@@ -981,7 +981,9 @@ mod tests {
let module = oxide_compiler::compiler::Compiler::new()
.compile(&program)
.expect("compile failed");
let err = vm.run(&module).expect_err("runaway allocation must hit the alloc cap");
let err = vm
.run(&Arc::new(module))
.expect_err("runaway allocation must hit the alloc cap");
assert!(err.contains("memory limit"), "unexpected error: {err}");
assert!(!err.contains("step limit"), "cap 应先于步数上限生效: {err}");
}
@@ -1015,7 +1017,7 @@ mod tests {
let module = oxide_compiler::compiler::Compiler::new()
.compile(&program)
.expect("compile failed");
let err = vm.run(&module).expect_err("reentry pump must hit the alloc cap");
let err = vm.run(&Arc::new(module)).expect_err("reentry pump must hit the alloc cap");
assert!(err.contains("memory limit"), "unexpected error: {err}");
}