Finalize new cache api

This commit is contained in:
Lachlan Sneff
2019-02-21 11:47:28 -08:00
parent 336c1d9c5f
commit 7fa818ea06
11 changed files with 150 additions and 121 deletions

View File

@ -4,7 +4,7 @@ use hashbrown::HashMap;
use std::sync::Arc;
use wasmer_runtime_core::{
backend::{sys::Memory, CacheGen},
cache::{Cache, Error},
cache::{Error, SerializedCache},
module::{ModuleInfo, ModuleInner},
structures::Map,
types::{LocalFuncIndex, SigIndex},
@ -61,7 +61,7 @@ pub struct BackendCache {
}
impl BackendCache {
pub fn from_cache(cache: Cache) -> Result<(ModuleInfo, Memory, Self), Error> {
pub fn from_cache(cache: SerializedCache) -> Result<(ModuleInfo, Memory, Self), Error> {
let (info, backend_data, compiled_code) = cache.consume();
let backend_cache =

View File

@ -14,7 +14,7 @@ use cranelift_codegen::{
};
use target_lexicon::Triple;
use wasmer_runtime_core::cache::{Cache, Error as CacheError};
use wasmer_runtime_core::cache::{Error as CacheError, SerializedCache};
use wasmer_runtime_core::{
backend::{Compiler, Token},
error::{CompileError, CompileResult},
@ -53,7 +53,11 @@ impl Compiler for CraneliftCompiler {
/// Create a wasmer Module from an already-compiled cache.
unsafe fn from_cache(&self, cache: Cache, _: Token) -> Result<ModuleInner, CacheError> {
unsafe fn from_cache(
&self,
cache: SerializedCache,
_: Token,
) -> Result<ModuleInner, CacheError> {
module::Module::from_cache(cache)
}

View File

@ -7,7 +7,7 @@ use cranelift_wasm;
use hashbrown::HashMap;
use std::sync::Arc;
use wasmer_runtime_core::cache::{Cache, Error as CacheError};
use wasmer_runtime_core::cache::{Error as CacheError, SerializedCache, WasmHash};
use wasmer_runtime_core::{
backend::Backend,
@ -19,8 +19,6 @@ use wasmer_runtime_core::{
},
};
use wasmer_runtime_core::module::WasmHash;
/// This contains all of the items in a `ModuleInner` except the `func_resolver`.
pub struct Module {
pub info: ModuleInfo,
@ -90,7 +88,7 @@ impl Module {
})
}
pub fn from_cache(cache: Cache) -> Result<ModuleInner, CacheError> {
pub fn from_cache(cache: SerializedCache) -> Result<ModuleInner, CacheError> {
let (info, compiled_code, backend_cache) = BackendCache::from_cache(cache)?;
let (func_resolver_builder, trampolines, handler_data) =