mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-12 16:41:21 +00:00
Use Arc instead of Rc
This commit is contained in:
@ -111,7 +111,6 @@ impl LocalBacking {
|
||||
.map(|index| {
|
||||
module
|
||||
.runnable_module
|
||||
.borrow()
|
||||
.get_func(&module.info, LocalFuncIndex::new(index))
|
||||
.unwrap()
|
||||
.as_ptr() as *const _
|
||||
@ -381,7 +380,6 @@ impl LocalBacking {
|
||||
LocalOrImport::Local(local_func_index) => (
|
||||
module
|
||||
.runnable_module
|
||||
.borrow()
|
||||
.get_func(&module.info, local_func_index)
|
||||
.unwrap()
|
||||
.as_ptr()
|
||||
@ -415,7 +413,6 @@ impl LocalBacking {
|
||||
LocalOrImport::Local(local_func_index) => (
|
||||
module
|
||||
.runnable_module
|
||||
.borrow()
|
||||
.get_func(&module.info, local_func_index)
|
||||
.unwrap()
|
||||
.as_ptr()
|
||||
|
@ -18,7 +18,6 @@ use std::fmt;
|
||||
use std::fmt::Debug;
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use wasmparser::{self, WasmDecoder};
|
||||
use wasmparser::{Operator, Type as WpType};
|
||||
|
||||
@ -250,7 +249,7 @@ impl<
|
||||
})?;
|
||||
Ok(ModuleInner {
|
||||
cache_gen,
|
||||
runnable_module: Rc::new(RefCell::new(Box::new(exec_context))),
|
||||
runnable_module: Arc::new(Box::new(exec_context)),
|
||||
info: Arc::try_unwrap(info).unwrap().into_inner().unwrap(),
|
||||
})
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ extern "C" fn signal_trap_handler(
|
||||
CURRENT_CODE_VERSIONS.with(|versions| {
|
||||
let versions = versions.borrow();
|
||||
for v in versions.iter() {
|
||||
let runnable_module = v.runnable_module.borrow();
|
||||
let runnable_module = &v.runnable_module;
|
||||
let magic_size =
|
||||
if let Some(x) = runnable_module.get_inline_breakpoint_size(ARCH) {
|
||||
x
|
||||
|
@ -103,7 +103,6 @@ impl Instance {
|
||||
LocalOrImport::Local(local_func_index) => instance
|
||||
.module
|
||||
.runnable_module
|
||||
.borrow()
|
||||
.get_func(&instance.module.info, local_func_index)
|
||||
.unwrap(),
|
||||
LocalOrImport::Import(import_func_index) => NonNull::new(
|
||||
@ -133,7 +132,6 @@ impl Instance {
|
||||
let wasm_trampoline = instance
|
||||
.module
|
||||
.runnable_module
|
||||
.borrow()
|
||||
.get_trampoline(&instance.module.info, sig_index)
|
||||
.expect("wasm trampoline");
|
||||
|
||||
@ -149,7 +147,7 @@ impl Instance {
|
||||
/// Load an `Instance` using the given loader.
|
||||
pub fn load<T: Loader>(&self, loader: T) -> ::std::result::Result<T::Instance, T::Error> {
|
||||
loader.load(
|
||||
&**self.module.runnable_module.borrow(),
|
||||
&**self.module.runnable_module,
|
||||
&self.module.info,
|
||||
unsafe { &*self.inner.vmctx },
|
||||
)
|
||||
@ -219,7 +217,6 @@ impl Instance {
|
||||
let func_wasm_inner = self
|
||||
.module
|
||||
.runnable_module
|
||||
.borrow()
|
||||
.get_trampoline(&self.module.info, sig_index)
|
||||
.unwrap();
|
||||
|
||||
@ -227,7 +224,6 @@ impl Instance {
|
||||
LocalOrImport::Local(local_func_index) => (
|
||||
self.module
|
||||
.runnable_module
|
||||
.borrow()
|
||||
.get_func(&self.module.info, local_func_index)
|
||||
.unwrap(),
|
||||
None,
|
||||
@ -368,7 +364,7 @@ impl Instance {
|
||||
|
||||
call_func_with_index(
|
||||
&self.module.info,
|
||||
&**self.module.runnable_module.borrow(),
|
||||
&**self.module.runnable_module,
|
||||
&self.inner.import_backing,
|
||||
self.inner.vmctx,
|
||||
func_index,
|
||||
@ -467,7 +463,6 @@ impl InstanceInner {
|
||||
LocalOrImport::Local(local_func_index) => (
|
||||
module
|
||||
.runnable_module
|
||||
.borrow()
|
||||
.get_func(&module.info, local_func_index)
|
||||
.expect("broken invariant, func resolver not synced with module.exports")
|
||||
.cast()
|
||||
@ -797,7 +792,7 @@ impl<'a> DynFunc<'a> {
|
||||
|
||||
call_func_with_index(
|
||||
&self.module.info,
|
||||
&**self.module.runnable_module.borrow(),
|
||||
&**self.module.runnable_module,
|
||||
&self.instance_inner.import_backing,
|
||||
self.instance_inner.vmctx,
|
||||
self.func_index,
|
||||
@ -819,7 +814,6 @@ impl<'a> DynFunc<'a> {
|
||||
LocalOrImport::Local(local_func_index) => self
|
||||
.module
|
||||
.runnable_module
|
||||
.borrow()
|
||||
.get_func(&self.module.info, local_func_index)
|
||||
.unwrap()
|
||||
.as_ptr(),
|
||||
|
@ -19,14 +19,12 @@ use crate::backend::CacheGen;
|
||||
use indexmap::IndexMap;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
/// This is used to instantiate a new WebAssembly module.
|
||||
#[doc(hidden)]
|
||||
pub struct ModuleInner {
|
||||
pub runnable_module: Rc<RefCell<Box<dyn RunnableModule>>>,
|
||||
pub runnable_module: Arc<Box<dyn RunnableModule>>,
|
||||
pub cache_gen: Box<dyn CacheGen>,
|
||||
|
||||
pub info: ModuleInfo,
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
use crate::backend::{Backend, RunnableModule};
|
||||
use std::collections::BTreeMap;
|
||||
use std::ops::Bound::{Included, Unbounded};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// An index to a register
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
||||
@ -189,7 +189,7 @@ pub struct CodeVersion {
|
||||
pub backend: Backend,
|
||||
|
||||
/// `RunnableModule` for this code version.
|
||||
pub runnable_module: Rc<RefCell<Box<dyn RunnableModule>>>,
|
||||
pub runnable_module: Arc<Box<dyn RunnableModule>>,
|
||||
}
|
||||
|
||||
impl ModuleStateMap {
|
||||
|
@ -14,7 +14,6 @@ use crate::vm::Ctx;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
struct Defer<F: FnOnce()>(Option<F>);
|
||||
impl<F: FnOnce()> Drop for Defer<F> {
|
||||
@ -212,7 +211,7 @@ pub unsafe fn run_tiering<F: Fn(InteractiveShellContext) -> ShellExitOperation>(
|
||||
baseline.context_mut().local_functions = optimized.context_mut().local_functions;
|
||||
}
|
||||
// Assuming we do not want to do breakpoint-based debugging on optimized backends.
|
||||
let breakpoints = baseline.module.runnable_module.borrow().get_breakpoints();
|
||||
let breakpoints = baseline.module.runnable_module.get_breakpoints();
|
||||
let ctx = baseline.context_mut() as *mut _;
|
||||
let ret = with_ctx(ctx, || {
|
||||
if let Some(image) = resume_image.take() {
|
||||
|
@ -515,7 +515,7 @@ macro_rules! impl_traits {
|
||||
// At this point, there is an error that needs to
|
||||
// be trapped.
|
||||
unsafe {
|
||||
(&*vmctx.module).runnable_module.borrow().do_early_trap(err)
|
||||
(&*vmctx.module).runnable_module.do_early_trap(err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -627,7 +627,7 @@ macro_rules! impl_traits {
|
||||
// At this point, there is an error that needs to
|
||||
// be trapped.
|
||||
unsafe {
|
||||
(&*vmctx.module).runnable_module.borrow().do_early_trap(err)
|
||||
(&*vmctx.module).runnable_module.do_early_trap(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,7 +457,6 @@ impl Ctx {
|
||||
|
||||
let sig_index = SigRegistry.lookup_sig_index(signature.clone());
|
||||
runnable
|
||||
.borrow()
|
||||
.get_trampoline(&module.info, sig_index)
|
||||
.expect("wasm trampoline")
|
||||
};
|
||||
@ -976,7 +975,6 @@ mod vm_ctx_tests {
|
||||
use crate::module::{ModuleInfo, ModuleInner, StringTable};
|
||||
use crate::structures::Map;
|
||||
use std::ffi::c_void;
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
struct TestData {
|
||||
x: u32,
|
||||
@ -1097,7 +1095,7 @@ mod vm_ctx_tests {
|
||||
}
|
||||
|
||||
ModuleInner {
|
||||
runnable_module: Rc::new(RefCell::new(Box::new(Placeholder))),
|
||||
runnable_module: Arc::new(Box::new(Placeholder)),
|
||||
cache_gen: Box::new(Placeholder),
|
||||
info: ModuleInfo {
|
||||
memories: Map::new(),
|
||||
|
Reference in New Issue
Block a user