|
7 | 7 | //! cranelift-compiled adapters, will use this `VMComponentContext` as well. |
8 | 8 |
|
9 | 9 | use crate::component::{Component, Instance, InstancePre, ResourceType, RuntimeImport}; |
10 | | -use crate::prelude::*; |
11 | 10 | use crate::runtime::component::ComponentInstanceId; |
12 | 11 | use crate::runtime::vm::{ |
13 | 12 | Export, ExportFunction, ExportGlobal, ExportGlobalKind, SendSyncPtr, VMArrayCallFunction, |
@@ -109,7 +108,7 @@ pub struct ComponentInstance { |
109 | 108 | imports: Arc<PrimaryMap<RuntimeImportIndex, RuntimeImport>>, |
110 | 109 |
|
111 | 110 | /// Self-pointer back to `Store<T>` and its functions. |
112 | | - store: Option<VMStoreRawPtr>, |
| 111 | + store: VMStoreRawPtr, |
113 | 112 |
|
114 | 113 | /// Cached ABI return value from the last-invoked function call along with |
115 | 114 | /// the function index that was invoked. |
@@ -224,7 +223,7 @@ impl ComponentInstance { |
224 | 223 | .byte_sub(mem::size_of::<ComponentInstance>()) |
225 | 224 | .cast::<ComponentInstance>(); |
226 | 225 | let reference = ptr.as_mut(); |
227 | | - let store = &mut *reference.store(); |
| 226 | + let store = &mut *reference.store.0.as_ptr(); |
228 | 227 | let instance = Instance::from_wasmtime(store, reference.id); |
229 | 228 | f(store, instance) |
230 | 229 | } |
@@ -297,8 +296,8 @@ impl ComponentInstance { |
297 | 296 | ), |
298 | 297 | component: component.clone(), |
299 | 298 | resource_types, |
300 | | - store: Some(VMStoreRawPtr(store)), |
301 | 299 | imports: imports.clone(), |
| 300 | + store: VMStoreRawPtr(store), |
302 | 301 | post_return_arg: None, |
303 | 302 | vmctx: VMComponentContext { |
304 | 303 | _marker: marker::PhantomPinned, |
@@ -343,13 +342,6 @@ impl ComponentInstance { |
343 | 342 | } |
344 | 343 | } |
345 | 344 |
|
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 | | - |
353 | 345 | /// Returns the runtime memory definition corresponding to the index of the |
354 | 346 | /// memory provided. |
355 | 347 | /// |
@@ -600,7 +592,7 @@ impl ComponentInstance { |
600 | 592 | *self.vmctx_plus_offset_mut(self.offsets.builtins()) = |
601 | 593 | VmPtr::from(NonNull::from(&libcalls::VMComponentBuiltins::INIT)); |
602 | 594 | *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()); |
604 | 596 |
|
605 | 597 | for i in 0..self.offsets.num_runtime_component_instances { |
606 | 598 | let i = RuntimeComponentInstanceIndex::from_u32(i); |
@@ -690,56 +682,6 @@ impl ComponentInstance { |
690 | 682 | resource.instance == component.defined_resource_instances[idx] |
691 | 683 | } |
692 | 684 |
|
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 | | - |
743 | 685 | /// Returns the runtime state of resources associated with this component. |
744 | 686 | #[inline] |
745 | 687 | pub fn guest_tables( |
|
0 commit comments