WebAssembly store and object caches

Before digging into interactions, let's discuss the relationship between JavaScript and WebAssembly in the context of execution. The Core Specification contains the following description in the Execution section:

"WebAssembly code is executed when instantiating a module or invoking an exported function on the resulting module instance.

Execution behavior is defined in terms of an abstract machine that models the program state. It includes a stack, which records operand values and control constructs, and an abstract store containing global state."

Under the hood, JavaScript uses something called agents to manage execution. The store being referred to in the definition is contained within an agent. The following diagram represents a JavaScript agent:

JavaScript agent elements

The store represents the state of the abstract machine. WebAssembly operations take a store and return an updated store. Each agent is associated with caches that map JavaScript objects to WebAssembly addresses. So why is this important? It represents the underlying method of interaction between WebAssembly modules and JavaScript. The JavaScript objects correspond to the WebAssembly namespace within the JavaScript API. With that in mind, let's dig into the interface.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset