[][src]Struct wasm_bindgen_threads_xform::Config

pub struct Config { /* fields omitted */ }

Configuration for the transformation pass in this module.

Created primarily through new and then executed through run.

Methods

impl Config[src]

pub fn new() -> Config[src]

Create a new configuration with default settings.

pub fn maximum_memory(&mut self, max: u32) -> &mut Config[src]

Specify the maximum amount of memory the wasm module can ever have.

We'll be specifying that the memory for this wasm module is shared, and all shared memories must have their maximum limit specified (whereas by default Rust/LLVM/LLD don't specify a maximum).

The default for this option is 16MB, and this can be used to change the maximum memory we'll be specifying.

The max argument is in units of bytes.

If the maximum memory is already specified this setting won't have any affect.

pub fn thread_stack_size(&mut self, size: u32) -> &mut Config[src]

Specify the stack size for all threads spawned.

The stack size is typically set by rustc as an argument to LLD and defaults to 1MB for the main thread. All threads spawned by the main thread, however, need to allocate their own stack!

This configuration option indicates how large the stack of each child thread will be. This will be allocated as part of the start function and will be stored in LLVM's global stack pointer.

pub fn run(&self, module: &mut Module) -> Result<(), Error>[src]

Execute the transformation on the parsed wasm module specified.

This function will prepare Module to be run on multiple threads, performing steps such as:

  • All data segments are switched to "passive" data segments to ensure they're only initialized once (coming later)
  • If memory is exported from this module, it is instead switched to being imported (with the same parameters).
  • The imported memory is required to be shared, ensuring it's backed by a SharedArrayBuffer on the web.
  • A global for a thread ID is injected.
  • Four bytes in linear memory are reserved for the counter of thread IDs.
  • A start function is injected (or prepended if one already exists) which initializes memory for the first thread and otherwise allocates thread ids for all threads.

More and/or less may happen here over time, stay tuned!

Auto Trait Implementations

impl Send for Config

impl Unpin for Config

impl Sync for Config

impl UnwindSafe for Config

impl RefUnwindSafe for Config

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]