Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions lib/compiler-cranelift/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::eh::{
use crate::translator::CraneliftUnwindInfo;
use crate::{
address_map::get_function_address_map,
config::Cranelift,
config::{Cranelift, CraneliftOptLevel},
func_environ::{FuncEnvironment, get_function_name},
trampoline::{
FunctionBuilderContext, make_trampoline_dynamic_function, make_trampoline_function_call,
Expand Down Expand Up @@ -726,11 +726,26 @@ impl Compiler for CraneliftCompiler {
}

fn deterministic_id(&self) -> String {
let mut components = vec![self.name()];
components.push(match self.config.opt_level {
CraneliftOptLevel::None => "opt0",
CraneliftOptLevel::Speed => "opts",
CraneliftOptLevel::SpeedAndSize => "optsz",
});
if self.config.experimental_artifact {
String::from("cranelift-elf")
} else {
String::from("cranelift")
components.push("exp_art");
}
if self.config.enable_nan_canonicalization {
components.push("nan_canon");
}
if self.config.enable_pic {
components.push("pic");
}
if self.config.allow_experimental_unaligned_memory_accesses {
components.push("unaligned_mem");
}

components.join("-")
}

/// Get the middlewares for this compiler
Expand Down
6 changes: 3 additions & 3 deletions lib/compiler-cranelift/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ pub enum CraneliftOptLevel {
/// consumed by `wasmer_engine::Engine::new`.
#[derive(Debug, Clone)]
pub struct Cranelift {
enable_nan_canonicalization: bool,
pub(crate) enable_nan_canonicalization: bool,
pub(crate) allow_experimental_unaligned_memory_accesses: bool,
enable_verifier: bool,
pub(crate) enable_perfmap: bool,
pub(crate) debugger: Option<Debugger>,
enable_pic: bool,
pub(crate) enable_pic: bool,
pub(crate) experimental_artifact: bool,
opt_level: CraneliftOptLevel,
pub(crate) opt_level: CraneliftOptLevel,
/// The number of threads to use for compilation.
pub num_threads: NonZero<usize>,
/// The middleware chain.
Expand Down
38 changes: 24 additions & 14 deletions lib/compiler-llvm/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,30 @@ impl Compiler for LLVMCompiler {
}

fn deterministic_id(&self) -> String {
format!(
"llvm-{}{}",
match self.config.opt_level {
inkwell::OptimizationLevel::None => "opt0",
inkwell::OptimizationLevel::Less => "optl",
inkwell::OptimizationLevel::Default => "optd",
inkwell::OptimizationLevel::Aggressive => "opta",
},
if self.config.experimental_artifact {
"-elf"
} else {
""
}
)
let mut components = vec![self.name()];
components.push(match self.config.opt_level {
inkwell::OptimizationLevel::None => "opt0",
inkwell::OptimizationLevel::Less => "optl",
inkwell::OptimizationLevel::Default => "optd",
inkwell::OptimizationLevel::Aggressive => "opta",
});
if self.config.experimental_artifact {
components.push("exp_art");
}
if self.config.enable_nan_canonicalization {
components.push("nan_canon");
}
if self.config.enable_non_volatile_memops {
components.push("non_vol_mem");
}
if self.config.is_pic {
components.push("pic");
}
if self.config.enable_readonly_funcref_table {
components.push("ro_ftable");
}

components.join("-")
}

/// Get the middlewares for this compiler
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler-llvm/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub struct LLVM {
pub(crate) enable_perfmap: bool,
pub(crate) debugger: Option<Debugger>,
pub(crate) opt_level: LLVMOptLevel,
is_pic: bool,
pub(crate) is_pic: bool,
pub(crate) experimental_artifact: bool,
pub(crate) callbacks: Option<LLVMCallbacks>,
/// The middleware chain.
Expand Down
13 changes: 10 additions & 3 deletions lib/compiler-singlepass/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,18 @@ impl Compiler for SinglepassCompiler {
}

fn deterministic_id(&self) -> String {
let mut components = vec![self.name()];
if self.config.experimental_artifact {
String::from("singlepass-elf")
} else {
String::from("singlepass")
components.push("exp_art");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does exp_art mean?

Ah... experimental_artifact.

Why name it that way though?
That will just cause recompilation again later.
(The compilation cache uses the engine deterministic id!).

Can we pick a new name for it and stick to that?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, skeptical if this should go into the deterministic engine id at all ... the artifact format.
It sort of mixes up concerns.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why name it that way though?

The name was deliberately renamed as elf was imprecise (won't be the case for macOS). I renamed it because I knew the rest of deterministic_if will change anyway, e.g. /home/marxin/.wasmer/cache/compiled/llvm-opta-exp_art-non_vol_mem-pic-ro_ftable-v23).

Actually, skeptical if this should go into the deterministic engine id at all ... the artifact format.

Why? For the clean separation of the new formats (on disk), I see it necessary.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It mixes up what the engine is vs what the artifact format is. That could become complicated for cache implementations, including eg our own.
It could eg make sense to have a separate function for the artifact format on the engine, but I wouldn't mix them up into the engine core deterministic ID.

They are only partially related.
I wouldn't care about the artifact format when just wanting to know what exactly that engine is.

}
if self.config.enable_nan_canonicalization {
components.push("nan_canon");
}
if self.config.allow_experimental_unaligned_memory_accesses {
components.push("unaligned_mem");
}

components.join("-")
}

/// Get the middlewares for this compiler
Expand Down
Loading