Skip to content

Shared memory support#9507

Merged
alexcrichton merged 8 commits into
bytecodealliance:mainfrom
atilag:shared-memory-support
Nov 1, 2024
Merged

Shared memory support#9507
alexcrichton merged 8 commits into
bytecodealliance:mainfrom
atilag:shared-memory-support

Conversation

@atilag
Copy link
Copy Markdown
Contributor

@atilag atilag commented Oct 24, 2024

I was trying to add Shared Memory support in the wasmtime-py library, but I found out that C-API support here was not finished, so this is my bold attempt to implement something that works.

As far as a I read, threads on WASI are still in discussion and Shared Memory is part of the proposal. In the other hand there's some basic support for Shared memory already present in the Rust API interface, so I guess it's fine to try gluing the C-API with what is supported today, and make wasmtime-py works with Shared Memory (?).

@atilag atilag requested review from a team as code owners October 24, 2024 01:49
@atilag atilag requested review from alexcrichton and removed request for a team October 24, 2024 01:49
@atilag atilag marked this pull request as draft October 24, 2024 01:49
Comment thread crates/fuzzing/src/oracles/dummy.rs Outdated
@github-actions github-actions Bot added fuzzing Issues related to our fuzzing infrastructure wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:c-api Issues pertaining to the C API. labels Oct 24, 2024
@github-actions
Copy link
Copy Markdown

Subscribe to Label Action

cc @fitzgen

Details This 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:

  • fitzgen: fuzzing

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

Learn more.

Comment thread crates/c-api/src/extern.rs Outdated
Comment thread crates/c-api/src/types/extern.rs Outdated
Comment thread crates/c-api/src/types/memory.rs Outdated
MemoryType::new64(minimum, maximum)
} else {
MemoryType::new(
Box::new(if shared {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mind panicking here for now with unimplemented!() if both shared and memory64 are set? (we need to add a constructor for that but haven't gotten around to it yet)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually I take this back, this may want to use MemoryTypeBuilder to support shared 64-bit memories

@atilag
Copy link
Copy Markdown
Contributor Author

atilag commented Oct 25, 2024

Suggestions applied!
Wanted to link this issue with this other one from wasmtime-py, as this is a required dependency. We will need to rebuild the _bindings.py after this is merged.

@alexcrichton
Copy link
Copy Markdown
Member

Thanks! I think we'll still want to remove the SharedMemory arm of ExternType which will help simplify this a bit more though.

@atilag
Copy link
Copy Markdown
Contributor Author

atilag commented Oct 25, 2024

Done!

Copy link
Copy Markdown
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Looking good! With MemoryTypeBuilder for the implementation I think this will be good to go 👍

Comment thread crates/fuzzing/src/oracles/dummy.rs Outdated
Comment on lines +80 to +83
/// Construct a dummy shared memory for the given memory type.
pub fn dummy_shared_memory(engine: &Engine, ty: MemoryType) -> Result<SharedMemory> {
SharedMemory::new(engine, ty)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this still needed? (or should it perhaps be integrated elsewhere?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nah, I just removed it

* moving dummy shared memory
@atilag
Copy link
Copy Markdown
Contributor Author

atilag commented Oct 30, 2024

Oh, nice, the MemoryTypeBuilder made the code way more readable :)
Done!

Copy link
Copy Markdown
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

There's a minor issue with clang-format in CI, but otherwise I think this is good to go 👍

@atilag
Copy link
Copy Markdown
Contributor Author

atilag commented Oct 31, 2024

Oh, no problem. I can run clang-format and see a green CI :)

@alexcrichton
Copy link
Copy Markdown
Member

I think there might be something else with clang-format in CI?

If you'd like also feel free to mark this as "ready for review" so it can be approved+merged once CI passes.

@atilag atilag marked this pull request as ready for review October 31, 2024 23:02
@atilag
Copy link
Copy Markdown
Contributor Author

atilag commented Oct 31, 2024

Yeah, might be the version of clang format usedd in the CI (15?) has different default options than the one I use locally.
Anyway, ready!
Thanks for taking a look Alex!

@alexcrichton
Copy link
Copy Markdown
Member

I dunno what's going on with clang-format myself, I've attempted to resolve the latest issue with a new commit

@alexcrichton alexcrichton added this pull request to the merge queue Nov 1, 2024
Merged via the queue into bytecodealliance:main with commit 288c151 Nov 1, 2024
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 wasmtime:c-api Issues pertaining to the C API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants