You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
It seems WasmGC currently can only create WasmGC arrays via the following instructions:
array.new
array.new_default
array.new_fixed
array.new_elem
array.new_data
If the array's field type is const then after creation the array can only be accessed in read-only mode (accessing length & elements).
It can be very beneficial for compilers & optimizers to know that an array is const, so two loads at same index will always yield the same value, etc. So we'd like to take advantage of that. If we know the length of the array it's very convenient to use array.new_fixed. Though if we don't know the length and have the array values in a mutable array (i.e. field type is var) it seems the only way to create a const array from that would be to load elements from the mutable array, store into element section and then use array.new_elem. This seems super cumbersome.
Is there any simple way to create a const array with contents from a var array where the length is unknown?
It would be nice to have an array.copy() (related #313) or array.new_copy() (related: #367) that atomically create a const array and initializes it from a source array (const or var) - or a sub-range of one.