1pub const MAX_FLAT_PARAMS: usize = 16;
26
27pub const MAX_FLAT_ASYNC_PARAMS: usize = 4;
30
31pub const MAX_FLAT_RESULTS: usize = 1;
35
36pub const PREPARE_ASYNC_NO_RESULT: u32 = u32::MAX;
40
41pub const PREPARE_ASYNC_WITH_RESULT: u32 = u32::MAX - 1;
46
47pub const START_FLAG_ASYNC_CALLEE: i32 = 1 << 0;
52
53pub const START_FLAG_ASYNC_CALLER: i32 = 1 << 1;
59
60mod artifacts;
61mod info;
62mod intrinsic;
63mod names;
64mod types;
65mod vmcomponent_offsets;
66pub use self::artifacts::*;
67pub use self::info::*;
68pub use self::intrinsic::*;
69pub use self::names::*;
70pub use self::types::*;
71pub use self::vmcomponent_offsets::*;
72
73#[cfg(feature = "compile")]
74mod compiler;
75#[cfg(feature = "compile")]
76pub mod dfg;
77#[cfg(feature = "compile")]
78mod same_vmctx;
79#[cfg(feature = "compile")]
80mod thread_transparency;
81#[cfg(feature = "compile")]
82mod translate;
83#[cfg(feature = "compile")]
84mod types_builder;
85#[cfg(feature = "compile")]
86pub use self::compiler::*;
87#[cfg(feature = "compile")]
88pub use self::same_vmctx::analyze_same_vmctx_imports;
89#[cfg(feature = "compile")]
90pub use self::thread_transparency::transparent_adapters;
91#[cfg(feature = "compile")]
92pub use self::translate::*;
93#[cfg(feature = "compile")]
94pub use self::types_builder::*;
95
96#[macro_export]
99macro_rules! foreach_builtin_component_function {
100 ($mac:ident) => {
101 $mac! {
102 resource_new32(vmctx: vmctx, caller_instance: u32, resource: u32, rep: u32) -> u64;
103 resource_rep32(vmctx: vmctx, caller_instance: u32, resource: u32, idx: u32) -> u64;
104
105 resource_drop(vmctx: vmctx, caller_instance: u32, resource: u32, idx: u32) -> u64;
110
111 resource_transfer_own(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
112 resource_transfer_borrow(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
113
114 enter_sync_call(vmctx: vmctx, callee_async: u32, callee_instance: u32) -> bool;
115 exit_sync_call(vmctx: vmctx) -> bool;
116
117 #[cfg(feature = "component-model-async")]
118 backpressure_modify(vmctx: vmctx, caller_instance: u32, increment: u8) -> bool;
119 #[cfg(feature = "component-model-async")]
120 task_return(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, storage: ptr_u8, storage_len: size) -> bool;
121 #[cfg(feature = "component-model-async")]
122 task_cancel(vmctx: vmctx, caller_instance: u32) -> bool;
123 #[cfg(feature = "component-model-async")]
124 waitable_set_new(vmctx: vmctx, caller_instance: u32) -> u64;
125 #[cfg(feature = "component-model-async")]
127 waitable_set_wait(vmctx: vmctx, caller_instance: u32, options: u32, set: u32, payload: u32) -> u64;
128 #[cfg(feature = "component-model-async")]
130 waitable_set_poll(vmctx: vmctx, caller_instance: u32, options: u32, set: u32, payload: u32) -> u64;
131 #[cfg(feature = "component-model-async")]
132 waitable_set_drop(vmctx: vmctx, caller_instance: u32, set: u32) -> bool;
133 #[cfg(feature = "component-model-async")]
134 waitable_join(vmctx: vmctx, caller_instance: u32, set: u32, waitable: u32) -> bool;
135 #[cfg(feature = "component-model-async")]
136 subtask_drop(vmctx: vmctx, caller_instance: u32, task_id: u32) -> bool;
137 #[cfg(feature = "component-model-async")]
138 subtask_cancel(vmctx: vmctx, caller_instance: u32, async_: u8, task_id: u32) -> u64;
139 #[cfg(feature = "component-model-async")]
140 prepare_call(
141 vmctx: vmctx,
142 memory: ptr_u8,
143 start: ptr_u8,
144 return_: ptr_u8,
145 caller_instance: u32,
146 callee_instance: u32,
147 task_return_type: u32,
148 callee_async: u32,
149 string_encoding: u32,
150 result_count_or_max_if_async: u32,
151 storage: ptr_u8,
152 storage_len: size
153 ) -> bool;
154 #[cfg(feature = "component-model-async")]
155 start_call(vmctx: vmctx, callback: ptr_u8, post_return: ptr_u8, storage: ptr_u8, storage_len: size, callee: ptr_u8, param_count: u32, result_count: u32, flags: u32) -> bool;
156 #[cfg(feature = "component-model-async")]
157 future_new(vmctx: vmctx, caller_instance: u32, ty: u32) -> u64;
158 #[cfg(feature = "component-model-async")]
160 future_write(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, future: u32, address: u32) -> u64;
161 #[cfg(feature = "component-model-async")]
163 future_read(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, future: u32, address: u32) -> u64;
164 #[cfg(feature = "component-model-async")]
165 future_cancel_write(vmctx: vmctx, caller_instance: u32, ty: u32, async_: u8, writer: u32) -> u64;
166 #[cfg(feature = "component-model-async")]
167 future_cancel_read(vmctx: vmctx, caller_instance: u32, ty: u32, async_: u8, reader: u32) -> u64;
168 #[cfg(feature = "component-model-async")]
169 future_drop_writable(vmctx: vmctx, caller_instance: u32, ty: u32, writer: u32) -> bool;
170 #[cfg(feature = "component-model-async")]
171 future_drop_readable(vmctx: vmctx, caller_instance: u32, ty: u32, reader: u32) -> bool;
172 #[cfg(feature = "component-model-async")]
173 stream_new(vmctx: vmctx, caller_instance: u32, ty: u32) -> u64;
174 #[cfg(feature = "component-model-async")]
176 stream_write(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, stream: u32, address: u32, count: u32) -> u64;
177 #[cfg(feature = "component-model-async")]
179 stream_read(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, stream: u32, address: u32, count: u32) -> u64;
180 #[cfg(feature = "component-model-async")]
181 stream_cancel_write(vmctx: vmctx, caller_instance: u32, ty: u32, async_: u8, writer: u32) -> u64;
182 #[cfg(feature = "component-model-async")]
183 stream_cancel_read(vmctx: vmctx, caller_instance: u32, ty: u32, async_: u8, reader: u32) -> u64;
184 #[cfg(feature = "component-model-async")]
185 stream_drop_writable(vmctx: vmctx, caller_instance: u32, ty: u32, writer: u32) -> bool;
186 #[cfg(feature = "component-model-async")]
187 stream_drop_readable(vmctx: vmctx, caller_instance: u32, ty: u32, reader: u32) -> bool;
188 #[cfg(feature = "component-model-async")]
190 flat_stream_write(vmctx: vmctx, caller_instance: u32, ty: u32, options:u32, payload_size: u32, payload_align: u32, stream: u32, address: u32, count: u32) -> u64;
191 #[cfg(feature = "component-model-async")]
193 flat_stream_read(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, payload_size: u32, payload_align: u32, stream: u32, address: u32, count: u32) -> u64;
194 #[cfg(feature = "component-model-async")]
196 error_context_new(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, debug_msg_address: u32, debug_msg_len: u32) -> u64;
197 #[cfg(feature = "component-model-async")]
199 error_context_debug_message(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, err_ctx_handle: u32, debug_msg_address: u32) -> bool;
200 #[cfg(feature = "component-model-async")]
201 error_context_drop(vmctx: vmctx, caller_instance: u32, ty: u32, err_ctx_handle: u32) -> bool;
202 #[cfg(feature = "component-model-async")]
203 future_transfer(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
204 #[cfg(feature = "component-model-async")]
205 stream_transfer(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
206 #[cfg(feature = "component-model-async")]
207 error_context_transfer(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
208 #[cfg(feature = "component-model-async")]
209 thread_index(vmctx: vmctx) -> u64;
210 #[cfg(feature = "component-model-async")]
211 thread_new_indirect(vmctx: vmctx, caller_instance: u32, func_ty_id: u32, func_table_idx: u32, func_idx: u32, context: u32) -> u64;
212 #[cfg(feature = "component-model-async")]
213 thread_resume_later(vmctx: vmctx, caller_instance: u32, thread_idx: u32) -> bool;
214 #[cfg(feature = "component-model-async")]
215 thread_suspend(vmctx: vmctx, caller_instance: u32) -> u32;
216 #[cfg(feature = "component-model-async")]
217 thread_yield(vmctx: vmctx, caller_instance: u32) -> u32;
218 #[cfg(feature = "component-model-async")]
219 thread_suspend_then_resume(vmctx: vmctx, caller_instance: u32, thread_idx: u32) -> u32;
220 #[cfg(feature = "component-model-async")]
221 thread_yield_then_resume(vmctx: vmctx, caller_instance: u32, thread_idx: u32) -> u32;
222 #[cfg(feature = "component-model-async")]
223 thread_suspend_then_promote(vmctx: vmctx, caller_instance: u32, thread_idx: u32) -> u32;
224 #[cfg(feature = "component-model-async")]
225 thread_yield_then_promote(vmctx: vmctx, caller_instance: u32, thread_idx: u32) -> u32;
226
227 utf8_to_utf8(vmctx: vmctx, src: ptr_u8, len: size, dst: ptr_u8) -> bool;
228 utf16_to_utf16(vmctx: vmctx, src: ptr_u16, len: size, dst: ptr_u16) -> bool;
229 latin1_to_latin1(vmctx: vmctx, src: ptr_u8, len: size, dst: ptr_u8) -> bool;
230 latin1_to_utf16(vmctx: vmctx, src: ptr_u8, len: size, dst: ptr_u16) -> bool;
231 utf8_to_utf16(vmctx: vmctx, src: ptr_u8, len: size, dst: ptr_u16) -> size;
232 utf16_to_utf8(vmctx: vmctx, src: ptr_u16, src_len: size, dst: ptr_u8, dst_len: size, first_pass: u32, ret2: ptr_size) -> size;
233 latin1_to_utf8(vmctx: vmctx, src: ptr_u8, src_len: size, dst: ptr_u8, dst_len: size, first_pass: u32, ret2: ptr_size) -> size;
234 utf16_to_compact_probably_utf16(vmctx: vmctx, src: ptr_u16, len: size, dst: ptr_u16) -> size;
235 utf8_to_latin1(vmctx: vmctx, src: ptr_u8, len: size, dst: ptr_u8, ret2: ptr_size) -> size;
236 utf16_to_latin1(vmctx: vmctx, src: ptr_u16, len: size, dst: ptr_u8, ret2: ptr_size) -> size;
237 utf8_to_compact_utf16(vmctx: vmctx, src: ptr_u8, src_len: size, dst: ptr_u16, dst_len: size, bytes_so_far: size) -> size;
238 utf16_to_compact_utf16(vmctx: vmctx, src: ptr_u16, src_len: size, dst: ptr_u16, dst_len: size, bytes_so_far: size) -> size;
239 }
240 };
241}
242
243declare_builtin_index! {
245 pub struct ComponentBuiltinFunctionIndex: foreach_builtin_component_function;
247}