pub struct Splitter<'a> { /* private fields */ }
Expand description
A parsed wasm module with additional metadata and functionality for splitting and patching.
This struct assumes that relocations will be present in incoming wasm binary. Upon construction, all the required metadata will be constructed.
Implementations§
Source§impl<'a> Splitter<'a>
impl<'a> Splitter<'a>
Sourcepub fn new(original: &'a [u8], bindgened: &'a [u8]) -> Result<Self>
pub fn new(original: &'a [u8], bindgened: &'a [u8]) -> Result<Self>
Create a new “splitter” instance using the original wasm and the wasm from the output of wasm-bindgen.
This will use the relocation data from the original module to create a call graph that we then use with the post-bindgened module to create the split modules.
It’s important to compile the wasm with –emit-relocs such that the relocations are available to construct the callgraph.
Sourcepub fn emit(self) -> Result<OutputModules>
pub fn emit(self) -> Result<OutputModules>
Split the module into multiple modules at the boundaries of split points.
Note that the binaries might still be “large” at the end of this process. In practice, you need to push these binaries through wasm-bindgen and wasm-opt to take advantage of the optimizations and splitting. We perform a few steps like zero-ing out the data segments that will only be removed by the memory-packing step of wasm-opt.
This returns the list of chunks, an import map, and some javascript to link everything together.
Auto Trait Implementations§
impl<'a> Freeze for Splitter<'a>
impl<'a> !RefUnwindSafe for Splitter<'a>
impl<'a> Send for Splitter<'a>
impl<'a> Sync for Splitter<'a>
impl<'a> Unpin for Splitter<'a>
impl<'a> !UnwindSafe for Splitter<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more