Cache config as a file

This commit is contained in:
Artur Jamro
2019-08-23 17:00:38 -07:00
committed by Dan Gohman
parent c42698dc85
commit 633dfa17ee
14 changed files with 530 additions and 201 deletions

View File

@@ -50,7 +50,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::cache_config;
use wasmtime_environ::{
Compiler, Cranelift, ModuleEnvironment, ModuleVmctxInfo, Tunables, VMOffsets,
};
@@ -63,7 +63,7 @@ The translation is dependent on the environment chosen.
The default is a dummy environment that produces placeholder values.
Usage:
wasm2obj [--target TARGET] [-dg] [--cache] [--cache-dir=<cache_dir>] [--cache-compression-level=<compr_level>] [--enable-simd] <file> -o <output>
wasm2obj [--target TARGET] [-dg] [--cache | --cache-config=<cache_config_file>] [--create-cache-config] [--enable-simd] <file> -o <output>
wasm2obj --help | --version
Options:
@@ -71,11 +71,12 @@ 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, use default cache directory
--cache-dir=<cache_dir>
enable caching system, use specified cache directory
--cache-compression-level=<compr_level>
enable caching system, use custom compression level for new cache, values 1-21
-c, --cache enable caching system, use default configuration
--cache-config=<cache_config_file>
enable caching system, use specified cache configuration
--create-cache-config
used with --cache or --cache-config, creates default configuration and writes it to the disk,
will fail if specified file already exists (or default file if used with --cache)
--enable-simd enable proposed SIMD instructions
--version print the Cranelift version
-d, --debug enable debug output on stderr/stdout
@@ -88,9 +89,9 @@ struct Args {
arg_target: Option<String>,
flag_g: bool,
flag_debug: bool,
flag_cache: bool,
flag_cache_dir: Option<String>,
flag_cache_compression_level: Option<i32>,
flag_cache: bool, // TODO change to disable cache after implementing cache eviction
flag_cache_config_file: Option<String>,
flag_create_cache_config: bool,
flag_enable_simd: bool,
}
@@ -117,14 +118,20 @@ fn main() {
wasmtime::init_file_per_thread_logger("wasm2obj.dbg.");
}
cache_conf::init(
args.flag_cache
|| args.flag_cache_dir.is_some()
|| args.flag_cache_compression_level.is_some(),
args.flag_cache_dir.as_ref(),
args.flag_cache_compression_level,
let errors = cache_config::init(
args.flag_cache || args.flag_cache_config_file.is_some(),
args.flag_cache_config_file.as_ref(),
args.flag_create_cache_config,
);
if !errors.is_empty() {
eprintln!("Cache initialization failed. Errors:");
for e in errors {
eprintln!("-> {}", e);
}
process::exit(1);
}
let path = Path::new(&args.arg_file);
match handle_module(
path.to_path_buf(),