Skip to content

Commit 418606f

Browse files
authored
Merge pull request #198 from alexcrichton/reduce-some-diff
Miscellaneous changes reducing the upstream diff
2 parents 0ad4b70 + a95792d commit 418606f

File tree

7 files changed

+11
-71
lines changed

7 files changed

+11
-71
lines changed

crates/cranelift/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,3 @@ gc-drc = ["gc", "wasmtime-environ/gc-drc"]
4848
gc-null = ["gc", "wasmtime-environ/gc-null"]
4949
stack-switching = []
5050
threads = ["wasmtime-environ/threads"]
51-

crates/environ/src/component/translate/adapt.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ impl<'data> Translator<'_, 'data> {
196196
names.push(name);
197197
}
198198
let wasm = module.encode();
199-
wasmparser::Validator::new().validate_all(&wasm).unwrap();
200199
let imports = module.imports().to_vec();
201200

202201
// Extend the lifetime of the owned `wasm: Vec<u8>` on the stack to

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl Func {
260260
/// panics if `store` does not own this function.
261261
pub fn call(
262262
&self,
263-
mut store: impl AsContextMut<Data: Send>,
263+
mut store: impl AsContextMut,
264264
params: &[Val],
265265
results: &mut [Val],
266266
) -> Result<()> {
@@ -397,7 +397,7 @@ impl Func {
397397

398398
fn call_impl(
399399
&self,
400-
mut store: impl AsContextMut<Data: Send>,
400+
mut store: impl AsContextMut,
401401
params: &[Val],
402402
results: &mut [Val],
403403
) -> Result<()> {

crates/wasmtime/src/runtime/component/func/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub struct LowerContext<'a, T: 'static> {
218218
pub types: &'a ComponentTypes,
219219

220220
/// Index of the component instance that's being lowered into.
221-
pub(crate) instance: Instance,
221+
instance: Instance,
222222
}
223223

224224
#[doc(hidden)]

crates/wasmtime/src/runtime/component/func/typed.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ where
164164
/// Panics if this is called on a function in an asynchronous store. This
165165
/// only works with functions defined within a synchronous store. Also
166166
/// panics if `store` does not own this function.
167-
pub fn call(&self, store: impl AsContextMut<Data: Send>, params: Params) -> Result<Return>
167+
pub fn call(&self, store: impl AsContextMut, params: Params) -> Result<Return>
168168
where
169169
Return: Send + Sync + 'static,
170170
{
@@ -184,7 +184,7 @@ where
184184
/// panics if `store` does not own this function.
185185
#[cfg(feature = "async")]
186186
pub async fn call_async(
187-
self,
187+
&self,
188188
mut store: impl AsContextMut<Data: Send>,
189189
params: Params,
190190
) -> Result<Return>
@@ -379,7 +379,7 @@ where
379379
}
380380
}
381381

382-
fn call_impl(&self, mut store: impl AsContextMut<Data: Send>, params: Params) -> Result<Return>
382+
fn call_impl(&self, mut store: impl AsContextMut, params: Params) -> Result<Return>
383383
where
384384
Return: Send + Sync + 'static,
385385
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl<T: 'static> Linker<T> {
319319
use wasmtime_environ::component::ComponentTypes;
320320
use wasmtime_environ::component::TypeDef;
321321
// Recursively stub out all imports of the component with a function that traps.
322-
fn stub_item<T: 'static>(
322+
fn stub_item<T>(
323323
linker: &mut LinkerInstance<T>,
324324
item_name: &str,
325325
item_def: &TypeDef,

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

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//! cranelift-compiled adapters, will use this `VMComponentContext` as well.
88
99
use crate::component::{Component, Instance, InstancePre, ResourceType, RuntimeImport};
10-
use crate::prelude::*;
1110
use crate::runtime::component::ComponentInstanceId;
1211
use crate::runtime::vm::{
1312
Export, ExportFunction, ExportGlobal, ExportGlobalKind, SendSyncPtr, VMArrayCallFunction,
@@ -109,7 +108,7 @@ pub struct ComponentInstance {
109108
imports: Arc<PrimaryMap<RuntimeImportIndex, RuntimeImport>>,
110109

111110
/// Self-pointer back to `Store<T>` and its functions.
112-
store: Option<VMStoreRawPtr>,
111+
store: VMStoreRawPtr,
113112

114113
/// Cached ABI return value from the last-invoked function call along with
115114
/// the function index that was invoked.
@@ -224,7 +223,7 @@ impl ComponentInstance {
224223
.byte_sub(mem::size_of::<ComponentInstance>())
225224
.cast::<ComponentInstance>();
226225
let reference = ptr.as_mut();
227-
let store = &mut *reference.store();
226+
let store = &mut *reference.store.0.as_ptr();
228227
let instance = Instance::from_wasmtime(store, reference.id);
229228
f(store, instance)
230229
}
@@ -297,8 +296,8 @@ impl ComponentInstance {
297296
),
298297
component: component.clone(),
299298
resource_types,
300-
store: Some(VMStoreRawPtr(store)),
301299
imports: imports.clone(),
300+
store: VMStoreRawPtr(store),
302301
post_return_arg: None,
303302
vmctx: VMComponentContext {
304303
_marker: marker::PhantomPinned,
@@ -343,13 +342,6 @@ impl ComponentInstance {
343342
}
344343
}
345344

346-
/// Returns the store that this component was created with.
347-
///
348-
/// This will panic if this instance has been removed from its store.
349-
pub fn store(&self) -> *mut dyn VMStore {
350-
self.store.unwrap().0.as_ptr()
351-
}
352-
353345
/// Returns the runtime memory definition corresponding to the index of the
354346
/// memory provided.
355347
///
@@ -600,7 +592,7 @@ impl ComponentInstance {
600592
*self.vmctx_plus_offset_mut(self.offsets.builtins()) =
601593
VmPtr::from(NonNull::from(&libcalls::VMComponentBuiltins::INIT));
602594
*self.vmctx_plus_offset_mut(self.offsets.vm_store_context()) =
603-
VmPtr::from(self.store.unwrap().0.as_ref().vm_store_context_ptr());
595+
VmPtr::from(self.store.0.as_ref().vm_store_context_ptr());
604596

605597
for i in 0..self.offsets.num_runtime_component_instances {
606598
let i = RuntimeComponentInstanceIndex::from_u32(i);
@@ -690,56 +682,6 @@ impl ComponentInstance {
690682
resource.instance == component.defined_resource_instances[idx]
691683
}
692684

693-
/// Implementation of the `resource.new` intrinsic for `i32`
694-
/// representations.
695-
pub fn resource_new32(
696-
&mut self,
697-
store: &mut dyn VMStore,
698-
ty: TypeResourceTableIndex,
699-
rep: u32,
700-
) -> Result<u32> {
701-
self.resource_tables(store)
702-
.resource_new(TypedResource::Component { ty, rep })
703-
}
704-
705-
/// Implementation of the `resource.rep` intrinsic for `i32`
706-
/// representations.
707-
pub fn resource_rep32(
708-
&mut self,
709-
store: &mut dyn VMStore,
710-
ty: TypeResourceTableIndex,
711-
index: u32,
712-
) -> Result<u32> {
713-
self.resource_tables(store)
714-
.resource_rep(TypedResourceIndex::Component { ty, index })
715-
}
716-
717-
/// Implementation of the `resource.drop` intrinsic.
718-
pub fn resource_drop(
719-
&mut self,
720-
store: &mut dyn VMStore,
721-
ty: TypeResourceTableIndex,
722-
index: u32,
723-
) -> Result<Option<u32>> {
724-
self.resource_tables(store)
725-
.resource_drop(TypedResourceIndex::Component { ty, index })
726-
}
727-
728-
/// NB: this is intended to be a private method. This does not have
729-
/// `host_table` information at this time meaning it's only suitable for
730-
/// working with resources specified to this component which is currently
731-
/// all that this is used for.
732-
///
733-
/// If necessary though it's possible to enhance the `Store` trait to thread
734-
/// through the relevant information and get `host_table` to be `Some` here.
735-
fn resource_tables<'a>(&'a mut self, store: &'a mut dyn VMStore) -> ResourceTables<'a> {
736-
ResourceTables {
737-
host_table: None,
738-
calls: store.component_calls(),
739-
guest: Some((&mut self.instance_resource_tables, self.component.types())),
740-
}
741-
}
742-
743685
/// Returns the runtime state of resources associated with this component.
744686
#[inline]
745687
pub fn guest_tables(

0 commit comments

Comments
 (0)