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

Separate core semantics and text format #93

Open
5 of 11 tasks
hjorthjort opened this issue Jun 14, 2019 · 4 comments
Open
5 of 11 tasks

Separate core semantics and text format #93

hjorthjort opened this issue Jun 14, 2019 · 4 comments

Comments

@hjorthjort
Copy link
Contributor

hjorthjort commented Jun 14, 2019

It's becoming a bit inconvenient to have all these folded instructions, aliases and syntactic sugars in the main semantics module, wasm.md. I suggest we move all rules that are just intermediate rewrites, such as instruction unfolding, into a module named normalizations.md. That way, wasm.md becomes a close mirror of the "Execution" part of the spec, dealing with the AST and state updates, and normalizations.md deals with the whole world of valid .wast concrete syntax by only rewriting top-level terms in the <k> cell.

Instead of having all these rules in the core syntax, we can keep them in a separate module. This both makes the core semantics smaller, more like the official spec, and a smaller compile target for the binary format.

Update: Here's the suggested tasks

  • Introduce a separate module for the text format.
  • Move out pure desugaring rules and syntax: folded instructions, inlined exports/imports, etc.
  • Move block instructions (control flow) with identifiers to text module (requires some way to look up the correct branching index).
  • Move definitions with identifers to the core semantics:
    • memory, table
    • func, start
    • global, local
    • imports, exports
    • type
    • elem, data
  • Move Identifiers out of data.md and into text module.
@QianyangPeng
Copy link
Contributor

I am also thinking about doing file splittings because the wasm.md file is getting too long. It is a good idea to split code by its purpose. We may do this after all the current features get merged.

@hjorthjort
Copy link
Contributor Author

I think it's no rush, really, but it also doesn't have to wait: it should be straightforward in most cases to grab the desugaring rules and move them, and merge conflicts should be simple, since the rules for desugaring are disjoint from the rest (or should be).

We could perhaps put the new module in the same file,we don't actually need a separate file. Perhaps that's the easiest to her an overview of, especially if we want to point people to a single file for getting to see most of our semantics.

@hjorthjort hjorthjort changed the title Execution semantics and normalization rules mixed in wasm.md Separate core semantics and text format Aug 15, 2019
@hjorthjort
Copy link
Contributor Author

Next step is drafted in #183

@hjorthjort
Copy link
Contributor Author

To avoid hacks like <labeldepth>, we should probably do a pre-pass over the text format and turn it into AST format.

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

No branches or pull requests

2 participants