1pub const MAX_FLAT_PARAMS: usize = 16;
34
35pub const MAX_FLAT_RESULTS: usize = 1;
39
40mod artifacts;
41mod info;
42mod names;
43mod types;
44mod vmcomponent_offsets;
45pub use self::artifacts::*;
46pub use self::info::*;
47pub use self::names::*;
48pub use self::types::*;
49pub use self::vmcomponent_offsets::*;
50
51#[cfg(feature = "compile")]
52mod compiler;
53#[cfg(feature = "compile")]
54pub mod dfg;
55#[cfg(feature = "compile")]
56mod translate;
57#[cfg(feature = "compile")]
58mod types_builder;
59#[cfg(feature = "compile")]
60pub use self::compiler::*;
61#[cfg(feature = "compile")]
62pub use self::translate::*;
63#[cfg(feature = "compile")]
64pub use self::types_builder::*;
65
66#[macro_export]
69macro_rules! foreach_builtin_component_function {
70 ($mac:ident) => {
71 $mac! {
72 resource_new32(vmctx: vmctx, resource: u32, rep: u32) -> u64;
73 resource_rep32(vmctx: vmctx, resource: u32, idx: u32) -> u64;
74
75 resource_drop(vmctx: vmctx, resource: u32, idx: u32) -> u64;
80
81 resource_transfer_own(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
82 resource_transfer_borrow(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
83 resource_enter_call(vmctx: vmctx);
84 resource_exit_call(vmctx: vmctx) -> bool;
85
86 #[cfg(feature = "component-model-async")]
87 backpressure_set(vmctx: vmctx, caller_instance: u32, enabled: u32) -> bool;
88 #[cfg(feature = "component-model-async")]
89 task_return(vmctx: vmctx, ty: u32, storage: ptr_u8, storage_len: size) -> bool;
90 #[cfg(feature = "component-model-async")]
91 waitable_set_new(vmctx: vmctx, caller_instance: u32) -> u64;
92 #[cfg(feature = "component-model-async")]
93 waitable_set_wait(vmctx: vmctx, caller_instance: u32, set: u32, async_: u8, memory: ptr_u8, payload: u32) -> u64;
94 #[cfg(feature = "component-model-async")]
95 waitable_set_poll(vmctx: vmctx, caller_instance: u32, set: u32, async_: u8, memory: ptr_u8, payload: u32) -> u64;
96 #[cfg(feature = "component-model-async")]
97 waitable_set_drop(vmctx: vmctx, caller_instance: u32, set: u32) -> bool;
98 #[cfg(feature = "component-model-async")]
99 waitable_join(vmctx: vmctx, caller_instance: u32, set: u32, waitable: u32) -> bool;
100 #[cfg(feature = "component-model-async")]
101 yield_(vmctx: vmctx, async_: u8) -> bool;
102 #[cfg(feature = "component-model-async")]
103 subtask_drop(vmctx: vmctx, caller_instance: u32, task_id: u32) -> bool;
104 #[cfg(feature = "component-model-async")]
105 sync_enter(vmctx: vmctx, start: ptr_u8, return_: ptr_u8, caller_instance: u32, task_return_type: u32, result_count: u32, storage: ptr_u8, storage_len: size) -> bool;
106 #[cfg(feature = "component-model-async")]
107 sync_exit(vmctx: vmctx, callback: ptr_u8, caller_instance: u32, callee: ptr_u8, callee_instance: u32, param_count: u32, storage: ptr_u8, storage_len: size) -> bool;
108 #[cfg(feature = "component-model-async")]
109 async_enter(vmctx: vmctx, start: ptr_u8, return_: ptr_u8, caller_instance: u32, task_return_type: u32, params: u32, results: u32) -> bool;
110 #[cfg(feature = "component-model-async")]
111 async_exit(vmctx: vmctx, callback: ptr_u8, post_return: ptr_u8, caller_instance: u32, callee: ptr_u8, callee_instance: u32, param_count: u32, result_count: u32, flags: u32) -> u64;
112 #[cfg(feature = "component-model-async")]
113 future_new(vmctx: vmctx, ty: u32) -> u64;
114 #[cfg(feature = "component-model-async")]
115 future_write(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, future: u32, address: u32) -> u64;
116 #[cfg(feature = "component-model-async")]
117 future_read(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, future: u32, address: u32) -> u64;
118 #[cfg(feature = "component-model-async")]
119 future_cancel_write(vmctx: vmctx, ty: u32, async_: u8, writer: u32) -> u64;
120 #[cfg(feature = "component-model-async")]
121 future_cancel_read(vmctx: vmctx, ty: u32, async_: u8, reader: u32) -> u64;
122 #[cfg(feature = "component-model-async")]
123 future_close_writable(vmctx: vmctx, ty: u32, writer: u32) -> bool;
124 #[cfg(feature = "component-model-async")]
125 future_close_readable(vmctx: vmctx, ty: u32, reader: u32) -> bool;
126 #[cfg(feature = "component-model-async")]
127 stream_new(vmctx: vmctx, ty: u32) -> u64;
128 #[cfg(feature = "component-model-async")]
129 stream_write(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, stream: u32, address: u32, count: u32) -> u64;
130 #[cfg(feature = "component-model-async")]
131 stream_read(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, stream: u32, address: u32, count: u32) -> u64;
132 #[cfg(feature = "component-model-async")]
133 stream_cancel_write(vmctx: vmctx, ty: u32, async_: u8, writer: u32) -> u64;
134 #[cfg(feature = "component-model-async")]
135 stream_cancel_read(vmctx: vmctx, ty: u32, async_: u8, reader: u32) -> u64;
136 #[cfg(feature = "component-model-async")]
137 stream_close_writable(vmctx: vmctx, ty: u32, writer: u32) -> bool;
138 #[cfg(feature = "component-model-async")]
139 stream_close_readable(vmctx: vmctx, ty: u32, reader: u32) -> bool;
140 #[cfg(feature = "component-model-async")]
141 flat_stream_write(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, ty: u32, payload_size: u32, payload_align: u32, stream: u32, address: u32, count: u32) -> u64;
142 #[cfg(feature = "component-model-async")]
143 flat_stream_read(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, ty: u32, payload_size: u32, payload_align: u32, stream: u32, address: u32, count: u32) -> u64;
144 #[cfg(feature = "component-model-async")]
145 error_context_new(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, debug_msg_address: u32, debug_msg_len: u32) -> u64;
146 #[cfg(feature = "component-model-async")]
147 error_context_debug_message(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, err_ctx_handle: u32, debug_msg_address: u32) -> bool;
148 #[cfg(feature = "component-model-async")]
149 error_context_drop(vmctx: vmctx, ty: u32, err_ctx_handle: u32) -> bool;
150 #[cfg(feature = "component-model-async")]
151 future_transfer(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
152 #[cfg(feature = "component-model-async")]
153 stream_transfer(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
154 #[cfg(feature = "component-model-async")]
155 error_context_transfer(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
156
157 trap(vmctx: vmctx, code: u8);
158
159 utf8_to_utf8(src: ptr_u8, len: size, dst: ptr_u8) -> bool;
160 utf16_to_utf16(src: ptr_u16, len: size, dst: ptr_u16) -> bool;
161 latin1_to_latin1(src: ptr_u8, len: size, dst: ptr_u8) -> bool;
162 latin1_to_utf16(src: ptr_u8, len: size, dst: ptr_u16) -> bool;
163 utf8_to_utf16(src: ptr_u8, len: size, dst: ptr_u16) -> size;
164 utf16_to_utf8(src: ptr_u16, src_len: size, dst: ptr_u8, dst_len: size, ret2: ptr_size) -> size;
165 latin1_to_utf8(src: ptr_u8, src_len: size, dst: ptr_u8, dst_len: size, ret2: ptr_size) -> size;
166 utf16_to_compact_probably_utf16(src: ptr_u16, len: size, dst: ptr_u16) -> size;
167 utf8_to_latin1(src: ptr_u8, len: size, dst: ptr_u8, ret2: ptr_size) -> size;
168 utf16_to_latin1(src: ptr_u16, len: size, dst: ptr_u8, ret2: ptr_size) -> size;
169 utf8_to_compact_utf16(src: ptr_u8, src_len: size, dst: ptr_u16, dst_len: size, bytes_so_far: size) -> size;
170 utf16_to_compact_utf16(src: ptr_u16, src_len: size, dst: ptr_u16, dst_len: size, bytes_so_far: size) -> size;
171 }
172 };
173}
174
175declare_builtin_index!(
177 ComponentBuiltinFunctionIndex,
178 foreach_builtin_component_function
179);