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

Unrecognized instructions in .wast files #2

Closed
mkarup opened this issue Jul 22, 2024 · 2 comments
Closed

Unrecognized instructions in .wast files #2

mkarup opened this issue Jul 22, 2024 · 2 comments

Comments

@mkarup
Copy link

mkarup commented Jul 22, 2024

Some of the Wasm text format instructions used when emitting the .wast files are not part of the text format in official GC spec (and by extension, not recognized by Binaryen), meaning that the compilation fails when linking with wasm-merge.

There may be more issues, but here are a few that I spotted in wasm/wast.ml, wasm/runtime_binaryen.wast and wasm/imports_binaryen.wast (I'm not sure if they will actually be used in practice when emitting the wast):

  • array.init_static is not a recognized instruction (maybe array.new_fixed instead?)
  • When referring to a type by an alias, I think a ref needs to be add in front of the alias. For example
    • (ref.cast (ref i31) (local.get $a))) instead of (ref.cast i31 (local.get $a))) (or using the abbreviation i31ref)
    • (ref.cast (ref $Float) (local.get $a)) instead of (ref.cast $Float (local.get $a))
  • ref.i31 instead of i31.new
  • I don't think array.len takes a type alias argument:
    • (array.len ...) instead of (array.len $Array ...)
  • struct.new_cannon is not a recognized instruction (maybe struct.new_default instead?`)
  • br_on_cast_static is not a recognized instruction (not sure what the equivalent instruction would be)
  • br_on_i31 is not a recognized instruction (not sure what the equivalent instruction would be)
  • array.new_canon_fixed is not a recognized instruction (maybe array.new_default instead?)
  • (register ...) is not recognized in the module (runtime_binaryen.wast / imports_bynaryen.wast), I think there is a new way to link modules with wasm-merge
  • There are no recognized instructions with the tuple prefix

Disclaimer: My suggested fixes may be incorrect (or there is a more elegant way)

@zapashcanon
Copy link
Member

zapashcanon commented Jul 22, 2024

Thanks a lot ! It looks like Binaryen is finally implementing the spec exactly. All these instructions are either things that have been renamed in the GC proposal or old custom instructions from Binaryen. :) I'll make a PR to fix these issues.

@zapashcanon
Copy link
Member

zapashcanon commented Oct 3, 2024

@mkarup, this should have been fixed by #3. Feel free to re-open if you find another issue. Thanks again for the report!

(Also, please note that there's no more .wast files, I renamed all of them to .wat, it was an old misnaming...)

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

No branches or pull requests

2 participants