Skip to content

Conversation

rossberg
Copy link
Member

First step towards handling the binary format in the spec. The patch was getting large, so I decided to split it up. This part includes the encoder, and several additions to make it useful. For example, you can now invoke the interpreter like

wasm module.wast -o module.wasm

to convert from text to binary. In a while, the same will also be possible in the inverse direction.

I also extended the script language with (input <file>) and (output <file>) commands. Both are supposed to be able to handle both wast and wasm eventually. The former allows including other scripts or binary modules, the latter allows conversion as part of a script.

Finally, the command line now supports an -e <script> option, which enables to give commands directly. This is useful, for example, when intermingled with binary module arguments, e.g., to invoke exports:

wasm module.wasm -e '(invoke "foo")'

Caveat: the binary format implemented in this patch already uses post-order. There currently is no compatible consumer (the decoder for the follow-up patch isn't quite ready yet), so this is completely untested. Uploading it anyway, to factor reviewing a little bit. Tests will follow once the decoder is ready.

@@ -119,7 +119,7 @@ and func' =
type memory = memory' Source.phrase
and memory' =
{
initial : Memory.size;
min : Memory.size;
Copy link
Member

Choose a reason for hiding this comment

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

It's perhaps subtle, but why is "initial" changing to "min" here and elsewhere? Apparently BinaryFormat.md calls it "minimum", but AstSemantics.md still calls it "initial".

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, fair point. The naming in BinaryFormat is more symmetric, so I chose that. We should resolve it either way, happy to change back if that's preferred.


The file format is a (very dumb) form of *script* that cannot just define a module, but also batch a sequence of invocations.
The S-expression format is a (very dumb) form of *script* that cannot just define a module, but in fact a sequence of them, and a batch of invocations, assertions, and conversions to each one. As such it is a superset of the binary format, with the additional functionality purely intended as testing infrastructure. (See [below][#scripts] for details.)
Copy link
Member

Choose a reason for hiding this comment

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

I'll make one more argument against calling .wast a "superset" of a .wasm:

From a user perspective, as opposed to a ml-proto implementation perspective, .wast files are not modules; they are scripts that have a way to define modules inline. They don't satisfy the "isa" relationship, except via an awkward path where all modules but one are silently discarded, behavior which isn't useful outside of artificial testcases.

Copy link
Member Author

Choose a reason for hiding this comment

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

Avoiding the word "superset" now.

@sunfishcode sunfishcode modified the milestone: MVP Mar 14, 2016
@rossberg
Copy link
Member Author

Superseded by #268.

@rossberg rossberg closed this Apr 21, 2016
@rossberg rossberg deleted the encode branch June 16, 2016 08:34
ngzhian added a commit to ngzhian/spec that referenced this pull request Nov 4, 2021
Merge upstream spec changes into simd
dhil pushed a commit to dhil/webassembly-spec that referenced this pull request Mar 2, 2023
* Update index of instructions.

Fixes Issue WebAssembly#258

-  Python script tweak, TRY has now two validation and two execution rules.
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.

2 participants