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

FF125 WAS multi memory ff125 #32919

Merged
merged 24 commits into from
Apr 16, 2024
Merged

Conversation

hamishwillee
Copy link
Collaborator

@hamishwillee hamishwillee commented Apr 2, 2024

This builds on #32917 with more general fixes plus documentation for multi-memory WASM.

So far:

  • Browser compat for all features added to the WebAssembly Home page
    • The JS API part of WASM works pretty much like WebAPI w.r.t compat. However the wasm text format does not - there are big picture features that touch many undocumented instructions, or some in JS and WASM.
    • This adds them in one place so at least interested parties who know about the specs can easily see the information.
    • This allows me to link to the compat rather than talking about versions that things were introduced in in the docs.
  • WebAssembly Multi memory in "using the text format"
  • Cannot update the Interactive examples because they don't support multi memory
  • memory and friends
    • load
    • store
    • grow
    • size
    • copy
    • fill

Associated example here: mdn/webassembly-examples#35

Related docs work tracked in #32777

@github-actions github-actions bot added Content:wasm WebAssembly docs size/s [PR only] 6-50 LoC changed labels Apr 2, 2024
@github-actions github-actions bot added size/m [PR only] 51-500 LoC changed and removed size/s [PR only] 6-50 LoC changed labels Apr 2, 2024
@hamishwillee hamishwillee marked this pull request as ready for review April 9, 2024 08:06
@hamishwillee hamishwillee requested a review from a team as a code owner April 9, 2024 08:06
@hamishwillee hamishwillee requested review from pepelsbey and MendyBerger and removed request for a team April 9, 2024 08:06
@hamishwillee
Copy link
Collaborator Author

@MendyBerger First draft of this done. It's like "minimum viable product". I expect to add more, but I want this in place as a link for the release note which I will craft on Friday. Then hope to go back and look at the other PR for getting sidebar etc.

@hamishwillee hamishwillee mentioned this pull request Apr 9, 2024
10 tasks
@@ -284,45 +284,93 @@ const global = new WebAssembly.Global({ value: "i32", mutable: true }, 0);

### WebAssembly Memory
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FYI @MendyBerger This is the same example, I've just restructured this to more clearly separate the theoretical bits from the example, and the bits about memory vs the logging. Also cross linked to the instructions.

NOTE, some things we can't link to that it would be nice to are: import, data, memory. The last one being the most important - the instruction to actually declare memory. Don't know if you're interested in creating instruction pages for those.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would love to, but unfortunately, I've got limited time right now.
Might have more time in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

More than fair enough.

@hamishwillee
Copy link
Collaborator Author

@MendyBerger (and @pepelsbey if you want to get involved). We have an FF release next week so it would be great if I could get this reviewed and merged as soon as possible. I am aware that if this goes in it will not be complete, because I still need to update the remaining instructions. But it will have the core information on how to use the feature. I expect to do the remaining work early next week, but would be good to get this looked at before then.

Copy link
Contributor

@MendyBerger MendyBerger left a comment

Choose a reason for hiding this comment

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

Looks really good!

Sorry I didn't review until now. Was swamped the last few days, and missed your note about needing it before Friday.

files/en-us/webassembly/reference/memory/grow/index.md Outdated Show resolved Hide resolved
files/en-us/webassembly/reference/memory/grow/index.md Outdated Show resolved Hide resolved
---

{{WebAssemblySidebar}}

The **`load`** instructions, are used to load a number from memory onto the stack.
The **`load`** [memory instructions](/en-US/docs/WebAssembly/Reference/Memory) are used to are used to load a number from memory onto the stack.
Copy link
Contributor

Choose a reason for hiding this comment

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

Double "are used to"?

Memorry support in WASM modules matches the [`WebAssembly.Memory`](/en-US/docs/WebAssembly/JavaScript_interface/Memory) JavaScript API.
Support for the multiMemory feature is listed below.

{{Compat}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Love what you've done with this page!!

@@ -284,45 +284,93 @@ const global = new WebAssembly.Global({ value: "i32", mutable: true }, 0);

### WebAssembly Memory
Copy link
Contributor

Choose a reason for hiding this comment

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

Would love to, but unfortunately, I've got limited time right now.
Might have more time in the future.


While there are many ways to encode a string's length in the string itself (for example, C strings); for simplicity here we just pass both offset and length as parameters:
Note that when you create the memory you need to define both the initial size, and the maximum size to which the memory can grow.
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't max size optional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. Fixed.

@github-actions github-actions bot added size/l [PR only] 501-1000 LoC changed and removed size/m [PR only] 51-500 LoC changed labels Apr 15, 2024
@hamishwillee
Copy link
Collaborator Author

Thanks for the review @MendyBerger. I've taken on board your feedback and updated what was there and the remaining instructions. All should be good now - though I did omit examples in copy and fill - I need this in and can back-fill that.

Can I get a final review/approval/merge on this @MendyBerger @pepelsbey . There is no doubt more that could be done, but this is a significant update, and would be good to get in.

Copy link
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

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

Amazing work! Thank you :)

@hamishwillee
Copy link
Collaborator Author

Thanks very much for the reviews!

@hamishwillee hamishwillee merged commit e731446 into mdn:main Apr 16, 2024
8 checks passed
@hamishwillee hamishwillee deleted the wasm_multi_memory_ff125 branch April 16, 2024 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:wasm WebAssembly docs size/l [PR only] 501-1000 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants