Heap

Kotlin Web Assembly direct buffer access with UTF-16 string

Submitted by Dickens A S on Fri, 05/01/2020 - 06:07

Kotlin WebAssembly runtime provides a global JavaScript array called heap

which can be accessed if the pointer of a variable is known

The pointer and size of the variable can be determined by library methods stringPointer and stringLengthBytes

The from JavaScript the value can be updated with below logic

Kotlin Main Code