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

winch: Add support for WebAssembly loads/stores #7894

Merged
merged 2 commits into from
Feb 9, 2024

Conversation

saulecabrera
Copy link
Member

@saulecabrera saulecabrera commented Feb 8, 2024

Closes #6528

This patch adds support for all the instructions involving WebAssembly loads and stores for 32-bit memories. Given that the memory64 proposal is not enabled by default, this patch doesn't include an implementation/tests for it; in theory minimal tweaks to the currrent implementation will be needed in order to support 64-bit memories.

Implemenation-wise, this change, follows a similar pattern as Cranelift in order to calculate addresses for dynamic/static heaps, the main difference being that in some cases, doing less work at compile time is preferred; the current implemenation only checks for the general case of out-of-bounds access for dynamic heaps for example.

Another important detail regarding the implementation, is the introduction of MacroAssembler::wasm_load and
MacroAssembler::wasm_store, which internally use a common implemenation for loads and stores, with the only difference that the wasm_* variants set the right flags in order to signal that these operations are not trusted and might trap.

Finally, given that this change introduces support for the last set of instructions missing for a Wasm MVP, it removes most of Winch's copy of the spectest suite, and switches over to using the official test suite where possible (for tests that don't use SIMD or Reference Types).

Follow-up items:

  • Before doing any deep benchmarking I'm planning on landing a couple of improvements regarding compile times that I've identified in parallel to this change.
  • The imports.wast tests are disabled because I've identified a bug with call_indirect, which is not related to this change and exists in main.
  • Find a way to run the tests/all/memory.rs (or perhaps most of integration tests) with Winch.

--
prtest:full

Closes bytecodealliance#6529

This patch adds support for all the instructions involving WebAssembly
loads and stores for 32-bit memories. Given that the `memory64` proposal
is not enabled by default, this patch doesn't include an
implementation/tests for it; in theory minimal tweaks to the
currrent implementation will be needed in order to support 64-bit
memories.

Implemenation-wise, this change, follows a similar pattern as Cranelift
in order to calculate addresses for dynamic/static heaps, the main
difference being that in some cases, doing less work at compile time is
preferred; the current implemenation only checks for the general case of
out-of-bounds access for dynamic heaps for example.

Another important detail regarding the implementation, is the
introduction of `MacroAssembler::wasm_load` and
`MacroAssembler::wasm_store`, which internally use a common
implemenation for loads and stores, with the only difference that the
`wasm_*` variants set the right flags in order to signal that these
operations are not trusted and might trap.

Finally, given that this change introduces support for the last set of
instructions missing for a Wasm MVP, it removes most of Winch's copy of
the spectest suite, and switches over to using the official test suite
where possible (for tests that don't use SIMD or Reference Types).

Follow-up items:

* Before doing any deep benchmarking I'm planning on landing a couple of
  improvements regarding compile times that I've identified in parallel
  to this change.
* The `imports.wast` tests are disabled because I've identified a bug
  with `call_indirect`, which is not related to this change and exists
  in main.
* Find a way to run the `tests/all/memory.rs` (or perhaps most of
  integration tests) with Winch.

--
prtest:full
@saulecabrera saulecabrera requested review from a team as code owners February 8, 2024 12:45
@saulecabrera saulecabrera requested review from elliottt and pchickey and removed request for a team and pchickey February 8, 2024 12:45
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen fuzzing Issues related to our fuzzing infrastructure winch Winch issues or pull requests labels Feb 8, 2024
Copy link

github-actions bot commented Feb 8, 2024

Subscribe to Label Action

cc @fitzgen, @saulecabrera

This issue or pull request has been labeled: "cranelift", "cranelift:area:x64", "fuzzing", "winch"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: fuzzing
  • saulecabrera: winch

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@fitzgen fitzgen removed request for a team February 8, 2024 19:13
Copy link
Member

@elliottt elliottt left a comment

Choose a reason for hiding this comment

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

So happy to see this PR, congratulations on closing out #6528!

The structure of this change makes sense to me, so I went ahead and made a bunch of smaller suggestions.

fuzz/fuzz_targets/differential.rs Outdated Show resolved Hide resolved
winch/codegen/src/codegen/bounds.rs Outdated Show resolved Hide resolved
winch/codegen/src/codegen/bounds.rs Outdated Show resolved Hide resolved
winch/codegen/src/codegen/bounds.rs Outdated Show resolved Hide resolved
winch/codegen/src/codegen/bounds.rs Outdated Show resolved Hide resolved
winch/codegen/src/frame/mod.rs Outdated Show resolved Hide resolved
winch/codegen/src/isa/x64/masm.rs Outdated Show resolved Hide resolved
winch/codegen/src/isa/x64/masm.rs Show resolved Hide resolved
winch/filetests/filetests/x64/store/f64.wat Show resolved Hide resolved
winch/codegen/src/codegen/mod.rs Outdated Show resolved Hide resolved
@saulecabrera
Copy link
Member Author

@elliottt Thanks for the detailed review and all the great suggestions, I've resolved most of them, excluding two of them which I've left open for further discussion. Happy to continue the discussion and/or create follow-up PRs!

@saulecabrera saulecabrera added this pull request to the merge queue Feb 9, 2024
Merged via the queue into bytecodealliance:main with commit 83cf743 Feb 9, 2024
42 checks passed
@saulecabrera saulecabrera deleted the winch-loads-stores branch February 9, 2024 16:09
@saulecabrera saulecabrera mentioned this pull request Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator fuzzing Issues related to our fuzzing infrastructure winch Winch issues or pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Winch Core Wasm Opcode Support
2 participants