Switch from hashmap_core to hashbrown.

As suggested
[here](https://github.com/Amanieu/hashmap_core/pull/10#issuecomment-455866083).

This also allows us to re-enable the basic compile fuzz target.
This commit is contained in:
Dan Gohman
2019-01-22 04:24:19 -08:00
parent 8769febdbd
commit dae04be948
9 changed files with 15 additions and 26 deletions

3
fuzz/.gitignore vendored
View File

@@ -1,3 +0,0 @@
target
corpus
artifacts

View File

@@ -10,7 +10,7 @@ extern crate wasmtime_jit;
use cranelift_codegen::settings; use cranelift_codegen::settings;
use wasmparser::validate; use wasmparser::validate;
use wasmtime_environ::{Module, ModuleEnvironment}; use wasmtime_jit::{CompiledModule, Compiler, NullResolver};
fuzz_target!(|data: &[u8]| { fuzz_target!(|data: &[u8]| {
if !validate(data, None) { if !validate(data, None) {
@@ -21,14 +21,9 @@ fuzz_target!(|data: &[u8]| {
panic!("host machine is not a supported target"); panic!("host machine is not a supported target");
}); });
let isa = isa_builder.finish(settings::Flags::new(flag_builder)); let isa = isa_builder.finish(settings::Flags::new(flag_builder));
let mut module = Module::new(); let mut compiler = Compiler::new(isa);
let environment = ModuleEnvironment::new(&*isa, &mut module); let mut resolver = NullResolver {};
let translation = match environment.translate(data) { let _compiled = match CompiledModule::new(&mut compiler, data, &mut resolver) {
Ok(translation) => translation,
Err(_) => return,
};
let imports_resolver = |_env: &str, _function: &str| None;
let _exec = match wasmtime_jit::compile_and_link_module(&*isa, &translation, imports_resolver) {
Ok(x) => x, Ok(x) => x,
Err(_) => return, Err(_) => return,
}; };

View File

@@ -18,12 +18,12 @@ cranelift-wasm = "0.26.0"
cast = { version = "0.2.2", default-features = false } cast = { version = "0.2.2", default-features = false }
failure = { version = "0.1.3", default-features = false } failure = { version = "0.1.3", default-features = false }
failure_derive = { version = "0.1.3", default-features = false } failure_derive = { version = "0.1.3", default-features = false }
hashmap_core = { version = "0.1.9", optional = true } hashbrown = { version = "0.1.8", optional = true }
[features] [features]
default = ["std"] default = ["std"]
std = ["cranelift-codegen/std", "cranelift-wasm/std"] std = ["cranelift-codegen/std", "cranelift-wasm/std"]
core = ["hashmap_core", "cranelift-codegen/core", "cranelift-wasm/core"] core = ["hashbrown/nightly", "cranelift-codegen/core", "cranelift-wasm/core"]
[badges] [badges]
maintenance = { status = "experimental" } maintenance = { status = "experimental" }

View File

@@ -35,7 +35,7 @@ extern crate alloc as std;
extern crate std; extern crate std;
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
use hashmap_core::HashMap; use hashbrown::HashMap;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::collections::HashMap; use std::collections::HashMap;

View File

@@ -22,12 +22,12 @@ region = "1.0.0"
failure = { version = "0.1.3", default-features = false } failure = { version = "0.1.3", default-features = false }
failure_derive = { version = "0.1.3", default-features = false } failure_derive = { version = "0.1.3", default-features = false }
target-lexicon = { version = "0.2.0", default-features = false } target-lexicon = { version = "0.2.0", default-features = false }
hashmap_core = { version = "0.1.9", optional = true } hashbrown = { version = "0.1.8", optional = true }
[features] [features]
default = ["std"] default = ["std"]
std = ["cranelift-codegen/std", "cranelift-wasm/std"] std = ["cranelift-codegen/std", "cranelift-wasm/std"]
core = ["hashmap_core", "cranelift-codegen/core", "cranelift-wasm/core", "wasmtime-environ/core"] core = ["hashbrown/nightly", "cranelift-codegen/core", "cranelift-wasm/core", "wasmtime-environ/core"]
[badges] [badges]
maintenance = { status = "experimental" } maintenance = { status = "experimental" }

View File

@@ -32,7 +32,7 @@ extern crate alloc as std;
extern crate std; extern crate std;
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
use hashmap_core::{map as hash_map, HashMap}; use hashbrown::{map as hash_map, HashMap};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::collections::{hash_map, HashMap}; use std::collections::{hash_map, HashMap};

View File

@@ -32,7 +32,7 @@ extern crate alloc as std;
extern crate std; extern crate std;
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
use hashmap_core::{map as hash_map, HashMap}; use hashbrown::{map as hash_map, HashMap};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::collections::{hash_map, HashMap}; use std::collections::{hash_map, HashMap};

View File

@@ -62,13 +62,10 @@ if rustup toolchain list | grep -q nightly; then
cargo +nightly install cargo-fuzz cargo +nightly install cargo-fuzz
fi fi
echo "Fuzz check temporarily disabled until " fuzz_module="1340712d77d3db3c79b4b0c1494df18615485480"
echo "https://github.com/Amanieu/hashmap_core/pull/8" ASAN_OPTIONS=detect_leaks=0 \
echo "is merged." cargo +nightly fuzz run compile \
#fuzz_module="8f0d725b20dcea52335cf521a5bb083833a5241f" "$topdir/fuzz/corpus/compile/$fuzz_module"
#ASAN_OPTIONS=detect_leaks=0 \
#cargo +nightly fuzz run compile \
# "$topdir/fuzz/corpus/compile/$fuzz_module"
else else
echo "nightly toolchain not found, skipping fuzz target integration test" echo "nightly toolchain not found, skipping fuzz target integration test"
fi fi