Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spec] Execution: conventions, runtime, instructions #467

Merged
merged 10 commits into from
May 16, 2017
Merged

Conversation

rossberg
Copy link
Member

@rossberg rossberg commented Apr 26, 2017

First stab at of the execution semantics. Describes conventions, runtime structures, and the semantics of instructions. Still missing: the description of the numeric operations and the instantiation/linking of modules. Various other tweaks included.

Preview at https://webassembly.github.io/spec/

kanaka added a commit to kanaka/awesome-wasm that referenced this pull request Apr 26, 2017
WebAssembly computations manipulate *values* of the four basic :ref:`value types <syntax-valtype>`: :ref:`integers <syntax-int>` and :ref:`floating-point data <syntax-float>` of 32 or 64 bit width each, respectively.

In most places of the semantics, values of different types can occur.
In order to avoid ambiguities, values are therefor represented with an abstract syntax that makes their type explicit.
Copy link
Member

Choose a reason for hiding this comment

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

sp: therefore

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

.. math::
\begin{array}{lll@{\qquad}l}
\bytes_N(i) &=& \epsilon & (N = 0 \wedge i = 0) \\
\bytes_N(i) &=& b~\bytes_{N-8}(j) & (N \geq 8 \wedge i = 8\cdot j + b) \\
Copy link
Member

Choose a reason for hiding this comment

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

Should this be i = 2^8\cdot j + b?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

(\mbox{if} & S.\FUNCS[a] = f \\
\wedge & f.\CODE = \{ \TYPE~x, \LOCALS~t^\ast, \BODY~\instr^\ast~\END \} \\
\wedge & f.\MODULE.\TYPES[x] = [t_1^n] \to [t_2^m] \\
\wedge & F = \{ \MODULE~f.\MODULE, ~\LOCALS~\val^n~(t.\CONST~0)^\ast \})
Copy link
Member

Choose a reason for hiding this comment

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

Seems a bit confusing to use * here since I normally assume they are all unrelated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, this pattern of implicit "mapping" over a sequence actually occurs in many places, not just this chapter. That is, when there is a sequence x*, then a sequence (...x...)* is meant to correlate. I added an explanation to the syntactic conventions section.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see. The mapping normally tracks for me, but t* -> (t.const 0)* didn't as much. In my mind using another symbol would make it clearer (e.g. t^k -> (t.const 0)^k), but I'm no formalist so I don't know if that makes any sense. :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, done.


a. Trap.

12. Let :math:`a` be the :ref:`function address <syntax-funcaddr>` :math:`\X{tab}.\ELEM[i]`.
Copy link
Member

Choose a reason for hiding this comment

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

a is redefined here (previously defined at step 3). Maybe worth using a new letter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@rossberg rossberg mentioned this pull request May 11, 2017
@lukewagner
Copy link
Member

Really nice! lgtm with a few small nits/suggestions:

  • conventions.html#textual-notation - Maybe want to rename this section to "Prose conventions" because when I first read "Textual Notation" and have the paragraph say that these are the conventions followed by option (1) above.
  • runtime.html#addresses - Might be useful to add note contrasting "addresses" to the indices in syntax/modules.html#syntax-index. Particularly that indices are static and module-local whereas addreses index a dynamic and index the store.
  • t.load/store - I think bounds checking (in prose and formal) needs to be strictly <, not <=. Also, it might be nice to hyperlink the colon in data[ea : N] and others to conventions.html#auxiliary-notation
  • call_indirect formal conjuncts' column alignment seems messed up
  • instructions.html#instruction-sequences - It'd be nice to prefix Entering/Exiting prose paragraphs with a note that these subroutines are "called" by other instructions. Similarly for "Invocation" in instructions.html#function-calls.

@rossberg
Copy link
Member Author

@lukewagner, thanks! Addressed comments, except the hyperlinking suggestion (put on my todo list of xref clean-ups/additions) and the bounds checking. I think the bounds check is correct as is -- note that it already includes the width of the data, and reading, say, 2 bytes at address 8 in a 10 byte address space should be fine.

@lukewagner
Copy link
Member

@rossberg-chromium D'oh, you're right; I missed the data width. Btw, have you considered any way to visually separate the end of the prose notation from the beginning of the formal rules? (e.g.) They sortof run together atm.

@rossberg
Copy link
Member Author

@lukewagner, yeah, I don't like that running together either, and I already tried an hline (which is the only thing markdown offers) but it made the grouping really confusing visually (rules looked as if they belonged to the next section title). Tweaking vertical spacing might be better, but markdown makes it impossible to insert less than a full empty line + paragraph space (so similar effect). But I just realised that I could play with putting the space in the formulas themselves. Are you okay with making that a todo?

@domenic
Copy link
Member

domenic commented May 15, 2017

FWIW in the HTML spec we use <hr> but style it as extra vertical whitespace. I guess that would only work here if you aren't already using <hr> for horizontal lines.

@rossberg
Copy link
Member Author

@domenic, whew, dirty. :)

@lukewagner
Copy link
Member

Are you okay with making that a todo?

Oh of course; already lgtm, just a broader question.

@rossberg rossberg merged commit 27b2ad5 into master May 16, 2017
ngzhian added a commit to ngzhian/spec that referenced this pull request Nov 4, 2021
Changes to interpreter will come in a follow-up patch.

Fixed WebAssembly#467.
ngzhian added a commit to ngzhian/spec that referenced this pull request Nov 4, 2021
dhil pushed a commit to dhil/webassembly-spec that referenced this pull request Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants