pub enum TableInitialization {
Segments {
segments: Vec<TableInitializer>,
},
FuncTable {
tables: PrimaryMap<TableIndex, Vec<FuncIndex>>,
segments: Vec<TableInitializer>,
},
}
Expand description
Table initialization data for all tables in the module.
Variants§
Segments
“Segment” mode: table initializer segments, possibly with dynamic bases, possibly applying to an imported memory.
Every kind of table initialization is supported by the Segments mode.
Fields
segments: Vec<TableInitializer>
The segment initializers. All apply to the table for which this TableInitialization is specified.
FuncTable
“FuncTable” mode: a single array per table, with a function index or null per slot. This is only possible to provide for a given table when it is defined by the module itself, and can only include data from initializer segments that have statically-knowable bases (i.e., not dependent on global values).
Any segments that are not compatible with this mode are held
in the segments
array of “leftover segments”, which are
still processed eagerly.
This mode facilitates lazy initialization of the tables. It is thus “nice to have”, but not necessary for correctness.
Fields
tables: PrimaryMap<TableIndex, Vec<FuncIndex>>
For each table, an array of function indices (or
FuncIndex::reserved_value(), meaning no initialized value,
hence null by default). Array elements correspond
one-to-one to table elements; i.e., elements[i]
is the
initial value for table[i]
.
segments: Vec<TableInitializer>
Leftover segments that need to be processed eagerly on instantiation. These either apply to an imported table (so we can’t pre-build a full image of the table from this overlay) or have dynamically (at instantiation time) determined bases.