Change WASM direct heap access to use helper functions (#61355)
authorKatelyn Gadd <kg@luminance.org>
Wed, 10 Nov 2021 08:47:26 +0000 (00:47 -0800)
committerGitHub <noreply@github.com>
Wed, 10 Nov 2021 08:47:26 +0000 (00:47 -0800)
commit3dce93bafed000321a4448b9212268f98d6e991f
treef97797b294472594489ad94ba3a4c5f0b96877e6
parente5eafc9bf8be55087dcc2907e9c4d6fa1c2e5773
Change WASM direct heap access to use helper functions (#61355)

Direct heap writes via Module.HEAPxx[y] = func(...) are incorrect because the left-hand side (according to spec) is evaluated before the right, so if evaluating func(...) causes the heap to grow, the assignment target becomes a detached buffer and the write goes nowhere, breaking your application. This PR introduces a new set of helper functions for memory reads and writes.
src/mono/wasm/runtime/cs-to-js.ts
src/mono/wasm/runtime/exports.ts
src/mono/wasm/runtime/js-to-cs.ts
src/mono/wasm/runtime/memory.ts
src/mono/wasm/runtime/method-binding.ts
src/mono/wasm/runtime/roots.ts
src/mono/wasm/runtime/strings.ts