Memory
Transferring data between JavaScript and WebAssembly is an expensive operation. In order to reduce the transfer of data between JavaScript and WebAssembly modules, WebAssembly uses sharedArrayBuffer
. With sharedArrayBuffer
both the JavaScript and WebAssembly modules can access the same memory and use it to share the data from one to the other.
The memory section of a WebAssembly module is a vector of linear memories. The linear memory model is a memory addressing technique in which the memory is organized in a single contiguous address space. It is also known as a flat memory model. The linear memory model makes it easier to understand, program, and represent the memory. But the linear memory model comes with a huge disadvantage of high execution time for rearranging elements in the memory and the wastage of memory space. Here, the memory represents a vector of raw bytes of uninterpreted data. They use resizable array buffers to hold the raw bytes of memory. We use sharedArrayBuffers...