Make state mapping work on non-x86 architectures.

This commit is contained in:
losfair 2019-10-07 23:00:37 +08:00
parent 80d6c4cbc0
commit e0e7d58313
2 changed files with 14 additions and 3 deletions

View File

@ -198,7 +198,7 @@ unsafe fn with_breakpoint_map<R, F: FnOnce(Option<&BreakpointMap>) -> R>(f: F) -
#[cfg(not(target_arch = "x86_64"))] #[cfg(not(target_arch = "x86_64"))]
pub fn allocate_and_run<R, F: FnOnce() -> R>(size: usize, f: F) -> R { pub fn allocate_and_run<R, F: FnOnce() -> R>(size: usize, f: F) -> R {
unimplemented!("allocate_and_run only supported on x86_64"); f()
} }
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]

View File

@ -3,6 +3,7 @@ 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,
@ -11,6 +12,7 @@ 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},
@ -333,7 +335,13 @@ impl Instance {
let mut results = Vec::new(); let mut results = Vec::new();
call_func_with_index( 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(
&self.module.info, &self.module.info,
&*self.module.runnable_module, &*self.module.runnable_module,
&self.inner.import_backing, &self.inner.import_backing,
@ -341,7 +349,10 @@ impl Instance {
func_index, func_index,
params, params,
&mut results, &mut results,
)?; );
pop_code_version().unwrap();
result?;
Ok(results) Ok(results)
} }