Skip to content
This repository was archived by the owner on Nov 3, 2021. It is now read-only.
This repository was archived by the owner on Nov 3, 2021. It is now read-only.

Change passive element segment encoding #98

Closed

Description

@binji

We discussed this at the 2019 June CG meeting, and decided to update the passive element segment encoding.

See https://github.com/WebAssembly/meetings/blob/master/2019/CG-06.md#bulk-memory--hr (particularly the slides).

Activity

  1. binji commented on Jun 28, 2019

    @binji
    MemberAuthor

    Proposed encoding (from slide 14):

    Flags Value Segment Type Externval Index / Element Expression Table 0 / Table index field
    0 Active Externval index Table 0
    1 Active Element expression Table 0
    2 Active Externval index Table index field
    3 Active Element expression Table index field
    4 Passive Externval index N/A
    5 Passive Element expression N/A
    6 Declared Externval index N/A

    Memory layout (from slide 16) (updated to match @rossberg's format below)

    Flag Meaning Field Field Field Payload
    0 active, externval, table 0 offset idx*
    1 active, elemexpr, table 0 offset expr*
    2 active, externval offset tableidx externkind idx*
    3 active, elemexpr offset tableidx expr*
    4 passive, externval externkind idx*
    5 passive, elemexpr elemtype expr*
    6 declared, externval externkind idx*

    (update added meaning of bits)

    Bit Meaning
    0 is elemexpr
    1 has tableidx (or declared if bit 2 is set)
    2 is passive (or declared if bit 1 is set)

    Any concerns with this?

  2. lars-t-hansen commented on Jul 1, 2019

    @lars-t-hansen
    Contributor

    No concerns.

  3. titzer commented on Jul 1, 2019

    @titzer

    I guess this is a bikeshedding thread. :-)

    What about making the low-order bit of the flags field for the first table indicate whether a table index immediate follows? That way, no table lookup is necessary for a decoder to skip to the next entry, just a bit check.

  4. rossberg commented on Jul 1, 2019

    @rossberg
    Member

    I generally would prefer compatibility with the flag layout for data segments, i.e., use more bits, but have the same bits mean the same thing. I also wouldn't mind a bit more separation of te various dimensions.

    For data segments we have:

    Bit Meaning
    0 is passive
    1 is zero idx (if bit 0 clear) or clear otherwise

    For elements that would suggest:

    Bit Meaning
    0 is passive
    1 is zero idx (if bit 0 clear) or is declared (if bit 0 set)
    2 is elemexpr

    That is, we add bit 2, and reuse bit 1 for a previously unused case.

    Furthermore, I would suggest to put the table index first if present, directly after the flag. That's consistent with data segments, plus that way the special backwards compat case with table 0 can be viewed as just a compression of two consecutive bytes.

    Together that would yield:

    Flag Meaning Field Field Field Payload
    0 legacy active, externval offset idx*
    1 passive, externval externkind idx*
    2 active, externval tableidx offset externkind idx*
    3 declared, externval externkind idx*
    4 legacy active, elemexpr offset expr*
    5 passive, elemexpr elemtype expr*
    6 active, elemexpr tableidx offset elemtype expr*
    7 declared, elemexpr elemtype expr*

    Other than renumbering, the only differences to your scheme are: (1) the tableidx is put first, (2) active elemexpr segments have an elemtype as well, and (3) it allows declared segments with elemexpr (which seems unnecessary to rule out).

    We could also reorder the flags to make this table look nicer, but then we should do the same for data segments.

  5. tlively commented on Jul 1, 2019

    @tlively
    Member

    I think having separate meanings for each bit as in @rossberg's scheme is a good idea.

  6. binji commented on Jul 1, 2019

    @binji
    MemberAuthor

    @tlively there are separate meanings in my proposal too, I've updated to show what they mean, and updated the table to match his format too. That said, I'm ok w/ @rossberg's proposal too.

  7. tlively commented on Jul 1, 2019

    @tlively
    Member

    Oh right, thanks for making those explicit. I'd be fine with either of these schemes.

  8. rossberg commented on Jul 2, 2019

    @rossberg
    Member

    Yes, the main point of my modification is consistency with data segments and consistency regarding the presence of elemtype.

  9. binji commented on Jul 8, 2019

    @binji
    MemberAuthor

    OK, let's do @rossberg's scheme then. @lars-t-hansen OK w/ you?

  10. lars-t-hansen commented on Jul 8, 2019

    @lars-t-hansen
    Contributor

    Sure, no problem.

  11. added 2 commits that reference this issue on Aug 13, 2019
  12. rossberg commented on Nov 23, 2019

    @rossberg
    Member

    This was done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions