Go 1.4
Most of the runtime converted from C to Go (scheduler, channels, maps, panics, signals). Stack copying is the only mechanism, with 2 KB minimum stacks. The compiler emits write barriers. atomic.Value. Android.
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 Memory management: GC and allocator (Go 1.0–1.17)
Allocator and collector prepared for Go: free removed, stack allocator split out, byte-array bitmap, more parallelism; GC still stop-the-world.
- Stop-the-world mark-sweep, then the parallel collector — Done: parallelism pass (
44106a0880,192bccbf33,f6f2f77142,0c32bd6262,98bebcc90aparfor in Go,aac7f1a0d6markallocated in Go,c46bcd4d13finalizer goroutine in Go); stack shrinking delayed until GC is done to avoid the GC seeing freed stacks throughSudoG.elem(91e8554b8b); invalid pointers into the GC arena crash (11e53e46a6);MemStats.PauseEnd(46af78915a); go1.4gctraceshows goroutine count (ed7db89b90). Left open: all of it still stop-the-world, with mark termination doing all marking; the power64 port disabled GC (9b88857f751.5, in the dev.power64 branch landed in 1.5). - Concurrent sweep and proportional sweep — Done:
sweepgenset before span state (3590d9ce69); transfer cache so a swept span does not bounce between mcentral/mheap locks (e0df11d57e: the previous dance was lock mcentral, remove, unlock, unmark, lock mheap, insert, unlock, lock mcentral). Left open: nothing noted. - Concurrent mark: write barriers and the dev.garbage collector — Done: compiler-inserted write-barrier call sites (a no-op barrier;
b035e973151.5’s message refers to barriers inserted “for Go 1.4”). Left open: collection still STW. - Stack scanning: conservative, precise by frames, stack barriers, hybrid barrier, async safe points — Done: conservative scanning of stacks removed for Go frames (
d208361cde), shrunk stacks freed only after GC (91e8554b8b,d57056ba261.5 later), parallel shrink (192bccbf33). Left open: stack rescan in STW. - Precise heap scanning: type information, the heap bitmap and GC programs — Done: byte-array bitmap (
ff3fa1b32d), unrolled mask cache (b91223edd1), backward scan removal (03f2189a1b), bitmap corruption fix (5bfe8adee5), type mandatory for scannable allocation (fb44fb6cb7). Left open: 4 bits per word and boundary bits. - Size classes, tiny allocator and mcache/mcentral — Done:
freeremoved (cecca43804), transfer cache (e0df11d57e), alloc counted for tiny allocs fortesting.AllocsPerRun(e19d8a47d1). Left open: nothing noted. - Span lifecycle in mheap: free lists, treaps, first-fit and the page reclaimer — Done: mheap not locked on user goroutine (
e91704af27: the code under lock could grow the stack), allspans races (7f223e3b3b). Left open: nothing noted. - Heap address space: contiguous arena to sparse arenas — Done: heap growth by 64K (
0622e13b4d);mincoreinaddrspace_free(0e1b6bb5471.3). Left open: nothing noted. - Finalizers and span specials — Done: finalizer thread in Go (
c46bcd4d13). Left open: nothing noted. - Mark work distribution: parfor, work buffers, gcWork and root jobs — Done: parfor converted to Go (
98bebcc90a), workbuf cache (f6f2f77142,ac9218f5f0), parfor untyped allocation removed (fc46931442). Left open: nothing noted. - Runtime allocators for runtime metadata and the port to Go — Done: stack allocator (
7c13860cd0), stack orders raised to 4 in 1.5 (5aae246f1e1.5),sysAllocnosplit (99a08262af). Left open: C-written malloc. - Memory statistics and accounting — Done:
PauseEnd(46af78915a), stats fixes (30ef2c7deb,266d350f5e,01a7d39df1), tiny allocs counted (e19d8a47d1),gctracegoroutine count (ed7db89b90). Left open: nothing noted.
Other changes
- GC cleanups before the Go port internal —
gobuf.ctxthandling removed because it was wrong (d3be3daafe),getgcmaskon the M stack (005806cab1),gctracedeadlock viaReadMemStatson m0 (a0dbbeae67),UncacheSpansimplification afterfreeremoval (f3dd6df6b1),FlagNoProfileremoved (1837419f30), Plan 9 and Windows accounting (846db08936,048692e5de),gctracefix (2425a2e32f), Go/Cmallocgcsignatures (489ff75ab8,58241bfdf7). - Scan and bitmap micro-optimisations internal —
markspan2x on NUMA (acb03b80281.3), scan-loop optimisations (b8fdaaf028,9dc6764d3c), memmove in mgc0 (ab5d105ba9). - Convert GC helpers to Go internal — Removed the C version of the GC, converted freeOSMemory and clearpools/registerPoolCleanup to Go, and restored the g0 check in GC. (
9f38b6c9e5,60447c2d95)
Scheduler and concurrency
From Scheduler and concurrency runtime (Go 1.0–1.17)
Conversion of the scheduler, channels, select, semaphores, timers and netpoll from C to Go, plus atomic.Value; threads: C→Go conversion, channels.
- The G-M-P scheduler: from global-lock M:N to per-P run queues, spinning Ms and work stealing — Done: scheduler functions converted to Go
684de04118,5d40742728,6ed58c2962,dropg/schedulerework to handle locked goroutines in one place64c2083ebc; scheduler trace now prints spinning Msa7186dc303; goroutine ids start at 1aa76377423;allpstatic array858c57f5bd;NumGoroutinesO(1)92c1e72040. - Network poller: from the netFD select loop to the runtime-integrated epoll/kqueue/IOCP poller — Done: netpoll converted to Go (epoll/kqueue)
91a670d179, Solaris97fdfdb52c; shrinkstack vs netpoll race2b62e1eaec1.5 (Go 1.5 list). - Timers: timerproc goroutine → per-bucket heaps → timers on Ps — Done: timers converted to Go
9601abaf8b; fake time support revived2fe9482343. - Channels and select — Done: chansend/chanrecv/closechan/select converted to Go
9a1e142bbc,47d6af2f68,6a76bca33f,1d8fa7fa5d; non-blocking fast paths (BenchmarkChanNonblocking27.8 → 7.8ns)f6ceefa2bf; chan type infodfa5a99ebb; sudog stale-pointer leaks0120f8378d,13da360845,e330cc16f4,b3932baba4,2ad99f0960,b3932baba4. - Semaphores, runtime locks and Notes — Done: sync and async semaphores converted to Go
a6950fe0f9,ebac0e6f30; notesafb2260491, futex notes fixd2165672ca; block-profile fix7b3677bf3c; semacquire always on the G stackda8cf5438aand71de7e7539. - sync.Mutex, RWMutex, WaitGroup, Cond, Once — Done: RWMutex misuse detection
22d46d53ea; panicking functions still mark Once completeb22dc6385d. - sync.Pool — Done: Pool memory released across second and later GCs
af3868f187. - sync.Map, atomic.Value and sync/atomic — Done: user-visible
atomic.Value98a1e207e2; nacl/arm62af04c0bc; missing prototypes735289ff76. - Runtime from C to Go: scheduler, channels, semaphores, timers, netpoll — Done: common scheduler
684de04118, notesafb2260491, chan9a1e142bbc,47d6af2f68,6a76bca33f, semaphoresa6950fe0f9,ebac0e6f30, timers9601abaf8b, select1d8fa7fa5d, netpoll91a670d179, cgocallc08d8834dd, forcegc helper42486ffc5d, cpuprofac49e6735b, mprof548d0805f7, mallocgcbffb0590c1,funcPC0e07f1c99f,getgcmask, Gosched5d40742728, newproc1 on M stack6ed58c2962,runtime.initrun1d0c89a454, goroutine start/stop at safepoints56bd176e1d,entersyscallsafe for stack splits5ea69978fd. - Goroutine and M lifecycle: caches, ids, LockOSThread, Goexit, cgo extra Ms, deadlock detection — Done: ids start at 1
aa76377423; goroutine locked marker in crash report07f6f313a9; per-P defer pool1ba04c171a1.3 (1.3). - Stop-the-world, safe points and GC–scheduler interaction — Done: start/stop individual goroutines at GC safepoints
56bd176e1d.
Other changes
- Runtime-level pprof/cpuprof bug fixes internal —
e0f08b938a,f595f834be,7ed8723d49. - Misc internal —
8fcdc70c5e(GODEBUG invalidptr),99080c4b6f,1d2955a2af(chan size rounding),6c934238c9(minimum stack 2K),45143aeca4,70b2da98ca. - C-to-Go conversion mop-up internal —
aac7f1a0d6,e03bce158f,8bca148a3e,30940cfad6(no acquirem on malloc fast path),d21638b5ec,6179aca548,2c1fde07ac,e77c2fe313,649c83530a,503bcd464e,005806cab1,8620e2b04e,a09e61395e,c01c2c8895,15a5c35cec,91baf5c65d(Gosched to Go),44753479c6,c3b5db895b,cd2f8356ce,6c007bb065,b83d8bd0b8(dedicated scavenger thread removed),21a4bdef2f. - Forcegc and scheduler robustness internal —
9aa7d136f5,176c44699b,93805d711c,7283e08cbf,6ad16c4a48,1d550b87db,99e9bac8c4,b02450da02,8422d1ea65,d3be3daafe,0603fbb01c,4534fdb144,0f4b53c1c2,97c8b24d01,76f1b901db,101c00a44f,16c59acb97,9a5654abef,8c2484ec11.
Data structures and type metadata
From Runtime data structures and type metadata (Go 1.0–1.17)
The C-to-Go conversion of maps, slices, hashing, interfaces and printing; the 2-bit GC type info; direct-interface policy moved into the compiler; random start bucket for iteration; 3-word Value; reflect call-frame cache.
- Hash map core: from the first hashmap.c to the 8-entry bucket design — Done: map implementation converted to Go (
0c6b55e76b), constants moved from header to map type (668a55a882),hmaptype size verified (fe3ee5741d), pass correct size to malloc for the new GC (7bcbdbd904). Left open: “room for improvement (saving space so we can use nosplit, and removing the requirement for hash/eq stubs)”. - Map growth, iteration order, overflow buckets and GC interaction — Done: random starting bucket for bigger maps (
55c458e05f,251daf8650). - Map fast paths and compiler/runtime specialization — Done: fast routines in Go (
0c6b55e76b). - Hash functions and algorithm tables: memhash, AES hash, fallback hash — Done: hash in Go (
a2a9768414,ea3ac6ba75), better interface/float hash (f098a29630,5fbcdb2661), equal in Go (7aa4e5ac5f), NaCl aeshash off (18ab35f7ba). - Compiler-generated equality and hash functions — Done: alg generated after dowidth (
8d47b08255). - Runtime type descriptors: layout, shrinking and name encoding — Done: sparse 2-bit GC type info (
cd17a717f9), direct-iface flag in kind (1806a5732b), unrolled GC bitmask in reflect (3cf9acccae),Type.Comparable(a325f4f2b3), type.go duplicate removed (81674f3135). - Interface values, itabs and type assertions — Done: direct-iface decision in compiler (
1806a5732b), iface in Go (483cb61921,b53b47f5ac), reflect interface allocation type (7b9c5ec24b: GC saw empty-interface layout for non-empty interface),x.(T)for 0-byte T (d646040fd1). - reflect redesign: from string parsing to Type/Value structs — Done: 3-word Value (
a1616d4a32),Type.Comparable(a325f4f2b3), fastFieldByIndex(94950afdf8), struct size includes trailing padding (4e1d196543), memmove shared with runtime (b78d7b75c7), a few microoptimizations (0d81b72e1b). - reflect.Call, MakeFunc, method values and argument-frame GC precision — Done:
sync.Poolframe cache (67f8a813161.5), stub arg maps in traceback (f0d44dbeaf),assignTo/cvtT2Iallocate correct type (7b9c5ec24b). - reflect performance, caches and API additions — Done: three-word Value, FieldByIndex fast path, microoptimizations (
a1616d4a32,94950afdf8,0d81b72e1b). - memmove, memclr, duff routines and pointer-write atomicity — Done: amd64 memmove (
a712e20a1d), no pointless jmp (bc9e160443),memclrBytesin Go (68f91aea57), reflect uses runtime memmove (b78d7b75c7). - internal/bytealg and string/byte comparison primitives — Done: compare only to min length (
5ea131f442). - Slices and append: growslice, makeslice and string/slice conversions — Done: Go port (
cc9ec52d73), correct malloc size (7bcbdbd904). - Strings: concatenation, conversion and printing helpers — Done: print in Go (
721c8735df,597b266eaf,ef64d9ffcc,d8cbbe6802),gostringnocopyupdates maxstring (bcd36e8857), concatstring panic usesgothrow(fa5f86281e). - Soft-float, 64-bit division and complex arithmetic helpers — Done: 64-bit division, complex division and conversions in Go (
d11bb3b177,c403af83a6,32b3a48ea8,0eaea6010a), nil pointer in softfloat (4b3906fec3). - C-to-Go conversion of runtime data-structure code — Done: conversions listed above (
0c6b55e76b,cc9ec52d73,a2a9768414,7aa4e5ac5f,483cb61921,b53b47f5ac,68f91aea57,d11bb3b177),errorCStringadjusted to avoid allocation (48452a276d).
Other changes
- Reflect trampoline and funcPC internal —
6baf173b67,0e07f1c99f. - Reflect correctness internal —
Value.Stringon methods (dd8f29e3fe), IsValid vs Kind afterElemof nil interface (62d3202aaa), gc[0]/gc[1] type-punning removed (18172c42ff),runetocharreconstituted forgostringw(0f4b53c1c2), NOPTR global (d514e2915c), build fixes of the C-to-Go conversion (53304558f9,8ee2a6658b,433d643732,6f19fd438e,ee6c6d96b6,8b7da4de48).
Diagnostics and knobs
From Diagnostics and knobs (Go 1.0–1.17)
Runtime converted from C to Go reaches profiling (cpuprof, MemProfile, traceback) and race code.
- Race detector integration — Done: runtime converted to Go-compatible race handling, ignoring accesses on g0/gsignal (
467a6d28be); writebarrier dst argument instrumented (d78823168f); undefined behaviour inracewalk.cfixed (1f5800673b). Left open: nothing noted. - CPU profiler and runtime/pprof writers (legacy format to compressed protobuf) — Done:
MemProfile,BlockProfile,ThreadCreateProfileconverted to Go (04487d5612); cpuprof converted from C to Go (ac49e6735b); data race in pprof double-checked locking fixed (fe7b29f5fd); profileBucketsub-structs named (a9cef4952f); no tracing pastjmpdeferon arm (597f87c997). Left open: nothing noted. - GODEBUG, runtime/debug, debug log and traceback knobs — Done: functions of
runtime/debugconverted to Go (ef50462378); exported runtime functions shown in stack traces (54245cba1f);gentracebackof self on the user stack forbidden because it may grow the stack (39bcbb353c);Stackfixes (a8c5e87b1e,9a5654abef). Left open: nothing noted. - Traceback correctness and inlining (diagnostic output) — Done: traceback converted from C to Go (
fa2af441f1); arm trap and unexpected-pc fixes (d889f5f01e,e5e547c71f);newproc1on M stack (6ed58c2962). Left open: nothing noted.
Other changes
- Windows fixes internal —
sigtrampPCand build (996835887c,60be96217d). - C sources prohibited user-visible —
cmd/gorejects C files unless cgo is used (a0785a53ad); static-marking,$sym(SB), andnaclflakiness (28cf62ed85,d89cd24857,84a36434d9); type kind mask (1e0b378905);Stackdeadlock (50bc3d5bbc1.5, 1.5). - mprof.goc pasted as comments internal — Pasted mprof.goc into mprof.go as comments during conversion to Go. (
4dba769b73)
OS layer, stacks and panics
From OS interface, stacks and panics (Go 1.0–1.4)
Stack copying becomes the only mechanism with a 2 KB minimum; panic/defer, symtab, signal queue and locks converted to Go under the new C calling convention; Android and NaCl/ARM; PC/traceback semantics for Callers.
- Segmented stacks to contiguous (copied) stacks — Done: single contiguous stack with
(lo, hi)bounds15b76ad94b; 2 KB minimum6c934238c9;StackCopyAlwaysstress mode toggled on/off several times during the conversion (277ef8fa07off,318294286aon,176020e1b1off after a windows/amd64 failure incopystack,815a843b6aon, finally assumed by15b76ad94b);f8f630f5ecusesreflect.callin panics instead ofnewstackcall;0f99a91bb5lets the copier update Panic structs;47f251c1ce/1b6807bb06make cgo cope with a moved G stack;59dd20f4d3fixes Windows syscalls for copying stacks; Gdead stack freeing92eb1e1600. Left open: nothing noted beyond later fixes (a shrink/netpoll race was still fixed on the release branch). - Stack-split prologue, nosplit budget and C-on-Go-stack detection — Done:
fe91006a02and397bdb216fenlarge the nosplit area,c81a0ed3c5C-on-Go-stack detection,32ecf57d22,d16a2ad09b,12308d5a0b,99f7df0598,653fb6d872,40dd6bf38e;9198ed4bd6. Left open: the dynamic check only catches code that executes. - Panic, defer, recover and Goexit — Done: full conversion to Go (
f44073785a,8217b4a203,3a3d47db37,523aa93288,7006aafdcd,f8f630f5ec);8473695797;f95beae61d;15274e5c9b;0306478fe5;36207a91d3,060a988011;c4efaac15dfixes unrecovered panic on an external (cgo) thread;7bcbdbd904fixes the size passed to malloc for Panic. Left open:recoverstill depends on argp arithmetic. - Tracebacks, crash output and GOTRACEBACK — Done:
a22c11b995,a5a0733144,3de7ba1873,7ba41e9972,d16a2ad09b,597f87c997(no trace past jmpdefer on ARM),6fb9d50d15more detail on adjustframe crash,b3d5a695a6diagnostics for non-copyable frames. Left open: nothing noted. - Symbol tables, pclntab and runtime.Caller/FuncForPC — Done: Go symtab
0be59730fd,97f8386af7; FUNCDATA holes3d128dbf96; ftab endianness3e62d2184a; Left open: nothing noted. - Signals: handling, os/signal, foreign threads — Done: sigqueue in Go
651d0cf204,81ed684a71;201cfe4afbruns the Windows sighandler on g0;c548cc2ec8fixes Windows handlers;de14137b4fdrops SA_RESTORER on ARM;d7b678b2caSolaris sigtramp register restore. Left open: nothing noted. - Threads, locks and the OS scheduler interface — Done:
3a7f6646cflock.c converted to Go; the Lock to Mutex rename (fee7c69c6c);df75f082d3makesusleep/osyieldcallable from a cgo callback;88d53ddb17releases Windows thread handle in unminit;9f012e1002callsrforkon the scheduler stack on Plan 9;b143feb143int64 reconstruction in semasleep. Left open:* nothing noted. - cgo runtime support and non-Go threads — Done:
54138e1ac3,cb767247ca,47f251c1ce,1b6807bb06,1aa65fe8d4,b4bfa6c964(save g to TLS more aggressively: callback thread with TLS holding g0 instead of curg faulted into sigpanic with wrong g). Left open: nothing noted. - TLS, g/m registers and shared-library linking — Done:
a36348008c,12b990ba7d,c1c8c3c8c4export_rt0for android,72faffbc70;89f185fe8aremoves extern register m;4769f87e0d;0b36211cfb. Left open: nothing noted. - Clocks, vDSO and timers — Done:
74b62b4864,13d0b82bc8,1db4c8dc41,2fe9482343,138b5ccd12,b60d5e12e9warns thatcputicksmay not be monotonic. Left open: nothing noted. - Windows runtime port — Done:
74b62b4864,a1778ec146,17a108ba07,e9ecd4aec5,38ce599494,2eccf0d18f,73f5010dc6,59dd20f4d3,201cfe4afb,2c780a35b9,f8474fa01d,2ed209eaf5. Left open: nothing noted. - Platform ports: OS and architecture matrix — Done: user-visible Android
a36348008c,12b990ba7d,c1c8c3c8c4; NaCl/ARMd1177ed40d; Plan 9/amd64decd810945;a84e3ad198(nsec syscall on Plan 9). Left open: nothing noted. - Integrated network poller: OS back-ends — Done:
91a670d179. Left open: Windows and Solaris code remained C. - Runtime C-to-Go conversion and the Go calling convention in C (1.4) — Done:
25f6b02ab0,012ceed914,4aa50434e1,d4df63c3e8,3a7f6646cf,50199d7b35,47d6af2f68,39ffa8be78,38ce599494,b4c28d9180,0a7c7ac80e,9a75c74836,f611ae1c75,d2574e2adb,ddce7c35f4;c007ce824dmoves package sources fromsrc/pkgtosrc. Left open: Windows/Solaris netpoll still C;onMbridge between Go and C.
Other changes
- Port build fixes during the C-to-Go conversion internal — Plan 9 (
a6999c8845,c5b2c370c6,9e36092697,b3de7f28a8,b1d0152997,f9829e92e1,2302b21bbe), NaCl (3a3f8993ce,f9b9ecc5ee,add7b22010,dae8038639,8a7597fd7a), Solaris (997809c809,6c59cdcf34,e8a74dcad9), OpenBSD/NetBSD/FreeBSD/Linux (4dbd0dbf15,2758cb75f0,b70bc22cd0,29225211e1,d703ac338e,a287567d3c), ARM (22af2b8ee0,45c819b2da,c486d4130d), windows/amd64 (3e9c7a8a1d,f950a14bb5,2b1659b57d,418b39d436,bf13b711bd), cgo (b2c75ae2be,f7a8adbd51). - Conversion adjustments and pointer hygiene internal —
gogetcallerpc(14c8143c31), alignment (5035750f23,34655223ef,9aa1e9afda), global variables marked NOPTR (5dab2da954,75cca0526d,3c94b1d305),aff7883d9a(assembler macros),5a008acec1,61b1d3a719,e4f3db3852,6c67dd90f7,e5a06ccd37,3306d119b0(unify fastrand1/2),e3edfea07f,f545b05aae,db58ab96fa,9e7c22938c,857d55a3f9and5103500d13(nosplit for freedefer/deferclass/endcgo),b78d7b75c7(reflect uses runtime memmove),a7c6d89166,5d5312c5dd(NewCallback parameter checking),dcc4a674d8,b02450da02(zero dead or pointer-looking values),cb6f5ac0b0(remove hand-written reflectcall bitmaps). - Go source layout internal — packages moved from
src/pkgtosrc(c007ce824d,de4964a78c);golang.org/x/...imports (7f0be1f781). - os.Unsetenv user-visible —
85cdc49e8a. - Misc internal — fake time (
2fe9482343), eqstring in assembly (b36ed9056f), select descriptor on stack (40d7d5a656), GC bitmap byte array (ff3fa1b32d), heap dump bitmap5b110c7b08,d1b2913710,9d06cfc810,b3f224b280,20d9cc4bb0. - Cleanups and heap dump format internal — A few runtime cleanups and an updated heap dump format for 1.4. (
526319830b,6ea3746adf)
Compiler frontend
From Compiler frontend (Go 1.1–1.9)
Write barriers emitted (fcb4cabba4), pointer-only interface data word (950ad4fa2b), for range x {}, escape-analysis soundness fix for stack copying, go:nosplit.
- Parser: from yacc to a hand-written recursive-descent parser — Done: user-visible
8d504c4e97for range x {;2565b5c060drops the parenthesization restriction for receiver types. - Escape analysis and stack allocation — Done:
fe3c913443,00d2f916ad,a3416cf5cd-adjacent write-barrier work lives in the GC thread. Left open: result mapping is not recorded; imprecise. - Closures, method values and variable capture — Done:
6c0bcb18631.3 (method value closures on nacl, 1.3). - Language changes and rules as implemented in the compiler — Done: user-visible
8d504c4e97,7f40e5e6e5,55df81d37f,db4dad7fd7,93fcb92257,fe8f799ef7,870f4e190c,2565b5c060. - Static initialization, composite literals and
init— Done:cfafa9f4cb,3c40ee0fe0(simplify explicit zeroing). - Walk-level lowering and runtime-call optimisations — Done:
61dca94e10,4af796fb6e(runtime.hex printing type). - Write barriers, precise stacks and liveness (compiler side) — Done:
fcb4cabba4,a3416cf5cd,3c40ee0fe0,1552e62d70,950ad4fa2b,75b72b1b27,7aa3031eba. Left open: elision ofx = x[0:y]andappendis a 1.4-only simplification; “for Go 1.5, will need to change the compilation” (1552e62d70). - Pragmas, directives and compiler flags — Done:
516d9ef53b.
Other changes
- Misc compiler fixes internal —
9e04ff7953,ae027f52fe,689995a73e,9c504696f4,6a2e844f51,8d61334dd5,43c4287b25,53c66543e0,52e9bcafe1,ff6d0a4df4,5e56854599,516d9ef53b.
Middle end and SSA optimizer
From Middle end and SSA optimizer (Go 1.0–1.9)
Escape-analysis soundness fixes motivated by stack copying (indirect-of-param), write barrier prep (threads: escape analysis).
- Escape analysis (esc.c → esc.go) — Done:
fe3c913443(the indirect-of-param fix),775ab8eeaa,f20e4d5ecb,0f2cde8bdc,d2204e6c0e,337fe4134f. Left open: per-result mapping and indirection counts (message). - Inlining (inl.c → inl.go) — Done:
eb54079264(liveness for address-taken variables in inlined functions). Left open: nothing noted. - Order, walk and temporary lifetimes (order.c, walk.c) — Done:
9aefdc8028,5225854b74,e024ed5ca4,454d1b0e8b. Left open: nothing noted.
Other changes
- Fixes internal —
eb54079264,88b78b41c5,897f7a31fa,20e97677fd,8e89f87158,6b54cc93d0.
Backends and assemblers
From Backends and assemblers (Go 1.0–1.6)
Preparation for translation (c2go annotations), plan9/amd64 and nacl/arm in liblink, assembly-function stack maps, small-struct registerization. Threads: liblink, C compilers, stack maps.
- Per-architecture compilers 6g/8g/5g/9g and the shared gc code generator — Done: registerize small structs/arrays in 5g and 8g (
527ae57e65); explicit zeroing simplified so*x = T{}needs no write barrier (3c40ee0fe0); fatal “out of registers” (c1c5d479bd); 5g does not make register variables for directly called functions (bb4a358af3). - Register allocation and the peephole optimizer (reg.c, peep.c) — Done: register variables for small structs/arrays on 5g/8g (
527ae57e65); registerized addr nodes cleared so full registerized temporaries stop reserving stack (be2ad1d7f5); optimizer failure fatal in the C compilers (3147d2c4ee). - Expression and statement code quality in 6g/8g/5g (division, bounds checks, loops, slices, interfaces) — Done: explicit zeroing without write barrier, MOVs instead of repeated STOSQ (
3c40ee0fe0);extern = <N>code (0edafefc36); no address-as-constant in amd64 instructions (ce35994d4e). - Stack frames, pointer maps and liveness analysis in the compiler — Done: local type information is emitted explicitly (see the 1.1 note on
1d5dc4fd481.1,43c04ba1b81.1,aa3efb28f01.1);args_stackmapfor assembly functions from Go prototypes (99f7df0598), slices/strings scanned like pointers (613383c765), all G frames copyable (00365b13b4),argsizePCDATA dropped (68c1c6afa0), auxiliary symbols marked pointer-free (8b20e7bb7e), runtime package decls never heap-promoted (064acace5b), liveness ~10x faster (7aa3031eba), invalid GC pointer crashes (11e53e46a6), emit code for extern init (0edafefc36). - Stack frame layout, prologues, stack split and frame pointers — Done: ARM wrapper prologue (
fb818eab7f). - Zeroing and copying: Duff’s device, REP, unaligned moves and AVX2 runtime assembly — Done:
3c40ee0fe0; - liblink: a shared assembler/linker library — Done: preliminary plan9/amd64 (
decd810945), nacl/arm (783bcba84d),LinkArch.textflag()instead ofthecharswitches (3c24b60fd3), big-endian support (08ee2661f2), shorter zeroing-register encoding (24db881689), MOVBQZX as MOVZBL (bbc6bb9a99), literal-word comparison on ARM (b916dc1992), way to avoid pc-relative addressing for Solaris (4516a60062), DATA must be offset-ordered with no overlap (5e6bd29c2c),%^verb andC_*constants moved (d69d0fe92b), arm MRC replacement generated in liblink (0b36211cfb),gotosrewritten for translation (8e0e09ae7d),fb818eab7f,20a5de9eb6,a6feaf3aff,ae027f52fe. - The Plan 9 C compilers (cc, 5c/6c/8c) in the Go toolchain — Done:
Eface→interface{}(948bb9150e), no tag-less structs (3ffd29fb2c), make optimizer failure fatal (3147d2c4ee), diagnose Go calling C (0bb14d74f1), stop emittingargsizePCDATA (68c1c6afa0),#pragma pack offerror (86c4c4f00c). Left open: the runtime still contained C (c2go translation was the plan). - Assemblers: 5a/6a/8a/9a and the Go cmd/asm — Done:
AJxxcondition-code docs (c6442c994a), SETPC encoding (a6feaf3aff). - C→Go translation of the toolchain (liblink, assemblers, compilers; dev.cc) — Done: c2go annotations (
ebce79446d). Left open: the actual conversion. - Native Client (nacl/386, nacl/amd64p32, nacl/arm) and amd64p32 in the toolchain — Done: nacl/arm (
783bcba84d),ac0e12d158,8a7597fd7a. - Position-independent code, dynamic linking and TLS in the assemblers — Done:
4516a60062.
Other changes
- Source tree move internal — build adjustments for the move from
src/pkgtosrc(220a6de47e,3511454e13). - Runtime escape is an error internal —
337fe4134f. - -X flag, big endian, Solaris internal —
df781cc4ab,08ee2661f2,4516a60062. - Heap-bit GC prerequisites internal —
613383c765,8b20e7bb7e,064acace5b. - ARM div/mod internal — avoid clobbering R12 in div/mod routines (
f666167572). - Remaining small code-generation, optimizer and tooling fixes (4 commits) internal — per-operator and per-back-end bug fixes and cleanups that do not carry design of their own: liblink and arm fixes, cap(chan) register, undefined-behaviour fixes in reg.c and bv.c, heap buffer overflow (
1ec56062ef,055dfc204c,a57dda74d9,53056c37c2) - Build, portability and warning fixes (5 commits) internal — Plan 9/gcc/clang warnings, yacc/bison, format verbs, buffer sizes, output-file handling and Windows paths in the compilers/assemblers/liblink (
90c146f390,afb6221bf7,e8d65b92d7,4a40fb1979,cbf97d9103)
Linker and object files
From Linker and object files (Go 1.0–1.9)
Go-specific DWARF type info and fixed frame tables, linker-defined symbols moved into package runtime, Android TLS, and a quiet cycle in the linker core.
- Go symbol table, pc/line table and function metadata (gosymtab, pclntab, findfunc) — Done: linker-defined symbols (
runtime.pclntab,runtime.etextetc.) moved into package runtime (2c110a11e0); PC deltas in DWARF line table fixed (507afa68c5). - Dead code and data elimination — Done: symbols created by
-Xno longer automatically marked reachable (f6fc14094a). - DWARF generation in the linker — Done: Go-specific type info (
e1821692ca), array encoding (cddad8affe,74c9cc8394,79b106ec62), frame table fixes (7b0ee53429), struct output change (125d1e9269). - External (host) linking and cgo — Done: hostobj sections marked noptr (
65e2b6f847), diagnostics for Go calling C (0bb14d74f1), clang integrated assembler disabled in cgo (cf9558c8ab), ignore.Linfo_string(82a5e95ccc). - liblink, the object file format and the move into the compilers — Done:
%^formatting and C_* constants moved (d69d0fe92b), pc-relative amd64 addressing (ca85d572d6). - From C to Go: cmd/link — Done:
eae9fee3bffixes zig-zag decoding in the Go skeleton; nothing else notable. Left open: nothing noted. - Architecture and OS ports in the linker (arm, power64, arm64, mips, s390x, nacl, BSDs, Solaris) and trampolines — Done: Android TLS emulation (
12b990ba7d), NaCl fix (a9b2651ade), big-endianaddstrdata(f29bd6c4a4), large link base addresses (9abf0b6e9f). - Build IDs, ABI hashes, flags and determinism — Done: flags documented (
6012ac9b79,c3dbf56a14).
Other changes
- Operator precedence and UB fixes internal —
2c181f0355,41d75933d7,78cc89ce67,f129370b3e,faa223459a,595dcef80a; diagnostics on unaligned symbols (9333fe8e92); cross-linking on Windows hosts (5a40b568d0); ELF build fixes (117a6973cb);goshows program name on crash (13a2c1ca78);fix off-by-one when emitting symbol names(8fe5ef4052). - 386 GOT32 in push internal —
609d996facacceptsR_386_GOT32in push instructions.