Make use of Lightbeam configurable.

This adds a `--always-lightbeam` option as well as an `--always-cranelift`
option, to allow the compilation strategy to be selected via the
command-line. This also enables regular testing for Lightbeam.
This commit is contained in:
Dan Gohman
2019-10-02 11:54:06 -07:00
parent 8c524815c3
commit 65b8afabe6
9 changed files with 162 additions and 59 deletions

View File

@@ -34,14 +34,14 @@ use serde::Deserialize;
use std::path::Path;
use std::process;
use wasmtime_environ::{cache_create_new_config, cache_init};
use wasmtime_jit::{Compiler, Features};
use wasmtime_jit::{CompilationStrategy, Compiler, Features};
use wasmtime_wast::WastContext;
const USAGE: &str = "
Wast test runner.
Usage:
wast [-do] [--enable-simd] [--disable-cache | --cache-config=<cache_config_file>] <file>...
wast [-do] [--enable-simd] [--disable-cache | --cache-config=<cache_config_file>] [--always-lightmean | --always-cranelift] <file>...
wast --create-cache-config [--cache-config=<cache_config_file>]
wast --help | --version
@@ -57,6 +57,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
-d, --debug enable debug output on stderr/stdout
--enable-simd enable proposed SIMD instructions
";
@@ -71,6 +73,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,
}
fn main() {
@@ -148,8 +152,18 @@ fn main() {
features.simd = true;
}
// Decide how to compile.
let strategy = match (args.flag_always_lightbeam, args.flag_always_cranelift) {
(true, false) => CompilationStrategy::AlwaysLightbeam,
(false, true) => CompilationStrategy::AlwaysCranelift,
(false, false) => CompilationStrategy::Auto,
(true, true) => {
panic!("Can't enable --always-cranelift and --always-lightbeam at the same time")
}
};
let isa = isa_builder.finish(settings::Flags::new(flag_builder));
let engine = Compiler::new(isa);
let engine = Compiler::new(isa, strategy);
let mut wast_context = WastContext::new(Box::new(engine)).with_features(features);
wast_context