]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: add heapObjectsCanMove
authorRuss Cox <rsc@golang.org>
Thu, 25 May 2023 04:21:13 +0000 (00:21 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 25 May 2023 13:00:06 +0000 (13:00 +0000)
commit055c186f53493da473c888869ad468861ba25f1a
tree6b3e6e18058a18b2dc5a2018bd7adfacaba89c15
parent6f7824f7a4d62998b03f3ddc5c12938a9a247e85
runtime: add heapObjectsCanMove

heapObjectsCanMove is always false in the current garbage collector.
It exists for go4.org/unsafe/assume-no-moving-gc, which is an
unfortunate idea that had an even more unfortunate implementation.
Every time a new Go release happened, the package stopped building,
and the authors had to add a new file with a new //go:build line, and
then the entire ecosystem of packages with that as a dependency had to
explicitly update to the new version. Many packages depend on
assume-no-moving-gc transitively, through paths like
inet.af/netaddr -> go4.org/intern -> assume-no-moving-gc.
This was causing a significant amount of friction around each new
release, so we added this bool for the package to //go:linkname
instead. The bool is still unfortunate, but it's not as bad as
breaking the ecosystem on every new release.

If the Go garbage collector ever does move heap objects, we can set
this to true to break all the programs using assume-no-moving-gc.

Change-Id: I06c32bf6ccc4601c8eef741d7382b678aada3508
Reviewed-on: https://go-review.googlesource.com/c/go/+/498121
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/mgc.go