Search code examples
javascriptwebassemblyemscripten

Where is the documentation for WebAssembly Heapf64.set


I have a bit of code I'm trying to optimise and it uses HEAPF64.set(jsArray, nativeArray)

Where is the documentation for this function call?

Is it a copy function from jsArray to nativeArray or setting a pointer?

What is HEAPF64? If I already have a native buffer in WebAssembly can I set directly into it?


Solution

  • HEAPF64 is one of several ArrayBufferView s that are created by the emscripten toolchain. Others include HEAPU8 and HEAPU32. They are all views of the same underlying WebAssembly memory buffer which is your C/C++ program's address space.

    There is some documentation on how emscripten sets things up here: https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#access-memory-from-javascript

    Specifically the .set method you are asking about is documented here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set