Update remaining locations to use a &'static str for backend

This commit is contained in:
Mark McCaskey
2020-01-15 10:28:06 -08:00
parent 273a6307f7
commit 75d7f106f2
3 changed files with 36 additions and 10 deletions

32
Cargo.lock generated
View File

@ -558,7 +558,7 @@ dependencies = [
"libc", "libc",
"llvm-sys", "llvm-sys",
"once_cell", "once_cell",
"parking_lot", "parking_lot 0.10.0",
"regex", "regex",
] ]
@ -827,6 +827,17 @@ dependencies = [
"md5", "md5",
] ]
[[package]]
name = "parking_lot"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252"
dependencies = [
"lock_api",
"parking_lot_core 0.6.2",
"rustc_version",
]
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.10.0" version = "0.10.0"
@ -834,7 +845,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc"
dependencies = [ dependencies = [
"lock_api", "lock_api",
"parking_lot_core", "parking_lot_core 0.7.0",
]
[[package]]
name = "parking_lot_core"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b"
dependencies = [
"cfg-if",
"cloudabi",
"libc",
"redox_syscall",
"rustc_version",
"smallvec 0.6.13",
"winapi",
] ]
[[package]] [[package]]
@ -1800,7 +1826,7 @@ dependencies = [
"libc", "libc",
"nix", "nix",
"page_size", "page_size",
"parking_lot", "parking_lot 0.9.0",
"rustc_version", "rustc_version",
"serde", "serde",
"serde-bench", "serde-bench",

View File

@ -43,7 +43,7 @@ struct OptimizationState {
} }
struct OptimizationOutcome { struct OptimizationOutcome {
backend_id: String, backend_id: &'static str,
module: Module, module: Module,
} }
@ -54,7 +54,7 @@ unsafe impl Sync for CtxWrapper {}
unsafe fn do_optimize( unsafe fn do_optimize(
binary: &[u8], binary: &[u8],
backend_id: String, backend_id: &'static str,
compiler: Box<dyn Compiler>, compiler: Box<dyn Compiler>,
ctx: &Mutex<CtxWrapper>, ctx: &Mutex<CtxWrapper>,
state: &OptimizationState, state: &OptimizationState,
@ -87,8 +87,8 @@ pub unsafe fn run_tiering<F: Fn(InteractiveShellContext) -> ShellExitOperation>(
import_object: &ImportObject, import_object: &ImportObject,
start_raw: extern "C" fn(&mut Ctx), start_raw: extern "C" fn(&mut Ctx),
baseline: &mut Instance, baseline: &mut Instance,
baseline_backend: String, baseline_backend: &'static str,
optimized_backends: Vec<(String, Box<dyn Fn() -> Box<dyn Compiler> + Send>)>, optimized_backends: Vec<(&'static str, Box<dyn Fn() -> Box<dyn Compiler> + Send>)>,
interactive_shell: F, interactive_shell: F,
) -> Result<(), String> { ) -> Result<(), String> {
ensure_sighandler(); ensure_sighandler();
@ -140,7 +140,7 @@ pub unsafe fn run_tiering<F: Fn(InteractiveShellContext) -> ShellExitOperation>(
})); }));
loop { loop {
let new_optimized: Option<(String, &mut Instance)> = { let new_optimized: Option<(&'static str, &mut Instance)> = {
let mut outcome = opt_state.outcome.lock().unwrap(); let mut outcome = opt_state.outcome.lock().unwrap();
if let Some(x) = outcome.take() { if let Some(x) = outcome.take() {
let instance = x let instance = x

View File

@ -448,7 +448,7 @@ fn execute_wasi(
&import_object, &import_object,
start_raw, start_raw,
&mut instance, &mut instance,
options.backend, options.backend.to_string(),
options options
.optimized_backends .optimized_backends
.iter() .iter()
@ -456,7 +456,7 @@ fn execute_wasi(
|&backend| -> (Backend, Box<dyn Fn() -> Box<dyn Compiler> + Send>) { |&backend| -> (Backend, Box<dyn Fn() -> Box<dyn Compiler> + Send>) {
let options = options.clone(); let options = options.clone();
( (
backend, backend.to_string(),
Box::new(move || { Box::new(move || {
get_compiler_by_backend(backend, &options).unwrap() get_compiler_by_backend(backend, &options).unwrap()
}), }),