Stream: git-wasmtime

Topic: wasmtime / PR #6884 wiggle: generate offset accessors for...


view this post on Zulip Wasmtime GitHub notifications bot (Aug 22 2023 at 19:45):

acfoltzer opened PR #6884 from bytecodealliance:acf/wiggle-struct-field-offsets to bytecodealliance:main (assigned to acfoltzer):

Adds methods of the shape GeneratedStruct::offset_of_<field_name>() -> u32 to allow clients to get the same offsets used in the generated read and write methods. I don't believe there is currently a way to get these otherwise for applications that wish to selectively read and write to fields.

I considered a couple alternatives to this:

  1. Add methods like read_<field_name> and write_<field_name>. The interface to these ends up being awkward because the GuestType impls are currently for owned types, so these methods would be forced to either take ownership of the entire struct to write one field, or else silently clone the field.

  2. Add #[repr(C)] to the generated struct definition so that clients could use tools like memoffset to calculate the offset themselves. I didn't want to depend on the witx offsets coinciding with repr(C), though.

I extended the Wiggle records to exercise these new methods.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Aug 22 2023 at 19:45):

acfoltzer assigned PR #6884 to acfoltzer.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 22 2023 at 19:45):

acfoltzer requested pchickey for a review on PR #6884.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 22 2023 at 19:45):

acfoltzer requested wasmtime-core-reviewers for a review on PR #6884.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 22 2023 at 20:09):

pchickey submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 22 2023 at 20:09):

pchickey has enabled auto merge for PR #6884.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 22 2023 at 21:03):

pchickey merged PR #6884.


Last updated: Nov 22 2024 at 17:03 UTC