Refactor the internals of vm::Memory to simplify the RuntimeLinearMemory trait#9577
Merged
alexcrichton merged 11 commits intobytecodealliance:mainfrom Nov 7, 2024
Merged
Conversation
Subscribe to Label Actioncc @fitzgen DetailsThis issue or pull request has been labeled: "fuzzing", "wasmtime:api", "wasmtime:c-api"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Instead of storing just a trait object store instead an `enum` between "local" memory and shared memory. This helps remove redundant trait impls on shared memories, removes the need for `dyn Any`, and removes the possibility of wrapping a shared memory as a shared memory. This is additionally intended to make it a bit easier to see what's nested where and reduce some layers of indirection.
This is intended to be a non-shared implementation of a linear memory with various bits and pieces tracking state. The end goal is to simplify the `RuntimeLinearMemory` trait to its bare bones necessary to faithfully implement wasm linear memory.
Further simplify `RuntimeLinearMemory` by moving these responsibilities up a layer into the `LocalMemory` structure.
No need to plumb it through all the traits any more. Now it's possible to only have it handled in `LocalMemory` and other pieces don't have to worry about it.
Further simplify custom traits and mmap/static memory by moving more responsibility into `LocalMemory`.
cce24de to
7e15030
Compare
fitzgen
approved these changes
Nov 7, 2024
Member
fitzgen
left a comment
There was a problem hiding this comment.
Nice! One suggestion on the ascii diagram below, that's it.
Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
github-merge-queue bot
pushed a commit
to dfinity/ic
that referenced
this pull request
Jan 9, 2025
Wasmtime release notes: https://github.com/bytecodealliance/wasmtime/releases/tag/v28.0.0 - Changed `LinearMemory` trait API, [code](bytecodealliance/wasmtime#9577) - Changed static/dynamic memory config, removed `static_memory_maximum_size` [code](bytecodealliance/wasmtime#9545) --------- Co-authored-by: Andriy Berestovskyy <andriy.berestovskyy@dfinity.org> Co-authored-by: IDX GitHub Automation <infra+github-automation@dfinity.org>
github-merge-queue bot
pushed a commit
to dfinity/ic
that referenced
this pull request
Jan 9, 2025
Wasmtime release notes: https://github.com/bytecodealliance/wasmtime/releases/tag/v28.0.0 - Changed `LinearMemory` trait API, [code](bytecodealliance/wasmtime#9577) - Changed static/dynamic memory config, removed `static_memory_maximum_size` [code](bytecodealliance/wasmtime#9545) --------- Co-authored-by: Andriy Berestovskyy <andriy.berestovskyy@dfinity.org> Co-authored-by: IDX GitHub Automation <infra+github-automation@dfinity.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a series of commits which have the end-goal of removing the
RuntimeLinearMemorytrait and replacing it withwasmtime::LinearMemory. In doing this though I wanted to simplify the trait to move more responsibilities up a layer so it's clearer what the safety contracts are and what exactly is required on behalf of embedders. This moves many of the responsibilities to a newLocalMemorytype rather than having most of the functionality implemented through trait methods. This provides, for example, a vector of having CoW support in Wasmtime without supporting it throughLinearMemory(or not officially at least).Each commit here is probably best viewed one-at-a-time since this adds up to a number of changes but I've tried to keep things separated and have tests passing for each individual commit.
Fixes #9568