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

View File

@ -630,7 +630,18 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
#[cfg(not(feature = "managed"))]
{
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();
pop_code_version().unwrap();
if let Err(ref err) = result {
match err {