Splitting into multiple lazily-loaded modules
### Motivation See motivation here: https://github.com/rustwasm/team/issues/52 ### Proposed Solution I have implemented a (limited/hacky) prototype, based on the following components: - A `#[wasm_split(xyz)]` function attribute macro that serves to annotate a function as a *split point*. `xyz` is an identifier for the module that this function should be "split off" into. The same identifier can be used multiple times, in which case multiple functions will be "split off" into the same module. In my prototype the function must be non-async, and this macro turns it into an async function, but it wouldn't be hard to support both sync and async split points. For example, the macro converts: ```rust #[wasm_split(zstd)] fn get_zstd_decoder( encoded_reader: Pin<Box<dyn futures::io::AsyncBufRead>>, ) -> Pin<Box<dyn futures::io::AsyncRead>> { Box::pin(async_compression::futures::bufread::ZstdDecoder::new( encoded_reader, )) } ``` into ```rust async fn get_zstd_decoder( __wasm_split_arg_0: Pin<Box<dyn futures::io::AsyncBufRead>>, ) -> Pin<Box<dyn futures::io::AsyncRead>> { thread_local! { static ::wasm_split::LazySplitLoader> = unsafe { ::wasm_split::LazySplitLoader::new(__wasm_split_load_zstd) }; } #[link(wasm_import_module = "./__wasm_split.js")] extern "C" { #[no_mangle] fn __wasm_split_load_zstd( callback: unsafe extern "C" fn(*const ::std::ffi::c_void, bool), data: *const ::std::ffi::
Posted by jbms on Apr 27, 2024, 8:08 PM
Tags
Related issues
- This is the biggest problem with contracts, there's simply no way to actually say "please always execute this check".
- I don't disagree with you on this, I worked my whole life in corporate and haven't worked as a OSS maintainer before, though I will _and ...
- the new VSCode UI, looks cute, i don't like it.
- I've been working on my own private harness for the past 8 months, and I've been collecting ideas from such repos I've stumbled upon.
- The way AI is able to interact with outside resources is pretty impressive, but the quality of code it produces to me is still questionab...
- Add PR-style review comments in Git Diff UI that feed into the active agent thread
Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments
ux (Software)
This is the biggest problem with contracts, there's simply no way to actually say "please always execute this check".
I don't disagree with you on this, I worked my whole life in corporate and haven't worked as a OSS maintainer before, though I will _and ...
the new VSCode UI, looks cute, i don't like it.
I've been working on my own private harness for the past 8 months, and I've been collecting ideas from such repos I've stumbled upon.
The way AI is able to interact with outside resources is pretty impressive, but the quality of code it produces to me is still questionab...
Add PR-style review comments in Git Diff UI that feed into the active agent thread
Thanks for indulging me so far, by the way, I really appreciate this discussion, it's very stimulating.
Migrate GDScript to the GDExtension mechanism and overhaul the implementation
Splitting into multiple lazily-loaded modules
### Motivation See motivation here: https://github.com/rustwasm/team/issues/52 ### Proposed Solution I have implemented a (limited/hacky) prototype, based on the following components: - A `#[wasm_split(xyz)]` function attribute macro that serves to annotate a function as a *split point*. `xyz` is an identifier for the module that this function should be "split off" into. The same identifier can be used multiple times, in which case multiple functions will be "split off" into the same module. In my prototype the function must be non-async, and this macro turns it into an async function, but it wouldn't be hard to support both sync and async split points. For example, the macro converts: ```rust #[wasm_split(zstd)] fn get_zstd_decoder( encoded_reader: Pin<Box<dyn futures::io::AsyncBufRead>>, ) -> Pin<Box<dyn futures::io::AsyncRead>> { Box::pin(async_compression::futures::bufread::ZstdDecoder::new( encoded_reader, )) } ``` into ```rust async fn get_zstd_decoder( __wasm_split_arg_0: Pin<Box<dyn futures::io::AsyncBufRead>>, ) -> Pin<Box<dyn futures::io::AsyncRead>> { thread_local! { static ::wasm_split::LazySplitLoader> = unsafe { ::wasm_split::LazySplitLoader::new(__wasm_split_load_zstd) }; } #[link(wasm_import_module = "./__wasm_split.js")] extern "C" { #[no_mangle] fn __wasm_split_load_zstd( callback: unsafe extern "C" fn(*const ::std::ffi::c_void, bool), data: *const ::std::ffi::
Comments (0)
No comments yet. Start the discussion.