Store values to an array in the array calling convention. Used either to store arguments to the array when calling a function using the array calling convention, or used to store results to the array when implementing a function that exposes the array calling convention.
(
&self,
builder: &mut FunctionBuilder,
types: &[WasmValType],
values: &[Value],
values_vec_ptr: Value,
values_vec_capacity: Value,
)
| 1179 | /// array when implementing a function that exposes the array calling |
| 1180 | /// convention. |
| 1181 | fn store_values_to_array( |
| 1182 | &self, |
| 1183 | builder: &mut FunctionBuilder, |
| 1184 | types: &[WasmValType], |
| 1185 | values: &[Value], |
| 1186 | values_vec_ptr: Value, |
| 1187 | values_vec_capacity: Value, |
| 1188 | ) { |
| 1189 | debug_assert_eq!(types.len(), values.len()); |
| 1190 | self.debug_assert_enough_capacity_for_length(builder, types.len(), values_vec_capacity); |
| 1191 | |
| 1192 | // Note that loads and stores are unconditionally done in the |
| 1193 | // little-endian format rather than the host's native-endianness, |
| 1194 | // despite this load/store being unrelated to execution in Wasm itself. |
| 1195 | // For more details on this see the `ValRaw` type in |
| 1196 | // `wasmtime::runtime::vm`. |
| 1197 | let flags = ir::MemFlagsData::new() |
| 1198 | .with_notrap() |
| 1199 | .with_endianness(ir::Endianness::Little); |
| 1200 | |
| 1201 | let value_size = mem::size_of::<u128>(); |
| 1202 | for (i, val) in values.iter().copied().enumerate() { |
| 1203 | crate::unbarriered_store_type_at_offset( |
| 1204 | &mut builder.cursor(), |
| 1205 | flags, |
| 1206 | values_vec_ptr, |
| 1207 | i32::try_from(i * value_size).unwrap(), |
| 1208 | val, |
| 1209 | ); |
| 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | /// Used for loading the values of an array-call host function's value |
| 1214 | /// array. |
no test coverage detected