Simple module compilation cache (#203)

* Simple module compilation cache

* Fix base64 encoding bug

* Use warn! everywhere in cache system

* Remove unused import

* Temporary workaround for long path on Windows

* Remove unused import for non-windows builds

* Add command line argument to enable cache system + apply minor review feedback
This commit is contained in:
Artur Jamro
2019-07-25 16:16:10 -07:00
committed by Dan Gohman
parent 17e4528648
commit 165dc4944d
20 changed files with 502 additions and 110 deletions

View File

@@ -10,6 +10,7 @@ use cranelift_wasm::{
self, translate_module, DefinedFuncIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex,
SignatureIndex, Table, TableIndex, WasmResult,
};
use sha2::{Digest, Sha256};
use std::boxed::Box;
use std::string::String;
use std::vec::Vec;
@@ -79,6 +80,11 @@ impl<'data> ModuleEnvironment<'data> {
pub fn translate(mut self, data: &'data [u8]) -> WasmResult<ModuleTranslation<'data>> {
translate_module(data, &mut self)?;
// TODO: this is temporary workaround and will be replaced with derive macro.
let mut hasher = Sha256::new();
hasher.input(data);
self.result.module.hash = Some(hasher.result().into());
Ok(self.result)
}
}