wasmtime/runtime/
trampoline.rs1mod func;
4mod global;
5mod memory;
6mod table;
7mod tag;
8
9pub use self::func::*;
10pub use self::global::*;
11pub(crate) use memory::MemoryCreatorProxy;
12
13use self::memory::create_memory;
14use self::table::create_table;
15use self::tag::create_tag;
16use crate::prelude::*;
17use crate::runtime::vm::SharedMemory;
18use crate::store::{StoreOpaque, StoreResourceLimiter};
19use crate::{MemoryType, TableType, TagType};
20use wasmtime_environ::{MemoryIndex, TableIndex, TagIndex};
21
22pub async fn generate_memory_export(
23 store: &mut StoreOpaque,
24 limiter: Option<&mut StoreResourceLimiter<'_>>,
25 m: &MemoryType,
26 preallocation: Option<&SharedMemory>,
27) -> Result<crate::Memory> {
28 let id = store.id();
29 let instance = create_memory(store, limiter, m, preallocation).await?;
30 Ok(store
31 .instance_mut(instance)
32 .get_exported_memory(id, MemoryIndex::from_u32(0)))
33}
34
35pub async fn generate_table_export(
36 store: &mut StoreOpaque,
37 limiter: Option<&mut StoreResourceLimiter<'_>>,
38 t: &TableType,
39) -> Result<crate::Table> {
40 let id = store.id();
41 let instance = create_table(store, limiter, t).await?;
42 Ok(store
43 .instance_mut(instance)
44 .get_exported_table(id, TableIndex::from_u32(0)))
45}
46
47pub fn generate_tag_export(store: &mut StoreOpaque, t: &TagType) -> Result<crate::Tag> {
48 let id = store.id();
49 let instance = create_tag(store, t)?;
50 Ok(store
51 .instance_mut(instance)
52 .get_exported_tag(id, TagIndex::from_u32(0)))
53}