Stream: git-wasmtime

Topic: wasmtime / PR #4330 Expose raw list accessors for all int...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2022 at 16:26):

alexcrichton opened PR #4330 from component-model-slice-align to main:

This commit extends the WasmList<T> type to have an
as_slice-lookalike method (now renamed to as_le_slice) for all
integer types rather than just the u8 type. With the guarantees of the
component model it's known that all lists are aligned in linear memory.
Additionally linear memories themselves are also generally guaranteed to
be aligned. This means that hosts where the primitive integer alignment
is at most the size (which I think is basically all host platforms) can
get a raw view into memory for the wasm linear memory for slices of
these types.

Note, though, that the remaining caveat after alignment is endianness.
Big-endian hosts need to be aware that the integers aren't stored in a
native format. Previously tools like wit-bindgen have added an Le<T>
wrapper but for now I've opted to instead use a method that has "le" in
the name - as_le_slice. I'm hoping that this is a clear enough
indicator for users to little-endian conversions as appropriate when
reading the values within the slice.

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2022 at 22:53):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2022 at 22:53):

fitzgen created PR review comment:

I guess if that isn't the case, this assertion will trip.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2022 at 22:53):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2022 at 22:53):

fitzgen created PR review comment:

Do we trap if they are not aligned? That is, can we rely on these actually being aligned here?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 28 2022 at 15:24):

alexcrichton merged PR #4330.


Last updated: Nov 22 2024 at 16:03 UTC