Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit f041787

Browse files
authored
Merge pull request #185 from bytecodealliance/dicej/remove-vmstore-static-bound
remove `'static` bound from `VMStore`
2 parents 4ad74fc + 60ea95f commit f041787

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

crates/wasmtime/src/runtime/component/concurrent.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ fn poll_with_local_instance<F: Future + Send + ?Sized>(
558558
let state = ResetInstanceThreadLocalState(INSTANCE_STATE.with(|v| {
559559
v.replace(InstanceThreadLocalState::PollingWith {
560560
instance,
561-
store: VMStoreRawPtr(store.into()),
561+
store: VMStoreRawPtr(store.traitobj()),
562562
})
563563
}));
564564

@@ -614,11 +614,15 @@ fn poll_with_state<T: 'static, F: Future + Send + ?Sized>(
614614
mut future: Pin<&mut F>,
615615
) -> Poll<F::Output> {
616616
with_local_instance(|store, instance| {
617-
let store_ptr = store as *mut dyn VMStore;
617+
let store_ptr = store.traitobj();
618618
let store_cx = token.as_context_mut(store);
619619

620620
let result = {
621-
let old_state = STATE.with(|v| v.replace(Some(State { store: store_ptr })));
621+
let old_state = STATE.with(|v| {
622+
v.replace(Some(State {
623+
store: store_ptr.as_ptr(),
624+
}))
625+
});
622626
let _reset_state = ResetState(old_state);
623627
poll_with_local_instance(store_cx.0.traitobj_mut(), instance, &mut future, cx)
624628
};
@@ -1958,7 +1962,7 @@ impl Instance {
19581962
// SAFETY: This is only ever called from a fiber that belongs to this
19591963
// store (and would in any case panic if called from outside any fiber).
19601964
unsafe {
1961-
async_cx.suspend(Some(store))?;
1965+
async_cx.suspend(Some(store.traitobj().as_ptr()))?;
19621966
}
19631967

19641968
if let Some(task) = task {
@@ -2904,7 +2908,7 @@ impl Instance {
29042908
// automatically from the event loop if it doesn't complete immediately
29052909
// here.
29062910
let poll = poll_with_local_instance(
2907-
store.traitobj_mut(),
2911+
store,
29082912
self,
29092913
&mut future.as_mut(),
29102914
&mut Context::from_waker(&dummy_waker()),

crates/wasmtime/src/runtime/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ cfg_if::cfg_if! {
172172
/// be respected by embedders (e.g. the `wasmtime::Store` structure). The theory
173173
/// is that `wasmtime::Store` handles all this correctly.
174174
#[doc(hidden)]
175-
pub unsafe trait VMStore: 'static {
175+
pub unsafe trait VMStore {
176176
/// Get a shared borrow of this store's `StoreOpaque`.
177177
fn store_opaque(&self) -> &StoreOpaque;
178178

0 commit comments

Comments
 (0)