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

Don't use MemoryStyle for heap base pointer relocations #9569

Merged
merged 2 commits into from
Nov 6, 2024

Conversation

alexcrichton
Copy link
Member

Instead add a helper method to Memory which indicates whether the base pointer of memory can move. Use this and plumb the result around to the various locations that require it. This improves the readonly application of the base pointer in Cranelift by having the optimization kick in in more scenarios. It additionally fixes combining shared linear memories with 64-bit addressing or a page size of 1 by adding a runtime check before relocation of a linear memory that it's allowed to do so.

A few codegen tests are added to ensure that readonly is applied where it wasn't previously and additionally a new *.wast test was added with the cross product of various features of linear memories and some basic tests to ensure that the memories all work as expected.

This refactoring fixes two preexisting issues about shared memories requiring a "static" memory style. The restriction is now based on whether the pointer can relocate or not and that's upheld via the new trait method added here.

To account for these bug fixes the fuzzers have been updated to allow mixing the threads proposal with memory64 or custom-page-sizes.

Closes #4267
Closes #9523

Instead add a helper method to `Memory` which indicates whether the base
pointer of memory can move. Use this and plumb the result around to the
various locations that require it. This improves the `readonly`
application of the base pointer in Cranelift by having the optimization
kick in in more scenarios. It additionally fixes combining shared linear
memories with 64-bit addressing or a page size of 1 by adding a runtime
check before relocation of a linear memory that it's allowed to do so.

A few codegen tests are added to ensure that `readonly` is applied where
it wasn't previously and additionally a new `*.wast` test was added with
the cross product of various features of linear memories and some basic
tests to ensure that the memories all work as expected.

This refactoring fixes two preexisting issues about `shared` memories
requiring a "static" memory style. The restriction is now based on
whether the pointer can relocate or not and that's upheld via the new
trait method added here.

To account for these bug fixes the fuzzers have been updated to allow
mixing the `threads` proposal with `memory64` or `custom-page-sizes`.

Closes bytecodealliance#4267
Closes bytecodealliance#9523
@alexcrichton
Copy link
Member Author

I'll also notably point out that this is incompatible with MemoryCreator so I've filed #9568 to track that. I think there needs to be a good bit of refactoring of the internals of how we represent memory so I hope to tackle that next-ish.

@github-actions github-actions bot added fuzzing Issues related to our fuzzing infrastructure wasmtime:api Related to the API of the `wasmtime` crate itself labels Nov 6, 2024
Copy link

github-actions bot commented Nov 6, 2024

Subscribe to Label Action

cc @fitzgen

This issue or pull request has been labeled: "fuzzing", "wasmtime:api"

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

  • fitzgen: fuzzing

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

Learn more.

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Really like this clean up, everything is much easier to follow now. Thanks!

@fitzgen fitzgen added this pull request to the merge queue Nov 6, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 6, 2024
This code will be short-lived due to scheduled future refactorings but
the idea is that when a "dynamic" memory is chosen the minimum size of
the allocation needs to be at least `tunables.memory_reservation` to fit
the constraints of the rest of the system, so be sure to factor that
in.
@alexcrichton alexcrichton added this pull request to the merge queue Nov 6, 2024
Merged via the queue into bytecodealliance:main with commit 84852f7 Nov 6, 2024
40 checks passed
@alexcrichton alexcrichton deleted the heap-base-pointer branch November 6, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fuzzing Issues related to our fuzzing infrastructure wasmtime:api Related to the API of the `wasmtime` crate itself
Projects
None yet
2 participants