From ab66cb8283953a9a3b280a35f3b89ad57518364b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=88=B1=E7=89=B9=E6=AF=8F=E7=BE=8A=E9=98=9F?= Date: Thu, 6 Aug 2026 12:17:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(bench):=20Compiler=20=E6=94=B9=E5=B8=A6?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=20struct=20=E5=90=8E=205=20=E5=A4=84=20bench?= =?UTF-8?q?=20=E7=94=A8=20new()=20=E6=9E=84=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 04-03 将 Compiler 从 unit struct 改为带 enable_dce 字段后, bench 里旧语法 'Compiler.compile(...)' 编译失败(clippy --all-targets 暴露,cargo test 不编 bench)。统一改 Compiler::new().compile(...)。 --- crates/oxide_vm/benches/call.rs | 2 +- crates/oxide_vm/benches/coercion.rs | 2 +- crates/oxide_vm/benches/dispatch.rs | 2 +- crates/oxide_vm/benches/gc_mark_sweep.rs | 2 +- crates/oxide_vm/benches/property.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/oxide_vm/benches/call.rs b/crates/oxide_vm/benches/call.rs index 64af270..84f5b08 100644 --- a/crates/oxide_vm/benches/call.rs +++ b/crates/oxide_vm/benches/call.rs @@ -9,7 +9,7 @@ fn bench_call(c: &mut Criterion) { let js = "function fib(n) { if (n < 2) return n; return fib(n-1) + fib(n-2); } fib(15);"; let alloc = oxide_parser::Allocator::default(); let program = oxide_parser::parse(&alloc, js).expect("parse"); - let module = Compiler.compile(&program).expect("compile"); + let module = Compiler::new().compile(&program).expect("compile"); c.bench_function("call", |b| { b.iter_batched( diff --git a/crates/oxide_vm/benches/coercion.rs b/crates/oxide_vm/benches/coercion.rs index c7bfcc3..6b2fa25 100644 --- a/crates/oxide_vm/benches/coercion.rs +++ b/crates/oxide_vm/benches/coercion.rs @@ -9,7 +9,7 @@ fn bench_coercion(c: &mut Criterion) { let js = "var x = \"42\"; var y = \"3.14\"; var r = 0; for (var i = 0; i < 5000; i++) { r += (+x) + (+y); } r"; let alloc = oxide_parser::Allocator::default(); let program = oxide_parser::parse(&alloc, js).expect("parse"); - let module = Compiler.compile(&program).expect("compile"); + let module = Compiler::new().compile(&program).expect("compile"); c.bench_function("coercion", |b| { b.iter_batched( diff --git a/crates/oxide_vm/benches/dispatch.rs b/crates/oxide_vm/benches/dispatch.rs index e68c108..dd01b43 100644 --- a/crates/oxide_vm/benches/dispatch.rs +++ b/crates/oxide_vm/benches/dispatch.rs @@ -9,7 +9,7 @@ fn bench_dispatch(c: &mut Criterion) { let js = "var x = 0; for (var i = 0; i < 10000; i++) { x = x + i - i * 2 + (i % 3); } x"; let alloc = oxide_parser::Allocator::default(); let program = oxide_parser::parse(&alloc, js).expect("parse"); - let module = Compiler.compile(&program).expect("compile"); + let module = Compiler::new().compile(&program).expect("compile"); c.bench_function("dispatch", |b| { b.iter_batched( diff --git a/crates/oxide_vm/benches/gc_mark_sweep.rs b/crates/oxide_vm/benches/gc_mark_sweep.rs index 6d85c66..7e33cea 100644 --- a/crates/oxide_vm/benches/gc_mark_sweep.rs +++ b/crates/oxide_vm/benches/gc_mark_sweep.rs @@ -11,7 +11,7 @@ fn bench_gc(c: &mut Criterion) { let js = "var g = {}; for (var i = 0; i < 500; i++) { var obj = { x: i, y: i * 2 }; g[i] = obj; } g[\"x\"]"; let alloc = oxide_parser::Allocator::default(); let program = oxide_parser::parse(&alloc, js).expect("parse"); - let module = Compiler.compile(&program).expect("compile"); + let module = Compiler::new().compile(&program).expect("compile"); c.bench_function("gc_mark_sweep", |b| { b.iter_batched( diff --git a/crates/oxide_vm/benches/property.rs b/crates/oxide_vm/benches/property.rs index c7361c0..8f811c4 100644 --- a/crates/oxide_vm/benches/property.rs +++ b/crates/oxide_vm/benches/property.rs @@ -9,7 +9,7 @@ fn bench_property(c: &mut Criterion) { let js = "var obj = { a: 1, b: 2, c: 3, d: 4, e: 5 }; var sum = 0; for (var i = 0; i < 10000; i++) { sum += obj.a + obj.b + obj.c + obj.d + obj.e; } sum"; let alloc = oxide_parser::Allocator::default(); let program = oxide_parser::parse(&alloc, js).expect("parse"); - let module = Compiler.compile(&program).expect("compile"); + let module = Compiler::new().compile(&program).expect("compile"); c.bench_function("property", |b| { b.iter_batched(