Improved compiler configurations

This commit is contained in:
Syrus
2020-06-17 22:47:32 -07:00
parent 8649f2eb79
commit 99bd98458a
16 changed files with 164 additions and 130 deletions

View File

@@ -7,11 +7,22 @@ use wasmer_compiler::{Compiler, CompilerConfig, CpuFeature, FunctionMiddlewareGe
#[derive(Clone)]
pub struct SinglepassConfig {
/// Enable NaN canonicalization.
///
/// NaN canonicalization is useful when trying to run WebAssembly
/// deterministically across different architectures.
pub enable_nan_canonicalization: bool,
pub(crate) enable_nan_canonicalization: bool,
pub(crate) enable_stack_check: bool,
/// The middleware chain.
pub(crate) middlewares: Vec<Arc<dyn FunctionMiddlewareGenerator>>,
}
impl SinglepassConfig {
/// Creates a new configuration object with the default configuration
/// specified.
pub fn new() -> Self {
Self {
enable_nan_canonicalization: true,
enable_stack_check: false,
middlewares: vec![],
}
}
/// Enable stack check.
///
@@ -20,24 +31,18 @@ pub struct SinglepassConfig {
///
/// Note that this doesn't guarantee deterministic execution across
/// different platforms.
pub enable_stack_check: bool,
pub fn enable_stack_check(&mut self, enable: bool) -> &mut Self {
self.enable_stack_check = enable;
self
}
target: Target,
/// The middleware chain.
pub(crate) middlewares: Vec<Arc<dyn FunctionMiddlewareGenerator>>,
}
impl SinglepassConfig {
/// Creates a new configuration object with the default configuration
/// specified.
pub fn new(target: Target) -> Self {
Self {
enable_nan_canonicalization: true,
enable_stack_check: false,
target,
middlewares: vec![],
}
/// Enable NaN canonicalization.
///
/// NaN canonicalization is useful when trying to run WebAssembly
/// deterministically across different architectures.
pub fn canonicalize_nans(&mut self, enable: bool) -> &mut Self {
self.enable_nan_canonicalization = enable;
self
}
}
@@ -47,12 +52,6 @@ impl CompilerConfig for SinglepassConfig {
// PIC code.
}
/// Gets the target that we will use for compiling
/// the WebAssembly module
fn target(&self) -> &Target {
&self.target
}
/// Transform it into the compiler
fn compiler(&self) -> Box<dyn Compiler + Send> {
Box::new(SinglepassCompiler::new(&self))
@@ -66,6 +65,6 @@ impl CompilerConfig for SinglepassConfig {
impl Default for SinglepassConfig {
fn default() -> SinglepassConfig {
Self::new(Default::default(), Default::default())
Self::new()
}
}