A WebAssembly store is the abstract runtime state containing allocated entities such as function, memory, table and global instances. A WebAssembly module instance refers to these entities through WebAssembly abstract addresses. A store memory address selects a memory instance; it is distinct from a byte offset within WebAssembly linear memory.[ref]
For an original toy model, let the store contain two memory instances at abstract addresses 0 and 1. Module instances A and B both use local memory index 0, but A maps it to address 0 and B maps it to address 1. A third instance C imports the first memory and maps its own local index 0 to address 0.
Initially, let byte offset 0 in both memories contain zero. Writing 17 through A changes the first memory. Reading offset 0 through B gives zero, while reading it through C gives 17. There are three distinct coordinates: the module-local index, the store address selecting a memory and the offset selecting a byte inside it. Equal local index numbers do not establish sharing.
These invented addresses illustrate the semantics; they are not exposed machine addresses measured from an engine. The WebAssembly store also is not one linear memory or a persistent file store. The abstract model records allocations, while implementations may reclaim unreachable entities when doing so is not semantically observable.[ref]
A WebAssembly abstract address identifies an allocated runtime entity in the appropriate component of the WebAssembly store. Its kind distinguishes a function, memory, table or other entity. It differs from a module-local index and from an offset into WebAssembly linear memory.[ref]
For an original lookup example, let the store's memory at address 0 contain bytes 10,11,12, and its memory at address 1 contain 20,21,22. A WebAssembly module instance maps local memory indices 0,1 to store addresses 1,0. Accessing its local memory index 0 at byte offset 2 therefore gives 22; local memory index 1 at the same offset gives 12.
The numerical labels need their context. A memory address 1 and a function address 1 select different store components. Byte offset 1 instead selects a location within an already selected memory. Thus writing down the integer 1 alone does not specify which of these references is intended.
The example uses invented store indices, not host-machine pointers observed from an engine. The specification uses abstract addresses to describe how runtime references resolve. WebAssembly module declarations supply local indices, instantiation establishes their runtime mappings, and memory instructions apply offsets within the selected object.[ref]

Articles by others on the same topic (0)

There are currently no matching articles.