Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multi-value wasm #399

Merged
merged 4 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ edition = "2018"
default-run = "wasmtime"

[dependencies]
cranelift-codegen = { version = "0.44.0", features = ["enable-serde"] }
cranelift-entity = { version = "0.44.0", features = ["enable-serde"] }
cranelift-wasm = { version = "0.44.0", features = ["enable-serde"] }
cranelift-native = "0.44.0"
cranelift-codegen = { version = "0.46.1", features = ["enable-serde"] }
cranelift-entity = { version = "0.46.1", features = ["enable-serde"] }
cranelift-wasm = { version = "0.46.1", features = ["enable-serde"] }
cranelift-native = "0.46.1"
wasmtime-api = { path = "wasmtime-api" }
wasmtime-debug = { path = "wasmtime-debug" }
wasmtime-environ = { path = "wasmtime-environ" }
Expand Down
28 changes: 25 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ fn main() {
strategy,
)
.expect("generating tests");

let multi_value_suite = Path::new("spec_testsuite")
.join("proposals")
.join("multi-value");
let multi_value_suite = multi_value_suite.display().to_string();
test_directory(&mut out, &multi_value_suite, strategy).expect("generating tests");
} else {
println!("cargo:warning=The spec testsuite is disabled. To enable, run `git submodule update --remote`.");
}
Expand Down Expand Up @@ -94,7 +100,8 @@ fn start_test_module(out: &mut File, testsuite: &str) -> io::Result<()> {
.expect("testsuite filename should have a stem")
.to_str()
.expect("testsuite filename should be representable as a string")
.replace("-", "_"),
.replace("-", "_")
.replace("/", "_")
)?;
writeln!(
out,
Expand Down Expand Up @@ -131,7 +138,8 @@ fn write_testsuite_tests(
)?;
writeln!(
out,
" let features = Features {{ simd: true, ..Default::default() }};"
" let features = Features {{ simd: true, multi_value: {}, ..Default::default() }};",
testsuite.contains("multi-value")
)?;
writeln!(
out,
Expand Down Expand Up @@ -159,18 +167,32 @@ fn write_testsuite_tests(

/// Ignore tests that aren't supported yet.
fn ignore(testsuite: &str, name: &str, strategy: &str) -> bool {
let is_multi_value = testsuite.ends_with("multi-value");
match strategy {
#[cfg(feature = "lightbeam")]
"Lightbeam" => match (testsuite, name) {
("single_file_spec_test", "simd_const") => return true,
(_, _) if is_multi_value => return true,
_ => (),
},
"Cranelift" => {}
"Cranelift" => match (testsuite, name) {
// We don't currently support more return values than available
// registers, and this contains a function with many, many more
// return values than that.
(_, "func") if is_multi_value => return true,
_ => {}
},
_ => panic!("unrecognized strategy"),
}

if cfg!(windows) {
return match (testsuite, name) {
// Currently, our multi-value support only works with however many
// extra return registers we have available, and windows' fastcall
// ABI only has a single return register, so we need to wait on full
// multi-value support in Cranelift.
(_, _) if is_multi_value => true,

("spec_testsuite", "address") => true,
("spec_testsuite", "align") => true,
("spec_testsuite", "call") => true,
Expand Down
8 changes: 4 additions & 4 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ cargo-fuzz = true
[dependencies]
wasmtime-environ = { path = "../wasmtime-environ" }
wasmtime-jit = { path = "../wasmtime-jit" }
cranelift-codegen = { version = "0.44.0", features = ["enable-serde"] }
cranelift-wasm = { version = "0.44.0", features = ["enable-serde"] }
cranelift-native = "0.44.0"
cranelift-codegen = { version = "0.46.1", features = ["enable-serde"] }
cranelift-wasm = { version = "0.46.1", features = ["enable-serde"] }
cranelift-native = "0.46.1"
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" }
wasmparser = { version = "0.39.1", default-features = false }
wasmparser = { version = "0.39.2", default-features = false }
binaryen = "0.5.0"

[features]
Expand Down
2 changes: 1 addition & 1 deletion lightbeam/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ itertools = "0.8"
capstone = "0.6.0"
failure = "0.1.3"
failure_derive = "0.1.3"
cranelift-codegen = "0.44"
cranelift-codegen = "0.46.1"
multi_mut = "0.1"
either = "1.5"
typemap = "0.3"
Expand Down
12 changes: 6 additions & 6 deletions misc/wasmtime-py/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ name = "_wasmtime"
crate-type = ["cdylib"]

[dependencies]
cranelift-codegen = "0.44.0"
cranelift-native = "0.44.0"
cranelift-entity = "0.44.0"
cranelift-wasm = "0.44.0"
cranelift-frontend = "0.44.0"
cranelift-codegen = "0.46.1"
cranelift-native = "0.46.1"
cranelift-entity = "0.46.1"
cranelift-wasm = "0.46.1"
cranelift-frontend = "0.46.1"
wasmtime-environ = { path = "../../wasmtime-environ" }
wasmtime-interface-types = { path = "../../wasmtime-interface-types" }
wasmtime-jit = { path = "../../wasmtime-jit" }
wasmtime-runtime = { path = "../../wasmtime-runtime" }
target-lexicon = { version = "0.8.1", default-features = false }
failure = "0.1"
region = "2.0.0"
wasmparser = "0.39.1"
wasmparser = "0.39.2"

[dependencies.pyo3]
version = "0.8.0"
Expand Down
4 changes: 2 additions & 2 deletions misc/wasmtime-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ test = false
doctest = false

[dependencies]
cranelift-codegen = "0.44.0"
cranelift-native = "0.44.0"
cranelift-codegen = "0.46.1"
cranelift-native = "0.46.1"
failure = "0.1.5"
wasmtime-interface-types = { path = "../../wasmtime-interface-types" }
wasmtime-jit = { path = "../../wasmtime-jit" }
Expand Down
5 changes: 4 additions & 1 deletion misc/wasmtime-rust/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ fn generate_load(item: &syn::ItemTrait) -> syn::Result<TokenStream> {
let mut cx = #root::wasmtime_jit::Context::with_isa(
isa,
#root::wasmtime_jit::CompilationStrategy::Auto
);
).with_features(#root::wasmtime_jit::Features {
multi_value: true,
..Default::default()
});
let data = #root::wasmtime_interface_types::ModuleData::new(&bytes)?;
let handle = cx.instantiate_module(None, &bytes)?;

Expand Down
11 changes: 10 additions & 1 deletion src/bin/wasm2obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,13 @@ fn handle_module(
// Decide how to compile.
let strategy = pick_compilation_strategy(cranelift, lightbeam);

let (module, lazy_function_body_inputs, lazy_data_initializers, target_config) = {
let (
module,
module_translation,
lazy_function_body_inputs,
lazy_data_initializers,
target_config,
) = {
let environ = ModuleEnvironment::new(isa.frontend_config(), tunables);

let translation = environ
Expand All @@ -247,6 +253,7 @@ fn handle_module(

(
translation.module,
translation.module_translation.unwrap(),
translation.function_body_inputs,
translation.data_initializers,
translation.target_config,
Expand All @@ -259,6 +266,7 @@ fn handle_module(
CompilationStrategy::Auto | CompilationStrategy::Cranelift => {
Cranelift::compile_module(
&module,
&module_translation,
lazy_function_body_inputs,
&*isa,
generate_debug_info,
Expand All @@ -268,6 +276,7 @@ fn handle_module(
#[cfg(feature = "lightbeam")]
CompilationStrategy::Lightbeam => Lightbeam::compile_module(
&module,
&module_translation,
lazy_function_body_inputs,
&*isa,
generate_debug_info,
Expand Down
12 changes: 6 additions & 6 deletions wasmtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ name = "wasmtime_api"
crate-type = ["lib", "staticlib", "cdylib"]

[dependencies]
cranelift-codegen = { version = "0.44.0", features = ["enable-serde"] }
cranelift-native = "0.44.0"
cranelift-entity = { version = "0.44.0", features = ["enable-serde"] }
cranelift-wasm = { version = "0.44.0", features = ["enable-serde"] }
cranelift-frontend = "0.44.0"
cranelift-codegen = { version = "0.46.1", features = ["enable-serde"] }
cranelift-native = "0.46.1"
cranelift-entity = { version = "0.46.1", features = ["enable-serde"] }
cranelift-wasm = { version = "0.46.1", features = ["enable-serde"] }
cranelift-frontend = "0.46.1"
wasmtime-runtime = { path="../wasmtime-runtime" }
wasmtime-environ = { path="../wasmtime-environ" }
wasmtime-jit = { path="../wasmtime-jit" }
wasmparser = { version = "0.39.1", default-features = false }
wasmparser = { version = "0.39.2", default-features = false }
failure = { version = "0.1.3", default-features = false }
failure_derive = { version = "0.1.3", default-features = false }
target-lexicon = { version = "0.8.1", default-features = false }
Expand Down
8 changes: 4 additions & 4 deletions wasmtime-debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ edition = "2018"

[dependencies]
gimli = "0.19.0"
wasmparser = { version = "0.39.1" }
cranelift-codegen = { version = "0.44.0", features = ["enable-serde"] }
cranelift-entity = { version = "0.44.0", features = ["enable-serde"] }
cranelift-wasm = { version = "0.44.0", features = ["enable-serde"] }
wasmparser = "0.39.2"
cranelift-codegen = { version = "0.46.1", features = ["enable-serde"] }
cranelift-entity = { version = "0.46.1", features = ["enable-serde"] }
cranelift-wasm = { version = "0.46.1", features = ["enable-serde"] }
faerie = "0.11.0"
wasmtime-environ = { path = "../wasmtime-environ", default-features = false }
target-lexicon = { version = "0.8.1", default-features = false }
Expand Down
8 changes: 4 additions & 4 deletions wasmtime-environ/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ readme = "README.md"
edition = "2018"

[dependencies]
cranelift-codegen = { version = "0.44.0", features = ["enable-serde"] }
cranelift-entity = { version = "0.44.0", features = ["enable-serde"] }
cranelift-wasm = { version = "0.44.0", features = ["enable-serde"] }
cranelift-codegen = { version = "0.46.1", features = ["enable-serde"] }
cranelift-entity = { version = "0.46.1", features = ["enable-serde"] }
cranelift-wasm = { version = "0.46.1", features = ["enable-serde"] }
lightbeam = { path = "../lightbeam", optional = true }
failure = { version = "0.1.3", default-features = false }
failure_derive = { version = "0.1.3", default-features = false }
Expand Down Expand Up @@ -44,7 +44,7 @@ tempfile = "3"
target-lexicon = { version = "0.8.1", default-features = false }
pretty_env_logger = "0.3.0"
rand = { version = "0.7.0", features = ["small_rng"] }
cranelift-codegen = { version = "0.44.0", features = ["enable-serde", "all-arch"] }
cranelift-codegen = { version = "0.46.1", features = ["enable-serde", "all-arch"] }
filetime = "0.2.7"

[features]
Expand Down
3 changes: 2 additions & 1 deletion wasmtime-environ/src/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::module_environ::FunctionBodyData;
use alloc::vec::Vec;
use cranelift_codegen::{binemit, ir, isa, CodegenError};
use cranelift_entity::PrimaryMap;
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, WasmError};
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, ModuleTranslationState, WasmError};
use serde::{Deserialize, Serialize};
use std::ops::Range;

Expand Down Expand Up @@ -164,6 +164,7 @@ pub trait Compiler {
/// Compile a parsed module with the given `TargetIsa`.
fn compile_module<'data, 'module>(
module: &'module module::Module,
module_translation: &ModuleTranslationState,
function_body_inputs: PrimaryMap<DefinedFuncIndex, FunctionBodyData<'data>>,
isa: &dyn isa::TargetIsa,
generate_debug_info: bool,
Expand Down
Loading