Skip to content

Finish initial pass on wasm-binary, and add wasm-as tool #13 - #95

Merged
kripken merged 1 commit into
masterfrom
wasm-as
Jan 12, 2016
Merged

kripken merged 1 commit into
masterfrom
wasm-as

Conversation

@kripken

@kripken kripken commented Jan 12, 2016

Copy link
Copy Markdown
Member

General idea is wasm-as is a parallel to llvm-as, and so forth. But no strong feelings about names, and perhaps anyhow all tools should be able to load both binary and text eventually.

This just adds the binary writer, and checks that it compiles.

Comment thread src/wasm-as.cpp Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

2016 now.

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.

fixed

@kripken
kripken force-pushed the wasm-as branch 2 times, most recently from e9b68c6 to 7d0048e Compare January 12, 2016 02:05
@jfbastien

Copy link
Copy Markdown
Member

Could you add the following to check.py:

import test.waterfall.src.link_assembly_files as link_assembly_files
wasm_as_torture_out = os.path.abspath(os.path.join('test', 'wasm-as-torture-out'))
if os.path.isdir(wasm_as_torture_out):
  shutil.rmtree(wasm_as_torture_out)
os.mkdir(wasm_as_torture_out)
unexpected_result_count = link_assembly_files.run(
    linker=os.path.abspath(os.path.join('bin', 'wasm-as')),
    files=os.path.abspath(os.path.join('test', 'torture-s', '*.s')),
    fails=os.path.abspath(os.path.join('test', 'wasm_as_known_gcc_test_failures.txt')),
    out=wasm_as_torture_out)
assert os.path.isdir(wasm_as_torture_out), 'Expected output directory %s' % wasm_as_torture_out
shutil.rmtree(wasm_as_torture_out)
if unexpected_result_count:
  fail(unexpected_result_count, 0)

It'll also require a new test/wasm_as_known_gcc_test_failures.txt file, and an update of the test/waterfall submodule.

@kripken

kripken commented Jan 12, 2016

Copy link
Copy Markdown
Member Author

Wait, what does that code do? Run wasm-as on stuff? It's not ready yet! :)

@jfbastien

Copy link
Copy Markdown
Member

Not even mildly ready to fail on most-but-not-quite-all tests? :p

@kripken

kripken commented Jan 12, 2016

Copy link
Copy Markdown
Member Author

No, it aborts on "hello world" :)

I need to do some other refactoring. This pull is mainly to finish getting it building, as I don't want to have a long-term side branch.

@jfbastien

Copy link
Copy Markdown
Member

Ah OK, lgtm then :)

@ghost

ghost commented Jan 12, 2016

Copy link
Copy Markdown

Just out of curiosity, the llvm backend currently emits a .s file in a format that is not vaguely like wast. This tools is describe as 'Assemble a .wast (WebAssembly text format) into a .wasm (WebAssembly binary format)' and if so then the wasm-as naming looks confusing. Is it planned that the current .s format becomes the text format and superseded wast or might there be a separate .s format?

Comment thread src/wasm-as.cpp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"Link and assemble a .s into a .wasm"

@jfbastien

Copy link
Copy Markdown
Member

Just out of curiosity, the llvm backend currently emits a .s file in a format that is not vaguely like wast. This tools is describe as 'Assemble a .wast (WebAssembly text format) into a .wasm (WebAssembly binary format)' and if so then the wasm-as naming looks confusing.

It consumes a .s file, the help is wrong but I hadn't noticed. Added a comment.

Is it planned that the current .s format becomes the text format and superseded wast or might there be a separate .s format?

The .s format is just convenient for LLVM as it is now, because that got things off the ground faster without introducing alien concepts into LLVM (which the LLVM community may frown upon). It's meant to look similar to .s files for other architectures, LLVM makes that easy. @sunfishcode is experimenting with outputting binary directly from LLVM, which is more involved but then you get assembler and disassembler for free if you Do It The Right Way™.

The plans for text format are still very up in the air, and the current s-expression format isn't agreed on either. .s seems less readable than .wast so I doubt we'll standardize it as The One True Text Format™, but it may be useful to standardize between compilers, the same way standardizing .o / .a / .so files between compilers could be useful: they're not meant to get shipped to a browser, but tools can get along and that's nice.

@kripken

kripken commented Jan 12, 2016

Copy link
Copy Markdown
Member Author

Actually no, the text as it stands is correct. This tool assembles a .wast (s-expression wasm text format, and eventually the official wasm text format whatever that will be) into a .wasm (binary wasm format, in current v8 proposal).

In other words:

  • wasm-as: .wast => .wasm
  • wasm-dis: .wasm => .wast - not yet implemented

These are parallel to llvm-as, llvm-dis. They translate between the text and binary formats of the same thing, either LLVM IR or wasm AST.

Other tools convert to/from external or unofficial formats, like

  • asm2wasm: .asm.js = .wasm (well, right now it emits text, but that should change)
  • s2wasm: LLVM .s => .wasm (again, right now it emits text)
  • etc.

A sad point of confusion is that .s is LLVM's .s format, while wasm-s-parser stands for wasm-s-expression-parser, which might trip people up. Suggestions for a better name?

@jfbastien

Copy link
Copy Markdown
Member

@kripken ah right, I double-misread :-)

@binji was using sexpr, but in general wasm-as seems intuitive. So would wast2wasm and similar.

kripken added a commit that referenced this pull request Jan 12, 2016
Finish initial pass on wasm-binary, and add wasm-as tool #13
@kripken
kripken merged commit efe3693 into master Jan 12, 2016
@jfbastien
jfbastien deleted the wasm-as branch January 12, 2016 04:11
@binji

binji commented Jan 12, 2016

Copy link
Copy Markdown
Member

@jfbastien I named it that before .wast existed :)

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.

3 participants