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

Segment refactoring - #113

Merged
rossberg merged 8 commits into
masterfrom
segment-cleanup
Oct 7, 2019
Merged

rossberg merged 8 commits into
masterfrom
segment-cleanup

Conversation

@rossberg

@rossberg rossberg commented Sep 28, 2019 •

Copy link
Copy Markdown
Member

Refactor segment representation in AST (in both spec and interpreter) by separating out a segment_mode.

Other changes in Spec:

  • Various fixes to text format grammar of segments.
  • Factor out elemkind in binary format.
  • Add note about possible future extension of element kinds.
  • Add note about interpretation of segment kinds as bitfields.
  • Fix some cross references.

Other changes in Interpreter:

  • Rename {table,memory}_segment to {elem,data}_segment.
  • Some rename elem to elem_expr and global.value to global.ginit for consistency with spec.
  • Decode the elem segment kind as vu32 to maintain backwards compat.
  • Some code simplifications / beautifications.

@rossberg
rossberg requested a review from gahaas September 28, 2019 09:15
@rossberg
rossberg requested a review from binji September 29, 2019 06:43
@rossberg rossberg changed the title [interpreter] Segment refactoring Segment refactoring Sep 29, 2019

@gahaas gahaas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits

\production{data segment} & \Bdata &::=&
\hex{00}~~e{:}\Bexpr~~b^\ast{:}\Bvec(\Bbyte)
&\Rightarrow& \{ \DMEM~0, \DOFFSET~e, \DINIT~b^\ast \} \\ &&|&
&\Rightarrow& \{ \DINIT~b^\ast, \DMODE~\DACTIVE~\{ \DMEM~0, \DOFFSET~e \} \} \\ &&|&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does \DMEM map to data and not to memory?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, can you elaborate?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\DMEM indicates the memory index, so I would have expected the mode to be active {memory 0, offset e}. However, for some reason it is active {data 0, offset e}.
For element segments, it is active {table 0, offset e} and not active {elem 0, offset e}.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you mean the macro is misdefined. Indeed, fixed!

Comment thread document/core/text/modules.rst Outdated
\text{(}~\text{elem}~~\Tid^?~~\text{(}~\text{table}~~x{:}\Ttableidx_I ~\text{)}~~\text{(}~\text{offset}~~e{:}\Texpr_I~\text{)}~~(et, y^\ast){:}\Telemlist~\text{)} \\ &&& \qquad
\Rightarrow\quad \{ \ETYPE~et, \EINIT~y^\ast, \EMODE~\EACTIVE~\{ \ETABLE~x, \EOFFSET~e \} \} \\
\production{element list} & \Telemlist &::=&
et{:}\Telemtype~~y^\ast{:}\Tvec(\Telemexpr_I) \qquad\Rightarrow\quad ( \ETYPE~et, \EINIT~y^\ast ) \\ &&|&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The &&|& at the end is a typo I think.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed.

Comment thread document/core/text/modules.rst Outdated
\text{(}~\text{elem}~~\text{(}~\text{offset}~~\Texpr_I~\text{)}~~\dots~\text{)}
\text{(}~\text{elem}~~\Tid^?~~\text{(}~\text{offset}~~\Texpr_I~\text{)}~~\Telemlist~\text{)}
&\equiv&
\text{(}~\text{elem}~~\Tid^?~~\text{(}~\text{table}~~\text{0}~\text{)}~~\text{(}~\text{offset}~~\Texpr_I~\text{)}~~\Telemlist~\text{)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A \equiv is missing here. Also, can you put all clauses into separate lines?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The \equiv is on the line before, but there was an \\ missing.

Added line wraps.

Comment thread document/core/valid/modules.rst Outdated
....................................................

* The memory :math:`C.\CMEMS[x]` must be defined in the context.
* The data mode :math:`\elemmode` must valid with type :math:`\segtype`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\elemmode -> \datamode

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread interpreter/binary/decode.ml Outdated
ref_func (at var s)

let elem_kind s =
match vs7 s with

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be u8 s?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@gahaas

gahaas commented Oct 1, 2019

Copy link
Copy Markdown
Contributor

Still LGTM. I don't know if Ben can take a look, he is OOO until next year.

@rossberg

rossberg commented Oct 1, 2019

Copy link
Copy Markdown
Member Author

@binji, since you are OOO, are you okay with @gahaas owning the reviews for this and PRs #114 and #115? They complete the spec and tweak the interpreter.

@rossberg

rossberg commented Oct 7, 2019

Copy link
Copy Markdown
Member Author

Okay, since @binji seems unreachable I'm landing this in the interest of making progress with the spec.

@rossberg
rossberg merged commit f47a675 into master Oct 7, 2019
@rossberg
rossberg deleted the segment-cleanup branch October 7, 2019 09:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants