mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-23 13:41:32 +00:00
Merge #1143
1143: Set backend_id to static str r=MarkMcCaskey a=syrusakbary <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description As per feedback in #1099, set backend_id to static str. <!-- Provide details regarding the change including motivation, links to related issues, and the context of the PR. --> # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Syrus <me@syrusakbary.com> Co-authored-by: Mark McCaskey <mark@wasmer.io>
This commit is contained in:
@ -32,6 +32,8 @@ use wasmer_runtime_core::{
|
||||
};
|
||||
use wasmparser::Type as WpType;
|
||||
|
||||
static BACKEND_ID: &str = "cranelift";
|
||||
|
||||
pub struct CraneliftModuleCodeGenerator {
|
||||
isa: Box<dyn isa::TargetIsa>,
|
||||
signatures: Option<Arc<Map<SigIndex, FuncSig>>>,
|
||||
@ -58,8 +60,8 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
|
||||
unimplemented!("cross compilation is not available for clif backend")
|
||||
}
|
||||
|
||||
fn backend_id() -> String {
|
||||
"cranelift".to_string()
|
||||
fn backend_id() -> &'static str {
|
||||
BACKEND_ID
|
||||
}
|
||||
|
||||
fn check_precondition(&mut self, _module_info: &ModuleInfo) -> Result<(), CodegenError> {
|
||||
|
@ -45,6 +45,8 @@ use wasmer_runtime_core::{
|
||||
};
|
||||
use wasmparser::{BinaryReaderError, MemoryImmediate, Operator, Type as WpType};
|
||||
|
||||
static BACKEND_ID: &str = "llvm";
|
||||
|
||||
fn func_sig_to_llvm<'ctx>(
|
||||
context: &'ctx Context,
|
||||
intrinsics: &Intrinsics<'ctx>,
|
||||
@ -8721,8 +8723,8 @@ impl<'ctx> ModuleCodeGenerator<LLVMFunctionCodeGenerator<'ctx>, LLVMBackend, Cod
|
||||
}
|
||||
}
|
||||
|
||||
fn backend_id() -> String {
|
||||
"llvm".to_string()
|
||||
fn backend_id() -> &'static str {
|
||||
BACKEND_ID
|
||||
}
|
||||
|
||||
fn check_precondition(&mut self, _module_info: &ModuleInfo) -> Result<(), CodegenError> {
|
||||
|
@ -92,7 +92,7 @@ pub trait ModuleCodeGenerator<FCG: FunctionCodeGenerator<E>, RM: RunnableModule,
|
||||
) -> Self;
|
||||
|
||||
/// Returns the backend id associated with this MCG.
|
||||
fn backend_id() -> String;
|
||||
fn backend_id() -> &'static str;
|
||||
|
||||
/// It sets if the current compiler requires validation before compilation
|
||||
fn requires_pre_validation() -> bool {
|
||||
@ -231,7 +231,7 @@ impl<
|
||||
validate_with_features(wasm, &compiler_config.features)?;
|
||||
}
|
||||
|
||||
let mut mcg = match MCG::backend_id().as_ref() {
|
||||
let mut mcg = match MCG::backend_id() {
|
||||
"llvm" => MCG::new_with_target(
|
||||
compiler_config.triple.clone(),
|
||||
compiler_config.cpu_name.clone(),
|
||||
|
@ -82,7 +82,7 @@ pub fn read_module<
|
||||
|
||||
func_assoc: Map::new(),
|
||||
signatures: Map::new(),
|
||||
backend: MCG::backend_id(),
|
||||
backend: MCG::backend_id().to_string(),
|
||||
|
||||
namespace_table: StringTable::new(),
|
||||
name_table: StringTable::new(),
|
||||
|
@ -186,7 +186,7 @@ pub struct CodeVersion {
|
||||
pub base: usize,
|
||||
|
||||
/// The backend used to compile this module.
|
||||
pub backend: String,
|
||||
pub backend: &'static str,
|
||||
|
||||
/// `RunnableModule` for this code version.
|
||||
pub runnable_module: Arc<Box<dyn RunnableModule>>,
|
||||
|
@ -43,7 +43,7 @@ struct OptimizationState {
|
||||
}
|
||||
|
||||
struct OptimizationOutcome {
|
||||
backend_id: String,
|
||||
backend_id: &'static str,
|
||||
module: Module,
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ unsafe impl Sync for CtxWrapper {}
|
||||
|
||||
unsafe fn do_optimize(
|
||||
binary: &[u8],
|
||||
backend_id: String,
|
||||
backend_id: &'static str,
|
||||
compiler: Box<dyn Compiler>,
|
||||
ctx: &Mutex<CtxWrapper>,
|
||||
state: &OptimizationState,
|
||||
@ -87,8 +87,8 @@ pub unsafe fn run_tiering<F: Fn(InteractiveShellContext) -> ShellExitOperation>(
|
||||
import_object: &ImportObject,
|
||||
start_raw: extern "C" fn(&mut Ctx),
|
||||
baseline: &mut Instance,
|
||||
baseline_backend: String,
|
||||
optimized_backends: Vec<(String, Box<dyn Fn() -> Box<dyn Compiler> + Send>)>,
|
||||
baseline_backend: &'static str,
|
||||
optimized_backends: Vec<(&'static str, Box<dyn Fn() -> Box<dyn Compiler> + Send>)>,
|
||||
interactive_shell: F,
|
||||
) -> Result<(), String> {
|
||||
ensure_sighandler();
|
||||
@ -140,7 +140,7 @@ pub unsafe fn run_tiering<F: Fn(InteractiveShellContext) -> ShellExitOperation>(
|
||||
}));
|
||||
|
||||
loop {
|
||||
let new_optimized: Option<(String, &mut Instance)> = {
|
||||
let new_optimized: Option<(&'static str, &mut Instance)> = {
|
||||
let mut outcome = opt_state.outcome.lock().unwrap();
|
||||
if let Some(x) = outcome.take() {
|
||||
let instance = x
|
||||
|
@ -59,6 +59,8 @@ pub const INLINE_BREAKPOINT_SIZE_X86_SINGLEPASS: usize = 7;
|
||||
/// Inline breakpoint size for aarch64.
|
||||
pub const INLINE_BREAKPOINT_SIZE_AARCH64_SINGLEPASS: usize = 12;
|
||||
|
||||
static BACKEND_ID: &str = "singlepass";
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
lazy_static! {
|
||||
/// Performs a System V call to `target` with [stack_top..stack_base] as the argument list, from right to left.
|
||||
@ -651,8 +653,8 @@ impl ModuleCodeGenerator<X64FunctionCode, X64ExecutionContext, CodegenError>
|
||||
false
|
||||
}
|
||||
|
||||
fn backend_id() -> String {
|
||||
"singlepass".to_string()
|
||||
fn backend_id() -> &'static str {
|
||||
BACKEND_ID
|
||||
}
|
||||
|
||||
fn new_with_target(_: Option<String>, _: Option<String>, _: Option<String>) -> Self {
|
||||
|
@ -454,7 +454,7 @@ fn execute_wasi(
|
||||
&import_object,
|
||||
start_raw,
|
||||
&mut instance,
|
||||
options.backend,
|
||||
options.backend.to_string(),
|
||||
options
|
||||
.optimized_backends
|
||||
.iter()
|
||||
@ -462,7 +462,7 @@ fn execute_wasi(
|
||||
|&backend| -> (Backend, Box<dyn Fn() -> Box<dyn Compiler> + Send>) {
|
||||
let options = options.clone();
|
||||
(
|
||||
backend,
|
||||
backend.to_string(),
|
||||
Box::new(move || {
|
||||
get_compiler_by_backend(backend, &options).unwrap()
|
||||
}),
|
||||
@ -492,7 +492,7 @@ fn execute_wasi(
|
||||
baseline: true,
|
||||
msm: msm,
|
||||
base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize,
|
||||
backend: options.backend.to_string().to_owned(),
|
||||
backend: options.backend.to_string(),
|
||||
runnable_module: instance.module.runnable_module.clone(),
|
||||
});
|
||||
true
|
||||
|
Reference in New Issue
Block a user