Go 1.18
Generics land: types2 plus GC-shape stenciling on the old typechecker. The register ABI spreads to arm64 and ppc64. The pacer is redesigned to count stacks and globals. GOAMD64 levels appear. Defers become argless closures. pclntab starts losing relocations.
Each area lists the stage every thread reached in this release (with what was left open afterwards), then changes that are not part of a thread. Thread names link to the full thread on its topic page.
Memory management
From Runtime: memory allocator and garbage collector (Go 1.18–1.28)
- GC pacer redesign — Done: user-visible Pacer state was untangled from global state so it could be unit-tested: atomic
gcPercent(6508fdad9d), scavenger pacing (f99e40aac0), sweeper pacing (413672fc84),startCycle/endCycle/heapLivemethods (4a5d78ff8b,8e112a7c2a,5ec2427357), atomic types (75b73d68b3,2f71c86370,09e8de70c2), and a simulation test framework driven by the real pacer (994049a9ad,b5a5b7bfb1). The redesign landed behindGOEXPERIMENT=pacerredesign. Its message says “on by default”, but the commit does not touchinternal/buildcfg(a108b280bc); a separate commit turned it on (961aab26bf). The minimum heap was cut to 512 KiB on the basis of ~200 KiB of runtime globals. That was pulled back into its own off-by-defaultheapminimum512kibexperiment after ~1% build slowdowns and “up to 8x” more GCs for <4 MiB heaps (c5c1955077). Fixes: hard-goal computation (156abe5122); the PI controller made robust to overflow/NaN (e4a173adf6); exact float arithmetic for GOGC=25 (8f374aa27f). Left open: the hard-goal case “is impossible [to test] in the idealized model … leave a TODO” (156abe5122). The heap-minimum question was deferred to “next cycle” (c5c1955077). biogo-igor regressed because the write barrier stays on longer (a108b280bc). - Scavenger redesign — Done: PI controller (
e48e4b4cbb), atomicscavengeGoal(fc5e8cd6c9), lock-free scavenging (4f543b59c5,6d1fffac63), the 1% total-CPU target (6f32d2050d), a released-bytes accumulation fix (f986191325), and a conservative fallback when the controller overflows (e4a173adf6). Left open: the scavenger “is not really in a testable state” (e4a173adf6). - Allocation publication, zeroing and preemptibility — Done: zeroing unified in
mallocgc. Small-object spans from mheap are never zeroed eagerly, and the flag becamedelayZeroing, used only for pointer-free large objects (d8fc7f785e). Left open: nothing noted. - Sweeper termination and pacing — Done: atomic sweep termination (
3aecb3a8f7);GCSweepStarttrace event fix (903f313d8b). Left open: nothing noted. - Stack and register root scanning — Done:
markrootreadallgsconcurrently withallgaddand could see nil on weak memory;gcMarkRootPreparenow snapshots the slice header during STW (08ecdf7c2e). Alsoclobberdeadpointer crash support on ARM64 (55b4310acd). Left open: nothing noted. - Address-space layout, tagged pointers and the mem.go layer — Done: ios/arm64 moved to 40 address bits with the 64-bit incremental page allocator (
c27a3592ae); mmap failure printed (bb7fb8a5fa). Left open: the exception for iOS <14 stays “Once iOS <14 is deprecated” (c27a3592ae).
Other changes
- mheap sweep/reclaim counters to typed atomics internal —
pagesInUse,pagesSwept,pagesSweptBasis,reclaimIndex,reclaimCreditconverted withrfscripts (d419a80bc7,e90492882a,1dff8f0a05,a91e976fd2,016d5eea11). - fixalloc hardening internal — object size bounded to [sizeof(mlink),
_FixAllocChunk] (90ed541149); chunk tail waste eliminated (4591f49938).getMCachetakes anmp(84ba117fd7). - reflect.Value.Elem on notinheap pointers user-visible — panics instead of creating a GC-visible bad pointer (
8331f25e96). - faketime vs GC internal — the scavenger runs one loop under faketime, and the write path has no write barriers (
0440fb8334).gcParkAssistdroppednowritebarrier(aeb4fbabc0). - GC background goroutines use real closures internal — once the compiler allowed escaping closures in the runtime (dev.typeparams defer/go wrapping), the argumentless-closure workaround for
go’d GC, sweep and scavenge goroutines was undone (3298c749ac).
Scheduler and concurrency
From Runtime: scheduler, timers, channels, locks and synchronization (Go 1.18–1.28)
- Timer rewrite: per-P timer heap, timer.lock, and GC-able synchronous timer channels — Done: fixes in the old CAS-state machine:
adjustTimersbacks up as far as needed (2da3375e9b). Left open: nothing noted. - Scheduler core: spinning Ms, work conservation, stealing, STW interaction — Done: redundant loop removed in
runqget(3920d6f208); tracking time for scheduler latency only when needed (29ec902efc);sysmonNetBSD workaround skipped on >=9.2 (6406227d71). Left open: nothing noted. - Asynchronous preemption: extended register state — Done: restartable-sequence pcdata accepted in
isAsyncSafePoint(8ff16c1990);maymorestackalways-preempt and stack-moving hooks for testing (35c7234601,bd580a0d10). Left open: nothing noted. - sync package API evolution — Done: user-visible
Mutex.TryLock,RWMutex.TryLock/TryRLock(645d07819b), TryLock fix to acquire even when state != 0 (fdd67930a0); WaitGroup avoids a dynamic alignment check on 64-bit (ad7db1f90f);Map.Rangere-entrancy doc (d5a5a13ad9). Left open: nothing noted. - Runtime lock ranking — Done: rank ordering fixes (
62c6ff4296). Left open: manual order. - Netpoller — Done: atomic accessors for pollDesc (
1b072b3ed5); net poll race fixes (17b2fb1b65). Left open: stale events. - Fast random numbers for the scheduler — Done:
fastrandswitched to wyrand (483533df9e);fastrandninstead of modulo (ecb2f231fa). Left open: nothing noted.
Other changes
- Closed-channel receive and time.now internal —
time.nowbecomes ABIInternal, dropping a wrapper (71adc658de);pollNoErrorconstant innetpollblock(69107e73ce); redirectable builtinwrite(901bf291bc). - Defer/newproc plumbing for regabi internal —
newprocmay split the stack (4468e1cfb9), defer-record simplification (e0e9fb8aff),d.linkfreeing subtlety (e590cb64f9);deferproc(func())attempt reverted (83da32749c,a4121d7dd6). - pprof labels / sigprof internal — missing pprof labels fix and revert (
9b0de0854d,c6a0b6f2de); sigprof flag normalisation reverted (2bc8ed8e9c,822dbcb7d4);sigprofNonGomoved (5b90958084); drop SIGPROF in ARM<7 helpers (20a620fd9f). - Clocks/faketime internal — Windows nanotime read (
cfd016df1f), nsec remainder constant (0e5f287fde), faketime GC robustness (0440fb8334). - Misc 1.18 extras internal — funcPC misuse (
6a81e063dd), pprof label fixes (da7173a2ed,3e45eb3ce1), funcinl sentinel (6c163e5ac9). - Misc internal — scannable stack tracking for the pacer (
9ac1ee2d46);mp.fastrandinit restored (5442f4d51b);doAllThreadsSyscallmoved (7a132d6f4e); fork hooks without systemstack (2eb4d68833); cpu feature fix (03df68d3c3); atomic.Value first-store marker is a real pointer (3a0cd11214,2278a51fa01.19 in 1.19).
Data structures and type metadata
From Runtime: maps, built-in data structures, hashing, randomness and type metadata (Go 1.18–1.28)
- Compiler-generated equality/hash functions and type descriptor emission (reflectdata) — Done: generics support in type metadata: always generate
(*T).Mwrappers for instantiated methods (4ed6317e73), crawl embeddable types so all methods are re-exported (132ea56d29, allowsmethodWrapperto always inline),Type.LinkStringfor map keys in typecheck/order (ed647b16d0), avoid redundant wrappers for anonymous types from imported packages in unified IR (7ab8754029, protobuf-heavy builds blew build-cache limits), shape types in their own package (b730a26729), no methods on shape types (48cf96c256), dictionaries reuse global node (8eeb1bff1d), type descriptors always dupok (79c5240799), prevent duplicate work inWriteRuntimeTypes(91e2e3b903),anydefinition emission when compiling runtime (3d7cb23e3d), unsatisfiable type assertions in instantiations (cf1ec17360). Left open: unified IR flagged as in-progress. - reflect implementation: performance, allocation and escape behaviour — Done: user-visible
MapIter.SetKey/SetValue→Value.SetIterKey/SetIterValue,MapIter.Reset,Value.UnsafePointer,Value.CanInt/CanUint/CanFloat/CanComplex,FieldByIndexErr,Pointer/PointerTokind renames (54cdef1f10,8dab959a8e,4d550727f8,04f7521b0a,33c392f72d,17910ed4ff); string-key map fast path (23832ba2e2, “over 80% of all Go map types use a string as the key”),DeepEqualfast paths (a0c409cbc8),hiterembedded inMapIter(1b2d794ca3,89c527007f), Elem/Pointer panic on bad notinheap pointers (8331f25e96,23e57e5955). Left open: nothing noted. - Register ABI completion for reflect, memmove/memclr and bytealg across architectures — Done: amd64 always on (
eeb7899137, bootstrapping hard-codes amd64), non-regabi fallback removed from amd64 runtime/bytealg (d7d4f28a06); arm64 reflect MakeFunc (0c123cdf8b), bytealg and runtime hot functions (5a40fab19f,5a008a92e8), ppc64x bytealg/memmove/memclr/reflect (b8a601756a,6c3cd5d2eb,daec057602,9c43872bd8,24c2ee7b65, adds duffcopy on ppc64x),internal/abiconstants for ARM64/PPC64 (c3639918d1,9cbdc1d48f),reflectbig-endian fix (f1d8ea1da3,fb84d213a8), softfloat functions rewritten to avoid floats (aa3d54da07). Left open: arm64/ppc64 still switchable. - Slice growth, string building and allocation-free bytes/strings helpers — Done: smoother growth (
2dda92ff6f),unsafe.Slicebounds check and up-to-end-of-address-space (4efa216c9d,40f82f8a09). Left open: nothing noted.
Other changes
- runtime/syscall asan hooks internal — calls to asan functions added (
6f327f7b88). - 386 SSE2 detection replaced by GO386 setting internal — (
8157960d7f). - reflect narrow-width float hooks and tests internal — (
ea434450c2). - reflect method-value and ABI correctness internal —
methodValueCallcode pointer mismatch fixes keepingValue.Pointerstable (f92a3589fa,d7149e502d,07e5527249), keep pointers live for aggregate args inCall(23adc139bf), ABIInternalmoveMakeFuncArgPtrson ARM64 (20b177268f), reflect usinginternal/abi.FuncPCABI0(f642742678), ABI0 spill functions on AMD64 (6633dc8b09),Pointer/UnsafeAddr/Ptr/PtrToun-deprecated (2ff1074f5a,056dfe6ff3). - Generics type-metadata plumbing in dev.typeparams internal — about 12 commits fixing dictionaries, wrappers for imported generics and embedded fields, shapes, and
comparable(ef6c5be160,ee4fc0c1bc,3f1a517a45,e6a2cf233f,40e561d933,27283d208f,5344dcae41,52078fa477,55e7f7e12d,0ae0d5c62e).
Diagnostics and knobs
From Runtime: tracing, profiling, metrics and diagnostics (Go 1.18–1.28)
- The new execution tracer (trace v2): generations, per-M buffers, new parser — Done: v1 tracer maintenance: guard against negative/huge tick frequency on riscv64 (
a78532a412), ensure at least one tick between events (ee92daae25). Left open: nothing noted (redesign had not started in this log). - CPU profiling, goroutine profiling, pprof labels and the protobuf writer — Done: missing-label fixes (
da7173a2ed,9b0de0854d; one revertedc6a0b6f2de), profile dump includes labels (90f47dbba6), first CPU record tag consumed (a3ae45ebe1), goroutine-profile traceback bypasses the scheduler for cgo traceback to avoid deadlock at exitsyscall under STW (8c73f80400), histogram bucket off-by-one fix (2e9dcb5086). Left open: labels on racecall frames in tests. - Race detector, ASan, MSan and Valgrind integration — Done: ASan runtime support,
asanread/asanwrite,runtime/asanpackage (adfb85b315, NOSPLIT2c58bb2e42, C declarationsa0f373ca08, error location fix91e782106e); race functions ABIInternal (40fce515f9,d93cc8cb96), arm64 stack space (d27248c52f). Left open: globals not yet checked. - Crash output, runtime/debug, BuildInfo and debuglog — Done: user-visible
runtime/debug.BuildInfogainsGoVersion(85a068fdf2),debug/buildinfopackage (434cdd0337), VCS stamping (a37bebc042),Settingsaligned with flags/env (931d80ec17),Parse/StringreplaceMarshal(9cec77ac11). Left open: nothing noted.
Other changes
- GDB helper robustness internal — parametric type printing fixed (
6d02ce8584); repeated timeouts and skips for gdb internal bugs inTestGdbBacktrace(8692bacb6a,275aedccd4,0a9d6a31b1). - Stack-size feedback loop internal — GC measures average goroutine stack use and starts new goroutines with that size; Issue18138 −29% (
016d7552131.19, belongs to the stacks area but listed in this bucket).
OS layer, stacks and panics
From Runtime: OS and platform layer, stacks, panics and tracebacks (Go 1.18–1.28)
- Defer, panic and recover re-implementation — Done: argless-closure defers: variadic defer/go removed (
12b37b713f),sizremoved fromnewproc/deferproc(8e5304f729),tracebackdefersdeleted (00d01b5786), open-defer metadata simplified (b20747334a),func()used for deferred functions (ea94e5d3c5).jmpdeferreplaced by a loop (fd0011dca5,1a0630aef4; first attempt reverted bye3e9f0bb2dbecause its parent was backed out). Fixed stack-copy hazard where a heap_defer.linkpoints to a stack defer (e590cb64f9), and a new invariant for panics: never add an open-coded defer entry above one already started (8dfb447231, issue 48898). Left open: thefreedefercall-site subtlety (unlink then cleard.link) is explicitly noted as unresolved; “popDefer” idea not done. - Unwinder: gentraceback →
unwinderiterator, inline unwinder, pcvalue cache — Done: unwinding throughmorestackon LR machines uses the saved LR, plus an infinite-loop detector (74f00094221.19);gentracebackprints goid on throw (cc9d3f548a1.19, 1.19); ARM atomic kernel helper traceback starts in caller (3634594790);vdsoSPset consistently (217507eb03). Left open:74f00094221.19 notes a missing test (low reproduction frequency). - Symbol tables,
runtime.CallerandCallersFrames— Done: funcInfo/entry-offset and findfunc work listed above; bad pcHeader/ftab output improved (13aa0d8f57,cd4d59232e);no_pointers_stackmapeliminated (c2483a5c03). Left open: nothing noted. - Stack growth, stack bounds and the crash stack — Done:
maymorestackalways-preempt hook (35c7234601); stack-move race instackForceMovefixed (71559a6ffd); debug-call tests keep GC off (7ee3f1427b). Left open: nothing noted. - C-to-Go callbacks: extra-M reuse, system-stack bounds, init gating — Done:
asmcgocallg0/gsignal checks made consistent (fcdc3c098c), mips64 signal-stack behaviour fixed (160d797260),sigprofNonGomoved (5b90958084), cgo traceback on linux/arm64 (81767e23c21.19, listed 1.19),runtime/cgoGCC/clang warnings (426ff3746f). Left open: nothing noted. - Library entry points and runtime initialization — Done: sigPreempt handler for c-archive/c-shared (
a4b2c579e9). Left open: nothing noted. - Security hardening: AT_SECURE, std fds, AT_RANDOM, gated debug features — Done: Windows crash dumps added (
353d5b6c53) then retracted (6dcf83d882). Left open: needs proposal process (per revert message). - vDSO,
vgetrandomand fast clocks — Done: riscv64 vDSO clock (1bd35fab05), async fatal signals in VDSO handled (86f6bf18b0),vdsoSPconsistent (217507eb03), RDTSCP forcputicksordering (22540abf76). Left open: nothing noted. - Signals and async-preemption machinery — Done:
TOPFRAMEfor sigtramp, handler for stray profile signals (8cfcee1fff), sigPreempt in c-archive (a4b2c579e9),AllThreadsSyscallrewritten on signals (see syscall thread), SIGPROF per-thread timers (8cfd8c3db8,8d09f7c517),runtime: don't inspect the stack for delayed signals from TSAN(d29d0314c11.19, 1.19). Left open: nothing noted. - Syscall layer:
AllThreadsSyscall,internal/runtime/syscall, libc and WindowsSyscallN— Done: AllThreadsSyscall via signals (0a5fae2a0e,7a132d6f4e),runtime/internal/syscall(0b321c9a7c), SyscallN on Windows user-visible (0e598e7da4), android per-thread syscall (b5af5c0834). Left open: SyscallN only Windows (“existing API set already contain differences”). - Windows runtime port — Done: crash dump added/reverted (
353d5b6c53,2622235a99,6dcf83d882), nanotime barrier (cfd016df1f), non-cooperative preemption on windows/arm and arm64 (c58243aa8a,f7e34e705c), ConsoleControlHandler park fix (54b9cb8037),os.Interrupthandling added then reverted (345184496c1.19,f86f9a30381.19, listed 1.19). Left open: nothing noted. - New, ported and removed platforms — Done: ARM64 and PPC64 register-ABI runtime support (
2e4b79949f,0c123cdf8b,aa9cfdf775,6e5dd0b59b), riscv64 GP freed (5b213178e7), goos/goarch constants moved tointernal/goarch/internal/goos(122f5e16d6,6d85891b29). Left open: nothing noted. - CPU feature detection, GOAMD64 checks and cpu GODEBUG options — Done: GO386 replaces runtime SSE2 detection (
8157960d7f); amd64 level check (8c8baad927);RDTSCPordering (22540abf76). Left open: nothing noted.
Other changes
- ABI0/ABIInternal address hygiene (dev.typeparams) internal — ~12 commits replacing
funcPCwithinternal/abi.FuncPCABI0/ABIInternalfor syscall wrappers and sigtramp on OpenBSD, FreeBSD, DragonflyBSD, Solaris, Plan 9, Windows/ARM64 (140cd7c1d3,077f03f4d8,3f6f12972b,a5cd89b8c3,ed2001232a,fb42fb705d,0e0a1f94f3,7d928460a1,6a81e063dd,626e89c261), so the register ABI can be enabled without wrapper breakage;deferproc func()attempt reverted (83da32749c,a4121d7dd6), split-stack/defer cleanups (b80a4c56f0,53fd5b1b77,077925e2b0,88bd92bb6d,cb14e673ec). - Misc platform fixes internal — riscv64 GP save in
crosscall1(70493b3eb0) and sigaction mask offset (2c5d2083e4), cgo signal detection (091db6392d),cgo_unsafe_argsargs kept alive (f463b20789), darwin/arm64 syscall wrappers without cgo_unsafe_args (57e3809884), netbsd-arm64 setcontext crash (f300fc2d2c), ARM walltime fixes (577287728a,15a54d627c), AES maphash on 386 (be0d049a42), pclntab micro-optimisations (113b52979f,2a5d4ea97e,88ea8a5fe0). - Per-thread CPU-profile timers on Linux user-visible —
timer_createper M, plus setitimer for non-Go threads, random initial offset; fixes under-reporting above ~2.5 parallel goroutines (3d795ea798,8cfd8c3db8,8d09f7c517). - amd64 microarchitecture check internal — runtime throws if built with GOAMD64 > CPU capabilities (
8c8baad927, TLS ordering01b6cf09fc; darwin v46a40bdcbaf1.19 in 1.19); SSE2 detection replaced by GO386 (8157960d7f). runtime/internal/sysexplosion internal —goarch/goospackages (122f5e16d6,6d85891b29,46e1e74a86,671954e72e,33d1b82d16).- Atomic types internal —
runtime/internal/atomictyped API for all functions (3ec8d4b5ed); more in 1.19 (f1b5c048d71.19 Bool) and 1.20 (0581d69dc61.20 Pointer[T],9fedc481ea1.20 write-barrier pointer atomics). - Misc ports internal — AIX syscall stack convention (
002283eaca), NetBSD sysmon workaround skipped >= 9.2 (6406227d71), OpenBSDasmcgocall_no_gfor sigprocmask (6416bde023),pthread.hin OpenBSD defs (6a760d6c36), Plan 9 X15 not zeroed (02117775d1), crypto/x509 spurious expiry fix on darwin (d17b65ff54), Linux kernel struct padding (reverted7ee4c16654).
Compiler frontend · types2
From Compiler frontend: the types2 type checker (Go 1.18–1.28)
- Bringing up generics in types2 (type-parameter operands, core/structural types, tparam-as-interface) — Done: user-visible full generic support in the checker. Ops on type-parameter operands (listed above). Constant conversion to a type parameter (
d39c873966,f9285818b6string conversion). Field access through struct core types (61014f00f2); this was disabled again in 1.19 (b8248fab891.19). Method calls on pointers to type parameters are rejected (18135150b0). Embedding a type parameter or a pointer to one is rejected (4ff0e04c2e,37d2219960).anyis accepted anywhere (1e57748892). Local defined types in generic functions are supported (1ba2074440). Thenomonocheck for infinite instantiation was ported (519c0a2323). Theimplements/Satisfiesmachinery was factored out (e08aae2ee4). Aliases to generic types were disallowed at first (68152359fd). About 45 further commits are error-message polish for type-parameter code, for example89cc528e43,283991bd7f,2639f2f79b,91edf2b7f2,3d3f5d912b. Left open: field access via core types, and an interface-typed operand switch for type assertions on type-parameter values (f9dcda3fd8makes it an error). Fixes in this period also report recurring infinite-recursion and “broken alias” gaps, tracked in the other threads. - Type sets, union terms, interfaces and constraint satisfaction — Done: user-visible type-set based constraints as above. Strict
comparable: “does not satisfy comparable” is delayed until needed (a2004de088), and a “dynamic” flag on the comparable predicate distinguishes Go-comparability from static comparability (163da6feb5: an interface does not implementcomparable, because a component interface is only dynamically comparable). Further fixes:comparablemust not be visible before 1.18 (1cd505c353), “all interfaces implement comparable” tests (38729cff96),67dd9ee92c(empty type set for invalid~T),c3561dd346(comparable in union), union-cycle checks (13f3c57cef), delayed union element checks (c90ead97ad),4fea5935f5(real/imag/complexdisallowed on type parameters). Left open:848b58e473notes the intersection “does not always compute the largest possible intersection”. - Instantiation, Named types, Context deduplication and lazy expansion — Done: user-visible
InstantiateAPI andContext(above). Methods are instantiated with the type (d1fd3eb40e),af80af22b5forbids new methods on instantiated types,73418bca34records all instances inInfo.Instances. Fixes for recursion:f2ed30c31e(recursive substitution must terminate),93b5309f0a(rename type parameters in self-recursive instantiation),ad99d8840e(invalid recursively expanding generic types),7520c080b4(SetUnderlyingsetsfromRHS),48ec6df16c(mutating an instance panics),186f375ecf(constructed type parameters are immutable),3c00a2839a(length mismatch is an error).2175e2f573added lazy import resolution for types2 (Scope.InsertLazy,NewTypeNameLazy,InstantiateLazy) for the unified-IR reader. Left open:2175e2f573says the sync.Once-based laziness is “fragile” and unification with the generic lazy-instance mechanism is possible. - Type inference and unification — Done: user-visible function and constraint type inference with core-type unification (
f03ab0e014,5bd734839d); ~20 fixes: argument-order independence for named/unnamed (68b3d36ff4, disabled at first, enabled byb004c739b51.19 in 1.19), “do not run CTI before FTI” (3d3f5d912b),b00447038ashorter list for the 2nd FTI phase,bf0bc4122fperf (context string not re-evaluated per argument),9133245be7detect constraint-inference cycles,73a062c3e7recursive type-parameter constraints,3a07ab70a2inference of type instances (disabled again in 1.19 by28fab5ef211.19),5140ad104bupdate the recorded function type after inference,9284279b44useIdenticalrather than unification inmissingMethod,eab9a77a60defined-type unification fix. Left open:68b3d36ff4leaves order-independence disabled “pending decision”. - Type declaration cycles, valid-type detection and the object path — Done:
fe85c24431and671e1150c6add a stop-gap “broken alias” side table so the compiler does not crash on aliases that depend on incomplete recursive types (#50259 and others);2abfa30f9e,cc14fcac2b(disallow cycles through type-parameter lists),9062a5298b,ad99d8840e. Left open:fe85c24431says the correct fix “will likely require some form of forwarding type”;ad99d8840eleaves undetected cases (#48962). - Per-file language versions and version gating — Done: user-visible
d3070a767b1.19 (“check go.mod” hint fortype parameter requires go1.18),242d02dd5e,3e41b18a46,eb3ac1f5a41.19 hint forany;1cd505c353hidescomparablebefore 1.18. - Language features as seen by the type checker (by release) — Done: user-visible generics (other threads);
1e57748892anyanywhere; type-switch/assertion improvements (cf51fb5d68,254c497e5c). - Method receiver checking — Done:
c0840a7c72receiver tparam count must match,7c694fbad1delay receiver validation,a7d3a0e971identifier map for receiver type params,8cfbb58bc7removesSetRecvTypeParams. - Error reporting: codes, messages, and sub-errors — Done: ~60 message commits (e.g.
c25bf0d959types in mismatched call/return errors,cf5d73e8a2restore “too many return values” with have/want,b14fd720a8,e052044d6b,63e833154c,2e2ef31778append,8070e70d64). - Checker performance, memory and API ergonomics — Done:
054710ce46,6b609110fd,bf0bc4122f,0a39e4a89dstructural-type fast path,b66bc0a9d5lazy methods. - Robustness: invariants, incomplete types and importers — Done:
eff66248ea,2175e2f573,3db4888a05(types2.Unsafein gcimports),1b193598b3fail early ontypes2.Invalid.
Other changes
- File and API restructuring internal — struct, signature, interface and remaining type declarations moved into per-type files (
211244e172,cfe0250497,243076da64,1aadb18f83,0e0b80cb56,9c1e7d9eff,30e5f266ed); atypeWriterreplaced ad-hoc type printing (5f0d821add,3342aa5f51); TypeParams API renames (49c688e45c,5ecbd811b5,f5f8a911d8,b1cdf860dd,0ac64f6d70) — all internal except the exported ones below. - Exported generic API user-visible —
NewSignatureType(4a8995179e),TypeParam.Constraint/SetConstraint(d6753fd491,5ecbd811b5),Interface.IsMethodSet/MarkImplicit(8cf0a087c0,3beab0cd71),Named.Origin(7dfe686a91),TypeParam.Index(26b6833308),Structure→coreTypeexported helper (12dc48fd54), removal of deprecated entry points (8ac5cbe05d). - Test-suite conversions internal — testdata converted to type-set syntax (
9a99e728fe,c790964ae4,8cdce85bdf),.go2files parsed as generic code always (565f457e81),29483b3daere-enables compiler tests with types2. - Compiler/types1 integration internal —
de5d1aca5e,1c947e4f31(tilde in types2-to-types1 union conversion),60cb2cab97(Instantiate with interface type parameter),feec53c4e5(skip GC test during bootstrap). - Assorted Checker fixes internal —
fc9e64cc98,ddb5a42b25,fa4df6597e,50869f377f(string(1<<s)),ffb6c79828,1efc5815dd,9bdbed1d96,0981724eae,49030c87e0,c5bce7445e,286e3e61aa(x.sel with built-in x),0400d536e4,61d789db3a(incomplete struct literal error);8c99421f01delayed-action debugging; debugging/tracing improvements (fef14fdd1d,a4b6fc7b1d,f2cdc6d1671.19 in 1.19). - Instantiation, Named-type, Union/TypeList and API plumbing during the dev.typeparams merge internal — 108 small commits not individually discussed above, e.g. lazy-expansion tidy-ups,
Named.SetTArgsremoval,TypeListuse,Identicalfor instances/unions, verification of instances, impl/missingMethod simplifications:03ed590e51,c92ae885d9,6bdfff112f,1608577e05,cc7ceea585,3c1d502a19,95c618e99a,b47cbc2ffe,9cb1b0f50b,1eb756689c,69d945fc6e,3a047326e8,c6d3d0b0ad,80127a7dfe,9f928f9318,b93f646125,c079b6baaa,46cc686381,880ab6209e,0d7dc417ea,f5f79c47f9,508624f359,e4cfa2f6da,7308d747e7,50f4ebbdd3,2d250043b4,456759b246,b2253c8041,9d9e3291fa,805d38a352,5d0c2840da,1ff0554b53,e6798795ff,5fb177163b,86fa510d24,b06cfe9b25,ded10d75a9,605d1aaea2,2872496ba5,ccc927b8f6,47f3e1e02c,b61e1ed863,b26d325cb1,738cebb174,4847c47cb8,2f87b9c942,1367a60b06,5efa8ff340,41bb7446dc,dab16c1c90,33576247e2,662c5eed33,a73c6cf762,99fad12e47,3ff39c5eda,8151b56c5d,76dd01f457,3cd28baffd,a91d0b649c,278b9b3a4c,d2b512160e,e2e910ef30,0ae4c7ff4a,f801da7855,8f0ca7dc72,2cf85b1fb8,f934b8326f,34abc12b2a,0aa194f758,96c94c2c83,23f653df96,9150c16bce,bc0b98eeff,c2397905e0,184ca3cf99,6b3f4d388f,f384c707ac,9c60a09689,773f43b356,c402d64f37,3ca57c7fb8,f8a8a73096,07ed86c57b,7a3a2b18ff,c5540e53b1,c295137ad8,deb45802a4,46f138f288,4284d45553,cdd9e939ef,9dfd458e64,84eefdc933,1a2435c95f,f5fe5a4524,8f7d96f5bc,b37c6e1547,360e1b8197,77eff30ec0,727790a2fd,d9eba71a64,ef843ae49c,f1903fd4ec,aadbfc30af,7db75b368d,875a6d4010,e534907f65,78e99761fc,c15527f0b0 - Error-message, printing and position polish internal — 39 commits:
0d1e293b23,90b6e72605,8c99e5db43,c23294d6b3,0c40cb4a07,f0206e3df2,47547d8508,3d8453e00e,717894cf80,03db2c2413,8250141c9a,1a9807906d,5a94a90d84,d90f0b9200,b091189762,5d414d180b,02e5913406,599de4b2c3,747e4afe07,cfb3dc7710,23dd389ac6,ccd41cc05e,3a4b95073a,92655582d0,42fa03a88c,fda9261504,95e85e3108,79d0013f53,83bfed916b,8cdfe408bb,b77f5f9667,2e6e9df2c1,f009910625,6019a52d4d,4ceb5a94d8,efbecc7eff,ca6a5c0d51,902dc38212,badba359da
Compiler frontend · syntax, IR, generics
From Compiler frontend: syntax, IR, unified IR and the generics implementation (Go 1.18–1.28)
- Generics via GC-shape stenciling and runtime dictionaries — Done: Generics were first brought up on the old typechecker (
-G=3, types2 type-checks,noder/irgen+stencil.gobuild IR and substitute with a type substituter(*subster)). Export/import of generic types and function bodies (15ad61aff5,8e6dfe1b31, new export version7b3ee6102d,fd2f4b58b3,f90a42b410, kept the old format if no generics are exportedc2c1b53b39/40ba119e3f). Initially every distinct type-argument tuple was fully stenciled, then dictionaries were added (7b876def6c,bad388744b), then GC shapes (8767b87ab5,a7a17f0ca8,9b85985d36): same-underlying-type types share a shape (40e561d933), all pointers one shape (0b8a9ccb25), pointer-to-array and notinheap pointers separate shapes (d4e0e8e4a4,fcf6afb82d1.19 in 1.19), shapes live in their own package (b730a26729). Method-on-shape handling went back and forth (48cf96c256no methods on shapes,dfd875d015allowed without bodies). Generic code transformed lazily (6acac8b685“delay all transforms for generic funcs”), plus the generics/inlining interaction (931e84af40: only dictionaries and shape instantiations of types referenced by exported inline bodies need exporting, not the types) andde61465156/6fefb7f9f3(missing inline bodies became a graceful fallback).-G=3enabled by defaultc9912780ab;-lang=go1.18gates generic syntax2aea44204e. Left open:6fefb7f9f3says perfect identification of inlinable bodies is “much harder with generics”; the structure is duplicated in-G=3/unified IR paths.- Stabilization burst (about 250 commits, mostly by Dan Scales and Cuong Manh Le, grouped here): the
-G=3stenciler needed a long tail of mechanisms. (a) Delayed transforms: types2 results are used to build IR innoder/irgen.go, but operations whose semantics depend on the concrete type (calls, assignments, composite literals,==) are transformed only after substitution, viadelayTransform/transformCall/transformAssign/transformCompLit(07b30a4f77,0d838ea5a2,c94543b85f,4edefe9568,6acac8b685,cfa233d76b). (b)gfInfo/getInstInfocaches per-generic-function information (derived types, subdictionaries, bound calls vs field access, itab-needing conversions) used to build dictionaries (ddb09af1b8,4a7975e73a,f88c3b9f4d,f154f8b5bb);CONVIFACEnodes made explicit early in noder2 (12866bd8ea,e6d956e1c5,3fff213ac2,ba7673069d). (c) Export/import:ODYNAMICTYPE/ODYNAMICDOTTYPE(2be5b84665,394a1ad295), recursive constraints (d35ed09486), instantiated types referenced from inlined bodies (98ed916369,a80e53ec43,899d19ac83), the crawler for generic types (c9e05fdcf7,cea7a71d40,f6b5ffb5e1,ca5f65d771),MarkUsedIfaceMethodIndexremoved (0ae0d5c62e). (d) Naming: type-parameter subscripts replaced by func/type prefixes for uniqueness (0d65c272c9), blank type params kept unique (32636cd1ff),go.shapepackage-path escaping (1387b5e91d), instantiated type names (5b64381155,6226020c2f). (e) Lazy/recursive loading of types in importers (d7e2e2ec2b,2a4845257f,13c912d192,e581ec07ee). (f) Misc:comparableas a real builtin/interface (b614c05a15,d7a43e8912),anyidentity (0e1d553b4d,bc0aba9717), structural typing for field access /appendofstring|[]byte(ef4be98abd,f4aa021985,c74be77e63),ONONAME/closure handling in dead code (5a40100141,771b8ea4f4,ac78501b9c).
- Stabilization burst (about 250 commits, mostly by Dan Scales and Cuong Manh Le, grouped here): the
- Unified IR: one serialization for noding, stenciling, inlining and export — Done:
79cd1687e6(construction),cf1ae5fc36(-d=unified), GOEXPERIMENT knob804ecc2581, documentation6fa0437958,TestUnifiedComparetoolstash-style comparison test (3f7a3133da), incremental typecheck while reading (a18726a648), wrappers generated inside unified IR (f4198f85d5,d44ed5d144, delayed to walk20a04f6041), unified export data written after the iexport data via “scaffolding for export data experiments” (2954f11ead) sogo/internal/gcimporterand x/tools importers keep reading iexport. Avoids redundant method wrappers for imported anonymous types (7ab8754029, to stop large protobuf projects blowing build-cache limits),f118d145a5. Left open: not default; no dictionaries (stencils fully); a quirks mode existed only to keeptoolstash -cmpclean. - Old typechecker and IR node-model cleanup — Done: new IR ops for desugaring (
OCONVIDATA77e0bf294c,ORECOVERFP/OGETCALLER{PC,SP}9be8303df9,OCALLPART->OMETHVALUE1b995f91a5,RawOrigExprea522bc546),StructKeyExprpoints attypes.Field(a94e4f5a85),OINLCALLflattened in walk (c45d0eaadb),Func.ClosureCalledset in escape (899b158ee9),~r0/~b0result naming simplified (e99e9a6e01). Base helpersbase.Assertf(6a931673f0).types.Type.Vargen,Extra,New,NewBasicunexported (eb6a07fcf9,3836983779,a9377183d0) andType.OrigSymgetters (68ecdc2c70). - Static initialization and package init — Done: pkginit “init” and “inittask” logic separated (
6c5f028242);opendeferinfo symbol content-addressable (d9952ff511). - Compiler debugging infrastructure: bisect/hash debugging, flags, dumps — Done:
-dflag parser moved toobjabi(1c4cfd8010),-asan(85b3b4ee03),-memprofilerate(6113dacf32), always print ICE message for panics (1abe9c1c73), dumps:-W=3,c2966ae272position details. - Frontend support for new language features and spec changes — Done: user-visible generics (see above),
anyas alias likebyte(b31dda8a2a,8ff254e30b),comparablebuiltin (b614c05a15),-langgating (2aea44204e,4068fb6c21always accept 1.18 syntax but complain if not 1.18),//go:embedinto any byte slice type (4f2ebfe34b),-langcheck for embed moved to noder (8eeaf961c5),unsafe.Sizeofon type parameters (be1a693477). - The syntax package (parser, scanner, tree) — Done: generics syntax: embedded type literals (
81b22480cf), type-set syntax in tests (90096f445e), constraint literals with elided interfaces (5279e534b5,bb49eb3e6a,0bef30d28aarray/slice constraints), type parameter list validity (2c60a99f72,33a1a93a92,da1aa65053),go/ast-styleWalk/Inspect/Visitor(8165256bc2, used byCaptureVarsbadb98364b),PosBase.Trimmed(ab9aaf46ee), “assume generic code for std lib” (aa878ee49b),AllowTypeSetsremoved (276fb279d1). - Types package internals: size, algorithm kind, TFlag, SIMD flags — Done:
types.RecalcSize(62f88b6dc8),PtrDataSizesimplified (c81fa001a7), types init code moved intotypes(967a3d985d1.19),Type.Extra/widthCalculatedunexported. - Method wrappers and promoted-method sharing — Done: wrappers generated in unified IR; wrapper emission after inlining (
50f38d0405); “always generate (*T).M wrappers for instantiated methods” (4ed6317e73);132ea56d29fixes crawling of embeddable types so inline bodies for promoted unexported methods are exported; ABI wrapper comments.
Other changes
- dev.boringcrypto / release-branch backports internal — a handful of old (2017-2018) commits tagged to this cycle by branch merge:
7b49445d0f1.19,e8eec3fbdb1.19,0cbb11c7201.19 and release-branch.go1.9 cherry-picks (fbc9b497901.19,5c48811aec1.19,0b55d8dbfc1.19,d80889341c1.19): file-descriptor limiting, GOROOT replacement in//linedirectives, panic-merge fix. - Export data reviews internal — importer files reviewed after import from
go/internal/gcimporter(8c5c5a9e69,cc52fdd1f3,c7b9811581,d36b7d7bdd,2fc7df93fe), position reading (fb79f6955e). - ABI documents internal —
abi-internal.mdfor ARM64 (ae26b45113) and ppc64 (9e60c37147), Plan 9 SSE note (b3e1fbff4d). - Error messages like Go 1.17 user-visible — types2 errors rewritten for compiler use (
c8d6ee12d5,ff8a7e513b,0626ac064d), nil-conversion message (375a1fba0e). - Interface cycle user-visible — anonymous interface cycles rejected (
840b346c5d1.20 in 1.20 with-d=interfacecycles; removed6fe0d3758b1.22 in 1.22). -asanand DWARF user-visible —-asanoption (85b3b4ee03); DWARF for dictionary entries (72bb8185b5).- Concurrent compile on darwin/arm64 internal — re-enabled (
579ff8b131). go_asm.hinternal — exact constants for big ints (8b9b365493,f582778ee9).- Unique LinkString internal —
struct{ Name = Type }notation for alias-renamed embedded fields (1a8b4e05b1, first attempt933f6685f7reverted55d10acb72due to racyLocalPkg.Lookup). - Generics via GC-shape stenciling: Generics dictionaries: layout, sub-dictionaries and hidden parameters internal — Dictionary design hardened during the dev.typeparams burst: a
.dicthidden parameter is formalized (“hidden parameters” idea, constants for local/global dictionary prefixes), instantiations are separated from dictionary creation,.dictParams are created in the package of the instantiated function, global dictionaries reuse one node, the captured dictionary is copied to a local in closures, and sub-dictionary entries (including optional ones for typeparam-bound method calls, method references and shape sub-instantiation indexes) are written out. Fixes cover dictionary assignment being a defining statement, wrong dict param for dict types, and dictionaryCapture.go (201d55e637,ccfb0ce8df,ee4fc0c1bc,6a5f7e8498,9ba294e15b,b994cc69e0,5dac279fbd,b4844c9f54,1c783dc148,5517053d17,10c8b7c1d7,4a97fe8c22,ee20dff27d,5cb84f0604,687f2acf6a,8486ced8b0,8eeb1bff1d,ee69b09424,812c99f86a,be571a36c7,ad7eae21d5,a064a4f29a) - Generics via GC-shape stenciling: Shape types: construction, identity and flags internal — Shape types (GC-shape stencil keys) were made robust:
HasShape()becomes a type flag,Unshapify/concretifyare removed so calls are transformed with the non-shape type, shapes get a proper package and size computation,anyand shapes get correct identity, constructed types containing shapes are handled, and shape type parameters get proper indexes for sub-instantiation (3dc0a0a2c5,5d8f90f904,35dbdda2fe,156eeb40a6,5e33d11e10,2dd7b770de,c2de759581,7f2463cc36,9bfe09d78b,b41185c5c3,a991d9dc27,1ab8273718,eb8198d2f6) - Generics via GC-shape stenciling: Method values, method expressions and closure instantiation under stenciling internal — Instantiated methods flip between being methods and functions several times before settling (keep as method, change back to functions, always strip the receiver type from instantiated method values). Method expressions on typeparams and
(*T).Mwith dictionaries, method-value wrappers (moved to walk,sym.Defset, marked wrappers), OFUNCINST closures (missing..., ddd, types), embedded-field receivers, imported instantiated types having their methods created, and methods of instantiated interfaces marked used are fixed (04f65d394c,9daf3cca82,468efd5e2f,ccbfbb1c33,8d2b4cb6cc,46beeed0ac,0132b91127,f1b1c2f67f,3f7f72a258,f99b3fe2ab,4e6836e82c,e00a6ec084,600b7b431b,fe73f28dc5,e61d1445ab,c2bd9ee2db,3081f817da,08d4cc20ca,62ba72b353,80783558b0,c981874a5a,54079dfd7f,6b4cf2be93,a45457df82,bee0c73900,5344dcae41,73a4bbb0df,429d1e0155,5b9207ff67,042548b1fd,1ee70da312) - Generics via GC-shape stenciling: Conversions to interfaces and type switches in generic code internal — Conversions of generic values to interface types use dictionary entries (type parameter to interface, derived types converted to interfaces,
==/!=operands, only for conversions to type parameters), with fixes for interface-to-interface and interface-to-empty-interface CONVIFACE cases, stenciled conversions that become NOPs, early CONVIFACE otherwise created in order, interface type parameters in type switches, and slice-of-user-byte to string (498a48327f,cf4b6dc48e,501725032c,bfcb7c4c8a,3cdf8b429e,2fbf6aafe7,b7b790a71a,c85695a117,5d863f89fe,4f0dedca71,6a35e07512,5670ff4ae5,19457a58e5,952df98158,bc0eb5789e,7548327374,c1296af151) - Generics via GC-shape stenciling: Export/import of generic function bodies (iexport) and inlining internal — Unified-IR-independent export data for generics: OFUNCINST, OSELRECV2, builtin calls, comm clauses/closures, range loops, Init/Def fields and constants of typeparam type are exported/imported; importers avoid re-typechecking and reading type parameters twice; instantiated functions and methods are loaded or not re-instantiated; inline crawling handles embeddable types; refactors split import reading and export writing (
f3fc8b5779,b1a398cf0f,d48f6d9f6f,22f5ece3b1,97cb0113a3,4c072c94dc,a5be3eaee2,74d46381b2,4a735ce068,844c076359,d10a904712,8ab59d812a,56c3856d52,08588e6036,ee91bb8319,e4dfd788e6,50e4508269,a83a558733,9fa85518ff,229b909313,e8cda0a6c9,be18cd51de,0103fd2b8b,7f2314530e,e7d5857a5a) - Generics via GC-shape stenciling: Type-parameter representation and the stenciling substituter (types1/-G=3) internal — Work in the old typechecker’s
subster/Tsubster: typeparam bounds and union/constraint support in types1 (TypeParam.Constraint,Structure()), type-alias and generic-type handling, set type-parameter indices at bind time, Nname/Defn/Funarg/Embedded/note copying, delay-transform conditions, noder2 fixes (++/–, OFUNCINST types, transformDot/transformCall/transformAssign ordering, inferred targs), local-type instantiation scoping and many individual stenciling crashes (c3fa51c9a2,f208f1ac99,701bd60646,b69347d24a,5b1120fac7,4c50721cda,fd54ae8b0c,95748d1b74,b7f7d1cd7b,417955d151,f32f4f58d9,4b10e4c547,2580e9a160,026480d06b,bcb3927cb5,18788245ea,62e32dd386,61888d47c4,8f00eb0099,ee0420d3b5,8f95eaddd3,dd95a4e3db,e9c01f9804,493e177639,107b1fce64,a8861b907d,64e6c75924,706c580ee1,ea5369bac0,cd00499c61,c65ca97a45,85267f402c,04acb8a7b9,e3e6cd3022,e6a2cf233f,dcc8350ad3,8e9109e95a,4cdc65d32a,6992dcdad9,a2e2b0362b,506fd520d5,27552e9172,9f4d6a8359,677dfe5ad6,099b819085,3d667671ad,82efc05403,8f4c020660,891470fbf7,ecfff58fb8,6640171914,a9a01a3fbd,2481f6e367,1a708bcf1d,8854368cb0,4186db6155,5d6d9f5610,10d3b13551,b1b6d928bd,1dc9af5cdc,560dc9712d,e39ab9b01c,0907d57abf,06a43e4ab6) - Unified IR: Unified IR: reader/writer refinements during dev.typeparams internal — Unified IR (
-d=unified) was refined as it caught up: more incremental top-level typecheck, objStub handling, variable capture and closure construction simplification, implicit/explicit factoring, sync-point stack recording,//go:nointerface, blank-function skipping,$GOROOTextrapolation, importing-function optimization, inlining panics and removal of reader/writerextfields (54fe57bc22,d24c90a153,e57da8e53c,9bdbf73c98,b55cc6687d,9fe7c38d3d,1b60284c0a,372b312735,3c3c1d8d28,0dcab98fd8,82744bfbfc,4a47e40a14,1d35d8ffa5,6dadee759c,88859f3cd8,9afbf82667,e30a09013b,4c52eac49b,42563f89d7,376a079762,b8c802b116) - Housekeeping, syntax-error messages and small fixes internal — Pure refactors, readme/TODO cleanups, and small bug fixes (syntax error messages and type-parameter positions in
syntax, gcimporter tweaks, ir.Dump, ssa.html source view, uint64-to-float32 on 32-bit, checkptr alignment moved to SSA generation, Sym/Type API tidying) (692399fbaa,6ed9463133,f457ecc7f0,d70c69d830,4a9f0cec29,4158e88f64,1f8d4562de,967a8017f7,c927599783,ef4cb2f776,010817714e,b602daea1b,f27d6a23b0,faf9c7d8fe,711e1c8224,5e0f8edbdc,df4c625d88,d62866ef79,b9e1a24581,73483df406,96ab854ab0,42057e9848,d09e09bc61,b6dddaccd7,cfd0868fc3,f375844342,2043b3b47b,4fb2e1cb86,0c45ed0561,22951fbc89,4e565f7372,73652af80d,9ff91b9098,b2fe2ebab6,eb63cbd295,a419f2f5c3,99699d14fe,d3aedb72c6,5337e53dfa,7f4a946fa2,0f64c21d90,d34051bf16,bbe1be5c19,ece493eb83,006d4e6278,c1f012a0d9,f1596d76f4,b850f3629f,edbe4742a2,bcee121ae4)
Middle end and SSA optimizer
From Compiler: middle end and SSA optimization (Go 1.18–1.28)
- Inliner: budget, closures, and the interleaved inline/devirtualize driver — Done:
- dev.typeparams refactors simplified variadic calls and
mkinlcall(6da1661371,417955d151,1ec056244e). Walk flattensOINLCALL(c45d0eaadb). - user-visible Functions containing
ORANGE(a3bb28e5ff) and labeledfor/switch(74acbaf94a) became inlinable, with fixes inb8da7e4c4candc6e82e5808. encoding/binarycalls are treated as cheap (17c513e722).- Closure positions (
08e2519ded,465b402808), a TODO in inl.go (d92101f452). - Shape-typed generic bodies are not inlined when shape and non-shape arguments mismatch (
6ba68a0581).
- dev.typeparams refactors simplified variadic calls and
- Escape analysis: call modelling, closures, func-variable callees, and solver speed — Done: dev.typeparams moved call handling out of order into escape:
- Call logic was moved from
order.gointo escape (0a0e3a3dea), escape analysis of calls was refactored (99732b9070), and the package was split into multiple files (3e6219c6a9). - The special escape-analysis tags were removed (
077100dfcd). - Method-expression calls are analyzed (
eb691fdd62), and method calls are rewritten into method expressions (2493c72742, then during typecheck in0cf71f7f92). - Constant
go/deferarguments are wrapped without allocating (a72a499c24). Diagnostics are skipped for wrappers (df00abc61b).walkGoDeferwas simplified (e59a19cceb). CallExpr.PreserveClosureand theSetClosureCalled(false)hacks were removed (1a445dab66,70f4ab6565). An outdated TODO was dropped (73162a54c2).- Defers lost variadic calls and
_defer.siz, and open-coded defer metadata was simplified (5b350505da,74b0b2772a,c0a86c10f1,b20747334a). ORECOVERwas desugared toORECOVERFP(574ec1c645). “Hidden parameters” were formalized (5dac279fbd).- Method-value wrappers moved to walk (
f99b3fe2ab,fe73f28dc5), andPartialCallTypewas renamedMethodValueType(4676c3675e). OCALLMETHis caught in the backend (aee209c044,180c338c68,27e3b797bb).
- Call logic was moved from
- Lowering of builtins to memory ops: memmove/memclr/memequal inlining and generated equality — Done:
memequal(x, const, sz)is inlined for 2/4/8 bytes, firing ~100 times in the compiler (810b08b8ec). Left open: nothing noted. - Static devirtualization and shape-aware type-assertion pruning — Done: fixed AST generation in devirtualization on dev.typeparams (
942bcc2d4f). Left open: nothing noted. - Branch-free lowering: CondSelect-into-math and ARM64 CCMP — Done:
branchelimenabled on ppc64 (259735f97a).
Other changes
- Fixes and small rules (~45 commits) internal — softfloat with register ABI (
656f0888b7), checkptr false positive (de1c934b97), ODYNAMICDOTTYPE can panic (c2f96e686f), arm CMP->CMN fix (b7b44b3173), closures not compiled twice (85d2751d2e), tail calls keep LR (9012996a9a), int/float->complex (d107aa2cd1), map-init arrays not noalg (0a7f00ae23), unified IR selective method wrappers (f118d145a5). - Register-ABI/dev.typeparams follow-ups internal — expandCalls fixes (
bcdc61d830,6e0adde1e9,bd49a998bf,f249fa27a9), regabi PPC64/riscv64 CALL ops (333f3de2a1), memmove ABI on ARM64 (e4003463ff), tail-call wrapper restoration and self-copy removal (c10b980220,f01721efb9), dictionary-argument handling (ccfb0ce8df,315cec25bc). - GOAMD64 v3 instructions internal — BMI1 (
04572fa29b), TZCNT (060cd73ab9), MOVBE (3e5cc4d6f6), later LZCNT, SARX/SHLX/SHRX incl. load forms (a92ca515071.19,d6320f1a581.19,66f03f79da1.19,cb702a2a561.19) in 1.19. - Intrinsics added internal —
publicationBarrier(739328c694), prefetch (23f4f0db68, PPC646ae3afa7e7), Mul64 on riscv64 (efd206eb40), BitLen32 on PPC64 (33b3260c1e). - Rewrite-rule infrastructure internal — automated rewrite cycle detection (
bff39cf6cb), fuse CFG fix (8dbf3e9393), generic 2/3-operand arithmetic simplification (6cf1d5d0fa), eliminate successive swaps (e1c294a56d). - Arch-specific rules (~35 commits) internal — arm64 bitfield/rotate/UBFX/SBFIZ merging (
2091bd3f26,43b05173a2,7b69ddc171,83b36ffb10,6f35430faa), riscv64 FMA, branch-with-zero and NEG absorption (ea51e223c2,bcd146d398,8fff20ffeb), amd64 MOVOstoreconst (144e0b1f6e), PPC64 inline memmove (b35c668072). - Write barriers and misc internal — no write barrier for global-address offsets (
6b9e3f883e), drop unnecessary amd64 extension checks (097a82f54d), SSA.thisvariable (4b654c0eec), checkptr moved to SSA generation (d62866ef79), better ssa.html line highlight and genssa dump (96ab854ab0,af72ddfcd7).
Backends and assemblers · architectures, ABI
From Compiler backend: architectures, register allocation, ABI and assemblers (Go 1.18–1.28)
- Register-based calling convention (ABIInternal) ports beyond amd64 — Done: ARM64 gets parameter registers
4bb927f82e, ABI-compatible prologue registersa4b2a04bc5, morestack arg spilling4c68edd1fe, arg/result load/spill06df0ee7fa, updated CALL ops8e7abefdaa, memmove call matchinge4003463ff, and is switched on by963f33b03b;clobberdeadon ARM646b1e4430bb. AMD64 regabi becomes unconditional and theregabigexperiment is removedc93d5d1a52. Do not schedule in-register args latecf23daeda3. PPC64 gets ABI register infocceadf8527, initial spill09d3df0183, new CALL ops333f3de2a1, enabled with duffcopy support24c2ee7b65, plus prologue0edc6c4fa0. Argument stack-slot liveness for tracebacks30a82efcf4.maymorestackdebug hook (asm + compile)3839b60014. Method-wrapper tail call restored by redefining OTAILCALL to carry an OCALLc10b980220. Tail-call fixes in leaf functions on PPC64d198a36d8c, MIPS/S390X67917c3d78. Loopjmpdeferreplacement was landed and reverted in the same cycle (fd0011dca5,e3e9f0bb2d); see the defer note under Other. Left open: riscv64, loong64, s390x still on stack ABI; the bug “args not spilled into dedicated slots” is called out in30a82efcf4. - Register allocator, scheduler and block-level backend passes — Done: regalloc switch sorted by arch
dcee007aad; eliminate successive swapse1c294a56d; helper removal of phi args (7b554575e4,f686f6a963). Left open: nothing noted. - amd64 code generation and GOAMD64 microarchitecture levels — Done: user-visible BMI1 instructions at GOAMD64≥v3
04572fa29b, TZCNT060cd73ab9, MOVBE3e5cc4d6f6(reverted/relandedb0351bfd7d,fe7df4c4d0), POPCNT register break via shorter XORb99abf3cce; TESTL for cpu-feature checksd2d21d98e4; ANDL for small immediates (4476→3024 ANDQ in the Go binary, 0.03% smaller)732f6fa9d5; MOVOstoreconst with offset folding (16-byte stack zero as one MOVUPS)144e0b1f6e; folding of 32-bit pointer offsets removed46121306d3; prefetch and publicationBarrier intrinsics23f4f0db68,739328c694; Plan 9 X15 not zeroed02117775d1. Left open: more v3 instructions. - arm64 code generation and assembler — Done: ZR/REGTMP encoding errors fixed (
aef24d8f7d,9cbc76bdf9,8e18428e38; pseudo-register addressing and SXTB checksc92c2c9d62,e9e0d1ef70, move-constant checks41f74079a9,6656269288); constant rotates83b36ffb10, rotate merged with logical ops6f35430faa, ext+shift → SBFIZ/UBFX43b05173a2,7b69ddc171; double-negate fold315dbd10c9; shift range checks for ARM/ARM64ccfc41eee0. - riscv64 compiler and assembler (RVA profiles, vector, compressed) — Done: FMA support
ea51e223c2, Mul64/MulUintptr intrinsicsefd206eb40,1951afc919, Abs/Copysignc69f5c0d76; branch-with-zero and NEG absorbed into branchesbcd146d398,8fff20ffeb; immediate-operand constant folding (e.g. the 5-instruction arithmetic right shift becomes onesrai)fe8347b61a; Prog-rewrite elimination series inobj/riscv(5ec298d7b0,9cb5716f00,ba66d62b68,8a01010c26,0b66310924,2d90df91a8,37e9c1d6fe,da790cccc5); c-archive/c-shared6458b2e8db; stack-bounds prologue made nonpreemptible59d04d104d; trampolines from large functionsbde0463da3. Left open: register ABI (next cycle). - PPC64 / Power10 backend (GOPPC64, prefixed instructions, PC-relative code) — Done: register ABI + duff (above), long conditional branch fixup
8f397bc118, prefixed-instruction alignment46796703d7, operand classification rework (5a3d0f5a63,1e2820a6d7,aa1c6f5639); memmove inliningb35c668072; prefetch6ae3afa7e7; AtomicLoad rulesce72766a02; PowerPC rule fixes94323206ae. - Duff’s device replaced by generated loops; Zero/Move lowering — Done: duffcopy/duffzero initial use on ppc64x
24c2ee7b65; Plan9 duff. Left open: nothing noted. - Multi-word arithmetic, intrinsics and carry-chain support — Done: Mul64 on riscv64
efd206eb40, MulUintptr1951afc919. - s390x, MIPS, 386 and 32-bit ARM backends — Done: MIPS64 extension elision fix
d93ff73ae2; s390x/mips tail call fix67917c3d78; Spectre assembler error on 386c091767d87.
Other changes
- GOAMD64 guard test internal — test ensures >v1 instructions are only emitted at v≥v2/v3 (
cbd7200167,5d946f1892). - obj: remove ABI aliases and funcdata offsets from object file internal —
a630783ba0,cfd74f7727,e180e2c27c,850a4ffb63; gcbits/stkobj symbols made content-addressable (c1a0aa300a,0e13da8fae,e5f6d8d00c,534dfb2aeb); assembly routines flagged in FuncFlags752cc07c77. - Wrapper DWARF internal —
DW_AT_trampolinefor wrappers5b48fca1fa; liveness diagnostics suppressed for wrappers808dca3b2d. - -buildmode=shared removal tried and reverted user-visible —
68bd5121ee,a88575d662. - dump to file for genssa
af72ddfcd7;LocResultsformatting48f431ee3c1.22. - fiat-crypto P-224/P-384 user-visible —
93bab8a2f9(crypto, edge). - 12 small ssa/regalloc/liveness/obj generic commits internal — e.g. cmd/go: remove double parallelism from “go fmt”; [dev.typeparams] runtime,cc,cmd/link: replace jmpdefer with ; cc: preserve statements better in expandCalls. (
7bf7bbc241,1a0630aef4,bcdc61d830,d350a66532,48e2b1ea91,df63673d6a,a8d78fae95,e741e2fe0e,e9ef931e06,c49627e81b,f005df8b58,1ed30ca537) - 2 small obj/ppc64 and PPC64 rules commits internal — e.g. obj/ppc64: allow VR register arguments to VS registers; cc: set PPC64’s MAXWIDTH as other architectures. (
b3c6de9dcd,8da66a35ca) - 10 small obj/riscv and riscv64 rules commits internal — e.g. obj/riscv: improve code generation for loading of constants; obj/riscv: simplify rewriteMOV; obj/riscv: simplify machine code output. (
28dae3defb,f5bdbf311c,f030043e37,ab7c904bf2,c50d811c7a,50c69cc3a9,37d4532867,6602c86a38,e9eb66da30,f1935c5270) - 1 small obj/loong64 and loong64 asm commits internal — e.g. cmd/internal/sys: fix placement of loong64 definition. (
20a71c9a1d) - 2 small obj/arm64 and arm64 rules commits internal — e.g. cc: fix simplification rules on arm/arm64; obj/arm64: adjust rule for VMOVQ instruction. (
79159f2e83,897b3da2e0) - 1 small obj/x86 and amd64/386 rules commits internal — e.g. obj/x86: modify the threshold of assert loop for span6. (
14f2b2a4c5)
Linker and object files
From Linker, object files and debug info (Go 1.18–1.28)
- Relocation-free pclntab and funcdata (offsets instead of relocations) — Done:
cmd/link,runtime: remove functab relocationsuses an offset fromruntime.texte31c9ab557; stkobjs relocations replaced by offsets fromgo.func.*3100dc1a7f;_func.entrybecomes an offset (about 10% fewer relocations on darwin/arm64)d3ad216f8e; FUNCDATA relocations converted to offsets (about 40% fewer relocations on darwin/arm64, smaller external-link binaries)017ffcd10d; all FUNCDATA refs moved intogo.func.*cfd74f7727; goobj loses the PCDATA block850a4ffb63and funcdataoffe180e2c27c; pcdata accessed via aux symbols587b3c1192,583eeaae50; symbol alignment logic moved to the object writer17674e2f17;funcSizemade constant2d6d558417; textsectmap fields reshaped for the runtime058fa255bc; holes in functab experimentally marked then reverted1ceb72394e,bd41f2d3cd. Caching field size indebug/gosym.funcTabavoided a 20% PCToLine regression (message ofe31c9ab557). Left open:pcHeader.textStartstill needs a relocation. - Type, itab and typelink layout (.go.type section, relro rework) — Done: type descriptor method arginfo placed in the correct section
52b23a50f8; gcprog symbols put with gcbitsd480b5c790;type..importpathfixe5ad363fff. Left open: nothing noted. - DWARF quality for debuggers (types, variables, trampolines) — Done: dictionary entries described in DWARF
72bb8185b5, types reachable only via dictionaries6268468e02; wrappers markedDW_AT_trampoline5b48fca1fa; register-resident output params79e03a9281; gdb script section pinneddaa55b21d1; column info dropped when line saturates1de2344af1. Left open: nothing noted. - Dead code elimination and reflection-aware pruning — Done: generic interface call relocations
c26a32a500; dead reference link fix58490972c0. Left open: nothing noted. - Linker performance and memory — Done: output file not unmapped on error exit (race with concurrent writers)
e9f0381a80. Left open: nothing noted. - Reproducible build IDs, buildinfo and symbol tables — Done: version info made easier to extract
b37a5391f9. Left open: nothing noted. - ELF/relro/hardening and external-link policy — Done: note sections merged into one segment
1ea4d3b911; SHT_INIT_ARRAYcfb0cc3552; non-exec stacks on FreeBSD782aa42255;-asanoptionae4d67c89d;CCwith spaces and quotes742dcba7bb; start address 0 for external linksc92f5ee170. Left open: nothing noted. - Per-platform object formats and internal linking (Mach-O, PE, XCOFF, wasm, ppc64, riscv64, loong64) — Done: ppc64le TOC rework and internal linking of PIE
9295723079,2c4f389c02,fa16efb835; riscv64 trampolines3bbc82371e; Mach-O runtime.text.N9112d296e8; AIX symbol manglingf1f626de53; wasm command-line args fix77f2750f43. Left open: nothing noted.
Other changes
- Linker robustness and small platform fixes internal — ~30 small changes:
CC --print-prog-nametool lookup (eb9f090d1b), GO_LDSO on cross compile (ddfcc02352), undefined func sym crash with external linking (014a9720f9), weak itab refs disabled with-linkshared(f687831e4c), funcdata alignment reductions (96d3ba868a,77bd0da688,8d494b0818), AIX go.buildid kept alive (415f0a3375), darwin libc-based fcntl in fallocate (d887d3be5f), forced eager binding for plugins on darwin (c5fee935bb),-dearly exit on libc platforms (57aba325c8), wasm env space (252324e879), ppc64le glink PIC (732db407d3), ARM64 PE label symbols (988efd5819), fuzz coverage instrumentation (74f49f3366), Plan 9 ABI mangling (240d6d00ca). - ABI aliases removed internal — ABIInternal normalized to ABI0 at link time, aliases deleted (
98989f2a74,55d22f7490). - Generic-type symbols internal — instantiated types elided in tracebacks (
a80cbc25bd). - goobj version bump internal —
5e217284dc.