Merge pull request #2305 from alexcrichton/no-arc
Don't store `Arc<VMInterrupts>` in instances
This commit is contained in:
@@ -250,7 +250,7 @@ impl CompiledModule {
|
|||||||
imports: Imports<'_>,
|
imports: Imports<'_>,
|
||||||
signature_registry: &mut SignatureRegistry,
|
signature_registry: &mut SignatureRegistry,
|
||||||
mem_creator: Option<&dyn RuntimeMemoryCreator>,
|
mem_creator: Option<&dyn RuntimeMemoryCreator>,
|
||||||
interrupts: Arc<VMInterrupts>,
|
interrupts: *const VMInterrupts,
|
||||||
host_state: Box<dyn Any>,
|
host_state: Box<dyn Any>,
|
||||||
externref_activations_table: *mut VMExternRefActivationsTable,
|
externref_activations_table: *mut VMExternRefActivationsTable,
|
||||||
stack_map_registry: *mut StackMapRegistry,
|
stack_map_registry: *mut StackMapRegistry,
|
||||||
|
|||||||
@@ -68,10 +68,6 @@ pub(crate) struct Instance {
|
|||||||
/// Hosts can store arbitrary per-instance information here.
|
/// Hosts can store arbitrary per-instance information here.
|
||||||
host_state: Box<dyn Any>,
|
host_state: Box<dyn Any>,
|
||||||
|
|
||||||
/// Externally allocated data indicating how this instance will be
|
|
||||||
/// interrupted.
|
|
||||||
pub(crate) interrupts: Arc<VMInterrupts>,
|
|
||||||
|
|
||||||
/// Additional context used by compiled wasm code. This field is last, and
|
/// Additional context used by compiled wasm code. This field is last, and
|
||||||
/// represents a dynamically-sized array that extends beyond the nominal
|
/// represents a dynamically-sized array that extends beyond the nominal
|
||||||
/// end of the struct (similar to a flexible array member).
|
/// end of the struct (similar to a flexible array member).
|
||||||
@@ -824,7 +820,7 @@ impl InstanceHandle {
|
|||||||
mem_creator: Option<&dyn RuntimeMemoryCreator>,
|
mem_creator: Option<&dyn RuntimeMemoryCreator>,
|
||||||
vmshared_signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
vmshared_signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
||||||
host_state: Box<dyn Any>,
|
host_state: Box<dyn Any>,
|
||||||
interrupts: Arc<VMInterrupts>,
|
interrupts: *const VMInterrupts,
|
||||||
externref_activations_table: *mut VMExternRefActivationsTable,
|
externref_activations_table: *mut VMExternRefActivationsTable,
|
||||||
stack_map_registry: *mut StackMapRegistry,
|
stack_map_registry: *mut StackMapRegistry,
|
||||||
) -> Result<Self, InstantiationError> {
|
) -> Result<Self, InstantiationError> {
|
||||||
@@ -863,7 +859,6 @@ impl InstanceHandle {
|
|||||||
passive_data,
|
passive_data,
|
||||||
trampolines,
|
trampolines,
|
||||||
host_state,
|
host_state,
|
||||||
interrupts,
|
|
||||||
vmctx: VMContext {},
|
vmctx: VMContext {},
|
||||||
};
|
};
|
||||||
let layout = instance.alloc_layout();
|
let layout = instance.alloc_layout();
|
||||||
@@ -930,7 +925,7 @@ impl InstanceHandle {
|
|||||||
instance.builtin_functions_ptr() as *mut VMBuiltinFunctionsArray,
|
instance.builtin_functions_ptr() as *mut VMBuiltinFunctionsArray,
|
||||||
VMBuiltinFunctionsArray::initialized(),
|
VMBuiltinFunctionsArray::initialized(),
|
||||||
);
|
);
|
||||||
*instance.interrupts() = &*instance.interrupts;
|
*instance.interrupts() = interrupts;
|
||||||
*instance.externref_activations_table() = externref_activations_table;
|
*instance.externref_activations_table() = externref_activations_table;
|
||||||
*instance.stack_map_registry() = stack_map_registry;
|
*instance.stack_map_registry() = stack_map_registry;
|
||||||
|
|
||||||
|
|||||||
@@ -453,8 +453,8 @@ impl<'a> CallThreadState<'a> {
|
|||||||
UnwindReason::JitTrap { backtrace, pc } => {
|
UnwindReason::JitTrap { backtrace, pc } => {
|
||||||
debug_assert_eq!(ret, 0);
|
debug_assert_eq!(ret, 0);
|
||||||
let maybe_interrupted = unsafe {
|
let maybe_interrupted = unsafe {
|
||||||
(*self.vmctx).instance().interrupts.stack_limit.load(SeqCst)
|
let interrupts = (*self.vmctx).instance().interrupts();
|
||||||
== wasmtime_environ::INTERRUPTED
|
(**interrupts).stack_limit.load(SeqCst) == wasmtime_environ::INTERRUPTED
|
||||||
};
|
};
|
||||||
Err(Trap::Jit {
|
Err(Trap::Jit {
|
||||||
pc,
|
pc,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ fn instantiate(
|
|||||||
imports,
|
imports,
|
||||||
&mut store.signatures_mut(),
|
&mut store.signatures_mut(),
|
||||||
config.memory_creator.as_ref().map(|a| a as _),
|
config.memory_creator.as_ref().map(|a| a as _),
|
||||||
store.interrupts().clone(),
|
store.interrupts(),
|
||||||
host,
|
host,
|
||||||
store.externref_activations_table() as *const VMExternRefActivationsTable as *mut _,
|
store.externref_activations_table() as *const VMExternRefActivationsTable as *mut _,
|
||||||
store.stack_map_registry() as *const StackMapRegistry as *mut _,
|
store.stack_map_registry() as *const StackMapRegistry as *mut _,
|
||||||
|
|||||||
@@ -1030,7 +1030,7 @@ impl Store {
|
|||||||
self.inner.signal_handler.borrow_mut()
|
self.inner.signal_handler.borrow_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn interrupts(&self) -> &Arc<VMInterrupts> {
|
pub(crate) fn interrupts(&self) -> &VMInterrupts {
|
||||||
&self.inner.interrupts
|
&self.inner.interrupts
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1128,7 +1128,7 @@ impl Store {
|
|||||||
pub fn interrupt_handle(&self) -> Result<InterruptHandle> {
|
pub fn interrupt_handle(&self) -> Result<InterruptHandle> {
|
||||||
if self.engine().config().tunables.interruptable {
|
if self.engine().config().tunables.interruptable {
|
||||||
Ok(InterruptHandle {
|
Ok(InterruptHandle {
|
||||||
interrupts: self.interrupts().clone(),
|
interrupts: self.inner.interrupts.clone(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
bail!("interrupts aren't enabled for this `Store`")
|
bail!("interrupts aren't enabled for this `Store`")
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pub(crate) fn create_handle(
|
|||||||
store.memory_creator(),
|
store.memory_creator(),
|
||||||
signatures.into_boxed_slice(),
|
signatures.into_boxed_slice(),
|
||||||
state,
|
state,
|
||||||
store.interrupts().clone(),
|
store.interrupts(),
|
||||||
store.externref_activations_table() as *const VMExternRefActivationsTable as *mut _,
|
store.externref_activations_table() as *const VMExternRefActivationsTable as *mut _,
|
||||||
store.stack_map_registry() as *const StackMapRegistry as *mut _,
|
store.stack_map_registry() as *const StackMapRegistry as *mut _,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user