-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat(ops): fast calls for Wasm #16776
Conversation
let ptr = backing_store.data().unwrap().as_ptr() as *mut u8; | ||
let len = backing_store.byte_length(); | ||
// SAFETY: `ptr` is a valid pointer to `len` bytes. | ||
unsafe { std::slice::from_raw_parts_mut(ptr, len) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that ptr is a null pointer? eg. Wasm module created with 0 length memory buffer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@littledivy what's the answer here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick test shows that it is not nullptr for an empty memory buffer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it can be...idk...this is just an example
This PR introduces Wasm ops. These calls are optimized for entry from Wasm land. The `#[op(wasm)]` attribute is opt-in. Last parameter `Option<&mut [u8]>` is the memory slice of the Wasm module *when entered from a Fast API call*. Otherwise, the user is expected to implement logic to obtain the memory if `None` ```rust #[op(wasm)] pub fn op_args_get( offset: i32, buffer_offset: i32, memory: Option<&mut [u8]>, ) { // ... } ```
This PR introduces Wasm ops. These calls are optimized for entry from Wasm land.
The
#[op(wasm)]
attribute is opt-in.Last parameter
Option<&mut [u8]>
is the memory slice of the Wasm module when entered from a Fast API call. Otherwise, the user is expected to implement logic to obtain the memory ifNone