Simple module compilation cache (#203)

* Simple module compilation cache

* Fix base64 encoding bug

* Use warn! everywhere in cache system

* Remove unused import

* Temporary workaround for long path on Windows

* Remove unused import for non-windows builds

* Add command line argument to enable cache system + apply minor review feedback
This commit is contained in:
Artur Jamro
2019-07-25 16:16:10 -07:00
committed by Dan Gohman
parent 17e4528648
commit 165dc4944d
20 changed files with 502 additions and 110 deletions

View File

@@ -29,14 +29,12 @@
)
)]
#[macro_use]
extern crate serde_derive;
use cranelift_codegen::isa;
use cranelift_codegen::settings;
use cranelift_native;
use docopt::Docopt;
use faerie::Artifact;
use serde::Deserialize;
use std::error::Error;
use std::fmt::format;
use std::fs::File;
@@ -49,6 +47,7 @@ use std::str;
use std::str::FromStr;
use target_lexicon::Triple;
use wasmtime_debug::{emit_debugsections, read_debuginfo};
use wasmtime_environ::cache_conf;
use wasmtime_environ::{Compiler, Cranelift, ModuleEnvironment, Tunables};
use wasmtime_obj::emit_module;
@@ -63,7 +62,7 @@ The translation is dependent on the environment chosen.
The default is a dummy environment that produces placeholder values.
Usage:
wasm2obj [--target TARGET] [-g] <file> -o <output>
wasm2obj [--target TARGET] [-cdg] <file> -o <output>
wasm2obj --help | --version
Options:
@@ -71,6 +70,7 @@ Options:
-h, --help print this help message
--target <TARGET> build for the target triple; default is the host machine
-g generate debug information
-c, --cache enable caching system
--version print the Cranelift version
-d, --debug enable debug output on stderr/stdout
";
@@ -82,6 +82,7 @@ struct Args {
arg_target: Option<String>,
flag_g: bool,
flag_debug: bool,
flag_cache: bool,
}
fn read_wasm_file(path: PathBuf) -> Result<Vec<u8>, io::Error> {
@@ -107,6 +108,8 @@ fn main() {
utils::init_file_per_thread_logger();
}
cache_conf::init(args.flag_cache);
let path = Path::new(&args.arg_file);
match handle_module(
path.to_path_buf(),

View File

@@ -30,14 +30,12 @@
)
)]
#[macro_use]
extern crate serde_derive;
use cranelift_codegen::settings;
use cranelift_codegen::settings::Configurable;
use cranelift_native;
use docopt::Docopt;
use pretty_env_logger;
use serde::Deserialize;
use std::error::Error;
use std::ffi::OsStr;
use std::fs::File;
@@ -48,6 +46,7 @@ use std::path::{Path, PathBuf};
use std::process::exit;
use wabt;
use wasi_common::preopen_dir;
use wasmtime_environ::cache_conf;
use wasmtime_jit::{ActionOutcome, Context};
use wasmtime_wasi::instantiate_wasi;
use wasmtime_wast::instantiate_spectest;
@@ -67,13 +66,14 @@ including calling the start function if one is present. Additional functions
given with --invoke are then called.
Usage:
wasmtime [-odg] [--wasi-c] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] <file> [<arg>...]
wasmtime [-odg] [--wasi-c] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] --invoke=<fn> <file> [<arg>...]
wasmtime [-ocdg] [--wasi-c] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] <file> [<arg>...]
wasmtime [-ocdg] [--wasi-c] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] --invoke=<fn> <file> [<arg>...]
wasmtime --help | --version
Options:
--invoke=<fn> name of function to run
-o, --optimize runs optimization passes on the translated functions
-c, --cache enable caching system
-g generate debug information
-d, --debug enable debug output on stderr/stdout
--wasi-c enable the wasi-c implementation of WASI
@@ -91,6 +91,7 @@ struct Args {
arg_file: String,
arg_arg: Vec<String>,
flag_optimize: bool,
flag_cache: bool,
flag_debug: bool,
flag_g: bool,
flag_invoke: Option<String>,
@@ -207,6 +208,8 @@ fn main() {
utils::init_file_per_thread_logger();
}
cache_conf::init(args.flag_cache);
let isa_builder = cranelift_native::builder().unwrap_or_else(|_| {
panic!("host machine is not a supported target");
});

View File

@@ -25,16 +25,15 @@
)
)]
#[macro_use]
extern crate serde_derive;
use cranelift_codegen::settings;
use cranelift_codegen::settings::Configurable;
use cranelift_native;
use docopt::Docopt;
use pretty_env_logger;
use serde::Deserialize;
use std::path::Path;
use std::process;
use wasmtime_environ::cache_conf;
use wasmtime_jit::Compiler;
use wasmtime_wast::WastContext;
@@ -46,13 +45,14 @@ const USAGE: &str = "
Wast test runner.
Usage:
run_wast [-do] <file>...
run_wast [-cdo] <file>...
run_wast --help | --version
Options:
-h, --help print this help message
--version print the Cranelift version
-o, --optimize runs optimization passes on the translated functions
-c, --cache enable caching system
-d, --debug enable debug output on stderr/stdout
";
@@ -62,6 +62,7 @@ struct Args {
flag_debug: bool,
flag_function: Option<String>,
flag_optimize: bool,
flag_cache: bool,
}
fn main() {
@@ -80,6 +81,8 @@ fn main() {
utils::init_file_per_thread_logger();
}
cache_conf::init(args.flag_cache);
let isa_builder = cranelift_native::builder().unwrap_or_else(|_| {
panic!("host machine is not a supported target");
});