Refactor Cache logic to include debug information (#2065)
* move caching to the CompilationArtifacts * mv cache_config from Compiler to CompiledModule * hash isa flags * no cache for wasm2obj * mv caching to wasmtime crate * account each Compiler field when hash
This commit is contained in:
@@ -4,6 +4,7 @@ use crate::types::{EntityType, ExportType, ExternType, ImportType};
|
||||
use anyhow::{bail, Context, Result};
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use wasmtime_environ::ModuleCacheEntry;
|
||||
use wasmtime_jit::{CompilationArtifacts, CompiledModule};
|
||||
|
||||
/// A compiled WebAssembly module, ready to be instantiated.
|
||||
@@ -300,7 +301,17 @@ impl Module {
|
||||
}
|
||||
|
||||
unsafe fn compile(engine: &Engine, binary: &[u8]) -> Result<Self> {
|
||||
let compiled = CompiledModule::new(engine.compiler(), binary, &*engine.config().profiler)?;
|
||||
let cache_entry = ModuleCacheEntry::new("wasmtime", engine.cache_config());
|
||||
let artifacts = cache_entry
|
||||
.get_data((engine.compiler(), binary), |(compiler, binary)| {
|
||||
CompilationArtifacts::build(compiler, binary)
|
||||
})?;
|
||||
|
||||
let compiled = CompiledModule::from_artifacts(
|
||||
artifacts,
|
||||
engine.compiler().isa(),
|
||||
&*engine.config().profiler,
|
||||
)?;
|
||||
|
||||
Ok(Module {
|
||||
engine: engine.clone(),
|
||||
|
||||
@@ -628,12 +628,7 @@ impl Config {
|
||||
|
||||
fn build_compiler(&self) -> Compiler {
|
||||
let isa = self.target_isa();
|
||||
Compiler::new(
|
||||
isa,
|
||||
self.strategy,
|
||||
self.cache_config.clone(),
|
||||
self.tunables.clone(),
|
||||
)
|
||||
Compiler::new(isa, self.strategy, self.tunables.clone())
|
||||
}
|
||||
|
||||
/// Hashes/fingerprints compiler setting to ensure that compatible
|
||||
@@ -798,6 +793,10 @@ impl Engine {
|
||||
&self.inner.compiler
|
||||
}
|
||||
|
||||
pub(crate) fn cache_config(&self) -> &CacheConfig {
|
||||
&self.config().cache_config
|
||||
}
|
||||
|
||||
/// Returns whether the engine `a` and `b` refer to the same configuration.
|
||||
pub fn same(a: &Engine, b: &Engine) -> bool {
|
||||
Arc::ptr_eq(&a.inner, &b.inner)
|
||||
|
||||
Reference in New Issue
Block a user