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

Add return_call example for WASM #2693

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Conversation

pepelsbey
Copy link
Contributor

@pepelsbey pepelsbey commented Dec 15, 2023

Description

Adds example for return_call, tail call version of the call. I took it from the explainer.

But there’s a catch: the playground shows an error when I try to run the code. There might be two reasons for that:

  • I don’t fully understand what I’m doing (first time looking at WASM)
  • Playground doesn’t support return_call, see the error below

Motivation

To support enabled tail calls in Firefox 121.

Additional details

> Error: parseWat failed:
3:6: error: opcode not allowed: return_call
    (return_call $fac-aux (local.get $x) (i32.const 1))
     ^^^^^^^^^^^
10:10: error: opcode not allowed: return_call
        (return_call $fac-aux
         ^^^^^^^^^^^

Related issues and pull requests

mdn/content#30333

@pepelsbey pepelsbey added the Content:WASM Issues related to WebAssembly examples. label Dec 15, 2023
@pepelsbey pepelsbey requested a review from a team as a code owner December 15, 2023 15:41
@pepelsbey pepelsbey requested review from zfox23 and removed request for a team December 15, 2023 15:41
Copy link

It looks like this is your first pull request. 🎉 Thank you for your contribution! One of the project maintainers will triage and assign the pull request for review. We appreciate your patience. To safeguard the health of the project, please take a moment to read our code of conduct.

@pepelsbey
Copy link
Contributor Author

@eqrion could you please have a look?

pepelsbey and others added 2 commits December 18, 2023 18:00
Co-authored-by: Yury Delendik <ydelendik@mozilla.com>
@pepelsbey
Copy link
Contributor Author

@yurydelendik thank you! However, the code still won’t run if pasted into the playground we have on the call page, for example:

> Error: parseWat failed:
3:6: error: opcode not allowed: return_call
    (return_call $fac-aux (local.get $x) (i64.const 1))
     ^^^^^^^^^^^
10:10: error: opcode not allowed: return_call
        (return_call $fac-aux
         ^^^^^^^^^^^

Do you have an idea if it’s the problem with the playground?

@yurydelendik
Copy link

yurydelendik commented Dec 18, 2023

Do you have an idea if it’s the problem with the playground?

I have a little insight into how playground works. The WebAssembly engine does not know about WAT and text representation. The transformation to bytecode is happening somewhere else. That something perhaps needs to be updated with new wasm specifications support.

@yurydelendik
Copy link

yurydelendik commented Dec 19, 2023

If not mistaken, parseWat is API function from wabt JS library. Is https://github.com/mdn/bob/blob/main/editor/js/editable-wat.ts executed on the main page?

There is a reference to "wabt": "^1.0.29", which is https://github.com/AssemblyScript/wabt.js . The package is not updated for long time and probably missing new specifications.

@pepelsbey
Copy link
Contributor Author

The package is not updated for long time and probably missing new specifications.

Thank you for investigating! I’ll reach out to platform engineers about this.

@github-actions github-actions bot added the idle Issues and pull requests with no activity for three months. label Jan 19, 2024
@github-actions github-actions bot removed the idle Issues and pull requests with no activity for three months. label Feb 23, 2024
@caugner caugner removed the request for review from zfox23 March 18, 2024 15:35
@github-actions github-actions bot added the idle Issues and pull requests with no activity for three months. label Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WASM Issues related to WebAssembly examples. idle Issues and pull requests with no activity for three months. needs infra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants