go/src/cmd/internal
Michael Pratt 78e6f2a1c8 runtime: rename mapiterinit and mapiternext
mapiterinit allows external linkname. These users must allocate their
own iter struct for initialization by mapiterinit. Since the type is
unexported, they also must define the struct themselves. As a result,
they of course define the struct matching the old hiter definition (in
map_noswiss.go).

The old definition is smaller on 32-bit platforms. On those platforms,
mapiternext will clobber memory outside of the caller's allocation.

On all platforms, the pointer layout between the old hiter and new
maps.Iter does not match. Thus the GC may miss pointers and free
reachable objects early, or it may see non-pointers that look like heap
pointers and throw due to invalid references to free objects.

To avoid these issues, we must keep mapiterinit and mapiternext with the
old hiter definition. The most straightforward way to do this is to use
mapiterinit and mapiternext as a compatibility layer between the old and
new iter types.

The first step to that is to move normal map use off of these functions,
which is what this CL does.

Introduce new mapIterStart and mapIterNext functions that replace the
former functions everywhere in the toolchain. These have the same
behavior as the old functions.

This CL temporarily makes the old functions throw to ensure we don't
have hidden dependencies on them. We cannot remove them entirely because
GOEXPERIMENT=noswissmap still uses the old names, and internal/goobj
requires all builtins to exist regardless of GOEXPERIMENT. The next CL
will introduce the compatibility layer.

I want to avoid using linkname between runtime and reflect, as that
would also allow external linknames. So mapIterStart and mapIterNext are
duplicated in reflect, which can be done trivially, as it imports
internal/runtime/maps.

For #71408.

Change-Id: I6a6a636c6d4bd1392618c67ca648d3f061afe669
Reviewed-on: https://go-review.googlesource.com/c/go/+/643898
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-01-28 10:54:43 -08:00
..
archive
bio all: use "unix" build tag where appropriate 2024-03-19 11:20:31 +00:00
bootstrap_test cmd: remove support for GOROOT_FINAL 2024-02-21 22:16:54 +00:00
browser
buildid cmd/internal/buildid: skip over GNU build ID from buildid computation 2024-10-21 17:56:51 +00:00
codesign cmd: do not use notsha256 2024-09-04 18:23:49 +00:00
cov cmd/internal/cov: close counter data files eagerly 2024-07-16 20:20:05 +00:00
disasm cmd/internal/disasm: correct instruction length handling for riscv64 2025-01-06 23:43:06 -08:00
dwarf all: remove unnecessary symbols and add missing symbols 2024-09-09 16:44:45 +00:00
edit
gcprog
goobj runtime: rename mapiterinit and mapiternext 2025-01-28 10:54:43 -08:00
hash cmd/internal/hash: stop using md5, sha1 2025-01-07 10:59:33 -08:00
macho cmd/internal/macho: new package for handling mach-o files in toolchain 2024-10-21 17:56:21 +00:00
metadata
moddeps cmd: remove support for GOROOT_FINAL 2024-02-21 22:16:54 +00:00
obj cmd/internal/obj/wasm, runtime: detect wasmexport call before runtime initialization 2025-01-16 12:14:23 -08:00
objabi cmd/internal/objabi, internal/runtime: increase nosplit limit on OpenBSD 2024-12-06 00:35:41 +00:00
objfile cmd/internal/objfile: break out dissassemblers to another package 2024-12-11 08:53:20 -08:00
osinfo cmd/internal/osinfo: stop importing golang.org/x/sys/unix 2024-10-30 18:19:19 +00:00
par cmd: relocate cmd/go/internal/par to cmd/internal/par 2024-07-29 15:37:29 +00:00
pathcache cmd: extract cmd/go's cfg.LookPath into separate pathcache package 2024-07-29 15:38:33 +00:00
pgo cmd/compile,cmd/preprofile: move logic to shared common package 2024-03-27 20:20:01 +00:00
pkgpath
pkgpattern
quoted
robustio cmd: relocate cmd/go/internal/robustio to cmd/internal/robustio 2024-07-29 15:38:00 +00:00
script all: fix some function names and typos in comment 2024-11-21 22:16:20 +00:00
src all: remove unnecessary symbols and add missing symbols 2024-09-09 16:44:45 +00:00
sys cmd/compile/internal/ssagen: improve intrinsic architecture handling 2024-08-20 13:39:19 +00:00
telemetry cmd/internal: separate counter package from telemetry package 2024-06-21 19:58:04 +00:00
test2json cmd/go: print build errors during go test -json in JSON 2024-11-17 14:32:05 +00:00
testdir cmd/internal/testdir: print stderr if go list fails while gathering stdlib import config 2024-11-20 13:07:35 +00:00