Rename --always-cranelift to --cranelift.
Also, enable use of Lightbeam in wasm2obj.
This commit is contained in:
@@ -49,11 +49,13 @@ use std::process;
|
||||
use std::str;
|
||||
use std::str::FromStr;
|
||||
use target_lexicon::Triple;
|
||||
use wasmtime::pick_compilation_strategy;
|
||||
use wasmtime_debug::{emit_debugsections, read_debuginfo};
|
||||
use wasmtime_environ::{cache_create_new_config, cache_init};
|
||||
use wasmtime_environ::{
|
||||
Compiler, Cranelift, ModuleEnvironment, ModuleVmctxInfo, Tunables, VMOffsets,
|
||||
};
|
||||
use wasmtime_jit::CompilationStrategy;
|
||||
use wasmtime_obj::emit_module;
|
||||
|
||||
const USAGE: &str = "
|
||||
@@ -63,7 +65,7 @@ The translation is dependent on the environment chosen.
|
||||
The default is a dummy environment that produces placeholder values.
|
||||
|
||||
Usage:
|
||||
wasm2obj [--target TARGET] [-Odg] [--disable-cache | --cache-config=<cache_config_file>] [--enable-simd] [--always-lightbeam | --always-cranelift] <file> -o <output>
|
||||
wasm2obj [--target TARGET] [-Odg] [--disable-cache | --cache-config=<cache_config_file>] [--enable-simd] [--lightbeam | --cranelift] <file> -o <output>
|
||||
wasm2obj --create-cache-config [--cache-config=<cache_config_file>]
|
||||
wasm2obj --help | --version
|
||||
|
||||
@@ -80,8 +82,8 @@ Options:
|
||||
creates default configuration and writes it to the disk,
|
||||
use with --cache-config to specify custom config file
|
||||
instead of default one
|
||||
--always-lightbeam use Lightbeam for all compilation
|
||||
--always-cranelift use Cranelift for all compilation
|
||||
--lightbeam use Lightbeam for all compilation
|
||||
--cranelift use Cranelift for all compilation
|
||||
--enable-simd enable proposed SIMD instructions
|
||||
-O, --optimize runs optimization passes on the translated functions
|
||||
--version print the Cranelift version
|
||||
@@ -99,8 +101,8 @@ struct Args {
|
||||
flag_cache_config: Option<String>,
|
||||
flag_create_cache_config: bool,
|
||||
flag_enable_simd: bool,
|
||||
flag_always_lightbeam: bool,
|
||||
flag_always_cranelift: bool,
|
||||
flag_lightbeam: bool,
|
||||
flag_cranelift: bool,
|
||||
flag_optimize: bool,
|
||||
}
|
||||
|
||||
@@ -168,6 +170,8 @@ fn main() {
|
||||
args.flag_g,
|
||||
args.flag_enable_simd,
|
||||
args.flag_optimize,
|
||||
args.flag_cranelift,
|
||||
args.flag_lightbeam,
|
||||
) {
|
||||
Ok(()) => {}
|
||||
Err(message) => {
|
||||
@@ -184,6 +188,8 @@ fn handle_module(
|
||||
generate_debug_info: bool,
|
||||
enable_simd: bool,
|
||||
enable_optimize: bool,
|
||||
cranelift: bool,
|
||||
lightbeam: bool,
|
||||
) -> Result<(), String> {
|
||||
let data = match read_wasm_file(path) {
|
||||
Ok(data) => data,
|
||||
@@ -227,6 +233,9 @@ fn handle_module(
|
||||
// TODO: Expose the tunables as command-line flags.
|
||||
let tunables = Tunables::default();
|
||||
|
||||
// Decide how to compile.
|
||||
let strategy = pick_compilation_strategy(cranelift, lightbeam);
|
||||
|
||||
let (module, lazy_function_body_inputs, lazy_data_initializers, target_config) = {
|
||||
let environ = ModuleEnvironment::new(isa.frontend_config(), tunables);
|
||||
|
||||
@@ -244,13 +253,25 @@ fn handle_module(
|
||||
|
||||
// TODO: use the traps information
|
||||
let (compilation, relocations, address_transform, value_ranges, stack_slots, _traps) =
|
||||
Cranelift::compile_module(
|
||||
&module,
|
||||
lazy_function_body_inputs,
|
||||
&*isa,
|
||||
generate_debug_info,
|
||||
)
|
||||
.map_err(|e| e.to_string())?;
|
||||
match strategy {
|
||||
CompilationStrategy::Auto | CompilationStrategy::Cranelift => {
|
||||
Cranelift::compile_module(
|
||||
&module,
|
||||
lazy_function_body_inputs,
|
||||
&*isa,
|
||||
generate_debug_info,
|
||||
)
|
||||
.map_err(|e| e.to_string())?
|
||||
}
|
||||
#[cfg(feature = "lightbeam")]
|
||||
CompilationStrategy::Lightbeam => Lightbeam::compile_module(
|
||||
&module,
|
||||
lazy_function_body_inputs,
|
||||
&*isa,
|
||||
generate_debug_info,
|
||||
)
|
||||
.map_err(|e| e.to_string())?,
|
||||
};
|
||||
|
||||
let module_vmctx_info = {
|
||||
let ofs = VMOffsets::new(target_config.pointer_bytes(), &module);
|
||||
|
||||
@@ -63,8 +63,8 @@ including calling the start function if one is present. Additional functions
|
||||
given with --invoke are then called.
|
||||
|
||||
Usage:
|
||||
wasmtime [-odg] [--enable-simd] [--wasi-c] [--disable-cache | --cache-config=<cache_config_file>] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] [--always-lightbeam | --always-cranelift] <file> [<arg>...]
|
||||
wasmtime [-odg] [--enable-simd] [--wasi-c] [--disable-cache | --cache-config=<cache_config_file>] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] --invoke=<fn> [--always-lightbeam | --always-cranelift] <file> [<arg>...]
|
||||
wasmtime [-odg] [--enable-simd] [--wasi-c] [--disable-cache | --cache-config=<cache_config_file>] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] [--lightbeam | --cranelift] <file> [<arg>...]
|
||||
wasmtime [-odg] [--enable-simd] [--wasi-c] [--disable-cache | --cache-config=<cache_config_file>] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] --invoke=<fn> [--lightbeam | --cranelift] <file> [<arg>...]
|
||||
wasmtime --create-cache-config [--cache-config=<cache_config_file>]
|
||||
wasmtime --help | --version
|
||||
|
||||
@@ -81,8 +81,8 @@ Options:
|
||||
instead of default one
|
||||
-g generate debug information
|
||||
-d, --debug enable debug output on stderr/stdout
|
||||
--always-lightbeam use Lightbeam for all compilation
|
||||
--always-cranelift use Cranelift for all compilation
|
||||
--lightbeam use Lightbeam for all compilation
|
||||
--cranelift use Cranelift for all compilation
|
||||
--enable-simd enable proposed SIMD instructions
|
||||
--wasi-c enable the wasi-c implementation of WASI
|
||||
--preload=<wasm> load an additional wasm module before loading the main module
|
||||
@@ -105,8 +105,8 @@ struct Args {
|
||||
flag_debug: bool,
|
||||
flag_g: bool,
|
||||
flag_enable_simd: bool,
|
||||
flag_always_lightbeam: bool,
|
||||
flag_always_cranelift: bool,
|
||||
flag_lightbeam: bool,
|
||||
flag_cranelift: bool,
|
||||
flag_invoke: Option<String>,
|
||||
flag_preload: Vec<String>,
|
||||
flag_env: Vec<String>,
|
||||
@@ -287,8 +287,7 @@ fn rmain() -> Result<(), Error> {
|
||||
}
|
||||
|
||||
// Decide how to compile.
|
||||
let strategy =
|
||||
pick_compilation_strategy(args.flag_always_cranelift, args.flag_always_lightbeam);
|
||||
let strategy = pick_compilation_strategy(args.flag_cranelift, args.flag_lightbeam);
|
||||
|
||||
let config = Config::new(
|
||||
settings::Flags::new(flag_builder),
|
||||
|
||||
@@ -42,7 +42,7 @@ const USAGE: &str = "
|
||||
Wast test runner.
|
||||
|
||||
Usage:
|
||||
wast [-do] [--enable-simd] [--disable-cache | --cache-config=<cache_config_file>] [--always-lightbeam | --always-cranelift] <file>...
|
||||
wast [-do] [--enable-simd] [--disable-cache | --cache-config=<cache_config_file>] [--lightbeam | --cranelift] <file>...
|
||||
wast --create-cache-config [--cache-config=<cache_config_file>]
|
||||
wast --help | --version
|
||||
|
||||
@@ -58,8 +58,8 @@ Options:
|
||||
creates default configuration and writes it to the disk,
|
||||
use with --cache-config to specify custom config file
|
||||
instead of default one
|
||||
--always-lightbeam use Lightbeam for all compilation
|
||||
--always-cranelift use Cranelift for all compilation
|
||||
--lightbeam use Lightbeam for all compilation
|
||||
--cranelift use Cranelift for all compilation
|
||||
-d, --debug enable debug output on stderr/stdout
|
||||
--enable-simd enable proposed SIMD instructions
|
||||
";
|
||||
|
||||
Reference in New Issue
Block a user