From cc9d3f548a0265124766dfdb45e77cf05579219d Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 4 Mar 2022 11:17:43 -0500 Subject: runtime: print goid when throwing in gentraceback This makes it easier to figure out where the crash is occurring. Change-Id: Ie1f78a360367090dcd61c61b2a55c34f3e2ff2eb Reviewed-on: https://go-review.googlesource.com/c/go/+/390034 Trust: David Chase Reviewed-by: David Chase Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui --- src/runtime/crash_test.go | 2 +- src/runtime/traceback.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/crash_test.go b/src/runtime/crash_test.go index 9b9ab4f3e1..d8cabcdda2 100644 --- a/src/runtime/crash_test.go +++ b/src/runtime/crash_test.go @@ -665,7 +665,7 @@ retry: func TestBadTraceback(t *testing.T) { output := runTestProg(t, "testprog", "BadTraceback") for _, want := range []string{ - "runtime: unexpected return pc", + "unexpected return pc", "called from 0xbad", "00000bad", // Smashed LR in hex dump " Date: Tue, 8 Mar 2022 14:55:26 +0100 Subject: runtime, syscall: implement syscall.Pipe using syscall.Pipe2 on solaris All other platforms providing the pipe2 syscall already implement it that way. Do so as well on solaris, which allows to drop runtime.syscall_pipe and its dependencies as well. Change-Id: Icf04777f21d1804da74325d173fefdc87caa42eb Reviewed-on: https://go-review.googlesource.com/c/go/+/390716 Trust: Tobias Klauser Run-TryBot: Tobias Klauser Trust: Matt Layher TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- src/runtime/os3_solaris.go | 3 --- src/runtime/sys_solaris_amd64.s | 12 ------------ src/runtime/syscall_solaris.go | 18 ------------------ src/syscall/asm_solaris_amd64.s | 3 --- src/syscall/syscall_solaris.go | 14 +------------- 5 files changed, 1 insertion(+), 49 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/os3_solaris.go b/src/runtime/os3_solaris.go index 5aee04d5a8..f465a3aa3f 100644 --- a/src/runtime/os3_solaris.go +++ b/src/runtime/os3_solaris.go @@ -47,7 +47,6 @@ import ( //go:cgo_import_dynamic libc_sysconf sysconf "libc.so" //go:cgo_import_dynamic libc_usleep usleep "libc.so" //go:cgo_import_dynamic libc_write write "libc.so" -//go:cgo_import_dynamic libc_pipe pipe "libc.so" //go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so" //go:linkname libc____errno libc____errno @@ -83,7 +82,6 @@ import ( //go:linkname libc_sysconf libc_sysconf //go:linkname libc_usleep libc_usleep //go:linkname libc_write libc_write -//go:linkname libc_pipe libc_pipe //go:linkname libc_pipe2 libc_pipe2 var ( @@ -120,7 +118,6 @@ var ( libc_sysconf, libc_usleep, libc_write, - libc_pipe, libc_pipe2 libcFunc ) diff --git a/src/runtime/sys_solaris_amd64.s b/src/runtime/sys_solaris_amd64.s index 05fd187517..24d2d61df0 100644 --- a/src/runtime/sys_solaris_amd64.s +++ b/src/runtime/sys_solaris_amd64.s @@ -29,18 +29,6 @@ TEXT runtime·miniterrno(SB),NOSPLIT,$0 MOVQ AX, (m_mOS+mOS_perrno)(BX) RET -// pipe(3c) wrapper that returns fds in AX, DX. -// NOT USING GO CALLING CONVENTION. -TEXT runtime·pipe1(SB),NOSPLIT,$0 - SUBQ $16, SP // 8 bytes will do, but stack has to be 16-byte aligned - MOVQ SP, DI - LEAQ libc_pipe(SB), AX - CALL AX - MOVL 0(SP), AX - MOVL 4(SP), DX - ADDQ $16, SP - RET - // Call a library function with SysV calling conventions. // The called function can take a maximum of 6 INTEGER class arguments, // see diff --git a/src/runtime/syscall_solaris.go b/src/runtime/syscall_solaris.go index e270e271c0..79775711ae 100644 --- a/src/runtime/syscall_solaris.go +++ b/src/runtime/syscall_solaris.go @@ -25,11 +25,6 @@ var ( libc_wait4 libcFunc ) -//go:linkname pipe1x runtime.pipe1 -var pipe1x libcFunc // name to take addr of pipe1 - -func pipe1() // declared for vet; do NOT call - // Many of these are exported via linkname to assembly in the syscall // package. @@ -196,19 +191,6 @@ func syscall_ioctl(fd, req, arg uintptr) (err uintptr) { return call.err } -//go:linkname syscall_pipe -func syscall_pipe() (r, w, err uintptr) { - call := libcall{ - fn: uintptr(unsafe.Pointer(&pipe1x)), - n: 0, - args: uintptr(unsafe.Pointer(&pipe1x)), // it's unused but must be non-nil, otherwise crashes - } - entersyscallblock() - asmcgocall(unsafe.Pointer(&asmsysvicall6x), unsafe.Pointer(&call)) - exitsyscall() - return call.r1, call.r2, call.err -} - // This is syscall.RawSyscall, it exists to satisfy some build dependency, // but it doesn't work. // diff --git a/src/syscall/asm_solaris_amd64.s b/src/syscall/asm_solaris_amd64.s index c61e04a42f..3672d3667f 100644 --- a/src/syscall/asm_solaris_amd64.s +++ b/src/syscall/asm_solaris_amd64.s @@ -48,9 +48,6 @@ TEXT ·getpid(SB),NOSPLIT,$0 TEXT ·ioctl(SB),NOSPLIT,$0 JMP runtime·syscall_ioctl(SB) -TEXT ·pipe(SB),NOSPLIT,$0 - JMP runtime·syscall_pipe(SB) - TEXT ·RawSyscall(SB),NOSPLIT,$0 JMP runtime·syscall_rawsyscall(SB) diff --git a/src/syscall/syscall_solaris.go b/src/syscall/syscall_solaris.go index 3c50343d84..d01070b2ec 100644 --- a/src/syscall/syscall_solaris.go +++ b/src/syscall/syscall_solaris.go @@ -47,20 +47,8 @@ func direntNamlen(buf []byte) (uint64, bool) { return reclen - uint64(unsafe.Offsetof(Dirent{}.Name)), true } -func pipe() (r uintptr, w uintptr, err uintptr) - func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - r0, w0, e1 := pipe() - if e1 != 0 { - err = Errno(e1) - } - if err == nil { - p[0], p[1] = int(r0), int(w0) - } - return + return Pipe2(p, 0) } //sysnb pipe2(p *[2]_C_int, flags int) (err error) -- cgit v1.3-5-g9baa From bd77d6e24048e5a8b7b07d2d0b7cf552d21905f5 Mon Sep 17 00:00:00 2001 From: Rhys Hiltner Date: Tue, 8 Feb 2022 14:51:41 -0800 Subject: runtime/pprof: check if PC is reused for inlining When describing call stacks that include inlined function calls, the runtime uses "fake" PCs to represent the frames that inlining removed. Those PCs correspond to real NOP instructions that the compiler inserts for this purpose. Describing the call stack in a protobuf-formatted profile requires the runtime/pprof package to collapse any sequences of fake call sites back into single PCs, removing the NOPs but retaining their line info. But because the NOP instructions are part of the function, they can appear as leaf nodes in a CPU profile. That results in an address that should sometimes be ignored (when it appears as a call site) and that sometimes should be present in the profile (when it is observed consuming CPU time). When processing a PC address, consider it first as a fake PC to add to the current inlining deck, and then as a previously-seen (real) PC. Fixes #50996 Change-Id: I80802369978bd7ac9969839ecfc9995ea4f84ab4 Reviewed-on: https://go-review.googlesource.com/c/go/+/384239 Reviewed-by: Cherry Mui Reviewed-by: Michael Pratt --- src/runtime/pprof/proto.go | 50 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'src/runtime') diff --git a/src/runtime/pprof/proto.go b/src/runtime/pprof/proto.go index 073a076802..215bd0bf96 100644 --- a/src/runtime/pprof/proto.go +++ b/src/runtime/pprof/proto.go @@ -244,6 +244,10 @@ type locInfo struct { // to represent inlined functions // https://github.com/golang/go/blob/d6f2f833c93a41ec1c68e49804b8387a06b131c5/src/runtime/traceback.go#L347-L368 pcs []uintptr + + // results of allFrames call for this PC + frames []runtime.Frame + symbolizeResult symbolizeFlag } // newProfileBuilder returns a new profileBuilder. @@ -399,6 +403,24 @@ func (b *profileBuilder) appendLocsForStack(locs []uint64, stk []uintptr) (newLo for len(stk) > 0 { addr := stk[0] if l, ok := b.locs[addr]; ok { + // When generating code for an inlined function, the compiler adds + // NOP instructions to the outermost function as a placeholder for + // each layer of inlining. When the runtime generates tracebacks for + // stacks that include inlined functions, it uses the addresses of + // those NOPs as "fake" PCs on the stack as if they were regular + // function call sites. But if a profiling signal arrives while the + // CPU is executing one of those NOPs, its PC will show up as a leaf + // in the profile with its own Location entry. So, always check + // whether addr is a "fake" PC in the context of the current call + // stack by trying to add it to the inlining deck before assuming + // that the deck is complete. + if len(b.deck.pcs) > 0 { + if added := b.deck.tryAdd(addr, l.frames, l.symbolizeResult); added { + stk = stk[1:] + continue + } + } + // first record the location if there is any pending accumulated info. if id := b.emitLocation(); id > 0 { locs = append(locs, id) @@ -451,6 +473,27 @@ func (b *profileBuilder) appendLocsForStack(locs []uint64, stk []uintptr) (newLo return locs } +// Here's an example of how Go 1.17 writes out inlined functions, compiled for +// linux/amd64. The disassembly of main.main shows two levels of inlining: main +// calls b, b calls a, a does some work. +// +// inline.go:9 0x4553ec 90 NOPL // func main() { b(v) } +// inline.go:6 0x4553ed 90 NOPL // func b(v *int) { a(v) } +// inline.go:5 0x4553ee 48c7002a000000 MOVQ $0x2a, 0(AX) // func a(v *int) { *v = 42 } +// +// If a profiling signal arrives while executing the MOVQ at 0x4553ee (for line +// 5), the runtime will report the stack as the MOVQ frame being called by the +// NOPL at 0x4553ed (for line 6) being called by the NOPL at 0x4553ec (for line +// 9). +// +// The role of pcDeck is to collapse those three frames back into a single +// location at 0x4553ee, with file/line/function symbolization info representing +// the three layers of calls. It does that via sequential calls to pcDeck.tryAdd +// starting with the leaf-most address. The fourth call to pcDeck.tryAdd will be +// for the caller of main.main. Because main.main was not inlined in its caller, +// the deck will reject the addition, and the fourth PC on the stack will get +// its own location. + // pcDeck is a helper to detect a sequence of inlined functions from // a stack trace returned by the runtime. // @@ -535,7 +578,12 @@ func (b *profileBuilder) emitLocation() uint64 { newFuncs := make([]newFunc, 0, 8) id := uint64(len(b.locs)) + 1 - b.locs[addr] = locInfo{id: id, pcs: append([]uintptr{}, b.deck.pcs...)} + b.locs[addr] = locInfo{ + id: id, + pcs: append([]uintptr{}, b.deck.pcs...), + symbolizeResult: b.deck.symbolizeResult, + frames: append([]runtime.Frame{}, b.deck.frames...), + } start := b.pb.startMessage() b.pb.uint64Opt(tagLocation_ID, id) -- cgit v1.3-5-g9baa From 0d33a9967540fe06f5ce7b14790e9be8da576936 Mon Sep 17 00:00:00 2001 From: Rhys Hiltner Date: Wed, 9 Mar 2022 07:56:04 -0800 Subject: runtime/pprof: fix pcDeck's frame indexing When building the inlining deck, correctly identify which is the last frame in the deck. Otherwise, when some forms of inlining cause a PC to expand to multiple frames, the length of the deck's two slices will diverge. Fixes #51567 Change-Id: I24e7ba32cb16b167f4307178b3f03c29e5362c4b Reviewed-on: https://go-review.googlesource.com/c/go/+/391134 Reviewed-by: Michael Pratt Trust: Than McIntosh --- src/runtime/pprof/proto.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/runtime') diff --git a/src/runtime/pprof/proto.go b/src/runtime/pprof/proto.go index 215bd0bf96..68dac42d20 100644 --- a/src/runtime/pprof/proto.go +++ b/src/runtime/pprof/proto.go @@ -530,7 +530,7 @@ func (d *pcDeck) reset() { // since the stack trace is already fully expanded) and the symbolizeResult // to the deck. If it fails the caller needs to flush the deck and retry. func (d *pcDeck) tryAdd(pc uintptr, frames []runtime.Frame, symbolizeResult symbolizeFlag) (success bool) { - if existing := len(d.pcs); existing > 0 { + if existing := len(d.frames); existing > 0 { // 'd.frames' are all expanded from one 'pc' and represent all // inlined functions so we check only the last one. newFrame := frames[0] -- cgit v1.3-5-g9baa From 29b968e76638c22368f775a4347a544a096d9380 Mon Sep 17 00:00:00 2001 From: Meng Zhuo Date: Fri, 22 Oct 2021 17:40:08 +0800 Subject: runtime,cmd/compile: change reg duff{zero,copy} for regabi riscv64 As CL 356519 require, X8-X23 will be argument register, however X10, X11 is used by duff device. This CL changes X10, X11 into X24, X25 to meet the prerequisite. Update #40724 Change-Id: Ie9b899afbba7e9a51bb7dacd89e49ca1c1fc33ff Reviewed-on: https://go-review.googlesource.com/c/go/+/357976 Trust: mzh Run-TryBot: mzh TryBot-Result: Gopher Robot Reviewed-by: Joel Sing --- src/cmd/compile/internal/riscv64/ggen.go | 2 +- src/cmd/compile/internal/ssa/gen/RISCV64Ops.go | 14 +- src/cmd/compile/internal/ssa/opGen.go | 10 +- src/runtime/duff_riscv64.s | 1790 ++++++++++++------------ src/runtime/mkduff.go | 22 +- 5 files changed, 919 insertions(+), 919 deletions(-) (limited to 'src/runtime') diff --git a/src/cmd/compile/internal/riscv64/ggen.go b/src/cmd/compile/internal/riscv64/ggen.go index 9df739456b..0f37f65fcf 100644 --- a/src/cmd/compile/internal/riscv64/ggen.go +++ b/src/cmd/compile/internal/riscv64/ggen.go @@ -29,7 +29,7 @@ func zeroRange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog } if cnt <= int64(128*types.PtrSize) { - p = pp.Append(p, riscv.AADDI, obj.TYPE_CONST, 0, off, obj.TYPE_REG, riscv.REG_A0, 0) + p = pp.Append(p, riscv.AADDI, obj.TYPE_CONST, 0, off, obj.TYPE_REG, riscv.REG_X25, 0) p.Reg = riscv.REG_SP p = pp.Append(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0) p.To.Name = obj.NAME_EXTERN diff --git a/src/cmd/compile/internal/ssa/gen/RISCV64Ops.go b/src/cmd/compile/internal/ssa/gen/RISCV64Ops.go index 09a8bb38c9..171fa23c6c 100644 --- a/src/cmd/compile/internal/ssa/gen/RISCV64Ops.go +++ b/src/cmd/compile/internal/ssa/gen/RISCV64Ops.go @@ -247,7 +247,7 @@ func init() { {name: "CALLinter", argLength: 2, reg: callInter, aux: "CallOff", call: true}, // call fn by pointer. arg0=codeptr, arg1=mem, auxint=argsize, returns mem // duffzero - // arg0 = address of memory to zero (in X10, changed as side effect) + // arg0 = address of memory to zero (in X25, changed as side effect) // arg1 = mem // auxint = offset into duffzero code to start executing // X1 (link register) changed because of function call @@ -257,16 +257,16 @@ func init() { aux: "Int64", argLength: 2, reg: regInfo{ - inputs: []regMask{regNamed["X10"]}, - clobbers: regNamed["X1"] | regNamed["X10"], + inputs: []regMask{regNamed["X25"]}, + clobbers: regNamed["X1"] | regNamed["X25"], }, typ: "Mem", faultOnNilArg0: true, }, // duffcopy - // arg0 = address of dst memory (in X11, changed as side effect) - // arg1 = address of src memory (in X10, changed as side effect) + // arg0 = address of dst memory (in X25, changed as side effect) + // arg1 = address of src memory (in X24, changed as side effect) // arg2 = mem // auxint = offset into duffcopy code to start executing // X1 (link register) changed because of function call @@ -276,8 +276,8 @@ func init() { aux: "Int64", argLength: 3, reg: regInfo{ - inputs: []regMask{regNamed["X11"], regNamed["X10"]}, - clobbers: regNamed["X1"] | regNamed["X10"] | regNamed["X11"], + inputs: []regMask{regNamed["X25"], regNamed["X24"]}, + clobbers: regNamed["X1"] | regNamed["X24"] | regNamed["X25"], }, typ: "Mem", faultOnNilArg0: true, diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go index 6f0eb45014..3ea3b73684 100644 --- a/src/cmd/compile/internal/ssa/opGen.go +++ b/src/cmd/compile/internal/ssa/opGen.go @@ -28923,9 +28923,9 @@ var opcodeTable = [...]opInfo{ faultOnNilArg0: true, reg: regInfo{ inputs: []inputInfo{ - {0, 512}, // X10 + {0, 16777216}, // X25 }, - clobbers: 512, // X10 + clobbers: 16777216, // X25 }, }, { @@ -28936,10 +28936,10 @@ var opcodeTable = [...]opInfo{ faultOnNilArg1: true, reg: regInfo{ inputs: []inputInfo{ - {0, 1024}, // X11 - {1, 512}, // X10 + {0, 16777216}, // X25 + {1, 8388608}, // X24 }, - clobbers: 1536, // X10 X11 + clobbers: 25165824, // X24 X25 }, }, { diff --git a/src/runtime/duff_riscv64.s b/src/runtime/duff_riscv64.s index f7bd3f326e..9d7f0031a3 100644 --- a/src/runtime/duff_riscv64.s +++ b/src/runtime/duff_riscv64.s @@ -5,903 +5,903 @@ #include "textflag.h" TEXT runtime·duffzero(SB), NOSPLIT|NOFRAME, $0-0 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 - MOV ZERO, (X10) - ADD $8, X10 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 + MOV ZERO, (X25) + ADD $8, X25 RET TEXT runtime·duffcopy(SB), NOSPLIT|NOFRAME, $0-0 - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 - - MOV (X10), X31 - ADD $8, X10 - MOV X31, (X11) - ADD $8, X11 + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 + + MOV (X24), X31 + ADD $8, X24 + MOV X31, (X25) + ADD $8, X25 RET diff --git a/src/runtime/mkduff.go b/src/runtime/mkduff.go index e8a85702c6..e1c01fffce 100644 --- a/src/runtime/mkduff.go +++ b/src/runtime/mkduff.go @@ -235,26 +235,26 @@ func copyMIPS64x(w io.Writer) { func zeroRISCV64(w io.Writer) { // ZERO: always zero - // X10: ptr to memory to be zeroed - // X10 is updated as a side effect. + // X25: ptr to memory to be zeroed + // X25 is updated as a side effect. fmt.Fprintln(w, "TEXT runtime·duffzero(SB), NOSPLIT|NOFRAME, $0-0") for i := 0; i < 128; i++ { - fmt.Fprintln(w, "\tMOV\tZERO, (X10)") - fmt.Fprintln(w, "\tADD\t$8, X10") + fmt.Fprintln(w, "\tMOV\tZERO, (X25)") + fmt.Fprintln(w, "\tADD\t$8, X25") } fmt.Fprintln(w, "\tRET") } func copyRISCV64(w io.Writer) { - // X10: ptr to source memory - // X11: ptr to destination memory - // X10 and X11 are updated as a side effect + // X24: ptr to source memory + // X25: ptr to destination memory + // X24 and X25 are updated as a side effect fmt.Fprintln(w, "TEXT runtime·duffcopy(SB), NOSPLIT|NOFRAME, $0-0") for i := 0; i < 128; i++ { - fmt.Fprintln(w, "\tMOV\t(X10), X31") - fmt.Fprintln(w, "\tADD\t$8, X10") - fmt.Fprintln(w, "\tMOV\tX31, (X11)") - fmt.Fprintln(w, "\tADD\t$8, X11") + fmt.Fprintln(w, "\tMOV\t(X24), X31") + fmt.Fprintln(w, "\tADD\t$8, X24") + fmt.Fprintln(w, "\tMOV\tX31, (X25)") + fmt.Fprintln(w, "\tADD\t$8, X25") fmt.Fprintln(w) } fmt.Fprintln(w, "\tRET") -- cgit v1.3-5-g9baa From 1cf67709beb2d7e317cb6e6b983f3fc6304ebc1a Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 9 Mar 2022 17:08:37 -0500 Subject: runtime: fix SegvInCgo skip check CL 390034 changed this throw message to add the goid, breaking the match. For #50979. Change-Id: I52d97695484938701e5b7c269e2caf0c87d44d7a Reviewed-on: https://go-review.googlesource.com/c/go/+/391139 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills --- src/runtime/crash_cgo_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/runtime') diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go index 37509b1292..5e58712297 100644 --- a/src/runtime/crash_cgo_test.go +++ b/src/runtime/crash_cgo_test.go @@ -629,7 +629,7 @@ func TestSegv(t *testing.T) { testenv.SkipFlaky(t, 50504) } } - if test == "SegvInCgo" && strings.Contains(got, "runtime: unknown pc") { + if test == "SegvInCgo" && strings.Contains(got, "unknown pc") { testenv.SkipFlaky(t, 50979) } -- cgit v1.3-5-g9baa From c1f22134f22158ebeebf450357f711eb22fab202 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 10 Mar 2022 09:28:09 +0100 Subject: runtime/pprof, syscall: report MaxRSS on all unix platforms All unix platforms currently supported by Go provide the getrusage syscall. On aix and solaris the Getrusage syscall wrapper is not available yet, so add and use it to report MaxRSS in memory profiles. Change-Id: Ie880a3058171031fd2e12ccf9adfb85ce18858b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/391434 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Gopher Robot Reviewed-by: Michael Pratt Trust: Michael Pratt Reviewed-by: Ian Lance Taylor --- src/runtime/pprof/pprof_norusage.go | 2 +- src/runtime/pprof/pprof_rusage.go | 6 ++++-- src/runtime/pprof/rusage_test.go | 2 +- src/syscall/syscall_aix.go | 1 + src/syscall/syscall_solaris.go | 1 + src/syscall/zsyscall_aix_ppc64.go | 13 +++++++++++++ src/syscall/zsyscall_solaris_amd64.go | 13 +++++++++++++ 7 files changed, 34 insertions(+), 4 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/pprof/pprof_norusage.go b/src/runtime/pprof/pprof_norusage.go index cbc5176cfa..3d6052519c 100644 --- a/src/runtime/pprof/pprof_norusage.go +++ b/src/runtime/pprof/pprof_norusage.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !darwin && !linux +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris package pprof diff --git a/src/runtime/pprof/pprof_rusage.go b/src/runtime/pprof/pprof_rusage.go index 46263fedd9..7df81eca23 100644 --- a/src/runtime/pprof/pprof_rusage.go +++ b/src/runtime/pprof/pprof_rusage.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build darwin || linux +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris package pprof @@ -17,10 +17,12 @@ import ( func addMaxRSS(w io.Writer) { var rssToBytes uintptr switch runtime.GOOS { - case "linux", "android": + case "aix", "android", "dragonfly", "freebsd", "linux", "netbsd", "openbsd": rssToBytes = 1024 case "darwin", "ios": rssToBytes = 1 + case "illumos", "solaris": + rssToBytes = uintptr(syscall.Getpagesize()) default: panic("unsupported OS") } diff --git a/src/runtime/pprof/rusage_test.go b/src/runtime/pprof/rusage_test.go index b0d651e0eb..f274d0caa3 100644 --- a/src/runtime/pprof/rusage_test.go +++ b/src/runtime/pprof/rusage_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build darwin || freebsd || linux || netbsd || openbsd +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris package pprof diff --git a/src/syscall/syscall_aix.go b/src/syscall/syscall_aix.go index 739c55f179..acc19b4db3 100644 --- a/src/syscall/syscall_aix.go +++ b/src/syscall/syscall_aix.go @@ -594,6 +594,7 @@ func PtraceDetach(pid int) (err error) { return ptrace64(PT_DETACH, int64(pid), //sys Getppid() (ppid int) //sys Getpriority(which int, who int) (n int, err error) //sysnb Getrlimit(which int, lim *Rlimit) (err error) +//sysnb Getrusage(who int, rusage *Rusage) (err error) //sysnb Getuid() (uid int) //sys Kill(pid int, signum Signal) (err error) //sys Lchown(path string, uid int, gid int) (err error) diff --git a/src/syscall/syscall_solaris.go b/src/syscall/syscall_solaris.go index d01070b2ec..38c82a11e8 100644 --- a/src/syscall/syscall_solaris.go +++ b/src/syscall/syscall_solaris.go @@ -421,6 +421,7 @@ func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags i //sys Getppid() (ppid int) //sys Getpriority(which int, who int) (n int, err error) //sysnb Getrlimit(which int, lim *Rlimit) (err error) +//sysnb Getrusage(who int, rusage *Rusage) (err error) //sysnb Gettimeofday(tv *Timeval) (err error) //sysnb Getuid() (uid int) //sys Kill(pid int, signum Signal) (err error) diff --git a/src/syscall/zsyscall_aix_ppc64.go b/src/syscall/zsyscall_aix_ppc64.go index 94f1b4371c..2a3411374f 100644 --- a/src/syscall/zsyscall_aix_ppc64.go +++ b/src/syscall/zsyscall_aix_ppc64.go @@ -62,6 +62,7 @@ import "unsafe" //go:cgo_import_dynamic libc_Getppid getppid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_Getpriority getpriority "libc.a/shr_64.o" //go:cgo_import_dynamic libc_Getrlimit getrlimit "libc.a/shr_64.o" +//go:cgo_import_dynamic libc_Getrusage getrusage "libc.a/shr_64.o" //go:cgo_import_dynamic libc_Getuid getuid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_Kill kill "libc.a/shr_64.o" //go:cgo_import_dynamic libc_Lchown lchown "libc.a/shr_64.o" @@ -154,6 +155,7 @@ import "unsafe" //go:linkname libc_Getppid libc_Getppid //go:linkname libc_Getpriority libc_Getpriority //go:linkname libc_Getrlimit libc_Getrlimit +//go:linkname libc_Getrusage libc_Getrusage //go:linkname libc_Getuid libc_Getuid //go:linkname libc_Kill libc_Kill //go:linkname libc_Lchown libc_Lchown @@ -249,6 +251,7 @@ var ( libc_Getppid, libc_Getpriority, libc_Getrlimit, + libc_Getrusage, libc_Getuid, libc_Kill, libc_Lchown, @@ -925,6 +928,16 @@ func Getrlimit(which int, lim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := rawSyscall6(uintptr(unsafe.Pointer(&libc_Getrusage)), 2, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getuid() (uid int) { r0, _, _ := rawSyscall6(uintptr(unsafe.Pointer(&libc_Getuid)), 0, 0, 0, 0, 0, 0, 0) uid = int(r0) diff --git a/src/syscall/zsyscall_solaris_amd64.go b/src/syscall/zsyscall_solaris_amd64.go index dad0580027..7b012bf9bb 100644 --- a/src/syscall/zsyscall_solaris_amd64.go +++ b/src/syscall/zsyscall_solaris_amd64.go @@ -35,6 +35,7 @@ import "unsafe" //go:cgo_import_dynamic libc_Getppid getppid "libc.so" //go:cgo_import_dynamic libc_Getpriority getpriority "libc.so" //go:cgo_import_dynamic libc_Getrlimit getrlimit "libc.so" +//go:cgo_import_dynamic libc_Getrusage getrusage "libc.so" //go:cgo_import_dynamic libc_Gettimeofday gettimeofday "libc.so" //go:cgo_import_dynamic libc_Getuid getuid "libc.so" //go:cgo_import_dynamic libc_Kill kill "libc.so" @@ -120,6 +121,7 @@ import "unsafe" //go:linkname libc_Getppid libc_Getppid //go:linkname libc_Getpriority libc_Getpriority //go:linkname libc_Getrlimit libc_Getrlimit +//go:linkname libc_Getrusage libc_Getrusage //go:linkname libc_Gettimeofday libc_Gettimeofday //go:linkname libc_Getuid libc_Getuid //go:linkname libc_Kill libc_Kill @@ -208,6 +210,7 @@ var ( libc_Getppid, libc_Getpriority, libc_Getrlimit, + libc_Getrusage, libc_Gettimeofday, libc_Getuid, libc_Kill, @@ -580,6 +583,16 @@ func Getrlimit(which int, lim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&libc_Getrusage)), 2, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Gettimeofday(tv *Timeval) (err error) { _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&libc_Gettimeofday)), 1, uintptr(unsafe.Pointer(tv)), 0, 0, 0, 0, 0) if e1 != 0 { -- cgit v1.3-5-g9baa From 842d37ee5f86f12aa096b750adbd2debd9129fcb Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 11 Mar 2022 18:29:37 -0800 Subject: syscall: add race annotations to Pread and Pwrite Fixes #51618 Change-Id: Ife894d8c313dce8c4929f40fa0ac90a069f77a89 Reviewed-on: https://go-review.googlesource.com/c/go/+/391954 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Keith Randall --- src/runtime/race/testdata/mop_test.go | 14 ++++++++++++- src/syscall/syscall_aix.go | 4 ++-- src/syscall/syscall_darwin.go | 4 ++-- src/syscall/syscall_dragonfly.go | 4 ++-- src/syscall/syscall_freebsd.go | 4 ++-- src/syscall/syscall_linux_386.go | 4 ++-- src/syscall/syscall_linux_amd64.go | 4 ++-- src/syscall/syscall_linux_arm.go | 4 ++-- src/syscall/syscall_linux_arm64.go | 4 ++-- src/syscall/syscall_linux_mips64x.go | 4 ++-- src/syscall/syscall_linux_mipsx.go | 4 ++-- src/syscall/syscall_linux_ppc64x.go | 4 ++-- src/syscall/syscall_linux_riscv64.go | 4 ++-- src/syscall/syscall_linux_s390x.go | 4 ++-- src/syscall/syscall_netbsd.go | 4 ++-- src/syscall/syscall_openbsd.go | 4 ++-- src/syscall/syscall_solaris.go | 4 ++-- src/syscall/syscall_unix.go | 36 ++++++++++++++++++++++++++++++++++ src/syscall/zsyscall_aix_ppc64.go | 20 +++++++++---------- src/syscall/zsyscall_darwin_amd64.go | 4 ++-- src/syscall/zsyscall_darwin_arm64.go | 4 ++-- src/syscall/zsyscall_freebsd_386.go | 4 ++-- src/syscall/zsyscall_freebsd_amd64.go | 4 ++-- src/syscall/zsyscall_freebsd_arm.go | 4 ++-- src/syscall/zsyscall_freebsd_arm64.go | 4 ++-- src/syscall/zsyscall_linux_386.go | 4 ++-- src/syscall/zsyscall_linux_amd64.go | 4 ++-- src/syscall/zsyscall_linux_arm.go | 4 ++-- src/syscall/zsyscall_linux_arm64.go | 4 ++-- src/syscall/zsyscall_linux_mips.go | 4 ++-- src/syscall/zsyscall_linux_mips64.go | 4 ++-- src/syscall/zsyscall_linux_mips64le.go | 4 ++-- src/syscall/zsyscall_linux_mipsle.go | 4 ++-- src/syscall/zsyscall_linux_ppc64.go | 4 ++-- src/syscall/zsyscall_linux_ppc64le.go | 4 ++-- src/syscall/zsyscall_linux_riscv64.go | 4 ++-- src/syscall/zsyscall_linux_s390x.go | 4 ++-- src/syscall/zsyscall_netbsd_386.go | 4 ++-- src/syscall/zsyscall_netbsd_amd64.go | 4 ++-- src/syscall/zsyscall_netbsd_arm.go | 4 ++-- src/syscall/zsyscall_netbsd_arm64.go | 4 ++-- src/syscall/zsyscall_openbsd_386.go | 4 ++-- src/syscall/zsyscall_openbsd_amd64.go | 4 ++-- src/syscall/zsyscall_openbsd_arm.go | 4 ++-- src/syscall/zsyscall_openbsd_arm64.go | 4 ++-- src/syscall/zsyscall_openbsd_mips64.go | 4 ++-- src/syscall/zsyscall_solaris_amd64.go | 20 +++++++++---------- 47 files changed, 155 insertions(+), 107 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/race/testdata/mop_test.go b/src/runtime/race/testdata/mop_test.go index 2d093739df..d05a443f62 100644 --- a/src/runtime/race/testdata/mop_test.go +++ b/src/runtime/race/testdata/mop_test.go @@ -1896,6 +1896,14 @@ func TestRaceNestedStruct(t *testing.T) { } func TestRaceIssue5567(t *testing.T) { + testRaceRead(t, false) +} + +func TestRaceIssue51618(t *testing.T) { + testRaceRead(t, true) +} + +func testRaceRead(t *testing.T, pread bool) { defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) in := make(chan []byte) res := make(chan error) @@ -1914,7 +1922,11 @@ func TestRaceIssue5567(t *testing.T) { var n, total int b := make([]byte, 17) // the race is on b buffer for err == nil { - n, err = f.Read(b) + if pread { + n, err = f.ReadAt(b, int64(total)) + } else { + n, err = f.Read(b) + } total += n if n > 0 { in <- b[:n] diff --git a/src/syscall/syscall_aix.go b/src/syscall/syscall_aix.go index acc19b4db3..a2f8c78438 100644 --- a/src/syscall/syscall_aix.go +++ b/src/syscall/syscall_aix.go @@ -604,8 +604,8 @@ func PtraceDetach(pid int) (err error) { return ptrace64(PT_DETACH, int64(pid), //sys Mkdirat(dirfd int, path string, mode uint32) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Reboot(how int) (err error) //sys Rename(from string, to string) (err error) diff --git a/src/syscall/syscall_darwin.go b/src/syscall/syscall_darwin.go index 87fb5c2f62..2e5387a6d9 100644 --- a/src/syscall/syscall_darwin.go +++ b/src/syscall/syscall_darwin.go @@ -170,8 +170,8 @@ func Kill(pid int, signum Signal) (err error) { return kill(pid, int(signum), 1) //sys Munlockall() (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) //sys Readlink(path string, buf []byte) (n int, err error) diff --git a/src/syscall/syscall_dragonfly.go b/src/syscall/syscall_dragonfly.go index f3c0f54521..d8edca9961 100644 --- a/src/syscall/syscall_dragonfly.go +++ b/src/syscall/syscall_dragonfly.go @@ -122,12 +122,12 @@ func Pipe2(p []int, flags int) (err error) { } //sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error) -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { return extpread(fd, p, 0, offset) } //sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error) -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { return extpwrite(fd, p, 0, offset) } diff --git a/src/syscall/syscall_freebsd.go b/src/syscall/syscall_freebsd.go index ecb9ec825a..8494b21e5b 100644 --- a/src/syscall/syscall_freebsd.go +++ b/src/syscall/syscall_freebsd.go @@ -469,8 +469,8 @@ func convertFromDirents11(buf []byte, old []byte) int { //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) //sys Rename(from string, to string) (err error) diff --git a/src/syscall/syscall_linux_386.go b/src/syscall/syscall_linux_386.go index ef0f53468a..fc7df8496e 100644 --- a/src/syscall/syscall_linux_386.go +++ b/src/syscall/syscall_linux_386.go @@ -32,8 +32,8 @@ func setTimeval(sec, usec int64) Timeval { //sys Ioperm(from int, num int, on int) (err error) //sys Iopl(level int) (err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 //sys Setfsgid(gid int) (err error) = SYS_SETFSGID32 diff --git a/src/syscall/syscall_linux_amd64.go b/src/syscall/syscall_linux_amd64.go index ea5229e8a0..0bcc664d32 100644 --- a/src/syscall/syscall_linux_amd64.go +++ b/src/syscall/syscall_linux_amd64.go @@ -22,8 +22,8 @@ const _SYS_setgroups = SYS_SETGROUPS //sys Iopl(level int) (err error) //sys Listen(s int, n int) (err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) diff --git a/src/syscall/syscall_linux_arm.go b/src/syscall/syscall_linux_arm.go index f00149a1d4..9db702729f 100644 --- a/src/syscall/syscall_linux_arm.go +++ b/src/syscall/syscall_linux_arm.go @@ -72,8 +72,8 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { //sys Utime(path string, buf *Utimbuf) (err error) //sys utimes(path string, times *[2]Timeval) (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64 //sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64 diff --git a/src/syscall/syscall_linux_arm64.go b/src/syscall/syscall_linux_arm64.go index 9ed20f43ed..ef935f3a63 100644 --- a/src/syscall/syscall_linux_arm64.go +++ b/src/syscall/syscall_linux_arm64.go @@ -28,8 +28,8 @@ func EpollCreate(size int) (fd int, err error) { //sysnb getrlimit(resource int, rlim *Rlimit) (err error) //sysnb Getuid() (uid int) //sys Listen(s int, n int) (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) diff --git a/src/syscall/syscall_linux_mips64x.go b/src/syscall/syscall_linux_mips64x.go index b56b8f06b6..258eb97b7e 100644 --- a/src/syscall/syscall_linux_mips64x.go +++ b/src/syscall/syscall_linux_mips64x.go @@ -23,8 +23,8 @@ const _SYS_setgroups = SYS_SETGROUPS //sys Lchown(path string, uid int, gid int) (err error) //sys Listen(s int, n int) (err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) diff --git a/src/syscall/syscall_linux_mipsx.go b/src/syscall/syscall_linux_mipsx.go index c9c9f94e42..5390277926 100644 --- a/src/syscall/syscall_linux_mipsx.go +++ b/src/syscall/syscall_linux_mipsx.go @@ -24,8 +24,8 @@ func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, //sys Lchown(path string, uid int, gid int) (err error) //sys Listen(s int, n int) (err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 diff --git a/src/syscall/syscall_linux_ppc64x.go b/src/syscall/syscall_linux_ppc64x.go index 4180a17f3b..88ad8e4cd4 100644 --- a/src/syscall/syscall_linux_ppc64x.go +++ b/src/syscall/syscall_linux_ppc64x.go @@ -28,8 +28,8 @@ const _SYS_setgroups = SYS_SETGROUPS //sys Listen(s int, n int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT diff --git a/src/syscall/syscall_linux_riscv64.go b/src/syscall/syscall_linux_riscv64.go index a5fb18aa85..0ac4c5496e 100644 --- a/src/syscall/syscall_linux_riscv64.go +++ b/src/syscall/syscall_linux_riscv64.go @@ -28,8 +28,8 @@ func EpollCreate(size int) (fd int, err error) { //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) //sysnb Getuid() (uid int) //sys Listen(s int, n int) (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) diff --git a/src/syscall/syscall_linux_s390x.go b/src/syscall/syscall_linux_s390x.go index 5d6f4d2526..46b252dc95 100644 --- a/src/syscall/syscall_linux_s390x.go +++ b/src/syscall/syscall_linux_s390x.go @@ -25,8 +25,8 @@ const _SYS_setgroups = SYS_SETGROUPS //sys Lchown(path string, uid int, gid int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) //sys Pause() (err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) diff --git a/src/syscall/syscall_netbsd.go b/src/syscall/syscall_netbsd.go index 0d562cc78e..9ccb66c083 100644 --- a/src/syscall/syscall_netbsd.go +++ b/src/syscall/syscall_netbsd.go @@ -198,8 +198,8 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) //sys Rename(from string, to string) (err error) diff --git a/src/syscall/syscall_openbsd.go b/src/syscall/syscall_openbsd.go index 30a95316e8..1d82351084 100644 --- a/src/syscall/syscall_openbsd.go +++ b/src/syscall/syscall_openbsd.go @@ -173,8 +173,8 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) //sys Rename(from string, to string) (err error) diff --git a/src/syscall/syscall_solaris.go b/src/syscall/syscall_solaris.go index 38c82a11e8..37ce5c9e3c 100644 --- a/src/syscall/syscall_solaris.go +++ b/src/syscall/syscall_solaris.go @@ -434,8 +434,8 @@ func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags i //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) //sys Rename(from string, to string) (err error) diff --git a/src/syscall/syscall_unix.go b/src/syscall/syscall_unix.go index 5ee938115d..c35df430aa 100644 --- a/src/syscall/syscall_unix.go +++ b/src/syscall/syscall_unix.go @@ -227,6 +227,42 @@ func Write(fd int, p []byte) (n int, err error) { return } +func Pread(fd int, p []byte, offset int64) (n int, err error) { + n, err = pread(fd, p, offset) + if race.Enabled { + if n > 0 { + race.WriteRange(unsafe.Pointer(&p[0]), n) + } + if err == nil { + race.Acquire(unsafe.Pointer(&ioSync)) + } + } + if msanenabled && n > 0 { + msanWrite(unsafe.Pointer(&p[0]), n) + } + if asanenabled && n > 0 { + asanWrite(unsafe.Pointer(&p[0]), n) + } + return +} + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + if race.Enabled { + race.ReleaseMerge(unsafe.Pointer(&ioSync)) + } + n, err = pwrite(fd, p, offset) + if race.Enabled && n > 0 { + race.ReadRange(unsafe.Pointer(&p[0]), n) + } + if msanenabled && n > 0 { + msanRead(unsafe.Pointer(&p[0]), n) + } + if asanenabled && n > 0 { + asanRead(unsafe.Pointer(&p[0]), n) + } + return +} + // For testing: clients can set this flag to force // creation of IPv6 sockets to return EAFNOSUPPORT. var SocketDisableIPv6 bool diff --git a/src/syscall/zsyscall_aix_ppc64.go b/src/syscall/zsyscall_aix_ppc64.go index 2a3411374f..39838a42e6 100644 --- a/src/syscall/zsyscall_aix_ppc64.go +++ b/src/syscall/zsyscall_aix_ppc64.go @@ -72,8 +72,8 @@ import "unsafe" //go:cgo_import_dynamic libc_Mkdirat mkdirat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_Mknodat mknodat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_Open open "libc.a/shr_64.o" -//go:cgo_import_dynamic libc_Pread pread "libc.a/shr_64.o" -//go:cgo_import_dynamic libc_Pwrite pwrite "libc.a/shr_64.o" +//go:cgo_import_dynamic libc_pread pread "libc.a/shr_64.o" +//go:cgo_import_dynamic libc_pwrite pwrite "libc.a/shr_64.o" //go:cgo_import_dynamic libc_read read "libc.a/shr_64.o" //go:cgo_import_dynamic libc_Reboot reboot "libc.a/shr_64.o" //go:cgo_import_dynamic libc_Rename rename "libc.a/shr_64.o" @@ -165,8 +165,8 @@ import "unsafe" //go:linkname libc_Mkdirat libc_Mkdirat //go:linkname libc_Mknodat libc_Mknodat //go:linkname libc_Open libc_Open -//go:linkname libc_Pread libc_Pread -//go:linkname libc_Pwrite libc_Pwrite +//go:linkname libc_pread libc_pread +//go:linkname libc_pwrite libc_pwrite //go:linkname libc_read libc_read //go:linkname libc_Reboot libc_Reboot //go:linkname libc_Rename libc_Rename @@ -261,8 +261,8 @@ var ( libc_Mkdirat, libc_Mknodat, libc_Open, - libc_Pread, - libc_Pwrite, + libc_pread, + libc_pwrite, libc_read, libc_Reboot, libc_Rename, @@ -1067,12 +1067,12 @@ func Open(path string, mode int, perm uint32) (fd int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { _p0 = &p[0] } - r0, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_Pread)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) + r0, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_pread)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -1082,12 +1082,12 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { _p0 = &p[0] } - r0, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_Pwrite)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) + r0, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_pwrite)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) diff --git a/src/syscall/zsyscall_darwin_amd64.go b/src/syscall/zsyscall_darwin_amd64.go index 0ccdaf2d0e..ee78a572fc 100644 --- a/src/syscall/zsyscall_darwin_amd64.go +++ b/src/syscall/zsyscall_darwin_amd64.go @@ -1137,7 +1137,7 @@ func libc_pathconf_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1158,7 +1158,7 @@ func libc_pread_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_darwin_arm64.go b/src/syscall/zsyscall_darwin_arm64.go index 09bf34bb3c..ac1eccf755 100644 --- a/src/syscall/zsyscall_darwin_arm64.go +++ b/src/syscall/zsyscall_darwin_arm64.go @@ -1137,7 +1137,7 @@ func libc_pathconf_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1158,7 +1158,7 @@ func libc_pread_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_freebsd_386.go b/src/syscall/zsyscall_freebsd_386.go index ed0eb9fa15..04bad4acc9 100644 --- a/src/syscall/zsyscall_freebsd_386.go +++ b/src/syscall/zsyscall_freebsd_386.go @@ -905,7 +905,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -922,7 +922,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_freebsd_amd64.go b/src/syscall/zsyscall_freebsd_amd64.go index e291a56756..eeb9c0cb9b 100644 --- a/src/syscall/zsyscall_freebsd_amd64.go +++ b/src/syscall/zsyscall_freebsd_amd64.go @@ -905,7 +905,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -922,7 +922,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_freebsd_arm.go b/src/syscall/zsyscall_freebsd_arm.go index 7dd856fd97..8ea4282ba4 100644 --- a/src/syscall/zsyscall_freebsd_arm.go +++ b/src/syscall/zsyscall_freebsd_arm.go @@ -905,7 +905,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -922,7 +922,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_freebsd_arm64.go b/src/syscall/zsyscall_freebsd_arm64.go index 229a9a2238..73bf50559d 100644 --- a/src/syscall/zsyscall_freebsd_arm64.go +++ b/src/syscall/zsyscall_freebsd_arm64.go @@ -905,7 +905,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -922,7 +922,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_linux_386.go b/src/syscall/zsyscall_linux_386.go index c385dd3ca1..36a3d7ed39 100644 --- a/src/syscall/zsyscall_linux_386.go +++ b/src/syscall/zsyscall_linux_386.go @@ -1196,7 +1196,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1213,7 +1213,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_linux_amd64.go b/src/syscall/zsyscall_linux_amd64.go index 3e22e20907..07f328e1e2 100644 --- a/src/syscall/zsyscall_linux_amd64.go +++ b/src/syscall/zsyscall_linux_amd64.go @@ -1211,7 +1211,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1228,7 +1228,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_linux_arm.go b/src/syscall/zsyscall_linux_arm.go index 38907a0b35..df79dbd0e1 100644 --- a/src/syscall/zsyscall_linux_arm.go +++ b/src/syscall/zsyscall_linux_arm.go @@ -1493,7 +1493,7 @@ func utimes(path string, times *[2]Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1510,7 +1510,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_linux_arm64.go b/src/syscall/zsyscall_linux_arm64.go index f335c062d5..73321bd897 100644 --- a/src/syscall/zsyscall_linux_arm64.go +++ b/src/syscall/zsyscall_linux_arm64.go @@ -1196,7 +1196,7 @@ func Listen(s int, n int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1213,7 +1213,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_linux_mips.go b/src/syscall/zsyscall_linux_mips.go index f5f73895cc..1ef8eebe4f 100644 --- a/src/syscall/zsyscall_linux_mips.go +++ b/src/syscall/zsyscall_linux_mips.go @@ -1180,7 +1180,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1197,7 +1197,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_linux_mips64.go b/src/syscall/zsyscall_linux_mips64.go index 32f3c32b9b..1ed877ce7e 100644 --- a/src/syscall/zsyscall_linux_mips64.go +++ b/src/syscall/zsyscall_linux_mips64.go @@ -1211,7 +1211,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1228,7 +1228,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_linux_mips64le.go b/src/syscall/zsyscall_linux_mips64le.go index 62dcff45a1..3d7cc9e373 100644 --- a/src/syscall/zsyscall_linux_mips64le.go +++ b/src/syscall/zsyscall_linux_mips64le.go @@ -1211,7 +1211,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1228,7 +1228,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_linux_mipsle.go b/src/syscall/zsyscall_linux_mipsle.go index 4761246536..59b49ddf74 100644 --- a/src/syscall/zsyscall_linux_mipsle.go +++ b/src/syscall/zsyscall_linux_mipsle.go @@ -1180,7 +1180,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1197,7 +1197,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_linux_ppc64.go b/src/syscall/zsyscall_linux_ppc64.go index c9b1365e74..93632bd1cb 100644 --- a/src/syscall/zsyscall_linux_ppc64.go +++ b/src/syscall/zsyscall_linux_ppc64.go @@ -1273,7 +1273,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1290,7 +1290,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_linux_ppc64le.go b/src/syscall/zsyscall_linux_ppc64le.go index 0807390894..fc8f6b7bcf 100644 --- a/src/syscall/zsyscall_linux_ppc64le.go +++ b/src/syscall/zsyscall_linux_ppc64le.go @@ -1273,7 +1273,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1290,7 +1290,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_linux_riscv64.go b/src/syscall/zsyscall_linux_riscv64.go index 1661d04221..0efa70715d 100644 --- a/src/syscall/zsyscall_linux_riscv64.go +++ b/src/syscall/zsyscall_linux_riscv64.go @@ -1196,7 +1196,7 @@ func Listen(s int, n int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1213,7 +1213,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_linux_s390x.go b/src/syscall/zsyscall_linux_s390x.go index 2ab78c71bf..568bb430a6 100644 --- a/src/syscall/zsyscall_linux_s390x.go +++ b/src/syscall/zsyscall_linux_s390x.go @@ -1243,7 +1243,7 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1260,7 +1260,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_netbsd_386.go b/src/syscall/zsyscall_netbsd_386.go index 408318181a..9b92859206 100644 --- a/src/syscall/zsyscall_netbsd_386.go +++ b/src/syscall/zsyscall_netbsd_386.go @@ -816,7 +816,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -833,7 +833,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_netbsd_amd64.go b/src/syscall/zsyscall_netbsd_amd64.go index 2039cf6d0e..ac34c00b5a 100644 --- a/src/syscall/zsyscall_netbsd_amd64.go +++ b/src/syscall/zsyscall_netbsd_amd64.go @@ -816,7 +816,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -833,7 +833,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_netbsd_arm.go b/src/syscall/zsyscall_netbsd_arm.go index 3c287ea223..2be5e7baa4 100644 --- a/src/syscall/zsyscall_netbsd_arm.go +++ b/src/syscall/zsyscall_netbsd_arm.go @@ -816,7 +816,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -833,7 +833,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_netbsd_arm64.go b/src/syscall/zsyscall_netbsd_arm64.go index 1d40db9e6b..02a652bbbb 100644 --- a/src/syscall/zsyscall_netbsd_arm64.go +++ b/src/syscall/zsyscall_netbsd_arm64.go @@ -816,7 +816,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -833,7 +833,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_openbsd_386.go b/src/syscall/zsyscall_openbsd_386.go index 2dcc4b2739..f7986d5ea5 100644 --- a/src/syscall/zsyscall_openbsd_386.go +++ b/src/syscall/zsyscall_openbsd_386.go @@ -1105,7 +1105,7 @@ func libc_pathconf_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1126,7 +1126,7 @@ func libc_pread_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_openbsd_amd64.go b/src/syscall/zsyscall_openbsd_amd64.go index 8d4cb9c1e1..605443d890 100644 --- a/src/syscall/zsyscall_openbsd_amd64.go +++ b/src/syscall/zsyscall_openbsd_amd64.go @@ -1105,7 +1105,7 @@ func libc_pathconf_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1126,7 +1126,7 @@ func libc_pread_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_openbsd_arm.go b/src/syscall/zsyscall_openbsd_arm.go index d45bc02fbd..0f2312fbc4 100644 --- a/src/syscall/zsyscall_openbsd_arm.go +++ b/src/syscall/zsyscall_openbsd_arm.go @@ -1105,7 +1105,7 @@ func libc_pathconf_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1126,7 +1126,7 @@ func libc_pread_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_openbsd_arm64.go b/src/syscall/zsyscall_openbsd_arm64.go index e060b092fe..1367e2aba9 100644 --- a/src/syscall/zsyscall_openbsd_arm64.go +++ b/src/syscall/zsyscall_openbsd_arm64.go @@ -1105,7 +1105,7 @@ func libc_pathconf_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -1126,7 +1126,7 @@ func libc_pread_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_openbsd_mips64.go b/src/syscall/zsyscall_openbsd_mips64.go index 51904b5e29..2cf8465319 100644 --- a/src/syscall/zsyscall_openbsd_mips64.go +++ b/src/syscall/zsyscall_openbsd_mips64.go @@ -810,7 +810,7 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) @@ -827,7 +827,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) diff --git a/src/syscall/zsyscall_solaris_amd64.go b/src/syscall/zsyscall_solaris_amd64.go index 7b012bf9bb..5bb50caaae 100644 --- a/src/syscall/zsyscall_solaris_amd64.go +++ b/src/syscall/zsyscall_solaris_amd64.go @@ -48,8 +48,8 @@ import "unsafe" //go:cgo_import_dynamic libc_Nanosleep nanosleep "libc.so" //go:cgo_import_dynamic libc_Open open "libc.so" //go:cgo_import_dynamic libc_Pathconf pathconf "libc.so" -//go:cgo_import_dynamic libc_Pread pread "libc.so" -//go:cgo_import_dynamic libc_Pwrite pwrite "libc.so" +//go:cgo_import_dynamic libc_pread pread "libc.so" +//go:cgo_import_dynamic libc_pwrite pwrite "libc.so" //go:cgo_import_dynamic libc_read read "libc.so" //go:cgo_import_dynamic libc_Readlink readlink "libc.so" //go:cgo_import_dynamic libc_Rename rename "libc.so" @@ -134,8 +134,8 @@ import "unsafe" //go:linkname libc_Nanosleep libc_Nanosleep //go:linkname libc_Open libc_Open //go:linkname libc_Pathconf libc_Pathconf -//go:linkname libc_Pread libc_Pread -//go:linkname libc_Pwrite libc_Pwrite +//go:linkname libc_pread libc_pread +//go:linkname libc_pwrite libc_pwrite //go:linkname libc_read libc_read //go:linkname libc_Readlink libc_Readlink //go:linkname libc_Rename libc_Rename @@ -223,8 +223,8 @@ var ( libc_Nanosleep, libc_Open, libc_Pathconf, - libc_Pread, - libc_Pwrite, + libc_pread, + libc_pwrite, libc_read, libc_Readlink, libc_Rename, @@ -753,12 +753,12 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pread(fd int, p []byte, offset int64) (n int, err error) { +func pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { _p0 = &p[0] } - r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&libc_Pread)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&libc_pread)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -768,12 +768,12 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pwrite(fd int, p []byte, offset int64) (n int, err error) { +func pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { _p0 = &p[0] } - r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&libc_Pwrite)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&libc_pwrite)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) -- cgit v1.3-5-g9baa From 3c2e73c8c3323887e6b95f72adb6242b8727ba8b Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 11 Mar 2022 08:20:55 +0100 Subject: runtime/pprof: use syscall.RUSAGE_SELF Change-Id: Idc37429de5a48e708eda868ca7fa26b28620bac0 Reviewed-on: https://go-review.googlesource.com/c/go/+/391854 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- src/runtime/pprof/pprof_rusage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/runtime') diff --git a/src/runtime/pprof/pprof_rusage.go b/src/runtime/pprof/pprof_rusage.go index 7df81eca23..984a32e79d 100644 --- a/src/runtime/pprof/pprof_rusage.go +++ b/src/runtime/pprof/pprof_rusage.go @@ -28,6 +28,6 @@ func addMaxRSS(w io.Writer) { } var rusage syscall.Rusage - syscall.Getrusage(0, &rusage) + syscall.Getrusage(syscall.RUSAGE_SELF, &rusage) fmt.Fprintf(w, "# MaxRSS = %d\n", uintptr(rusage.Maxrss)*rssToBytes) } -- cgit v1.3-5-g9baa From 1178255f8596ea503daf30c84c7c1039f755e7f0 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 3 Feb 2022 11:50:45 -0500 Subject: all: untab /* */ doc comments A long time ago, gofmt insisted on inserting tabs in /* */ comments at the top level of the file, like this: /* Package doc comment. */ package p Gofmt still insists on the tab for comments not at top level, but it has relaxed the rules about top-level comments. A few very old doc comments are indented, left over from the old rule. We are considering formatting doc comments, and so to make everything consistent, standardize on unindented doc comments by removing tabs in the few doc comments that are still indented this way. Also update some cmd/gofmt testdata to match. Change-Id: I293742e39b52f8a48ec41f72ca4acdafa7ce43bc Reviewed-on: https://go-review.googlesource.com/c/go/+/384261 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- src/builtin/builtin.go | 8 +- src/cmd/gofmt/testdata/crlf.golden | 8 +- src/cmd/gofmt/testdata/crlf.input | 8 +- src/cmd/gofmt/testdata/typeswitch.golden | 26 +- src/cmd/gofmt/testdata/typeswitch.input | 26 +- src/flag/flag.go | 116 +++--- src/fmt/doc.go | 674 +++++++++++++++---------------- src/go/doc/headscan.go | 10 +- src/net/rpc/server.go | 182 ++++----- src/runtime/debug/stack_test.go | 30 +- src/unsafe/unsafe.go | 6 +- 11 files changed, 547 insertions(+), 547 deletions(-) (limited to 'src/runtime') diff --git a/src/builtin/builtin.go b/src/builtin/builtin.go index 5657be4564..8997902f8f 100644 --- a/src/builtin/builtin.go +++ b/src/builtin/builtin.go @@ -3,10 +3,10 @@ // license that can be found in the LICENSE file. /* - Package builtin provides documentation for Go's predeclared identifiers. - The items documented here are not actually in package builtin - but their descriptions here allow godoc to present documentation - for the language's special identifiers. +Package builtin provides documentation for Go's predeclared identifiers. +The items documented here are not actually in package builtin +but their descriptions here allow godoc to present documentation +for the language's special identifiers. */ package builtin diff --git a/src/cmd/gofmt/testdata/crlf.golden b/src/cmd/gofmt/testdata/crlf.golden index 193dbacc72..65de9cf199 100644 --- a/src/cmd/gofmt/testdata/crlf.golden +++ b/src/cmd/gofmt/testdata/crlf.golden @@ -1,8 +1,8 @@ /* - Source containing CR/LF line endings. - The gofmt'ed output must only have LF - line endings. - Test case for issue 3961. +Source containing CR/LF line endings. +The gofmt'ed output must only have LF +line endings. +Test case for issue 3961. */ package main diff --git a/src/cmd/gofmt/testdata/crlf.input b/src/cmd/gofmt/testdata/crlf.input index ae7e14dbf1..3cd4934caf 100644 --- a/src/cmd/gofmt/testdata/crlf.input +++ b/src/cmd/gofmt/testdata/crlf.input @@ -1,8 +1,8 @@ /* - Source containing CR/LF line endings. - The gofmt'ed output must only have LF - line endings. - Test case for issue 3961. +Source containing CR/LF line endings. +The gofmt'ed output must only have LF +line endings. +Test case for issue 3961. */ package main diff --git a/src/cmd/gofmt/testdata/typeswitch.golden b/src/cmd/gofmt/testdata/typeswitch.golden index 2b1905edd3..3cf4dca7d4 100644 --- a/src/cmd/gofmt/testdata/typeswitch.golden +++ b/src/cmd/gofmt/testdata/typeswitch.golden @@ -1,17 +1,17 @@ /* - Parenthesized type switch expressions originally - accepted by gofmt must continue to be rewritten - into the correct unparenthesized form. - - Only type-switches that didn't declare a variable - in the type switch type assertion and which - contained only "expression-like" (named) types in their - cases were permitted to have their type assertion parenthesized - by go/parser (due to a weak predicate in the parser). All others - were rejected always, either with a syntax error in the - type switch header or in the case. - - See also issue 4470. +Parenthesized type switch expressions originally +accepted by gofmt must continue to be rewritten +into the correct unparenthesized form. + +Only type-switches that didn't declare a variable +in the type switch type assertion and which +contained only "expression-like" (named) types in their +cases were permitted to have their type assertion parenthesized +by go/parser (due to a weak predicate in the parser). All others +were rejected always, either with a syntax error in the +type switch header or in the case. + +See also issue 4470. */ package p diff --git a/src/cmd/gofmt/testdata/typeswitch.input b/src/cmd/gofmt/testdata/typeswitch.input index 8f8cba9b85..992a772d52 100644 --- a/src/cmd/gofmt/testdata/typeswitch.input +++ b/src/cmd/gofmt/testdata/typeswitch.input @@ -1,17 +1,17 @@ /* - Parenthesized type switch expressions originally - accepted by gofmt must continue to be rewritten - into the correct unparenthesized form. - - Only type-switches that didn't declare a variable - in the type switch type assertion and which - contained only "expression-like" (named) types in their - cases were permitted to have their type assertion parenthesized - by go/parser (due to a weak predicate in the parser). All others - were rejected always, either with a syntax error in the - type switch header or in the case. - - See also issue 4470. +Parenthesized type switch expressions originally +accepted by gofmt must continue to be rewritten +into the correct unparenthesized form. + +Only type-switches that didn't declare a variable +in the type switch type assertion and which +contained only "expression-like" (named) types in their +cases were permitted to have their type assertion parenthesized +by go/parser (due to a weak predicate in the parser). All others +were rejected always, either with a syntax error in the +type switch header or in the case. + +See also issue 4470. */ package p diff --git a/src/flag/flag.go b/src/flag/flag.go index c27a144434..cdea949a2f 100644 --- a/src/flag/flag.go +++ b/src/flag/flag.go @@ -3,67 +3,67 @@ // license that can be found in the LICENSE file. /* - Package flag implements command-line flag parsing. +Package flag implements command-line flag parsing. - Usage +Usage - Define flags using flag.String(), Bool(), Int(), etc. +Define flags using flag.String(), Bool(), Int(), etc. - This declares an integer flag, -n, stored in the pointer nFlag, with type *int: - import "flag" - var nFlag = flag.Int("n", 1234, "help message for flag n") - If you like, you can bind the flag to a variable using the Var() functions. - var flagvar int - func init() { - flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") - } - Or you can create custom flags that satisfy the Value interface (with - pointer receivers) and couple them to flag parsing by - flag.Var(&flagVal, "name", "help message for flagname") - For such flags, the default value is just the initial value of the variable. - - After all flags are defined, call - flag.Parse() - to parse the command line into the defined flags. - - Flags may then be used directly. If you're using the flags themselves, - they are all pointers; if you bind to variables, they're values. - fmt.Println("ip has value ", *ip) - fmt.Println("flagvar has value ", flagvar) - - After parsing, the arguments following the flags are available as the - slice flag.Args() or individually as flag.Arg(i). - The arguments are indexed from 0 through flag.NArg()-1. - - Command line flag syntax - - The following forms are permitted: - - -flag - -flag=x - -flag x // non-boolean flags only - One or two minus signs may be used; they are equivalent. - The last form is not permitted for boolean flags because the - meaning of the command - cmd -x * - where * is a Unix shell wildcard, will change if there is a file - called 0, false, etc. You must use the -flag=false form to turn - off a boolean flag. - - Flag parsing stops just before the first non-flag argument - ("-" is a non-flag argument) or after the terminator "--". - - Integer flags accept 1234, 0664, 0x1234 and may be negative. - Boolean flags may be: - 1, 0, t, f, T, F, true, false, TRUE, FALSE, True, False - Duration flags accept any input valid for time.ParseDuration. - - The default set of command-line flags is controlled by - top-level functions. The FlagSet type allows one to define - independent sets of flags, such as to implement subcommands - in a command-line interface. The methods of FlagSet are - analogous to the top-level functions for the command-line - flag set. +This declares an integer flag, -n, stored in the pointer nFlag, with type *int: + import "flag" + var nFlag = flag.Int("n", 1234, "help message for flag n") +If you like, you can bind the flag to a variable using the Var() functions. + var flagvar int + func init() { + flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") + } +Or you can create custom flags that satisfy the Value interface (with +pointer receivers) and couple them to flag parsing by + flag.Var(&flagVal, "name", "help message for flagname") +For such flags, the default value is just the initial value of the variable. + +After all flags are defined, call + flag.Parse() +to parse the command line into the defined flags. + +Flags may then be used directly. If you're using the flags themselves, +they are all pointers; if you bind to variables, they're values. + fmt.Println("ip has value ", *ip) + fmt.Println("flagvar has value ", flagvar) + +After parsing, the arguments following the flags are available as the +slice flag.Args() or individually as flag.Arg(i). +The arguments are indexed from 0 through flag.NArg()-1. + +Command line flag syntax + +The following forms are permitted: + + -flag + -flag=x + -flag x // non-boolean flags only +One or two minus signs may be used; they are equivalent. +The last form is not permitted for boolean flags because the +meaning of the command + cmd -x * +where * is a Unix shell wildcard, will change if there is a file +called 0, false, etc. You must use the -flag=false form to turn +off a boolean flag. + +Flag parsing stops just before the first non-flag argument +("-" is a non-flag argument) or after the terminator "--". + +Integer flags accept 1234, 0664, 0x1234 and may be negative. +Boolean flags may be: + 1, 0, t, f, T, F, true, false, TRUE, FALSE, True, False +Duration flags accept any input valid for time.ParseDuration. + +The default set of command-line flags is controlled by +top-level functions. The FlagSet type allows one to define +independent sets of flags, such as to implement subcommands +in a command-line interface. The methods of FlagSet are +analogous to the top-level functions for the command-line +flag set. */ package flag diff --git a/src/fmt/doc.go b/src/fmt/doc.go index a7bd02b627..f14a7a73e3 100644 --- a/src/fmt/doc.go +++ b/src/fmt/doc.go @@ -3,342 +3,342 @@ // license that can be found in the LICENSE file. /* - Package fmt implements formatted I/O with functions analogous - to C's printf and scanf. The format 'verbs' are derived from C's but - are simpler. - - - Printing - - The verbs: - - General: - %v the value in a default format - when printing structs, the plus flag (%+v) adds field names - %#v a Go-syntax representation of the value - %T a Go-syntax representation of the type of the value - %% a literal percent sign; consumes no value - - Boolean: - %t the word true or false - Integer: - %b base 2 - %c the character represented by the corresponding Unicode code point - %d base 10 - %o base 8 - %O base 8 with 0o prefix - %q a single-quoted character literal safely escaped with Go syntax. - %x base 16, with lower-case letters for a-f - %X base 16, with upper-case letters for A-F - %U Unicode format: U+1234; same as "U+%04X" - Floating-point and complex constituents: - %b decimalless scientific notation with exponent a power of two, - in the manner of strconv.FormatFloat with the 'b' format, - e.g. -123456p-78 - %e scientific notation, e.g. -1.234456e+78 - %E scientific notation, e.g. -1.234456E+78 - %f decimal point but no exponent, e.g. 123.456 - %F synonym for %f - %g %e for large exponents, %f otherwise. Precision is discussed below. - %G %E for large exponents, %F otherwise - %x hexadecimal notation (with decimal power of two exponent), e.g. -0x1.23abcp+20 - %X upper-case hexadecimal notation, e.g. -0X1.23ABCP+20 - String and slice of bytes (treated equivalently with these verbs): - %s the uninterpreted bytes of the string or slice - %q a double-quoted string safely escaped with Go syntax - %x base 16, lower-case, two characters per byte - %X base 16, upper-case, two characters per byte - Slice: - %p address of 0th element in base 16 notation, with leading 0x - Pointer: - %p base 16 notation, with leading 0x - The %b, %d, %o, %x and %X verbs also work with pointers, - formatting the value exactly as if it were an integer. - - The default format for %v is: - bool: %t - int, int8 etc.: %d - uint, uint8 etc.: %d, %#x if printed with %#v - float32, complex64, etc: %g - string: %s - chan: %p - pointer: %p - For compound objects, the elements are printed using these rules, recursively, - laid out like this: - struct: {field0 field1 ...} - array, slice: [elem0 elem1 ...] - maps: map[key1:value1 key2:value2 ...] - pointer to above: &{}, &[], &map[] - - Width is specified by an optional decimal number immediately preceding the verb. - If absent, the width is whatever is necessary to represent the value. - Precision is specified after the (optional) width by a period followed by a - decimal number. If no period is present, a default precision is used. - A period with no following number specifies a precision of zero. - Examples: - %f default width, default precision - %9f width 9, default precision - %.2f default width, precision 2 - %9.2f width 9, precision 2 - %9.f width 9, precision 0 - - Width and precision are measured in units of Unicode code points, - that is, runes. (This differs from C's printf where the - units are always measured in bytes.) Either or both of the flags - may be replaced with the character '*', causing their values to be - obtained from the next operand (preceding the one to format), - which must be of type int. - - For most values, width is the minimum number of runes to output, - padding the formatted form with spaces if necessary. - - For strings, byte slices and byte arrays, however, precision - limits the length of the input to be formatted (not the size of - the output), truncating if necessary. Normally it is measured in - runes, but for these types when formatted with the %x or %X format - it is measured in bytes. - - For floating-point values, width sets the minimum width of the field and - precision sets the number of places after the decimal, if appropriate, - except that for %g/%G precision sets the maximum number of significant - digits (trailing zeros are removed). For example, given 12.345 the format - %6.3f prints 12.345 while %.3g prints 12.3. The default precision for %e, %f - and %#g is 6; for %g it is the smallest number of digits necessary to identify - the value uniquely. - - For complex numbers, the width and precision apply to the two - components independently and the result is parenthesized, so %f applied - to 1.2+3.4i produces (1.200000+3.400000i). - - Other flags: - + always print a sign for numeric values; - guarantee ASCII-only output for %q (%+q) - - pad with spaces on the right rather than the left (left-justify the field) - # alternate format: add leading 0b for binary (%#b), 0 for octal (%#o), - 0x or 0X for hex (%#x or %#X); suppress 0x for %p (%#p); - for %q, print a raw (backquoted) string if strconv.CanBackquote - returns true; - always print a decimal point for %e, %E, %f, %F, %g and %G; - do not remove trailing zeros for %g and %G; - write e.g. U+0078 'x' if the character is printable for %U (%#U). - ' ' (space) leave a space for elided sign in numbers (% d); - put spaces between bytes printing strings or slices in hex (% x, % X) - 0 pad with leading zeros rather than spaces; - for numbers, this moves the padding after the sign; - ignored for strings, byte slices and byte arrays - - Flags are ignored by verbs that do not expect them. - For example there is no alternate decimal format, so %#d and %d - behave identically. - - For each Printf-like function, there is also a Print function - that takes no format and is equivalent to saying %v for every - operand. Another variant Println inserts blanks between - operands and appends a newline. - - Regardless of the verb, if an operand is an interface value, - the internal concrete value is used, not the interface itself. - Thus: - var i interface{} = 23 - fmt.Printf("%v\n", i) - will print 23. - - Except when printed using the verbs %T and %p, special - formatting considerations apply for operands that implement - certain interfaces. In order of application: - - 1. If the operand is a reflect.Value, the operand is replaced by the - concrete value that it holds, and printing continues with the next rule. - - 2. If an operand implements the Formatter interface, it will - be invoked. In this case the interpretation of verbs and flags is - controlled by that implementation. - - 3. If the %v verb is used with the # flag (%#v) and the operand - implements the GoStringer interface, that will be invoked. - - If the format (which is implicitly %v for Println etc.) is valid - for a string (%s %q %v %x %X), the following two rules apply: - - 4. If an operand implements the error interface, the Error method - will be invoked to convert the object to a string, which will then - be formatted as required by the verb (if any). - - 5. If an operand implements method String() string, that method - will be invoked to convert the object to a string, which will then - be formatted as required by the verb (if any). - - For compound operands such as slices and structs, the format - applies to the elements of each operand, recursively, not to the - operand as a whole. Thus %q will quote each element of a slice - of strings, and %6.2f will control formatting for each element - of a floating-point array. - - However, when printing a byte slice with a string-like verb - (%s %q %x %X), it is treated identically to a string, as a single item. - - To avoid recursion in cases such as - type X string - func (x X) String() string { return Sprintf("<%s>", x) } - convert the value before recurring: - func (x X) String() string { return Sprintf("<%s>", string(x)) } - Infinite recursion can also be triggered by self-referential data - structures, such as a slice that contains itself as an element, if - that type has a String method. Such pathologies are rare, however, - and the package does not protect against them. - - When printing a struct, fmt cannot and therefore does not invoke - formatting methods such as Error or String on unexported fields. - - Explicit argument indexes - - In Printf, Sprintf, and Fprintf, the default behavior is for each - formatting verb to format successive arguments passed in the call. - However, the notation [n] immediately before the verb indicates that the - nth one-indexed argument is to be formatted instead. The same notation - before a '*' for a width or precision selects the argument index holding - the value. After processing a bracketed expression [n], subsequent verbs - will use arguments n+1, n+2, etc. unless otherwise directed. - - For example, - fmt.Sprintf("%[2]d %[1]d\n", 11, 22) - will yield "22 11", while - fmt.Sprintf("%[3]*.[2]*[1]f", 12.0, 2, 6) - equivalent to - fmt.Sprintf("%6.2f", 12.0) - will yield " 12.00". Because an explicit index affects subsequent verbs, - this notation can be used to print the same values multiple times - by resetting the index for the first argument to be repeated: - fmt.Sprintf("%d %d %#[1]x %#x", 16, 17) - will yield "16 17 0x10 0x11". - - Format errors - - If an invalid argument is given for a verb, such as providing - a string to %d, the generated string will contain a - description of the problem, as in these examples: - - Wrong type or unknown verb: %!verb(type=value) - Printf("%d", "hi"): %!d(string=hi) - Too many arguments: %!(EXTRA type=value) - Printf("hi", "guys"): hi%!(EXTRA string=guys) - Too few arguments: %!verb(MISSING) - Printf("hi%d"): hi%!d(MISSING) - Non-int for width or precision: %!(BADWIDTH) or %!(BADPREC) - Printf("%*s", 4.5, "hi"): %!(BADWIDTH)hi - Printf("%.*s", 4.5, "hi"): %!(BADPREC)hi - Invalid or invalid use of argument index: %!(BADINDEX) - Printf("%*[2]d", 7): %!d(BADINDEX) - Printf("%.[2]d", 7): %!d(BADINDEX) - - All errors begin with the string "%!" followed sometimes - by a single character (the verb) and end with a parenthesized - description. - - If an Error or String method triggers a panic when called by a - print routine, the fmt package reformats the error message - from the panic, decorating it with an indication that it came - through the fmt package. For example, if a String method - calls panic("bad"), the resulting formatted message will look - like - %!s(PANIC=bad) - - The %!s just shows the print verb in use when the failure - occurred. If the panic is caused by a nil receiver to an Error - or String method, however, the output is the undecorated - string, "". - - Scanning - - An analogous set of functions scans formatted text to yield - values. Scan, Scanf and Scanln read from os.Stdin; Fscan, - Fscanf and Fscanln read from a specified io.Reader; Sscan, - Sscanf and Sscanln read from an argument string. - - Scan, Fscan, Sscan treat newlines in the input as spaces. - - Scanln, Fscanln and Sscanln stop scanning at a newline and - require that the items be followed by a newline or EOF. - - Scanf, Fscanf, and Sscanf parse the arguments according to a - format string, analogous to that of Printf. In the text that - follows, 'space' means any Unicode whitespace character - except newline. - - In the format string, a verb introduced by the % character - consumes and parses input; these verbs are described in more - detail below. A character other than %, space, or newline in - the format consumes exactly that input character, which must - be present. A newline with zero or more spaces before it in - the format string consumes zero or more spaces in the input - followed by a single newline or the end of the input. A space - following a newline in the format string consumes zero or more - spaces in the input. Otherwise, any run of one or more spaces - in the format string consumes as many spaces as possible in - the input. Unless the run of spaces in the format string - appears adjacent to a newline, the run must consume at least - one space from the input or find the end of the input. - - The handling of spaces and newlines differs from that of C's - scanf family: in C, newlines are treated as any other space, - and it is never an error when a run of spaces in the format - string finds no spaces to consume in the input. - - The verbs behave analogously to those of Printf. - For example, %x will scan an integer as a hexadecimal number, - and %v will scan the default representation format for the value. - The Printf verbs %p and %T and the flags # and + are not implemented. - For floating-point and complex values, all valid formatting verbs - (%b %e %E %f %F %g %G %x %X and %v) are equivalent and accept - both decimal and hexadecimal notation (for example: "2.3e+7", "0x4.5p-8") - and digit-separating underscores (for example: "3.14159_26535_89793"). - - Input processed by verbs is implicitly space-delimited: the - implementation of every verb except %c starts by discarding - leading spaces from the remaining input, and the %s verb - (and %v reading into a string) stops consuming input at the first - space or newline character. - - The familiar base-setting prefixes 0b (binary), 0o and 0 (octal), - and 0x (hexadecimal) are accepted when scanning integers - without a format or with the %v verb, as are digit-separating - underscores. - - Width is interpreted in the input text but there is no - syntax for scanning with a precision (no %5.2f, just %5f). - If width is provided, it applies after leading spaces are - trimmed and specifies the maximum number of runes to read - to satisfy the verb. For example, - Sscanf(" 1234567 ", "%5s%d", &s, &i) - will set s to "12345" and i to 67 while - Sscanf(" 12 34 567 ", "%5s%d", &s, &i) - will set s to "12" and i to 34. - - In all the scanning functions, a carriage return followed - immediately by a newline is treated as a plain newline - (\r\n means the same as \n). - - In all the scanning functions, if an operand implements method - Scan (that is, it implements the Scanner interface) that - method will be used to scan the text for that operand. Also, - if the number of arguments scanned is less than the number of - arguments provided, an error is returned. - - All arguments to be scanned must be either pointers to basic - types or implementations of the Scanner interface. - - Like Scanf and Fscanf, Sscanf need not consume its entire input. - There is no way to recover how much of the input string Sscanf used. - - Note: Fscan etc. can read one character (rune) past the input - they return, which means that a loop calling a scan routine - may skip some of the input. This is usually a problem only - when there is no space between input values. If the reader - provided to Fscan implements ReadRune, that method will be used - to read characters. If the reader also implements UnreadRune, - that method will be used to save the character and successive - calls will not lose data. To attach ReadRune and UnreadRune - methods to a reader without that capability, use - bufio.NewReader. +Package fmt implements formatted I/O with functions analogous +to C's printf and scanf. The format 'verbs' are derived from C's but +are simpler. + + +Printing + +The verbs: + +General: + %v the value in a default format + when printing structs, the plus flag (%+v) adds field names + %#v a Go-syntax representation of the value + %T a Go-syntax representation of the type of the value + %% a literal percent sign; consumes no value + +Boolean: + %t the word true or false +Integer: + %b base 2 + %c the character represented by the corresponding Unicode code point + %d base 10 + %o base 8 + %O base 8 with 0o prefix + %q a single-quoted character literal safely escaped with Go syntax. + %x base 16, with lower-case letters for a-f + %X base 16, with upper-case letters for A-F + %U Unicode format: U+1234; same as "U+%04X" +Floating-point and complex constituents: + %b decimalless scientific notation with exponent a power of two, + in the manner of strconv.FormatFloat with the 'b' format, + e.g. -123456p-78 + %e scientific notation, e.g. -1.234456e+78 + %E scientific notation, e.g. -1.234456E+78 + %f decimal point but no exponent, e.g. 123.456 + %F synonym for %f + %g %e for large exponents, %f otherwise. Precision is discussed below. + %G %E for large exponents, %F otherwise + %x hexadecimal notation (with decimal power of two exponent), e.g. -0x1.23abcp+20 + %X upper-case hexadecimal notation, e.g. -0X1.23ABCP+20 +String and slice of bytes (treated equivalently with these verbs): + %s the uninterpreted bytes of the string or slice + %q a double-quoted string safely escaped with Go syntax + %x base 16, lower-case, two characters per byte + %X base 16, upper-case, two characters per byte +Slice: + %p address of 0th element in base 16 notation, with leading 0x +Pointer: + %p base 16 notation, with leading 0x + The %b, %d, %o, %x and %X verbs also work with pointers, + formatting the value exactly as if it were an integer. + +The default format for %v is: + bool: %t + int, int8 etc.: %d + uint, uint8 etc.: %d, %#x if printed with %#v + float32, complex64, etc: %g + string: %s + chan: %p + pointer: %p +For compound objects, the elements are printed using these rules, recursively, +laid out like this: + struct: {field0 field1 ...} + array, slice: [elem0 elem1 ...] + maps: map[key1:value1 key2:value2 ...] + pointer to above: &{}, &[], &map[] + +Width is specified by an optional decimal number immediately preceding the verb. +If absent, the width is whatever is necessary to represent the value. +Precision is specified after the (optional) width by a period followed by a +decimal number. If no period is present, a default precision is used. +A period with no following number specifies a precision of zero. +Examples: + %f default width, default precision + %9f width 9, default precision + %.2f default width, precision 2 + %9.2f width 9, precision 2 + %9.f width 9, precision 0 + +Width and precision are measured in units of Unicode code points, +that is, runes. (This differs from C's printf where the +units are always measured in bytes.) Either or both of the flags +may be replaced with the character '*', causing their values to be +obtained from the next operand (preceding the one to format), +which must be of type int. + +For most values, width is the minimum number of runes to output, +padding the formatted form with spaces if necessary. + +For strings, byte slices and byte arrays, however, precision +limits the length of the input to be formatted (not the size of +the output), truncating if necessary. Normally it is measured in +runes, but for these types when formatted with the %x or %X format +it is measured in bytes. + +For floating-point values, width sets the minimum width of the field and +precision sets the number of places after the decimal, if appropriate, +except that for %g/%G precision sets the maximum number of significant +digits (trailing zeros are removed). For example, given 12.345 the format +%6.3f prints 12.345 while %.3g prints 12.3. The default precision for %e, %f +and %#g is 6; for %g it is the smallest number of digits necessary to identify +the value uniquely. + +For complex numbers, the width and precision apply to the two +components independently and the result is parenthesized, so %f applied +to 1.2+3.4i produces (1.200000+3.400000i). + +Other flags: + + always print a sign for numeric values; + guarantee ASCII-only output for %q (%+q) + - pad with spaces on the right rather than the left (left-justify the field) + # alternate format: add leading 0b for binary (%#b), 0 for octal (%#o), + 0x or 0X for hex (%#x or %#X); suppress 0x for %p (%#p); + for %q, print a raw (backquoted) string if strconv.CanBackquote + returns true; + always print a decimal point for %e, %E, %f, %F, %g and %G; + do not remove trailing zeros for %g and %G; + write e.g. U+0078 'x' if the character is printable for %U (%#U). + ' ' (space) leave a space for elided sign in numbers (% d); + put spaces between bytes printing strings or slices in hex (% x, % X) + 0 pad with leading zeros rather than spaces; + for numbers, this moves the padding after the sign; + ignored for strings, byte slices and byte arrays + +Flags are ignored by verbs that do not expect them. +For example there is no alternate decimal format, so %#d and %d +behave identically. + +For each Printf-like function, there is also a Print function +that takes no format and is equivalent to saying %v for every +operand. Another variant Println inserts blanks between +operands and appends a newline. + +Regardless of the verb, if an operand is an interface value, +the internal concrete value is used, not the interface itself. +Thus: + var i interface{} = 23 + fmt.Printf("%v\n", i) +will print 23. + +Except when printed using the verbs %T and %p, special +formatting considerations apply for operands that implement +certain interfaces. In order of application: + +1. If the operand is a reflect.Value, the operand is replaced by the +concrete value that it holds, and printing continues with the next rule. + +2. If an operand implements the Formatter interface, it will +be invoked. In this case the interpretation of verbs and flags is +controlled by that implementation. + +3. If the %v verb is used with the # flag (%#v) and the operand +implements the GoStringer interface, that will be invoked. + +If the format (which is implicitly %v for Println etc.) is valid +for a string (%s %q %v %x %X), the following two rules apply: + +4. If an operand implements the error interface, the Error method +will be invoked to convert the object to a string, which will then +be formatted as required by the verb (if any). + +5. If an operand implements method String() string, that method +will be invoked to convert the object to a string, which will then +be formatted as required by the verb (if any). + +For compound operands such as slices and structs, the format +applies to the elements of each operand, recursively, not to the +operand as a whole. Thus %q will quote each element of a slice +of strings, and %6.2f will control formatting for each element +of a floating-point array. + +However, when printing a byte slice with a string-like verb +(%s %q %x %X), it is treated identically to a string, as a single item. + +To avoid recursion in cases such as + type X string + func (x X) String() string { return Sprintf("<%s>", x) } +convert the value before recurring: + func (x X) String() string { return Sprintf("<%s>", string(x)) } +Infinite recursion can also be triggered by self-referential data +structures, such as a slice that contains itself as an element, if +that type has a String method. Such pathologies are rare, however, +and the package does not protect against them. + +When printing a struct, fmt cannot and therefore does not invoke +formatting methods such as Error or String on unexported fields. + +Explicit argument indexes + +In Printf, Sprintf, and Fprintf, the default behavior is for each +formatting verb to format successive arguments passed in the call. +However, the notation [n] immediately before the verb indicates that the +nth one-indexed argument is to be formatted instead. The same notation +before a '*' for a width or precision selects the argument index holding +the value. After processing a bracketed expression [n], subsequent verbs +will use arguments n+1, n+2, etc. unless otherwise directed. + +For example, + fmt.Sprintf("%[2]d %[1]d\n", 11, 22) +will yield "22 11", while + fmt.Sprintf("%[3]*.[2]*[1]f", 12.0, 2, 6) +equivalent to + fmt.Sprintf("%6.2f", 12.0) +will yield " 12.00". Because an explicit index affects subsequent verbs, +this notation can be used to print the same values multiple times +by resetting the index for the first argument to be repeated: + fmt.Sprintf("%d %d %#[1]x %#x", 16, 17) +will yield "16 17 0x10 0x11". + +Format errors + +If an invalid argument is given for a verb, such as providing +a string to %d, the generated string will contain a +description of the problem, as in these examples: + + Wrong type or unknown verb: %!verb(type=value) + Printf("%d", "hi"): %!d(string=hi) + Too many arguments: %!(EXTRA type=value) + Printf("hi", "guys"): hi%!(EXTRA string=guys) + Too few arguments: %!verb(MISSING) + Printf("hi%d"): hi%!d(MISSING) + Non-int for width or precision: %!(BADWIDTH) or %!(BADPREC) + Printf("%*s", 4.5, "hi"): %!(BADWIDTH)hi + Printf("%.*s", 4.5, "hi"): %!(BADPREC)hi + Invalid or invalid use of argument index: %!(BADINDEX) + Printf("%*[2]d", 7): %!d(BADINDEX) + Printf("%.[2]d", 7): %!d(BADINDEX) + +All errors begin with the string "%!" followed sometimes +by a single character (the verb) and end with a parenthesized +description. + +If an Error or String method triggers a panic when called by a +print routine, the fmt package reformats the error message +from the panic, decorating it with an indication that it came +through the fmt package. For example, if a String method +calls panic("bad"), the resulting formatted message will look +like + %!s(PANIC=bad) + +The %!s just shows the print verb in use when the failure +occurred. If the panic is caused by a nil receiver to an Error +or String method, however, the output is the undecorated +string, "". + +Scanning + +An analogous set of functions scans formatted text to yield +values. Scan, Scanf and Scanln read from os.Stdin; Fscan, +Fscanf and Fscanln read from a specified io.Reader; Sscan, +Sscanf and Sscanln read from an argument string. + +Scan, Fscan, Sscan treat newlines in the input as spaces. + +Scanln, Fscanln and Sscanln stop scanning at a newline and +require that the items be followed by a newline or EOF. + +Scanf, Fscanf, and Sscanf parse the arguments according to a +format string, analogous to that of Printf. In the text that +follows, 'space' means any Unicode whitespace character +except newline. + +In the format string, a verb introduced by the % character +consumes and parses input; these verbs are described in more +detail below. A character other than %, space, or newline in +the format consumes exactly that input character, which must +be present. A newline with zero or more spaces before it in +the format string consumes zero or more spaces in the input +followed by a single newline or the end of the input. A space +following a newline in the format string consumes zero or more +spaces in the input. Otherwise, any run of one or more spaces +in the format string consumes as many spaces as possible in +the input. Unless the run of spaces in the format string +appears adjacent to a newline, the run must consume at least +one space from the input or find the end of the input. + +The handling of spaces and newlines differs from that of C's +scanf family: in C, newlines are treated as any other space, +and it is never an error when a run of spaces in the format +string finds no spaces to consume in the input. + +The verbs behave analogously to those of Printf. +For example, %x will scan an integer as a hexadecimal number, +and %v will scan the default representation format for the value. +The Printf verbs %p and %T and the flags # and + are not implemented. +For floating-point and complex values, all valid formatting verbs +(%b %e %E %f %F %g %G %x %X and %v) are equivalent and accept +both decimal and hexadecimal notation (for example: "2.3e+7", "0x4.5p-8") +and digit-separating underscores (for example: "3.14159_26535_89793"). + +Input processed by verbs is implicitly space-delimited: the +implementation of every verb except %c starts by discarding +leading spaces from the remaining input, and the %s verb +(and %v reading into a string) stops consuming input at the first +space or newline character. + +The familiar base-setting prefixes 0b (binary), 0o and 0 (octal), +and 0x (hexadecimal) are accepted when scanning integers +without a format or with the %v verb, as are digit-separating +underscores. + +Width is interpreted in the input text but there is no +syntax for scanning with a precision (no %5.2f, just %5f). +If width is provided, it applies after leading spaces are +trimmed and specifies the maximum number of runes to read +to satisfy the verb. For example, + Sscanf(" 1234567 ", "%5s%d", &s, &i) +will set s to "12345" and i to 67 while + Sscanf(" 12 34 567 ", "%5s%d", &s, &i) +will set s to "12" and i to 34. + +In all the scanning functions, a carriage return followed +immediately by a newline is treated as a plain newline +(\r\n means the same as \n). + +In all the scanning functions, if an operand implements method +Scan (that is, it implements the Scanner interface) that +method will be used to scan the text for that operand. Also, +if the number of arguments scanned is less than the number of +arguments provided, an error is returned. + +All arguments to be scanned must be either pointers to basic +types or implementations of the Scanner interface. + +Like Scanf and Fscanf, Sscanf need not consume its entire input. +There is no way to recover how much of the input string Sscanf used. + +Note: Fscan etc. can read one character (rune) past the input +they return, which means that a loop calling a scan routine +may skip some of the input. This is usually a problem only +when there is no space between input values. If the reader +provided to Fscan implements ReadRune, that method will be used +to read characters. If the reader also implements UnreadRune, +that method will be used to save the character and successive +calls will not lose data. To attach ReadRune and UnreadRune +methods to a reader without that capability, use +bufio.NewReader. */ package fmt diff --git a/src/go/doc/headscan.go b/src/go/doc/headscan.go index 320895e43a..f55ca754a6 100644 --- a/src/go/doc/headscan.go +++ b/src/go/doc/headscan.go @@ -5,13 +5,13 @@ //go:build ignore /* - The headscan command extracts comment headings from package files; - it is used to detect false positives which may require an adjustment - to the comment formatting heuristics in comment.go. +The headscan command extracts comment headings from package files; +it is used to detect false positives which may require an adjustment +to the comment formatting heuristics in comment.go. - Usage: headscan [-root root_directory] +Usage: headscan [-root root_directory] - By default, the $GOROOT/src directory is scanned. +By default, the $GOROOT/src directory is scanned. */ package main diff --git a/src/net/rpc/server.go b/src/net/rpc/server.go index d5207a42cf..f53ea75f9c 100644 --- a/src/net/rpc/server.go +++ b/src/net/rpc/server.go @@ -3,126 +3,126 @@ // license that can be found in the LICENSE file. /* - Package rpc provides access to the exported methods of an object across a - network or other I/O connection. A server registers an object, making it visible - as a service with the name of the type of the object. After registration, exported - methods of the object will be accessible remotely. A server may register multiple - objects (services) of different types but it is an error to register multiple - objects of the same type. +Package rpc provides access to the exported methods of an object across a +network or other I/O connection. A server registers an object, making it visible +as a service with the name of the type of the object. After registration, exported +methods of the object will be accessible remotely. A server may register multiple +objects (services) of different types but it is an error to register multiple +objects of the same type. - Only methods that satisfy these criteria will be made available for remote access; - other methods will be ignored: +Only methods that satisfy these criteria will be made available for remote access; +other methods will be ignored: - - the method's type is exported. - - the method is exported. - - the method has two arguments, both exported (or builtin) types. - - the method's second argument is a pointer. - - the method has return type error. + - the method's type is exported. + - the method is exported. + - the method has two arguments, both exported (or builtin) types. + - the method's second argument is a pointer. + - the method has return type error. - In effect, the method must look schematically like +In effect, the method must look schematically like - func (t *T) MethodName(argType T1, replyType *T2) error + func (t *T) MethodName(argType T1, replyType *T2) error - where T1 and T2 can be marshaled by encoding/gob. - These requirements apply even if a different codec is used. - (In the future, these requirements may soften for custom codecs.) +where T1 and T2 can be marshaled by encoding/gob. +These requirements apply even if a different codec is used. +(In the future, these requirements may soften for custom codecs.) - The method's first argument represents the arguments provided by the caller; the - second argument represents the result parameters to be returned to the caller. - The method's return value, if non-nil, is passed back as a string that the client - sees as if created by errors.New. If an error is returned, the reply parameter - will not be sent back to the client. +The method's first argument represents the arguments provided by the caller; the +second argument represents the result parameters to be returned to the caller. +The method's return value, if non-nil, is passed back as a string that the client +sees as if created by errors.New. If an error is returned, the reply parameter +will not be sent back to the client. - The server may handle requests on a single connection by calling ServeConn. More - typically it will create a network listener and call Accept or, for an HTTP - listener, HandleHTTP and http.Serve. +The server may handle requests on a single connection by calling ServeConn. More +typically it will create a network listener and call Accept or, for an HTTP +listener, HandleHTTP and http.Serve. - A client wishing to use the service establishes a connection and then invokes - NewClient on the connection. The convenience function Dial (DialHTTP) performs - both steps for a raw network connection (an HTTP connection). The resulting - Client object has two methods, Call and Go, that specify the service and method to - call, a pointer containing the arguments, and a pointer to receive the result - parameters. +A client wishing to use the service establishes a connection and then invokes +NewClient on the connection. The convenience function Dial (DialHTTP) performs +both steps for a raw network connection (an HTTP connection). The resulting +Client object has two methods, Call and Go, that specify the service and method to +call, a pointer containing the arguments, and a pointer to receive the result +parameters. - The Call method waits for the remote call to complete while the Go method - launches the call asynchronously and signals completion using the Call - structure's Done channel. +The Call method waits for the remote call to complete while the Go method +launches the call asynchronously and signals completion using the Call +structure's Done channel. - Unless an explicit codec is set up, package encoding/gob is used to - transport the data. +Unless an explicit codec is set up, package encoding/gob is used to +transport the data. - Here is a simple example. A server wishes to export an object of type Arith: +Here is a simple example. A server wishes to export an object of type Arith: - package server + package server - import "errors" + import "errors" - type Args struct { - A, B int - } + type Args struct { + A, B int + } - type Quotient struct { - Quo, Rem int - } + type Quotient struct { + Quo, Rem int + } - type Arith int + type Arith int - func (t *Arith) Multiply(args *Args, reply *int) error { - *reply = args.A * args.B - return nil - } + func (t *Arith) Multiply(args *Args, reply *int) error { + *reply = args.A * args.B + return nil + } - func (t *Arith) Divide(args *Args, quo *Quotient) error { - if args.B == 0 { - return errors.New("divide by zero") - } - quo.Quo = args.A / args.B - quo.Rem = args.A % args.B - return nil + func (t *Arith) Divide(args *Args, quo *Quotient) error { + if args.B == 0 { + return errors.New("divide by zero") } + quo.Quo = args.A / args.B + quo.Rem = args.A % args.B + return nil + } - The server calls (for HTTP service): +The server calls (for HTTP service): - arith := new(Arith) - rpc.Register(arith) - rpc.HandleHTTP() - l, e := net.Listen("tcp", ":1234") - if e != nil { - log.Fatal("listen error:", e) - } - go http.Serve(l, nil) + arith := new(Arith) + rpc.Register(arith) + rpc.HandleHTTP() + l, e := net.Listen("tcp", ":1234") + if e != nil { + log.Fatal("listen error:", e) + } + go http.Serve(l, nil) - At this point, clients can see a service "Arith" with methods "Arith.Multiply" and - "Arith.Divide". To invoke one, a client first dials the server: +At this point, clients can see a service "Arith" with methods "Arith.Multiply" and +"Arith.Divide". To invoke one, a client first dials the server: - client, err := rpc.DialHTTP("tcp", serverAddress + ":1234") - if err != nil { - log.Fatal("dialing:", err) - } + client, err := rpc.DialHTTP("tcp", serverAddress + ":1234") + if err != nil { + log.Fatal("dialing:", err) + } - Then it can make a remote call: +Then it can make a remote call: - // Synchronous call - args := &server.Args{7,8} - var reply int - err = client.Call("Arith.Multiply", args, &reply) - if err != nil { - log.Fatal("arith error:", err) - } - fmt.Printf("Arith: %d*%d=%d", args.A, args.B, reply) + // Synchronous call + args := &server.Args{7,8} + var reply int + err = client.Call("Arith.Multiply", args, &reply) + if err != nil { + log.Fatal("arith error:", err) + } + fmt.Printf("Arith: %d*%d=%d", args.A, args.B, reply) - or +or - // Asynchronous call - quotient := new(Quotient) - divCall := client.Go("Arith.Divide", args, quotient, nil) - replyCall := <-divCall.Done // will be equal to divCall - // check errors, print, etc. + // Asynchronous call + quotient := new(Quotient) + divCall := client.Go("Arith.Divide", args, quotient, nil) + replyCall := <-divCall.Done // will be equal to divCall + // check errors, print, etc. - A server implementation will often provide a simple, type-safe wrapper for the - client. +A server implementation will often provide a simple, type-safe wrapper for the +client. - The net/rpc package is frozen and is not accepting new features. +The net/rpc package is frozen and is not accepting new features. */ package rpc diff --git a/src/runtime/debug/stack_test.go b/src/runtime/debug/stack_test.go index 9376e82b84..4cab8864df 100644 --- a/src/runtime/debug/stack_test.go +++ b/src/runtime/debug/stack_test.go @@ -20,22 +20,22 @@ func (t T) method() []byte { } /* - The traceback should look something like this, modulo line numbers and hex constants. - Don't worry much about the base levels, but check the ones in our own package. +The traceback should look something like this, modulo line numbers and hex constants. +Don't worry much about the base levels, but check the ones in our own package. - goroutine 10 [running]: - runtime/debug.Stack(0x0, 0x0, 0x0) - /Users/r/go/src/runtime/debug/stack.go:28 +0x80 - runtime/debug.(*T).ptrmethod(0xc82005ee70, 0x0, 0x0, 0x0) - /Users/r/go/src/runtime/debug/stack_test.go:15 +0x29 - runtime/debug.T.method(0x0, 0x0, 0x0, 0x0) - /Users/r/go/src/runtime/debug/stack_test.go:18 +0x32 - runtime/debug.TestStack(0xc8201ce000) - /Users/r/go/src/runtime/debug/stack_test.go:37 +0x38 - testing.tRunner(0xc8201ce000, 0x664b58) - /Users/r/go/src/testing/testing.go:456 +0x98 - created by testing.RunTests - /Users/r/go/src/testing/testing.go:561 +0x86d + goroutine 10 [running]: + runtime/debug.Stack(0x0, 0x0, 0x0) + /Users/r/go/src/runtime/debug/stack.go:28 +0x80 + runtime/debug.(*T).ptrmethod(0xc82005ee70, 0x0, 0x0, 0x0) + /Users/r/go/src/runtime/debug/stack_test.go:15 +0x29 + runtime/debug.T.method(0x0, 0x0, 0x0, 0x0) + /Users/r/go/src/runtime/debug/stack_test.go:18 +0x32 + runtime/debug.TestStack(0xc8201ce000) + /Users/r/go/src/runtime/debug/stack_test.go:37 +0x38 + testing.tRunner(0xc8201ce000, 0x664b58) + /Users/r/go/src/testing/testing.go:456 +0x98 + created by testing.RunTests + /Users/r/go/src/testing/testing.go:561 +0x86d */ func TestStack(t *testing.T) { b := T(0).method() diff --git a/src/unsafe/unsafe.go b/src/unsafe/unsafe.go index 16e3890d0b..a6a255658b 100644 --- a/src/unsafe/unsafe.go +++ b/src/unsafe/unsafe.go @@ -3,10 +3,10 @@ // license that can be found in the LICENSE file. /* - Package unsafe contains operations that step around the type safety of Go programs. +Package unsafe contains operations that step around the type safety of Go programs. - Packages that import unsafe may be non-portable and are not protected by the - Go 1 compatibility guidelines. +Packages that import unsafe may be non-portable and are not protected by the +Go 1 compatibility guidelines. */ package unsafe -- cgit v1.3-5-g9baa From 1a2f72619510f944289587d41fcb86cad9026f7d Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Thu, 10 Mar 2022 10:41:54 -0500 Subject: runtime/pprof: do not require a GOROOT/src prefix in tests When paths are trimmed, the reported file locations begin with the package import path (not GOROOT/src). Updates #51461 Change-Id: Idbd408a02e8d03329d10e30b0b08263e69e66285 Reviewed-on: https://go-review.googlesource.com/c/go/+/391812 Trust: Bryan Mills Run-TryBot: Bryan Mills Reviewed-by: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui --- src/runtime/pprof/mprof_test.go | 18 +++++++++--------- src/runtime/pprof/pprof_test.go | 42 ++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/pprof/mprof_test.go b/src/runtime/pprof/mprof_test.go index 665487a7c4..391588d4ac 100644 --- a/src/runtime/pprof/mprof_test.go +++ b/src/runtime/pprof/mprof_test.go @@ -93,31 +93,31 @@ func TestMemoryProfiler(t *testing.T) { }{{ stk: []string{"runtime/pprof.allocatePersistent1K", "runtime/pprof.TestMemoryProfiler"}, legacy: fmt.Sprintf(`%v: %v \[%v: %v\] @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ -# 0x[0-9,a-f]+ runtime/pprof\.allocatePersistent1K\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test\.go:47 -# 0x[0-9,a-f]+ runtime/pprof\.TestMemoryProfiler\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test\.go:82 +# 0x[0-9,a-f]+ runtime/pprof\.allocatePersistent1K\+0x[0-9,a-f]+ .*runtime/pprof/mprof_test\.go:47 +# 0x[0-9,a-f]+ runtime/pprof\.TestMemoryProfiler\+0x[0-9,a-f]+ .*runtime/pprof/mprof_test\.go:82 `, 32*memoryProfilerRun, 1024*memoryProfilerRun, 32*memoryProfilerRun, 1024*memoryProfilerRun), }, { stk: []string{"runtime/pprof.allocateTransient1M", "runtime/pprof.TestMemoryProfiler"}, legacy: fmt.Sprintf(`0: 0 \[%v: %v\] @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ -# 0x[0-9,a-f]+ runtime/pprof\.allocateTransient1M\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:24 -# 0x[0-9,a-f]+ runtime/pprof\.TestMemoryProfiler\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:79 +# 0x[0-9,a-f]+ runtime/pprof\.allocateTransient1M\+0x[0-9,a-f]+ .*runtime/pprof/mprof_test.go:24 +# 0x[0-9,a-f]+ runtime/pprof\.TestMemoryProfiler\+0x[0-9,a-f]+ .*runtime/pprof/mprof_test.go:79 `, (1<<10)*memoryProfilerRun, (1<<20)*memoryProfilerRun), }, { stk: []string{"runtime/pprof.allocateTransient2M", "runtime/pprof.TestMemoryProfiler"}, legacy: fmt.Sprintf(`0: 0 \[%v: %v\] @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ -# 0x[0-9,a-f]+ runtime/pprof\.allocateTransient2M\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:30 -# 0x[0-9,a-f]+ runtime/pprof\.TestMemoryProfiler\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:80 +# 0x[0-9,a-f]+ runtime/pprof\.allocateTransient2M\+0x[0-9,a-f]+ .*runtime/pprof/mprof_test.go:30 +# 0x[0-9,a-f]+ runtime/pprof\.TestMemoryProfiler\+0x[0-9,a-f]+ .*runtime/pprof/mprof_test.go:80 `, memoryProfilerRun, (2<<20)*memoryProfilerRun), }, { stk: []string{"runtime/pprof.allocateTransient2MInline", "runtime/pprof.TestMemoryProfiler"}, legacy: fmt.Sprintf(`0: 0 \[%v: %v\] @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ -# 0x[0-9,a-f]+ runtime/pprof\.allocateTransient2MInline\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:34 -# 0x[0-9,a-f]+ runtime/pprof\.TestMemoryProfiler\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:81 +# 0x[0-9,a-f]+ runtime/pprof\.allocateTransient2MInline\+0x[0-9,a-f]+ .*runtime/pprof/mprof_test.go:34 +# 0x[0-9,a-f]+ runtime/pprof\.TestMemoryProfiler\+0x[0-9,a-f]+ .*runtime/pprof/mprof_test.go:81 `, memoryProfilerRun, (2<<20)*memoryProfilerRun), }, { stk: []string{"runtime/pprof.allocateReflectTransient"}, legacy: fmt.Sprintf(`0: 0 \[%v: %v\] @( 0x[0-9,a-f]+)+ -# 0x[0-9,a-f]+ runtime/pprof\.allocateReflectTransient\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:55 +# 0x[0-9,a-f]+ runtime/pprof\.allocateReflectTransient\+0x[0-9,a-f]+ .*runtime/pprof/mprof_test.go:55 `, memoryProfilerRun, (2<<20)*memoryProfilerRun), }} diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index 322579cdc4..99897fcfdc 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -809,9 +809,9 @@ func TestBlockProfile(t *testing.T) { }, re: ` [0-9]+ [0-9]+ @( 0x[[:xdigit:]]+)+ -# 0x[0-9a-f]+ runtime\.chanrecv1\+0x[0-9a-f]+ .*/src/runtime/chan.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.blockChanRecv\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ runtime\.chanrecv1\+0x[0-9a-f]+ .*runtime/chan.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.blockChanRecv\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ `}, { name: "chan send", @@ -823,9 +823,9 @@ func TestBlockProfile(t *testing.T) { }, re: ` [0-9]+ [0-9]+ @( 0x[[:xdigit:]]+)+ -# 0x[0-9a-f]+ runtime\.chansend1\+0x[0-9a-f]+ .*/src/runtime/chan.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.blockChanSend\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ runtime\.chansend1\+0x[0-9a-f]+ .*runtime/chan.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.blockChanSend\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ `}, { name: "chan close", @@ -837,9 +837,9 @@ func TestBlockProfile(t *testing.T) { }, re: ` [0-9]+ [0-9]+ @( 0x[[:xdigit:]]+)+ -# 0x[0-9a-f]+ runtime\.chanrecv1\+0x[0-9a-f]+ .*/src/runtime/chan.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.blockChanClose\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ runtime\.chanrecv1\+0x[0-9a-f]+ .*runtime/chan.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.blockChanClose\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ `}, { name: "select recv async", @@ -851,9 +851,9 @@ func TestBlockProfile(t *testing.T) { }, re: ` [0-9]+ [0-9]+ @( 0x[[:xdigit:]]+)+ -# 0x[0-9a-f]+ runtime\.selectgo\+0x[0-9a-f]+ .*/src/runtime/select.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.blockSelectRecvAsync\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ runtime\.selectgo\+0x[0-9a-f]+ .*runtime/select.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.blockSelectRecvAsync\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ `}, { name: "select send sync", @@ -865,9 +865,9 @@ func TestBlockProfile(t *testing.T) { }, re: ` [0-9]+ [0-9]+ @( 0x[[:xdigit:]]+)+ -# 0x[0-9a-f]+ runtime\.selectgo\+0x[0-9a-f]+ .*/src/runtime/select.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.blockSelectSendSync\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ runtime\.selectgo\+0x[0-9a-f]+ .*runtime/select.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.blockSelectSendSync\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ `}, { name: "mutex", @@ -879,9 +879,9 @@ func TestBlockProfile(t *testing.T) { }, re: ` [0-9]+ [0-9]+ @( 0x[[:xdigit:]]+)+ -# 0x[0-9a-f]+ sync\.\(\*Mutex\)\.Lock\+0x[0-9a-f]+ .*/src/sync/mutex\.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.blockMutex\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ sync\.\(\*Mutex\)\.Lock\+0x[0-9a-f]+ .*sync/mutex\.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.blockMutex\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ `}, { name: "cond", @@ -893,9 +893,9 @@ func TestBlockProfile(t *testing.T) { }, re: ` [0-9]+ [0-9]+ @( 0x[[:xdigit:]]+)+ -# 0x[0-9a-f]+ sync\.\(\*Cond\)\.Wait\+0x[0-9a-f]+ .*/src/sync/cond\.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.blockCond\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ -# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*/src/runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ sync\.\(\*Cond\)\.Wait\+0x[0-9a-f]+ .*sync/cond\.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.blockCond\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ +# 0x[0-9a-f]+ runtime/pprof\.TestBlockProfile\+0x[0-9a-f]+ .*runtime/pprof/pprof_test.go:[0-9]+ `}, } -- cgit v1.3-5-g9baa From c6244b59095a74b77c977d250708ba1858ae2388 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Thu, 10 Mar 2022 23:57:57 -0500 Subject: runtime/debug: do not require a GOROOT/src prefix in TestStack When paths are trimmed, the reported file locations begin with the package import path (not GOROOT/src). Updates #51461. Change-Id: Ia6814f970aee11f3d933e75c75136d679d19e220 Reviewed-on: https://go-review.googlesource.com/c/go/+/391815 Trust: Bryan Mills Run-TryBot: Bryan Mills Reviewed-by: Cherry Mui TryBot-Result: Gopher Robot --- src/runtime/debug/stack_test.go | 82 ++++++++++++++++++++++++++++++++++------- 1 file changed, 69 insertions(+), 13 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/debug/stack_test.go b/src/runtime/debug/stack_test.go index 4cab8864df..671057c3a0 100644 --- a/src/runtime/debug/stack_test.go +++ b/src/runtime/debug/stack_test.go @@ -5,11 +5,26 @@ package debug_test import ( + "bytes" + "fmt" + "internal/testenv" + "os" + "os/exec" + "path/filepath" + "runtime" . "runtime/debug" "strings" "testing" ) +func TestMain(m *testing.M) { + if os.Getenv("GO_RUNTIME_DEBUG_TEST_DUMP_GOROOT") != "" { + fmt.Println(runtime.GOROOT()) + os.Exit(0) + } + os.Exit(m.Run()) +} + type T int func (t *T) ptrmethod() []byte { @@ -43,23 +58,64 @@ func TestStack(t *testing.T) { if len(lines) < 6 { t.Fatal("too few lines") } + + // If built with -trimpath, file locations should start with package paths. + // Otherwise, file locations should start with a GOROOT/src prefix + // (for whatever value of GOROOT is baked into the binary, not the one + // that may be set in the environment). + fileGoroot := "" + if envGoroot := os.Getenv("GOROOT"); envGoroot != "" { + // Since GOROOT is set explicitly in the environment, we can't be certain + // that it is the same GOROOT value baked into the binary, and we can't + // change the value in-process because runtime.GOROOT uses the value from + // initial (not current) environment. Spawn a subprocess to determine the + // real baked-in GOROOT. + t.Logf("found GOROOT %q from environment; checking embedded GOROOT value", envGoroot) + testenv.MustHaveExec(t) + exe, err := os.Executable() + if err != nil { + t.Fatal(err) + } + cmd := exec.Command(exe) + cmd.Env = append(os.Environ(), "GOROOT=", "GO_RUNTIME_DEBUG_TEST_DUMP_GOROOT=1") + out, err := cmd.Output() + if err != nil { + t.Fatal(err) + } + fileGoroot = string(bytes.TrimSpace(out)) + } else { + // Since GOROOT is not set in the environment, its value (if any) must come + // from the path embedded in the binary. + fileGoroot = runtime.GOROOT() + } + filePrefix := "" + if fileGoroot != "" { + filePrefix = filepath.ToSlash(fileGoroot) + "/src/" + } + n := 0 - frame := func(line, code string) { - check(t, lines[n], code) + frame := func(file, code string) { + t.Helper() + + line := lines[n] + if !strings.Contains(line, code) { + t.Errorf("expected %q in %q", code, line) + } n++ - check(t, lines[n], line) + + line = lines[n] + + wantPrefix := "\t" + filePrefix + file + if !strings.HasPrefix(line, wantPrefix) { + t.Errorf("in line %q, expected prefix %q", line, wantPrefix) + } n++ } n++ - frame("src/runtime/debug/stack.go", "runtime/debug.Stack") - frame("src/runtime/debug/stack_test.go", "runtime/debug_test.(*T).ptrmethod") - frame("src/runtime/debug/stack_test.go", "runtime/debug_test.T.method") - frame("src/runtime/debug/stack_test.go", "runtime/debug_test.TestStack") - frame("src/testing/testing.go", "") -} -func check(t *testing.T, line, has string) { - if !strings.Contains(line, has) { - t.Errorf("expected %q in %q", has, line) - } + frame("runtime/debug/stack.go", "runtime/debug.Stack") + frame("runtime/debug/stack_test.go", "runtime/debug_test.(*T).ptrmethod") + frame("runtime/debug/stack_test.go", "runtime/debug_test.T.method") + frame("runtime/debug/stack_test.go", "runtime/debug_test.TestStack") + frame("testing/testing.go", "") } -- cgit v1.3-5-g9baa From 2d32594396b231b39d09ec21d34b22b0270268b5 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 15 Mar 2022 21:05:11 -0700 Subject: runtime: call testenv.MustHaveCGO in a couple of tests Fixes #51695 Change-Id: Icfe9d26ecc28a7db9040d50d4661cf9e8245471e Reviewed-on: https://go-review.googlesource.com/c/go/+/392916 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills --- src/runtime/signal_windows_test.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/runtime') diff --git a/src/runtime/signal_windows_test.go b/src/runtime/signal_windows_test.go index 7c88ab573e..ebe94797fb 100644 --- a/src/runtime/signal_windows_test.go +++ b/src/runtime/signal_windows_test.go @@ -24,6 +24,7 @@ func TestVectoredHandlerDontCrashOnLibrary(t *testing.T) { t.Skip("this test can only run on windows/amd64") } testenv.MustHaveGoBuild(t) + testenv.MustHaveCGO(t) testenv.MustHaveExecPath(t, "gcc") testprog.Lock() defer testprog.Unlock() @@ -148,6 +149,7 @@ func TestLibraryCtrlHandler(t *testing.T) { t.Skip("this test can only run on windows/amd64") } testenv.MustHaveGoBuild(t) + testenv.MustHaveCGO(t) testenv.MustHaveExecPath(t, "gcc") testprog.Lock() defer testprog.Unlock() -- cgit v1.3-5-g9baa From adfee1e1e7b3236770c19d255e945613a53a34cc Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 17 Mar 2022 22:39:53 +0100 Subject: runtime/cgo: remove memset in _cgo_sys_thread_start on freebsd/arm pthread_attr_init on freebsd properly initializes the pthread_attr, there is no need to zero it before the call. The comment and code were probably copied from the linux/arm implementation. This aligns the implementation on freebsd/arm with the implementation on other freebsd architectures. Fixes #44248 Change-Id: If82ebb115b877b6c6f4862018a9419ba8d870f12 Reviewed-on: https://go-review.googlesource.com/c/go/+/393617 Trust: Tobias Klauser Run-TryBot: Tobias Klauser Reviewed-by: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Hajime Hoshi Trust: Hajime Hoshi --- src/runtime/cgo/gcc_freebsd_arm.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/cgo/gcc_freebsd_arm.c b/src/runtime/cgo/gcc_freebsd_arm.c index 74f2e0ede5..5f89978379 100644 --- a/src/runtime/cgo/gcc_freebsd_arm.c +++ b/src/runtime/cgo/gcc_freebsd_arm.c @@ -37,7 +37,6 @@ x_cgo_init(G *g, void (*setg)(void*)) pthread_attr_destroy(&attr); } - void _cgo_sys_thread_start(ThreadStart *ts) { @@ -50,12 +49,7 @@ _cgo_sys_thread_start(ThreadStart *ts) SIGFILLSET(ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); - // Not sure why the memset is necessary here, - // but without it, we get a bogus stack size - // out of pthread_attr_getstacksize. C'est la Linux. - memset(&attr, 0, sizeof attr); pthread_attr_init(&attr); - size = 0; pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; -- cgit v1.3-5-g9baa From f02108636c3b098b3153e90b6478e292628ac4f9 Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Thu, 17 Mar 2022 16:38:00 +0000 Subject: runtime: allow TestCtrlHandler to run in ConPTY Fixes #51602. Previous test would not run in a pseudo-console (ConPTY). New test avoids taskkill entirely by having the child request its own console window be closed. Verified that this runs locally (within a real console), over SSH (within a pseudo-console), and that it breaks if #41884 were reverted. Change-Id: If868b92ec36647e5d0e4107e29a2a6e048d35ced GitHub-Last-Rev: b1421e4bed2dc729c266928f002b39374d7e391a GitHub-Pull-Request: golang/go#51681 Reviewed-on: https://go-review.googlesource.com/c/go/+/392874 Reviewed-by: Bryan Mills Trust: Bryan Mills Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: Alex Brainman Trust: Alex Brainman --- src/runtime/signal_windows_test.go | 32 +++++++++----------------- src/runtime/testdata/testwinsignal/main.go | 36 +++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 23 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/signal_windows_test.go b/src/runtime/signal_windows_test.go index ebe94797fb..add23cd292 100644 --- a/src/runtime/signal_windows_test.go +++ b/src/runtime/signal_windows_test.go @@ -10,7 +10,6 @@ import ( "os/exec" "path/filepath" "runtime" - "strconv" "strings" "syscall" "testing" @@ -92,13 +91,16 @@ func TestCtrlHandler(t *testing.T) { // run test program cmd = exec.Command(exe) + var stdout bytes.Buffer var stderr bytes.Buffer + cmd.Stdout = &stdout cmd.Stderr = &stderr - outPipe, err := cmd.StdoutPipe() + inPipe, err := cmd.StdinPipe() if err != nil { - t.Fatalf("Failed to create stdout pipe: %v", err) + t.Fatalf("Failed to create stdin pipe: %v", err) } - outReader := bufio.NewReader(outPipe) + // keep inPipe alive until the end of the test + defer inPipe.Close() // in a new command window const _CREATE_NEW_CONSOLE = 0x00000010 @@ -114,29 +116,15 @@ func TestCtrlHandler(t *testing.T) { cmd.Wait() }() - // wait for child to be ready to receive signals - if line, err := outReader.ReadString('\n'); err != nil { - t.Fatalf("could not read stdout: %v", err) - } else if strings.TrimSpace(line) != "ready" { - t.Fatalf("unexpected message: %s", line) - } - - // gracefully kill pid, this closes the command window - if err := exec.Command("taskkill.exe", "/pid", strconv.Itoa(cmd.Process.Pid)).Run(); err != nil { - t.Fatalf("failed to kill: %v", err) + // check child exited gracefully, did not timeout + if err := cmd.Wait(); err != nil { + t.Fatalf("Program exited with error: %v\n%s", err, &stderr) } // check child received, handled SIGTERM - if line, err := outReader.ReadString('\n'); err != nil { - t.Fatalf("could not read stdout: %v", err) - } else if expected, got := syscall.SIGTERM.String(), strings.TrimSpace(line); expected != got { + if expected, got := syscall.SIGTERM.String(), strings.TrimSpace(stdout.String()); expected != got { t.Fatalf("Expected '%s' got: %s", expected, got) } - - // check child exited gracefully, did not timeout - if err := cmd.Wait(); err != nil { - t.Fatalf("Program exited with error: %v\n%s", err, &stderr) - } } // TestLibraryCtrlHandler tests that Go DLL allows calling program to handle console control events. diff --git a/src/runtime/testdata/testwinsignal/main.go b/src/runtime/testdata/testwinsignal/main.go index 1e7c9475fd..e1136f3887 100644 --- a/src/runtime/testdata/testwinsignal/main.go +++ b/src/runtime/testdata/testwinsignal/main.go @@ -2,18 +2,52 @@ package main import ( "fmt" + "io" + "log" "os" "os/signal" + "syscall" "time" ) func main() { + // Ensure that this process terminates when the test times out, + // even if the expected signal never arrives. + go func() { + io.Copy(io.Discard, os.Stdin) + log.Fatal("stdin is closed; terminating") + }() + + // Register to receive all signals. c := make(chan os.Signal, 1) signal.Notify(c) - fmt.Println("ready") + // Get console window handle. + kernel32 := syscall.NewLazyDLL("kernel32.dll") + getConsoleWindow := kernel32.NewProc("GetConsoleWindow") + hwnd, _, err := getConsoleWindow.Call() + if hwnd == 0 { + log.Fatal("no associated console: ", err) + } + + // Send message to close the console window. + const _WM_CLOSE = 0x0010 + user32 := syscall.NewLazyDLL("user32.dll") + postMessage := user32.NewProc("PostMessageW") + ok, _, err := postMessage.Call(hwnd, _WM_CLOSE, 0, 0) + if ok == 0 { + log.Fatal("post message failed: ", err) + } + sig := <-c + // Allow some time for the handler to complete if it's going to. + // + // (In https://go.dev/issue/41884 the handler returned immediately, + // which caused Windows to terminate the program before the goroutine + // that received the SIGTERM had a chance to actually clean up.) time.Sleep(time.Second) + + // Print the signal's name: "terminated" makes the test succeed. fmt.Println(sig) } -- cgit v1.3-5-g9baa From 3684abbf6c82d7f151a30cce6f435ee203908b2c Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Tue, 15 Mar 2022 13:27:53 -0400 Subject: all: delete regabireflect goexperiment regabireflect goexperiment was helpful in the register ABI development, to control code paths for reflect calls, before the compiler can generate register ABI everywhere. It is not necessary for now. Drop it. Change-Id: I2731197d2f496e29616c426a01045c9b685946a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/393362 Trust: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Gopher Robot Reviewed-by: Michael Knyszek --- src/internal/abi/abi_arm64.go | 2 +- src/internal/abi/abi_generic.go | 2 +- src/internal/abi/abi_ppc64x.go | 2 +- src/internal/buildcfg/exp.go | 8 ++------ src/internal/goexperiment/exp_regabireflect_off.go | 9 --------- src/internal/goexperiment/exp_regabireflect_on.go | 9 --------- src/internal/goexperiment/flags.go | 5 ----- src/reflect/abi_test.go | 2 +- src/runtime/abi_test.go | 2 +- src/runtime/asm_arm64.s | 2 +- src/runtime/asm_ppc64x.s | 2 +- 11 files changed, 9 insertions(+), 36 deletions(-) delete mode 100644 src/internal/goexperiment/exp_regabireflect_off.go delete mode 100644 src/internal/goexperiment/exp_regabireflect_on.go (limited to 'src/runtime') diff --git a/src/internal/abi/abi_arm64.go b/src/internal/abi/abi_arm64.go index 5c3dd6cbe2..8f85901c47 100644 --- a/src/internal/abi/abi_arm64.go +++ b/src/internal/abi/abi_arm64.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build goexperiment.regabireflect +//go:build goexperiment.regabiargs package abi diff --git a/src/internal/abi/abi_generic.go b/src/internal/abi/abi_generic.go index a36745f402..d7d2f3749b 100644 --- a/src/internal/abi/abi_generic.go +++ b/src/internal/abi/abi_generic.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !goexperiment.regabireflect && !amd64 +//go:build !goexperiment.regabiargs && !amd64 package abi diff --git a/src/internal/abi/abi_ppc64x.go b/src/internal/abi/abi_ppc64x.go index d47271d1a1..d51fb49bea 100644 --- a/src/internal/abi/abi_ppc64x.go +++ b/src/internal/abi/abi_ppc64x.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build goexperiment.regabireflect && (ppc64 || ppc64le) +//go:build goexperiment.regabiargs && (ppc64 || ppc64le) package abi diff --git a/src/internal/buildcfg/exp.go b/src/internal/buildcfg/exp.go index a9b29d6718..230ec0b231 100644 --- a/src/internal/buildcfg/exp.go +++ b/src/internal/buildcfg/exp.go @@ -54,7 +54,6 @@ func ParseGOEXPERIMENT(goos, goarch, goexp string) (flags, baseline goexperiment baseline = goexperiment.Flags{ RegabiWrappers: regabiSupported, - RegabiReflect: regabiSupported, RegabiArgs: regabiSupported, PacerRedesign: true, } @@ -81,7 +80,6 @@ func ParseGOEXPERIMENT(goos, goarch, goexp string) (flags, baseline goexperiment // do the right thing. names["regabi"] = func(v bool) { flags.RegabiWrappers = v - flags.RegabiReflect = v flags.RegabiArgs = v } @@ -113,17 +111,15 @@ func ParseGOEXPERIMENT(goos, goarch, goexp string) (flags, baseline goexperiment // regabi is always enabled on amd64. if goarch == "amd64" { flags.RegabiWrappers = true - flags.RegabiReflect = true flags.RegabiArgs = true } // regabi is only supported on amd64, arm64, ppc64 and ppc64le. if !regabiSupported { - flags.RegabiReflect = false flags.RegabiArgs = false } // Check regabi dependencies. - if flags.RegabiArgs && !(flags.RegabiWrappers && flags.RegabiReflect) { - err = fmt.Errorf("GOEXPERIMENT regabiargs requires regabiwrappers,regabireflect") + if flags.RegabiArgs && !flags.RegabiWrappers { + err = fmt.Errorf("GOEXPERIMENT regabiargs requires regabiwrappers") } return } diff --git a/src/internal/goexperiment/exp_regabireflect_off.go b/src/internal/goexperiment/exp_regabireflect_off.go deleted file mode 100644 index 515f4a53e6..0000000000 --- a/src/internal/goexperiment/exp_regabireflect_off.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by mkconsts.go. DO NOT EDIT. - -//go:build !goexperiment.regabireflect -// +build !goexperiment.regabireflect - -package goexperiment - -const RegabiReflect = false -const RegabiReflectInt = 0 diff --git a/src/internal/goexperiment/exp_regabireflect_on.go b/src/internal/goexperiment/exp_regabireflect_on.go deleted file mode 100644 index e8a3e9c06a..0000000000 --- a/src/internal/goexperiment/exp_regabireflect_on.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by mkconsts.go. DO NOT EDIT. - -//go:build goexperiment.regabireflect -// +build goexperiment.regabireflect - -package goexperiment - -const RegabiReflect = true -const RegabiReflectInt = 1 diff --git a/src/internal/goexperiment/flags.go b/src/internal/goexperiment/flags.go index 6d935edc2b..9150493575 100644 --- a/src/internal/goexperiment/flags.go +++ b/src/internal/goexperiment/flags.go @@ -72,11 +72,6 @@ type Flags struct { // ABI0 and ABIInternal functions. Without this, the ABIs are // assumed to be identical so cross-ABI calls are direct. RegabiWrappers bool - // RegabiReflect enables the register-passing paths in - // reflection calls. This is also gated by intArgRegs in - // reflect and runtime (which are disabled by default) so it - // can be used in targeted tests. - RegabiReflect bool // RegabiArgs enables register arguments/results in all // compiled Go functions. // diff --git a/src/reflect/abi_test.go b/src/reflect/abi_test.go index f39eb5efea..c9a4cd1c8e 100644 --- a/src/reflect/abi_test.go +++ b/src/reflect/abi_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build goexperiment.regabireflect && goexperiment.regabiargs +//go:build goexperiment.regabiargs package reflect_test diff --git a/src/runtime/abi_test.go b/src/runtime/abi_test.go index f9e8d701ce..0c9488a5f4 100644 --- a/src/runtime/abi_test.go +++ b/src/runtime/abi_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build goexperiment.regabireflect +//go:build goexperiment.regabiargs // This file contains tests specific to making sure the register ABI // works in a bunch of contexts in the runtime. diff --git a/src/runtime/asm_arm64.s b/src/runtime/asm_arm64.s index 9e9d9314ef..46ffaaa9b3 100644 --- a/src/runtime/asm_arm64.s +++ b/src/runtime/asm_arm64.s @@ -317,7 +317,7 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT|NOFRAME,$0-0 MOVW $0, R26 B runtime·morestack(SB) -#ifdef GOEXPERIMENT_regabireflect +#ifdef GOEXPERIMENT_regabiargs // spillArgs stores return values from registers to a *internal/abi.RegArgs in R20. TEXT ·spillArgs(SB),NOSPLIT,$0-0 MOVD R0, (0*8)(R20) diff --git a/src/runtime/asm_ppc64x.s b/src/runtime/asm_ppc64x.s index ae14213999..45e0c8240a 100644 --- a/src/runtime/asm_ppc64x.s +++ b/src/runtime/asm_ppc64x.s @@ -788,7 +788,7 @@ TEXT runtime·cputicks(SB),NOSPLIT,$0-8 MOVD R3, ret+0(FP) RET -#ifdef GOEXPERIMENT_regabireflect +#ifdef GOEXPERIMENT_regabiargs // spillArgs stores return values from registers to a *internal/abi.RegArgs in R20. TEXT runtime·spillArgs(SB),NOSPLIT,$0-0 MOVD R3, 0(R20) -- cgit v1.3-5-g9baa From d8bee94be2fc2afa6418f0bf2d474c103d38c094 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Wed, 16 Mar 2022 12:12:50 -0400 Subject: reflect, runtime: drop RegabiArgs conditions With the previous CL, internal/abi.IntArgRegs and FloatArgRegs is controlled by RegabiArgs (or always enabled), so there is no need to check for that goexperiment. There are a few places we guard register-ABI specific code and tests with the RegabiArgs flag. Switch to checking for the number of argument registers instead. Change-Id: I79fff9fd1e919684ffaf73aba9e7e85d5a9e1629 Reviewed-on: https://go-review.googlesource.com/c/go/+/393363 Trust: Cherry Mui Reviewed-by: Michael Knyszek Run-TryBot: Cherry Mui TryBot-Result: Gopher Robot --- src/reflect/abi.go | 7 +++---- src/runtime/debug_test.go | 5 ++--- src/runtime/stubs.go | 3 +-- src/runtime/traceback_test.go | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) (limited to 'src/runtime') diff --git a/src/reflect/abi.go b/src/reflect/abi.go index 28204b8193..9957d23768 100644 --- a/src/reflect/abi.go +++ b/src/reflect/abi.go @@ -7,7 +7,6 @@ package reflect import ( "internal/abi" "internal/goarch" - "internal/goexperiment" "unsafe" ) @@ -30,9 +29,9 @@ import ( // commented out there should be the actual values once // we're ready to use the register ABI everywhere. var ( - intArgRegs = abi.IntArgRegs * goexperiment.RegabiArgsInt - floatArgRegs = abi.FloatArgRegs * goexperiment.RegabiArgsInt - floatRegSize = uintptr(abi.EffectiveFloatRegSize * goexperiment.RegabiArgsInt) + intArgRegs = abi.IntArgRegs + floatArgRegs = abi.FloatArgRegs + floatRegSize = uintptr(abi.EffectiveFloatRegSize) ) // abiStep represents an ABI "instruction." Each instruction diff --git a/src/runtime/debug_test.go b/src/runtime/debug_test.go index 5bb0c5cee3..7698eacb59 100644 --- a/src/runtime/debug_test.go +++ b/src/runtime/debug_test.go @@ -16,7 +16,6 @@ package runtime_test import ( "fmt" "internal/abi" - "internal/goexperiment" "math" "os" "regexp" @@ -144,7 +143,7 @@ func TestDebugCall(t *testing.T) { intRegs := regs.Ints[:] floatRegs := regs.Floats[:] fval := float64(42.0) - if goexperiment.RegabiArgs { + if len(intRegs) > 0 { intRegs[0] = 42 floatRegs[0] = math.Float64bits(fval) } else { @@ -159,7 +158,7 @@ func TestDebugCall(t *testing.T) { } var result0 int var result1 float64 - if goexperiment.RegabiArgs { + if len(intRegs) > 0 { result0 = int(intRegs[0]) result1 = math.Float64frombits(floatRegs[0]) } else { diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go index ad78363bb6..cd7c91029b 100644 --- a/src/runtime/stubs.go +++ b/src/runtime/stubs.go @@ -7,7 +7,6 @@ package runtime import ( "internal/abi" "internal/goarch" - "internal/goexperiment" "runtime/internal/math" "unsafe" ) @@ -434,4 +433,4 @@ func sigpanic0() // registers the system supports. // // Protected by finlock. -var intArgRegs = abi.IntArgRegs * (goexperiment.RegabiArgsInt | goarch.IsAmd64) +var intArgRegs = abi.IntArgRegs diff --git a/src/runtime/traceback_test.go b/src/runtime/traceback_test.go index 7d8b04e14b..e50bd95ead 100644 --- a/src/runtime/traceback_test.go +++ b/src/runtime/traceback_test.go @@ -6,7 +6,7 @@ package runtime_test import ( "bytes" - "internal/goexperiment" + "internal/abi" "internal/testenv" "runtime" "strings" @@ -23,7 +23,7 @@ func TestTracebackArgs(t *testing.T) { abiSel := func(x, y string) string { // select expected output based on ABI // In noopt build we always spill arguments so the output is the same as stack ABI. - if optimized && goexperiment.RegabiArgs { + if optimized && abi.IntArgRegs > 0 { return x } return y -- cgit v1.3-5-g9baa From 9f252a0462bd8c279beec56d1538e8a6c26c44c5 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Fri, 18 Mar 2022 13:04:08 -0400 Subject: all: delete ARM64 non-register ABI fallback path Change-Id: I3996fb31789a1f8559348e059cf371774e548a8d Reviewed-on: https://go-review.googlesource.com/c/go/+/393875 Trust: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Gopher Robot Reviewed-by: Michael Knyszek --- src/internal/bytealg/compare_arm64.s | 27 ------ src/internal/bytealg/equal_arm64.s | 33 -------- src/reflect/asm_arm64.s | 10 --- src/runtime/asm_arm64.s | 155 +---------------------------------- src/runtime/memclr_arm64.s | 5 -- src/runtime/memmove_arm64.s | 5 -- src/runtime/race_arm64.s | 22 ----- 7 files changed, 1 insertion(+), 256 deletions(-) (limited to 'src/runtime') diff --git a/src/internal/bytealg/compare_arm64.s b/src/internal/bytealg/compare_arm64.s index 5a80207258..cc02c464e8 100644 --- a/src/internal/bytealg/compare_arm64.s +++ b/src/internal/bytealg/compare_arm64.s @@ -6,7 +6,6 @@ #include "textflag.h" TEXT ·Compare(SB),NOSPLIT|NOFRAME,$0-56 -#ifdef GOEXPERIMENT_regabiargs // R0 = a_base (want in R0) // R1 = a_len (want in R1) // R2 = a_cap (unused) @@ -15,28 +14,13 @@ TEXT ·Compare(SB),NOSPLIT|NOFRAME,$0-56 // R5 = b_cap (unused) MOVD R3, R2 MOVD R4, R3 -#else - MOVD a_base+0(FP), R0 - MOVD a_len+8(FP), R1 - MOVD b_base+24(FP), R2 - MOVD b_len+32(FP), R3 - MOVD $ret+48(FP), R7 -#endif B cmpbody<>(SB) TEXT runtime·cmpstring(SB),NOSPLIT|NOFRAME,$0-40 -#ifdef GOEXPERIMENT_regabiargs // R0 = a_base // R1 = a_len // R2 = b_base // R3 = b_len -#else - MOVD a_base+0(FP), R0 - MOVD a_len+8(FP), R1 - MOVD b_base+16(FP), R2 - MOVD b_len+24(FP), R3 - MOVD $ret+32(FP), R7 -#endif B cmpbody<>(SB) // On entry: @@ -44,14 +28,9 @@ TEXT runtime·cmpstring(SB),NOSPLIT|NOFRAME,$0-40 // R1 is the length of a // R2 points to the start of b // R3 is the length of b -#ifndef GOEXPERIMENT_regabiargs -// R7 points to return value (-1/0/1 will be written here) -#endif // // On exit: -#ifdef GOEXPERIMENT_regabiargs // R0 is the result -#endif // R4, R5, R6, R8, R9 and R10 are clobbered TEXT cmpbody<>(SB),NOSPLIT|NOFRAME,$0-0 CMP R0, R2 @@ -96,9 +75,6 @@ cmp: ret: MOVD $1, R0 CNEG HI, R0, R0 -#ifndef GOEXPERIMENT_regabiargs - MOVD R0, (R7) -#endif RET small: TBZ $3, R6, lt_8 @@ -141,9 +117,6 @@ samebytes: CMP R3, R1 CSET NE, R0 CNEG LO, R0, R0 -#ifndef GOEXPERIMENT_regabiargs - MOVD R0, (R7) -#endif RET cmpnext: REV R8, R4 diff --git a/src/internal/bytealg/equal_arm64.s b/src/internal/bytealg/equal_arm64.s index cf5cf54e59..d3aabba587 100644 --- a/src/internal/bytealg/equal_arm64.s +++ b/src/internal/bytealg/equal_arm64.s @@ -7,55 +7,29 @@ // memequal(a, b unsafe.Pointer, size uintptr) bool TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-25 -#ifndef GOEXPERIMENT_regabiargs - MOVD size+16(FP), R2 -#endif // short path to handle 0-byte case CBZ R2, equal -#ifndef GOEXPERIMENT_regabiargs - MOVD a+0(FP), R0 - MOVD b+8(FP), R1 - MOVD $ret+24(FP), R8 -#endif B memeqbody<>(SB) equal: MOVD $1, R0 -#ifndef GOEXPERIMENT_regabiargs - MOVB R0, ret+24(FP) -#endif RET // memequal_varlen(a, b unsafe.Pointer) bool TEXT runtime·memequal_varlen(SB),NOSPLIT,$0-17 -#ifndef GOEXPERIMENT_regabiargs - MOVD a+0(FP), R0 - MOVD b+8(FP), R1 -#endif CMP R0, R1 BEQ eq MOVD 8(R26), R2 // compiler stores size at offset 8 in the closure CBZ R2, eq -#ifndef GOEXPERIMENT_regabiargs - MOVD $ret+16(FP), R8 -#endif B memeqbody<>(SB) eq: MOVD $1, R0 -#ifndef GOEXPERIMENT_regabiargs - MOVB R0, ret+16(FP) -#endif RET // input: // R0: pointer a // R1: pointer b // R2: data len -#ifdef GOEXPERIMENT_regabiargs // at return: result in R0 -#else -// R8: address to put result -#endif - TEXT memeqbody<>(SB),NOSPLIT,$0 CMP $1, R2 // handle 1-byte special case for better performance @@ -141,14 +115,7 @@ one: BNE not_equal equal: MOVD $1, R0 -#ifndef GOEXPERIMENT_regabiargs - MOVB R0, (R8) -#endif RET not_equal: -#ifdef GOEXPERIMENT_regabiargs MOVB ZR, R0 -#else - MOVB ZR, (R8) -#endif RET diff --git a/src/reflect/asm_arm64.s b/src/reflect/asm_arm64.s index 812b8a02c3..5e91e62aa1 100644 --- a/src/reflect/asm_arm64.s +++ b/src/reflect/asm_arm64.s @@ -33,13 +33,8 @@ TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$432 ADD $LOCAL_REGARGS, RSP, R20 CALL runtime·spillArgs(SB) MOVD R26, 32(RSP) // outside of moveMakeFuncArgPtrs's arg area -#ifdef GOEXPERIMENT_regabiargs MOVD R26, R0 MOVD R20, R1 -#else - MOVD R26, 8(RSP) - MOVD R20, 16(RSP) -#endif CALL ·moveMakeFuncArgPtrs(SB) MOVD 32(RSP), R26 MOVD R26, 8(RSP) @@ -66,13 +61,8 @@ TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$432 ADD $LOCAL_REGARGS, RSP, R20 CALL runtime·spillArgs(SB) MOVD R26, 32(RSP) // outside of moveMakeFuncArgPtrs's arg area -#ifdef GOEXPERIMENT_regabiargs MOVD R26, R0 MOVD R20, R1 -#else - MOVD R26, 8(RSP) - MOVD R20, 16(RSP) -#endif CALL ·moveMakeFuncArgPtrs(SB) MOVD 32(RSP), R26 MOVD R26, 8(RSP) diff --git a/src/runtime/asm_arm64.s b/src/runtime/asm_arm64.s index 46ffaaa9b3..62deb070aa 100644 --- a/src/runtime/asm_arm64.s +++ b/src/runtime/asm_arm64.s @@ -150,11 +150,7 @@ TEXT gogo<>(SB), NOSPLIT|NOFRAME, $0 // Fn must never return. It should gogo(&g->sched) // to keep running g. TEXT runtime·mcall(SB), NOSPLIT|NOFRAME, $0-8 -#ifdef GOEXPERIMENT_regabiargs MOVD R0, R26 // context -#else - MOVD fn+0(FP), R26 // context -#endif // Save caller state in g->sched MOVD RSP, R0 @@ -175,11 +171,7 @@ TEXT runtime·mcall(SB), NOSPLIT|NOFRAME, $0-8 MOVD (g_sched+gobuf_sp)(g), R0 MOVD R0, RSP // sp = m->g0->sched.sp MOVD (g_sched+gobuf_bp)(g), R29 -#ifdef GOEXPERIMENT_regabiargs MOVD R3, R0 // arg = g -#else - MOVD R3, -8(RSP) // arg = g -#endif MOVD $0, -16(RSP) // dummy LR SUB $16, RSP MOVD 0(R26), R4 // code pointer @@ -317,7 +309,6 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT|NOFRAME,$0-0 MOVW $0, R26 B runtime·morestack(SB) -#ifdef GOEXPERIMENT_regabiargs // spillArgs stores return values from registers to a *internal/abi.RegArgs in R20. TEXT ·spillArgs(SB),NOSPLIT,$0-0 MOVD R0, (0*8)(R20) @@ -389,13 +380,6 @@ TEXT ·unspillArgs(SB),NOSPLIT,$0-0 FMOVD (30*8)(R20), F14 FMOVD (31*8)(R20), F15 RET -#else -TEXT ·spillArgs(SB),NOSPLIT,$0-0 - RET - -TEXT ·unspillArgs(SB),NOSPLIT,$0-0 - RET -#endif // reflectcall: call a function with the given argument list // func call(stackArgsType *_type, f *FuncVal, stackArgs *byte, stackArgsSize, stackRetOffset, frameSize uint32, regArgs *abi.RegArgs). @@ -536,11 +520,6 @@ CALLFN(·call1073741824, 1073741824) TEXT runtime·memhash32(SB),NOSPLIT|NOFRAME,$0-24 MOVB runtime·useAeshash(SB), R10 CBZ R10, noaes -#ifndef GOEXPERIMENT_regabiargs - MOVD p+0(FP), R0 - MOVD h+8(FP), R1 - MOVD $ret+16(FP), R2 -#endif MOVD $runtime·aeskeysched+0(SB), R3 VEOR V0.B16, V0.B16, V0.B16 @@ -554,11 +533,7 @@ TEXT runtime·memhash32(SB),NOSPLIT|NOFRAME,$0-24 AESMC V0.B16, V0.B16 AESE V2.B16, V0.B16 -#ifdef GOEXPERIMENT_regabiargs VMOV V0.D[0], R0 -#else - VST1 [V0.D1], (R2) -#endif RET noaes: B runtime·memhash32Fallback(SB) @@ -567,11 +542,6 @@ noaes: TEXT runtime·memhash64(SB),NOSPLIT|NOFRAME,$0-24 MOVB runtime·useAeshash(SB), R10 CBZ R10, noaes -#ifndef GOEXPERIMENT_regabiargs - MOVD p+0(FP), R0 - MOVD h+8(FP), R1 - MOVD $ret+16(FP), R2 -#endif MOVD $runtime·aeskeysched+0(SB), R3 VEOR V0.B16, V0.B16, V0.B16 @@ -585,11 +555,7 @@ TEXT runtime·memhash64(SB),NOSPLIT|NOFRAME,$0-24 AESMC V0.B16, V0.B16 AESE V2.B16, V0.B16 -#ifdef GOEXPERIMENT_regabiargs VMOV V0.D[0], R0 -#else - VST1 [V0.D1], (R2) -#endif RET noaes: B runtime·memhash64Fallback(SB) @@ -598,12 +564,6 @@ noaes: TEXT runtime·memhash(SB),NOSPLIT|NOFRAME,$0-32 MOVB runtime·useAeshash(SB), R10 CBZ R10, noaes -#ifndef GOEXPERIMENT_regabiargs - MOVD p+0(FP), R0 - MOVD h+8(FP), R1 - MOVD s+16(FP), R2 - MOVD $ret+24(FP), R8 -#endif B aeshashbody<>(SB) noaes: B runtime·memhashFallback(SB) @@ -612,14 +572,7 @@ noaes: TEXT runtime·strhash(SB),NOSPLIT|NOFRAME,$0-24 MOVB runtime·useAeshash(SB), R10 CBZ R10, noaes -#ifdef GOEXPERIMENT_regabiargs LDP (R0), (R0, R2) // string data / length -#else - MOVD p+0(FP), R10 // string pointer - LDP (R10), (R0, R2) // string data / length - MOVD h+8(FP), R1 - MOVD $ret+16(FP), R8 // return adddress -#endif B aeshashbody<>(SB) noaes: B runtime·strhashFallback(SB) @@ -627,11 +580,7 @@ noaes: // R0: data // R1: seed data // R2: length -#ifdef GOEXPERIMENT_regabiargs // At return, R0 = return value -#else -// R8: address to put return value -#endif TEXT aeshashbody<>(SB),NOSPLIT|NOFRAME,$0 VEOR V30.B16, V30.B16, V30.B16 VMOV R1, V30.D[0] @@ -676,19 +625,11 @@ done: AESMC V2.B16, V2.B16 AESE V0.B16, V2.B16 -#ifdef GOEXPERIMENT_regabiargs VMOV V2.D[0], R0 -#else - VST1 [V2.D1], (R8) -#endif RET aes0: -#ifdef GOEXPERIMENT_regabiargs VMOV V0.D[0], R0 -#else - VST1 [V0.D1], (R8) -#endif RET aes16: @@ -718,11 +659,8 @@ aes17to32: AESE V1.B16, V3.B16 VEOR V3.B16, V2.B16, V2.B16 -#ifdef GOEXPERIMENT_regabiargs + VMOV V2.D[0], R0 -#else - VST1 [V2.D1], (R8) -#endif RET aes33to64: @@ -765,11 +703,7 @@ aes33to64: VEOR V7.B16, V5.B16, V5.B16 VEOR V5.B16, V4.B16, V4.B16 -#ifdef GOEXPERIMENT_regabiargs VMOV V4.D[0], R0 -#else - VST1 [V4.D1], (R8) -#endif RET aes65to128: @@ -844,11 +778,7 @@ aes65to128: VEOR V11.B16, V9.B16, V9.B16 VEOR V9.B16, V8.B16, V8.B16 -#ifdef GOEXPERIMENT_regabiargs VMOV V8.D[0], R0 -#else - VST1 [V8.D1], (R8) -#endif RET aes129plus: @@ -967,11 +897,7 @@ aesloop: VEOR V4.B16, V6.B16, V4.B16 VEOR V4.B16, V0.B16, V0.B16 -#ifdef GOEXPERIMENT_regabiargs VMOV V0.D[0], R0 -#else - VST1 [V0.D1], (R8) -#endif RET TEXT runtime·procyield(SB),NOSPLIT,$0-0 @@ -1383,137 +1309,58 @@ flush: // Defined as ABIInternal since the compiler generates ABIInternal // calls to it directly and it does not use the stack-based Go ABI. TEXT runtime·panicIndex(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD R0, x+0(FP) - MOVD R1, y+8(FP) -#endif JMP runtime·goPanicIndex(SB) TEXT runtime·panicIndexU(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD R0, x+0(FP) - MOVD R1, y+8(FP) -#endif JMP runtime·goPanicIndexU(SB) TEXT runtime·panicSliceAlen(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R1, R0 MOVD R2, R1 -#else - MOVD R1, x+0(FP) - MOVD R2, y+8(FP) -#endif JMP runtime·goPanicSliceAlen(SB) TEXT runtime·panicSliceAlenU(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R1, R0 MOVD R2, R1 -#else - MOVD R1, x+0(FP) - MOVD R2, y+8(FP) -#endif JMP runtime·goPanicSliceAlenU(SB) TEXT runtime·panicSliceAcap(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R1, R0 MOVD R2, R1 -#else - MOVD R1, x+0(FP) - MOVD R2, y+8(FP) -#endif JMP runtime·goPanicSliceAcap(SB) TEXT runtime·panicSliceAcapU(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R1, R0 MOVD R2, R1 -#else - MOVD R1, x+0(FP) - MOVD R2, y+8(FP) -#endif JMP runtime·goPanicSliceAcapU(SB) TEXT runtime·panicSliceB(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD R0, x+0(FP) - MOVD R1, y+8(FP) -#endif JMP runtime·goPanicSliceB(SB) TEXT runtime·panicSliceBU(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD R0, x+0(FP) - MOVD R1, y+8(FP) -#endif JMP runtime·goPanicSliceBU(SB) TEXT runtime·panicSlice3Alen(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R2, R0 MOVD R3, R1 -#else - MOVD R2, x+0(FP) - MOVD R3, y+8(FP) -#endif JMP runtime·goPanicSlice3Alen(SB) TEXT runtime·panicSlice3AlenU(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R2, R0 MOVD R3, R1 -#else - MOVD R2, x+0(FP) - MOVD R3, y+8(FP) -#endif JMP runtime·goPanicSlice3AlenU(SB) TEXT runtime·panicSlice3Acap(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R2, R0 MOVD R3, R1 -#else - MOVD R2, x+0(FP) - MOVD R3, y+8(FP) -#endif JMP runtime·goPanicSlice3Acap(SB) TEXT runtime·panicSlice3AcapU(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R2, R0 MOVD R3, R1 -#else - MOVD R2, x+0(FP) - MOVD R3, y+8(FP) -#endif JMP runtime·goPanicSlice3AcapU(SB) TEXT runtime·panicSlice3B(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R1, R0 MOVD R2, R1 -#else - MOVD R1, x+0(FP) - MOVD R2, y+8(FP) -#endif JMP runtime·goPanicSlice3B(SB) TEXT runtime·panicSlice3BU(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R1, R0 MOVD R2, R1 -#else - MOVD R1, x+0(FP) - MOVD R2, y+8(FP) -#endif JMP runtime·goPanicSlice3BU(SB) TEXT runtime·panicSlice3C(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD R0, x+0(FP) - MOVD R1, y+8(FP) -#endif JMP runtime·goPanicSlice3C(SB) TEXT runtime·panicSlice3CU(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD R0, x+0(FP) - MOVD R1, y+8(FP) -#endif JMP runtime·goPanicSlice3CU(SB) TEXT runtime·panicSliceConvert(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R2, R0 MOVD R3, R1 -#else - MOVD R2, x+0(FP) - MOVD R3, y+8(FP) -#endif JMP runtime·goPanicSliceConvert(SB) diff --git a/src/runtime/memclr_arm64.s b/src/runtime/memclr_arm64.s index b80cca6a1c..1c35dfe0cf 100644 --- a/src/runtime/memclr_arm64.s +++ b/src/runtime/memclr_arm64.s @@ -9,11 +9,6 @@ // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) // Also called from assembly in sys_windows_arm64.s without g (but using Go stack convention). TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD ptr+0(FP), R0 - MOVD n+8(FP), R1 -#endif - CMP $16, R1 // If n is equal to 16 bytes, use zero_exact_16 to zero BEQ zero_exact_16 diff --git a/src/runtime/memmove_arm64.s b/src/runtime/memmove_arm64.s index bee3b00c47..8ec3ed86b9 100644 --- a/src/runtime/memmove_arm64.s +++ b/src/runtime/memmove_arm64.s @@ -27,11 +27,6 @@ // func memmove(to, from unsafe.Pointer, n uintptr) TEXT runtime·memmove(SB), NOSPLIT|NOFRAME, $0-24 -#ifndef GOEXPERIMENT_regabiargs - MOVD to+0(FP), R0 - MOVD from+8(FP), R1 - MOVD n+16(FP), R2 -#endif CBZ R2, copy0 // Small copies: 1..16 bytes diff --git a/src/runtime/race_arm64.s b/src/runtime/race_arm64.s index 95fec0b9c6..8c0dd25f0b 100644 --- a/src/runtime/race_arm64.s +++ b/src/runtime/race_arm64.s @@ -45,11 +45,7 @@ // Defined as ABIInternal so as to avoid introducing a wrapper, // which would make caller's PC ineffective. TEXT runtime·raceread(SB), NOSPLIT, $0-8 -#ifdef GOEXPERIMENT_regabiargs MOVD R0, R1 // addr -#else - MOVD addr+0(FP), R1 -#endif MOVD LR, R2 // void __tsan_read(ThreadState *thr, void *addr, void *pc); MOVD $__tsan_read(SB), R9 @@ -74,11 +70,7 @@ TEXT runtime·racereadpc(SB), NOSPLIT, $0-24 // Defined as ABIInternal so as to avoid introducing a wrapper, // which would make caller's PC ineffective. TEXT runtime·racewrite(SB), NOSPLIT, $0-8 -#ifdef GOEXPERIMENT_regabiargs MOVD R0, R1 // addr -#else - MOVD addr+0(FP), R1 -#endif MOVD LR, R2 // void __tsan_write(ThreadState *thr, void *addr, void *pc); MOVD $__tsan_write(SB), R9 @@ -103,13 +95,8 @@ TEXT runtime·racewritepc(SB), NOSPLIT, $0-24 // Defined as ABIInternal so as to avoid introducing a wrapper, // which would make caller's PC ineffective. TEXT runtime·racereadrange(SB), NOSPLIT, $0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R1, R2 // size MOVD R0, R1 // addr -#else - MOVD addr+0(FP), R1 - MOVD size+8(FP), R2 -#endif MOVD LR, R3 // void __tsan_read_range(ThreadState *thr, void *addr, uintptr size, void *pc); MOVD $__tsan_read_range(SB), R9 @@ -135,13 +122,8 @@ TEXT runtime·racereadrangepc1(SB), NOSPLIT, $0-24 // Defined as ABIInternal so as to avoid introducing a wrapper, // which would make caller's PC ineffective. TEXT runtime·racewriterange(SB), NOSPLIT, $0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R1, R2 // size MOVD R0, R1 // addr -#else - MOVD addr+0(FP), R1 - MOVD size+8(FP), R2 -#endif MOVD LR, R3 // void __tsan_write_range(ThreadState *thr, void *addr, uintptr size, void *pc); MOVD $__tsan_write_range(SB), R9 @@ -189,11 +171,7 @@ ret: // func runtime·racefuncenter(pc uintptr) // Called from instrumented code. TEXT runtime·racefuncenter(SB), NOSPLIT, $0-8 -#ifdef GOEXPERIMENT_regabiargs MOVD R0, R9 // callpc -#else - MOVD callpc+0(FP), R9 -#endif JMP racefuncenter<>(SB) // Common code for racefuncenter -- cgit v1.3-5-g9baa From 58631ba54f45506f2f178bb01d22273e7dfba674 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 9 Mar 2022 17:19:23 -0500 Subject: internal/testenv: add GOROOT and use it to fix tests broken with -trimpath This fixes many (but not all) of the tests that currently fail (due to a bogus path reported by runtime.GOROOT) when run with 'go test -trimpath std cmd'. Updates #51461 Change-Id: Ia2cc05705529c4859e7928f32eeceed647f2e986 Reviewed-on: https://go-review.googlesource.com/c/go/+/391806 Trust: Bryan Mills Run-TryBot: Bryan Mills Reviewed-by: Russ Cox TryBot-Result: Gopher Robot --- src/cmd/api/goapi.go | 12 ++- src/cmd/api/goapi_test.go | 2 + .../compile/internal/importer/gcimporter_test.go | 8 +- src/cmd/compile/internal/syntax/parser_test.go | 7 +- src/cmd/compile/internal/types2/main_test.go | 17 ++++ src/cmd/compile/internal/types2/stdlib_test.go | 26 +++--- src/cmd/doc/doc_test.go | 8 ++ src/cmd/go/internal/imports/scan_test.go | 3 +- src/cmd/gofmt/long_test.go | 7 +- src/cmd/internal/moddeps/moddeps_test.go | 23 +++-- src/cmd/link/internal/ld/nooptcgolink_test.go | 3 +- src/cmd/nm/nm_test.go | 2 +- src/go/importer/importer_test.go | 9 +- src/go/internal/gcimporter/gcimporter_test.go | 10 +- src/go/internal/srcimporter/srcimporter_test.go | 9 +- src/go/types/main_test.go | 17 ++++ src/go/types/stdlib_test.go | 31 +++---- src/internal/testenv/testenv.go | 101 ++++++++++++++++++++- src/net/netip/inlining_test.go | 7 +- src/path/filepath/path_test.go | 2 +- src/runtime/runtime-gdb_test.go | 18 ++-- src/time/zoneinfo_test.go | 3 +- 22 files changed, 242 insertions(+), 83 deletions(-) create mode 100644 src/cmd/compile/internal/types2/main_test.go create mode 100644 src/go/types/main_test.go (limited to 'src/runtime') diff --git a/src/cmd/api/goapi.go b/src/cmd/api/goapi.go index 2a0e109575..b2a023a9b7 100644 --- a/src/cmd/api/goapi.go +++ b/src/cmd/api/goapi.go @@ -34,9 +34,11 @@ func goCmd() string { if runtime.GOOS == "windows" { exeSuffix = ".exe" } - path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix) - if _, err := os.Stat(path); err == nil { - return path + if goroot := build.Default.GOROOT; goroot != "" { + path := filepath.Join(goroot, "bin", "go"+exeSuffix) + if _, err := os.Stat(path); err == nil { + return path + } } return "go" } @@ -127,6 +129,10 @@ var internalPkg = regexp.MustCompile(`(^|/)internal($|/)`) func main() { flag.Parse() + if build.Default.GOROOT == "" { + log.Fatalf("GOROOT not found. (If binary was built with -trimpath, $GOROOT must be set.)") + } + if !strings.Contains(runtime.Version(), "weekly") && !strings.Contains(runtime.Version(), "devel") { if *nextFiles != "" { fmt.Printf("Go version is %q, ignoring -next %s\n", runtime.Version(), *nextFiles) diff --git a/src/cmd/api/goapi_test.go b/src/cmd/api/goapi_test.go index 16e0058e5e..862ab183b2 100644 --- a/src/cmd/api/goapi_test.go +++ b/src/cmd/api/goapi_test.go @@ -9,6 +9,7 @@ import ( "flag" "fmt" "go/build" + "internal/testenv" "os" "path/filepath" "sort" @@ -22,6 +23,7 @@ func TestMain(m *testing.M) { for _, c := range contexts { c.Compiler = build.Default.Compiler } + build.Default.GOROOT = testenv.GOROOT(nil) // Warm up the import cache in parallel. var wg sync.WaitGroup diff --git a/src/cmd/compile/internal/importer/gcimporter_test.go b/src/cmd/compile/internal/importer/gcimporter_test.go index cc804aabbc..9fecf742fb 100644 --- a/src/cmd/compile/internal/importer/gcimporter_test.go +++ b/src/cmd/compile/internal/importer/gcimporter_test.go @@ -8,6 +8,7 @@ import ( "bytes" "cmd/compile/internal/types2" "fmt" + "go/build" "internal/goexperiment" "internal/testenv" "os" @@ -19,6 +20,11 @@ import ( "time" ) +func TestMain(m *testing.M) { + build.Default.GOROOT = testenv.GOROOT(nil) + os.Exit(m.Run()) +} + // skipSpecialPlatforms causes the test to be skipped for platforms where // builders (build.golang.org) don't have access to compiled packages for // import. @@ -62,7 +68,7 @@ func testPath(t *testing.T, path, srcDir string) *types2.Package { const maxTime = 30 * time.Second func testDir(t *testing.T, dir string, endTime time.Time) (nimports int) { - dirname := filepath.Join(runtime.GOROOT(), "pkg", runtime.GOOS+"_"+runtime.GOARCH, dir) + dirname := filepath.Join(testenv.GOROOT(t), "pkg", runtime.GOOS+"_"+runtime.GOARCH, dir) list, err := os.ReadDir(dirname) if err != nil { t.Fatalf("testDir(%s): %s", dirname, err) diff --git a/src/cmd/compile/internal/syntax/parser_test.go b/src/cmd/compile/internal/syntax/parser_test.go index ecb21e070b..66690a527a 100644 --- a/src/cmd/compile/internal/syntax/parser_test.go +++ b/src/cmd/compile/internal/syntax/parser_test.go @@ -8,6 +8,7 @@ import ( "bytes" "flag" "fmt" + "internal/testenv" "io/ioutil" "path/filepath" "regexp" @@ -74,12 +75,14 @@ func TestStdLib(t *testing.T) { lines uint } + goroot := testenv.GOROOT(t) + results := make(chan parseResult) go func() { defer close(results) for _, dir := range []string{ - filepath.Join(runtime.GOROOT(), "src"), - filepath.Join(runtime.GOROOT(), "misc"), + filepath.Join(goroot, "src"), + filepath.Join(goroot, "misc"), } { walkDirs(t, dir, func(filename string) { if skipRx != nil && skipRx.MatchString(filename) { diff --git a/src/cmd/compile/internal/types2/main_test.go b/src/cmd/compile/internal/types2/main_test.go new file mode 100644 index 0000000000..42d26943c4 --- /dev/null +++ b/src/cmd/compile/internal/types2/main_test.go @@ -0,0 +1,17 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2_test + +import ( + "go/build" + "internal/testenv" + "os" + "testing" +) + +func TestMain(m *testing.M) { + build.Default.GOROOT = testenv.GOROOT(nil) + os.Exit(m.Run()) +} diff --git a/src/cmd/compile/internal/types2/stdlib_test.go b/src/cmd/compile/internal/types2/stdlib_test.go index 551611da55..fda78e20d1 100644 --- a/src/cmd/compile/internal/types2/stdlib_test.go +++ b/src/cmd/compile/internal/types2/stdlib_test.go @@ -15,7 +15,6 @@ import ( "internal/testenv" "os" "path/filepath" - "runtime" "strings" "testing" "time" @@ -29,7 +28,7 @@ func TestStdlib(t *testing.T) { testenv.MustHaveGoBuild(t) pkgCount := 0 - duration := walkPkgDirs(filepath.Join(runtime.GOROOT(), "src"), func(dir string, filenames []string) { + duration := walkPkgDirs(filepath.Join(testenv.GOROOT(t), "src"), func(dir string, filenames []string) { typecheck(t, dir, filenames) pkgCount++ }, t.Error) @@ -162,7 +161,7 @@ func TestStdTest(t *testing.T) { t.Skip("skipping in short mode") } - testTestDir(t, filepath.Join(runtime.GOROOT(), "test"), + testTestDir(t, filepath.Join(testenv.GOROOT(t), "test"), "cmplxdivide.go", // also needs file cmplxdivide1.go - ignore "directive.go", // tests compiler rejection of bad directive placement - ignore "directive2.go", // tests compiler rejection of bad directive placement - ignore @@ -180,7 +179,7 @@ func TestStdFixed(t *testing.T) { t.Skip("skipping in short mode") } - testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "fixedbugs"), + testTestDir(t, filepath.Join(testenv.GOROOT(t), "test", "fixedbugs"), "bug248.go", "bug302.go", "bug369.go", // complex test instructions - ignore "issue6889.go", // gc-specific test "issue11362.go", // canonical import path check @@ -204,7 +203,7 @@ func TestStdFixed(t *testing.T) { func TestStdKen(t *testing.T) { testenv.MustHaveGoBuild(t) - testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "ken")) + testTestDir(t, filepath.Join(testenv.GOROOT(t), "test", "ken")) } // Package paths of excluded packages. @@ -311,16 +310,13 @@ func (w *walker) walk(dir string) { } // apply pkgh to the files in directory dir - // but ignore files directly under $GOROOT/src (might be temporary test files). - if dir != filepath.Join(runtime.GOROOT(), "src") { - files, err := pkgFilenames(dir) - if err != nil { - w.errh(err) - return - } - if files != nil { - w.pkgh(dir, files) - } + pkgFiles, err := pkgFilenames(dir) + if err != nil { + w.errh(err) + return + } + if pkgFiles != nil { + w.pkgh(dir, pkgFiles) } // traverse subdirectories, but don't walk into testdata diff --git a/src/cmd/doc/doc_test.go b/src/cmd/doc/doc_test.go index 0ff9edcde3..ead4f722f6 100644 --- a/src/cmd/doc/doc_test.go +++ b/src/cmd/doc/doc_test.go @@ -7,6 +7,8 @@ package main import ( "bytes" "flag" + "go/build" + "internal/testenv" "log" "os" "path/filepath" @@ -21,6 +23,12 @@ func TestMain(m *testing.M) { buildCtx.GOPATH = "" testGOPATH = true // force GOPATH mode; module test is in cmd/go/testdata/script/mod_doc.txt + // Set GOROOT in case runtime.GOROOT is wrong (for example, if the test was + // built with -trimpath). dirsInit would identify it using 'go env GOROOT', + // but we can't be sure that the 'go' in $PATH is the right one either. + buildCtx.GOROOT = testenv.GOROOT(nil) + build.Default.GOROOT = testenv.GOROOT(nil) + // Add $GOROOT/src/cmd/doc/testdata explicitly so we can access its contents in the test. // Normally testdata directories are ignored, but sending it to dirs.scan directly is // a hack that works around the check. diff --git a/src/cmd/go/internal/imports/scan_test.go b/src/cmd/go/internal/imports/scan_test.go index 7e69c56513..56efa9023f 100644 --- a/src/cmd/go/internal/imports/scan_test.go +++ b/src/cmd/go/internal/imports/scan_test.go @@ -10,7 +10,6 @@ import ( "os" "path" "path/filepath" - "runtime" "strings" "testing" ) @@ -18,7 +17,7 @@ import ( func TestScan(t *testing.T) { testenv.MustHaveGoBuild(t) - imports, testImports, err := ScanDir(filepath.Join(runtime.GOROOT(), "src/encoding/json"), Tags()) + imports, testImports, err := ScanDir(filepath.Join(testenv.GOROOT(t), "src/encoding/json"), Tags()) if err != nil { t.Fatal(err) } diff --git a/src/cmd/gofmt/long_test.go b/src/cmd/gofmt/long_test.go index 4a821705f1..a130874048 100644 --- a/src/cmd/gofmt/long_test.go +++ b/src/cmd/gofmt/long_test.go @@ -15,6 +15,7 @@ import ( "go/ast" "go/printer" "go/token" + "internal/testenv" "io" "io/fs" "os" @@ -130,7 +131,11 @@ func genFilenames(t *testing.T, filenames chan<- string) { } // otherwise, test all Go files under *root - filepath.WalkDir(*root, handleFile) + goroot := *root + if goroot == "" { + goroot = testenv.GOROOT(t) + } + filepath.WalkDir(goroot, handleFile) } func TestAll(t *testing.T) { diff --git a/src/cmd/internal/moddeps/moddeps_test.go b/src/cmd/internal/moddeps/moddeps_test.go index 56c3b2585c..a63ac71a16 100644 --- a/src/cmd/internal/moddeps/moddeps_test.go +++ b/src/cmd/internal/moddeps/moddeps_test.go @@ -15,7 +15,6 @@ import ( "os" "os/exec" "path/filepath" - "runtime" "strings" "sync" "testing" @@ -153,7 +152,7 @@ func TestAllDependencies(t *testing.T) { // module version specified in GOROOT/src/cmd/go.mod. bundleDir := t.TempDir() r := runner{ - Dir: filepath.Join(runtime.GOROOT(), "src/cmd"), + Dir: filepath.Join(testenv.GOROOT(t), "src/cmd"), Env: append(os.Environ(), modcacheEnv...), } r.run(t, goBin, "build", "-mod=readonly", "-o", bundleDir, "golang.org/x/tools/cmd/bundle") @@ -183,9 +182,9 @@ func TestAllDependencies(t *testing.T) { } }() - rel, err := filepath.Rel(runtime.GOROOT(), m.Dir) + rel, err := filepath.Rel(testenv.GOROOT(t), m.Dir) if err != nil { - t.Fatalf("filepath.Rel(%q, %q): %v", runtime.GOROOT(), m.Dir, err) + t.Fatalf("filepath.Rel(%q, %q): %v", testenv.GOROOT(t), m.Dir, err) } r := runner{ Dir: filepath.Join(gorootCopyDir, rel), @@ -252,22 +251,22 @@ func packagePattern(modulePath string) string { func makeGOROOTCopy(t *testing.T) string { t.Helper() gorootCopyDir := t.TempDir() - err := filepath.Walk(runtime.GOROOT(), func(src string, info os.FileInfo, err error) error { + err := filepath.Walk(testenv.GOROOT(t), func(src string, info os.FileInfo, err error) error { if err != nil { return err } - if info.IsDir() && src == filepath.Join(runtime.GOROOT(), ".git") { + if info.IsDir() && src == filepath.Join(testenv.GOROOT(t), ".git") { return filepath.SkipDir } - rel, err := filepath.Rel(runtime.GOROOT(), src) + rel, err := filepath.Rel(testenv.GOROOT(t), src) if err != nil { - return fmt.Errorf("filepath.Rel(%q, %q): %v", runtime.GOROOT(), src, err) + return fmt.Errorf("filepath.Rel(%q, %q): %v", testenv.GOROOT(t), src, err) } dst := filepath.Join(gorootCopyDir, rel) - if info.IsDir() && (src == filepath.Join(runtime.GOROOT(), "bin") || - src == filepath.Join(runtime.GOROOT(), "pkg")) { + if info.IsDir() && (src == filepath.Join(testenv.GOROOT(t), "bin") || + src == filepath.Join(testenv.GOROOT(t), "pkg")) { // If the OS supports symlinks, use them instead // of copying the bin and pkg directories. if err := os.Symlink(src, dst); err == nil { @@ -435,14 +434,14 @@ func findGorootModules(t *testing.T) []gorootModule { goBin := testenv.GoToolPath(t) goroot.once.Do(func() { - goroot.err = filepath.WalkDir(runtime.GOROOT(), func(path string, info fs.DirEntry, err error) error { + goroot.err = filepath.WalkDir(testenv.GOROOT(t), func(path string, info fs.DirEntry, err error) error { if err != nil { return err } if info.IsDir() && (info.Name() == "vendor" || info.Name() == "testdata") { return filepath.SkipDir } - if info.IsDir() && path == filepath.Join(runtime.GOROOT(), "pkg") { + if info.IsDir() && path == filepath.Join(testenv.GOROOT(t), "pkg") { // GOROOT/pkg contains generated artifacts, not source code. // // In https://golang.org/issue/37929 it was observed to somehow contain diff --git a/src/cmd/link/internal/ld/nooptcgolink_test.go b/src/cmd/link/internal/ld/nooptcgolink_test.go index 73548dabd4..0b76ecaecb 100644 --- a/src/cmd/link/internal/ld/nooptcgolink_test.go +++ b/src/cmd/link/internal/ld/nooptcgolink_test.go @@ -8,7 +8,6 @@ import ( "internal/testenv" "os/exec" "path/filepath" - "runtime" "testing" ) @@ -22,7 +21,7 @@ func TestNooptCgoBuild(t *testing.T) { testenv.MustHaveCGO(t) dir := t.TempDir() cmd := exec.Command(testenv.GoToolPath(t), "build", "-gcflags=-N -l", "-o", filepath.Join(dir, "a.out")) - cmd.Dir = filepath.Join(runtime.GOROOT(), "src", "runtime", "testdata", "testprogcgo") + cmd.Dir = filepath.Join(testenv.GOROOT(t), "src", "runtime", "testdata", "testprogcgo") out, err := cmd.CombinedOutput() if err != nil { t.Logf("go build output: %s", out) diff --git a/src/cmd/nm/nm_test.go b/src/cmd/nm/nm_test.go index 0d51b07a44..226c2c3bcd 100644 --- a/src/cmd/nm/nm_test.go +++ b/src/cmd/nm/nm_test.go @@ -66,7 +66,7 @@ func TestNonGoExecs(t *testing.T) { "internal/xcoff/testdata/gcc-ppc64-aix-dwarf2-exec", } for _, f := range testfiles { - exepath := filepath.Join(runtime.GOROOT(), "src", f) + exepath := filepath.Join(testenv.GOROOT(t), "src", f) if strings.HasSuffix(f, ".base64") { tf, err := obscuretestdata.DecodeToTempFile(exepath) if err != nil { diff --git a/src/go/importer/importer_test.go b/src/go/importer/importer_test.go index 27c4aa7871..91b656a88c 100644 --- a/src/go/importer/importer_test.go +++ b/src/go/importer/importer_test.go @@ -5,16 +5,21 @@ package importer import ( + "go/build" "go/token" "internal/testenv" "io" "os" "os/exec" - "runtime" "strings" "testing" ) +func TestMain(m *testing.M) { + build.Default.GOROOT = testenv.GOROOT(nil) + os.Exit(m.Run()) +} + func TestForCompiler(t *testing.T) { testenv.MustHaveGoBuild(t) @@ -49,7 +54,7 @@ func TestForCompiler(t *testing.T) { // https://github.com/golang/go#28995 mathBigInt := pkg.Scope().Lookup("Int") posn := fset.Position(mathBigInt.Pos()) // "$GOROOT/src/math/big/int.go:25:1" - filename := strings.Replace(posn.Filename, "$GOROOT", runtime.GOROOT(), 1) + filename := strings.Replace(posn.Filename, "$GOROOT", testenv.GOROOT(t), 1) data, err := os.ReadFile(filename) if err != nil { t.Fatalf("can't read file containing declaration of math/big.Int: %v", err) diff --git a/src/go/internal/gcimporter/gcimporter_test.go b/src/go/internal/gcimporter/gcimporter_test.go index 51511ea620..89b7fde836 100644 --- a/src/go/internal/gcimporter/gcimporter_test.go +++ b/src/go/internal/gcimporter/gcimporter_test.go @@ -18,6 +18,7 @@ import ( "time" "go/ast" + "go/build" "go/importer" "go/parser" "go/token" @@ -26,6 +27,11 @@ import ( . "go/internal/gcimporter" ) +func TestMain(m *testing.M) { + build.Default.GOROOT = testenv.GOROOT(nil) + os.Exit(m.Run()) +} + // skipSpecialPlatforms causes the test to be skipped for platforms where // builders (build.golang.org) don't have access to compiled packages for // import. @@ -72,7 +78,7 @@ const maxTime = 30 * time.Second var pkgExts = [...]string{".a", ".o"} // keep in sync with gcimporter.go func testDir(t *testing.T, dir string, endTime time.Time) (nimports int) { - dirname := filepath.Join(runtime.GOROOT(), "pkg", runtime.GOOS+"_"+runtime.GOARCH, dir) + dirname := filepath.Join(testenv.GOROOT(t), "pkg", runtime.GOOS+"_"+runtime.GOARCH, dir) list, err := os.ReadDir(dirname) if err != nil { t.Fatalf("testDir(%s): %s", dirname, err) @@ -162,7 +168,7 @@ func TestImportTypeparamTests(t *testing.T) { // Check go files in test/typeparam, except those that fail for a known // reason. - rootDir := filepath.Join(runtime.GOROOT(), "test", "typeparam") + rootDir := filepath.Join(testenv.GOROOT(t), "test", "typeparam") list, err := os.ReadDir(rootDir) if err != nil { t.Fatal(err) diff --git a/src/go/internal/srcimporter/srcimporter_test.go b/src/go/internal/srcimporter/srcimporter_test.go index 05b12f1636..af394665fa 100644 --- a/src/go/internal/srcimporter/srcimporter_test.go +++ b/src/go/internal/srcimporter/srcimporter_test.go @@ -13,7 +13,6 @@ import ( "os" "path" "path/filepath" - "runtime" "strings" "testing" "time" @@ -21,9 +20,7 @@ import ( func TestMain(m *testing.M) { flag.Parse() - if goTool, err := testenv.GoTool(); err == nil { - os.Setenv("PATH", filepath.Dir(goTool)+string(os.PathListSeparator)+os.Getenv("PATH")) - } + build.Default.GOROOT = testenv.GOROOT(nil) os.Exit(m.Run()) } @@ -58,7 +55,7 @@ func walkDir(t *testing.T, path string, endTime time.Time) (int, bool) { return 0, false } - list, err := os.ReadDir(filepath.Join(runtime.GOROOT(), "src", path)) + list, err := os.ReadDir(filepath.Join(testenv.GOROOT(t), "src", path)) if err != nil { t.Fatalf("walkDir %s failed (%v)", path, err) } @@ -247,7 +244,7 @@ func TestCgo(t *testing.T) { testenv.MustHaveCGO(t) importer := New(&build.Default, token.NewFileSet(), make(map[string]*types.Package)) - _, err := importer.ImportFrom("./misc/cgo/test", runtime.GOROOT(), 0) + _, err := importer.ImportFrom("./misc/cgo/test", testenv.GOROOT(t), 0) if err != nil { t.Fatalf("Import failed: %v", err) } diff --git a/src/go/types/main_test.go b/src/go/types/main_test.go new file mode 100644 index 0000000000..73d7d183f7 --- /dev/null +++ b/src/go/types/main_test.go @@ -0,0 +1,17 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types_test + +import ( + "go/build" + "internal/testenv" + "os" + "testing" +) + +func TestMain(m *testing.M) { + build.Default.GOROOT = testenv.GOROOT(nil) + os.Exit(m.Run()) +} diff --git a/src/go/types/stdlib_test.go b/src/go/types/stdlib_test.go index 5e5e09562a..69bd20b504 100644 --- a/src/go/types/stdlib_test.go +++ b/src/go/types/stdlib_test.go @@ -18,7 +18,6 @@ import ( "internal/testenv" "os" "path/filepath" - "runtime" "strings" "testing" "time" @@ -40,7 +39,7 @@ func TestStdlib(t *testing.T) { testenv.MustHaveGoBuild(t) pkgCount := 0 - duration := walkPkgDirs(filepath.Join(runtime.GOROOT(), "src"), func(dir string, filenames []string) { + duration := walkPkgDirs(filepath.Join(testenv.GOROOT(t), "src"), func(dir string, filenames []string) { typecheck(t, dir, filenames) pkgCount++ }, t.Error) @@ -163,7 +162,7 @@ func TestStdTest(t *testing.T) { t.Skip("skipping in short mode") } - testTestDir(t, filepath.Join(runtime.GOROOT(), "test"), + testTestDir(t, filepath.Join(testenv.GOROOT(t), "test"), "cmplxdivide.go", // also needs file cmplxdivide1.go - ignore "directive.go", // tests compiler rejection of bad directive placement - ignore "directive2.go", // tests compiler rejection of bad directive placement - ignore @@ -181,7 +180,7 @@ func TestStdFixed(t *testing.T) { t.Skip("skipping in short mode") } - testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "fixedbugs"), + testTestDir(t, filepath.Join(testenv.GOROOT(t), "test", "fixedbugs"), "bug248.go", "bug302.go", "bug369.go", // complex test instructions - ignore "issue6889.go", // gc-specific test "issue11362.go", // canonical import path check @@ -206,7 +205,7 @@ func TestStdFixed(t *testing.T) { func TestStdKen(t *testing.T) { testenv.MustHaveGoBuild(t) - testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "ken")) + testTestDir(t, filepath.Join(testenv.GOROOT(t), "test", "ken")) } // Package paths of excluded packages. @@ -249,7 +248,10 @@ func typecheck(t *testing.T, path string, filenames []string) { // typecheck package files conf := Config{ - Error: func(err error) { t.Error(err) }, + Error: func(err error) { + t.Helper() + t.Error(err) + }, Importer: stdLibImporter, } info := Info{Uses: make(map[*ast.Ident]Object)} @@ -322,16 +324,13 @@ func (w *walker) walk(dir string) { } // apply pkgh to the files in directory dir - // but ignore files directly under $GOROOT/src (might be temporary test files). - if dir != filepath.Join(runtime.GOROOT(), "src") { - files, err := pkgFilenames(dir) - if err != nil { - w.errh(err) - return - } - if files != nil { - w.pkgh(dir, files) - } + pkgFiles, err := pkgFilenames(dir) + if err != nil { + w.errh(err) + return + } + if pkgFiles != nil { + w.pkgh(dir, pkgFiles) } // traverse subdirectories, but don't walk into testdata diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go index d7614b0706..6ef889b02a 100644 --- a/src/internal/testenv/testenv.go +++ b/src/internal/testenv/testenv.go @@ -14,6 +14,7 @@ import ( "bytes" "errors" "flag" + "fmt" "internal/cfg" "os" "os/exec" @@ -96,6 +97,100 @@ func GoToolPath(t testing.TB) string { return path } +var ( + gorootOnce sync.Once + gorootPath string + gorootErr error +) + +func findGOROOT() (string, error) { + gorootOnce.Do(func() { + gorootPath = runtime.GOROOT() + if gorootPath != "" { + // If runtime.GOROOT() is non-empty, assume that it is valid. + // + // (It might not be: for example, the user may have explicitly set GOROOT + // to the wrong directory, or explicitly set GOROOT_FINAL but not GOROOT + // and hasn't moved the tree to GOROOT_FINAL yet. But those cases are + // rare, and if that happens the user can fix what they broke.) + return + } + + // runtime.GOROOT doesn't know where GOROOT is (perhaps because the test + // binary was built with -trimpath, or perhaps because GOROOT_FINAL was set + // without GOROOT and the tree hasn't been moved there yet). + // + // Since this is internal/testenv, we can cheat and assume that the caller + // is a test of some package in a subdirectory of GOROOT/src. ('go test' + // runs the test in the directory containing the packaged under test.) That + // means that if we start walking up the tree, we should eventually find + // GOROOT/src/go.mod, and we can report the parent directory of that. + + cwd, err := os.Getwd() + if err != nil { + gorootErr = fmt.Errorf("finding GOROOT: %w", err) + return + } + + dir := cwd + for { + parent := filepath.Dir(dir) + if parent == dir { + // dir is either "." or only a volume name. + gorootErr = fmt.Errorf("failed to locate GOROOT/src in any parent directory") + return + } + + if base := filepath.Base(dir); base != "src" { + dir = parent + continue // dir cannot be GOROOT/src if it doesn't end in "src". + } + + b, err := os.ReadFile(filepath.Join(dir, "go.mod")) + if err != nil { + if os.IsNotExist(err) { + dir = parent + continue + } + gorootErr = fmt.Errorf("finding GOROOT: %w", err) + return + } + goMod := string(b) + + for goMod != "" { + var line string + line, goMod, _ = strings.Cut(goMod, "\n") + fields := strings.Fields(line) + if len(fields) >= 2 && fields[0] == "module" && fields[1] == "std" { + // Found "module std", which is the module declaration in GOROOT/src! + gorootPath = parent + return + } + } + } + }) + + return gorootPath, gorootErr +} + +// GOROOT reports the path to the directory containing the root of the Go +// project source tree. This is normally equivalent to runtime.GOROOT, but +// works even if the test binary was built with -trimpath. +// +// If GOROOT cannot be found, GOROOT skips t if t is non-nil, +// or panics otherwise. +func GOROOT(t testing.TB) string { + path, err := findGOROOT() + if err != nil { + if t == nil { + panic(err) + } + t.Helper() + t.Skip(err) + } + return path +} + // GoTool reports the path to the Go tool. func GoTool() (string, error) { if !HasGoBuild() { @@ -105,7 +200,11 @@ func GoTool() (string, error) { if runtime.GOOS == "windows" { exeSuffix = ".exe" } - path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix) + goroot, err := findGOROOT() + if err != nil { + return "", fmt.Errorf("cannot find go tool: %w", err) + } + path := filepath.Join(goroot, "bin", "go"+exeSuffix) if _, err := os.Stat(path); err == nil { return path, nil } diff --git a/src/net/netip/inlining_test.go b/src/net/netip/inlining_test.go index 107fe1f083..52991bee8c 100644 --- a/src/net/netip/inlining_test.go +++ b/src/net/netip/inlining_test.go @@ -7,7 +7,6 @@ package netip import ( "internal/testenv" "os/exec" - "path/filepath" "regexp" "runtime" "strings" @@ -17,12 +16,8 @@ import ( func TestInlining(t *testing.T) { testenv.MustHaveGoBuild(t) t.Parallel() - var exe string - if runtime.GOOS == "windows" { - exe = ".exe" - } out, err := exec.Command( - filepath.Join(runtime.GOROOT(), "bin", "go"+exe), + testenv.GoToolPath(t), "build", "--gcflags=-m", "net/netip").CombinedOutput() diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go index 55b27f1af8..cfd0c8244d 100644 --- a/src/path/filepath/path_test.go +++ b/src/path/filepath/path_test.go @@ -1329,7 +1329,7 @@ func TestBug3486(t *testing.T) { // https://golang.org/issue/3486 if runtime.GOOS == "ios" { t.Skipf("skipping on %s/%s", runtime.GOOS, runtime.GOARCH) } - root, err := filepath.EvalSymlinks(runtime.GOROOT() + "/test") + root, err := filepath.EvalSymlinks(testenv.GOROOT(t) + "/test") if err != nil { t.Fatal(err) } diff --git a/src/runtime/runtime-gdb_test.go b/src/runtime/runtime-gdb_test.go index ee8c6c210f..bb76116ee9 100644 --- a/src/runtime/runtime-gdb_test.go +++ b/src/runtime/runtime-gdb_test.go @@ -49,7 +49,7 @@ func checkGdbEnvironment(t *testing.T) { case "plan9": t.Skip("there is no gdb on Plan 9") } - if final := os.Getenv("GOROOT_FINAL"); final != "" && runtime.GOROOT() != final { + if final := os.Getenv("GOROOT_FINAL"); final != "" && testenv.GOROOT(t) != final { t.Skip("gdb test can fail with GOROOT_FINAL pending") } } @@ -204,7 +204,7 @@ func testGdbPython(t *testing.T, cgo bool) { } args := []string{"-nx", "-q", "--batch", - "-iex", "add-auto-load-safe-path " + filepath.Join(runtime.GOROOT(), "src", "runtime"), + "-iex", "add-auto-load-safe-path " + filepath.Join(testenv.GOROOT(t), "src", "runtime"), "-ex", "set startup-with-shell off", "-ex", "set print thread-events off", } @@ -215,7 +215,7 @@ func testGdbPython(t *testing.T, cgo bool) { // Until gold and gdb can work together, temporarily load the // python script directly. args = append(args, - "-ex", "source "+filepath.Join(runtime.GOROOT(), "src", "runtime", "runtime-gdb.py"), + "-ex", "source "+filepath.Join(testenv.GOROOT(t), "src", "runtime", "runtime-gdb.py"), ) } else { args = append(args, @@ -276,7 +276,7 @@ func testGdbPython(t *testing.T, cgo bool) { cmd.Env = []string{} out, err := cmd.CombinedOutput() if err != nil && bytes.Contains(out, []byte("cannot find GOROOT")) { - t.Skipf("skipping because GOROOT=%s does not exist", runtime.GOROOT()) + t.Skipf("skipping because GOROOT=%s does not exist", testenv.GOROOT(t)) } _, file, _, _ := runtime.Caller(1) @@ -416,7 +416,7 @@ func TestGdbBacktrace(t *testing.T) { // Execute gdb commands. args := []string{"-nx", "-batch", - "-iex", "add-auto-load-safe-path " + filepath.Join(runtime.GOROOT(), "src", "runtime"), + "-iex", "add-auto-load-safe-path " + filepath.Join(testenv.GOROOT(t), "src", "runtime"), "-ex", "set startup-with-shell off", "-ex", "break main.eee", "-ex", "run", @@ -498,7 +498,7 @@ func TestGdbAutotmpTypes(t *testing.T) { // Execute gdb commands. args := []string{"-nx", "-batch", - "-iex", "add-auto-load-safe-path " + filepath.Join(runtime.GOROOT(), "src", "runtime"), + "-iex", "add-auto-load-safe-path " + filepath.Join(testenv.GOROOT(t), "src", "runtime"), "-ex", "set startup-with-shell off", "-ex", "break main.main", "-ex", "run", @@ -563,7 +563,7 @@ func TestGdbConst(t *testing.T) { // Execute gdb commands. args := []string{"-nx", "-batch", - "-iex", "add-auto-load-safe-path " + filepath.Join(runtime.GOROOT(), "src", "runtime"), + "-iex", "add-auto-load-safe-path " + filepath.Join(testenv.GOROOT(t), "src", "runtime"), "-ex", "set startup-with-shell off", "-ex", "break main.main", "-ex", "run", @@ -626,7 +626,7 @@ func TestGdbPanic(t *testing.T) { // Execute gdb commands. args := []string{"-nx", "-batch", - "-iex", "add-auto-load-safe-path " + filepath.Join(runtime.GOROOT(), "src", "runtime"), + "-iex", "add-auto-load-safe-path " + filepath.Join(testenv.GOROOT(t), "src", "runtime"), "-ex", "set startup-with-shell off", "-ex", "run", "-ex", "backtrace", @@ -701,7 +701,7 @@ func TestGdbInfCallstack(t *testing.T) { // Execute gdb commands. // 'setg_gcc' is the first point where we can reproduce the issue with just one 'run' command. args := []string{"-nx", "-batch", - "-iex", "add-auto-load-safe-path " + filepath.Join(runtime.GOROOT(), "src", "runtime"), + "-iex", "add-auto-load-safe-path " + filepath.Join(testenv.GOROOT(t), "src", "runtime"), "-ex", "set startup-with-shell off", "-ex", "break setg_gcc", "-ex", "run", diff --git a/src/time/zoneinfo_test.go b/src/time/zoneinfo_test.go index 0a5ce6d732..243ff8ebde 100644 --- a/src/time/zoneinfo_test.go +++ b/src/time/zoneinfo_test.go @@ -7,6 +7,7 @@ package time_test import ( "errors" "fmt" + "internal/testenv" "os" "reflect" "testing" @@ -137,7 +138,7 @@ func TestLoadLocationFromTZData(t *testing.T) { t.Fatal(err) } - gorootSource, ok := time.GorootZoneSource("../..") + gorootSource, ok := time.GorootZoneSource(testenv.GOROOT(t)) if !ok { t.Fatal("Failed to locate tzinfo source in GOROOT.") } -- cgit v1.3-5-g9baa From 86c8075675ed74c1f404894242c26b99800f1639 Mon Sep 17 00:00:00 2001 From: Jakub Ciolek Date: Fri, 18 Mar 2022 09:10:02 +0100 Subject: runtime: combine wbuf checks in tryGetFast and putFast Less text and improves codegen a bit. compilecmp on ARM64: runtime (*gcWork).putFast 160 -> 144 (-10.00%) (*gcWork).tryGetFast 144 -> 128 (-11.11%) scanobject 784 -> 752 (-4.08%) greyobject 800 -> 784 (-2.00%) AMD64: runtime greyobject 765 -> 748 (-2.22%) (*gcWork).tryGetFast 102 -> 85 (-16.67%) scanobject 837 -> 820 (-2.03%) (*gcWork).putFast 102 -> 89 (-12.75%) Change-Id: I6bb508afe1ba416823775c0bfc08ea9dc21de8a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/393754 Reviewed-by: Austin Clements Reviewed-by: Robert Griesemer Trust: Michael Knyszek --- src/runtime/mgcwork.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/mgcwork.go b/src/runtime/mgcwork.go index 9c3f7fd223..56d0b1cd62 100644 --- a/src/runtime/mgcwork.go +++ b/src/runtime/mgcwork.go @@ -148,9 +148,7 @@ func (w *gcWork) put(obj uintptr) { //go:nowritebarrierrec func (w *gcWork) putFast(obj uintptr) bool { wbuf := w.wbuf1 - if wbuf == nil { - return false - } else if wbuf.nobj == len(wbuf.obj) { + if wbuf == nil || wbuf.nobj == len(wbuf.obj) { return false } @@ -230,10 +228,7 @@ func (w *gcWork) tryGet() uintptr { //go:nowritebarrierrec func (w *gcWork) tryGetFast() uintptr { wbuf := w.wbuf1 - if wbuf == nil { - return 0 - } - if wbuf.nobj == 0 { + if wbuf == nil || wbuf.nobj == 0 { return 0 } -- cgit v1.3-5-g9baa From 817d6ea2b3dd08d3594341ca5ab7932c102694ad Mon Sep 17 00:00:00 2001 From: eric fang Date: Fri, 17 Dec 2021 08:26:06 +0000 Subject: runtime: delete useless TPIDR macro on arm64 The TPIDR macro in tls_arm64.h is not used anywhere, so remove it to reduce confusion. Change-Id: I04aa5e64ee30753f28f43bc67b44559d81d093c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/373357 Trust: Eric Fang Run-TryBot: Eric Fang TryBot-Result: Gopher Robot Reviewed-by: Michael Pratt --- src/runtime/tls_arm64.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/tls_arm64.h b/src/runtime/tls_arm64.h index fe5e4cee12..3aa8c63d39 100644 --- a/src/runtime/tls_arm64.h +++ b/src/runtime/tls_arm64.h @@ -10,7 +10,6 @@ #define TLS_linux #endif #ifdef TLS_linux -#define TPIDR TPIDR_EL0 #define MRS_TPIDR_R0 WORD $0xd53bd040 // MRS TPIDR_EL0, R0 #endif @@ -21,23 +20,19 @@ #define TLS_darwin #endif #ifdef TLS_darwin -#define TPIDR TPIDRRO_EL0 #define TLSG_IS_VARIABLE #define MRS_TPIDR_R0 WORD $0xd53bd060 // MRS TPIDRRO_EL0, R0 #endif #ifdef GOOS_freebsd -#define TPIDR TPIDR_EL0 #define MRS_TPIDR_R0 WORD $0xd53bd040 // MRS TPIDR_EL0, R0 #endif #ifdef GOOS_netbsd -#define TPIDR TPIDRRO_EL0 #define MRS_TPIDR_R0 WORD $0xd53bd040 // MRS TPIDRRO_EL0, R0 #endif #ifdef GOOS_openbsd -#define TPIDR TPIDR_EL0 #define MRS_TPIDR_R0 WORD $0xd53bd040 // MRS TPIDR_EL0, R0 #endif -- cgit v1.3-5-g9baa From 946167906ed8646c433c257b074a10e01f0a7dab Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Tue, 22 Mar 2022 11:52:02 -0500 Subject: runtime: make static/dynamic startup detection work with musl on ppc64le The glibc loader explicitly sets the first doubleword on the stack (R1) to $0 to indicate it was dynamically loaded. An ELFv2 ABI compliant loader will set R3/R4 to argc/argv when starting the process, and R13 to TLS. musl is not compliant. Instead it passes argc/argv like the kernel, but R3/R4 are in an undefined state and R13 is valid. With the knowledge above, the startup code can be modified to dynamically handle all three cases when linked internally. Fixes #51787 Change-Id: I5de33862c161900d9161817388bbc13a65fdc69c Reviewed-on: https://go-review.googlesource.com/c/go/+/394654 Reviewed-by: Cherry Mui Run-TryBot: Paul Murphy TryBot-Result: Gopher Robot Trust: Paul Murphy Trust: Lynn Boger --- src/runtime/rt0_linux_ppc64le.s | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/rt0_linux_ppc64le.s b/src/runtime/rt0_linux_ppc64le.s index 4f7c6e6c99..66f7e7b22a 100644 --- a/src/runtime/rt0_linux_ppc64le.s +++ b/src/runtime/rt0_linux_ppc64le.s @@ -147,25 +147,35 @@ TEXT _main<>(SB),NOSPLIT,$-8 // In a statically linked binary, the stack contains argc, // argv as argc string pointers followed by a NULL, envv as a // sequence of string pointers followed by a NULL, and auxv. - // There is no TLS base pointer. + // The TLS pointer should be initialized to 0. // - // In a dynamically linked binary, r3 contains argc, r4 - // contains argv, r5 contains envp, r6 contains auxv, and r13 + // In an ELFv2 compliant dynamically linked binary, R3 contains argc, + // R4 contains argv, R5 contains envp, R6 contains auxv, and R13 // contains the TLS pointer. // - // Figure out which case this is by looking at r4: if it's 0, - // we're statically linked; otherwise we're dynamically - // linked. - CMP R0, R4 - BNE dlink - - // Statically linked + // When loading via glibc, the first doubleword on the stack points + // to NULL a value. (that is *(uintptr)(R1) == 0). This is used to + // differentiate static vs dynamicly linked binaries. + // + // If loading with the musl loader, it doesn't follow the ELFv2 ABI. It + // passes argc/argv similar to the linux kernel, R13 (TLS) is + // initialized, and R3/R4 are undefined. + MOVD (R1), R12 + CMP R0, R12 + BEQ tls_and_argcv_in_reg + + // Arguments are passed via the stack (musl loader or a static binary) MOVD 0(R1), R3 // argc ADD $8, R1, R4 // argv + + // Did the TLS pointer get set? If so, don't change it (e.g musl). + CMP R0, R13 + BNE tls_and_argcv_in_reg + MOVD $runtime·m0+m_tls(SB), R13 // TLS ADD $0x7000, R13 -dlink: +tls_and_argcv_in_reg: BR main(SB) TEXT main(SB),NOSPLIT,$-8 -- cgit v1.3-5-g9baa From 212bda066996d1ed06e738c8b408bb2b65896064 Mon Sep 17 00:00:00 2001 From: Rhys Hiltner Date: Fri, 18 Mar 2022 11:36:39 -0700 Subject: runtime/pprof: rerun magnitude test on failure Restructure TestCPUProfileMultithreadMagnitude so it will run again with a longer duration on failure. Log the split between the user vs system CPU time that rusage reports. For #50232 Change-Id: Ice5b38ee7594dbee1eaa5686d32b968c306e3e85 Reviewed-on: https://go-review.googlesource.com/c/go/+/393934 Run-TryBot: Rhys Hiltner TryBot-Result: Gopher Robot Reviewed-by: Michael Pratt Trust: Michael Knyszek --- src/runtime/pprof/pprof_test.go | 66 ++++++++++++++++++++++++---------------- src/runtime/pprof/rusage_test.go | 8 +++-- 2 files changed, 44 insertions(+), 30 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index 99897fcfdc..ff4ecb4c68 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -188,10 +188,43 @@ func TestCPUProfileMultithreadMagnitude(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Logf("Running with %d workers", tc.workers) - var cpuTime time.Duration + var userTime, systemTime time.Duration matches := matchAndAvoidStacks(stackContains, []string{"runtime/pprof.cpuHog1"}, avoidFunctions()) - p := testCPUProfile(t, matches, func(dur time.Duration) { - cpuTime = diffCPUTime(t, func() { + acceptProfile := func(t *testing.T, p *profile.Profile) bool { + if !matches(t, p) { + return false + } + + ok := true + for i, unit := range []string{"count", "nanoseconds"} { + if have, want := p.SampleType[i].Unit, unit; have != want { + t.Logf("pN SampleType[%d]; %q != %q", i, have, want) + ok = false + } + } + + // cpuHog1 called below is the primary source of CPU + // load, but there may be some background work by the + // runtime. Since the OS rusage measurement will + // include all work done by the process, also compare + // against all samples in our profile. + var value time.Duration + for _, sample := range p.Sample { + value += time.Duration(sample.Value[1]) * time.Nanosecond + } + + totalTime := userTime + systemTime + t.Logf("compare %s user + %s system = %s vs %s", userTime, systemTime, totalTime, value) + if err := compare(totalTime, value, maxDiff); err != nil { + t.Logf("compare got %v want nil", err) + ok = false + } + + return ok + } + + testCPUProfile(t, acceptProfile, func(dur time.Duration) { + userTime, systemTime = diffCPUTime(t, func() { var wg sync.WaitGroup var once sync.Once for i := 0; i < tc.workers; i++ { @@ -206,27 +239,6 @@ func TestCPUProfileMultithreadMagnitude(t *testing.T) { wg.Wait() }) }) - - for i, unit := range []string{"count", "nanoseconds"} { - if have, want := p.SampleType[i].Unit, unit; have != want { - t.Errorf("pN SampleType[%d]; %q != %q", i, have, want) - } - } - - // cpuHog1 called above is the primary source of CPU - // load, but there may be some background work by the - // runtime. Since the OS rusage measurement will - // include all work done by the process, also compare - // against all samples in our profile. - var value time.Duration - for _, sample := range p.Sample { - value += time.Duration(sample.Value[1]) * time.Nanosecond - } - - t.Logf("compare %s vs %s", cpuTime, value) - if err := compare(cpuTime, value, maxDiff); err != nil { - t.Errorf("compare got %v want nil", err) - } }) } } @@ -476,14 +488,14 @@ func testCPUProfile(t *testing.T, matches profileMatchFunc, f func(dur time.Dura return nil } -var diffCPUTimeImpl func(f func()) time.Duration +var diffCPUTimeImpl func(f func()) (user, system time.Duration) -func diffCPUTime(t *testing.T, f func()) time.Duration { +func diffCPUTime(t *testing.T, f func()) (user, system time.Duration) { if fn := diffCPUTimeImpl; fn != nil { return fn(f) } t.Fatalf("cannot measure CPU time on GOOS=%s GOARCH=%s", runtime.GOOS, runtime.GOARCH) - return 0 + return 0, 0 } func contains(slice []string, s string) bool { diff --git a/src/runtime/pprof/rusage_test.go b/src/runtime/pprof/rusage_test.go index f274d0caa3..b82b1af768 100644 --- a/src/runtime/pprof/rusage_test.go +++ b/src/runtime/pprof/rusage_test.go @@ -15,7 +15,7 @@ func init() { diffCPUTimeImpl = diffCPUTimeRUsage } -func diffCPUTimeRUsage(f func()) time.Duration { +func diffCPUTimeRUsage(f func()) (user, system time.Duration) { ok := true var before, after syscall.Rusage @@ -32,8 +32,10 @@ func diffCPUTimeRUsage(f func()) time.Duration { } if !ok { - return 0 + return 0, 0 } - return time.Duration((after.Utime.Nano() + after.Stime.Nano()) - (before.Utime.Nano() + before.Stime.Nano())) + user = time.Duration(after.Utime.Nano() - before.Utime.Nano()) + system = time.Duration(after.Stime.Nano() - before.Stime.Nano()) + return user, system } -- cgit v1.3-5-g9baa From b2643c673970676065e4683bbbaa087db694bbc9 Mon Sep 17 00:00:00 2001 From: Romanos Skiadas Date: Wed, 23 Mar 2022 13:47:08 +0200 Subject: runtime: update framepointer_enabled doc Change-Id: I69e64ebf8c11145ce32aa4c11178e3a47d22fb84 Reviewed-on: https://go-review.googlesource.com/c/go/+/394915 Reviewed-by: Michael Pratt Trust: Michael Knyszek --- src/runtime/runtime2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/runtime') diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 3d01ac5171..1fb9e195e5 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -1129,5 +1129,5 @@ var ( isarchive bool // -buildmode=c-archive ) -// Must agree with internal/buildcfg.Experiment.FramePointer. +// Must agree with internal/buildcfg.FramePointerEnabled. const framepointer_enabled = GOARCH == "amd64" || GOARCH == "arm64" -- cgit v1.3-5-g9baa From 56400fc70675cc2f404f33e3ed13386967cfe4da Mon Sep 17 00:00:00 2001 From: Meng Zhuo Date: Wed, 3 Nov 2021 18:01:09 +0800 Subject: reflect, runtime: add reflect support for regabi on riscv64 This CL adds regabi support needed for reflect. Change-Id: Ib78f8c7765f03e3a7b46e8b115bf8870b8076e6a Reviewed-on: https://go-review.googlesource.com/c/go/+/360994 Trust: mzh Run-TryBot: mzh TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui --- src/reflect/asm_riscv64.s | 54 ++++++++++++++++++++++++++++++++++++++++------- src/runtime/stack.go | 3 ++- 2 files changed, 48 insertions(+), 9 deletions(-) (limited to 'src/runtime') diff --git a/src/reflect/asm_riscv64.s b/src/reflect/asm_riscv64.s index e707112277..8ca1d3bbd9 100644 --- a/src/reflect/asm_riscv64.s +++ b/src/reflect/asm_riscv64.s @@ -5,34 +5,72 @@ #include "textflag.h" #include "funcdata.h" +// The frames of each of the two functions below contain two locals, at offsets +// that are known to the runtime. +// +// The first local is a bool called retValid with a whole pointer-word reserved +// for it on the stack. The purpose of this word is so that the runtime knows +// whether the stack-allocated return space contains valid values for stack +// scanning. +// +// The second local is an abi.RegArgs value whose offset is also known to the +// runtime, so that a stack map for it can be constructed, since it contains +// pointers visible to the GC. +#define LOCAL_RETVALID 40 +#define LOCAL_REGARGS 48 + +// The frame size of the functions below is +// 32 (args of callReflect/callMethod) + (8 bool with padding) + 392 (abi.RegArgs) = 432. + // makeFuncStub is the code half of the function returned by MakeFunc. // See the comment on the declaration of makeFuncStub in makefunc.go // for more details. // No arg size here, runtime pulls arg map out of the func value. -TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$40 +TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$432 NO_LOCAL_POINTERS + ADD $LOCAL_REGARGS, SP, X25 // spillArgs using X25 + CALL runtime·spillArgs(SB) + MOV CTXT, 32(SP) // save CTXT > args of moveMakeFuncArgPtrs < LOCAL_REGARGS + MOV CTXT, 8(SP) + MOV X25, 16(SP) + CALL ·moveMakeFuncArgPtrs(SB) + MOV 32(SP), CTXT // restore CTXT + MOV CTXT, 8(SP) MOV $argframe+0(FP), T0 MOV T0, 16(SP) - ADD $40, SP, T1 + MOV ZERO, LOCAL_RETVALID(SP) + ADD $LOCAL_RETVALID, SP, T1 MOV T1, 24(SP) - MOV ZERO, 32(SP) - MOVB ZERO, 40(SP) + MOV $LOCAL_REGARGS, SP, T1 + MOV T1, 32(SP) CALL ·callReflect(SB) + ADD $LOCAL_REGARGS, SP, X25 // unspillArgs using X25 + CALL runtime·unspillArgs(SB) RET // methodValueCall is the code half of the function returned by makeMethodValue. // See the comment on the declaration of methodValueCall in makefunc.go // for more details. // No arg size here; runtime pulls arg map out of the func value. -TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$40 +TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$432 NO_LOCAL_POINTERS + ADD $LOCAL_REGARGS, SP, X25 // spillArgs using X25 + CALL runtime·spillArgs(SB) + MOV CTXT, 32(SP) // save CTXT + MOV CTXT, 8(SP) + MOV X25, 16(SP) + CALL ·moveMakeFuncArgPtrs(SB) + MOV 32(SP), CTXT // restore CTXT MOV CTXT, 8(SP) MOV $argframe+0(FP), T0 MOV T0, 16(SP) - ADD $40, SP, T1 + MOV ZERO, LOCAL_RETVALID(SP) + ADD $LOCAL_RETVALID, SP, T1 MOV T1, 24(SP) - MOV ZERO, 32(SP) - MOVB ZERO, 40(SP) + MOV $LOCAL_REGARGS, SP, T1 + MOV T1, 32(SP) // frame size to 32+SP as callreflect args CALL ·callMethod(SB) + ADD $LOCAL_REGARGS, SP, X25 // unspillArgs using X25 + CALL runtime·unspillArgs(SB) RET diff --git a/src/runtime/stack.go b/src/runtime/stack.go index edc37d4878..54a02173c3 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -1332,7 +1332,8 @@ func getStackMap(frame *stkframe, cache *pcvalueCache, debug bool) (locals, args } // stack objects. - if (GOARCH == "amd64" || GOARCH == "arm64" || GOARCH == "ppc64" || GOARCH == "ppc64le") && unsafe.Sizeof(abi.RegArgs{}) > 0 && frame.argmap != nil { + if (GOARCH == "amd64" || GOARCH == "arm64" || GOARCH == "ppc64" || GOARCH == "ppc64le" || GOARCH == "riscv64") && + unsafe.Sizeof(abi.RegArgs{}) > 0 && frame.argmap != nil { // argmap is set when the function is reflect.makeFuncStub or reflect.methodValueCall. // We don't actually use argmap in this case, but we need to fake the stack object // record for these frames which contain an internal/abi.RegArgs at a hard-coded offset. -- cgit v1.3-5-g9baa From ad646b33c9fd2366c91a44b262910c1064b24f11 Mon Sep 17 00:00:00 2001 From: mzh Date: Sun, 27 Mar 2022 23:08:32 +0000 Subject: Revert "reflect, runtime: add reflect support for regabi on riscv64" This reverts commit 56400fc70675cc2f404f33e3ed13386967cfe4da. Reason for revert: this CL requires CL360296 be merged Change-Id: I4c48c4d23b73b6e892cf86cbbc864698ebc5c992 Reviewed-on: https://go-review.googlesource.com/c/go/+/396076 Reviewed-by: Ian Lance Taylor Trust: mzh Run-TryBot: mzh TryBot-Result: Gopher Robot --- src/reflect/asm_riscv64.s | 54 +++++++---------------------------------------- src/runtime/stack.go | 3 +-- 2 files changed, 9 insertions(+), 48 deletions(-) (limited to 'src/runtime') diff --git a/src/reflect/asm_riscv64.s b/src/reflect/asm_riscv64.s index 8ca1d3bbd9..e707112277 100644 --- a/src/reflect/asm_riscv64.s +++ b/src/reflect/asm_riscv64.s @@ -5,72 +5,34 @@ #include "textflag.h" #include "funcdata.h" -// The frames of each of the two functions below contain two locals, at offsets -// that are known to the runtime. -// -// The first local is a bool called retValid with a whole pointer-word reserved -// for it on the stack. The purpose of this word is so that the runtime knows -// whether the stack-allocated return space contains valid values for stack -// scanning. -// -// The second local is an abi.RegArgs value whose offset is also known to the -// runtime, so that a stack map for it can be constructed, since it contains -// pointers visible to the GC. -#define LOCAL_RETVALID 40 -#define LOCAL_REGARGS 48 - -// The frame size of the functions below is -// 32 (args of callReflect/callMethod) + (8 bool with padding) + 392 (abi.RegArgs) = 432. - // makeFuncStub is the code half of the function returned by MakeFunc. // See the comment on the declaration of makeFuncStub in makefunc.go // for more details. // No arg size here, runtime pulls arg map out of the func value. -TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$432 +TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$40 NO_LOCAL_POINTERS - ADD $LOCAL_REGARGS, SP, X25 // spillArgs using X25 - CALL runtime·spillArgs(SB) - MOV CTXT, 32(SP) // save CTXT > args of moveMakeFuncArgPtrs < LOCAL_REGARGS - MOV CTXT, 8(SP) - MOV X25, 16(SP) - CALL ·moveMakeFuncArgPtrs(SB) - MOV 32(SP), CTXT // restore CTXT - MOV CTXT, 8(SP) MOV $argframe+0(FP), T0 MOV T0, 16(SP) - MOV ZERO, LOCAL_RETVALID(SP) - ADD $LOCAL_RETVALID, SP, T1 + ADD $40, SP, T1 MOV T1, 24(SP) - MOV $LOCAL_REGARGS, SP, T1 - MOV T1, 32(SP) + MOV ZERO, 32(SP) + MOVB ZERO, 40(SP) CALL ·callReflect(SB) - ADD $LOCAL_REGARGS, SP, X25 // unspillArgs using X25 - CALL runtime·unspillArgs(SB) RET // methodValueCall is the code half of the function returned by makeMethodValue. // See the comment on the declaration of methodValueCall in makefunc.go // for more details. // No arg size here; runtime pulls arg map out of the func value. -TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$432 +TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$40 NO_LOCAL_POINTERS - ADD $LOCAL_REGARGS, SP, X25 // spillArgs using X25 - CALL runtime·spillArgs(SB) - MOV CTXT, 32(SP) // save CTXT - MOV CTXT, 8(SP) - MOV X25, 16(SP) - CALL ·moveMakeFuncArgPtrs(SB) - MOV 32(SP), CTXT // restore CTXT MOV CTXT, 8(SP) MOV $argframe+0(FP), T0 MOV T0, 16(SP) - MOV ZERO, LOCAL_RETVALID(SP) - ADD $LOCAL_RETVALID, SP, T1 + ADD $40, SP, T1 MOV T1, 24(SP) - MOV $LOCAL_REGARGS, SP, T1 - MOV T1, 32(SP) // frame size to 32+SP as callreflect args + MOV ZERO, 32(SP) + MOVB ZERO, 40(SP) CALL ·callMethod(SB) - ADD $LOCAL_REGARGS, SP, X25 // unspillArgs using X25 - CALL runtime·unspillArgs(SB) RET diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 54a02173c3..edc37d4878 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -1332,8 +1332,7 @@ func getStackMap(frame *stkframe, cache *pcvalueCache, debug bool) (locals, args } // stack objects. - if (GOARCH == "amd64" || GOARCH == "arm64" || GOARCH == "ppc64" || GOARCH == "ppc64le" || GOARCH == "riscv64") && - unsafe.Sizeof(abi.RegArgs{}) > 0 && frame.argmap != nil { + if (GOARCH == "amd64" || GOARCH == "arm64" || GOARCH == "ppc64" || GOARCH == "ppc64le") && unsafe.Sizeof(abi.RegArgs{}) > 0 && frame.argmap != nil { // argmap is set when the function is reflect.makeFuncStub or reflect.methodValueCall. // We don't actually use argmap in this case, but we need to fake the stack object // record for these frames which contain an internal/abi.RegArgs at a hard-coded offset. -- cgit v1.3-5-g9baa From d6a1ffd624bd0d6dbf3a15070e378749612b35c9 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 21 Feb 2022 09:52:14 +0100 Subject: runtime/race: update runtime (v3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New tsan runtime (v3) built on llvm commit 1784fe0532a6. The new runtime features: - 2x smaller shadow memory (2x of app memory) - faster fully vectorized (on x86) race detection - small fixed-size vector clocks (512b) - fast vectorized vector clock operations - unlimited number of alive threads/goroutines Some random subset of benchmarks: encoding/json: CodeEncoder-72 20.3ms ± 6% 11.7ms ± 4% -42.02% (p=0.000 n=10+8) CodeMarshal-72 22.3ms ±11% 12.7ms ±11% -43.28% (p=0.000 n=10+10) CodeDecoder-72 46.1ms ±42% 20.2ms ± 7% -56.18% (p=0.000 n=10+10) CodeUnmarshal-72 16.7ms ±14% 13.2ms ± 9% -20.93% (p=0.000 n=10+10) CodeUnmarshalReuse-72 17.7ms ±17% 12.8ms ± 8% -27.58% (p=0.000 n=10+10) net/http: ClientServerParallel4-72 914µs ±18% 72µs ± 5% -92.16% (p=0.000 n=20+18) ClientServerParallel64-72 1.77ms ±16% 0.12ms ±29% -93.43% (p=0.000 n=20+17) ClientServerParallelTLS4-72 1.99ms ±33% 0.20ms ± 5% -89.83% (p=0.000 n=19+17) ClientServerParallelTLS64-72 2.72ms ±26% 0.25ms ±16% -90.96% (p=0.000 n=20+16) compress/flate: Decode/Digits/Huffman/1e4-72 2.53ms ± 3% 1.47ms ± 4% -41.72% (p=0.000 n=9+10) Decode/Digits/Speed/1e4-72 2.59ms ± 5% 1.52ms ± 3% -41.44% (p=0.000 n=8+9) Decode/Digits/Default/1e4-72 2.56ms ± 6% 1.51ms ± 4% -40.96% (p=0.000 n=10+10) Decode/Digits/Compression/1e4-72 2.54ms ± 6% 1.52ms ± 2% -40.14% (p=0.000 n=10+9) Decode/Newton/Huffman/1e4-72 2.65ms ± 3% 1.58ms ± 4% -40.45% (p=0.000 n=10+10) Decode/Newton/Speed/1e4-72 2.16ms ± 9% 1.28ms ± 5% -40.59% (p=0.000 n=10+10) Decode/Newton/Default/1e4-72 2.01ms ± 8% 1.16ms ± 6% -42.11% (p=0.000 n=10+10) Decode/Newton/Compression/1e4-72 1.99ms ± 6% 1.17ms ± 3% -41.05% (p=0.000 n=9+10) Encode/Digits/Huffman/1e4-72 2.05ms ± 2% 0.75ms ± 5% -63.32% (p=0.000 n=10+10) Encode/Digits/Speed/1e4-72 2.89ms ± 2% 1.37ms ± 2% -52.56% (p=0.000 n=9+10) Encode/Digits/Default/1e4-72 7.55ms ± 2% 3.86ms ± 4% -48.93% (p=0.000 n=8+10) Encode/Digits/Compression/1e4-72 7.46ms ± 4% 3.88ms ± 4% -48.07% (p=0.000 n=9+9) Encode/Newton/Huffman/1e4-72 2.20ms ± 4% 0.90ms ± 6% -59.01% (p=0.000 n=10+10) Encode/Newton/Speed/1e4-72 2.62ms ± 2% 1.30ms ± 4% -50.52% (p=0.000 n=9+10) Encode/Newton/Default/1e4-72 7.40ms ± 5% 3.72ms ± 2% -49.65% (p=0.000 n=10+9) Encode/Newton/Compression/1e4-72 7.67ms ± 9% 3.85ms ± 4% -49.87% (p=0.000 n=10+10) encoding/json short tests: Time 2.34sec ± 6% 1.67sec ±11% -28.85% (p=0.000 n=10+10) Memory 266MB ± 1% 190MB ± 9% -28.78% (p=0.000 n=10+10) compress/flate short tests: Time 4.69sec ± 4% 2.78sec ± 3% -40.61% (p=0.000 n=10+10) Memory 284MB ± 5% 181MB ± 4% -36.04% (p=0.000 n=10+9) sync short tests: Time 4.87sec ± 4% 0.87sec ± 6% -82.21% (p=0.000 n=10+10) Memory 147MB ± 3% 99MB ± 8% -32.47% (p=0.000 n=10+9) Fixes #47056 Fixes #38184 Change-Id: I0cf228f2e4cac7778d34d33e46df7c081645f5d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/333529 Run-TryBot: Dmitry Vyukov TryBot-Result: Gopher Robot Reviewed-by: Dmitry Vyukov Trust: Dmitry Vyukov Reviewed-by: Cherry Mui --- src/runtime/race/README | 2 +- src/runtime/race/race_linux_amd64.syso | Bin 525176 -> 552768 bytes 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'src/runtime') diff --git a/src/runtime/race/README b/src/runtime/race/README index d3c55182ef..fdbf1d55e6 100644 --- a/src/runtime/race/README +++ b/src/runtime/race/README @@ -6,7 +6,7 @@ To update the .syso files use golang.org/x/build/cmd/racebuild. race_darwin_amd64.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 with https://reviews.llvm.org/D114825 applied and Go 7ccbcc90560468937f02609a43cb39a6e13ff797. race_freebsd_amd64.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 and Go f62d3202bf9dbb3a00ad2a2c63ff4fa4188c5d3b. -race_linux_amd64.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 and Go f62d3202bf9dbb3a00ad2a2c63ff4fa4188c5d3b. +race_linux_amd64.syso built with LLVM 41cb504b7c4b18ac15830107431a0c1eec73a6b2 and Go 851ecea4cc99ab276109493477b2c7e30c253ea8. race_linux_ppc64le.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 and Go f62d3202bf9dbb3a00ad2a2c63ff4fa4188c5d3b. race_netbsd_amd64.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 and Go f62d3202bf9dbb3a00ad2a2c63ff4fa4188c5d3b. race_windows_amd64.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 and Go f62d3202bf9dbb3a00ad2a2c63ff4fa4188c5d3b. diff --git a/src/runtime/race/race_linux_amd64.syso b/src/runtime/race/race_linux_amd64.syso index e00398c964..a23064efac 100644 Binary files a/src/runtime/race/race_linux_amd64.syso and b/src/runtime/race/race_linux_amd64.syso differ -- cgit v1.3-5-g9baa From 0a69c98214839a07cb4ac16466fa7961e537881f Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Fri, 18 Mar 2022 18:49:39 -0400 Subject: all: delete PPC64 non-register ABI fallback path Change-Id: Ie058c0549167b256ad943a0134907df3aca4a69f Reviewed-on: https://go-review.googlesource.com/c/go/+/394215 Trust: Cherry Mui Run-TryBot: Cherry Mui Reviewed-by: Michael Knyszek TryBot-Result: Gopher Robot --- src/internal/bytealg/compare_ppc64x.s | 98 ++++++++------------------------- src/internal/bytealg/count_ppc64x.s | 37 +++---------- src/internal/bytealg/equal_ppc64x.s | 29 +++------- src/internal/bytealg/index_ppc64x.s | 69 +++++------------------ src/internal/bytealg/indexbyte_ppc64x.s | 34 ++++-------- src/runtime/asm_ppc64x.s | 92 ------------------------------- src/runtime/memclr_ppc64x.s | 6 +- src/runtime/memmove_ppc64x.s | 8 +-- src/runtime/race_ppc64le.s | 30 ++-------- 9 files changed, 76 insertions(+), 327 deletions(-) (limited to 'src/runtime') diff --git a/src/internal/bytealg/compare_ppc64x.s b/src/internal/bytealg/compare_ppc64x.s index 2793e44e8b..fc6f170ca8 100644 --- a/src/internal/bytealg/compare_ppc64x.s +++ b/src/internal/bytealg/compare_ppc64x.s @@ -8,24 +8,16 @@ #include "textflag.h" TEXT ·Compare(SB),NOSPLIT|NOFRAME,$0-56 -#ifdef GOEXPERIMENT_regabiargs -// incoming: -// R3 a addr -> R5 -// R4 a len -> R3 -// R5 a cap unused -// R6 b addr -> R6 -// R7 b len -> R4 -// R8 b cap unused + // incoming: + // R3 a addr -> R5 + // R4 a len -> R3 + // R5 a cap unused + // R6 b addr -> R6 + // R7 b len -> R4 + // R8 b cap unused MOVD R3, R5 MOVD R4, R3 MOVD R7, R4 -#else - MOVD a_base+0(FP), R5 - MOVD b_base+24(FP), R6 - MOVD a_len+8(FP), R3 - MOVD b_len+32(FP), R4 - MOVD $ret+48(FP), R7 -#endif CMP R5,R6,CR7 CMP R3,R4,CR6 BEQ CR7,equal @@ -40,39 +32,23 @@ equal: BGT CR6,greater NEG R8 greater: -#ifdef GOEXPERIMENT_regabiargs MOVD R8, R3 -#else - MOVD R8, (R7) -#endif RET done: -#ifdef GOEXPERIMENT_regabiargs MOVD $0, R3 -#else - MOVD $0, (R7) -#endif RET TEXT runtime·cmpstring(SB),NOSPLIT|NOFRAME,$0-40 -#ifdef GOEXPERIMENT_regabiargs -// incoming: -// R3 a addr -> R5 -// R4 a len -> R3 -// R5 b addr -> R6 -// R6 b len -> R4 + // incoming: + // R3 a addr -> R5 + // R4 a len -> R3 + // R5 b addr -> R6 + // R6 b len -> R4 MOVD R6, R7 MOVD R5, R6 MOVD R3, R5 MOVD R4, R3 MOVD R7, R4 -#else - MOVD a_base+0(FP), R5 - MOVD b_base+16(FP), R6 - MOVD a_len+8(FP), R3 - MOVD b_len+24(FP), R4 - MOVD $ret+32(FP), R7 -#endif CMP R5,R6,CR7 CMP R3,R4,CR6 BEQ CR7,equal @@ -87,19 +63,11 @@ equal: BGT CR6,greater NEG R8 greater: -#ifdef GOEXPERIMENT_regabiargs MOVD R8, R3 -#else - MOVD R8, (R7) -#endif RET done: -#ifdef GOEXPERIMENT_regabiargs MOVD $0, R3 -#else - MOVD $0, (R7) -#endif RET // Do an efficient memcmp for ppc64le @@ -107,7 +75,8 @@ done: // R4 = b len // R5 = a addr // R6 = b addr -// R7 = addr of return value if not regabi +// On exit: +// R3 = return value TEXT cmpbodyLE<>(SB),NOSPLIT|NOFRAME,$0-0 MOVD R3,R8 // set up length CMP R3,R4,CR2 // unequal? @@ -126,8 +95,8 @@ setup32a: SRADCC $5,R8,R9 // number of 32 byte chunks MOVD R9,CTR - // Special processing for 32 bytes or longer. - // Loading this way is faster and correct as long as the + // Special processing for 32 bytes or longer. + // Loading this way is faster and correct as long as the // doublewords being compared are equal. Once they // are found unequal, reload them in proper byte order // to determine greater or less than. @@ -201,23 +170,13 @@ cmpne: // only here is not equal CMPU R8,R9 // compare correct endianness BGT greater // here only if NE less: - MOVD $-1,R3 -#ifndef GOEXPERIMENT_regabiargs - MOVD R3,(R7) // return value if A < B -#endif + MOVD $-1, R3 // return value if A < B RET equal: -#ifdef GOEXPERIMENT_regabiargs - MOVD $0, R3 -#else - MOVD $0,(R7) // return value if A == B -#endif + MOVD $0, R3 // return value if A == B RET greater: - MOVD $1,R3 -#ifndef GOEXPERIMENT_regabiargs - MOVD R3,(R7) // return value if A > B -#endif + MOVD $1, R3 // return value if A > B RET // Do an efficient memcmp for ppc64 (BE) @@ -225,7 +184,8 @@ greater: // R4 = b len // R5 = a addr // R6 = b addr -// R7 = addr of return value +// On exit: +// R3 = return value TEXT cmpbodyBE<>(SB),NOSPLIT|NOFRAME,$0-0 MOVD R3,R8 // set up length CMP R3,R4,CR2 // unequal? @@ -308,21 +268,11 @@ simple: BC 12,10,equal // test CR2 for length comparison BC 12,9,greater // 2nd len > 1st len less: - MOVD $-1,R3 -#ifndef GOEXPERIMENT_regabiargs - MOVD R3,(R7) // return value if A < B -#endif + MOVD $-1, R3 // return value if A < B RET equal: -#ifdef GOEXPERIMENT_regabiargs - MOVD $0, R3 -#else - MOVD $0,(R7) // return value if A == B -#endif + MOVD $0, R3 // return value if A == B RET greater: - MOVD $1,R3 -#ifndef GOEXPERIMENT_regabiargs - MOVD R3,(R7) // return value if A > B -#endif + MOVD $1, R3 // return value if A > B RET diff --git a/src/internal/bytealg/count_ppc64x.s b/src/internal/bytealg/count_ppc64x.s index 43d547bb8a..2d2490b024 100644 --- a/src/internal/bytealg/count_ppc64x.s +++ b/src/internal/bytealg/count_ppc64x.s @@ -8,36 +8,22 @@ #include "textflag.h" TEXT ·Count(SB),NOSPLIT|NOFRAME,$0-40 -#ifdef GOEXPERIMENT_regabiargs -// R3 = byte array pointer -// R4 = length - MOVBZ R6,R5 // R5 = byte -#else - - MOVD b_base+0(FP), R3 // R3 = byte array pointer - MOVD b_len+8(FP), R4 // R4 = length - MOVBZ c+24(FP), R5 // R5 = byte - MOVD $ret+32(FP), R14 // R14 = &ret -#endif + // R3 = byte array pointer + // R4 = length + MOVBZ R6, R5 // R5 = byte BR countbytebody<>(SB) TEXT ·CountString(SB), NOSPLIT|NOFRAME, $0-32 -#ifdef GOEXPERIMENT_regabiargs -// R3 = byte array pointer -// R4 = length - MOVBZ R5,R5 // R5 = byte -#else - MOVD s_base+0(FP), R3 // R3 = string - MOVD s_len+8(FP), R4 // R4 = length - MOVBZ c+16(FP), R5 // R5 = byte - MOVD $ret+24(FP), R14 // R14 = &ret -#endif + // R3 = byte array pointer + // R4 = length + MOVBZ R5, R5 // R5 = byte BR countbytebody<>(SB) // R3: addr of string // R4: len of string // R5: byte to count -// R14: addr for return value when not regabi +// On exit: +// R3: return value // endianness shouldn't matter since we are just counting and order // is irrelevant TEXT countbytebody<>(SB), NOSPLIT|NOFRAME, $0-0 @@ -106,10 +92,5 @@ next2: BR small done: -#ifdef GOEXPERIMENT_regabiargs - MOVD R18, R3 // return count -#else - MOVD R18, (R14) // return count -#endif - + MOVD R18, R3 // return count RET diff --git a/src/internal/bytealg/equal_ppc64x.s b/src/internal/bytealg/equal_ppc64x.s index bd8caa7f18..8c9443d6fd 100644 --- a/src/internal/bytealg/equal_ppc64x.s +++ b/src/internal/bytealg/equal_ppc64x.s @@ -9,37 +9,29 @@ // memequal(a, b unsafe.Pointer, size uintptr) bool TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-25 -#ifndef GOEXPERIMENT_regabiargs - MOVD a+0(FP), R3 - MOVD b+8(FP), R4 - MOVD size+16(FP), R5 - MOVD $ret+24(FP), R10 -#endif + // R3 = a + // R4 = b + // R5 = size BR memeqbody<>(SB) // memequal_varlen(a, b unsafe.Pointer) bool TEXT runtime·memequal_varlen(SB),NOSPLIT|NOFRAME,$0-17 -#ifndef GOEXPERIMENT_regabiargs - MOVD a+0(FP), R3 - MOVD b+8(FP), R4 - MOVD $ret+16(FP), R10 -#endif + // R3 = a + // R4 = b CMP R3, R4 BEQ eq MOVD 8(R11), R5 // compiler stores size at offset 8 in the closure BR memeqbody<>(SB) eq: MOVD $1, R3 -#ifndef GOEXPERIMENT_regabiargs - MOVB R3, ret+16(FP) -#endif RET // Do an efficient memequal for ppc64 // R3 = s1 // R4 = s2 // R5 = len -// R10 = addr of return value (byte) when not regabi +// On exit: +// R3 = return value TEXT memeqbody<>(SB),NOSPLIT|NOFRAME,$0-0 MOVD R5,CTR CMP R5,$8 // only optimize >=8 @@ -98,16 +90,9 @@ simple: BNE noteq BR equal noteq: -#ifdef GOEXPERIMENT_regabiargs MOVD $0, R3 -#else - MOVB $0, (R10) -#endif RET equal: MOVD $1, R3 -#ifndef GOEXPERIMENT_regabiargs - MOVB R3, (R10) -#endif RET diff --git a/src/internal/bytealg/index_ppc64x.s b/src/internal/bytealg/index_ppc64x.s index 2d2a7146f1..18e57fb033 100644 --- a/src/internal/bytealg/index_ppc64x.s +++ b/src/internal/bytealg/index_ppc64x.s @@ -46,39 +46,25 @@ DATA byteswap<>+8(SB)/8, $0x0f0e0d0c0b0a0908 GLOBL byteswap<>+0(SB), RODATA, $16 TEXT ·Index(SB),NOSPLIT|NOFRAME,$0-56 -#ifdef GOEXPERIMENT_regabiargs -// R3 = byte array pointer -// R4 = length - MOVD R6,R5 // R5 = separator pointer - MOVD R7,R6 // R6 = separator length -#else - MOVD a_base+0(FP), R3 // R3 = byte array pointer - MOVD a_len+8(FP), R4 // R4 = length - MOVD b_base+24(FP), R5 // R5 = separator pointer - MOVD b_len+32(FP), R6 // R6 = separator length - MOVD $ret+48(FP), R14 // R14 = &ret -#endif - + // R3 = byte array pointer + // R4 = length + MOVD R6, R5 // R5 = separator pointer + MOVD R7, R6 // R6 = separator length #ifdef GOARCH_ppc64le MOVBZ internal∕cpu·PPC64+const_offsetPPC64HasPOWER9(SB), R7 CMP R7, $1 BNE power8 BR indexbodyp9<>(SB) - #endif power8: BR indexbody<>(SB) TEXT ·IndexString(SB),NOSPLIT|NOFRAME,$0-40 -#ifndef GOEXPERIMENT_regabiargs - MOVD a_base+0(FP), R3 // R3 = string - MOVD a_len+8(FP), R4 // R4 = length - MOVD b_base+16(FP), R5 // R5 = separator pointer - MOVD b_len+24(FP), R6 // R6 = separator length - MOVD $ret+32(FP), R14 // R14 = &ret -#endif - + // R3 = string + // R4 = length + // R5 = separator pointer + // R6 = separator length #ifdef GOARCH_ppc64le MOVBZ internal∕cpu·PPC64+const_offsetPPC64HasPOWER9(SB), R7 @@ -430,12 +416,7 @@ next17: BR index17to32loop // Continue notfound: -#ifdef GOEXPERIMENT_regabiargs - MOVD $-1, R3 // Return -1 if not found -#else - MOVD $-1, R8 // Return -1 if not found - MOVD R8, (R14) -#endif + MOVD $-1, R3 // Return -1 if not found RET index33plus: @@ -446,20 +427,12 @@ foundR25: SRD $3, R25 // Convert from bits to bytes ADD R25, R7 // Add to current string address SUB R3, R7 // Subtract from start of string -#ifdef GOEXPERIMENT_regabiargs - MOVD R7, R3 // Return byte where found -#else - MOVD R7, (R14) // Return byte where found -#endif + MOVD R7, R3 // Return byte where found RET found: SUB R3, R7 // Return byte where found -#ifdef GOEXPERIMENT_regabiargs - MOVD R7, R3 -#else - MOVD R7, (R14) -#endif + MOVD R7, R3 RET TEXT indexbodyp9<>(SB), NOSPLIT|NOFRAME, $0 @@ -768,12 +741,7 @@ next17: BR index17to32loop // Continue notfound: -#ifdef GOEXPERIMENT_regabiargs - MOVD $-1, R3 // Return -1 if not found -#else - MOVD $-1, R8 // Return -1 if not found - MOVD R8, (R14) -#endif + MOVD $-1, R3 // Return -1 if not found RET index33plus: @@ -784,19 +752,10 @@ foundR25: SRD $3, R25 // Convert from bits to bytes ADD R25, R7 // Add to current string address SUB R3, R7 // Subtract from start of string -#ifdef GOEXPERIMENT_regabiargs - MOVD R7, R3 // Return byte where found -#else - MOVD R7, (R14) // Return byte where found -#endif + MOVD R7, R3 // Return byte where found RET found: SUB R3, R7 // Return byte where found -#ifdef GOEXPERIMENT_regabiargs - MOVD R7, R3 -#else - MOVD R7, (R14) -#endif + MOVD R7, R3 RET - diff --git a/src/internal/bytealg/indexbyte_ppc64x.s b/src/internal/bytealg/indexbyte_ppc64x.s index 87ef8ecffc..4cc2b44087 100644 --- a/src/internal/bytealg/indexbyte_ppc64x.s +++ b/src/internal/bytealg/indexbyte_ppc64x.s @@ -8,28 +8,22 @@ #include "textflag.h" TEXT ·IndexByte(SB),NOSPLIT|NOFRAME,$0-40 -#ifndef GOEXPERIMENT_regabiargs - MOVD b_base+0(FP), R3 // R3 = byte array pointer - MOVD b_len+8(FP), R4 // R4 = length - MOVBZ c+24(FP), R5 // R5 = byte - MOVD $ret+32(FP), R14 // R14 = &ret -#else - MOVD R6, R5 -#endif + // R3 = byte array pointer + // R4 = length + MOVD R6, R5 // R5 = byte BR indexbytebody<>(SB) TEXT ·IndexByteString(SB),NOSPLIT|NOFRAME,$0-32 -#ifndef GOEXPERIMENT_regabiargs - MOVD s_base+0(FP), R3 // R3 = string - MOVD s_len+8(FP), R4 // R4 = length - MOVBZ c+16(FP), R5 // R5 = byte - MOVD $ret+24(FP), R14 // R14 = &ret -#endif + // R3 = string + // R4 = length + // R5 = byte BR indexbytebody<>(SB) + // R3 = addr of string // R4 = len of string // R5 = byte to find -// R14 = addr of return value when not regabi +// On exit: +// R3 = return value TEXT indexbytebody<>(SB),NOSPLIT|NOFRAME,$0-0 MOVD R3,R17 // Save base address for calculating the index later. RLDICR $0,R3,$60,R8 // Align address to doubleword boundary in R8. @@ -193,10 +187,7 @@ tail: BNE CR6,found_qw_align notfound: - MOVD $-1,R3 -#ifndef GOEXPERIMENT_regabiargs - MOVD R3,(R14) -#endif + MOVD $-1, R3 RET found: @@ -238,10 +229,7 @@ found: ADD R8,R11,R3 // Calculate byte address return: - SUB R17,R3 -#ifndef GOEXPERIMENT_regabiargs - MOVD R3,(R14) -#endif + SUB R17, R3 RET found_qw_align: diff --git a/src/runtime/asm_ppc64x.s b/src/runtime/asm_ppc64x.s index 45e0c8240a..1d292b4e60 100644 --- a/src/runtime/asm_ppc64x.s +++ b/src/runtime/asm_ppc64x.s @@ -167,11 +167,7 @@ TEXT gogo<>(SB), NOSPLIT|NOFRAME, $0 TEXT runtime·mcall(SB), NOSPLIT|NOFRAME, $0-8 // Save caller state in g->sched // R11 should be safe across save_g?? -#ifdef GOEXPERIMENT_regabiargs MOVD R3, R11 -#else - MOVD fn+0(FP), R11 -#endif MOVD R1, (g_sched+gobuf_sp)(g) MOVD LR, R31 MOVD R31, (g_sched+gobuf_pc)(g) @@ -788,7 +784,6 @@ TEXT runtime·cputicks(SB),NOSPLIT,$0-8 MOVD R3, ret+0(FP) RET -#ifdef GOEXPERIMENT_regabiargs // spillArgs stores return values from registers to a *internal/abi.RegArgs in R20. TEXT runtime·spillArgs(SB),NOSPLIT,$0-0 MOVD R3, 0(R20) @@ -844,14 +839,6 @@ TEXT runtime·unspillArgs(SB),NOSPLIT,$0-0 FMOVD 176(R20), F11 FMOVD 184(R20), F12 RET -#else - -TEXT runtime·spillArgs(SB),NOSPLIT,$0-0 - RET - -TEXT runtime·unspillArgs(SB),NOSPLIT,$0-0 - RET -#endif // AES hashing not implemented for ppc64 TEXT runtime·memhash(SB),NOSPLIT|NOFRAME,$0-32 @@ -1009,137 +996,58 @@ flush: // then tail call to the corresponding runtime handler. // The tail call makes these stubs disappear in backtraces. TEXT runtime·panicIndex(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD R3, x+0(FP) - MOVD R4, y+8(FP) -#endif JMP runtime·goPanicIndex(SB) TEXT runtime·panicIndexU(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD R3, x+0(FP) - MOVD R4, y+8(FP) -#endif JMP runtime·goPanicIndexU(SB) TEXT runtime·panicSliceAlen(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R4, R3 MOVD R5, R4 -#else - MOVD R4, x+0(FP) - MOVD R5, y+8(FP) -#endif JMP runtime·goPanicSliceAlen(SB) TEXT runtime·panicSliceAlenU(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R4, R3 MOVD R5, R4 -#else - MOVD R4, x+0(FP) - MOVD R5, y+8(FP) -#endif JMP runtime·goPanicSliceAlenU(SB) TEXT runtime·panicSliceAcap(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R4, R3 MOVD R5, R4 -#else - MOVD R4, x+0(FP) - MOVD R5, y+8(FP) -#endif JMP runtime·goPanicSliceAcap(SB) TEXT runtime·panicSliceAcapU(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R4, R3 MOVD R5, R4 -#else - MOVD R4, x+0(FP) - MOVD R5, y+8(FP) -#endif JMP runtime·goPanicSliceAcapU(SB) TEXT runtime·panicSliceB(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD R3, x+0(FP) - MOVD R4, y+8(FP) -#endif JMP runtime·goPanicSliceB(SB) TEXT runtime·panicSliceBU(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD R3, x+0(FP) - MOVD R4, y+8(FP) -#endif JMP runtime·goPanicSliceBU(SB) TEXT runtime·panicSlice3Alen(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R5, R3 MOVD R6, R4 -#else - MOVD R5, x+0(FP) - MOVD R6, y+8(FP) -#endif JMP runtime·goPanicSlice3Alen(SB) TEXT runtime·panicSlice3AlenU(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R5, R3 MOVD R6, R4 -#else - MOVD R5, x+0(FP) - MOVD R6, y+8(FP) -#endif JMP runtime·goPanicSlice3AlenU(SB) TEXT runtime·panicSlice3Acap(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R5, R3 MOVD R6, R4 -#else - MOVD R5, x+0(FP) - MOVD R6, y+8(FP) -#endif JMP runtime·goPanicSlice3Acap(SB) TEXT runtime·panicSlice3AcapU(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R5, R3 MOVD R6, R4 -#else - MOVD R5, x+0(FP) - MOVD R6, y+8(FP) -#endif JMP runtime·goPanicSlice3AcapU(SB) TEXT runtime·panicSlice3B(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R4, R3 MOVD R5, R4 -#else - MOVD R4, x+0(FP) - MOVD R5, y+8(FP) -#endif JMP runtime·goPanicSlice3B(SB) TEXT runtime·panicSlice3BU(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R4, R3 MOVD R5, R4 -#else - MOVD R4, x+0(FP) - MOVD R5, y+8(FP) -#endif JMP runtime·goPanicSlice3BU(SB) TEXT runtime·panicSlice3C(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD R3, x+0(FP) - MOVD R4, y+8(FP) -#endif JMP runtime·goPanicSlice3C(SB) TEXT runtime·panicSlice3CU(SB),NOSPLIT,$0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD R3, x+0(FP) - MOVD R4, y+8(FP) -#endif JMP runtime·goPanicSlice3CU(SB) TEXT runtime·panicSliceConvert(SB),NOSPLIT,$0-16 -#ifdef GOEXPERIMENT_regabiargs MOVD R5, R3 MOVD R6, R4 -#else - MOVD R5, x+0(FP) - MOVD R6, y+8(FP) -#endif JMP runtime·goPanicSliceConvert(SB) diff --git a/src/runtime/memclr_ppc64x.s b/src/runtime/memclr_ppc64x.s index 64132cee96..ad84ea9600 100644 --- a/src/runtime/memclr_ppc64x.s +++ b/src/runtime/memclr_ppc64x.s @@ -10,10 +10,8 @@ // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT|NOFRAME, $0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD ptr+0(FP), R3 - MOVD n+8(FP), R4 -#endif + // R3 = ptr + // R4 = n // Determine if there are doublewords to clear check: diff --git a/src/runtime/memmove_ppc64x.s b/src/runtime/memmove_ppc64x.s index 2152fb4f69..25101a28c7 100644 --- a/src/runtime/memmove_ppc64x.s +++ b/src/runtime/memmove_ppc64x.s @@ -28,11 +28,9 @@ #define QWORDS R10 TEXT runtime·memmove(SB), NOSPLIT|NOFRAME, $0-24 -#ifndef GOEXPERIMENT_regabiargs - MOVD to+0(FP), TGT - MOVD from+8(FP), SRC - MOVD n+16(FP), LEN -#endif + // R3 = TGT = to + // R4 = SRC = from + // R5 = LEN = n // Determine if there are doublewords to // copy so a more efficient move can be done diff --git a/src/runtime/race_ppc64le.s b/src/runtime/race_ppc64le.s index 68cc5c8805..0d8aaa01c1 100644 --- a/src/runtime/race_ppc64le.s +++ b/src/runtime/race_ppc64le.s @@ -43,11 +43,7 @@ // func runtime·RaceRead(addr uintptr) // Called from instrumented Go code TEXT runtime·raceread(SB), NOSPLIT, $0-8 -#ifndef GOEXPERIMENT_regabiargs - MOVD addr+0(FP), R4 -#else - MOVD R3, R4 -#endif + MOVD R3, R4 // addr MOVD LR, R5 // caller of this? // void __tsan_read(ThreadState *thr, void *addr, void *pc); MOVD $__tsan_read(SB), R8 @@ -68,11 +64,7 @@ TEXT runtime·racereadpc(SB), NOSPLIT, $0-24 // func runtime·RaceWrite(addr uintptr) // Called from instrumented Go code TEXT runtime·racewrite(SB), NOSPLIT, $0-8 -#ifndef GOEXPERIMENT_regabiargs - MOVD addr+0(FP), R4 -#else - MOVD R3, R4 -#endif + MOVD R3, R4 // addr MOVD LR, R5 // caller has set LR via BL inst // void __tsan_write(ThreadState *thr, void *addr, void *pc); MOVD $__tsan_write(SB), R8 @@ -93,13 +85,8 @@ TEXT runtime·racewritepc(SB), NOSPLIT, $0-24 // func runtime·RaceReadRange(addr, size uintptr) // Called from instrumented Go code. TEXT runtime·racereadrange(SB), NOSPLIT, $0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD addr+0(FP), R4 - MOVD size+8(FP), R5 -#else - MOVD R4, R5 - MOVD R3, R4 -#endif + MOVD R4, R5 // size + MOVD R3, R4 // addr MOVD LR, R6 // void __tsan_read_range(ThreadState *thr, void *addr, uintptr size, void *pc); MOVD $__tsan_read_range(SB), R8 @@ -121,13 +108,8 @@ TEXT runtime·RaceReadRange(SB), NOSPLIT, $0-16 // func runtime·RaceWriteRange(addr, size uintptr) // Called from instrumented Go code. TEXT runtime·racewriterange(SB), NOSPLIT, $0-16 -#ifndef GOEXPERIMENT_regabiargs - MOVD addr+0(FP), R4 - MOVD size+8(FP), R5 -#else - MOVD R4, R5 - MOVD R3, R4 -#endif + MOVD R4, R5 // size + MOVD R3, R4 // addr MOVD LR, R6 // void __tsan_write_range(ThreadState *thr, void *addr, uintptr size, void *pc); MOVD $__tsan_write_range(SB), R8 -- cgit v1.3-5-g9baa