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:
Yury Delendik
2020-07-23 12:10:13 -05:00
committed by GitHub
parent 87eb4392c4
commit 42127aac4e
11 changed files with 92 additions and 128 deletions

View File

@@ -14,6 +14,7 @@ mod worker;
pub use config::{create_new_config, CacheConfig};
use worker::Worker;
/// Module level cache entry.
pub struct ModuleCacheEntry<'config>(Option<ModuleCacheEntryInner<'config>>);
struct ModuleCacheEntryInner<'config> {
@@ -24,6 +25,7 @@ struct ModuleCacheEntryInner<'config> {
struct Sha256Hasher(Sha256);
impl<'config> ModuleCacheEntry<'config> {
/// Create the cache entry.
pub fn new<'data>(compiler_name: &str, cache_config: &'config CacheConfig) -> Self {
if cache_config.enabled() {
Self(Some(ModuleCacheEntryInner::new(
@@ -40,6 +42,7 @@ impl<'config> ModuleCacheEntry<'config> {
Self(Some(inner))
}
/// Gets cached data if state matches, otherwise calls the `compute`.
pub fn get_data<T, U, E>(&self, state: T, compute: fn(T) -> Result<U, E>) -> Result<U, E>
where
T: Hash,