diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index 9a0c06d8996..beb643d96dc 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -53,6 +53,7 @@ dependencies = [ "boa_gc", "boa_interner", "boa_macros", + "boa_parser", "boa_profiler", "boa_unicode", "chrono", @@ -84,6 +85,7 @@ dependencies = [ "boa_ast", "boa_engine", "boa_interner", + "boa_parser", "libfuzzer-sys", ] @@ -115,6 +117,22 @@ dependencies = [ "syn", ] +[[package]] +name = "boa_parser" +version = "0.16.0" +dependencies = [ + "bitflags", + "boa_ast", + "boa_interner", + "boa_macros", + "boa_profiler", + "boa_unicode", + "fast-float", + "num-bigint", + "num-traits", + "rustc-hash", +] + [[package]] name = "boa_profiler" version = "0.16.0" diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 62ceab94043..cc86d751da9 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -13,6 +13,7 @@ libfuzzer-sys = "0.4" boa_ast = { path = "../boa_ast", features = ["fuzz"] } boa_engine = { path = "../boa_engine", features = ["fuzz"] } boa_interner = { path = "../boa_interner", features = ["fuzz"] } +boa_parser = { path = "../boa_parser" } # Prevent this from interfering with workspaces [workspace] diff --git a/fuzz/fuzz_targets/parser-idempotency.rs b/fuzz/fuzz_targets/parser-idempotency.rs index 96d2c81777c..1b6a23a3c99 100644 --- a/fuzz/fuzz_targets/parser-idempotency.rs +++ b/fuzz/fuzz_targets/parser-idempotency.rs @@ -3,8 +3,8 @@ mod common; use crate::common::FuzzData; -use boa_engine::syntax::Parser; use boa_interner::ToInternedString; +use boa_parser::Parser; use libfuzzer_sys::fuzz_target; use libfuzzer_sys::Corpus; use std::error::Error; @@ -21,7 +21,7 @@ fn do_fuzz(mut data: FuzzData) -> Result<(), Box> { let before = data.context.interner().len(); // For a variety of reasons, we may not actually produce valid code here (e.g., nameless function). // Fail fast and only make the next checks if we were valid. - if let Ok(first) = parser.parse_all(&mut data.context) { + if let Ok(first) = parser.parse_all(data.context.interner_mut()) { let after_first = data.context.interner().len(); let first_interned = first.to_interned_string(data.context.interner()); @@ -38,7 +38,7 @@ fn do_fuzz(mut data: FuzzData) -> Result<(), Box> { // Now, we most assuredly should produce valid code. It has already gone through a first pass. let second = parser - .parse_all(&mut data.context) + .parse_all(data.context.interner_mut()) .expect("Could not parse the first-pass interned copy."); let second_interned = second.to_interned_string(data.context.interner()); let after_second = data.context.interner().len();