]> Cypherpunks repositories - gostls13.git/commit
runtime: (re)use unused linear memory on Wasm
authorCherry Mui <cherryyz@google.com>
Mon, 21 Oct 2024 17:01:56 +0000 (13:01 -0400)
committerCherry Mui <cherryyz@google.com>
Mon, 21 Oct 2024 21:52:53 +0000 (21:52 +0000)
commit4510586f930b49a142f991c51d960a3afc18e667
tree310e438a37f35f6517bbe2717c1b76096a56d254
parent6a49f81edc7aa8aa12e26a1a0ed8819a3e5c7b5e
runtime: (re)use unused linear memory on Wasm

CL 476717 adopted the memory management mechanism on Plan 9 to
manage Wasm's linear memory. But the Plan 9 code uses global
variable bloc and blocMax to keep track of the runtime's and the
OS's sense of break, whereas the Wasm sbrk function doesn't use
those global variables, and directly goes to grow the linear
memory instead. This causes that if there is any unused portion at
the end of the linear memory, the runtime doesn't use it. This CL
fixes it, adopts the same mechanism as the Plan 9 code.

In particular, the runtime is not aware of any unused initial
memory at startup. Therefore, (most of) the extra initial memory
set by the linker are not actually used. This CL fixes this as
well.

For #69018.

Change-Id: I2ea6a138310627eda5f19a1c76b1e1327362e5f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/621635
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/runtime/mem_sbrk.go
src/runtime/mem_wasm.go
src/runtime/os_wasm.go
src/runtime/sys_wasm.s