Move {push,pop}_code_version to caller side for non-mananged execution.

This commit is contained in:
losfair 2019-10-08 18:41:22 +08:00
parent e0e7d58313
commit b5bb3fa764
2 changed files with 13 additions and 13 deletions

View File

@ -3,7 +3,6 @@ use crate::{
backing::{ImportBacking, LocalBacking}, backing::{ImportBacking, LocalBacking},
error::{CallError, CallResult, ResolveError, ResolveResult, Result, RuntimeError}, error::{CallError, CallResult, ResolveError, ResolveResult, Result, RuntimeError},
export::{Context, Export, ExportIter, FuncPointer}, export::{Context, Export, ExportIter, FuncPointer},
fault::{pop_code_version, push_code_version},
global::Global, global::Global,
import::{ImportObject, LikeNamespace}, import::{ImportObject, LikeNamespace},
loader::Loader, loader::Loader,
@ -12,7 +11,6 @@ use crate::{
sig_registry::SigRegistry, sig_registry::SigRegistry,
structures::TypedIndex, structures::TypedIndex,
table::Table, table::Table,
state::CodeVersion,
typed_func::{Func, Wasm, WasmTrapInfo, WasmTypeList}, typed_func::{Func, Wasm, WasmTrapInfo, WasmTypeList},
types::{FuncIndex, FuncSig, GlobalIndex, LocalOrImport, MemoryIndex, TableIndex, Type, Value}, types::{FuncIndex, FuncSig, GlobalIndex, LocalOrImport, MemoryIndex, TableIndex, Type, Value},
vm::{self, InternalField}, vm::{self, InternalField},
@ -335,13 +333,7 @@ impl Instance {
let mut results = Vec::new(); let mut results = Vec::new();
push_code_version(CodeVersion { call_func_with_index(
baseline: true,
msm: self.module.runnable_module.get_module_state_map().unwrap(),
base: self.module.runnable_module.get_code().unwrap().as_ptr() as usize,
});
let result = call_func_with_index(
&self.module.info, &self.module.info,
&*self.module.runnable_module, &*self.module.runnable_module,
&self.inner.import_backing, &self.inner.import_backing,
@ -349,10 +341,7 @@ impl Instance {
func_index, func_index,
params, params,
&mut results, &mut results,
); )?;
pop_code_version().unwrap();
result?;
Ok(results) Ok(results)
} }

View File

@ -630,7 +630,18 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
#[cfg(not(feature = "managed"))] #[cfg(not(feature = "managed"))]
{ {
use wasmer_runtime::error::RuntimeError; use wasmer_runtime::error::RuntimeError;
use wasmer_runtime_core::{
fault::{push_code_version, pop_code_version},
state::CodeVersion
};
push_code_version(CodeVersion {
baseline: true,
msm: instance.module.runnable_module.get_module_state_map().unwrap(),
base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize,
});
let result = start.call(); let result = start.call();
pop_code_version().unwrap();
if let Err(ref err) = result { if let Err(ref err) = result {
match err { match err {