diff options
| author | Russ Cox <rsc@golang.org> | 2022-02-03 14:12:08 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2022-04-11 16:34:30 +0000 |
| commit | 19309779ac5e2f5a2fd3cbb34421dafb2855ac21 (patch) | |
| tree | 67dfd3e5d96250325e383183f95b6f5fe1968514 /src/runtime | |
| parent | 017933163ab6a2b254f0310c61b57db65cded92e (diff) | |
| download | go-19309779ac5e2f5a2fd3cbb34421dafb2855ac21.tar.xz | |
all: gofmt main repo
[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]
Run the updated gofmt, which reformats doc comments,
on the main repository. Vendored files are excluded.
For #51082.
Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407
Reviewed-on: https://go-review.googlesource.com/c/go/+/384268
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime')
31 files changed, 182 insertions, 163 deletions
diff --git a/src/runtime/chan.go b/src/runtime/chan.go index 308667d7bc..6511d80c2c 100644 --- a/src/runtime/chan.go +++ b/src/runtime/chan.go @@ -596,10 +596,11 @@ func chanrecv(c *hchan, ep unsafe.Pointer, block bool) (selected, received bool) // recv processes a receive operation on a full channel c. // There are 2 parts: -// 1) The value sent by the sender sg is put into the channel +// 1. The value sent by the sender sg is put into the channel // and the sender is woken up to go on its merry way. -// 2) The value received by the receiver (the current G) is +// 2. The value received by the receiver (the current G) is // written to ep. +// // For synchronous channels, both values are the same. // For asynchronous channels, the receiver gets its data from // the channel buffer and the sender's data is put in the diff --git a/src/runtime/chan_test.go b/src/runtime/chan_test.go index 9471d4596c..1e0aa53213 100644 --- a/src/runtime/chan_test.go +++ b/src/runtime/chan_test.go @@ -226,11 +226,13 @@ func TestNonblockRecvRace(t *testing.T) { // This test checks that select acts on the state of the channels at one // moment in the execution, not over a smeared time window. // In the test, one goroutine does: +// // create c1, c2 // make c1 ready for receiving // create second goroutine // make c2 ready for receiving // make c1 no longer ready for receiving (if possible) +// // The second goroutine does a non-blocking select receiving from c1 and c2. // From the time the second goroutine is created, at least one of c1 and c2 // is always ready for receiving, so the select in the second goroutine must diff --git a/src/runtime/debug.go b/src/runtime/debug.go index 2703a0ce01..0ab23e0eb7 100644 --- a/src/runtime/debug.go +++ b/src/runtime/debug.go @@ -69,7 +69,7 @@ func debug_modinfo() string { // preemption points. To apply this to all preemption points in the // runtime and runtime-like code, use the following in bash or zsh: // -// X=(-{gc,asm}flags={runtime/...,reflect,sync}=-d=maymorestack=runtime.mayMoreStackPreempt) GOFLAGS=${X[@]} +// X=(-{gc,asm}flags={runtime/...,reflect,sync}=-d=maymorestack=runtime.mayMoreStackPreempt) GOFLAGS=${X[@]} // // This must be deeply nosplit because it is called from a function // prologue before the stack is set up and because the compiler will @@ -79,10 +79,9 @@ func debug_modinfo() string { // Ideally it should also use very little stack because the linker // doesn't currently account for this in nosplit stack depth checking. // -//go:nosplit -// // Ensure mayMoreStackPreempt can be called for all ABIs. // +//go:nosplit //go:linkname mayMoreStackPreempt func mayMoreStackPreempt() { // Don't do anything on the g0 or gsignal stack. diff --git a/src/runtime/debug/garbage.go b/src/runtime/debug/garbage.go index 00f92c3ddf..ce4bb10407 100644 --- a/src/runtime/debug/garbage.go +++ b/src/runtime/debug/garbage.go @@ -142,7 +142,9 @@ func SetMaxThreads(threads int) int { // dramatic situations; SetPanicOnFault allows such programs to request // that the runtime trigger only a panic, not a crash. // The runtime.Error that the runtime panics with may have an additional method: -// Addr() uintptr +// +// Addr() uintptr +// // If that method exists, it returns the memory address which triggered the fault. // The results of Addr are best-effort and the veracity of the result // may depend on the platform. diff --git a/src/runtime/error.go b/src/runtime/error.go index 43114f092e..b11473c634 100644 --- a/src/runtime/error.go +++ b/src/runtime/error.go @@ -53,10 +53,11 @@ func (e *TypeAssertionError) Error() string { ": missing method " + e.missingMethod } -//go:nosplit // itoa converts val to a decimal representation. The result is // written somewhere within buf and the location of the result is returned. // buf must be at least 20 bytes. +// +//go:nosplit func itoa(buf []byte, val uint64) []byte { i := len(buf) - 1 for val >= 10 { diff --git a/src/runtime/extern.go b/src/runtime/extern.go index 39bdd09849..9dd59e0985 100644 --- a/src/runtime/extern.go +++ b/src/runtime/extern.go @@ -8,7 +8,7 @@ such as functions to control goroutines. It also includes the low-level type inf used by the reflect package; see reflect's documentation for the programmable interface to the run-time type system. -Environment Variables +# Environment Variables The following environment variables ($name or %name%, depending on the host operating system) control the run-time behavior of Go programs. The meanings @@ -172,9 +172,9 @@ or the failure is internal to the run-time. GOTRACEBACK=none omits the goroutine stack traces entirely. GOTRACEBACK=single (the default) behaves as described above. GOTRACEBACK=all adds stack traces for all user-created goroutines. -GOTRACEBACK=system is like ``all'' but adds stack frames for run-time functions +GOTRACEBACK=system is like “all” but adds stack frames for run-time functions and shows goroutines created internally by the run-time. -GOTRACEBACK=crash is like ``system'' but crashes in an operating system-specific +GOTRACEBACK=crash is like “system” but crashes in an operating system-specific manner instead of exiting. For example, on Unix systems, the crash raises SIGABRT to trigger a core dump. For historical reasons, the GOTRACEBACK settings 0, 1, and 2 are synonyms for diff --git a/src/runtime/float.go b/src/runtime/float.go index 7aef78a2ec..c80c8b7abf 100644 --- a/src/runtime/float.go +++ b/src/runtime/float.go @@ -27,6 +27,7 @@ func isInf(f float64) bool { // Abs returns the absolute value of x. // // Special cases are: +// // Abs(±Inf) = +Inf // Abs(NaN) = NaN func abs(x float64) float64 { diff --git a/src/runtime/lock_sema.go b/src/runtime/lock_sema.go index 6961c2ea9b..c5e8cfe24a 100644 --- a/src/runtime/lock_sema.go +++ b/src/runtime/lock_sema.go @@ -96,8 +96,9 @@ func unlock(l *mutex) { unlockWithRank(l) } -//go:nowritebarrier // We might not be holding a p in this code. +// +//go:nowritebarrier func unlock2(l *mutex) { gp := getg() var mp *m diff --git a/src/runtime/map_test.go b/src/runtime/map_test.go index 0c83dd4ddf..5c458b4a49 100644 --- a/src/runtime/map_test.go +++ b/src/runtime/map_test.go @@ -29,8 +29,9 @@ func TestHmapSize(t *testing.T) { } // negative zero is a good test because: -// 1) 0 and -0 are equal, yet have distinct representations. -// 2) 0 is represented as all zeros, -0 isn't. +// 1. 0 and -0 are equal, yet have distinct representations. +// 2. 0 is represented as all zeros, -0 isn't. +// // I'm not sure the language spec actually requires this behavior, // but it's what the current map implementation does. func TestNegativeZero(t *testing.T) { diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go index 665a9c6f63..a3a6590d65 100644 --- a/src/runtime/mbitmap.go +++ b/src/runtime/mbitmap.go @@ -99,10 +99,9 @@ func add1(p *byte) *byte { // subtract1 returns the byte pointer p-1. // -//go:nowritebarrier -// // nosplit because it is used during write barriers and must not be preempted. // +//go:nowritebarrier //go:nosplit func subtract1(p *byte) *byte { // Note: wrote out full expression instead of calling subtractb(p, 1) diff --git a/src/runtime/metrics/doc.go b/src/runtime/metrics/doc.go index 91ef03072d..63bea8c448 100644 --- a/src/runtime/metrics/doc.go +++ b/src/runtime/metrics/doc.go @@ -11,7 +11,7 @@ The set of metrics defined by this package may evolve as the runtime itself evolves, and also enables variation across Go implementations, whose relevant metric sets may not intersect. -Interface +# Interface Metrics are designated by a string key, rather than, for example, a field name in a struct. The full list of supported metrics is always available in the slice of @@ -30,7 +30,7 @@ In the interest of not breaking users of this package, the "kind" for a given me is guaranteed not to change. If it must change, then a new metric will be introduced with a new key and a new "kind." -Metric key format +# Metric key format As mentioned earlier, metric keys are strings. Their format is simple and well-defined, designed to be both human and machine readable. It is split into two components, @@ -41,13 +41,13 @@ did also, and a new key should be introduced. For more details on the precise definition of the metric key's path and unit formats, see the documentation of the Name field of the Description struct. -A note about floats +# A note about floats This package supports metrics whose values have a floating-point representation. In order to improve ease-of-use, this package promises to never produce the following classes of floating-point values: NaN, infinity. -Supported metrics +# Supported metrics Below is the full list of supported metrics, ordered lexicographically. diff --git a/src/runtime/mfinal.go b/src/runtime/mfinal.go index 979e0b4a2c..bf537b417c 100644 --- a/src/runtime/mfinal.go +++ b/src/runtime/mfinal.go @@ -447,16 +447,17 @@ okarg: // before the point in the program where KeepAlive is called. // // A very simplified example showing where KeepAlive is required: -// type File struct { d int } -// d, err := syscall.Open("/file/path", syscall.O_RDONLY, 0) -// // ... do something if err != nil ... -// p := &File{d} -// runtime.SetFinalizer(p, func(p *File) { syscall.Close(p.d) }) -// var buf [10]byte -// n, err := syscall.Read(p.d, buf[:]) -// // Ensure p is not finalized until Read returns. -// runtime.KeepAlive(p) -// // No more uses of p after this point. +// +// type File struct { d int } +// d, err := syscall.Open("/file/path", syscall.O_RDONLY, 0) +// // ... do something if err != nil ... +// p := &File{d} +// runtime.SetFinalizer(p, func(p *File) { syscall.Close(p.d) }) +// var buf [10]byte +// n, err := syscall.Read(p.d, buf[:]) +// // Ensure p is not finalized until Read returns. +// runtime.KeepAlive(p) +// // No more uses of p after this point. // // Without the KeepAlive call, the finalizer could run at the start of // syscall.Read, closing the file descriptor before syscall.Read makes diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index ba679e0af5..9f17e47488 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -760,7 +760,7 @@ var gcMarkDoneFlushed uint32 // This should be called when all local mark work has been drained and // there are no remaining workers. Specifically, when // -// work.nwait == work.nproc && !gcMarkWorkAvailable(p) +// work.nwait == work.nproc && !gcMarkWorkAvailable(p) // // The calling context must be preemptible. // diff --git a/src/runtime/mgcwork.go b/src/runtime/mgcwork.go index 5c47006cc2..424de2fcca 100644 --- a/src/runtime/mgcwork.go +++ b/src/runtime/mgcwork.go @@ -44,9 +44,9 @@ func init() { // // A gcWork can be used on the stack as follows: // -// (preemption must be disabled) -// gcw := &getg().m.p.ptr().gcw -// .. call gcw.put() to produce and gcw.tryGet() to consume .. +// (preemption must be disabled) +// gcw := &getg().m.p.ptr().gcw +// .. call gcw.put() to produce and gcw.tryGet() to consume .. // // It's important that any use of gcWork during the mark phase prevent // the garbage collector from transitioning to mark termination since diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index a8a1e61ef2..d99363d991 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -319,16 +319,16 @@ type arenaHint struct { // mSpanManual, or mSpanFree. Transitions between these states are // constrained as follows: // -// * A span may transition from free to in-use or manual during any GC -// phase. +// - A span may transition from free to in-use or manual during any GC +// phase. // -// * During sweeping (gcphase == _GCoff), a span may transition from -// in-use to free (as a result of sweeping) or manual to free (as a -// result of stacks being freed). +// - During sweeping (gcphase == _GCoff), a span may transition from +// in-use to free (as a result of sweeping) or manual to free (as a +// result of stacks being freed). // -// * During GC (gcphase != _GCoff), a span *must not* transition from -// manual or in-use to free. Because concurrent GC may read a pointer -// and then look up its span, the span state must be monotonic. +// - During GC (gcphase != _GCoff), a span *must not* transition from +// manual or in-use to free. Because concurrent GC may read a pointer +// and then look up its span, the span state must be monotonic. // // Setting mspan.state to mSpanInUse or mSpanManual must be done // atomically and only after all other span fields are valid. diff --git a/src/runtime/mpagealloc_64bit.go b/src/runtime/mpagealloc_64bit.go index 1bacfbe0fa..76b54baa55 100644 --- a/src/runtime/mpagealloc_64bit.go +++ b/src/runtime/mpagealloc_64bit.go @@ -41,7 +41,8 @@ var levelBits = [summaryLevels]uint{ // // With levelShift, one can compute the index of the summary at level l related to a // pointer p by doing: -// p >> levelShift[l] +// +// p >> levelShift[l] var levelShift = [summaryLevels]uint{ heapAddrBits - summaryL0Bits, heapAddrBits - summaryL0Bits - 1*summaryLevelBits, diff --git a/src/runtime/mwbbuf.go b/src/runtime/mwbbuf.go index 78d9382620..39ce0b46a9 100644 --- a/src/runtime/mwbbuf.go +++ b/src/runtime/mwbbuf.go @@ -116,11 +116,11 @@ func (b *wbBuf) empty() bool { // putFast adds old and new to the write barrier buffer and returns // false if a flush is necessary. Callers should use this as: // -// buf := &getg().m.p.ptr().wbBuf -// if !buf.putFast(old, new) { -// wbBufFlush(...) -// } -// ... actual memory write ... +// buf := &getg().m.p.ptr().wbBuf +// if !buf.putFast(old, new) { +// wbBufFlush(...) +// } +// ... actual memory write ... // // The arguments to wbBufFlush depend on whether the caller is doing // its own cgo pointer checks. If it is, then this can be diff --git a/src/runtime/netpoll.go b/src/runtime/netpoll.go index 6dcc60953f..ac6bc89530 100644 --- a/src/runtime/netpoll.go +++ b/src/runtime/netpoll.go @@ -47,16 +47,17 @@ const ( // pollDesc contains 2 binary semaphores, rg and wg, to park reader and writer // goroutines respectively. The semaphore can be in the following states: -// pdReady - io readiness notification is pending; -// a goroutine consumes the notification by changing the state to nil. -// pdWait - a goroutine prepares to park on the semaphore, but not yet parked; -// the goroutine commits to park by changing the state to G pointer, -// or, alternatively, concurrent io notification changes the state to pdReady, -// or, alternatively, concurrent timeout/close changes the state to nil. -// G pointer - the goroutine is blocked on the semaphore; -// io notification or timeout/close changes the state to pdReady or nil respectively -// and unparks the goroutine. -// nil - none of the above. +// +// pdReady - io readiness notification is pending; +// a goroutine consumes the notification by changing the state to nil. +// pdWait - a goroutine prepares to park on the semaphore, but not yet parked; +// the goroutine commits to park by changing the state to G pointer, +// or, alternatively, concurrent io notification changes the state to pdReady, +// or, alternatively, concurrent timeout/close changes the state to nil. +// G pointer - the goroutine is blocked on the semaphore; +// io notification or timeout/close changes the state to pdReady or nil respectively +// and unparks the goroutine. +// nil - none of the above. const ( pdReady uintptr = 1 pdWait uintptr = 2 diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index 812a0b4ad3..a6e7a33191 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -52,7 +52,9 @@ const ( ) // Atomically, +// // if(*addr == val) sleep +// // Might be woken up spuriously; that's allowed. // Don't sleep longer than ns; ns < 0 means forever. // diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go index e3cd6b9d2a..f0b25c131f 100644 --- a/src/runtime/pprof/pprof.go +++ b/src/runtime/pprof/pprof.go @@ -5,7 +5,7 @@ // Package pprof writes runtime profiling data in the format expected // by the pprof visualization tool. // -// Profiling a Go program +// # Profiling a Go program // // The first step to profiling a Go program is to enable profiling. // Support for profiling benchmarks built with the standard testing @@ -13,54 +13,54 @@ // runs benchmarks in the current directory and writes the CPU and // memory profiles to cpu.prof and mem.prof: // -// go test -cpuprofile cpu.prof -memprofile mem.prof -bench . +// go test -cpuprofile cpu.prof -memprofile mem.prof -bench . // // To add equivalent profiling support to a standalone program, add // code like the following to your main function: // -// var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`") -// var memprofile = flag.String("memprofile", "", "write memory profile to `file`") +// var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`") +// var memprofile = flag.String("memprofile", "", "write memory profile to `file`") // -// func main() { -// flag.Parse() -// if *cpuprofile != "" { -// f, err := os.Create(*cpuprofile) -// if err != nil { -// log.Fatal("could not create CPU profile: ", err) -// } -// defer f.Close() // error handling omitted for example -// if err := pprof.StartCPUProfile(f); err != nil { -// log.Fatal("could not start CPU profile: ", err) -// } -// defer pprof.StopCPUProfile() -// } +// func main() { +// flag.Parse() +// if *cpuprofile != "" { +// f, err := os.Create(*cpuprofile) +// if err != nil { +// log.Fatal("could not create CPU profile: ", err) +// } +// defer f.Close() // error handling omitted for example +// if err := pprof.StartCPUProfile(f); err != nil { +// log.Fatal("could not start CPU profile: ", err) +// } +// defer pprof.StopCPUProfile() +// } // -// // ... rest of the program ... +// // ... rest of the program ... // -// if *memprofile != "" { -// f, err := os.Create(*memprofile) -// if err != nil { -// log.Fatal("could not create memory profile: ", err) -// } -// defer f.Close() // error handling omitted for example -// runtime.GC() // get up-to-date statistics -// if err := pprof.WriteHeapProfile(f); err != nil { -// log.Fatal("could not write memory profile: ", err) -// } -// } -// } +// if *memprofile != "" { +// f, err := os.Create(*memprofile) +// if err != nil { +// log.Fatal("could not create memory profile: ", err) +// } +// defer f.Close() // error handling omitted for example +// runtime.GC() // get up-to-date statistics +// if err := pprof.WriteHeapProfile(f); err != nil { +// log.Fatal("could not write memory profile: ", err) +// } +// } +// } // // There is also a standard HTTP interface to profiling data. Adding // the following line will install handlers under the /debug/pprof/ // URL to download live profiles: // -// import _ "net/http/pprof" +// import _ "net/http/pprof" // // See the net/http/pprof package for more details. // // Profiles can then be visualized with the pprof tool: // -// go tool pprof cpu.prof +// go tool pprof cpu.prof // // There are many commands available from the pprof command line. // Commonly used commands include "top", which prints a summary of the diff --git a/src/runtime/pprof/proto.go b/src/runtime/pprof/proto.go index 68dac42d20..f0769935ae 100644 --- a/src/runtime/pprof/proto.go +++ b/src/runtime/pprof/proto.go @@ -56,9 +56,10 @@ type memMap struct { } // symbolizeFlag keeps track of symbolization result. -// 0 : no symbol lookup was performed -// 1<<0 (lookupTried) : symbol lookup was performed -// 1<<1 (lookupFailed): symbol lookup was performed but failed +// +// 0 : no symbol lookup was performed +// 1<<0 (lookupTried) : symbol lookup was performed +// 1<<1 (lookupFailed): symbol lookup was performed but failed type symbolizeFlag uint8 const ( @@ -507,9 +508,10 @@ func (b *profileBuilder) appendLocsForStack(locs []uint64, stk []uintptr) (newLo // and looking up debug info is not ideal, so we use a heuristic to filter // the fake pcs and restore the inlined and entry functions. Inlined functions // have the following properties: -// Frame's Func is nil (note: also true for non-Go functions), and -// Frame's Entry matches its entry function frame's Entry (note: could also be true for recursive calls and non-Go functions), and -// Frame's Name does not match its entry function frame's name (note: inlined functions cannot be directly recursive). +// +// Frame's Func is nil (note: also true for non-Go functions), and +// Frame's Entry matches its entry function frame's Entry (note: could also be true for recursive calls and non-Go functions), and +// Frame's Name does not match its entry function frame's name (note: inlined functions cannot be directly recursive). // // As reading and processing the pcs in a stack trace one by one (from leaf to the root), // we use pcDeck to temporarily hold the observed pcs and their expanded frames diff --git a/src/runtime/proc.go b/src/runtime/proc.go index ae4440786e..4535f62053 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -1664,9 +1664,9 @@ func forEachP(fn func(*p)) { // runSafePointFn runs the safe point function, if any, for this P. // This should be called like // -// if getg().m.p.runSafePointFn != 0 { -// runSafePointFn() -// } +// if getg().m.p.runSafePointFn != 0 { +// runSafePointFn() +// } // // runSafePointFn must be checked on any transition in to _Pidle or // _Psyscall to avoid a race where forEachP sees that the P is running @@ -5602,11 +5602,11 @@ func (p pMask) clear(id int32) { // // Thus, we get the following effects on timer-stealing in findrunnable: // -// * Idle Ps with no timers when they go idle are never checked in findrunnable -// (for work- or timer-stealing; this is the ideal case). -// * Running Ps must always be checked. -// * Idle Ps whose timers are stolen must continue to be checked until they run -// again, even after timer expiration. +// - Idle Ps with no timers when they go idle are never checked in findrunnable +// (for work- or timer-stealing; this is the ideal case). +// - Running Ps must always be checked. +// - Idle Ps whose timers are stolen must continue to be checked until they run +// again, even after timer expiration. // // When the P starts running again, the mask should be set, as a timer may be // added at any time. diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 54a02173c3..b7df231722 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -151,7 +151,9 @@ const ( // Global pool of spans that have free stacks. // Stacks are assigned an order according to size. -// order = log_2(size/FixedStack) +// +// order = log_2(size/FixedStack) +// // There is a free list for each order. var stackpool [_NumStackOrders]struct { item stackpoolItem diff --git a/src/runtime/string.go b/src/runtime/string.go index bef097c87e..8b20c93fd7 100644 --- a/src/runtime/string.go +++ b/src/runtime/string.go @@ -147,10 +147,10 @@ func rawstringtmp(buf *tmpBuf, l int) (s string, b []byte) { // and otherwise intrinsified by the compiler. // // Some internal compiler optimizations use this function. -// - Used for m[T1{... Tn{..., string(k), ...} ...}] and m[string(k)] -// where k is []byte, T1 to Tn is a nesting of struct and array literals. -// - Used for "<"+string(b)+">" concatenation where b is []byte. -// - Used for string(b)=="foo" comparison where b is []byte. +// - Used for m[T1{... Tn{..., string(k), ...} ...}] and m[string(k)] +// where k is []byte, T1 to Tn is a nesting of struct and array literals. +// - Used for "<"+string(b)+">" concatenation where b is []byte. +// - Used for string(b)=="foo" comparison where b is []byte. func slicebytetostringtmp(ptr *byte, n int) (str string) { if raceenabled && n > 0 { racereadrangepc(unsafe.Pointer(ptr), diff --git a/src/runtime/symtab_test.go b/src/runtime/symtab_test.go index 79a114b02b..1a0c55af97 100644 --- a/src/runtime/symtab_test.go +++ b/src/runtime/symtab_test.go @@ -206,15 +206,15 @@ func tracebackFunc(t *testing.T) uintptr { // Go obviously doesn't easily expose the problematic PCs to running programs, // so this test is a bit fragile. Some details: // -// * tracebackFunc is our target function. We want to get a PC in the -// alignment region following this function. This function also has other -// functions inlined into it to ensure it has an InlTree (this was the source -// of the bug in issue 44971). +// - tracebackFunc is our target function. We want to get a PC in the +// alignment region following this function. This function also has other +// functions inlined into it to ensure it has an InlTree (this was the source +// of the bug in issue 44971). // -// * We acquire a PC in tracebackFunc, walking forwards until FuncForPC says -// we're in a new function. The last PC of the function according to FuncForPC -// should be in the alignment region (assuming the function isn't already -// perfectly aligned). +// - We acquire a PC in tracebackFunc, walking forwards until FuncForPC says +// we're in a new function. The last PC of the function according to FuncForPC +// should be in the alignment region (assuming the function isn't already +// perfectly aligned). // // This is a regression test for issue 44971. func TestFunctionAlignmentTraceback(t *testing.T) { diff --git a/src/runtime/sys_darwin.go b/src/runtime/sys_darwin.go index ea81fd4f46..1547fdceb0 100644 --- a/src/runtime/sys_darwin.go +++ b/src/runtime/sys_darwin.go @@ -233,11 +233,10 @@ func closefd(fd int32) int32 { } func close_trampoline() -//go:nosplit -//go:cgo_unsafe_args -// // This is exported via linkname to assembly in runtime/cgo. // +//go:nosplit +//go:cgo_unsafe_args //go:linkname exit func exit(code int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(exit_trampoline)), unsafe.Pointer(&code)) diff --git a/src/runtime/time.go b/src/runtime/time.go index 3ff3b668c0..e4d8269987 100644 --- a/src/runtime/time.go +++ b/src/runtime/time.go @@ -225,8 +225,9 @@ func stopTimer(t *timer) bool { // resetTimer resets an inactive timer, adding it to the heap. // -//go:linkname resetTimer time.resetTimer // Reports whether the timer was modified before it was run. +// +//go:linkname resetTimer time.resetTimer func resetTimer(t *timer, when int64) bool { if raceenabled { racerelease(unsafe.Pointer(t)) diff --git a/src/runtime/trace/annotation.go b/src/runtime/trace/annotation.go index bf3dbc3d79..9171633b07 100644 --- a/src/runtime/trace/annotation.go +++ b/src/runtime/trace/annotation.go @@ -28,13 +28,13 @@ type traceContextKey struct{} // If the end function is called multiple times, only the first // call is used in the latency measurement. // -// ctx, task := trace.NewTask(ctx, "awesomeTask") -// trace.WithRegion(ctx, "preparation", prepWork) -// // preparation of the task -// go func() { // continue processing the task in a separate goroutine. -// defer task.End() -// trace.WithRegion(ctx, "remainingWork", remainingWork) -// }() +// ctx, task := trace.NewTask(ctx, "awesomeTask") +// trace.WithRegion(ctx, "preparation", prepWork) +// // preparation of the task +// go func() { // continue processing the task in a separate goroutine. +// defer task.End() +// trace.WithRegion(ctx, "remainingWork", remainingWork) +// }() func NewTask(pctx context.Context, taskType string) (ctx context.Context, task *Task) { pid := fromContext(pctx).id id := newID() @@ -148,7 +148,7 @@ func WithRegion(ctx context.Context, regionType string, fn func()) { // after this region must be ended before this region can be ended. // Recommended usage is // -// defer trace.StartRegion(ctx, "myTracedRegion").End() +// defer trace.StartRegion(ctx, "myTracedRegion").End() func StartRegion(ctx context.Context, regionType string) *Region { if !IsEnabled() { return noopRegion diff --git a/src/runtime/trace/trace.go b/src/runtime/trace/trace.go index b34aef03c5..e0c3ca7a1e 100644 --- a/src/runtime/trace/trace.go +++ b/src/runtime/trace/trace.go @@ -5,7 +5,7 @@ // Package trace contains facilities for programs to generate traces // for the Go execution tracer. // -// Tracing runtime activities +// # Tracing runtime activities // // The execution trace captures a wide range of execution events such as // goroutine creation/blocking/unblocking, syscall enter/exit/block, @@ -19,7 +19,7 @@ // command runs the test in the current directory and writes the trace // file (trace.out). // -// go test -trace=trace.out +// go test -trace=trace.out // // This runtime/trace package provides APIs to add equivalent tracing // support to a standalone program. See the Example that demonstrates @@ -29,12 +29,12 @@ // following line will install a handler under the /debug/pprof/trace URL // to download a live trace: // -// import _ "net/http/pprof" +// import _ "net/http/pprof" // // See the net/http/pprof package for more details about all of the // debug endpoints installed by this import. // -// User annotation +// # User annotation // // Package trace provides user annotation APIs that can be used to // log interesting events during execution. @@ -55,16 +55,16 @@ // trace to trace the durations of sequential steps in a cappuccino making // operation. // -// trace.WithRegion(ctx, "makeCappuccino", func() { +// trace.WithRegion(ctx, "makeCappuccino", func() { // -// // orderID allows to identify a specific order -// // among many cappuccino order region records. -// trace.Log(ctx, "orderID", orderID) +// // orderID allows to identify a specific order +// // among many cappuccino order region records. +// trace.Log(ctx, "orderID", orderID) // -// trace.WithRegion(ctx, "steamMilk", steamMilk) -// trace.WithRegion(ctx, "extractCoffee", extractCoffee) -// trace.WithRegion(ctx, "mixMilkCoffee", mixMilkCoffee) -// }) +// trace.WithRegion(ctx, "steamMilk", steamMilk) +// trace.WithRegion(ctx, "extractCoffee", extractCoffee) +// trace.WithRegion(ctx, "mixMilkCoffee", mixMilkCoffee) +// }) // // A task is a higher-level component that aids tracing of logical // operations such as an RPC request, an HTTP request, or an @@ -80,27 +80,26 @@ // the trace tool can identify the goroutines involved in a specific // cappuccino order. // -// ctx, task := trace.NewTask(ctx, "makeCappuccino") -// trace.Log(ctx, "orderID", orderID) +// ctx, task := trace.NewTask(ctx, "makeCappuccino") +// trace.Log(ctx, "orderID", orderID) // -// milk := make(chan bool) -// espresso := make(chan bool) -// -// go func() { -// trace.WithRegion(ctx, "steamMilk", steamMilk) -// milk <- true -// }() -// go func() { -// trace.WithRegion(ctx, "extractCoffee", extractCoffee) -// espresso <- true -// }() -// go func() { -// defer task.End() // When assemble is done, the order is complete. -// <-espresso -// <-milk -// trace.WithRegion(ctx, "mixMilkCoffee", mixMilkCoffee) -// }() +// milk := make(chan bool) +// espresso := make(chan bool) // +// go func() { +// trace.WithRegion(ctx, "steamMilk", steamMilk) +// milk <- true +// }() +// go func() { +// trace.WithRegion(ctx, "extractCoffee", extractCoffee) +// espresso <- true +// }() +// go func() { +// defer task.End() // When assemble is done, the order is complete. +// <-espresso +// <-milk +// trace.WithRegion(ctx, "mixMilkCoffee", mixMilkCoffee) +// }() // // The trace tool computes the latency of a task by measuring the // time between the task creation and the task end and provides diff --git a/src/runtime/type.go b/src/runtime/type.go index a00394f3b3..44f36a85ca 100644 --- a/src/runtime/type.go +++ b/src/runtime/type.go @@ -14,6 +14,7 @@ import ( // tflag is documented in reflect/type.go. // // tflag values must be kept in sync with copies in: +// // cmd/compile/internal/reflectdata/reflect.go // cmd/link/internal/ld/decodesym.go // reflect/type.go diff --git a/src/runtime/vlrt.go b/src/runtime/vlrt.go index 1dcb125aef..4b12f593c8 100644 --- a/src/runtime/vlrt.go +++ b/src/runtime/vlrt.go @@ -296,11 +296,14 @@ func slowdodiv(n, d uint64) (q, r uint64) { // Floating point control word values. // Bits 0-5 are bits to disable floating-point exceptions. // Bits 8-9 are the precision control: -// 0 = single precision a.k.a. float32 -// 2 = double precision a.k.a. float64 +// +// 0 = single precision a.k.a. float32 +// 2 = double precision a.k.a. float64 +// // Bits 10-11 are the rounding mode: -// 0 = round to nearest (even on a tie) -// 3 = round toward zero +// +// 0 = round to nearest (even on a tie) +// 3 = round toward zero var ( controlWord64 uint16 = 0x3f + 2<<8 + 0<<10 controlWord64trunc uint16 = 0x3f + 2<<8 + 3<<10 |
