From b5904f3de0937aac72acd40d6c26494ebb9d7909 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 12 Oct 2021 15:03:25 -0400 Subject: [PATCH 001/406] net: remove timeout in TestDialTimeoutMaxDuration This test seems only to be testing that Dial does not time out immediately as a result of integer overflow; the precise time taken to connect is immaterial. Replace naked loop with sub-tests. Fixes #43069. Change-Id: Ib5e38a1d8cd191b74c2bc7c26bef57b180e16f68 Reviewed-on: https://go-review.googlesource.com/c/go/+/355390 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Damien Neil --- src/net/timeout_test.go | 53 +++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/src/net/timeout_test.go b/src/net/timeout_test.go index e1cf1467c3..6c8e9cf76e 100644 --- a/src/net/timeout_test.go +++ b/src/net/timeout_test.go @@ -93,53 +93,38 @@ func TestDialTimeout(t *testing.T) { } } -var dialTimeoutMaxDurationTests = []struct { - timeout time.Duration - delta time.Duration // for deadline -}{ - // Large timeouts that will overflow an int64 unix nanos. - {1<<63 - 1, 0}, - {0, 1<<63 - 1}, -} - func TestDialTimeoutMaxDuration(t *testing.T) { - if runtime.GOOS == "openbsd" { - testenv.SkipFlaky(t, 15157) - } - ln, err := newLocalListener("tcp") if err != nil { t.Fatal(err) } - defer ln.Close() + defer func() { + if err := ln.Close(); err != nil { + t.Error(err) + } + }() - for i, tt := range dialTimeoutMaxDurationTests { - ch := make(chan error) - max := time.NewTimer(250 * time.Millisecond) - defer max.Stop() - go func() { + for _, tt := range []struct { + timeout time.Duration + delta time.Duration // for deadline + }{ + // Large timeouts that will overflow an int64 unix nanos. + {1<<63 - 1, 0}, + {0, 1<<63 - 1}, + } { + t.Run(fmt.Sprintf("timeout=%s/delta=%s", tt.timeout, tt.delta), func(t *testing.T) { d := Dialer{Timeout: tt.timeout} if tt.delta != 0 { d.Deadline = time.Now().Add(tt.delta) } c, err := d.Dial(ln.Addr().Network(), ln.Addr().String()) - if err == nil { - c.Close() - } - ch <- err - }() - - select { - case <-max.C: - t.Fatalf("#%d: Dial didn't return in an expected time", i) - case err := <-ch: - if perr := parseDialError(err); perr != nil { - t.Error(perr) - } if err != nil { - t.Errorf("#%d: %v", i, err) + t.Fatal(err) } - } + if err := c.Close(); err != nil { + t.Error(err) + } + }) } } From 4a3daeee636751a262eb9f77d8e90c59955ee6bb Mon Sep 17 00:00:00 2001 From: James Harris Date: Fri, 17 Sep 2021 02:29:00 +0000 Subject: [PATCH 002/406] net/http/httputil: allow MIME parameters when detecting SSE in ReverseProxy This change allows httputil.ReverseProxy to detect SSE (server-sent events) content when the response's Content-Type header includes MIME parameters, such as "text/event-stream;charset=utf-8". Prior to this change the value of the Content-Type header was compared directly to the literal "text/event-stream". This caused a false-negative which failed to set the FlushInterval correctly when MIME parameters were present. Change-Id: If8bb43efb78787b6519d7fe7599ca018a0da0023 GitHub-Last-Rev: 224518c5eb9686ee050c79f5f853ebacfdf6fc42 GitHub-Pull-Request: golang/go#48427 Reviewed-on: https://go-review.googlesource.com/c/go/+/350509 Trust: Alexander Rakoczy Trust: Damien Neil Run-TryBot: Alexander Rakoczy TryBot-Result: Go Bot Reviewed-by: Damien Neil --- src/net/http/httputil/reverseproxy.go | 3 ++- src/net/http/httputil/reverseproxy_test.go | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go index 8b63368386..71849bb8f7 100644 --- a/src/net/http/httputil/reverseproxy.go +++ b/src/net/http/httputil/reverseproxy.go @@ -11,6 +11,7 @@ import ( "fmt" "io" "log" + "mime" "net" "net/http" "net/http/internal/ascii" @@ -412,7 +413,7 @@ func (p *ReverseProxy) flushInterval(res *http.Response) time.Duration { // For Server-Sent Events responses, flush immediately. // The MIME type is defined in https://www.w3.org/TR/eventsource/#text-event-stream - if resCT == "text/event-stream" { + if baseCT, _, _ := mime.ParseMediaType(resCT); baseCT == "text/event-stream" { return -1 // negative means immediately } diff --git a/src/net/http/httputil/reverseproxy_test.go b/src/net/http/httputil/reverseproxy_test.go index 4b6ad77a29..90e8903e9c 100644 --- a/src/net/http/httputil/reverseproxy_test.go +++ b/src/net/http/httputil/reverseproxy_test.go @@ -1194,6 +1194,26 @@ func TestSelectFlushInterval(t *testing.T) { p: &ReverseProxy{FlushInterval: 0}, want: -1, }, + { + name: "server-sent events with media-type parameters overrides non-zero", + res: &http.Response{ + Header: http.Header{ + "Content-Type": {"text/event-stream;charset=utf-8"}, + }, + }, + p: &ReverseProxy{FlushInterval: 123}, + want: -1, + }, + { + name: "server-sent events with media-type parameters overrides zero", + res: &http.Response{ + Header: http.Header{ + "Content-Type": {"text/event-stream;charset=utf-8"}, + }, + }, + p: &ReverseProxy{FlushInterval: 0}, + want: -1, + }, { name: "Content-Length: -1, overrides non-zero", res: &http.Response{ From 4efa216c9d753c0853aa96a8c54ed5014fbc12e6 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Tue, 12 Oct 2021 15:31:25 -0700 Subject: [PATCH 003/406] unsafe: allow unsafe.Slice up to end of address space Allow the user to construct slices that are larger than the Go heap as long as they don't overflow the address space. Updates #48798. Change-Id: I659c8334d04676e1f253b9c3cd499eab9b9f989a Reviewed-on: https://go-review.googlesource.com/c/go/+/355489 Trust: Matthew Dempsky Run-TryBot: Matthew Dempsky Reviewed-by: Ian Lance Taylor --- src/runtime/slice.go | 2 +- test/unsafebuiltins.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/runtime/slice.go b/src/runtime/slice.go index cfa862e047..66bb7d9d93 100644 --- a/src/runtime/slice.go +++ b/src/runtime/slice.go @@ -124,7 +124,7 @@ func unsafeslice(et *_type, ptr unsafe.Pointer, len int) { } mem, overflow := math.MulUintptr(et.size, uintptr(len)) - if overflow || mem > maxAlloc || len < 0 { + if overflow || mem > -uintptr(ptr) || len < 0 { panicunsafeslicelen() } } diff --git a/test/unsafebuiltins.go b/test/unsafebuiltins.go index 4c940aa855..d04bcbdc7d 100644 --- a/test/unsafebuiltins.go +++ b/test/unsafebuiltins.go @@ -47,6 +47,11 @@ func main() { // size overflows address space mustPanic(func() { _ = unsafe.Slice(new(uint64), maxUintptr/8) }) mustPanic(func() { _ = unsafe.Slice(new(uint64), maxUintptr/8+1) }) + + // sliced memory overflows address space + last := (*byte)(unsafe.Pointer(^uintptr(0))) + _ = unsafe.Slice(last, 1) + mustPanic(func() { _ = unsafe.Slice(last, 2) }) } } From 40f82f8a092ac1f23eb3af86f34b7436a6fc19e0 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Tue, 12 Oct 2021 15:38:52 -0700 Subject: [PATCH 004/406] unsafe: optimize Slice bounds checking This reduces the number of branches to bounds check non-empty slices from 5 to 3. It does also increase the number of branches to handle empty slices from 1 to 3; but for non-panicking calls, they should all be predictable. Updates #48798. Change-Id: I3ffa66857096486f4dee417e1a66eb8fdf7a3777 Reviewed-on: https://go-review.googlesource.com/c/go/+/355490 Trust: Matthew Dempsky Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/runtime/slice.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/runtime/slice.go b/src/runtime/slice.go index 66bb7d9d93..aab8a598c5 100644 --- a/src/runtime/slice.go +++ b/src/runtime/slice.go @@ -115,16 +115,15 @@ func makeslice64(et *_type, len64, cap64 int64) unsafe.Pointer { } func unsafeslice(et *_type, ptr unsafe.Pointer, len int) { - if len == 0 { - return - } - - if ptr == nil { - panic(errorString("unsafe.Slice: ptr is nil and len is not zero")) + if len < 0 { + panicunsafeslicelen() } mem, overflow := math.MulUintptr(et.size, uintptr(len)) - if overflow || mem > -uintptr(ptr) || len < 0 { + if overflow || mem > -uintptr(ptr) { + if ptr == nil { + panic(errorString("unsafe.Slice: ptr is nil and len is not zero")) + } panicunsafeslicelen() } } From b90d258b18e2fe728a3d7c856ad08c7fa6845fc2 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Wed, 13 Oct 2021 10:27:01 -0700 Subject: [PATCH 005/406] cmd/compile: fix inst_test.go for riscv5 On riscv5, apparently extra wrappers (trampolines) are created for some functions with the suffix "-tramp". Modify inst_test.go to not match these "-tramp" wrappers. Change-Id: I754c724f03555c30f8e1b5cfc08152555bbbcf17 Reviewed-on: https://go-review.googlesource.com/c/go/+/355650 Run-TryBot: Dan Scales Reviewed-by: Keith Randall Trust: Dan Scales --- src/cmd/compile/internal/test/inst_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/test/inst_test.go b/src/cmd/compile/internal/test/inst_test.go index 59a67cb545..951f6a05aa 100644 --- a/src/cmd/compile/internal/test/inst_test.go +++ b/src/cmd/compile/internal/test/inst_test.go @@ -50,7 +50,9 @@ func TestInst(t *testing.T) { if output, err = cmd.CombinedOutput(); err != nil { t.Fatalf("Failed: %v:\nOut: %s\n", err, output) } - re := regexp.MustCompile(`\bSort\[.*shape.*\]`) + // Look for shape-based instantiation of Sort, but ignore any extra wrapper + // ending in "-tramp" (which are created on riscv). + re := regexp.MustCompile(`\bSort\[.*shape.*\][^-]`) r := re.FindAllIndex(output, -1) if len(r) != 1 { t.Fatalf("Wanted 1 instantiations of Sort function, got %d\n", len(r)) From 276fb279d1703451e5b962350727f84e4e8e9814 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 13 Oct 2021 11:50:46 -0700 Subject: [PATCH 006/406] cmd/compile/internal/syntax: remove AllowTypeSets mode The respective issue has been accepted, so we can always accept constraint literals with omitted interfaces. For #48424. Change-Id: Ia3d325401252a5a22d5ffa98d2ae6af73178dec0 Reviewed-on: https://go-review.googlesource.com/c/go/+/355709 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/noder/noder.go | 2 +- src/cmd/compile/internal/syntax/error_test.go | 2 +- src/cmd/compile/internal/syntax/parser.go | 2 +- src/cmd/compile/internal/syntax/parser_test.go | 6 +++--- src/cmd/compile/internal/syntax/printer_test.go | 4 ++-- src/cmd/compile/internal/syntax/syntax.go | 1 - src/cmd/compile/internal/types2/check_test.go | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/cmd/compile/internal/noder/noder.go b/src/cmd/compile/internal/noder/noder.go index 2e7b636681..7c14fcf041 100644 --- a/src/cmd/compile/internal/noder/noder.go +++ b/src/cmd/compile/internal/noder/noder.go @@ -36,7 +36,7 @@ func LoadPackage(filenames []string) { mode := syntax.CheckBranches if supportsGenerics { - mode |= syntax.AllowGenerics | syntax.AllowTypeSets + mode |= syntax.AllowGenerics } // Limit the number of simultaneously open files. diff --git a/src/cmd/compile/internal/syntax/error_test.go b/src/cmd/compile/internal/syntax/error_test.go index 0ab3c20ce5..d87e8eaee3 100644 --- a/src/cmd/compile/internal/syntax/error_test.go +++ b/src/cmd/compile/internal/syntax/error_test.go @@ -130,7 +130,7 @@ func testSyntaxErrors(t *testing.T, filename string) { var mode Mode if strings.HasSuffix(filename, ".go2") { - mode = AllowGenerics | AllowTypeSets + mode = AllowGenerics } ParseFile(filename, func(err error) { e, ok := err.(Error) diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go index a669c54712..e78e77561d 100644 --- a/src/cmd/compile/internal/syntax/parser.go +++ b/src/cmd/compile/internal/syntax/parser.go @@ -1820,7 +1820,7 @@ func (p *parser) paramDeclOrNil(name *Name, follow token) *Field { } // type set notation is ok in type parameter lists - typeSetsOk := p.mode&AllowTypeSets != 0 && follow == _Rbrack + typeSetsOk := follow == _Rbrack pos := p.pos() if name != nil { diff --git a/src/cmd/compile/internal/syntax/parser_test.go b/src/cmd/compile/internal/syntax/parser_test.go index 29682012e5..68f3c376c9 100644 --- a/src/cmd/compile/internal/syntax/parser_test.go +++ b/src/cmd/compile/internal/syntax/parser_test.go @@ -26,11 +26,11 @@ var ( ) func TestParse(t *testing.T) { - ParseFile(*src_, func(err error) { t.Error(err) }, nil, AllowGenerics|AllowTypeSets) + ParseFile(*src_, func(err error) { t.Error(err) }, nil, AllowGenerics) } func TestVerify(t *testing.T) { - ast, err := ParseFile(*src_, func(err error) { t.Error(err) }, nil, AllowGenerics|AllowTypeSets) + ast, err := ParseFile(*src_, func(err error) { t.Error(err) }, nil, AllowGenerics) if err != nil { return // error already reported } @@ -46,7 +46,7 @@ func TestParseGo2(t *testing.T) { for _, fi := range list { name := fi.Name() if !fi.IsDir() && !strings.HasPrefix(name, ".") { - ParseFile(filepath.Join(dir, name), func(err error) { t.Error(err) }, nil, AllowGenerics|AllowTypeSets) + ParseFile(filepath.Join(dir, name), func(err error) { t.Error(err) }, nil, AllowGenerics) } } } diff --git a/src/cmd/compile/internal/syntax/printer_test.go b/src/cmd/compile/internal/syntax/printer_test.go index 9b5331b148..604f1fc1ca 100644 --- a/src/cmd/compile/internal/syntax/printer_test.go +++ b/src/cmd/compile/internal/syntax/printer_test.go @@ -72,7 +72,7 @@ var stringTests = []string{ "package p; func (*R[A, B, C]) _()", "package p; func (_ *R[A, B, C]) _()", - // type constraint literals with elided interfaces (only if AllowTypeSets is set) + // type constraint literals with elided interfaces "package p; func _[P ~int, Q int | string]() {}", "package p; func _[P struct{f int}, Q *P]() {}", @@ -94,7 +94,7 @@ var stringTests = []string{ func TestPrintString(t *testing.T) { for _, want := range stringTests { - ast, err := Parse(nil, strings.NewReader(want), nil, nil, AllowGenerics|AllowTypeSets) + ast, err := Parse(nil, strings.NewReader(want), nil, nil, AllowGenerics) if err != nil { t.Error(err) continue diff --git a/src/cmd/compile/internal/syntax/syntax.go b/src/cmd/compile/internal/syntax/syntax.go index 49ba87786e..f3d4c09ed5 100644 --- a/src/cmd/compile/internal/syntax/syntax.go +++ b/src/cmd/compile/internal/syntax/syntax.go @@ -17,7 +17,6 @@ type Mode uint const ( CheckBranches Mode = 1 << iota // check correct use of labels, break, continue, and goto statements AllowGenerics - AllowTypeSets // requires AllowGenerics; remove once #48424 is decided ) // Error describes a syntax error. Error implements the error interface. diff --git a/src/cmd/compile/internal/types2/check_test.go b/src/cmd/compile/internal/types2/check_test.go index 5b2f09425b..bc68e76407 100644 --- a/src/cmd/compile/internal/types2/check_test.go +++ b/src/cmd/compile/internal/types2/check_test.go @@ -100,7 +100,7 @@ func testFiles(t *testing.T, filenames []string, colDelta uint, manual bool) { var mode syntax.Mode if strings.HasSuffix(filenames[0], ".go2") { - mode |= syntax.AllowGenerics | syntax.AllowTypeSets + mode |= syntax.AllowGenerics } // parse files and collect parser errors files, errlist := parseFiles(t, filenames, mode) From 9e4dc6f37f75840d1193accae697a0e9283f5384 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 13 Oct 2021 12:46:33 -0700 Subject: [PATCH 007/406] cmd/link/internal/ld: don't use linkname before 1.12 Before the 1.12 release the use of linkname did not prevent a compiler error for an empty function body (see #23311). Add some build tags so that cmd/link will build with earlier releases. It's true that we currently require Go 1.16 as the bootstrap compiler (#44505). But for this simple case keep things working with older compilers for now. Change-Id: I67fe021406096c64c01d6e2c9adbcc4388988a6e Reviewed-on: https://go-review.googlesource.com/c/go/+/355690 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Russ Cox --- src/cmd/link/internal/ld/outbuf_darwin.go | 3 +++ src/cmd/link/internal/ld/outbuf_nofallocate.go | 4 ++-- src/cmd/link/internal/ld/outbuf_notdarwin.go | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cmd/link/internal/ld/outbuf_darwin.go b/src/cmd/link/internal/ld/outbuf_darwin.go index 6920a0a843..b1ee3c5628 100644 --- a/src/cmd/link/internal/ld/outbuf_darwin.go +++ b/src/cmd/link/internal/ld/outbuf_darwin.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin && go1.12 +// +build darwin,go1.12 + package ld import ( diff --git a/src/cmd/link/internal/ld/outbuf_nofallocate.go b/src/cmd/link/internal/ld/outbuf_nofallocate.go index 6564bd54a3..3bffe4543d 100644 --- a/src/cmd/link/internal/ld/outbuf_nofallocate.go +++ b/src/cmd/link/internal/ld/outbuf_nofallocate.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !darwin && !linux -// +build !darwin,!linux +//go:build (!darwin && !linux) || (darwin && !go1.12) +// +build !darwin,!linux darwin,!go1.12 package ld diff --git a/src/cmd/link/internal/ld/outbuf_notdarwin.go b/src/cmd/link/internal/ld/outbuf_notdarwin.go index f9caa413e3..85e64421a3 100644 --- a/src/cmd/link/internal/ld/outbuf_notdarwin.go +++ b/src/cmd/link/internal/ld/outbuf_notdarwin.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !darwin -// +build !darwin +//go:build !darwin || (darwin && !go1.12) +// +build !darwin darwin,!go1.12 package ld From 1349c6eb1e3faf8b83db9a1ea30764d56b40c7dc Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 13 Oct 2021 15:42:31 +0200 Subject: [PATCH 008/406] syscall: separate ProcSysAttr and forkAndExecInChild for FreeBSD To allow adding fields to ProcSysAttr which are supported on FreeBSD but not on other BSDs. For now exec_freebsd.go is an exact copy of exec_bsd.go with adjusted build tags and copyright year. For #46258 For #46259 Change-Id: I7667a0cdf1ca86ef64a147b77c06db70c5f8eb90 Reviewed-on: https://go-review.googlesource.com/c/go/+/355569 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/syscall/exec_bsd.go | 4 +- src/syscall/exec_freebsd.go | 263 ++++++++++++++++++++++++++++++++++++ 2 files changed, 265 insertions(+), 2 deletions(-) create mode 100644 src/syscall/exec_freebsd.go diff --git a/src/syscall/exec_bsd.go b/src/syscall/exec_bsd.go index 709066e809..4c36f9ec13 100644 --- a/src/syscall/exec_bsd.go +++ b/src/syscall/exec_bsd.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build dragonfly || freebsd || netbsd || (openbsd && mips64) -// +build dragonfly freebsd netbsd openbsd,mips64 +//go:build dragonfly || netbsd || (openbsd && mips64) +// +build dragonfly netbsd openbsd,mips64 package syscall diff --git a/src/syscall/exec_freebsd.go b/src/syscall/exec_freebsd.go new file mode 100644 index 0000000000..393b3d485b --- /dev/null +++ b/src/syscall/exec_freebsd.go @@ -0,0 +1,263 @@ +// Copyright 2021 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 syscall + +import ( + "unsafe" +) + +type SysProcAttr struct { + Chroot string // Chroot. + Credential *Credential // Credential. + Ptrace bool // Enable tracing. + Setsid bool // Create session. + // Setpgid sets the process group ID of the child to Pgid, + // or, if Pgid == 0, to the new child's process ID. + Setpgid bool + // Setctty sets the controlling terminal of the child to + // file descriptor Ctty. Ctty must be a descriptor number + // in the child process: an index into ProcAttr.Files. + // This is only meaningful if Setsid is true. + Setctty bool + Noctty bool // Detach fd 0 from controlling terminal + Ctty int // Controlling TTY fd + // Foreground places the child process group in the foreground. + // This implies Setpgid. The Ctty field must be set to + // the descriptor of the controlling TTY. + // Unlike Setctty, in this case Ctty must be a descriptor + // number in the parent process. + Foreground bool + Pgid int // Child's process group ID if Setpgid. +} + +// Implemented in runtime package. +func runtime_BeforeFork() +func runtime_AfterFork() +func runtime_AfterForkInChild() + +// Fork, dup fd onto 0..len(fd), and exec(argv0, argvv, envv) in child. +// If a dup or exec fails, write the errno error to pipe. +// (Pipe is close-on-exec so if exec succeeds, it will be closed.) +// In the child, this function must not acquire any locks, because +// they might have been locked at the time of the fork. This means +// no rescheduling, no malloc calls, and no new stack segments. +// For the same reason compiler does not race instrument it. +// The calls to RawSyscall are okay because they are assembly +// functions that do not grow the stack. +//go:norace +func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr *ProcAttr, sys *SysProcAttr, pipe int) (pid int, err Errno) { + // Declare all variables at top in case any + // declarations require heap allocation (e.g., err1). + var ( + r1 uintptr + err1 Errno + nextfd int + i int + ) + + // guard against side effects of shuffling fds below. + // Make sure that nextfd is beyond any currently open files so + // that we can't run the risk of overwriting any of them. + fd := make([]int, len(attr.Files)) + nextfd = len(attr.Files) + for i, ufd := range attr.Files { + if nextfd < int(ufd) { + nextfd = int(ufd) + } + fd[i] = int(ufd) + } + nextfd++ + + // About to call fork. + // No more allocation or calls of non-assembly functions. + runtime_BeforeFork() + r1, _, err1 = RawSyscall(SYS_FORK, 0, 0, 0) + if err1 != 0 { + runtime_AfterFork() + return 0, err1 + } + + if r1 != 0 { + // parent; return PID + runtime_AfterFork() + return int(r1), 0 + } + + // Fork succeeded, now in child. + + // Enable tracing if requested. + if sys.Ptrace { + _, _, err1 = RawSyscall(SYS_PTRACE, uintptr(PTRACE_TRACEME), 0, 0) + if err1 != 0 { + goto childerror + } + } + + // Session ID + if sys.Setsid { + _, _, err1 = RawSyscall(SYS_SETSID, 0, 0, 0) + if err1 != 0 { + goto childerror + } + } + + // Set process group + if sys.Setpgid || sys.Foreground { + // Place child in process group. + _, _, err1 = RawSyscall(SYS_SETPGID, 0, uintptr(sys.Pgid), 0) + if err1 != 0 { + goto childerror + } + } + + if sys.Foreground { + // This should really be pid_t, however _C_int (aka int32) is + // generally equivalent. + pgrp := _C_int(sys.Pgid) + if pgrp == 0 { + r1, _, err1 = RawSyscall(SYS_GETPID, 0, 0, 0) + if err1 != 0 { + goto childerror + } + + pgrp = _C_int(r1) + } + + // Place process group in foreground. + _, _, err1 = RawSyscall(SYS_IOCTL, uintptr(sys.Ctty), uintptr(TIOCSPGRP), uintptr(unsafe.Pointer(&pgrp))) + if err1 != 0 { + goto childerror + } + } + + // Restore the signal mask. We do this after TIOCSPGRP to avoid + // having the kernel send a SIGTTOU signal to the process group. + runtime_AfterForkInChild() + + // Chroot + if chroot != nil { + _, _, err1 = RawSyscall(SYS_CHROOT, uintptr(unsafe.Pointer(chroot)), 0, 0) + if err1 != 0 { + goto childerror + } + } + + // User and groups + if cred := sys.Credential; cred != nil { + ngroups := uintptr(len(cred.Groups)) + groups := uintptr(0) + if ngroups > 0 { + groups = uintptr(unsafe.Pointer(&cred.Groups[0])) + } + if !cred.NoSetGroups { + _, _, err1 = RawSyscall(SYS_SETGROUPS, ngroups, groups, 0) + if err1 != 0 { + goto childerror + } + } + _, _, err1 = RawSyscall(SYS_SETGID, uintptr(cred.Gid), 0, 0) + if err1 != 0 { + goto childerror + } + _, _, err1 = RawSyscall(SYS_SETUID, uintptr(cred.Uid), 0, 0) + if err1 != 0 { + goto childerror + } + } + + // Chdir + if dir != nil { + _, _, err1 = RawSyscall(SYS_CHDIR, uintptr(unsafe.Pointer(dir)), 0, 0) + if err1 != 0 { + goto childerror + } + } + + // Pass 1: look for fd[i] < i and move those up above len(fd) + // so that pass 2 won't stomp on an fd it needs later. + if pipe < nextfd { + _, _, err1 = RawSyscall(SYS_DUP2, uintptr(pipe), uintptr(nextfd), 0) + if err1 != 0 { + goto childerror + } + RawSyscall(SYS_FCNTL, uintptr(nextfd), F_SETFD, FD_CLOEXEC) + pipe = nextfd + nextfd++ + } + for i = 0; i < len(fd); i++ { + if fd[i] >= 0 && fd[i] < int(i) { + if nextfd == pipe { // don't stomp on pipe + nextfd++ + } + _, _, err1 = RawSyscall(SYS_DUP2, uintptr(fd[i]), uintptr(nextfd), 0) + if err1 != 0 { + goto childerror + } + RawSyscall(SYS_FCNTL, uintptr(nextfd), F_SETFD, FD_CLOEXEC) + fd[i] = nextfd + nextfd++ + } + } + + // Pass 2: dup fd[i] down onto i. + for i = 0; i < len(fd); i++ { + if fd[i] == -1 { + RawSyscall(SYS_CLOSE, uintptr(i), 0, 0) + continue + } + if fd[i] == int(i) { + // dup2(i, i) won't clear close-on-exec flag on Linux, + // probably not elsewhere either. + _, _, err1 = RawSyscall(SYS_FCNTL, uintptr(fd[i]), F_SETFD, 0) + if err1 != 0 { + goto childerror + } + continue + } + // The new fd is created NOT close-on-exec, + // which is exactly what we want. + _, _, err1 = RawSyscall(SYS_DUP2, uintptr(fd[i]), uintptr(i), 0) + if err1 != 0 { + goto childerror + } + } + + // By convention, we don't close-on-exec the fds we are + // started with, so if len(fd) < 3, close 0, 1, 2 as needed. + // Programs that know they inherit fds >= 3 will need + // to set them close-on-exec. + for i = len(fd); i < 3; i++ { + RawSyscall(SYS_CLOSE, uintptr(i), 0, 0) + } + + // Detach fd 0 from tty + if sys.Noctty { + _, _, err1 = RawSyscall(SYS_IOCTL, 0, uintptr(TIOCNOTTY), 0) + if err1 != 0 { + goto childerror + } + } + + // Set the controlling TTY to Ctty + if sys.Setctty { + _, _, err1 = RawSyscall(SYS_IOCTL, uintptr(sys.Ctty), uintptr(TIOCSCTTY), 0) + if err1 != 0 { + goto childerror + } + } + + // Time to exec. + _, _, err1 = RawSyscall(SYS_EXECVE, + uintptr(unsafe.Pointer(argv0)), + uintptr(unsafe.Pointer(&argv[0])), + uintptr(unsafe.Pointer(&envv[0]))) + +childerror: + // send error code on pipe + RawSyscall(SYS_WRITE, uintptr(pipe), uintptr(unsafe.Pointer(&err1)), unsafe.Sizeof(err1)) + for { + RawSyscall(SYS_EXIT, 253, 0, 0) + } +} From 2feb2cc450e1925b9359957c90bae27e01662171 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 13 Oct 2021 16:30:12 +0200 Subject: [PATCH 009/406] syscall: add support for SysProcAttr.Pdeathsig on FreeBSD Fixes #46258 Change-Id: I63f70e67274a9df39c757243b99b12e50a9e4784 Reviewed-on: https://go-review.googlesource.com/c/go/+/355570 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/syscall/exec_freebsd.go | 38 +++++++- src/syscall/exec_linux.go | 2 +- src/syscall/exec_pdeathsig_test.go | 135 ++++++++++++++++++++++++++++ src/syscall/syscall_freebsd_test.go | 11 +++ src/syscall/syscall_linux_test.go | 117 ------------------------ 5 files changed, 184 insertions(+), 119 deletions(-) create mode 100644 src/syscall/exec_pdeathsig_test.go diff --git a/src/syscall/exec_freebsd.go b/src/syscall/exec_freebsd.go index 393b3d485b..a7410db4b6 100644 --- a/src/syscall/exec_freebsd.go +++ b/src/syscall/exec_freebsd.go @@ -5,6 +5,7 @@ package syscall import ( + "runtime" "unsafe" ) @@ -29,9 +30,16 @@ type SysProcAttr struct { // Unlike Setctty, in this case Ctty must be a descriptor // number in the parent process. Foreground bool - Pgid int // Child's process group ID if Setpgid. + Pgid int // Child's process group ID if Setpgid. + Pdeathsig Signal // Signal that the process will get when its parent dies (Linux and FreeBSD only) } +const ( + _P_PID = 0 + + _PROC_PDEATHSIG_CTL = 11 +) + // Implemented in runtime package. func runtime_BeforeFork() func runtime_AfterFork() @@ -57,6 +65,9 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr i int ) + // Record parent PID so child can test if it has died. + ppid, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + // guard against side effects of shuffling fds below. // Make sure that nextfd is beyond any currently open files so // that we can't run the risk of overwriting any of them. @@ -175,6 +186,31 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr } } + // Parent death signal + if sys.Pdeathsig != 0 { + switch runtime.GOARCH { + case "386", "arm": + _, _, err1 = RawSyscall6(SYS_PROCCTL, _P_PID, 0, 0, _PROC_PDEATHSIG_CTL, uintptr(unsafe.Pointer(&sys.Pdeathsig)), 0) + default: + _, _, err1 = RawSyscall6(SYS_PROCCTL, _P_PID, 0, _PROC_PDEATHSIG_CTL, uintptr(unsafe.Pointer(&sys.Pdeathsig)), 0, 0) + } + if err1 != 0 { + goto childerror + } + + // Signal self if parent is already dead. This might cause a + // duplicate signal in rare cases, but it won't matter when + // using SIGKILL. + r1, _, _ = RawSyscall(SYS_GETPPID, 0, 0, 0) + if r1 != ppid { + pid, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + _, _, err1 := RawSyscall(SYS_KILL, pid, uintptr(sys.Pdeathsig), 0) + if err1 != 0 { + goto childerror + } + } + } + // Pass 1: look for fd[i] < i and move those up above len(fd) // so that pass 2 won't stomp on an fd it needs later. if pipe < nextfd { diff --git a/src/syscall/exec_linux.go b/src/syscall/exec_linux.go index dfc5228545..e1506e1e2b 100644 --- a/src/syscall/exec_linux.go +++ b/src/syscall/exec_linux.go @@ -46,7 +46,7 @@ type SysProcAttr struct { // number in the parent process. Foreground bool Pgid int // Child's process group ID if Setpgid. - Pdeathsig Signal // Signal that the process will get when its parent dies (Linux only) + Pdeathsig Signal // Signal that the process will get when its parent dies (Linux and FreeBSD only) Cloneflags uintptr // Flags for clone calls (Linux only) Unshareflags uintptr // Flags for unshare calls (Linux only) UidMappings []SysProcIDMap // User ID mappings for user namespaces. diff --git a/src/syscall/exec_pdeathsig_test.go b/src/syscall/exec_pdeathsig_test.go new file mode 100644 index 0000000000..6533d3a138 --- /dev/null +++ b/src/syscall/exec_pdeathsig_test.go @@ -0,0 +1,135 @@ +// Copyright 2015 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. + +//go:build freebsd || linux +// +build freebsd linux + +package syscall_test + +import ( + "bufio" + "fmt" + "io" + "os" + "os/exec" + "os/signal" + "path/filepath" + "syscall" + "testing" + "time" +) + +func TestDeathSignal(t *testing.T) { + if os.Getuid() != 0 { + t.Skip("skipping root only test") + } + + // Copy the test binary to a location that a non-root user can read/execute + // after we drop privileges + tempDir, err := os.MkdirTemp("", "TestDeathSignal") + if err != nil { + t.Fatalf("cannot create temporary directory: %v", err) + } + defer os.RemoveAll(tempDir) + os.Chmod(tempDir, 0755) + + tmpBinary := filepath.Join(tempDir, filepath.Base(os.Args[0])) + + src, err := os.Open(os.Args[0]) + if err != nil { + t.Fatalf("cannot open binary %q, %v", os.Args[0], err) + } + defer src.Close() + + dst, err := os.OpenFile(tmpBinary, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) + if err != nil { + t.Fatalf("cannot create temporary binary %q, %v", tmpBinary, err) + } + if _, err := io.Copy(dst, src); err != nil { + t.Fatalf("failed to copy test binary to %q, %v", tmpBinary, err) + } + err = dst.Close() + if err != nil { + t.Fatalf("failed to close test binary %q, %v", tmpBinary, err) + } + + cmd := exec.Command(tmpBinary) + cmd.Env = append(os.Environ(), "GO_DEATHSIG_PARENT=1") + chldStdin, err := cmd.StdinPipe() + if err != nil { + t.Fatalf("failed to create new stdin pipe: %v", err) + } + chldStdout, err := cmd.StdoutPipe() + if err != nil { + t.Fatalf("failed to create new stdout pipe: %v", err) + } + cmd.Stderr = os.Stderr + + err = cmd.Start() + defer cmd.Wait() + if err != nil { + t.Fatalf("failed to start first child process: %v", err) + } + + chldPipe := bufio.NewReader(chldStdout) + + if got, err := chldPipe.ReadString('\n'); got == "start\n" { + syscall.Kill(cmd.Process.Pid, syscall.SIGTERM) + + go func() { + time.Sleep(5 * time.Second) + chldStdin.Close() + }() + + want := "ok\n" + if got, err = chldPipe.ReadString('\n'); got != want { + t.Fatalf("expected %q, received %q, %v", want, got, err) + } + } else { + t.Fatalf("did not receive start from child, received %q, %v", got, err) + } +} + +func deathSignalParent() { + cmd := exec.Command(os.Args[0]) + cmd.Env = append(os.Environ(), + "GO_DEATHSIG_PARENT=", + "GO_DEATHSIG_CHILD=1", + ) + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + attrs := syscall.SysProcAttr{ + Pdeathsig: syscall.SIGUSR1, + // UID/GID 99 is the user/group "nobody" on RHEL/Fedora and is + // unused on Ubuntu + Credential: &syscall.Credential{Uid: 99, Gid: 99}, + } + cmd.SysProcAttr = &attrs + + err := cmd.Start() + if err != nil { + fmt.Fprintf(os.Stderr, "death signal parent error: %v\n", err) + os.Exit(1) + } + cmd.Wait() + os.Exit(0) +} + +func deathSignalChild() { + c := make(chan os.Signal, 1) + signal.Notify(c, syscall.SIGUSR1) + go func() { + <-c + fmt.Println("ok") + os.Exit(0) + }() + fmt.Println("start") + + buf := make([]byte, 32) + os.Stdin.Read(buf) + + // We expected to be signaled before stdin closed + fmt.Println("not ok") + os.Exit(1) +} diff --git a/src/syscall/syscall_freebsd_test.go b/src/syscall/syscall_freebsd_test.go index 89c7959d0c..72cd133b85 100644 --- a/src/syscall/syscall_freebsd_test.go +++ b/src/syscall/syscall_freebsd_test.go @@ -9,6 +9,7 @@ package syscall_test import ( "fmt" + "os" "syscall" "testing" "unsafe" @@ -53,3 +54,13 @@ func TestConvertFromDirent11(t *testing.T) { } } } + +func TestMain(m *testing.M) { + if os.Getenv("GO_DEATHSIG_PARENT") == "1" { + deathSignalParent() + } else if os.Getenv("GO_DEATHSIG_CHILD") == "1" { + deathSignalChild() + } + + os.Exit(m.Run()) +} diff --git a/src/syscall/syscall_linux_test.go b/src/syscall/syscall_linux_test.go index 442dc9f10e..8d828be015 100644 --- a/src/syscall/syscall_linux_test.go +++ b/src/syscall/syscall_linux_test.go @@ -5,13 +5,11 @@ package syscall_test import ( - "bufio" "fmt" "io" "io/fs" "os" "os/exec" - "os/signal" "path/filepath" "runtime" "sort" @@ -19,7 +17,6 @@ import ( "strings" "syscall" "testing" - "time" "unsafe" ) @@ -153,120 +150,6 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -func TestLinuxDeathSignal(t *testing.T) { - if os.Getuid() != 0 { - t.Skip("skipping root only test") - } - - // Copy the test binary to a location that a non-root user can read/execute - // after we drop privileges - tempDir, err := os.MkdirTemp("", "TestDeathSignal") - if err != nil { - t.Fatalf("cannot create temporary directory: %v", err) - } - defer os.RemoveAll(tempDir) - os.Chmod(tempDir, 0755) - - tmpBinary := filepath.Join(tempDir, filepath.Base(os.Args[0])) - - src, err := os.Open(os.Args[0]) - if err != nil { - t.Fatalf("cannot open binary %q, %v", os.Args[0], err) - } - defer src.Close() - - dst, err := os.OpenFile(tmpBinary, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) - if err != nil { - t.Fatalf("cannot create temporary binary %q, %v", tmpBinary, err) - } - if _, err := io.Copy(dst, src); err != nil { - t.Fatalf("failed to copy test binary to %q, %v", tmpBinary, err) - } - err = dst.Close() - if err != nil { - t.Fatalf("failed to close test binary %q, %v", tmpBinary, err) - } - - cmd := exec.Command(tmpBinary) - cmd.Env = append(os.Environ(), "GO_DEATHSIG_PARENT=1") - chldStdin, err := cmd.StdinPipe() - if err != nil { - t.Fatalf("failed to create new stdin pipe: %v", err) - } - chldStdout, err := cmd.StdoutPipe() - if err != nil { - t.Fatalf("failed to create new stdout pipe: %v", err) - } - cmd.Stderr = os.Stderr - - err = cmd.Start() - defer cmd.Wait() - if err != nil { - t.Fatalf("failed to start first child process: %v", err) - } - - chldPipe := bufio.NewReader(chldStdout) - - if got, err := chldPipe.ReadString('\n'); got == "start\n" { - syscall.Kill(cmd.Process.Pid, syscall.SIGTERM) - - go func() { - time.Sleep(5 * time.Second) - chldStdin.Close() - }() - - want := "ok\n" - if got, err = chldPipe.ReadString('\n'); got != want { - t.Fatalf("expected %q, received %q, %v", want, got, err) - } - } else { - t.Fatalf("did not receive start from child, received %q, %v", got, err) - } -} - -func deathSignalParent() { - cmd := exec.Command(os.Args[0]) - cmd.Env = append(os.Environ(), - "GO_DEATHSIG_PARENT=", - "GO_DEATHSIG_CHILD=1", - ) - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - attrs := syscall.SysProcAttr{ - Pdeathsig: syscall.SIGUSR1, - // UID/GID 99 is the user/group "nobody" on RHEL/Fedora and is - // unused on Ubuntu - Credential: &syscall.Credential{Uid: 99, Gid: 99}, - } - cmd.SysProcAttr = &attrs - - err := cmd.Start() - if err != nil { - fmt.Fprintf(os.Stderr, "death signal parent error: %v\n", err) - os.Exit(1) - } - cmd.Wait() - os.Exit(0) -} - -func deathSignalChild() { - c := make(chan os.Signal, 1) - signal.Notify(c, syscall.SIGUSR1) - go func() { - <-c - fmt.Println("ok") - os.Exit(0) - }() - fmt.Println("start") - - buf := make([]byte, 32) - os.Stdin.Read(buf) - - // We expected to be signaled before stdin closed - fmt.Println("not ok") - os.Exit(1) -} - func TestParseNetlinkMessage(t *testing.T) { for i, b := range [][]byte{ {103, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 11, 0, 1, 0, 0, 0, 0, 5, 8, 0, 3, From 24e798e2876f05d628f1e9a32ce8c7f4a3ed3268 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 13 Oct 2021 16:30:16 +0200 Subject: [PATCH 010/406] syscall: use fcntl with F_DUP2FD_CLOEXEC in forkAndExecInChild on FreeBSD Use fcntl(oldfd, F_DUP2FD_CLOEXEC, newfd) to duplicate the file descriptor and mark is as close-on-exec instead of dup2 & fcntl. FreeBSD implements dup3 like this in libc. Change-Id: I36e37bc61c2e31561adb49001f287764125a74de Reviewed-on: https://go-review.googlesource.com/c/go/+/355571 Trust: Tobias Klauser Reviewed-by: Ian Lance Taylor --- src/syscall/exec_freebsd.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/syscall/exec_freebsd.go b/src/syscall/exec_freebsd.go index a7410db4b6..90793fe83f 100644 --- a/src/syscall/exec_freebsd.go +++ b/src/syscall/exec_freebsd.go @@ -214,11 +214,10 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr // Pass 1: look for fd[i] < i and move those up above len(fd) // so that pass 2 won't stomp on an fd it needs later. if pipe < nextfd { - _, _, err1 = RawSyscall(SYS_DUP2, uintptr(pipe), uintptr(nextfd), 0) + _, _, err1 = RawSyscall(SYS_FCNTL, uintptr(pipe), F_DUP2FD_CLOEXEC, uintptr(nextfd)) if err1 != 0 { goto childerror } - RawSyscall(SYS_FCNTL, uintptr(nextfd), F_SETFD, FD_CLOEXEC) pipe = nextfd nextfd++ } @@ -227,11 +226,10 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr if nextfd == pipe { // don't stomp on pipe nextfd++ } - _, _, err1 = RawSyscall(SYS_DUP2, uintptr(fd[i]), uintptr(nextfd), 0) + _, _, err1 = RawSyscall(SYS_FCNTL, uintptr(fd[i]), F_DUP2FD_CLOEXEC, uintptr(nextfd)) if err1 != 0 { goto childerror } - RawSyscall(SYS_FCNTL, uintptr(nextfd), F_SETFD, FD_CLOEXEC) fd[i] = nextfd nextfd++ } From ad99d8840edc655a757570d3d4ec62ad8f4df8a7 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 13 Oct 2021 21:13:05 -0700 Subject: [PATCH 011/406] cmd/compile/internal/types2: avoid infinite expansion for invalid recursive generic types The algorithm for detecting invalid recursive types that expand indefinitely suffered from the exact problem is was intended to detect: if the indefinite expansion is happening through type parameters, the algorithm ended up in an infinite sequence of instantiations. (This is only a problem for generic types). Changed the algorithm to always only consider the "original" uninstantiated types. This avoids the problem but it will also not detect some invalid recursive generic types anymore. That requires a more sophisticated type flow analysis. Opened #48962 to track. Addressed with help from @findleyr. For #48951. Change-Id: Ie29cea8f810dae55153dbb1b17c9390cd823c2d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/355732 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/decl.go | 13 ++++++++++-- .../internal/types2/testdata/check/issues.go2 | 4 ++-- .../types2/testdata/fixedbugs/issue39634.go2 | 4 ++-- .../types2/testdata/fixedbugs/issue39938.go2 | 12 ++++++----- .../types2/testdata/fixedbugs/issue48951.go2 | 21 +++++++++++++++++++ 5 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 src/cmd/compile/internal/types2/testdata/fixedbugs/issue48951.go2 diff --git a/src/cmd/compile/internal/types2/decl.go b/src/cmd/compile/internal/types2/decl.go index 26a16d9917..9fd60d6aa2 100644 --- a/src/cmd/compile/internal/types2/decl.go +++ b/src/cmd/compile/internal/types2/decl.go @@ -330,7 +330,16 @@ func (check *Checker) validType(typ Type, path []Object) typeInfo { } case *Named: - t.resolve(check.conf.Context) + // If t is parameterized, we should be considering the instantiated (expanded) + // form of t, but in general we can't with this algorithm: if t is an invalid + // type it may be so because it infinitely expands through a type parameter. + // Instantiating such a type would lead to an infinite sequence of instantiations. + // In general, we need "type flow analysis" to recognize those cases. + // Example: type A[T any] struct{ x A[*T] } (issue #48951) + // In this algorithm we always only consider the orginal, uninstantiated type. + // This won't recognize some invalid cases with parameterized types, but it + // will terminate. + t = t.orig // don't touch the type if it is from a different package or the Universe scope // (doing so would lead to a race condition - was issue #35049) @@ -359,7 +368,7 @@ func (check *Checker) validType(typ Type, path []Object) typeInfo { check.cycleError(path[i:]) t.info = invalid t.underlying = Typ[Invalid] - return t.info + return invalid } } panic("cycle start not found") diff --git a/src/cmd/compile/internal/types2/testdata/check/issues.go2 b/src/cmd/compile/internal/types2/testdata/check/issues.go2 index effc2db7ae..7c5659ba17 100644 --- a/src/cmd/compile/internal/types2/testdata/check/issues.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/issues.go2 @@ -145,8 +145,8 @@ type List3[TElem any] struct { } // Infinite generic type declarations must lead to an error. -type inf1[T any] struct{ _ inf1 /* ERROR illegal cycle */ [T] } -type inf2[T any] struct{ inf2 /* ERROR illegal cycle */ [T] } +type inf1 /* ERROR illegal cycle */ [T any] struct{ _ inf1[T] } +type inf2 /* ERROR illegal cycle */ [T any] struct{ inf2[T] } // The implementation of conversions T(x) between integers and floating-point // numbers checks that both T and x have either integer or floating-point diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2 index 8e6bd974e8..200484b6d9 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2 @@ -37,8 +37,8 @@ func main7() { var _ foo7 = x7[int]{} } // func main8() {} // crash 9 -type foo9[A any] interface { foo9 /* ERROR illegal cycle */ [A] } -func _() { var _ = new(foo9 /* ERROR illegal cycle */ [int]) } +type foo9 /* ERROR illegal cycle */ [A any] interface { foo9[A] } +func _() { var _ = new(foo9[int]) } // crash 12 var u /* ERROR cycle */ , i [func /* ERROR used as value */ /* ERROR used as value */ (u, c /* ERROR undeclared */ /* ERROR undeclared */ ) {}(0, len /* ERROR must be called */ /* ERROR must be called */ )]c /* ERROR undeclared */ /* ERROR undeclared */ diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39938.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39938.go2 index 0da6e103fd..31bec5fb01 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39938.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39938.go2 @@ -3,6 +3,8 @@ // license that can be found in the LICENSE file. // Check "infinite expansion" cycle errors across instantiated types. +// We can't detect these errors anymore at the moment. See #48962 for +// details. package p @@ -11,11 +13,11 @@ type E1[P any] *P type E2[P any] struct{ _ P } type E3[P any] struct{ _ *P } -type T0 /* ERROR illegal cycle */ struct { +type T0 /* illegal cycle */ struct { _ E0[T0] } -type T0_ /* ERROR illegal cycle */ struct { +type T0_ /* illegal cycle */ struct { E0[T0_] } @@ -23,7 +25,7 @@ type T1 struct { _ E1[T1] } -type T2 /* ERROR illegal cycle */ struct { +type T2 /* illegal cycle */ struct { _ E2[T2] } @@ -33,7 +35,7 @@ type T3 struct { // some more complex cases -type T4 /* ERROR illegal cycle */ struct { +type T4 /* illegal cycle */ struct { _ E0[E2[T4]] } @@ -41,7 +43,7 @@ type T5 struct { _ E0[E2[E0[E1[E2[[10]T5]]]]] } -type T6 /* ERROR illegal cycle */ struct { +type T6 /* illegal cycle */ struct { _ E0[[10]E2[E0[E2[E2[T6]]]]] } diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48951.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48951.go2 new file mode 100644 index 0000000000..cf02cc130a --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48951.go2 @@ -0,0 +1,21 @@ +// Copyright 2020 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 p + +type ( + A1 /* ERROR illegal cycle */ [P any] [10]A1[P] + A2 /* ERROR illegal cycle */ [P any] [10]A2[*P] + A3[P any] [10]*A3[P] + + L1[P any] []L1[P] + + S1 /* ERROR illegal cycle */ [P any] struct{ f S1[P] } + S2 /* ERROR illegal cycle */ [P any] struct{ f S2[*P] } // like example in issue + S3[P any] struct{ f *S3[P] } + + I1 /* ERROR illegal cycle */ [P any] interface{ I1[P] } + I2 /* ERROR illegal cycle */ [P any] interface{ I2[*P] } + I3[P any] interface{ *I3 /* ERROR interface contains type constraints */ [P] } +) From fbdf83072c413943ccbd3b556654276126117463 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 13 Oct 2021 21:36:03 -0700 Subject: [PATCH 012/406] go/types: avoid infinite expansion for invalid recursive generic types This is a clean port of CL 355732 from types2 to go/types. Fixes #48951. Change-Id: I9f8cc0655166835d9450608f6e50b726659a73f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/355733 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/go/types/decl.go | 14 +++++++++++-- src/go/types/testdata/check/issues.go2 | 4 ++-- .../types/testdata/fixedbugs/issue39634.go2 | 4 ++-- .../types/testdata/fixedbugs/issue39938.go2 | 12 ++++++----- .../types/testdata/fixedbugs/issue48951.go2 | 21 +++++++++++++++++++ 5 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 src/go/types/testdata/fixedbugs/issue48951.go2 diff --git a/src/go/types/decl.go b/src/go/types/decl.go index f97fa252cb..4aa49b17ca 100644 --- a/src/go/types/decl.go +++ b/src/go/types/decl.go @@ -329,7 +329,17 @@ func (check *Checker) validType(typ Type, path []Object) typeInfo { } case *Named: - t.resolve(check.conf.Context) + // If t is parameterized, we should be considering the instantiated (expanded) + // form of t, but in general we can't with this algorithm: if t is an invalid + // type it may be so because it infinitely expands through a type parameter. + // Instantiating such a type would lead to an infinite sequence of instantiations. + // In general, we need "type flow analysis" to recognize those cases. + // Example: type A[T any] struct{ x A[*T] } (issue #48951) + // In this algorithm we always only consider the orginal, uninstantiated type. + // This won't recognize some invalid cases with parameterized types, but it + // will terminate. + t = t.orig + // don't touch the type if it is from a different package or the Universe scope // (doing so would lead to a race condition - was issue #35049) if t.obj.pkg != check.pkg { @@ -357,7 +367,7 @@ func (check *Checker) validType(typ Type, path []Object) typeInfo { check.cycleError(path[i:]) t.info = invalid t.underlying = Typ[Invalid] - return t.info + return invalid } } panic("cycle start not found") diff --git a/src/go/types/testdata/check/issues.go2 b/src/go/types/testdata/check/issues.go2 index a994d73f66..c46a34e2eb 100644 --- a/src/go/types/testdata/check/issues.go2 +++ b/src/go/types/testdata/check/issues.go2 @@ -146,8 +146,8 @@ type List3[TElem any] struct { } // Infinite generic type declarations must lead to an error. -type inf1[T any] struct{ _ inf1 /* ERROR illegal cycle */ [T] } -type inf2[T any] struct{ inf2 /* ERROR illegal cycle */ [T] } +type inf1 /* ERROR illegal cycle */ [T any] struct{ _ inf1[T] } +type inf2 /* ERROR illegal cycle */ [T any] struct{ inf2[T] } // The implementation of conversions T(x) between integers and floating-point // numbers checks that both T and x have either integer or floating-point diff --git a/src/go/types/testdata/fixedbugs/issue39634.go2 b/src/go/types/testdata/fixedbugs/issue39634.go2 index c46d38f8c4..5cff6e7555 100644 --- a/src/go/types/testdata/fixedbugs/issue39634.go2 +++ b/src/go/types/testdata/fixedbugs/issue39634.go2 @@ -37,8 +37,8 @@ func main7() { var _ foo7 = x7[int]{} } // func main8() {} // crash 9 -type foo9[A any] interface { foo9 /* ERROR illegal cycle */ [A] } -func _() { var _ = new(foo9 /* ERROR illegal cycle */ [int]) } +type foo9 /* ERROR illegal cycle */ [A any] interface { foo9[A] } +func _() { var _ = new(foo9[int]) } // crash 12 var u /* ERROR cycle */ , i [func /* ERROR used as value */ /* ERROR used as value */ (u, c /* ERROR undeclared */ /* ERROR undeclared */ ) {}(0, len /* ERROR must be called */ /* ERROR must be called */ )]c /* ERROR undeclared */ /* ERROR undeclared */ diff --git a/src/go/types/testdata/fixedbugs/issue39938.go2 b/src/go/types/testdata/fixedbugs/issue39938.go2 index 0da6e103fd..31bec5fb01 100644 --- a/src/go/types/testdata/fixedbugs/issue39938.go2 +++ b/src/go/types/testdata/fixedbugs/issue39938.go2 @@ -3,6 +3,8 @@ // license that can be found in the LICENSE file. // Check "infinite expansion" cycle errors across instantiated types. +// We can't detect these errors anymore at the moment. See #48962 for +// details. package p @@ -11,11 +13,11 @@ type E1[P any] *P type E2[P any] struct{ _ P } type E3[P any] struct{ _ *P } -type T0 /* ERROR illegal cycle */ struct { +type T0 /* illegal cycle */ struct { _ E0[T0] } -type T0_ /* ERROR illegal cycle */ struct { +type T0_ /* illegal cycle */ struct { E0[T0_] } @@ -23,7 +25,7 @@ type T1 struct { _ E1[T1] } -type T2 /* ERROR illegal cycle */ struct { +type T2 /* illegal cycle */ struct { _ E2[T2] } @@ -33,7 +35,7 @@ type T3 struct { // some more complex cases -type T4 /* ERROR illegal cycle */ struct { +type T4 /* illegal cycle */ struct { _ E0[E2[T4]] } @@ -41,7 +43,7 @@ type T5 struct { _ E0[E2[E0[E1[E2[[10]T5]]]]] } -type T6 /* ERROR illegal cycle */ struct { +type T6 /* illegal cycle */ struct { _ E0[[10]E2[E0[E2[E2[T6]]]]] } diff --git a/src/go/types/testdata/fixedbugs/issue48951.go2 b/src/go/types/testdata/fixedbugs/issue48951.go2 new file mode 100644 index 0000000000..cf02cc130a --- /dev/null +++ b/src/go/types/testdata/fixedbugs/issue48951.go2 @@ -0,0 +1,21 @@ +// Copyright 2020 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 p + +type ( + A1 /* ERROR illegal cycle */ [P any] [10]A1[P] + A2 /* ERROR illegal cycle */ [P any] [10]A2[*P] + A3[P any] [10]*A3[P] + + L1[P any] []L1[P] + + S1 /* ERROR illegal cycle */ [P any] struct{ f S1[P] } + S2 /* ERROR illegal cycle */ [P any] struct{ f S2[*P] } // like example in issue + S3[P any] struct{ f *S3[P] } + + I1 /* ERROR illegal cycle */ [P any] interface{ I1[P] } + I2 /* ERROR illegal cycle */ [P any] interface{ I2[*P] } + I3[P any] interface{ *I3 /* ERROR interface contains type constraints */ [P] } +) From 011fd002457da0823da5f06b099fcf6e21444b00 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Thu, 5 Aug 2021 11:32:43 -0700 Subject: [PATCH 013/406] sync: remove TestWaitGroupMisuse2 and TestWaitGroupMisuse3 These tests are inherently nondeterministic: They exercise a racy code path for up to one million iterations, and require that an error occur at least once. TestWaitGroupMisuse2 in particular is an ongoing source of trybot flakiness. Fixes #38163. Change-Id: Ibbbda2c998c915333487ad262d3df6829de01c2b Reviewed-on: https://go-review.googlesource.com/c/go/+/340249 Trust: Damien Neil Trust: Dmitri Shuralyov Run-TryBot: Damien Neil TryBot-Result: Go Bot Reviewed-by: Dmitry Vyukov --- src/sync/waitgroup_test.go | 126 ------------------------------------- 1 file changed, 126 deletions(-) diff --git a/src/sync/waitgroup_test.go b/src/sync/waitgroup_test.go index c569e0faa2..4ded218d2d 100644 --- a/src/sync/waitgroup_test.go +++ b/src/sync/waitgroup_test.go @@ -5,8 +5,6 @@ package sync_test import ( - "internal/race" - "runtime" . "sync" "sync/atomic" "testing" @@ -48,12 +46,6 @@ func TestWaitGroup(t *testing.T) { } } -func knownRacy(t *testing.T) { - if race.Enabled { - t.Skip("skipping known-racy test under the race detector") - } -} - func TestWaitGroupMisuse(t *testing.T) { defer func() { err := recover() @@ -68,124 +60,6 @@ func TestWaitGroupMisuse(t *testing.T) { t.Fatal("Should panic") } -// pollUntilEqual blocks until v, loaded atomically, is -// equal to the target. -func pollUntilEqual(v *uint32, target uint32) { - for { - for i := 0; i < 1e3; i++ { - if atomic.LoadUint32(v) == target { - return - } - } - // yield to avoid deadlock with the garbage collector - // see issue #20072 - runtime.Gosched() - } -} - -func TestWaitGroupMisuse2(t *testing.T) { - knownRacy(t) - if runtime.NumCPU() <= 4 { - t.Skip("NumCPU<=4, skipping: this test requires parallelism") - } - defer func() { - err := recover() - if err != "sync: negative WaitGroup counter" && - err != "sync: WaitGroup misuse: Add called concurrently with Wait" && - err != "sync: WaitGroup is reused before previous Wait has returned" { - t.Fatalf("Unexpected panic: %#v", err) - } - }() - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) - done := make(chan interface{}, 2) - // The detection is opportunistic, so we want it to panic - // at least in one run out of a million. - for i := 0; i < 1e6; i++ { - var wg WaitGroup - var here uint32 - wg.Add(1) - go func() { - defer func() { - done <- recover() - }() - atomic.AddUint32(&here, 1) - pollUntilEqual(&here, 3) - wg.Wait() - }() - go func() { - defer func() { - done <- recover() - }() - atomic.AddUint32(&here, 1) - pollUntilEqual(&here, 3) - wg.Add(1) // This is the bad guy. - wg.Done() - }() - atomic.AddUint32(&here, 1) - pollUntilEqual(&here, 3) - wg.Done() - for j := 0; j < 2; j++ { - if err := <-done; err != nil { - panic(err) - } - } - } - t.Fatal("Should panic") -} - -func TestWaitGroupMisuse3(t *testing.T) { - knownRacy(t) - if runtime.NumCPU() <= 1 { - t.Skip("NumCPU==1, skipping: this test requires parallelism") - } - defer func() { - err := recover() - if err != "sync: negative WaitGroup counter" && - err != "sync: WaitGroup misuse: Add called concurrently with Wait" && - err != "sync: WaitGroup is reused before previous Wait has returned" { - t.Fatalf("Unexpected panic: %#v", err) - } - }() - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) - done := make(chan interface{}, 3) - // The detection is opportunistically, so we want it to panic - // at least in one run out of a million. - for i := 0; i < 1e6; i++ { - var wg WaitGroup - wg.Add(1) - go func() { - defer func() { - done <- recover() - }() - wg.Done() - }() - go func() { - defer func() { - done <- recover() - }() - wg.Wait() - // Start reusing the wg before waiting for the Wait below to return. - wg.Add(1) - go func() { - wg.Done() - }() - wg.Wait() - }() - go func() { - defer func() { - done <- recover() - }() - wg.Wait() - }() - for j := 0; j < 3; j++ { - if err := <-done; err != nil { - panic(err) - } - } - } - t.Fatal("Should panic") -} - func TestWaitGroupRace(t *testing.T) { // Run this test for about 1ms. for i := 0; i < 1000; i++ { From 765c9116be44641854f580c19e3589d7b86a3d28 Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Thu, 30 Sep 2021 14:37:30 -0700 Subject: [PATCH 014/406] cmd/go: move module build info formatting into runtime/debug Previously, modload.PackageBuildInfo returned a string containing information about modules used to build an executable. This string is embedded in the binary and can be read with debug.ReadBuildInfo or 'go version -m'. With this change, debug.BuildInfo now has a MarshalText method that returns a string in the same format as modload.PackageBuildInfo. Package.load now calls Package.setBuildInfo, which constructs a debug.BuildInfo, formats it with MarshalText, then sets Package.Internal.BuildInfo. This is equivalent to what modload.PackageBuildInfo did. modload.PackageBuildInfo is deleted, since it's no longer used. For #37475 Change-Id: I5875a98cb64737637fec2a450ab2ffa7f1805707 Reviewed-on: https://go-review.googlesource.com/c/go/+/353886 Trust: Jay Conrod Run-TryBot: Jay Conrod Reviewed-by: Bryan C. Mills --- api/next.txt | 1 + src/cmd/go/internal/load/pkg.go | 83 +++++++++++++++++++++++++++- src/cmd/go/internal/modload/build.go | 48 ---------------- src/runtime/debug/mod.go | 37 +++++++++++++ 4 files changed, 118 insertions(+), 51 deletions(-) diff --git a/api/next.txt b/api/next.txt index 1192fc9069..cb729ea72f 100644 --- a/api/next.txt +++ b/api/next.txt @@ -1,3 +1,4 @@ +pkg runtime/debug, method (*BuildInfo) MarshalText() ([]byte, error) pkg syscall (darwin-amd64), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) pkg syscall (darwin-amd64), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) pkg syscall (darwin-amd64), func SendtoInet4(int, []uint8, int, SockaddrInet4) error diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index a3a8de81c9..a7428ed420 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -21,6 +21,7 @@ import ( pathpkg "path" "path/filepath" "runtime" + "runtime/debug" "sort" "strconv" "strings" @@ -1921,9 +1922,8 @@ func (p *Package) load(ctx context.Context, opts PackageOpts, path string, stk * } p.Internal.Imports = imports p.collectDeps() - - if cfg.ModulesEnabled && p.Error == nil && p.Name == "main" && len(p.DepsErrors) == 0 { - p.Internal.BuildInfo = modload.PackageBuildInfo(pkgPath, p.Deps) + if p.Error == nil && p.Name == "main" && len(p.DepsErrors) == 0 { + p.setBuildInfo() } // unsafe is a fake package. @@ -2195,6 +2195,83 @@ func (p *Package) collectDeps() { } } +// setBuildInfo gathers build information, formats it as a string to be +// embedded in the binary, then sets p.Internal.BuildInfo to that string. +// setBuildInfo should only be called on a main package with no errors. +// +// This information can be retrieved using debug.ReadBuildInfo. +func (p *Package) setBuildInfo() { + setPkgErrorf := func(format string, args ...interface{}) { + if p.Error == nil { + p.Error = &PackageError{Err: fmt.Errorf(format, args...)} + } + } + + var debugModFromModinfo func(*modinfo.ModulePublic) *debug.Module + debugModFromModinfo = func(mi *modinfo.ModulePublic) *debug.Module { + dm := &debug.Module{ + Path: mi.Path, + Version: mi.Version, + } + if mi.Replace != nil { + dm.Replace = debugModFromModinfo(mi.Replace) + } else { + dm.Sum = modfetch.Sum(module.Version{Path: mi.Path, Version: mi.Version}) + } + return dm + } + + var main debug.Module + if p.Module != nil { + main = *debugModFromModinfo(p.Module) + } + + visited := make(map[*Package]bool) + mdeps := make(map[module.Version]*debug.Module) + var q []*Package + q = append(q, p.Internal.Imports...) + for len(q) > 0 { + p1 := q[0] + q = q[1:] + if visited[p1] { + continue + } + visited[p1] = true + if p1.Module != nil { + m := module.Version{Path: p1.Module.Path, Version: p1.Module.Version} + if p1.Module.Path != main.Path && mdeps[m] == nil { + mdeps[m] = debugModFromModinfo(p1.Module) + } + } + q = append(q, p1.Internal.Imports...) + } + sortedMods := make([]module.Version, 0, len(mdeps)) + for mod := range mdeps { + sortedMods = append(sortedMods, mod) + } + module.Sort(sortedMods) + deps := make([]*debug.Module, len(sortedMods)) + for i, mod := range sortedMods { + deps[i] = mdeps[mod] + } + + pkgPath := p.ImportPath + if p.Internal.CmdlineFiles { + pkgPath = "command-line-arguments" + } + info := &debug.BuildInfo{ + Path: pkgPath, + Main: main, + Deps: deps, + } + text, err := info.MarshalText() + if err != nil { + setPkgErrorf("error formatting build info: %v", err) + return + } + p.Internal.BuildInfo = string(text) +} + // SafeArg reports whether arg is a "safe" command-line argument, // meaning that when it appears in a command-line, it probably // doesn't have some special meaning other than its own name. diff --git a/src/cmd/go/internal/modload/build.go b/src/cmd/go/internal/modload/build.go index 8a9792089b..da50743138 100644 --- a/src/cmd/go/internal/modload/build.go +++ b/src/cmd/go/internal/modload/build.go @@ -5,7 +5,6 @@ package modload import ( - "bytes" "context" "encoding/hex" "errors" @@ -336,53 +335,6 @@ func moduleInfo(ctx context.Context, rs *Requirements, m module.Version, mode Li return info } -// PackageBuildInfo returns a string containing module version information -// for modules providing packages named by path and deps. path and deps must -// name packages that were resolved successfully with LoadPackages. -func PackageBuildInfo(path string, deps []string) string { - if !Enabled() { - return "" - } - target, _ := findModule(loaded, path) - mdeps := make(map[module.Version]bool) - for _, dep := range deps { - if m, ok := findModule(loaded, dep); ok { - mdeps[m] = true - } - } - var mods []module.Version - delete(mdeps, target) - for mod := range mdeps { - mods = append(mods, mod) - } - module.Sort(mods) - - var buf bytes.Buffer - fmt.Fprintf(&buf, "path\t%s\n", path) - - writeEntry := func(token string, m module.Version) { - mv := m.Version - if mv == "" { - mv = "(devel)" - } - fmt.Fprintf(&buf, "%s\t%s\t%s", token, m.Path, mv) - if r, _ := Replacement(m); r.Path == "" { - fmt.Fprintf(&buf, "\t%s\n", modfetch.Sum(m)) - } else { - fmt.Fprintf(&buf, "\n=>\t%s\t%s\t%s\n", r.Path, r.Version, modfetch.Sum(r)) - } - } - - if target.Path != "" { - writeEntry("mod", target) - } - for _, mod := range mods { - writeEntry("dep", mod) - } - - return buf.String() -} - // findModule searches for the module that contains the package at path. // If the package was loaded, its containing module and true are returned. // Otherwise, module.Version{} and false are returned. diff --git a/src/runtime/debug/mod.go b/src/runtime/debug/mod.go index 05cad61155..11f995ba75 100644 --- a/src/runtime/debug/mod.go +++ b/src/runtime/debug/mod.go @@ -5,6 +5,8 @@ package debug import ( + "bytes" + "fmt" "strings" ) @@ -34,6 +36,41 @@ type Module struct { Replace *Module // replaced by this module } +func (bi *BuildInfo) MarshalText() ([]byte, error) { + buf := &bytes.Buffer{} + if bi.Path != "" { + fmt.Fprintf(buf, "path\t%s\n", bi.Path) + } + var formatMod func(string, Module) + formatMod = func(word string, m Module) { + buf.WriteString(word) + buf.WriteByte('\t') + buf.WriteString(m.Path) + mv := m.Version + if mv == "" { + mv = "(devel)" + } + buf.WriteByte('\t') + buf.WriteString(mv) + if m.Replace == nil { + buf.WriteByte('\t') + buf.WriteString(m.Sum) + } else { + buf.WriteByte('\n') + formatMod("=>", *m.Replace) + } + buf.WriteByte('\n') + } + if bi.Main.Path != "" { + formatMod("mod", bi.Main) + } + for _, dep := range bi.Deps { + formatMod("dep", *dep) + } + + return buf.Bytes(), nil +} + func readBuildInfo(data string) (*BuildInfo, bool) { if len(data) < 32 { return nil, false From 434cdd0337b9e6c7e0c369c9293cc14fd38dc80d Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Thu, 30 Sep 2021 10:25:49 -0700 Subject: [PATCH 015/406] debug/buildinfo: new package with Read and ReadFile These functions provide access to module information stamped into Go binaries. In the future, they'll provide access to other information (like VCS info). These functions are added in a new package instead of runtime/debug since they use binary parsing packages like debug/elf, which would make runtime/debug an unacceptably heavy dependency. The types in runtime/debug are still used; debug/buildinfo uses them via type aliases. This information is already available for the running binary through debug.ReadBuildInfo and for other binaries with 'go version -m', but until now, there hasn't been a way to get it for other binaries without installing cmd/go. This change copies most of the code in cmd/go/internal/version. A later CL will migrate 'go version -m' to use this package. For #37475 Fixes #39301 Change-Id: I0fbe0896e04f12ef81c6d79fb61b20daede86159 Reviewed-on: https://go-review.googlesource.com/c/go/+/353887 Trust: Jay Conrod Run-TryBot: Jay Conrod Reviewed-by: Bryan C. Mills --- api/next.txt | 4 + src/debug/buildinfo/buildinfo.go | 374 ++++++++++++++++++++++++++ src/debug/buildinfo/buildinfo_test.go | 206 ++++++++++++++ src/go/build/deps_test.go | 5 +- src/runtime/debug/mod.go | 104 +++---- 5 files changed, 645 insertions(+), 48 deletions(-) create mode 100644 src/debug/buildinfo/buildinfo.go create mode 100644 src/debug/buildinfo/buildinfo_test.go diff --git a/api/next.txt b/api/next.txt index cb729ea72f..0a976d7b19 100644 --- a/api/next.txt +++ b/api/next.txt @@ -1,4 +1,8 @@ +pkg debug/buildinfo, func Read(io.ReaderAt) (*debug.BuildInfo, error) +pkg debug/buildinfo, func ReadFile(string) (*debug.BuildInfo, error) +pkg debug/buildinfo, type BuildInfo = debug.BuildInfo pkg runtime/debug, method (*BuildInfo) MarshalText() ([]byte, error) +pkg runtime/debug, method (*BuildInfo) UnmarshalText() ([]byte, error) pkg syscall (darwin-amd64), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) pkg syscall (darwin-amd64), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) pkg syscall (darwin-amd64), func SendtoInet4(int, []uint8, int, SockaddrInet4) error diff --git a/src/debug/buildinfo/buildinfo.go b/src/debug/buildinfo/buildinfo.go new file mode 100644 index 0000000000..8def2eae6e --- /dev/null +++ b/src/debug/buildinfo/buildinfo.go @@ -0,0 +1,374 @@ +// Copyright 2021 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 buildinfo provides access to information embedded in a Go binary +// about how it was built. This includes the Go toolchain version, and the +// set of modules used (for binaries built in module mode). +// +// Build information is available for the currently running binary in +// runtime/debug.ReadBuildInfo. +package buildinfo + +import ( + "bytes" + "debug/elf" + "debug/macho" + "debug/pe" + "encoding/binary" + "errors" + "fmt" + "internal/xcoff" + "io" + "io/fs" + "os" + "runtime/debug" +) + +// Type alias for build info. We cannot move the types here, since +// runtime/debug would need to import this package, which would make it +// a much larger dependency. +type BuildInfo = debug.BuildInfo + +var ( + // errUnrecognizedFormat is returned when a given executable file doesn't + // appear to be in a known format, or it breaks the rules of that format, + // or when there are I/O errors reading the file. + errUnrecognizedFormat = errors.New("unrecognized file format") + + // errNotGoExe is returned when a given executable file is valid but does + // not contain Go build information. + errNotGoExe = errors.New("not a Go executable") + + // The build info blob left by the linker is identified by + // a 16-byte header, consisting of buildInfoMagic (14 bytes), + // the binary's pointer size (1 byte), + // and whether the binary is big endian (1 byte). + buildInfoMagic = []byte("\xff Go buildinf:") +) + +// ReadFile returns build information embedded in a Go binary +// file at the given path. Most information is only available for binaries built +// with module support. +func ReadFile(name string) (info *BuildInfo, err error) { + defer func() { + if pathErr := (*fs.PathError)(nil); errors.As(err, &pathErr) { + err = fmt.Errorf("could not read Go build info: %w", err) + } else if err != nil { + err = fmt.Errorf("could not read Go build info from %s: %w", name, err) + } + }() + + f, err := os.Open(name) + if err != nil { + return nil, err + } + defer f.Close() + return Read(f) +} + +// Read returns build information embedded in a Go binary file +// accessed through the given ReaderAt. Most information is only available for +// binaries built with module support. +func Read(r io.ReaderAt) (*BuildInfo, error) { + _, mod, err := readRawBuildInfo(r) + if err != nil { + return nil, err + } + bi := &BuildInfo{} + if err := bi.UnmarshalText([]byte(mod)); err != nil { + return nil, err + } + return bi, nil +} + +type exe interface { + // ReadData reads and returns up to size bytes starting at virtual address addr. + ReadData(addr, size uint64) ([]byte, error) + + // DataStart returns the virtual address of the segment or section that + // should contain build information. This is either a specially named section + // or the first writable non-zero data segment. + DataStart() uint64 +} + +// readRawBuildInfo extracts the Go toolchain version and module information +// strings from a Go binary. On success, vers should be non-empty. mod +// is empty if the binary was not built with modules enabled. +func readRawBuildInfo(r io.ReaderAt) (vers, mod string, err error) { + // Read the first bytes of the file to identify the format, then delegate to + // a format-specific function to load segment and section headers. + ident := make([]byte, 16) + if n, err := r.ReadAt(ident, 0); n < len(ident) || err != nil { + return "", "", errUnrecognizedFormat + } + + var x exe + switch { + case bytes.HasPrefix(ident, []byte("\x7FELF")): + f, err := elf.NewFile(r) + if err != nil { + return "", "", errUnrecognizedFormat + } + x = &elfExe{f} + case bytes.HasPrefix(ident, []byte("MZ")): + f, err := pe.NewFile(r) + if err != nil { + return "", "", errUnrecognizedFormat + } + x = &peExe{f} + case bytes.HasPrefix(ident, []byte("\xFE\xED\xFA")) || bytes.HasPrefix(ident[1:], []byte("\xFA\xED\xFE")): + f, err := macho.NewFile(r) + if err != nil { + return "", "", errUnrecognizedFormat + } + x = &machoExe{f} + case bytes.HasPrefix(ident, []byte{0x01, 0xDF}) || bytes.HasPrefix(ident, []byte{0x01, 0xF7}): + f, err := xcoff.NewFile(r) + if err != nil { + return "", "", errUnrecognizedFormat + } + x = &xcoffExe{f} + default: + return "", "", errUnrecognizedFormat + } + + // Read the first 64kB of dataAddr to find the build info blob. + // On some platforms, the blob will be in its own section, and DataStart + // returns the address of that section. On others, it's somewhere in the + // data segment; the linker puts it near the beginning. + // See cmd/link/internal/ld.Link.buildinfo. + dataAddr := x.DataStart() + data, err := x.ReadData(dataAddr, 64*1024) + if err != nil { + return "", "", err + } + const ( + buildInfoAlign = 16 + buildinfoSize = 32 + ) + for ; !bytes.HasPrefix(data, buildInfoMagic); data = data[buildInfoAlign:] { + if len(data) < 32 { + return "", "", errNotGoExe + } + } + + // Decode the blob. + // The first 14 bytes are buildInfoMagic. + // The next two bytes indicate pointer size in bytes (4 or 8) and endianness + // (0 for little, 1 for big). + // Two virtual addresses to Go strings follow that: runtime.buildVersion, + // and runtime.modinfo. + // On 32-bit platforms, the last 8 bytes are unused. + ptrSize := int(data[14]) + bigEndian := data[15] != 0 + var bo binary.ByteOrder + if bigEndian { + bo = binary.BigEndian + } else { + bo = binary.LittleEndian + } + var readPtr func([]byte) uint64 + if ptrSize == 4 { + readPtr = func(b []byte) uint64 { return uint64(bo.Uint32(b)) } + } else { + readPtr = bo.Uint64 + } + vers = readString(x, ptrSize, readPtr, readPtr(data[16:])) + if vers == "" { + return "", "", errNotGoExe + } + mod = readString(x, ptrSize, readPtr, readPtr(data[16+ptrSize:])) + if len(mod) >= 33 && mod[len(mod)-17] == '\n' { + // Strip module framing: sentinel strings delimiting the module info. + // These are cmd/go/internal/modload.infoStart and infoEnd. + mod = mod[16 : len(mod)-16] + } else { + mod = "" + } + + return vers, mod, nil +} + +// readString returns the string at address addr in the executable x. +func readString(x exe, ptrSize int, readPtr func([]byte) uint64, addr uint64) string { + hdr, err := x.ReadData(addr, uint64(2*ptrSize)) + if err != nil || len(hdr) < 2*ptrSize { + return "" + } + dataAddr := readPtr(hdr) + dataLen := readPtr(hdr[ptrSize:]) + data, err := x.ReadData(dataAddr, dataLen) + if err != nil || uint64(len(data)) < dataLen { + return "" + } + return string(data) +} + +// elfExe is the ELF implementation of the exe interface. +type elfExe struct { + f *elf.File +} + +func (x *elfExe) ReadData(addr, size uint64) ([]byte, error) { + for _, prog := range x.f.Progs { + if prog.Vaddr <= addr && addr <= prog.Vaddr+prog.Filesz-1 { + n := prog.Vaddr + prog.Filesz - addr + if n > size { + n = size + } + data := make([]byte, n) + _, err := prog.ReadAt(data, int64(addr-prog.Vaddr)) + if err != nil { + return nil, err + } + return data, nil + } + } + return nil, errUnrecognizedFormat +} + +func (x *elfExe) DataStart() uint64 { + for _, s := range x.f.Sections { + if s.Name == ".go.buildinfo" { + return s.Addr + } + } + for _, p := range x.f.Progs { + if p.Type == elf.PT_LOAD && p.Flags&(elf.PF_X|elf.PF_W) == elf.PF_W { + return p.Vaddr + } + } + return 0 +} + +// peExe is the PE (Windows Portable Executable) implementation of the exe interface. +type peExe struct { + f *pe.File +} + +func (x *peExe) imageBase() uint64 { + switch oh := x.f.OptionalHeader.(type) { + case *pe.OptionalHeader32: + return uint64(oh.ImageBase) + case *pe.OptionalHeader64: + return oh.ImageBase + } + return 0 +} + +func (x *peExe) ReadData(addr, size uint64) ([]byte, error) { + addr -= x.imageBase() + for _, sect := range x.f.Sections { + if uint64(sect.VirtualAddress) <= addr && addr <= uint64(sect.VirtualAddress+sect.Size-1) { + n := uint64(sect.VirtualAddress+sect.Size) - addr + if n > size { + n = size + } + data := make([]byte, n) + _, err := sect.ReadAt(data, int64(addr-uint64(sect.VirtualAddress))) + if err != nil { + return nil, errUnrecognizedFormat + } + return data, nil + } + } + return nil, errUnrecognizedFormat +} + +func (x *peExe) DataStart() uint64 { + // Assume data is first writable section. + const ( + IMAGE_SCN_CNT_CODE = 0x00000020 + IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040 + IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080 + IMAGE_SCN_MEM_EXECUTE = 0x20000000 + IMAGE_SCN_MEM_READ = 0x40000000 + IMAGE_SCN_MEM_WRITE = 0x80000000 + IMAGE_SCN_MEM_DISCARDABLE = 0x2000000 + IMAGE_SCN_LNK_NRELOC_OVFL = 0x1000000 + IMAGE_SCN_ALIGN_32BYTES = 0x600000 + ) + for _, sect := range x.f.Sections { + if sect.VirtualAddress != 0 && sect.Size != 0 && + sect.Characteristics&^IMAGE_SCN_ALIGN_32BYTES == IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_MEM_READ|IMAGE_SCN_MEM_WRITE { + return uint64(sect.VirtualAddress) + x.imageBase() + } + } + return 0 +} + +// machoExe is the Mach-O (Apple macOS/iOS) implementation of the exe interface. +type machoExe struct { + f *macho.File +} + +func (x *machoExe) ReadData(addr, size uint64) ([]byte, error) { + for _, load := range x.f.Loads { + seg, ok := load.(*macho.Segment) + if !ok { + continue + } + if seg.Addr <= addr && addr <= seg.Addr+seg.Filesz-1 { + if seg.Name == "__PAGEZERO" { + continue + } + n := seg.Addr + seg.Filesz - addr + if n > size { + n = size + } + data := make([]byte, n) + _, err := seg.ReadAt(data, int64(addr-seg.Addr)) + if err != nil { + return nil, err + } + return data, nil + } + } + return nil, errUnrecognizedFormat +} + +func (x *machoExe) DataStart() uint64 { + // Look for section named "__go_buildinfo". + for _, sec := range x.f.Sections { + if sec.Name == "__go_buildinfo" { + return sec.Addr + } + } + // Try the first non-empty writable segment. + const RW = 3 + for _, load := range x.f.Loads { + seg, ok := load.(*macho.Segment) + if ok && seg.Addr != 0 && seg.Filesz != 0 && seg.Prot == RW && seg.Maxprot == RW { + return seg.Addr + } + } + return 0 +} + +// xcoffExe is the XCOFF (AIX eXtended COFF) implementation of the exe interface. +type xcoffExe struct { + f *xcoff.File +} + +func (x *xcoffExe) ReadData(addr, size uint64) ([]byte, error) { + for _, sect := range x.f.Sections { + if uint64(sect.VirtualAddress) <= addr && addr <= uint64(sect.VirtualAddress+sect.Size-1) { + n := uint64(sect.VirtualAddress+sect.Size) - addr + if n > size { + n = size + } + data := make([]byte, n) + _, err := sect.ReadAt(data, int64(addr-uint64(sect.VirtualAddress))) + if err != nil { + return nil, err + } + return data, nil + } + } + return nil, fmt.Errorf("address not mapped") +} + +func (x *xcoffExe) DataStart() uint64 { + return x.f.SectionByType(xcoff.STYP_DATA).VirtualAddress +} diff --git a/src/debug/buildinfo/buildinfo_test.go b/src/debug/buildinfo/buildinfo_test.go new file mode 100644 index 0000000000..765bf24627 --- /dev/null +++ b/src/debug/buildinfo/buildinfo_test.go @@ -0,0 +1,206 @@ +// Copyright 2021 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 buildinfo_test + +import ( + "bytes" + "debug/buildinfo" + "flag" + "internal/testenv" + "os" + "os/exec" + "path" + "path/filepath" + "runtime" + "strings" + "testing" +) + +var flagAll = flag.Bool("all", false, "test all supported GOOS/GOARCH platforms, instead of only the current platform") + +// TestReadFile confirms that ReadFile can read build information from binaries +// on supported target platforms. It builds a trivial binary on the current +// platforms (or all platforms if -all is set) in various configurations and +// checks that build information can or cannot be read. +func TestReadFile(t *testing.T) { + if testing.Short() { + t.Skip("test requires compiling and linking, which may be slow") + } + testenv.MustHaveGoBuild(t) + + type platform struct{ goos, goarch string } + platforms := []platform{ + {"aix", "ppc64"}, + {"darwin", "amd64"}, + {"darwin", "arm64"}, + {"linux", "386"}, + {"linux", "amd64"}, + {"windows", "386"}, + {"windows", "amd64"}, + } + runtimePlatform := platform{runtime.GOOS, runtime.GOARCH} + haveRuntimePlatform := false + for _, p := range platforms { + if p == runtimePlatform { + haveRuntimePlatform = true + break + } + } + if !haveRuntimePlatform { + platforms = append(platforms, runtimePlatform) + } + + buildWithModules := func(t *testing.T, goos, goarch string) string { + dir := t.TempDir() + gomodPath := filepath.Join(dir, "go.mod") + gomodData := []byte("module example.com/m\ngo 1.18\n") + if err := os.WriteFile(gomodPath, gomodData, 0666); err != nil { + t.Fatal(err) + } + helloPath := filepath.Join(dir, "hello.go") + helloData := []byte("package main\nfunc main() {}\n") + if err := os.WriteFile(helloPath, helloData, 0666); err != nil { + t.Fatal(err) + } + outPath := filepath.Join(dir, path.Base(t.Name())) + cmd := exec.Command("go", "build", "-o="+outPath) + cmd.Dir = dir + cmd.Env = append(os.Environ(), "GO111MODULE=on", "GOOS="+goos, "GOARCH="+goarch) + stderr := &bytes.Buffer{} + cmd.Stderr = stderr + if err := cmd.Run(); err != nil { + t.Fatalf("failed building test file: %v\n%s", err, stderr.Bytes()) + } + return outPath + } + + buildWithGOPATH := func(t *testing.T, goos, goarch string) string { + gopathDir := t.TempDir() + pkgDir := filepath.Join(gopathDir, "src/example.com/m") + if err := os.MkdirAll(pkgDir, 0777); err != nil { + t.Fatal(err) + } + helloPath := filepath.Join(pkgDir, "hello.go") + helloData := []byte("package main\nfunc main() {}\n") + if err := os.WriteFile(helloPath, helloData, 0666); err != nil { + t.Fatal(err) + } + outPath := filepath.Join(gopathDir, path.Base(t.Name())) + cmd := exec.Command("go", "build", "-o="+outPath) + cmd.Dir = pkgDir + cmd.Env = append(os.Environ(), "GO111MODULE=off", "GOPATH="+gopathDir, "GOOS="+goos, "GOARCH="+goarch) + stderr := &bytes.Buffer{} + cmd.Stderr = stderr + if err := cmd.Run(); err != nil { + t.Fatalf("failed building test file: %v\n%s", err, stderr.Bytes()) + } + return outPath + } + + damageBuildInfo := func(t *testing.T, name string) { + data, err := os.ReadFile(name) + if err != nil { + t.Fatal(err) + } + i := bytes.Index(data, []byte("\xff Go buildinf:")) + if i < 0 { + t.Fatal("Go buildinf not found") + } + data[i+2] = 'N' + if err := os.WriteFile(name, data, 0666); err != nil { + t.Fatal(err) + } + } + + cases := []struct { + name string + build func(t *testing.T, goos, goarch string) string + want string + wantErr string + }{ + { + name: "doesnotexist", + build: func(t *testing.T, goos, goarch string) string { + return "doesnotexist.txt" + }, + wantErr: "doesnotexist", + }, + { + name: "empty", + build: func(t *testing.T, _, _ string) string { + dir := t.TempDir() + name := filepath.Join(dir, "empty") + if err := os.WriteFile(name, nil, 0666); err != nil { + t.Fatal(err) + } + return name + }, + wantErr: "unrecognized file format", + }, + { + name: "valid_modules", + build: buildWithModules, + want: "path\texample.com/m\n" + + "mod\texample.com/m\t(devel)\t\n", + }, + { + name: "invalid_modules", + build: func(t *testing.T, goos, goarch string) string { + name := buildWithModules(t, goos, goarch) + damageBuildInfo(t, name) + return name + }, + wantErr: "not a Go executable", + }, + { + name: "valid_gopath", + build: buildWithGOPATH, + want: "", + }, + { + name: "invalid_gopath", + build: func(t *testing.T, goos, goarch string) string { + name := buildWithGOPATH(t, goos, goarch) + damageBuildInfo(t, name) + return name + }, + wantErr: "not a Go executable", + }, + } + + for _, p := range platforms { + p := p + t.Run(p.goos+"_"+p.goarch, func(t *testing.T) { + if p != runtimePlatform && !*flagAll { + t.Skipf("skipping platforms other than %s_%s because -all was not set", runtimePlatform.goos, runtimePlatform.goarch) + } + for _, tc := range cases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + name := tc.build(t, p.goos, p.goarch) + if info, err := buildinfo.ReadFile(name); err != nil { + if tc.wantErr == "" { + t.Fatalf("unexpected error: %v", err) + } else if errMsg := err.Error(); !strings.Contains(errMsg, tc.wantErr) { + t.Fatalf("got error %q; want error containing %q", errMsg, tc.wantErr) + } + } else { + if tc.wantErr != "" { + t.Fatalf("unexpected success; want error containing %q", tc.wantErr) + } else if got, err := info.MarshalText(); err != nil { + t.Fatalf("unexpected error marshaling BuildInfo: %v", err) + } else { + got := string(got) + if got != tc.want { + t.Fatalf("got:\n%s\nwant:\n%s", got, tc.want) + } + } + } + }) + } + }) + } +} diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go index 07fbc8b023..a92bb3893b 100644 --- a/src/go/build/deps_test.go +++ b/src/go/build/deps_test.go @@ -214,7 +214,6 @@ var depsRules = ` mime/quotedprintable, net/internal/socktest, net/url, - runtime/debug, runtime/trace, text/scanner, text/tabwriter; @@ -271,8 +270,10 @@ var depsRules = ` # executable parsing FMT, encoding/binary, compress/zlib + < runtime/debug < debug/dwarf < debug/elf, debug/gosym, debug/macho, debug/pe, debug/plan9obj, internal/xcoff + < debug/buildinfo < DEBUG; # go parser and friends. @@ -510,7 +511,7 @@ var depsRules = ` FMT, flag, math/rand < testing/quick; - FMT, flag, runtime/debug, runtime/trace, internal/sysinfo, math/rand + FMT, DEBUG, flag, runtime/trace, internal/sysinfo, math/rand < testing; FMT, crypto/sha256, encoding/json, go/ast, go/parser, go/token, math/rand, encoding/hex, crypto/sha256 diff --git a/src/runtime/debug/mod.go b/src/runtime/debug/mod.go index 11f995ba75..8c6c48089b 100644 --- a/src/runtime/debug/mod.go +++ b/src/runtime/debug/mod.go @@ -7,7 +7,6 @@ package debug import ( "bytes" "fmt" - "strings" ) // exported from runtime @@ -17,11 +16,19 @@ func modinfo() string // in the running binary. The information is available only // in binaries built with module support. func ReadBuildInfo() (info *BuildInfo, ok bool) { - return readBuildInfo(modinfo()) + data := modinfo() + if len(data) < 32 { + return nil, false + } + data = data[16 : len(data)-16] + bi := &BuildInfo{} + if err := bi.UnmarshalText([]byte(data)); err != nil { + return nil, false + } + return bi, true } -// BuildInfo represents the build information read from -// the running binary. +// BuildInfo represents the build information read from a Go binary. type BuildInfo struct { Path string // The main package path Main Module // The module containing the main package @@ -71,80 +78,85 @@ func (bi *BuildInfo) MarshalText() ([]byte, error) { return buf.Bytes(), nil } -func readBuildInfo(data string) (*BuildInfo, bool) { - if len(data) < 32 { - return nil, false - } - data = data[16 : len(data)-16] +func (bi *BuildInfo) UnmarshalText(data []byte) (err error) { + *bi = BuildInfo{} + lineNum := 1 + defer func() { + if err != nil { + err = fmt.Errorf("could not parse Go build info: line %d: %w", lineNum, err) + } + }() - const ( - pathLine = "path\t" - modLine = "mod\t" - depLine = "dep\t" - repLine = "=>\t" + var ( + pathLine = []byte("path\t") + modLine = []byte("mod\t") + depLine = []byte("dep\t") + repLine = []byte("=>\t") + newline = []byte("\n") + tab = []byte("\t") ) - readEntryFirstLine := func(elem []string) (Module, bool) { + readModuleLine := func(elem [][]byte) (Module, error) { if len(elem) != 2 && len(elem) != 3 { - return Module{}, false + return Module{}, fmt.Errorf("expected 2 or 3 columns; got %d", len(elem)) } sum := "" if len(elem) == 3 { - sum = elem[2] + sum = string(elem[2]) } return Module{ - Path: elem[0], - Version: elem[1], + Path: string(elem[0]), + Version: string(elem[1]), Sum: sum, - }, true + }, nil } var ( - info = &BuildInfo{} last *Module - line string + line []byte ok bool ) - // Reverse of cmd/go/internal/modload.PackageBuildInfo + // Reverse of BuildInfo.String() for len(data) > 0 { - line, data, ok = strings.Cut(data, "\n") + line, data, ok = bytes.Cut(data, newline) if !ok { break } switch { - case strings.HasPrefix(line, pathLine): + case bytes.HasPrefix(line, pathLine): elem := line[len(pathLine):] - info.Path = elem - case strings.HasPrefix(line, modLine): - elem := strings.Split(line[len(modLine):], "\t") - last = &info.Main - *last, ok = readEntryFirstLine(elem) - if !ok { - return nil, false + bi.Path = string(elem) + case bytes.HasPrefix(line, modLine): + elem := bytes.Split(line[len(modLine):], tab) + last = &bi.Main + *last, err = readModuleLine(elem) + if err != nil { + return err } - case strings.HasPrefix(line, depLine): - elem := strings.Split(line[len(depLine):], "\t") + case bytes.HasPrefix(line, depLine): + elem := bytes.Split(line[len(depLine):], tab) last = new(Module) - info.Deps = append(info.Deps, last) - *last, ok = readEntryFirstLine(elem) - if !ok { - return nil, false + bi.Deps = append(bi.Deps, last) + *last, err = readModuleLine(elem) + if err != nil { + return err } - case strings.HasPrefix(line, repLine): - elem := strings.Split(line[len(repLine):], "\t") + case bytes.HasPrefix(line, repLine): + elem := bytes.Split(line[len(repLine):], tab) if len(elem) != 3 { - return nil, false + return fmt.Errorf("expected 3 columns for replacement; got %d", len(elem)) } if last == nil { - return nil, false + return fmt.Errorf("replacement with no module on previous line") } last.Replace = &Module{ - Path: elem[0], - Version: elem[1], - Sum: elem[2], + Path: string(elem[0]), + Version: string(elem[1]), + Sum: string(elem[2]), } last = nil } + lineNum++ } - return info, true + return nil } From 85a068fdf21bd2e4475a87ee049af4fbe797bcbe Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Thu, 30 Sep 2021 10:46:03 -0700 Subject: [PATCH 016/406] runtime/debug: add GoVersion to BuildInfo BuildInfo now includes the version of Go used to build a binary, as reported by runtime.Version() or 'go version'. For #37475 Change-Id: Id07dda357dc70599d64a9202dab894c7288de1de Reviewed-on: https://go-review.googlesource.com/c/go/+/353888 Trust: Jay Conrod Run-TryBot: Jay Conrod TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- api/next.txt | 1 + src/cmd/go/internal/load/pkg.go | 3 +++ src/debug/buildinfo/buildinfo.go | 3 ++- src/debug/buildinfo/buildinfo_test.go | 7 ++++--- src/runtime/debug/mod.go | 20 ++++++++++++++++---- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/api/next.txt b/api/next.txt index 0a976d7b19..ced738e480 100644 --- a/api/next.txt +++ b/api/next.txt @@ -3,6 +3,7 @@ pkg debug/buildinfo, func ReadFile(string) (*debug.BuildInfo, error) pkg debug/buildinfo, type BuildInfo = debug.BuildInfo pkg runtime/debug, method (*BuildInfo) MarshalText() ([]byte, error) pkg runtime/debug, method (*BuildInfo) UnmarshalText() ([]byte, error) +pkg runtime/debug, type BuildInfo struct, GoVersion string pkg syscall (darwin-amd64), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) pkg syscall (darwin-amd64), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) pkg syscall (darwin-amd64), func SendtoInet4(int, []uint8, int, SockaddrInet4) error diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index a7428ed420..0fc5afbc36 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -2200,6 +2200,9 @@ func (p *Package) collectDeps() { // setBuildInfo should only be called on a main package with no errors. // // This information can be retrieved using debug.ReadBuildInfo. +// +// Note that the GoVersion field is not set here to avoid encoding it twice. +// It is stored separately in the binary, mostly for historical reasons. func (p *Package) setBuildInfo() { setPkgErrorf := func(format string, args ...interface{}) { if p.Error == nil { diff --git a/src/debug/buildinfo/buildinfo.go b/src/debug/buildinfo/buildinfo.go index 8def2eae6e..f84429a342 100644 --- a/src/debug/buildinfo/buildinfo.go +++ b/src/debug/buildinfo/buildinfo.go @@ -71,7 +71,7 @@ func ReadFile(name string) (info *BuildInfo, err error) { // accessed through the given ReaderAt. Most information is only available for // binaries built with module support. func Read(r io.ReaderAt) (*BuildInfo, error) { - _, mod, err := readRawBuildInfo(r) + vers, mod, err := readRawBuildInfo(r) if err != nil { return nil, err } @@ -79,6 +79,7 @@ func Read(r io.ReaderAt) (*BuildInfo, error) { if err := bi.UnmarshalText([]byte(mod)); err != nil { return nil, err } + bi.GoVersion = vers return bi, nil } diff --git a/src/debug/buildinfo/buildinfo_test.go b/src/debug/buildinfo/buildinfo_test.go index 765bf24627..ab307d75c2 100644 --- a/src/debug/buildinfo/buildinfo_test.go +++ b/src/debug/buildinfo/buildinfo_test.go @@ -142,7 +142,8 @@ func TestReadFile(t *testing.T) { { name: "valid_modules", build: buildWithModules, - want: "path\texample.com/m\n" + + want: "go\t$GOVERSION\n" + + "path\texample.com/m\n" + "mod\texample.com/m\t(devel)\t\n", }, { @@ -157,7 +158,7 @@ func TestReadFile(t *testing.T) { { name: "valid_gopath", build: buildWithGOPATH, - want: "", + want: "go\t$GOVERSION\n", }, { name: "invalid_gopath", @@ -193,7 +194,7 @@ func TestReadFile(t *testing.T) { } else if got, err := info.MarshalText(); err != nil { t.Fatalf("unexpected error marshaling BuildInfo: %v", err) } else { - got := string(got) + got := strings.ReplaceAll(string(got), runtime.Version(), "$GOVERSION") if got != tc.want { t.Fatalf("got:\n%s\nwant:\n%s", got, tc.want) } diff --git a/src/runtime/debug/mod.go b/src/runtime/debug/mod.go index 8c6c48089b..0c6488753b 100644 --- a/src/runtime/debug/mod.go +++ b/src/runtime/debug/mod.go @@ -7,6 +7,7 @@ package debug import ( "bytes" "fmt" + "runtime" ) // exported from runtime @@ -25,14 +26,22 @@ func ReadBuildInfo() (info *BuildInfo, ok bool) { if err := bi.UnmarshalText([]byte(data)); err != nil { return nil, false } + + // The go version is stored separately from other build info, mostly for + // historical reasons. It is not part of the modinfo() string, and + // ParseBuildInfo does not recognize it. We inject it here to hide this + // awkwardness from the user. + bi.GoVersion = runtime.Version() + return bi, true } // BuildInfo represents the build information read from a Go binary. type BuildInfo struct { - Path string // The main package path - Main Module // The module containing the main package - Deps []*Module // Module dependencies + GoVersion string // Version of Go that produced this binary. + Path string // The main package path + Main Module // The module containing the main package + Deps []*Module // Module dependencies } // Module represents a module. @@ -45,6 +54,9 @@ type Module struct { func (bi *BuildInfo) MarshalText() ([]byte, error) { buf := &bytes.Buffer{} + if bi.GoVersion != "" { + fmt.Fprintf(buf, "go\t%s\n", bi.GoVersion) + } if bi.Path != "" { fmt.Fprintf(buf, "path\t%s\n", bi.Path) } @@ -116,7 +128,7 @@ func (bi *BuildInfo) UnmarshalText(data []byte) (err error) { line []byte ok bool ) - // Reverse of BuildInfo.String() + // Reverse of BuildInfo.String(), except for go version. for len(data) > 0 { line, data, ok = bytes.Cut(data, newline) if !ok { From a8c5a994d62cc920c134426f7eae892b013ee32d Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Thu, 30 Sep 2021 13:16:33 -0700 Subject: [PATCH 017/406] cmd/go: migrate 'go version' to use buildinfo.ReadFile The same code was copied into debug/buildinfo. 'go version' doesn't need its own copy. For #37475 Change-Id: I9e473ce574139a87a5f9c63229f0fc7ffac447a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/353929 Trust: Jay Conrod Run-TryBot: Jay Conrod Reviewed-by: Bryan C. Mills --- src/cmd/go/internal/version/exe.go | 263 ------------------------- src/cmd/go/internal/version/version.go | 92 ++------- 2 files changed, 14 insertions(+), 341 deletions(-) delete mode 100644 src/cmd/go/internal/version/exe.go diff --git a/src/cmd/go/internal/version/exe.go b/src/cmd/go/internal/version/exe.go deleted file mode 100644 index 0e7deef149..0000000000 --- a/src/cmd/go/internal/version/exe.go +++ /dev/null @@ -1,263 +0,0 @@ -// Copyright 2019 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 version - -import ( - "bytes" - "debug/elf" - "debug/macho" - "debug/pe" - "fmt" - "internal/xcoff" - "io" - "os" -) - -// An exe is a generic interface to an OS executable (ELF, Mach-O, PE, XCOFF). -type exe interface { - // Close closes the underlying file. - Close() error - - // ReadData reads and returns up to size byte starting at virtual address addr. - ReadData(addr, size uint64) ([]byte, error) - - // DataStart returns the writable data segment start address. - DataStart() uint64 -} - -// openExe opens file and returns it as an exe. -func openExe(file string) (exe, error) { - f, err := os.Open(file) - if err != nil { - return nil, err - } - data := make([]byte, 16) - if _, err := io.ReadFull(f, data); err != nil { - return nil, err - } - f.Seek(0, 0) - if bytes.HasPrefix(data, []byte("\x7FELF")) { - e, err := elf.NewFile(f) - if err != nil { - f.Close() - return nil, err - } - return &elfExe{f, e}, nil - } - if bytes.HasPrefix(data, []byte("MZ")) { - e, err := pe.NewFile(f) - if err != nil { - f.Close() - return nil, err - } - return &peExe{f, e}, nil - } - if bytes.HasPrefix(data, []byte("\xFE\xED\xFA")) || bytes.HasPrefix(data[1:], []byte("\xFA\xED\xFE")) { - e, err := macho.NewFile(f) - if err != nil { - f.Close() - return nil, err - } - return &machoExe{f, e}, nil - } - if bytes.HasPrefix(data, []byte{0x01, 0xDF}) || bytes.HasPrefix(data, []byte{0x01, 0xF7}) { - e, err := xcoff.NewFile(f) - if err != nil { - f.Close() - return nil, err - } - return &xcoffExe{f, e}, nil - - } - return nil, fmt.Errorf("unrecognized executable format") -} - -// elfExe is the ELF implementation of the exe interface. -type elfExe struct { - os *os.File - f *elf.File -} - -func (x *elfExe) Close() error { - return x.os.Close() -} - -func (x *elfExe) ReadData(addr, size uint64) ([]byte, error) { - for _, prog := range x.f.Progs { - if prog.Vaddr <= addr && addr <= prog.Vaddr+prog.Filesz-1 { - n := prog.Vaddr + prog.Filesz - addr - if n > size { - n = size - } - data := make([]byte, n) - _, err := prog.ReadAt(data, int64(addr-prog.Vaddr)) - if err != nil { - return nil, err - } - return data, nil - } - } - return nil, fmt.Errorf("address not mapped") -} - -func (x *elfExe) DataStart() uint64 { - for _, s := range x.f.Sections { - if s.Name == ".go.buildinfo" { - return s.Addr - } - } - for _, p := range x.f.Progs { - if p.Type == elf.PT_LOAD && p.Flags&(elf.PF_X|elf.PF_W) == elf.PF_W { - return p.Vaddr - } - } - return 0 -} - -// peExe is the PE (Windows Portable Executable) implementation of the exe interface. -type peExe struct { - os *os.File - f *pe.File -} - -func (x *peExe) Close() error { - return x.os.Close() -} - -func (x *peExe) imageBase() uint64 { - switch oh := x.f.OptionalHeader.(type) { - case *pe.OptionalHeader32: - return uint64(oh.ImageBase) - case *pe.OptionalHeader64: - return oh.ImageBase - } - return 0 -} - -func (x *peExe) ReadData(addr, size uint64) ([]byte, error) { - addr -= x.imageBase() - for _, sect := range x.f.Sections { - if uint64(sect.VirtualAddress) <= addr && addr <= uint64(sect.VirtualAddress+sect.Size-1) { - n := uint64(sect.VirtualAddress+sect.Size) - addr - if n > size { - n = size - } - data := make([]byte, n) - _, err := sect.ReadAt(data, int64(addr-uint64(sect.VirtualAddress))) - if err != nil { - return nil, err - } - return data, nil - } - } - return nil, fmt.Errorf("address not mapped") -} - -func (x *peExe) DataStart() uint64 { - // Assume data is first writable section. - const ( - IMAGE_SCN_CNT_CODE = 0x00000020 - IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040 - IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080 - IMAGE_SCN_MEM_EXECUTE = 0x20000000 - IMAGE_SCN_MEM_READ = 0x40000000 - IMAGE_SCN_MEM_WRITE = 0x80000000 - IMAGE_SCN_MEM_DISCARDABLE = 0x2000000 - IMAGE_SCN_LNK_NRELOC_OVFL = 0x1000000 - IMAGE_SCN_ALIGN_32BYTES = 0x600000 - ) - for _, sect := range x.f.Sections { - if sect.VirtualAddress != 0 && sect.Size != 0 && - sect.Characteristics&^IMAGE_SCN_ALIGN_32BYTES == IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_MEM_READ|IMAGE_SCN_MEM_WRITE { - return uint64(sect.VirtualAddress) + x.imageBase() - } - } - return 0 -} - -// machoExe is the Mach-O (Apple macOS/iOS) implementation of the exe interface. -type machoExe struct { - os *os.File - f *macho.File -} - -func (x *machoExe) Close() error { - return x.os.Close() -} - -func (x *machoExe) ReadData(addr, size uint64) ([]byte, error) { - for _, load := range x.f.Loads { - seg, ok := load.(*macho.Segment) - if !ok { - continue - } - if seg.Addr <= addr && addr <= seg.Addr+seg.Filesz-1 { - if seg.Name == "__PAGEZERO" { - continue - } - n := seg.Addr + seg.Filesz - addr - if n > size { - n = size - } - data := make([]byte, n) - _, err := seg.ReadAt(data, int64(addr-seg.Addr)) - if err != nil { - return nil, err - } - return data, nil - } - } - return nil, fmt.Errorf("address not mapped") -} - -func (x *machoExe) DataStart() uint64 { - // Look for section named "__go_buildinfo". - for _, sec := range x.f.Sections { - if sec.Name == "__go_buildinfo" { - return sec.Addr - } - } - // Try the first non-empty writable segment. - const RW = 3 - for _, load := range x.f.Loads { - seg, ok := load.(*macho.Segment) - if ok && seg.Addr != 0 && seg.Filesz != 0 && seg.Prot == RW && seg.Maxprot == RW { - return seg.Addr - } - } - return 0 -} - -// xcoffExe is the XCOFF (AIX eXtended COFF) implementation of the exe interface. -type xcoffExe struct { - os *os.File - f *xcoff.File -} - -func (x *xcoffExe) Close() error { - return x.os.Close() -} - -func (x *xcoffExe) ReadData(addr, size uint64) ([]byte, error) { - for _, sect := range x.f.Sections { - if uint64(sect.VirtualAddress) <= addr && addr <= uint64(sect.VirtualAddress+sect.Size-1) { - n := uint64(sect.VirtualAddress+sect.Size) - addr - if n > size { - n = size - } - data := make([]byte, n) - _, err := sect.ReadAt(data, int64(addr-uint64(sect.VirtualAddress))) - if err != nil { - return nil, err - } - return data, nil - } - } - return nil, fmt.Errorf("address not mapped") -} - -func (x *xcoffExe) DataStart() uint64 { - return x.f.SectionByType(xcoff.STYP_DATA).VirtualAddress -} diff --git a/src/cmd/go/internal/version/version.go b/src/cmd/go/internal/version/version.go index e885933ac3..febc7c638a 100644 --- a/src/cmd/go/internal/version/version.go +++ b/src/cmd/go/internal/version/version.go @@ -8,7 +8,8 @@ package version import ( "bytes" "context" - "encoding/binary" + "debug/buildinfo" + "errors" "fmt" "io/fs" "os" @@ -141,90 +142,25 @@ func scanFile(file string, info fs.FileInfo, mustPrint bool) { return } - x, err := openExe(file) + bi, err := buildinfo.ReadFile(file) if err != nil { if mustPrint { - fmt.Fprintf(os.Stderr, "%s: %v\n", file, err) + if pathErr := (*os.PathError)(nil); errors.As(err, &pathErr) && filepath.Clean(pathErr.Path) == filepath.Clean(file) { + fmt.Fprintf(os.Stderr, "%v\n", file) + } else { + fmt.Fprintf(os.Stderr, "%s: %v\n", file, err) + } } - return - } - defer x.Close() - - vers, mod := findVers(x) - if vers == "" { - if mustPrint { - fmt.Fprintf(os.Stderr, "%s: go version not found\n", file) - } - return } - fmt.Printf("%s: %s\n", file, vers) - if *versionM && mod != "" { - fmt.Printf("\t%s\n", strings.ReplaceAll(mod[:len(mod)-1], "\n", "\n\t")) - } -} - -// The build info blob left by the linker is identified by -// a 16-byte header, consisting of buildInfoMagic (14 bytes), -// the binary's pointer size (1 byte), -// and whether the binary is big endian (1 byte). -var buildInfoMagic = []byte("\xff Go buildinf:") - -// findVers finds and returns the Go version and module version information -// in the executable x. -func findVers(x exe) (vers, mod string) { - // Read the first 64kB of text to find the build info blob. - text := x.DataStart() - data, err := x.ReadData(text, 64*1024) + fmt.Printf("%s: %s\n", file, bi.GoVersion) + bi.GoVersion = "" // suppress printing go version again + mod, err := bi.MarshalText() if err != nil { + fmt.Fprintf(os.Stderr, "%s: formatting build info: %v\n", file, err) return } - for ; !bytes.HasPrefix(data, buildInfoMagic); data = data[32:] { - if len(data) < 32 { - return - } + if *versionM && len(mod) > 0 { + fmt.Printf("\t%s\n", bytes.ReplaceAll(mod[:len(mod)-1], []byte("\n"), []byte("\n\t"))) } - - // Decode the blob. - ptrSize := int(data[14]) - bigEndian := data[15] != 0 - var bo binary.ByteOrder - if bigEndian { - bo = binary.BigEndian - } else { - bo = binary.LittleEndian - } - var readPtr func([]byte) uint64 - if ptrSize == 4 { - readPtr = func(b []byte) uint64 { return uint64(bo.Uint32(b)) } - } else { - readPtr = bo.Uint64 - } - vers = readString(x, ptrSize, readPtr, readPtr(data[16:])) - if vers == "" { - return - } - mod = readString(x, ptrSize, readPtr, readPtr(data[16+ptrSize:])) - if len(mod) >= 33 && mod[len(mod)-17] == '\n' { - // Strip module framing. - mod = mod[16 : len(mod)-16] - } else { - mod = "" - } - return -} - -// readString returns the string at address addr in the executable x. -func readString(x exe, ptrSize int, readPtr func([]byte) uint64, addr uint64) string { - hdr, err := x.ReadData(addr, uint64(2*ptrSize)) - if err != nil || len(hdr) < 2*ptrSize { - return "" - } - dataAddr := readPtr(hdr) - dataLen := readPtr(hdr[ptrSize:]) - data, err := x.ReadData(dataAddr, dataLen) - if err != nil || uint64(len(data)) < dataLen { - return "" - } - return string(data) } From a37bebc042672d20837ea348d45e39740568cb77 Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Fri, 1 Oct 2021 11:21:49 -0700 Subject: [PATCH 018/406] cmd/go: stamp VCS revision and uncommitted status into binaries When the go command builds a binary, it will now stamp the current revision from the local Git or Mercurial repository, and it will also stamp whether there are uncommitted edited or untracked files. Only Git and Mercurial are supported for now. If no repository is found containing the current working directory (where the go command was started), or if either the main package directory or the containing module's root directory is outside the repository, no VCS information will be stamped. If the VCS tool is missing or returns an error, that error is reported on the main package (hinting that -buildvcs may be disabled). This change introduces the -buildvcs flag, which is enabled by default. When disabled, VCS information won't be stamped when it would be otherwise. Stamped information may be read using 'go version -m file' or debug.ReadBuildInfo. For #37475 Change-Id: I4e7d3159e1c270d85869ad99f10502e546e7582d Reviewed-on: https://go-review.googlesource.com/c/go/+/353930 Trust: Jay Conrod Run-TryBot: Jay Conrod TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- api/next.txt | 4 + src/cmd/go/alldocs.go | 6 + src/cmd/go/internal/cfg/cfg.go | 1 + src/cmd/go/internal/get/get.go | 18 ++- src/cmd/go/internal/load/pkg.go | 67 +++++++++ src/cmd/go/internal/vcs/vcs.go | 115 +++++++++++---- src/cmd/go/internal/vcs/vcs_test.go | 16 +-- src/cmd/go/internal/work/build.go | 7 + src/cmd/go/script_test.go | 78 ++++++++++ .../testdata/script/version_buildvcs_git.txt | 135 ++++++++++++++++++ .../testdata/script/version_buildvcs_hg.txt | 81 +++++++++++ .../script/version_buildvcs_nested.txt | 50 +++++++ src/cmd/internal/str/path.go | 14 ++ src/runtime/debug/mod.go | 46 ++++-- 14 files changed, 585 insertions(+), 53 deletions(-) create mode 100644 src/cmd/go/testdata/script/version_buildvcs_git.txt create mode 100644 src/cmd/go/testdata/script/version_buildvcs_hg.txt create mode 100644 src/cmd/go/testdata/script/version_buildvcs_nested.txt diff --git a/api/next.txt b/api/next.txt index ced738e480..9e4bb83cb7 100644 --- a/api/next.txt +++ b/api/next.txt @@ -4,6 +4,10 @@ pkg debug/buildinfo, type BuildInfo = debug.BuildInfo pkg runtime/debug, method (*BuildInfo) MarshalText() ([]byte, error) pkg runtime/debug, method (*BuildInfo) UnmarshalText() ([]byte, error) pkg runtime/debug, type BuildInfo struct, GoVersion string +pkg runtime/debug, type BuildInfo struct, Settings []BuildSetting +pkg runtime/debug, type BuildSetting struct +pkg runtime/debug, type BuildSetting struct, Key string +pkg runtime/debug, type BuildSetting struct, Value string pkg syscall (darwin-amd64), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) pkg syscall (darwin-amd64), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) pkg syscall (darwin-amd64), func SendtoInet4(int, []uint8, int, SockaddrInet4) error diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index c3e4179025..b6ea5a3701 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -133,6 +133,12 @@ // arguments to pass on each go tool asm invocation. // -buildmode mode // build mode to use. See 'go help buildmode' for more. +// -buildvcs +// Whether to stamp binaries with version control information. By default, +// version control information is stamped into a binary if the main package +// and the main module containing it are in the repository containing the +// current directory (if there is a repository). Use -buildvcs=false to +// omit version control information. // -compiler name // name of compiler to use, as in runtime.Compiler (gccgo or gc). // -gccgoflags '[pattern=]arg list' diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go index c8747d6c11..e1bf11fce2 100644 --- a/src/cmd/go/internal/cfg/cfg.go +++ b/src/cmd/go/internal/cfg/cfg.go @@ -26,6 +26,7 @@ import ( var ( BuildA bool // -a flag BuildBuildmode string // -buildmode flag + BuildBuildvcs bool // -buildvcs flag BuildContext = defaultContext() BuildMod string // -mod flag BuildModExplicit bool // whether -mod was set explicitly diff --git a/src/cmd/go/internal/get/get.go b/src/cmd/go/internal/get/get.go index b79d3ba86f..c96459297a 100644 --- a/src/cmd/go/internal/get/get.go +++ b/src/cmd/go/internal/get/get.go @@ -417,10 +417,10 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int) // to make the first copy of or update a copy of the given package. func downloadPackage(p *load.Package) error { var ( - vcsCmd *vcs.Cmd - repo, rootPath string - err error - blindRepo bool // set if the repo has unusual configuration + vcsCmd *vcs.Cmd + repo, rootPath, repoDir string + err error + blindRepo bool // set if the repo has unusual configuration ) // p can be either a real package, or a pseudo-package whose “import path” is @@ -446,10 +446,18 @@ func downloadPackage(p *load.Package) error { if p.Internal.Build.SrcRoot != "" { // Directory exists. Look for checkout along path to src. - vcsCmd, rootPath, err = vcs.FromDir(p.Dir, p.Internal.Build.SrcRoot) + repoDir, vcsCmd, err = vcs.FromDir(p.Dir, p.Internal.Build.SrcRoot) if err != nil { return err } + if !str.HasFilePathPrefix(repoDir, p.Internal.Build.SrcRoot) { + panic(fmt.Sprintf("repository %q not in source root %q", repo, p.Internal.Build.SrcRoot)) + } + rootPath = str.TrimFilePathPrefix(repoDir, p.Internal.Build.SrcRoot) + if err := vcs.CheckGOVCS(vcsCmd, rootPath); err != nil { + return err + } + repo = "" // should be unused; make distinctive // Double-check where it came from. diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 0fc5afbc36..473fa7a9d6 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -38,6 +38,7 @@ import ( "cmd/go/internal/par" "cmd/go/internal/search" "cmd/go/internal/trace" + "cmd/go/internal/vcs" "cmd/internal/str" "cmd/internal/sys" @@ -2267,6 +2268,72 @@ func (p *Package) setBuildInfo() { Main: main, Deps: deps, } + + // Add VCS status if all conditions are true: + // + // - -buildvcs is enabled. + // - p is contained within a main module (there may be multiple main modules + // in a workspace, but local replacements don't count). + // - Both the current directory and p's module's root directory are contained + // in the same local repository. + // - We know the VCS commands needed to get the status. + setVCSError := func(err error) { + setPkgErrorf("error obtaining VCS status: %v\n\tUse -buildvcs=false to disable VCS stamping.", err) + } + + var repoDir string + var vcsCmd *vcs.Cmd + var err error + if cfg.BuildBuildvcs && p.Module != nil && p.Module.Version == "" { + repoDir, vcsCmd, err = vcs.FromDir(base.Cwd(), "") + if err != nil && !errors.Is(err, os.ErrNotExist) { + setVCSError(err) + return + } + if !str.HasFilePathPrefix(p.Module.Dir, repoDir) && + !str.HasFilePathPrefix(repoDir, p.Module.Dir) { + // The module containing the main package does not overlap with the + // repository containing the working directory. Don't include VCS info. + // If the repo contains the module or vice versa, but they are not + // the same directory, it's likely an error (see below). + repoDir, vcsCmd = "", nil + } + } + if repoDir != "" && vcsCmd.Status != nil { + // Check that the current directory, package, and module are in the same + // repository. vcs.FromDir allows nested Git repositories, but nesting + // is not allowed for other VCS tools. The current directory may be outside + // p.Module.Dir when a workspace is used. + pkgRepoDir, _, err := vcs.FromDir(p.Dir, "") + if err != nil { + setVCSError(err) + return + } + if pkgRepoDir != repoDir { + setVCSError(fmt.Errorf("main package is in repository %q but current directory is in repository %q", pkgRepoDir, repoDir)) + return + } + modRepoDir, _, err := vcs.FromDir(p.Module.Dir, "") + if err != nil { + setVCSError(err) + return + } + if modRepoDir != repoDir { + setVCSError(fmt.Errorf("main module is in repository %q but current directory is in repository %q", modRepoDir, repoDir)) + return + } + + st, err := vcsCmd.Status(vcsCmd, repoDir) + if err != nil { + setVCSError(err) + return + } + info.Settings = []debug.BuildSetting{ + {Key: vcsCmd.Cmd + "revision", Value: st.Revision}, + {Key: vcsCmd.Cmd + "uncommitted", Value: strconv.FormatBool(st.Uncommitted)}, + } + } + text, err := info.MarshalText() if err != nil { setPkgErrorf("error formatting build info: %v", err) diff --git a/src/cmd/go/internal/vcs/vcs.go b/src/cmd/go/internal/vcs/vcs.go index 97b2a631ae..ebb4850443 100644 --- a/src/cmd/go/internal/vcs/vcs.go +++ b/src/cmd/go/internal/vcs/vcs.go @@ -5,6 +5,7 @@ package vcs import ( + "bytes" "encoding/json" "errors" "fmt" @@ -29,7 +30,7 @@ import ( "golang.org/x/mod/module" ) -// A vcsCmd describes how to use a version control system +// A Cmd describes how to use a version control system // like Mercurial, Git, or Subversion. type Cmd struct { Name string @@ -48,6 +49,13 @@ type Cmd struct { RemoteRepo func(v *Cmd, rootDir string) (remoteRepo string, err error) ResolveRepo func(v *Cmd, rootDir, remoteRepo string) (realRepo string, err error) + Status func(v *Cmd, rootDir string) (Status, error) +} + +// Status is the current state of a local repository. +type Status struct { + Revision string + Uncommitted bool } var defaultSecureScheme = map[string]bool{ @@ -139,6 +147,7 @@ var vcsHg = &Cmd{ Scheme: []string{"https", "http", "ssh"}, PingCmd: "identify -- {scheme}://{repo}", RemoteRepo: hgRemoteRepo, + Status: hgStatus, } func hgRemoteRepo(vcsHg *Cmd, rootDir string) (remoteRepo string, err error) { @@ -149,6 +158,27 @@ func hgRemoteRepo(vcsHg *Cmd, rootDir string) (remoteRepo string, err error) { return strings.TrimSpace(string(out)), nil } +func hgStatus(vcsHg *Cmd, rootDir string) (Status, error) { + out, err := vcsHg.runOutputVerboseOnly(rootDir, "identify -i") + if err != nil { + return Status{}, err + } + rev := strings.TrimSpace(string(out)) + uncommitted := strings.HasSuffix(rev, "+") + if uncommitted { + // "+" means a tracked file is edited. + rev = rev[:len(rev)-len("+")] + } else { + // Also look for untracked files. + out, err = vcsHg.runOutputVerboseOnly(rootDir, "status -u") + if err != nil { + return Status{}, err + } + uncommitted = len(out) > 0 + } + return Status{Revision: rev, Uncommitted: uncommitted}, nil +} + // vcsGit describes how to use Git. var vcsGit = &Cmd{ Name: "Git", @@ -182,6 +212,7 @@ var vcsGit = &Cmd{ PingCmd: "ls-remote {scheme}://{repo}", RemoteRepo: gitRemoteRepo, + Status: gitStatus, } // scpSyntaxRe matches the SCP-like addresses used by Git to access @@ -232,6 +263,20 @@ func gitRemoteRepo(vcsGit *Cmd, rootDir string) (remoteRepo string, err error) { return "", errParse } +func gitStatus(cmd *Cmd, repoDir string) (Status, error) { + out, err := cmd.runOutputVerboseOnly(repoDir, "rev-parse HEAD") + if err != nil { + return Status{}, err + } + rev := string(bytes.TrimSpace(out)) + out, err = cmd.runOutputVerboseOnly(repoDir, "status --porcelain") + if err != nil { + return Status{}, err + } + uncommitted := len(out) != 0 + return Status{Revision: rev, Uncommitted: uncommitted}, nil +} + // vcsBzr describes how to use Bazaar. var vcsBzr = &Cmd{ Name: "Bazaar", @@ -395,6 +440,12 @@ func (v *Cmd) runOutput(dir string, cmd string, keyval ...string) ([]byte, error return v.run1(dir, cmd, keyval, true) } +// runOutputVerboseOnly is like runOutput but only generates error output to +// standard error in verbose mode. +func (v *Cmd) runOutputVerboseOnly(dir string, cmd string, keyval ...string) ([]byte, error) { + return v.run1(dir, cmd, keyval, false) +} + // run1 is the generalized implementation of run and runOutput. func (v *Cmd) run1(dir string, cmdline string, keyval []string, verbose bool) ([]byte, error) { m := make(map[string]string) @@ -550,58 +601,62 @@ type vcsPath struct { // FromDir inspects dir and its parents to determine the // version control system and code repository to use. -// On return, root is the import path -// corresponding to the root of the repository. -func FromDir(dir, srcRoot string) (vcs *Cmd, root string, err error) { +// If no repository is found, FromDir returns an error +// equivalent to os.ErrNotExist. +func FromDir(dir, srcRoot string) (repoDir string, vcsCmd *Cmd, err error) { // Clean and double-check that dir is in (a subdirectory of) srcRoot. dir = filepath.Clean(dir) - srcRoot = filepath.Clean(srcRoot) - if len(dir) <= len(srcRoot) || dir[len(srcRoot)] != filepath.Separator { - return nil, "", fmt.Errorf("directory %q is outside source root %q", dir, srcRoot) + if srcRoot != "" { + srcRoot = filepath.Clean(srcRoot) + if len(dir) <= len(srcRoot) || dir[len(srcRoot)] != filepath.Separator { + return "", nil, fmt.Errorf("directory %q is outside source root %q", dir, srcRoot) + } } - var vcsRet *Cmd - var rootRet string - origDir := dir for len(dir) > len(srcRoot) { for _, vcs := range vcsList { if _, err := os.Stat(filepath.Join(dir, "."+vcs.Cmd)); err == nil { - root := filepath.ToSlash(dir[len(srcRoot)+1:]) // Record first VCS we find, but keep looking, // to detect mistakes like one kind of VCS inside another. - if vcsRet == nil { - vcsRet = vcs - rootRet = root + if vcsCmd == nil { + vcsCmd = vcs + repoDir = dir continue } // Allow .git inside .git, which can arise due to submodules. - if vcsRet == vcs && vcs.Cmd == "git" { + if vcsCmd == vcs && vcs.Cmd == "git" { continue } // Otherwise, we have one VCS inside a different VCS. - return nil, "", fmt.Errorf("directory %q uses %s, but parent %q uses %s", - filepath.Join(srcRoot, rootRet), vcsRet.Cmd, filepath.Join(srcRoot, root), vcs.Cmd) + return "", nil, fmt.Errorf("directory %q uses %s, but parent %q uses %s", + repoDir, vcsCmd.Cmd, dir, vcs.Cmd) } } // Move to parent. ndir := filepath.Dir(dir) if len(ndir) >= len(dir) { - // Shouldn't happen, but just in case, stop. break } dir = ndir } - - if vcsRet != nil { - if err := checkGOVCS(vcsRet, rootRet); err != nil { - return nil, "", err - } - return vcsRet, rootRet, nil + if vcsCmd == nil { + return "", nil, &vcsNotFoundError{dir: origDir} } + return repoDir, vcsCmd, nil +} - return nil, "", fmt.Errorf("directory %q is not using a known version control system", origDir) +type vcsNotFoundError struct { + dir string +} + +func (e *vcsNotFoundError) Error() string { + return fmt.Sprintf("directory %q is not using a known version control system", e.dir) +} + +func (e *vcsNotFoundError) Is(err error) bool { + return err == os.ErrNotExist } // A govcsRule is a single GOVCS rule like private:hg|svn. @@ -707,7 +762,11 @@ var defaultGOVCS = govcsConfig{ {"public", []string{"git", "hg"}}, } -func checkGOVCS(vcs *Cmd, root string) error { +// CheckGOVCS checks whether the policy defined by the environment variable +// GOVCS allows the given vcs command to be used with the given repository +// root path. Note that root may not be a real package or module path; it's +// the same as the root path in the go-import meta tag. +func CheckGOVCS(vcs *Cmd, root string) error { if vcs == vcsMod { // Direct module (proxy protocol) fetches don't // involve an external version control system @@ -885,7 +944,7 @@ func repoRootFromVCSPaths(importPath string, security web.SecurityMode, vcsPaths if vcs == nil { return nil, fmt.Errorf("unknown version control system %q", match["vcs"]) } - if err := checkGOVCS(vcs, match["root"]); err != nil { + if err := CheckGOVCS(vcs, match["root"]); err != nil { return nil, err } var repoURL string @@ -1012,7 +1071,7 @@ func repoRootForImportDynamic(importPath string, mod ModuleMode, security web.Se } } - if err := checkGOVCS(vcs, mmi.Prefix); err != nil { + if err := CheckGOVCS(vcs, mmi.Prefix); err != nil { return nil, err } diff --git a/src/cmd/go/internal/vcs/vcs_test.go b/src/cmd/go/internal/vcs/vcs_test.go index c5c7a3283b..248c541014 100644 --- a/src/cmd/go/internal/vcs/vcs_test.go +++ b/src/cmd/go/internal/vcs/vcs_test.go @@ -8,7 +8,6 @@ import ( "errors" "internal/testenv" "os" - "path" "path/filepath" "strings" "testing" @@ -205,7 +204,8 @@ func TestRepoRootForImportPath(t *testing.T) { } } -// Test that vcsFromDir correctly inspects a given directory and returns the right VCS and root. +// Test that vcs.FromDir correctly inspects a given directory and returns the +// right VCS and repo directory. func TestFromDir(t *testing.T) { tempDir, err := os.MkdirTemp("", "vcstest") if err != nil { @@ -232,18 +232,14 @@ func TestFromDir(t *testing.T) { f.Close() } - want := RepoRoot{ - VCS: vcs, - Root: path.Join("example.com", vcs.Name), - } - var got RepoRoot - got.VCS, got.Root, err = FromDir(dir, tempDir) + wantRepoDir := filepath.Dir(dir) + gotRepoDir, gotVCS, err := FromDir(dir, tempDir) if err != nil { t.Errorf("FromDir(%q, %q): %v", dir, tempDir, err) continue } - if got.VCS.Name != want.VCS.Name || got.Root != want.Root { - t.Errorf("FromDir(%q, %q) = VCS(%s) Root(%s), want VCS(%s) Root(%s)", dir, tempDir, got.VCS, got.Root, want.VCS, want.Root) + if gotRepoDir != wantRepoDir || gotVCS.Name != vcs.Name { + t.Errorf("FromDir(%q, %q) = RepoDir(%s), VCS(%s); want RepoDir(%s), VCS(%s)", dir, tempDir, gotRepoDir, gotVCS.Name, wantRepoDir, vcs.Name) } } } diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index 55e4954eee..114abab16c 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -87,6 +87,12 @@ and test commands: arguments to pass on each go tool asm invocation. -buildmode mode build mode to use. See 'go help buildmode' for more. + -buildvcs + Whether to stamp binaries with version control information. By default, + version control information is stamped into a binary if the main package + and the main module containing it are in the repository containing the + current directory (if there is a repository). Use -buildvcs=false to + omit version control information. -compiler name name of compiler to use, as in runtime.Compiler (gccgo or gc). -gccgoflags '[pattern=]arg list' @@ -302,6 +308,7 @@ func AddBuildFlags(cmd *base.Command, mask BuildFlagMask) { cmd.Flag.Var((*base.StringsFlag)(&cfg.BuildToolexec), "toolexec", "") cmd.Flag.BoolVar(&cfg.BuildTrimpath, "trimpath", false, "") cmd.Flag.BoolVar(&cfg.BuildWork, "work", false, "") + cmd.Flag.BoolVar(&cfg.BuildBuildvcs, "buildvcs", true, "") // Undocumented, unstable debugging flags. cmd.Flag.StringVar(&cfg.DebugActiongraph, "debug-actiongraph", "", "") diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go index 17782420c7..ac9764db94 100644 --- a/src/cmd/go/script_test.go +++ b/src/cmd/go/script_test.go @@ -1130,6 +1130,17 @@ func (ts *testScript) startBackground(want simpleStatus, command string, args .. done: done, } + // Use the script's PATH to look up the command if it contains a separator + // instead of the test process's PATH (see lookPath). + // Don't use filepath.Clean, since that changes "./foo" to "foo". + command = filepath.FromSlash(command) + if !strings.Contains(command, string(filepath.Separator)) { + var err error + command, err = ts.lookPath(command) + if err != nil { + return nil, err + } + } cmd := exec.Command(command, args...) cmd.Dir = ts.cd cmd.Env = append(ts.env, "PWD="+ts.cd) @@ -1146,6 +1157,73 @@ func (ts *testScript) startBackground(want simpleStatus, command string, args .. return bg, nil } +// lookPath is (roughly) like exec.LookPath, but it uses the test script's PATH +// instead of the test process's PATH to find the executable. We don't change +// the test process's PATH since it may run scripts in parallel. +func (ts *testScript) lookPath(command string) (string, error) { + var strEqual func(string, string) bool + if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { + // Using GOOS as a proxy for case-insensitive file system. + strEqual = strings.EqualFold + } else { + strEqual = func(a, b string) bool { return a == b } + } + + var pathExt []string + var searchExt bool + var isExecutable func(os.FileInfo) bool + if runtime.GOOS == "windows" { + // Use the test process's PathExt instead of the script's. + // If PathExt is set in the command's environment, cmd.Start fails with + // "parameter is invalid". Not sure why. + // If the command already has an extension in PathExt (like "cmd.exe") + // don't search for other extensions (not "cmd.bat.exe"). + pathExt = strings.Split(os.Getenv("PathExt"), string(filepath.ListSeparator)) + searchExt = true + cmdExt := filepath.Ext(command) + for _, ext := range pathExt { + if strEqual(cmdExt, ext) { + searchExt = false + break + } + } + isExecutable = func(fi os.FileInfo) bool { + return fi.Mode().IsRegular() + } + } else { + isExecutable = func(fi os.FileInfo) bool { + return fi.Mode().IsRegular() && fi.Mode().Perm()&0111 != 0 + } + } + + pathName := "PATH" + if runtime.GOOS == "plan9" { + pathName = "path" + } + + for _, dir := range strings.Split(ts.envMap[pathName], string(filepath.ListSeparator)) { + if searchExt { + ents, err := os.ReadDir(dir) + if err != nil { + continue + } + for _, ent := range ents { + for _, ext := range pathExt { + if !ent.IsDir() && strEqual(ent.Name(), command+ext) { + return dir + string(filepath.Separator) + ent.Name(), nil + } + } + } + } else { + path := dir + string(filepath.Separator) + command + if fi, err := os.Stat(path); err == nil && isExecutable(fi) { + return path, nil + } + } + } + return "", &exec.Error{Name: command, Err: exec.ErrNotFound} +} + // waitOrStop waits for the already-started command cmd by calling its Wait method. // // If cmd does not return before ctx is done, waitOrStop sends it the given interrupt signal. diff --git a/src/cmd/go/testdata/script/version_buildvcs_git.txt b/src/cmd/go/testdata/script/version_buildvcs_git.txt new file mode 100644 index 0000000000..78ce2e835e --- /dev/null +++ b/src/cmd/go/testdata/script/version_buildvcs_git.txt @@ -0,0 +1,135 @@ +# This test checks that VCS information is stamped into Go binaries by default, +# controlled with -buildvcs. This test focuses on Git. Other tests focus on +# other VCS tools but may not cover common functionality. + +[!exec:git] skip +[short] skip +env GOBIN=$WORK/gopath/bin +env oldpath=$PATH +cd repo/a + +# If there's no local repository, there's no VCS info. +go install +go version -m $GOBIN/a$GOEXE +! stdout gitrevision +rm $GOBIN/a$GOEXE + +# If there is a repository, but it can't be used for some reason, +# there should be an error. It should hint about -buildvcs=false. +cd .. +mkdir .git +env PATH=$WORK${/}fakebin${:}$oldpath +chmod 0755 $WORK/fakebin/git +! exec git help +cd a +! go install +stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$' +cd .. +env PATH=$oldpath +rm .git + +# If there is a repository in a parent directory, there should be VCS info. +exec git init +exec git config user.email gopher@golang.org +exec git config user.name 'J.R. Gopher' +exec git add -A +exec git commit -m 'initial commit' +cd a +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\tgitrevision\t' +stdout '^\tbuild\tgituncommitted\tfalse$' +rm $GOBIN/a$GOEXE + +# Building with -buildvcs=false suppresses the info. +go install -buildvcs=false +go version -m $GOBIN/a$GOEXE +! stdout gitrevision +rm $GOBIN/a$GOEXE + +# An untracked file is shown as uncommitted, even if it isn't part of the build. +cp ../../outside/empty.txt . +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\tgituncommitted\ttrue$' +rm empty.txt +rm $GOBIN/a$GOEXE + +# An edited file is shown as uncommitted, even if it isn't part of the build. +cp ../../outside/empty.txt ../README +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\tgituncommitted\ttrue$' +exec git checkout ../README +rm $GOBIN/a$GOEXE + +# If the build doesn't include any packages from the repository, +# there should be no VCS info. +go install example.com/cmd/a@v1.0.0 +go version -m $GOBIN/a$GOEXE +! stdout gitrevision +rm $GOBIN/a$GOEXE + +go mod edit -require=example.com/c@v0.0.0 +go mod edit -replace=example.com/c@v0.0.0=../../outside/c +go install example.com/c +go version -m $GOBIN/c$GOEXE +! stdout gitrevision +rm $GOBIN/c$GOEXE +exec git checkout go.mod + +# If the build depends on a package in the repository, but it's not in the +# main module, there should be no VCS info. +go mod edit -require=example.com/b@v0.0.0 +go mod edit -replace=example.com/b@v0.0.0=../b +go mod edit -require=example.com/d@v0.0.0 +go mod edit -replace=example.com/d@v0.0.0=../../outside/d +go install example.com/d +go version -m $GOBIN/d$GOEXE +! stdout gitrevision +exec git checkout go.mod +rm $GOBIN/d$GOEXE + +-- $WORK/fakebin/git -- +#!/bin/sh +exit 1 +-- $WORK/fakebin/git.bat -- +exit 1 +-- repo/README -- +Far out in the uncharted backwaters of the unfashionable end of the western +spiral arm of the Galaxy lies a small, unregarded yellow sun. +-- repo/a/go.mod -- +module example.com/a + +go 1.18 +-- repo/a/a.go -- +package main + +func main() {} +-- repo/b/go.mod -- +module example.com/b + +go 1.18 +-- repo/b/b.go -- +package b +-- outside/empty.txt -- +-- outside/c/go.mod -- +module example.com/c + +go 1.18 +-- outside/c/main.go -- +package main + +func main() {} +-- outside/d/go.mod -- +module example.com/d + +go 1.18 + +require example.com/b v0.0.0 +-- outside/d/main.go -- +package main + +import _ "example.com/b" + +func main() {} diff --git a/src/cmd/go/testdata/script/version_buildvcs_hg.txt b/src/cmd/go/testdata/script/version_buildvcs_hg.txt new file mode 100644 index 0000000000..9dcb8dd950 --- /dev/null +++ b/src/cmd/go/testdata/script/version_buildvcs_hg.txt @@ -0,0 +1,81 @@ +# This test checks that VCS information is stamped into Go binaries by default, +# controlled with -buildvcs. This test focuses on Mercurial specifics. +# The Git test covers common functionality. + +[!exec:hg] skip +[short] skip +env GOBIN=$WORK/gopath/bin +env oldpath=$PATH +cd repo/a + +# If there's no local repository, there's no VCS info. +go install +go version -m $GOBIN/a$GOEXE +! stdout hgrevision +rm $GOBIN/a$GOEXE + +# If there is a repository, but it can't be used for some reason, +# there should be an error. It should hint about -buildvcs=false. +cd .. +mkdir .hg +env PATH=$WORK${/}fakebin${:}$oldpath +chmod 0755 $WORK/fakebin/hg +! exec hg help +cd a +! go install +stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$' +rm $GOBIN/a$GOEXE +cd .. +env PATH=$oldpath +rm .hg + +# If there is a repository in a parent directory, there should be VCS info. +exec hg init +exec hg add a README +exec hg commit -m 'initial commit' +cd a +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\thgrevision\t' +stdout '^\tbuild\thguncommitted\tfalse$' +rm $GOBIN/a$GOEXE + +# Building with -buildvcs=false suppresses the info. +go install -buildvcs=false +go version -m $GOBIN/a$GOEXE +! stdout hgrevision +rm $GOBIN/a$GOEXE + +# An untracked file is shown as uncommitted, even if it isn't part of the build. +cp ../../outside/empty.txt . +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\thguncommitted\ttrue$' +rm empty.txt +rm $GOBIN/a$GOEXE + +# An edited file is shown as uncommitted, even if it isn't part of the build. +cp ../../outside/empty.txt ../README +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\thguncommitted\ttrue$' +exec hg revert ../README +rm $GOBIN/a$GOEXE + +-- $WORK/fakebin/hg -- +#!/bin/sh +exit 1 +-- $WORK/fakebin/hg.bat -- +exit 1 +-- repo/README -- +Far out in the uncharted backwaters of the unfashionable end of the western +spiral arm of the Galaxy lies a small, unregarded yellow sun. +-- repo/a/go.mod -- +module example.com/a + +go 1.18 +-- repo/a/a.go -- +package main + +func main() {} +-- outside/empty.txt -- diff --git a/src/cmd/go/testdata/script/version_buildvcs_nested.txt b/src/cmd/go/testdata/script/version_buildvcs_nested.txt new file mode 100644 index 0000000000..f904c41bf8 --- /dev/null +++ b/src/cmd/go/testdata/script/version_buildvcs_nested.txt @@ -0,0 +1,50 @@ +[!exec:git] skip +[!exec:hg] skip +env GOFLAGS=-n + +# Create a root module in a root Git repository. +mkdir root +cd root +go mod init example.com/root +exec git init + +# It's an error to build a package from a nested Mercurial repository +# without -buildvcs=false, even if the package is in a separate module. +mkdir hgsub +cd hgsub +exec hg init +cp ../../main.go main.go +! go build +stderr '^error obtaining VCS status: directory ".*hgsub" uses hg, but parent ".*root" uses git$' +stderr '\tUse -buildvcs=false to disable VCS stamping.$' +go mod init example.com/root/hgsub +! go build +stderr '^error obtaining VCS status: directory ".*hgsub" uses hg, but parent ".*root" uses git$' +go build -buildvcs=false +cd .. + +# It's an error to build a package from a nested Git repository if the package +# is in a separate repository from the current directory or from the module +# root directory. However, unlike with other VCS, it's okay for a Git repository +# to be nested within another Git repository. This happens with submodules. +mkdir gitsub +cd gitsub +exec git init +exec git config user.name 'J.R.Gopher' +exec git config user.email 'gopher@golang.org' +cp ../../main.go main.go +! go build +stderr '^error obtaining VCS status: main module is in repository ".*root" but current directory is in repository ".*gitsub"$' +go build -buildvcs=false +go mod init example.com/root/gitsub +exec git commit --allow-empty -m empty # status commands fail without this +go build +rm go.mod +cd .. +! go build ./gitsub +stderr '^error obtaining VCS status: main package is in repository ".*gitsub" but current directory is in repository ".*root"$' +go build -buildvcs=false -o=gitsub${/} ./gitsub + +-- main.go -- +package main +func main() {} diff --git a/src/cmd/internal/str/path.go b/src/cmd/internal/str/path.go index 51ab2af82b..0c8aaeaca1 100644 --- a/src/cmd/internal/str/path.go +++ b/src/cmd/internal/str/path.go @@ -49,3 +49,17 @@ func HasFilePathPrefix(s, prefix string) bool { return s[len(prefix)] == filepath.Separator && s[:len(prefix)] == prefix } } + +// TrimFilePathPrefix returns s without the leading path elements in prefix. +// If s does not start with prefix (HasFilePathPrefix with the same arguments +// returns false), TrimFilePathPrefix returns s. If s equals prefix, +// TrimFilePathPrefix returns "". +func TrimFilePathPrefix(s, prefix string) string { + if !HasFilePathPrefix(s, prefix) { + return s + } + if len(s) == len(prefix) { + return "" + } + return s[len(prefix)+1:] +} diff --git a/src/runtime/debug/mod.go b/src/runtime/debug/mod.go index 0c6488753b..14b99f5735 100644 --- a/src/runtime/debug/mod.go +++ b/src/runtime/debug/mod.go @@ -8,6 +8,7 @@ import ( "bytes" "fmt" "runtime" + "strings" ) // exported from runtime @@ -38,10 +39,11 @@ func ReadBuildInfo() (info *BuildInfo, ok bool) { // BuildInfo represents the build information read from a Go binary. type BuildInfo struct { - GoVersion string // Version of Go that produced this binary. - Path string // The main package path - Main Module // The module containing the main package - Deps []*Module // Module dependencies + GoVersion string // Version of Go that produced this binary. + Path string // The main package path + Main Module // The module containing the main package + Deps []*Module // Module dependencies + Settings []BuildSetting // Other information about the build. } // Module represents a module. @@ -52,6 +54,14 @@ type Module struct { Replace *Module // replaced by this module } +// BuildSetting describes a setting that may be used to understand how the +// binary was built. For example, VCS commit and dirty status is stored here. +type BuildSetting struct { + // Key and Value describe the build setting. They must not contain tabs + // or newlines. + Key, Value string +} + func (bi *BuildInfo) MarshalText() ([]byte, error) { buf := &bytes.Buffer{} if bi.GoVersion != "" { @@ -86,6 +96,12 @@ func (bi *BuildInfo) MarshalText() ([]byte, error) { for _, dep := range bi.Deps { formatMod("dep", *dep) } + for _, s := range bi.Settings { + if strings.ContainsAny(s.Key, "\n\t") || strings.ContainsAny(s.Value, "\n\t") { + return nil, fmt.Errorf("build setting %q contains tab or newline", s.Key) + } + fmt.Fprintf(buf, "build\t%s\t%s\n", s.Key, s.Value) + } return buf.Bytes(), nil } @@ -100,12 +116,13 @@ func (bi *BuildInfo) UnmarshalText(data []byte) (err error) { }() var ( - pathLine = []byte("path\t") - modLine = []byte("mod\t") - depLine = []byte("dep\t") - repLine = []byte("=>\t") - newline = []byte("\n") - tab = []byte("\t") + pathLine = []byte("path\t") + modLine = []byte("mod\t") + depLine = []byte("dep\t") + repLine = []byte("=>\t") + buildLine = []byte("build\t") + newline = []byte("\n") + tab = []byte("\t") ) readModuleLine := func(elem [][]byte) (Module, error) { @@ -167,6 +184,15 @@ func (bi *BuildInfo) UnmarshalText(data []byte) (err error) { Sum: string(elem[2]), } last = nil + case bytes.HasPrefix(line, buildLine): + elem := bytes.Split(line[len(buildLine):], tab) + if len(elem) != 2 { + return fmt.Errorf("expected 2 columns for build setting; got %d", len(elem)) + } + if len(elem[0]) == 0 { + return fmt.Errorf("empty key") + } + bi.Settings = append(bi.Settings, BuildSetting{Key: string(elem[0]), Value: string(elem[1])}) } lineNum++ } From 0fd0639e4c429e147d33bfc42654fcd651f4449f Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Tue, 12 Oct 2021 15:08:54 -0700 Subject: [PATCH 019/406] cmd/go: stamp tags and flags in build info Toolchain flags (like -gcflags), build tags (including race and msan), and cgo variables (including CGO_ENABLED, CGO_CPPFLAGS and others) are now stamped into binaries. For #37475 Change-Id: I9023e682c0618f91805434946c6bc937536b69bb Reviewed-on: https://go-review.googlesource.com/c/go/+/355493 Trust: Jay Conrod Run-TryBot: Jay Conrod TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/cmd/go/alldocs.go | 7 +- src/cmd/go/go_test.go | 2 +- src/cmd/go/internal/cfg/cfg.go | 1 + src/cmd/go/internal/load/flag.go | 6 +- src/cmd/go/internal/load/pkg.go | 33 +++++++++- src/cmd/go/internal/work/build.go | 8 ++- .../script/version_build_settings.txt | 66 +++++++++++++++++++ 7 files changed, 115 insertions(+), 8 deletions(-) create mode 100644 src/cmd/go/testdata/script/version_build_settings.txt diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index b6ea5a3701..d04ba04a53 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -131,6 +131,11 @@ // // -asmflags '[pattern=]arg list' // arguments to pass on each go tool asm invocation. +// -buildinfo +// Whether to stamp binaries with build flags. By default, the compiler name +// (gc or gccgo), toolchain flags (like -gcflags), and environment variables +// containing flags (like CGO_CFLAGS) are stamped into binaries. Use +// -buildinfo=false to omit build information. See also -buildvcs. // -buildmode mode // build mode to use. See 'go help buildmode' for more. // -buildvcs @@ -138,7 +143,7 @@ // version control information is stamped into a binary if the main package // and the main module containing it are in the repository containing the // current directory (if there is a repository). Use -buildvcs=false to -// omit version control information. +// omit version control information. See also -buildinfo. // -compiler name // name of compiler to use, as in runtime.Compiler (gccgo or gc). // -gccgoflags '[pattern=]arg list' diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 07e9962896..d67d01aa1e 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -1380,7 +1380,7 @@ func TestLdFlagsLongArgumentsIssue42295(t *testing.T) { for buf.Len() < sys.ExecArgLengthLimit+1 { buf.WriteString(testStr) } - tg.run("run", "-ldflags", fmt.Sprintf(`-X "main.extern=%s"`, buf.String()), tg.path("main.go")) + tg.run("run", "-buildinfo=false", "-ldflags", fmt.Sprintf(`-X "main.extern=%s"`, buf.String()), tg.path("main.go")) if tg.stderr.String() != buf.String() { t.Errorf("strings differ") } diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go index e1bf11fce2..37e9b2666e 100644 --- a/src/cmd/go/internal/cfg/cfg.go +++ b/src/cmd/go/internal/cfg/cfg.go @@ -25,6 +25,7 @@ import ( // These are general "build flags" used by build and other commands. var ( BuildA bool // -a flag + BuildBuildinfo bool // -buildinfo flag BuildBuildmode string // -buildmode flag BuildBuildvcs bool // -buildvcs flag BuildContext = defaultContext() diff --git a/src/cmd/go/internal/load/flag.go b/src/cmd/go/internal/load/flag.go index 4e0cb5bc19..d0d5716c3f 100644 --- a/src/cmd/go/internal/load/flag.go +++ b/src/cmd/go/internal/load/flag.go @@ -22,6 +22,7 @@ var ( // that allows specifying different effective flags for different packages. // See 'go help build' for more details about per-package flags. type PerPackageFlag struct { + raw string present bool values []ppfValue } @@ -39,6 +40,7 @@ func (f *PerPackageFlag) Set(v string) error { // set is the implementation of Set, taking a cwd (current working directory) for easier testing. func (f *PerPackageFlag) set(v, cwd string) error { + f.raw = v f.present = true match := func(p *Package) bool { return p.Internal.CmdlinePkg || p.Internal.CmdlineFiles } // default predicate with no pattern // For backwards compatibility with earlier flag splitting, ignore spaces around flags. @@ -72,9 +74,7 @@ func (f *PerPackageFlag) set(v, cwd string) error { return nil } -// String is required to implement flag.Value. -// It is not used, because cmd/go never calls flag.PrintDefaults. -func (f *PerPackageFlag) String() string { return "" } +func (f *PerPackageFlag) String() string { return f.raw } // Present reports whether the flag appeared on the command line. func (f *PerPackageFlag) Present() bool { diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 473fa7a9d6..716994b3ad 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -2268,6 +2268,35 @@ func (p *Package) setBuildInfo() { Main: main, Deps: deps, } + appendSetting := func(key, value string) { + info.Settings = append(info.Settings, debug.BuildSetting{Key: key, Value: value}) + } + + // Add command-line flags relevant to the build. + // This is informational, not an exhaustive list. + if cfg.BuildBuildinfo { + appendSetting("compiler", cfg.BuildContext.Compiler) + if BuildAsmflags.present { + appendSetting("asmflags", BuildAsmflags.String()) + } + if BuildGcflags.present && cfg.BuildContext.Compiler == "gc" { + appendSetting("gcflags", BuildGcflags.String()) + } + if BuildGccgoflags.present && cfg.BuildContext.Compiler == "gccgo" { + appendSetting("gccgoflags", BuildGccgoflags.String()) + } + if BuildLdflags.present { + appendSetting("ldflags", BuildLdflags.String()) + } + tags := append(cfg.BuildContext.BuildTags, cfg.BuildContext.ToolTags...) + appendSetting("tags", strings.Join(tags, ",")) + appendSetting("CGO_ENABLED", strconv.FormatBool(cfg.BuildContext.CgoEnabled)) + if cfg.BuildContext.CgoEnabled { + for _, name := range []string{"CGO_CPPFLAGS", "CGO_CFLAGS", "CGO_CXXFLAGS", "CGO_LDFLAGS"} { + appendSetting(name, cfg.Getenv(name)) + } + } + } // Add VCS status if all conditions are true: // @@ -2328,10 +2357,10 @@ func (p *Package) setBuildInfo() { setVCSError(err) return } - info.Settings = []debug.BuildSetting{ + info.Settings = append(info.Settings, []debug.BuildSetting{ {Key: vcsCmd.Cmd + "revision", Value: st.Revision}, {Key: vcsCmd.Cmd + "uncommitted", Value: strconv.FormatBool(st.Uncommitted)}, - } + }...) } text, err := info.MarshalText() diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index 114abab16c..e10f647a6d 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -85,6 +85,11 @@ and test commands: -asmflags '[pattern=]arg list' arguments to pass on each go tool asm invocation. + -buildinfo + Whether to stamp binaries with build flags. By default, the compiler name + (gc or gccgo), toolchain flags (like -gcflags), and environment variables + containing flags (like CGO_CFLAGS) are stamped into binaries. Use + -buildinfo=false to omit build information. See also -buildvcs. -buildmode mode build mode to use. See 'go help buildmode' for more. -buildvcs @@ -92,7 +97,7 @@ and test commands: version control information is stamped into a binary if the main package and the main module containing it are in the repository containing the current directory (if there is a repository). Use -buildvcs=false to - omit version control information. + omit version control information. See also -buildinfo. -compiler name name of compiler to use, as in runtime.Compiler (gccgo or gc). -gccgoflags '[pattern=]arg list' @@ -308,6 +313,7 @@ func AddBuildFlags(cmd *base.Command, mask BuildFlagMask) { cmd.Flag.Var((*base.StringsFlag)(&cfg.BuildToolexec), "toolexec", "") cmd.Flag.BoolVar(&cfg.BuildTrimpath, "trimpath", false, "") cmd.Flag.BoolVar(&cfg.BuildWork, "work", false, "") + cmd.Flag.BoolVar(&cfg.BuildBuildinfo, "buildinfo", true, "") cmd.Flag.BoolVar(&cfg.BuildBuildvcs, "buildvcs", true, "") // Undocumented, unstable debugging flags. diff --git a/src/cmd/go/testdata/script/version_build_settings.txt b/src/cmd/go/testdata/script/version_build_settings.txt new file mode 100644 index 0000000000..7e93643b9f --- /dev/null +++ b/src/cmd/go/testdata/script/version_build_settings.txt @@ -0,0 +1,66 @@ +[short] skip + +# Compiler name is always added. +go build +go version -m m$GOEXE +stdout '^\tbuild\tcompiler\tgc$' +! stdout asmflags|gcflags|ldflags|gccgoflags + +# Toolchain flags are added if present. +# The raw flags are included, with package patterns if specified. +go build -asmflags=all=-spectre=all +go version -m m$GOEXE +stdout '^\tbuild\tasmflags\tall=-spectre=all$' + +go build -gcflags=all=-spectre=all +go version -m m$GOEXE +stdout '^\tbuild\tgcflags\tall=-spectre=all$' + +go build -ldflags=-w +go version -m m$GOEXE +stdout '^\tbuild\tldflags\t-w$' + +# gccgoflags are not added when gc is used, and vice versa. +# TODO: test gccgo. +go build -gccgoflags=all=UNUSED +go version -m m$GOEXE +! stdout gccgoflags + +# Build and tool tags are added but not release tags. +# "race" is included with build tags but not "cgo". +go build -tags=a,b +go version -m m$GOEXE +stdout '^\tbuild\ttags\ta,b(,goexperiment\.[a-z0-9]+)*$' +[race] go build -race +[race] go version -m m$GOEXE +[race] stdout '^\tbuild\ttags\t.*race.*$' + +# CGO flags are separate settings. +# CGO_ENABLED is always present. +# Other flags are added if CGO_ENABLED is true. +env CGO_ENABLED=0 +go build +go version -m m$GOEXE +stdout '^\tbuild\tCGO_ENABLED\tfalse$' +! stdout CGO_CPPFLAGS|CGO_CFLAGS|CGO_CXXFLAGS|CGO_LDFLAGS +[cgo] env CGO_ENABLED=1 +[cgo] env CGO_CPPFLAGS=-DFROM_CPPFLAGS=1 +[cgo] env CGO_CFLAGS=-DFROM_CFLAGS=1 +[cgo] env CGO_CXXFLAGS=-DFROM_CXXFLAGS=1 +[cgo] env CGO_LDFLAGS=-L/extra/dir/does/not/exist +[cgo] go build +[cgo] go version -m m$GOEXE +[cgo] stdout '^\tbuild\tCGO_ENABLED\ttrue$' +[cgo] stdout '^\tbuild\tCGO_CPPFLAGS\t-DFROM_CPPFLAGS=1$' +[cgo] stdout '^\tbuild\tCGO_CFLAGS\t-DFROM_CFLAGS=1$' +[cgo] stdout '^\tbuild\tCGO_CXXFLAGS\t-DFROM_CXXFLAGS=1$' +[cgo] stdout '^\tbuild\tCGO_LDFLAGS\t-L/extra/dir/does/not/exist$' + +-- go.mod -- +module example.com/m + +go 1.18 +-- m.go -- +package main + +func main() {} From 4cbc0a555474f59b8600e7e8ecba5c70d619ba0b Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Thu, 14 Oct 2021 11:34:00 -0400 Subject: [PATCH 020/406] cmd/go: produce a better error for generic test functions Test functions with type parameters cannot be invoked without type arguments, so cmd/go would previously fail with a type-checking error in the test harness. Avoid this by producing an error explaining that test functions cannot have type parameters. Fixes #48953 Change-Id: I4e39c9b7a06c964fad5f12d74d262aa090c25d79 Reviewed-on: https://go-review.googlesource.com/c/go/+/355889 Trust: Robert Findley Run-TryBot: Bryan C. Mills Reviewed-by: Bryan C. Mills TryBot-Result: Go Bot --- src/cmd/go/internal/load/test.go | 10 ++++++++-- src/cmd/go/testdata/script/list_test_err.txt | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/cmd/go/internal/load/test.go b/src/cmd/go/internal/load/test.go index da6d1cb21d..4cefb62d51 100644 --- a/src/cmd/go/internal/load/test.go +++ b/src/cmd/go/internal/load/test.go @@ -678,10 +678,16 @@ func (t *testFuncs) load(filename, pkg string, doImport, seen *bool) error { } func checkTestFunc(fn *ast.FuncDecl, arg string) error { + var why string if !isTestFunc(fn, arg) { - name := fn.Name.String() + why = fmt.Sprintf("must be: func %s(%s *testing.%s)", fn.Name.String(), strings.ToLower(arg), arg) + } + if fn.Type.TypeParams.NumFields() > 0 { + why = "test functions cannot have type parameters" + } + if why != "" { pos := testFileSet.Position(fn.Pos()) - return fmt.Errorf("%s: wrong signature for %s, must be: func %s(%s *testing.%s)", pos, name, name, strings.ToLower(arg), arg) + return fmt.Errorf("%s: wrong signature for %s, %s", pos, fn.Name.String(), why) } return nil } diff --git a/src/cmd/go/testdata/script/list_test_err.txt b/src/cmd/go/testdata/script/list_test_err.txt index c6f1ecf400..25dbb969b0 100644 --- a/src/cmd/go/testdata/script/list_test_err.txt +++ b/src/cmd/go/testdata/script/list_test_err.txt @@ -44,6 +44,10 @@ stdout 'testdep_b ' stdout 'nameerr\.test "[^"]*wrong signature for TestBad' ! stderr 'wrong signature for TestBad' +# go list prints a useful error for generic test functions +! go list -test -deps genericerr +stderr 'wrong signature for TestGeneric, test functions cannot have type parameters' + # go list prints partial information with error if test has cyclic import ! go list -test -deps cycleerr stdout cycleerr @@ -106,6 +110,16 @@ import ( func TestBad(t *testing.B) {} +-- genericerr/genericerr.go -- +package genericerr + +-- genericerr/genericerr_test.go -- +package genericerr + +import "testing" + +func TestGeneric[T any](t *testing.T) {} + -- cycleerr/cycleerr_test.go -- package cycleerr From 440b63bd6f29ad1efd747db9d137a844a3621bdc Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 14 Oct 2021 12:02:23 -0700 Subject: [PATCH 021/406] cmd/compile/internal/types2: remove Config.AllowTypeLists (cleanup) This flag is not used anymore. Change-Id: Id083ffa4f0a3051d3f1905a211db8acaaf525cf4 Reviewed-on: https://go-review.googlesource.com/c/go/+/355931 Trust: Robert Griesemer Reviewed-by: Robert Findley Reviewed-by: Dan Scales --- src/cmd/compile/internal/noder/irgen.go | 1 - src/cmd/compile/internal/types2/api.go | 6 ------ 2 files changed, 7 deletions(-) diff --git a/src/cmd/compile/internal/noder/irgen.go b/src/cmd/compile/internal/noder/irgen.go index e912f797b2..a3501fb90b 100644 --- a/src/cmd/compile/internal/noder/irgen.go +++ b/src/cmd/compile/internal/noder/irgen.go @@ -44,7 +44,6 @@ func checkFiles(noders []*noder) (posMap, *types2.Package, *types2.Info) { GoVersion: base.Flag.Lang, IgnoreLabels: true, // parser already checked via syntax.CheckBranches mode CompilerErrorMessages: true, // use error strings matching existing compiler errors - AllowTypeLists: true, // remove this line once all tests use type set syntax Error: func(err error) { terr := err.(types2.Error) base.ErrorfAt(m.makeXPos(terr.Pos), "%s", terr.Msg) diff --git a/src/cmd/compile/internal/types2/api.go b/src/cmd/compile/internal/types2/api.go index faf570c32e..e6d28af3c8 100644 --- a/src/cmd/compile/internal/types2/api.go +++ b/src/cmd/compile/internal/types2/api.go @@ -141,12 +141,6 @@ type Config struct { // TODO(gri) Consolidate error messages and remove this flag. CompilerErrorMessages bool - // If AllowTypeLists is set, the type list syntax is permitted - // in an interface in addition to the type set syntax. - // TODO(gri) Remove once type lists are no longer supported by - // the parser. - AllowTypeLists bool - // If go115UsesCgo is set, the type checker expects the // _cgo_gotypes.go file generated by running cmd/cgo to be // provided as a package source file. Qualified identifiers From 0400d536e4f349c8f30777c975af78b6a19e73b4 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 14 Oct 2021 12:41:29 -0700 Subject: [PATCH 022/406] go/types, types2: add a test case to ConvertibleTo string(int) conversions are somewhat special and deserve an entry. Change-Id: Ia68d047cfdb2f98e837bf663659f7f46404b16ac Reviewed-on: https://go-review.googlesource.com/c/go/+/355989 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/api_test.go | 4 ++-- src/go/types/api_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cmd/compile/internal/types2/api_test.go b/src/cmd/compile/internal/types2/api_test.go index 4966848ed4..ecb5a29830 100644 --- a/src/cmd/compile/internal/types2/api_test.go +++ b/src/cmd/compile/internal/types2/api_test.go @@ -1655,6 +1655,7 @@ func TestConvertibleTo(t *testing.T) { }{ {Typ[Int], Typ[Int], true}, {Typ[Int], Typ[Float32], true}, + {Typ[Int], Typ[String], true}, {newDefined(Typ[Int]), Typ[Int], true}, {newDefined(new(Struct)), new(Struct), true}, {newDefined(Typ[Int]), new(Struct), false}, @@ -1662,8 +1663,7 @@ func TestConvertibleTo(t *testing.T) { {NewSlice(Typ[Int]), NewPointer(NewArray(Typ[Int], 10)), true}, {NewSlice(Typ[Int]), NewArray(Typ[Int], 10), false}, {NewSlice(Typ[Int]), NewPointer(NewArray(Typ[Uint], 10)), false}, - // Untyped string values are not permitted by the spec, so the below - // behavior is undefined. + // Untyped string values are not permitted by the spec, so the behavior below is undefined. {Typ[UntypedString], Typ[String], true}, } { if got := ConvertibleTo(test.v, test.t); got != test.want { diff --git a/src/go/types/api_test.go b/src/go/types/api_test.go index 9044449e5c..b331ad929b 100644 --- a/src/go/types/api_test.go +++ b/src/go/types/api_test.go @@ -1631,6 +1631,7 @@ func TestConvertibleTo(t *testing.T) { }{ {Typ[Int], Typ[Int], true}, {Typ[Int], Typ[Float32], true}, + {Typ[Int], Typ[String], true}, {newDefined(Typ[Int]), Typ[Int], true}, {newDefined(new(Struct)), new(Struct), true}, {newDefined(Typ[Int]), new(Struct), false}, @@ -1638,8 +1639,7 @@ func TestConvertibleTo(t *testing.T) { {NewSlice(Typ[Int]), NewPointer(NewArray(Typ[Int], 10)), true}, {NewSlice(Typ[Int]), NewArray(Typ[Int], 10), false}, {NewSlice(Typ[Int]), NewPointer(NewArray(Typ[Uint], 10)), false}, - // Untyped string values are not permitted by the spec, so the below - // behavior is undefined. + // Untyped string values are not permitted by the spec, so the behavior below is undefined. {Typ[UntypedString], Typ[String], true}, } { if got := ConvertibleTo(test.v, test.t); got != test.want { From b59467e0365776761c3787a4d541b5e74fe24b24 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 14 Oct 2021 08:45:16 -0700 Subject: [PATCH 023/406] net/http: also use Server.ReadHeaderTimeout for TLS handshake deadline Fixes #48120 Change-Id: I72e89af8aaf3310e348d8ab639925ce0bf84204d Reviewed-on: https://go-review.googlesource.com/c/go/+/355870 Trust: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Go Bot Reviewed-by: Damien Neil --- src/net/http/server.go | 37 ++++++++++++++++++++++---- src/net/http/server_test.go | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 5 deletions(-) diff --git a/src/net/http/server.go b/src/net/http/server.go index 55fd4ae22f..e9b0b4d9bd 100644 --- a/src/net/http/server.go +++ b/src/net/http/server.go @@ -865,6 +865,28 @@ func (srv *Server) initialReadLimitSize() int64 { return int64(srv.maxHeaderBytes()) + 4096 // bufio slop } +// tlsHandshakeTimeout returns the time limit permitted for the TLS +// handshake, or zero for unlimited. +// +// It returns the minimum of any positive ReadHeaderTimeout, +// ReadTimeout, or WriteTimeout. +func (srv *Server) tlsHandshakeTimeout() time.Duration { + var ret time.Duration + for _, v := range [...]time.Duration{ + srv.ReadHeaderTimeout, + srv.ReadTimeout, + srv.WriteTimeout, + } { + if v <= 0 { + continue + } + if ret == 0 || v < ret { + ret = v + } + } + return ret +} + // wrapper around io.ReadCloser which on first read, sends an // HTTP/1.1 100 Continue header type expectContinueReader struct { @@ -1816,11 +1838,11 @@ func (c *conn) serve(ctx context.Context) { }() if tlsConn, ok := c.rwc.(*tls.Conn); ok { - if d := c.server.ReadTimeout; d > 0 { - c.rwc.SetReadDeadline(time.Now().Add(d)) - } - if d := c.server.WriteTimeout; d > 0 { - c.rwc.SetWriteDeadline(time.Now().Add(d)) + tlsTO := c.server.tlsHandshakeTimeout() + if tlsTO > 0 { + dl := time.Now().Add(tlsTO) + c.rwc.SetReadDeadline(dl) + c.rwc.SetWriteDeadline(dl) } if err := tlsConn.HandshakeContext(ctx); err != nil { // If the handshake failed due to the client not speaking @@ -1834,6 +1856,11 @@ func (c *conn) serve(ctx context.Context) { c.server.logf("http: TLS handshake error from %s: %v", c.rwc.RemoteAddr(), err) return } + // Restore Conn-level deadlines. + if tlsTO > 0 { + c.rwc.SetReadDeadline(time.Time{}) + c.rwc.SetWriteDeadline(time.Time{}) + } c.tlsState = new(tls.ConnectionState) *c.tlsState = tlsConn.ConnectionState() if proto := c.tlsState.NegotiatedProtocol; validNextProto(proto) { diff --git a/src/net/http/server_test.go b/src/net/http/server_test.go index 0132f3ba5f..d17c5c1e7e 100644 --- a/src/net/http/server_test.go +++ b/src/net/http/server_test.go @@ -9,8 +9,61 @@ package http import ( "fmt" "testing" + "time" ) +func TestServerTLSHandshakeTimeout(t *testing.T) { + tests := []struct { + s *Server + want time.Duration + }{ + { + s: &Server{}, + want: 0, + }, + { + s: &Server{ + ReadTimeout: -1, + }, + want: 0, + }, + { + s: &Server{ + ReadTimeout: 5 * time.Second, + }, + want: 5 * time.Second, + }, + { + s: &Server{ + ReadTimeout: 5 * time.Second, + WriteTimeout: -1, + }, + want: 5 * time.Second, + }, + { + s: &Server{ + ReadTimeout: 5 * time.Second, + WriteTimeout: 4 * time.Second, + }, + want: 4 * time.Second, + }, + { + s: &Server{ + ReadTimeout: 5 * time.Second, + ReadHeaderTimeout: 2 * time.Second, + WriteTimeout: 4 * time.Second, + }, + want: 2 * time.Second, + }, + } + for i, tt := range tests { + got := tt.s.tlsHandshakeTimeout() + if got != tt.want { + t.Errorf("%d. got %v; want %v", i, got, tt.want) + } + } +} + func BenchmarkServerMatch(b *testing.B) { fn := func(w ResponseWriter, r *Request) { fmt.Fprintf(w, "OK") From 9e8ed86813dd49c4160dd4813901e2ac03de5abd Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Thu, 14 Oct 2021 14:57:49 -0700 Subject: [PATCH 024/406] debug/buildinfo: fix test for build settings This CL fixes the debug/buildinfo test, which did not expect build settings. For #37475 Change-Id: Ie8c15ec633b4eec6a976120c8db64f116589d98e Reviewed-on: https://go-review.googlesource.com/c/go/+/356012 Trust: Jay Conrod Run-TryBot: Jay Conrod Reviewed-by: Bryan C. Mills --- src/debug/buildinfo/buildinfo_test.go | 28 ++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/debug/buildinfo/buildinfo_test.go b/src/debug/buildinfo/buildinfo_test.go index ab307d75c2..44d78a6be0 100644 --- a/src/debug/buildinfo/buildinfo_test.go +++ b/src/debug/buildinfo/buildinfo_test.go @@ -13,6 +13,7 @@ import ( "os/exec" "path" "path/filepath" + "regexp" "runtime" "strings" "testing" @@ -114,6 +115,23 @@ func TestReadFile(t *testing.T) { } } + goVersionRe := regexp.MustCompile("(?m)^go\t.*\n") + buildRe := regexp.MustCompile("(?m)^build\t.*\n") + cleanOutputForComparison := func(got string) string { + // Remove or replace anything that might depend on the test's environment + // so we can check the output afterward with a string comparison. + // We'll remove all build lines except the compiler, just to make sure + // build lines are included. + got = goVersionRe.ReplaceAllString(got, "go\tGOVERSION\n") + got = buildRe.ReplaceAllStringFunc(got, func(match string) string { + if strings.HasPrefix(match, "build\tcompiler\t") { + return match + } + return "" + }) + return got + } + cases := []struct { name string build func(t *testing.T, goos, goarch string) string @@ -142,9 +160,10 @@ func TestReadFile(t *testing.T) { { name: "valid_modules", build: buildWithModules, - want: "go\t$GOVERSION\n" + + want: "go\tGOVERSION\n" + "path\texample.com/m\n" + - "mod\texample.com/m\t(devel)\t\n", + "mod\texample.com/m\t(devel)\t\n" + + "build\tcompiler\tgc\n", }, { name: "invalid_modules", @@ -158,7 +177,7 @@ func TestReadFile(t *testing.T) { { name: "valid_gopath", build: buildWithGOPATH, - want: "go\t$GOVERSION\n", + want: "go\tGOVERSION\n", }, { name: "invalid_gopath", @@ -193,8 +212,7 @@ func TestReadFile(t *testing.T) { t.Fatalf("unexpected success; want error containing %q", tc.wantErr) } else if got, err := info.MarshalText(); err != nil { t.Fatalf("unexpected error marshaling BuildInfo: %v", err) - } else { - got := strings.ReplaceAll(string(got), runtime.Version(), "$GOVERSION") + } else if got := cleanOutputForComparison(string(got)); got != tc.want { if got != tc.want { t.Fatalf("got:\n%s\nwant:\n%s", got, tc.want) } From 0c45ed05612bb315c949229f7b484b4b573af4b0 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 13 Oct 2021 17:11:16 +0700 Subject: [PATCH 025/406] cmd/compile: fix irgen reports wrong error message for misuse of //go:embed Fixes #48230 Change-Id: Ic6490e065e7e79793faa0d0201dc94f5fcea694a Reviewed-on: https://go-review.googlesource.com/c/go/+/355529 Trust: Cuong Manh Le Trust: Dan Scales Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky Reviewed-by: Dan Scales --- src/cmd/compile/internal/noder/decl.go | 11 +++++++++-- src/cmd/compile/internal/noder/irgen.go | 8 +++++++- src/cmd/compile/internal/types2/stdlib_test.go | 2 +- src/go/types/stdlib_test.go | 1 + test/fixedbugs/issue48230.go | 10 ++++++++++ 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 test/fixedbugs/issue48230.go diff --git a/src/cmd/compile/internal/noder/decl.go b/src/cmd/compile/internal/noder/decl.go index f2dad9c302..82455f7d4a 100644 --- a/src/cmd/compile/internal/noder/decl.go +++ b/src/cmd/compile/internal/noder/decl.go @@ -132,7 +132,11 @@ func (g *irgen) funcDecl(out *ir.Nodes, decl *syntax.FuncDecl) { g.target.Inits = append(g.target.Inits, fn) } + haveEmbed := g.haveEmbed g.later(func() { + defer func(b bool) { g.haveEmbed = b }(g.haveEmbed) + + g.haveEmbed = haveEmbed if fn.Type().HasTParam() { g.topFuncIsGeneric = true } @@ -241,12 +245,15 @@ func (g *irgen) varDecl(out *ir.Nodes, decl *syntax.VarDecl) { if decl.Pragma != nil { pragma := decl.Pragma.(*pragmas) - // TODO(mdempsky): Plumb noder.importedEmbed through to here. - varEmbed(g.makeXPos, names[0], decl, pragma, true) + varEmbed(g.makeXPos, names[0], decl, pragma, g.haveEmbed) g.reportUnused(pragma) } + haveEmbed := g.haveEmbed do := func() { + defer func(b bool) { g.haveEmbed = b }(g.haveEmbed) + + g.haveEmbed = haveEmbed values := g.exprList(decl.Values) var as2 *ir.AssignListStmt diff --git a/src/cmd/compile/internal/noder/irgen.go b/src/cmd/compile/internal/noder/irgen.go index a3501fb90b..982e811f5f 100644 --- a/src/cmd/compile/internal/noder/irgen.go +++ b/src/cmd/compile/internal/noder/irgen.go @@ -147,6 +147,9 @@ type irgen struct { // laterFuncs records tasks that need to run after all declarations // are processed. laterFuncs []func() + // haveEmbed indicates whether the current node belongs to file that + // imports "embed" package. + haveEmbed bool // exprStmtOK indicates whether it's safe to generate expressions or // statements yet. @@ -254,8 +257,11 @@ Outer: types.ResumeCheckSize() // 3. Process all remaining declarations. - for _, declList := range declLists { + for i, declList := range declLists { + old := g.haveEmbed + g.haveEmbed = noders[i].importedEmbed g.decls((*ir.Nodes)(&g.target.Decls), declList) + g.haveEmbed = old } g.exprStmtOK = true diff --git a/src/cmd/compile/internal/types2/stdlib_test.go b/src/cmd/compile/internal/types2/stdlib_test.go index 6e340d0777..9c22f01673 100644 --- a/src/cmd/compile/internal/types2/stdlib_test.go +++ b/src/cmd/compile/internal/types2/stdlib_test.go @@ -193,7 +193,7 @@ func TestStdFixed(t *testing.T) { "issue42058a.go", // types2 does not have constraints on channel element size "issue42058b.go", // types2 does not have constraints on channel element size "issue48097.go", // go/types doesn't check validity of //go:xxx directives, and non-init bodyless function - + "issue48230.go", // go/types doesn't check validity of //go:xxx directives ) } diff --git a/src/go/types/stdlib_test.go b/src/go/types/stdlib_test.go index 12ed9a54f2..b0d7fdd3d9 100644 --- a/src/go/types/stdlib_test.go +++ b/src/go/types/stdlib_test.go @@ -195,6 +195,7 @@ func TestStdFixed(t *testing.T) { "issue42058a.go", // go/types does not have constraints on channel element size "issue42058b.go", // go/types does not have constraints on channel element size "issue48097.go", // go/types doesn't check validity of //go:xxx directives, and non-init bodyless function + "issue48230.go", // go/types doesn't check validity of //go:xxx directives ) } diff --git a/test/fixedbugs/issue48230.go b/test/fixedbugs/issue48230.go new file mode 100644 index 0000000000..5f213762da --- /dev/null +++ b/test/fixedbugs/issue48230.go @@ -0,0 +1,10 @@ +// errorcheck + +// Copyright 2021 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 p + +//go:embed issue48230.go // ERROR `go:embed only allowed in Go files that import "embed"` +var _ string From 3da0ff8e3b05333c378efe17585609598692791e Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Thu, 14 Oct 2021 16:47:47 -0700 Subject: [PATCH 026/406] cmd/go: don't stamp build or vcs info for GOROOT binaries Fixes a test failure in cmd/go TestScript/mod_outside. make.bash (cmd/dist) builds everything with -gcflags=all= -ldflags=all= by default. If those no-op flags aren't used, all GOROOT binaries appear stale. It's likely safe to omit those flags in cmd/dist if they're empty. Checking out a new commit in GOROOT would always cause staleness since the VCS info would change. For #37475 Change-Id: Ic9aa0f3b7318e05fbb2f7d2c008ad07a4c61952f Reviewed-on: https://go-review.googlesource.com/c/go/+/356014 Trust: Jay Conrod Run-TryBot: Jay Conrod TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/cmd/go/internal/load/pkg.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 716994b3ad..58dc242383 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -2205,6 +2205,11 @@ func (p *Package) collectDeps() { // Note that the GoVersion field is not set here to avoid encoding it twice. // It is stored separately in the binary, mostly for historical reasons. func (p *Package) setBuildInfo() { + // TODO: build and vcs information is not embedded for executables in GOROOT. + // cmd/dist uses -gcflags=all= -ldflags=all= by default, which means these + // executables always appear stale unless the user sets the same flags. + // Perhaps it's safe to omit those flags when GO_GCFLAGS and GO_LDFLAGS + // are not set? setPkgErrorf := func(format string, args ...interface{}) { if p.Error == nil { p.Error = &PackageError{Err: fmt.Errorf(format, args...)} @@ -2274,7 +2279,7 @@ func (p *Package) setBuildInfo() { // Add command-line flags relevant to the build. // This is informational, not an exhaustive list. - if cfg.BuildBuildinfo { + if cfg.BuildBuildinfo && !p.Standard { appendSetting("compiler", cfg.BuildContext.Compiler) if BuildAsmflags.present { appendSetting("asmflags", BuildAsmflags.String()) @@ -2313,7 +2318,7 @@ func (p *Package) setBuildInfo() { var repoDir string var vcsCmd *vcs.Cmd var err error - if cfg.BuildBuildvcs && p.Module != nil && p.Module.Version == "" { + if cfg.BuildBuildvcs && p.Module != nil && p.Module.Version == "" && !p.Standard { repoDir, vcsCmd, err = vcs.FromDir(base.Cwd(), "") if err != nil && !errors.Is(err, os.ErrNotExist) { setVCSError(err) From 8dab959a8e3c631e3166eb08ba450bfdbbf56e03 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 14 Oct 2021 17:30:42 -0700 Subject: [PATCH 027/406] reflect: rename Mapiter.SetKey to Value.SetIterKey Same for Value. Add a bigger test. Include some shouldPanic checks. Fix a bug in assignment conversion. Fixes #48294 Change-Id: Id863ee5122a5787a7b35574b18586fd24d118788 Reviewed-on: https://go-review.googlesource.com/c/go/+/356049 Trust: Keith Randall Trust: Josh Bleecher Snyder Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Josh Bleecher Snyder --- src/reflect/all_test.go | 90 ++++++++++++++++++++++++++++++++++++++--- src/reflect/value.go | 48 +++++++++++----------- 2 files changed, 108 insertions(+), 30 deletions(-) diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 5e10cc7a63..58156e0e5f 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -348,8 +348,8 @@ func TestMapIterSet(t *testing.T) { iter := v.MapRange() for iter.Next() { - iter.SetKey(k) - iter.SetValue(e) + k.SetIterKey(iter) + e.SetIterValue(iter) want := m[k.String()] got := e.Interface() if got != want { @@ -366,8 +366,8 @@ func TestMapIterSet(t *testing.T) { got := int(testing.AllocsPerRun(10, func() { iter := v.MapRange() for iter.Next() { - iter.SetKey(k) - iter.SetValue(e) + k.SetIterKey(iter) + e.SetIterValue(iter) } })) // Making a *MapIter allocates. This should be the only allocation. @@ -7475,9 +7475,9 @@ func TestMapIterReset(t *testing.T) { var seenk, seenv uint64 iter.Reset(ValueOf(m3)) for iter.Next() { - iter.SetKey(kv) + kv.SetIterKey(iter) seenk ^= kv.Uint() - iter.SetValue(kv) + kv.SetIterValue(iter) seenv ^= kv.Uint() } if seenk != 0b111 { @@ -7619,3 +7619,81 @@ func TestConvertibleTo(t *testing.T) { t.Fatalf("(%s).ConvertibleTo(%s) = true, want false", t3, t4) } } + +func TestSetIter(t *testing.T) { + data := map[string]int{ + "foo": 1, + "bar": 2, + "baz": 3, + } + + m := ValueOf(data) + i := m.MapRange() + k := New(TypeOf("")).Elem() + v := New(TypeOf(0)).Elem() + shouldPanic("Value.SetIterKey called before Next", func() { + k.SetIterKey(i) + }) + shouldPanic("Value.SetIterValue called before Next", func() { + k.SetIterValue(i) + }) + data2 := map[string]int{} + for i.Next() { + k.SetIterKey(i) + v.SetIterValue(i) + data2[k.Interface().(string)] = v.Interface().(int) + } + if !DeepEqual(data, data2) { + t.Errorf("maps not equal, got %v want %v", data2, data) + } + shouldPanic("Value.SetIterKey called on exhausted iterator", func() { + k.SetIterKey(i) + }) + shouldPanic("Value.SetIterValue called on exhausted iterator", func() { + k.SetIterValue(i) + }) + + i.Reset(m) + i.Next() + shouldPanic("Value.SetIterKey using unaddressable value", func() { + ValueOf("").SetIterKey(i) + }) + shouldPanic("Value.SetIterValue using unaddressable value", func() { + ValueOf(0).SetIterValue(i) + }) + shouldPanic("value of type string is not assignable to type int", func() { + New(TypeOf(0)).Elem().SetIterKey(i) + }) + shouldPanic("value of type int is not assignable to type string", func() { + New(TypeOf("")).Elem().SetIterValue(i) + }) + + // Make sure assignment conversion works. + var x interface{} + y := ValueOf(&x).Elem() + y.SetIterKey(i) + if _, ok := data[x.(string)]; !ok { + t.Errorf("got key %s which is not in map", x) + } + y.SetIterValue(i) + if x.(int) < 1 || x.(int) > 3 { + t.Errorf("got value %d which is not in map", x) + } + + // Try some key/value types which are direct interfaces. + a := 88 + b := 99 + pp := map[*int]*int{ + &a: &b, + } + i = ValueOf(pp).MapRange() + i.Next() + y.SetIterKey(i) + if got := *y.Interface().(*int); got != a { + t.Errorf("pointer incorrect: got %d want %d", got, a) + } + y.SetIterValue(i) + if got := *y.Interface().(*int); got != b { + t.Errorf("pointer incorrect: got %d want %d", got, b) + } +} diff --git a/src/reflect/value.go b/src/reflect/value.go index 39b82a8c01..abcc346de8 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -1651,30 +1651,30 @@ func (iter *MapIter) Key() Value { return copyVal(ktype, iter.m.flag.ro()|flag(ktype.Kind()), iterkey) } -// SetKey assigns dst to the key of iter's current map entry. -// It is equivalent to dst.Set(i.Key()), but it avoids allocating a new Value. -// As in Go, the key must be assignable to dst's type. -func (iter *MapIter) SetKey(dst Value) { +// SetIterKey assigns to v the key of iter's current map entry. +// It is equivalent to v.Set(iter.Key()), but it avoids allocating a new Value. +// As in Go, the key must be assignable to v's type. +func (v Value) SetIterKey(iter *MapIter) { if !iter.hiter.initialized() { - panic("MapIter.SetKey called before Next") + panic("reflect: Value.SetIterKey called before Next") } iterkey := mapiterkey(&iter.hiter) if iterkey == nil { - panic("MapIter.SetKey called on exhausted iterator") + panic("reflect: Value.SetIterKey called on exhausted iterator") } - dst.mustBeAssignable() + v.mustBeAssignable() var target unsafe.Pointer - if dst.kind() == Interface { - target = dst.ptr + if v.kind() == Interface { + target = v.ptr } t := (*mapType)(unsafe.Pointer(iter.m.typ)) ktype := t.key - key := Value{ktype, iterkey, iter.m.flag | flag(ktype.Kind())} - key = key.assignTo("reflect.MapIter.SetKey", dst.typ, target) - typedmemmove(dst.typ, dst.ptr, key.ptr) + key := Value{ktype, iterkey, iter.m.flag | flag(ktype.Kind()) | flagIndir} + key = key.assignTo("reflect.MapIter.SetKey", v.typ, target) + typedmemmove(v.typ, v.ptr, key.ptr) } // Value returns the value of iter's current map entry. @@ -1692,30 +1692,30 @@ func (iter *MapIter) Value() Value { return copyVal(vtype, iter.m.flag.ro()|flag(vtype.Kind()), iterelem) } -// SetValue assigns dst to the value of iter's current map entry. -// It is equivalent to dst.Set(i.Value()), but it avoids allocating a new Value. -// As in Go, the value must be assignable to dst's type. -func (iter *MapIter) SetValue(dst Value) { +// SetIterValue assigns to v the value of iter's current map entry. +// It is equivalent to v.Set(iter.Value()), but it avoids allocating a new Value. +// As in Go, the value must be assignable to v's type. +func (v Value) SetIterValue(iter *MapIter) { if !iter.hiter.initialized() { - panic("MapIter.SetValue called before Next") + panic("reflect: Value.SetIterValue called before Next") } iterelem := mapiterelem(&iter.hiter) if iterelem == nil { - panic("MapIter.SetValue called on exhausted iterator") + panic("reflect: Value.SetIterValue called on exhausted iterator") } - dst.mustBeAssignable() + v.mustBeAssignable() var target unsafe.Pointer - if dst.kind() == Interface { - target = dst.ptr + if v.kind() == Interface { + target = v.ptr } t := (*mapType)(unsafe.Pointer(iter.m.typ)) vtype := t.elem - elem := Value{vtype, iterelem, iter.m.flag | flag(vtype.Kind())} - elem = elem.assignTo("reflect.MapIter.SetValue", dst.typ, target) - typedmemmove(dst.typ, dst.ptr, elem.ptr) + elem := Value{vtype, iterelem, iter.m.flag | flag(vtype.Kind()) | flagIndir} + elem = elem.assignTo("reflect.MapIter.SetValue", v.typ, target) + typedmemmove(v.typ, v.ptr, elem.ptr) } // Next advances the map iterator and reports whether there is another From 81484cf6263461057251bbda825f2c3dc4cdcd09 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 14 Oct 2021 21:08:11 -0700 Subject: [PATCH 028/406] doc: document new reflect.SetIter{Key,Value} functions Update #48294 Update #47694 Change-Id: I4d4c01be74a9736d89a4ec92318ce29ff7289a0d Reviewed-on: https://go-review.googlesource.com/c/go/+/356050 Trust: Keith Randall Reviewed-by: Joe Tsai --- doc/go1.18.html | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/go1.18.html b/doc/go1.18.html index a5b47fa261..f4d097d06b 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -127,12 +127,25 @@ Do not send CLs removing the interior tags from such phrases. +
reflect
+
+

+ The new + Value.SetIterKey + and Value.SetIterValue + methods set a Value using a map iterator as the source. They are equivalent to + Value.Set(iter.Key()) and Value.Set(iter.Value()) but + do fewer allocations. +

+
+
+
syscall

The new function SyscallN has been introduced for Windows, allowing for calls with arbitrary number - of arguments. As results, + of arguments. As a result, Syscall, Syscall6, Syscall9, From 1cbec685124b7a40fe899286db697a85da7be28a Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 14 Oct 2021 23:01:34 -0700 Subject: [PATCH 029/406] reflect: fix SetIter test Missed one review comment in CL 356049 Change-Id: I05be585d15e77afc1aa57b737cdc8ba7204bab98 Reviewed-on: https://go-review.googlesource.com/c/go/+/356051 Trust: Keith Randall Trust: Josh Bleecher Snyder Run-TryBot: Keith Randall Reviewed-by: Josh Bleecher Snyder TryBot-Result: Go Bot --- src/reflect/all_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 58156e0e5f..427855b02e 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -7635,7 +7635,7 @@ func TestSetIter(t *testing.T) { k.SetIterKey(i) }) shouldPanic("Value.SetIterValue called before Next", func() { - k.SetIterValue(i) + v.SetIterValue(i) }) data2 := map[string]int{} for i.Next() { @@ -7650,7 +7650,7 @@ func TestSetIter(t *testing.T) { k.SetIterKey(i) }) shouldPanic("Value.SetIterValue called on exhausted iterator", func() { - k.SetIterValue(i) + v.SetIterValue(i) }) i.Reset(m) From fad4a16fd43f6a72b6917eff656be27522809074 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 15 Oct 2021 11:22:03 -0400 Subject: [PATCH 030/406] cmd/go: use portable flags in TestScript/version_build_settings This fixes a test failure on the 386-longtest builder. For #37475 Change-Id: Icd1d3474968fcf85ef893190760fb488302abc3a Reviewed-on: https://go-review.googlesource.com/c/go/+/356209 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Jay Conrod --- .../go/testdata/script/version_build_settings.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd/go/testdata/script/version_build_settings.txt b/src/cmd/go/testdata/script/version_build_settings.txt index 7e93643b9f..1ced285ac3 100644 --- a/src/cmd/go/testdata/script/version_build_settings.txt +++ b/src/cmd/go/testdata/script/version_build_settings.txt @@ -8,17 +8,17 @@ stdout '^\tbuild\tcompiler\tgc$' # Toolchain flags are added if present. # The raw flags are included, with package patterns if specified. -go build -asmflags=all=-spectre=all +go build -asmflags=example.com/m=-D=FOO=bar go version -m m$GOEXE -stdout '^\tbuild\tasmflags\tall=-spectre=all$' +stdout '^\tbuild\tasmflags\texample\.com/m=-D=FOO=bar$' -go build -gcflags=all=-spectre=all +go build -gcflags=example.com/m=-N go version -m m$GOEXE -stdout '^\tbuild\tgcflags\tall=-spectre=all$' +stdout '^\tbuild\tgcflags\texample\.com/m=-N$' -go build -ldflags=-w +go build -ldflags=example.com/m=-w go version -m m$GOEXE -stdout '^\tbuild\tldflags\t-w$' +stdout '^\tbuild\tldflags\texample\.com/m=-w$' # gccgoflags are not added when gc is used, and vice versa. # TODO: test gccgo. From a80e53ec43d6ab925bb34d62dd8597a4227af363 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Sun, 19 Sep 2021 09:13:47 -0700 Subject: [PATCH 031/406] cmd/compile: support new fully-inst types referenced during inlining Modify the phase for creating needed function/method instantiations and modifying functions to use those instantiations, so that the phase is self-contained and can be called again after inlining. This is to deal with the issue that inlining may reveal new fully-instantiated types whose methods must be instantiated. With this change, we have an extra phase for instantiation after inlining, to take care of the new fully-instantiated types that have shown up during inlining. We call inline.InlineCalls() for any new instantiated functions that are created. Change-Id: I4ddf0b1907e5f1f7d45891db7876455a99381133 Reviewed-on: https://go-review.googlesource.com/c/go/+/352870 Run-TryBot: Dan Scales TryBot-Result: Go Bot Reviewed-by: Keith Randall Trust: Alexander Rakoczy --- src/cmd/compile/internal/gc/main.go | 5 + src/cmd/compile/internal/noder/irgen.go | 32 +- src/cmd/compile/internal/noder/stencil.go | 452 +++++++++++---------- src/cmd/compile/internal/typecheck/subr.go | 11 +- test/typeparam/geninline.dir/a.go | 56 +++ test/typeparam/geninline.dir/main.go | 16 + test/typeparam/geninline.go | 7 + 7 files changed, 355 insertions(+), 224 deletions(-) create mode 100644 test/typeparam/geninline.dir/a.go create mode 100644 test/typeparam/geninline.dir/main.go create mode 100644 test/typeparam/geninline.go diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index 8ddef6721f..74b21571b3 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -244,6 +244,11 @@ func Main(archInit func(*ssagen.ArchInfo)) { base.Timer.Start("fe", "inlining") if base.Flag.LowerL != 0 { inline.InlinePackage() + // If any new fully-instantiated types were referenced during + // inlining, we need to create needed instantiations. + if len(typecheck.GetInstTypeList()) > 0 { + noder.BuildInstantiations(false) + } } noder.MakeWrappers(typecheck.Target) // must happen after inlining diff --git a/src/cmd/compile/internal/noder/irgen.go b/src/cmd/compile/internal/noder/irgen.go index 982e811f5f..e20939de66 100644 --- a/src/cmd/compile/internal/noder/irgen.go +++ b/src/cmd/compile/internal/noder/irgen.go @@ -158,16 +158,6 @@ type irgen struct { // types which we need to finish, by doing g.fillinMethods. typesToFinalize []*typeDelayInfo - dnum int // for generating unique dictionary variables - - // Map from a name of function that been instantiated to information about - // its instantiated function (including dictionary format). - instInfoMap map[*types.Sym]*instInfo - - // dictionary syms which we need to finish, by writing out any itabconv - // entries. - dictSymsToFinalize []*delayInfo - // True when we are compiling a top-level generic function or method. Use to // avoid adding closures of generic functions/methods to the target.Decls // list. @@ -180,6 +170,23 @@ type irgen struct { curDecl string } +// genInst has the information for creating needed instantiations and modifying +// functions to use instantiations. +type genInst struct { + dnum int // for generating unique dictionary variables + + // Map from the names of all instantiations to information about the + // instantiations. + instInfoMap map[*types.Sym]*instInfo + + // Dictionary syms which we need to finish, by writing out any itabconv + // entries. + dictSymsToFinalize []*delayInfo + + // New instantiations created during this round of buildInstantiations(). + newInsts []ir.Node +} + func (g *irgen) later(fn func()) { g.laterFuncs = append(g.laterFuncs, fn) } @@ -308,8 +315,9 @@ Outer: typecheck.DeclareUniverse() - // Create any needed stencils of generic functions - g.stencil() + // Create any needed instantiations of generic functions and transform + // existing and new functions to use those instantiations. + BuildInstantiations(true) // Remove all generic functions from g.target.Decl, since they have been // used for stenciling, but don't compile. Generic functions will already diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 447fe8a538..cfa90e4399 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -9,6 +9,7 @@ package noder import ( "cmd/compile/internal/base" + "cmd/compile/internal/inline" "cmd/compile/internal/ir" "cmd/compile/internal/objw" "cmd/compile/internal/reflectdata" @@ -37,207 +38,54 @@ func infoPrint(format string, a ...interface{}) { } } -// stencil scans functions for instantiated generic function calls and creates the -// required instantiations for simple generic functions. It also creates -// instantiated methods for all fully-instantiated generic types that have been -// encountered already or new ones that are encountered during the stenciling -// process. -func (g *irgen) stencil() { - g.instInfoMap = make(map[*types.Sym]*instInfo) +var geninst genInst +func BuildInstantiations(preinliningMainScan bool) { + if geninst.instInfoMap == nil { + geninst.instInfoMap = make(map[*types.Sym]*instInfo) + } + geninst.buildInstantiations(preinliningMainScan) +} + +// buildInstantiations scans functions for generic function calls and methods, and +// creates the required instantiations. It also creates instantiated methods for all +// fully-instantiated generic types that have been encountered already or new ones +// that are encountered during the instantiation process. If preinliningMainScan is +// true, it scans all declarations in typecheck.Target.Decls first, before scanning +// any new instantiations created. If preinliningMainScan is false, we do not scan +// any existing decls - we only scan method instantiations for any new +// fully-instantiated types that we saw during inlining. +func (g *genInst) buildInstantiations(preinliningMainScan bool) { // Instantiate the methods of instantiated generic types that we have seen so far. g.instantiateMethods() - // Don't use range(g.target.Decls) - we also want to process any new instantiated - // functions that are created during this loop, in order to handle generic - // functions calling other generic functions. - for i := 0; i < len(g.target.Decls); i++ { - decl := g.target.Decls[i] - - // Look for function instantiations in bodies of non-generic - // functions or in global assignments (ignore global type and - // constant declarations). - switch decl.Op() { - case ir.ODCLFUNC: - if decl.Type().HasTParam() { - // Skip any generic functions - continue - } - // transformCall() below depends on CurFunc being set. - ir.CurFunc = decl.(*ir.Func) - - case ir.OAS, ir.OAS2, ir.OAS2DOTTYPE, ir.OAS2FUNC, ir.OAS2MAPR, ir.OAS2RECV, ir.OASOP: - // These are all the various kinds of global assignments, - // whose right-hand-sides might contain a function - // instantiation. - - default: - // The other possible ops at the top level are ODCLCONST - // and ODCLTYPE, which don't have any function - // instantiations. - continue + if preinliningMainScan { + n := len(typecheck.Target.Decls) + for i := 0; i < n; i++ { + g.scanForGenCalls(typecheck.Target.Decls[i]) } + } - // For all non-generic code, search for any function calls using - // generic function instantiations. Then create the needed - // instantiated function if it hasn't been created yet, and change - // to calling that function directly. - modified := false - closureRequired := false - // declInfo will be non-nil exactly if we are scanning an instantiated function - declInfo := g.instInfoMap[decl.Sym()] - - ir.Visit(decl, func(n ir.Node) { - if n.Op() == ir.OFUNCINST { - // generic F, not immediately called - closureRequired = true - } - if (n.Op() == ir.OMETHEXPR || n.Op() == ir.OMETHVALUE) && len(deref(n.(*ir.SelectorExpr).X.Type()).RParams()) > 0 && !types.IsInterfaceMethod(n.(*ir.SelectorExpr).Selection.Type) { - // T.M or x.M, where T or x is generic, but not immediately - // called. Not necessary if the method selected is - // actually for an embedded interface field. - closureRequired = true - } - if n.Op() == ir.OCALL && n.(*ir.CallExpr).X.Op() == ir.OFUNCINST { - // We have found a function call using a generic function - // instantiation. - call := n.(*ir.CallExpr) - inst := call.X.(*ir.InstExpr) - nameNode, isMeth := g.getInstNameNode(inst) - targs := typecheck.TypesOf(inst.Targs) - st := g.getInstantiation(nameNode, targs, isMeth).fun - dictValue, usingSubdict := g.getDictOrSubdict(declInfo, n, nameNode, targs, isMeth) - if infoPrintMode { - dictkind := "Main dictionary" - if usingSubdict { - dictkind = "Sub-dictionary" - } - if inst.X.Op() == ir.OMETHVALUE { - fmt.Printf("%s in %v at generic method call: %v - %v\n", dictkind, decl, inst.X, call) - } else { - fmt.Printf("%s in %v at generic function call: %v - %v\n", dictkind, decl, inst.X, call) - } - } - - // Transform the Call now, which changes OCALL to - // OCALLFUNC and does typecheckaste/assignconvfn. Do - // it before installing the instantiation, so we are - // checking against non-shape param types in - // typecheckaste. - transformCall(call, nil) - - // Replace the OFUNCINST with a direct reference to the - // new stenciled function - call.X = st.Nname - if inst.X.Op() == ir.OMETHVALUE { - // When we create an instantiation of a method - // call, we make it a function. So, move the - // receiver to be the first arg of the function - // call. - call.Args.Prepend(inst.X.(*ir.SelectorExpr).X) - } - - // Add dictionary to argument list. - call.Args.Prepend(dictValue) - modified = true - } - if n.Op() == ir.OCALLMETH && n.(*ir.CallExpr).X.Op() == ir.ODOTMETH && len(deref(n.(*ir.CallExpr).X.Type().Recv().Type).RParams()) > 0 { - // Method call on a generic type, which was instantiated by stenciling. - // Method calls on explicitly instantiated types will have an OFUNCINST - // and are handled above. - call := n.(*ir.CallExpr) - meth := call.X.(*ir.SelectorExpr) - targs := deref(meth.Type().Recv().Type).RParams() - - t := meth.X.Type() - baseSym := deref(t).OrigSym() - baseType := baseSym.Def.(*ir.Name).Type() - var gf *ir.Name - for _, m := range baseType.Methods().Slice() { - if meth.Sel == m.Sym { - gf = m.Nname.(*ir.Name) - break - } - } - - // Transform the Call now, which changes OCALL - // to OCALLFUNC and does typecheckaste/assignconvfn. - transformCall(call, nil) - - st := g.getInstantiation(gf, targs, true).fun - dictValue, usingSubdict := g.getDictOrSubdict(declInfo, n, gf, targs, true) - // We have to be using a subdictionary, since this is - // a generic method call. - assert(usingSubdict) - - // Transform to a function call, by appending the - // dictionary and the receiver to the args. - call.SetOp(ir.OCALLFUNC) - call.X = st.Nname - call.Args.Prepend(dictValue, meth.X) - modified = true - } - }) - - // If we found a reference to a generic instantiation that wasn't an - // immediate call, then traverse the nodes of decl again (with - // EditChildren rather than Visit), where we actually change the - // reference to the instantiation to a closure that captures the - // dictionary, then does a direct call. - // EditChildren is more expensive than Visit, so we only do this - // in the infrequent case of an OFUNCINST without a corresponding - // call. - if closureRequired { - modified = true - var edit func(ir.Node) ir.Node - var outer *ir.Func - if f, ok := decl.(*ir.Func); ok { - outer = f - } - edit = func(x ir.Node) ir.Node { - if x.Op() == ir.OFUNCINST { - child := x.(*ir.InstExpr).X - if child.Op() == ir.OMETHEXPR || child.Op() == ir.OMETHVALUE { - // Call EditChildren on child (x.X), - // not x, so that we don't do - // buildClosure() on the - // METHEXPR/METHVALUE nodes as well. - ir.EditChildren(child, edit) - return g.buildClosure(outer, x) - } - } - ir.EditChildren(x, edit) - switch { - case x.Op() == ir.OFUNCINST: - return g.buildClosure(outer, x) - case (x.Op() == ir.OMETHEXPR || x.Op() == ir.OMETHVALUE) && - len(deref(x.(*ir.SelectorExpr).X.Type()).RParams()) > 0 && - !types.IsInterfaceMethod(x.(*ir.SelectorExpr).Selection.Type): - return g.buildClosure(outer, x) - } - return x - } - edit(decl) - } - if base.Flag.W > 1 && modified { - ir.Dump(fmt.Sprintf("\nmodified %v", decl), decl) - } - ir.CurFunc = nil - // We may have seen new fully-instantiated generic types while - // instantiating any needed functions/methods in the above - // function. If so, instantiate all the methods of those types - // (which will then lead to more function/methods to scan in the loop). - g.instantiateMethods() + // Scan all new instantiations created due to g.instantiateMethods() and the + // scan of current decls (if done). This loop purposely runs until no new + // instantiations are created. + for i := 0; i < len(g.newInsts); i++ { + g.scanForGenCalls(g.newInsts[i]) } g.finalizeSyms() // All the instantiations and dictionaries have been created. Now go through - // each instantiation and transform the various operations that need to make + // each new instantiation and transform the various operations that need to make // use of their dictionary. - l := len(g.instInfoMap) - for _, info := range g.instInfoMap { + l := len(g.newInsts) + for _, fun := range g.newInsts { + info := g.instInfoMap[fun.Sym()] g.dictPass(info) + if !preinliningMainScan { + // Prepare for the round of inlining below. + inline.CanInline(fun.(*ir.Func)) + } if doubleCheck { ir.Visit(info.fun, func(n ir.Node) { if n.Op() != ir.OCONVIFACE { @@ -255,13 +103,198 @@ func (g *irgen) stencil() { ir.Dump(fmt.Sprintf("\ndictpass %v", info.fun), info.fun) } } - assert(l == len(g.instInfoMap)) + if !preinliningMainScan { + // Extra round of inlining for the new instantiations (only if + // preinliningMainScan is false, which means we have already done the + // main round of inlining) + for _, fun := range g.newInsts { + inline.InlineCalls(fun.(*ir.Func)) + } + } + assert(l == len(g.newInsts)) + g.newInsts = nil +} + +// scanForGenCalls scans a single function (or global assignment), looking for +// references to generic functions/methods. At each such reference, it creates any +// required instantiation and transforms the reference. +func (g *genInst) scanForGenCalls(decl ir.Node) { + switch decl.Op() { + case ir.ODCLFUNC: + if decl.Type().HasTParam() { + // Skip any generic functions + return + } + // transformCall() below depends on CurFunc being set. + ir.CurFunc = decl.(*ir.Func) + + case ir.OAS, ir.OAS2, ir.OAS2DOTTYPE, ir.OAS2FUNC, ir.OAS2MAPR, ir.OAS2RECV, ir.OASOP: + // These are all the various kinds of global assignments, + // whose right-hand-sides might contain a function + // instantiation. + + default: + // The other possible ops at the top level are ODCLCONST + // and ODCLTYPE, which don't have any function + // instantiations. + return + } + + // Search for any function references using generic function/methods. Then + // create the needed instantiated function if it hasn't been created yet, and + // change to calling that function directly. + modified := false + closureRequired := false + // declInfo will be non-nil exactly if we are scanning an instantiated function + declInfo := g.instInfoMap[decl.Sym()] + + ir.Visit(decl, func(n ir.Node) { + if n.Op() == ir.OFUNCINST { + // generic F, not immediately called + closureRequired = true + } + if (n.Op() == ir.OMETHEXPR || n.Op() == ir.OMETHVALUE) && len(deref(n.(*ir.SelectorExpr).X.Type()).RParams()) > 0 && !types.IsInterfaceMethod(n.(*ir.SelectorExpr).Selection.Type) { + // T.M or x.M, where T or x is generic, but not immediately + // called. Not necessary if the method selected is + // actually for an embedded interface field. + closureRequired = true + } + if n.Op() == ir.OCALL && n.(*ir.CallExpr).X.Op() == ir.OFUNCINST { + // We have found a function call using a generic function + // instantiation. + call := n.(*ir.CallExpr) + inst := call.X.(*ir.InstExpr) + nameNode, isMeth := g.getInstNameNode(inst) + targs := typecheck.TypesOf(inst.Targs) + st := g.getInstantiation(nameNode, targs, isMeth).fun + dictValue, usingSubdict := g.getDictOrSubdict(declInfo, n, nameNode, targs, isMeth) + if infoPrintMode { + dictkind := "Main dictionary" + if usingSubdict { + dictkind = "Sub-dictionary" + } + if inst.X.Op() == ir.OMETHVALUE { + fmt.Printf("%s in %v at generic method call: %v - %v\n", dictkind, decl, inst.X, call) + } else { + fmt.Printf("%s in %v at generic function call: %v - %v\n", dictkind, decl, inst.X, call) + } + } + + // Transform the Call now, which changes OCALL to + // OCALLFUNC and does typecheckaste/assignconvfn. Do + // it before installing the instantiation, so we are + // checking against non-shape param types in + // typecheckaste. + transformCall(call, nil) + + // Replace the OFUNCINST with a direct reference to the + // new stenciled function + call.X = st.Nname + if inst.X.Op() == ir.OMETHVALUE { + // When we create an instantiation of a method + // call, we make it a function. So, move the + // receiver to be the first arg of the function + // call. + call.Args.Prepend(inst.X.(*ir.SelectorExpr).X) + } + + // Add dictionary to argument list. + call.Args.Prepend(dictValue) + modified = true + } + if n.Op() == ir.OCALLMETH && n.(*ir.CallExpr).X.Op() == ir.ODOTMETH && len(deref(n.(*ir.CallExpr).X.Type().Recv().Type).RParams()) > 0 { + // Method call on a generic type, which was instantiated by stenciling. + // Method calls on explicitly instantiated types will have an OFUNCINST + // and are handled above. + call := n.(*ir.CallExpr) + meth := call.X.(*ir.SelectorExpr) + targs := deref(meth.Type().Recv().Type).RParams() + + t := meth.X.Type() + baseSym := deref(t).OrigSym() + baseType := baseSym.Def.(*ir.Name).Type() + var gf *ir.Name + for _, m := range baseType.Methods().Slice() { + if meth.Sel == m.Sym { + gf = m.Nname.(*ir.Name) + break + } + } + + // Transform the Call now, which changes OCALL + // to OCALLFUNC and does typecheckaste/assignconvfn. + transformCall(call, nil) + + st := g.getInstantiation(gf, targs, true).fun + dictValue, usingSubdict := g.getDictOrSubdict(declInfo, n, gf, targs, true) + // We have to be using a subdictionary, since this is + // a generic method call. + assert(usingSubdict) + + // Transform to a function call, by appending the + // dictionary and the receiver to the args. + call.SetOp(ir.OCALLFUNC) + call.X = st.Nname + call.Args.Prepend(dictValue, meth.X) + modified = true + } + }) + + // If we found a reference to a generic instantiation that wasn't an + // immediate call, then traverse the nodes of decl again (with + // EditChildren rather than Visit), where we actually change the + // reference to the instantiation to a closure that captures the + // dictionary, then does a direct call. + // EditChildren is more expensive than Visit, so we only do this + // in the infrequent case of an OFUNCINST without a corresponding + // call. + if closureRequired { + modified = true + var edit func(ir.Node) ir.Node + var outer *ir.Func + if f, ok := decl.(*ir.Func); ok { + outer = f + } + edit = func(x ir.Node) ir.Node { + if x.Op() == ir.OFUNCINST { + child := x.(*ir.InstExpr).X + if child.Op() == ir.OMETHEXPR || child.Op() == ir.OMETHVALUE { + // Call EditChildren on child (x.X), + // not x, so that we don't do + // buildClosure() on the + // METHEXPR/METHVALUE nodes as well. + ir.EditChildren(child, edit) + return g.buildClosure(outer, x) + } + } + ir.EditChildren(x, edit) + switch { + case x.Op() == ir.OFUNCINST: + return g.buildClosure(outer, x) + case (x.Op() == ir.OMETHEXPR || x.Op() == ir.OMETHVALUE) && + len(deref(x.(*ir.SelectorExpr).X.Type()).RParams()) > 0 && + !types.IsInterfaceMethod(x.(*ir.SelectorExpr).Selection.Type): + return g.buildClosure(outer, x) + } + return x + } + edit(decl) + } + if base.Flag.W > 1 && modified { + ir.Dump(fmt.Sprintf("\nmodified %v", decl), decl) + } + ir.CurFunc = nil + // We may have seen new fully-instantiated generic types while + // instantiating any needed functions/methods in the above + // function. If so, instantiate all the methods of those types + // (which will then lead to more function/methods to scan in the loop). + g.instantiateMethods() } // buildClosure makes a closure to implement x, a OFUNCINST or OMETHEXPR/OMETHVALUE // of generic type. outer is the containing function (or nil if closure is // in a global assignment instead of a function). -func (g *irgen) buildClosure(outer *ir.Func, x ir.Node) ir.Node { +func (g *genInst) buildClosure(outer *ir.Func, x ir.Node) ir.Node { pos := x.Pos() var target *ir.Func // target instantiated function/method var dictValue ir.Node // dictionary to use @@ -423,8 +456,8 @@ func (g *irgen) buildClosure(outer *ir.Func, x ir.Node) ir.Node { rcvrVar.Defn = rcvrAssign if outer == nil { rcvrVar.Class = ir.PEXTERN - g.target.Decls = append(g.target.Decls, rcvrAssign) - g.target.Externs = append(g.target.Externs, rcvrVar) + typecheck.Target.Decls = append(typecheck.Target.Decls, rcvrAssign) + typecheck.Target.Externs = append(typecheck.Target.Externs, rcvrVar) } else { rcvrVar.Class = ir.PAUTO rcvrVar.Curfn = outer @@ -496,7 +529,7 @@ func (g *irgen) buildClosure(outer *ir.Func, x ir.Node) ir.Node { ir.FinishCaptureNames(pos, outer, fn) // Make a closure referencing our new internal function. - c := ir.UseClosure(fn.OClosure, g.target) + c := ir.UseClosure(fn.OClosure, typecheck.Target) var init []ir.Node if outer != nil { init = append(init, dictAssign) @@ -510,12 +543,13 @@ func (g *irgen) buildClosure(outer *ir.Func, x ir.Node) ir.Node { // instantiateMethods instantiates all the methods (and associated dictionaries) of // all fully-instantiated generic types that have been added to typecheck.instTypeList. // It continues until no more types are added to typecheck.instTypeList. -func (g *irgen) instantiateMethods() { +func (g *genInst) instantiateMethods() { for { instTypeList := typecheck.GetInstTypeList() if len(instTypeList) == 0 { break } + typecheck.ClearInstTypeList() for _, typ := range instTypeList { assert(!typ.HasShape()) // Mark runtime type as needed, since this ensures that the @@ -548,7 +582,7 @@ func (g *irgen) instantiateMethods() { } // getInstNameNode returns the name node for the method or function being instantiated, and a bool which is true if a method is being instantiated. -func (g *irgen) getInstNameNode(inst *ir.InstExpr) (*ir.Name, bool) { +func (g *genInst) getInstNameNode(inst *ir.InstExpr) (*ir.Name, bool) { if meth, ok := inst.X.(*ir.SelectorExpr); ok { return meth.Selection.Nname.(*ir.Name), true } else { @@ -561,7 +595,7 @@ func (g *irgen) getInstNameNode(inst *ir.InstExpr) (*ir.Name, bool) { // or main/static dictionary, as needed, and also returns a boolean indicating if a // sub-dictionary was accessed. nameNode is the particular function or method being // called/referenced, and targs are the type arguments. -func (g *irgen) getDictOrSubdict(declInfo *instInfo, n ir.Node, nameNode *ir.Name, targs []*types.Type, isMeth bool) (ir.Node, bool) { +func (g *genInst) getDictOrSubdict(declInfo *instInfo, n ir.Node, nameNode *ir.Name, targs []*types.Type, isMeth bool) (ir.Node, bool) { var dict ir.Node usingSubdict := false if declInfo != nil { @@ -603,7 +637,7 @@ func checkFetchBody(nameNode *ir.Name) { // getInstantiation gets the instantiantion and dictionary of the function or method nameNode // with the type arguments shapes. If the instantiated function is not already // cached, then it calls genericSubst to create the new instantiation. -func (g *irgen) getInstantiation(nameNode *ir.Name, shapes []*types.Type, isMeth bool) *instInfo { +func (g *genInst) getInstantiation(nameNode *ir.Name, shapes []*types.Type, isMeth bool) *instInfo { checkFetchBody(nameNode) // Convert any non-shape type arguments to their shape, so we can reduce the @@ -645,7 +679,8 @@ func (g *irgen) getInstantiation(nameNode *ir.Name, shapes []*types.Type, isMeth // This ensures that the linker drops duplicates of this instantiation. // All just works! st.SetDupok(true) - g.target.Decls = append(g.target.Decls, st) + typecheck.Target.Decls = append(typecheck.Target.Decls, st) + g.newInsts = append(g.newInsts, st) } return info } @@ -653,7 +688,7 @@ func (g *irgen) getInstantiation(nameNode *ir.Name, shapes []*types.Type, isMeth // Struct containing info needed for doing the substitution as we create the // instantiation of a generic function with specified type arguments. type subster struct { - g *irgen + g *genInst isMethod bool // If a method is being instantiated newf *ir.Func // Func node for the new stenciled function ts typecheck.Tsubster @@ -669,7 +704,7 @@ type subster struct { // function type where the receiver becomes the first parameter. For either a generic // method or function, a dictionary parameter is the added as the very first // parameter. genericSubst fills in info.dictParam and info.tparamToBound. -func (g *irgen) genericSubst(newsym *types.Sym, nameNode *ir.Name, shapes []*types.Type, isMethod bool, info *instInfo) *ir.Func { +func (g *genInst) genericSubst(newsym *types.Sym, nameNode *ir.Name, shapes []*types.Type, isMethod bool, info *instInfo) *ir.Func { var tparams []*types.Type if isMethod { // Get the type params from the method receiver (after skipping @@ -1170,7 +1205,8 @@ func (subst *subster) node(n ir.Node) ir.Node { subst.newf = saveNewf ir.CurFunc = saveNewf - m = ir.UseClosure(newfn.OClosure, subst.g.target) + m = ir.UseClosure(newfn.OClosure, typecheck.Target) + subst.g.newInsts = append(subst.g.newInsts, m.(*ir.ClosureExpr).Func) m.(*ir.ClosureExpr).SetInit(subst.list(x.Init())) } @@ -1182,7 +1218,7 @@ func (subst *subster) node(n ir.Node) ir.Node { // dictPass takes a function instantiation and does the transformations on the // operations that need to make use of the dictionary param. -func (g *irgen) dictPass(info *instInfo) { +func (g *genInst) dictPass(info *instInfo) { savef := ir.CurFunc ir.CurFunc = info.fun @@ -1503,7 +1539,7 @@ func markTypeUsed(t *types.Type, lsym *obj.LSym) { // getDictionarySym returns the dictionary for the named generic function gf, which // is instantiated with the type arguments targs. -func (g *irgen) getDictionarySym(gf *ir.Name, targs []*types.Type, isMeth bool) *types.Sym { +func (g *genInst) getDictionarySym(gf *ir.Name, targs []*types.Type, isMeth bool) *types.Sym { if len(targs) == 0 { base.Fatalf("%s should have type arguments", gf.Sym().Name) } @@ -1678,7 +1714,7 @@ func (g *irgen) getDictionarySym(gf *ir.Name, targs []*types.Type, isMeth bool) // dictionaries and method instantiations to be complete, so, to avoid recursive // dependencies, we finalize the itab lsyms only after all dictionaries syms and // instantiations have been created. -func (g *irgen) finalizeSyms() { +func (g *genInst) finalizeSyms() { for _, d := range g.dictSymsToFinalize { infoPrint("=== Finalizing dictionary %s\n", d.sym.Name) @@ -1744,7 +1780,7 @@ func (g *irgen) finalizeSyms() { g.dictSymsToFinalize = nil } -func (g *irgen) getDictionaryValue(gf *ir.Name, targs []*types.Type, isMeth bool) ir.Node { +func (g *genInst) getDictionaryValue(gf *ir.Name, targs []*types.Type, isMeth bool) ir.Node { sym := g.getDictionarySym(gf, targs, isMeth) // Make (or reuse) a node referencing the dictionary symbol. @@ -1792,7 +1828,7 @@ func hasShapeTypes(targs []*types.Type) bool { // getInstInfo get the dictionary format for a function instantiation- type params, derived // types, and needed subdictionaries and itabs. -func (g *irgen) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instInfo) { +func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instInfo) { info := instInfo.dictInfo info.shapeParams = shapes @@ -2100,7 +2136,7 @@ func assertToBound(info *instInfo, dictVar *ir.Name, pos src.XPos, rcvr ir.Node, // // The returned closure is fully substituted and has already had any needed // transformations done. -func (g *irgen) buildClosure2(info *instInfo, m ir.Node) ir.Node { +func (g *genInst) buildClosure2(info *instInfo, m ir.Node) ir.Node { outer := info.fun pos := m.Pos() typ := m.Type() // type of the closure @@ -2155,5 +2191,5 @@ func (g *irgen) buildClosure2(info *instInfo, m ir.Node) ir.Node { ir.FinishCaptureNames(pos, outer, fn) // Do final checks on closure and return it. - return ir.UseClosure(fn.OClosure, g.target) + return ir.UseClosure(fn.OClosure, typecheck.Target) } diff --git a/src/cmd/compile/internal/typecheck/subr.go b/src/cmd/compile/internal/typecheck/subr.go index 6288d15a01..b3fc7459e1 100644 --- a/src/cmd/compile/internal/typecheck/subr.go +++ b/src/cmd/compile/internal/typecheck/subr.go @@ -1007,19 +1007,22 @@ func assert(p bool) { // List of newly fully-instantiated types who should have their methods generated. var instTypeList []*types.Type -// NeedInstType adds a new fully-instantied type to instTypeList. +// NeedInstType adds a new fully-instantiated type to instTypeList. func NeedInstType(t *types.Type) { instTypeList = append(instTypeList, t) } -// GetInstTypeList returns the current contents of instTypeList, and sets -// instTypeList to nil. +// GetInstTypeList returns the current contents of instTypeList. func GetInstTypeList() []*types.Type { r := instTypeList - instTypeList = nil return r } +// ClearInstTypeList clears the contents of instTypeList. +func ClearInstTypeList() { + instTypeList = nil +} + // General type substituter, for replacing typeparams with type args. type Tsubster struct { Tparams []*types.Type diff --git a/test/typeparam/geninline.dir/a.go b/test/typeparam/geninline.dir/a.go new file mode 100644 index 0000000000..fe5ba22f6e --- /dev/null +++ b/test/typeparam/geninline.dir/a.go @@ -0,0 +1,56 @@ +// Copyright 2021 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 a + +type IVal[T comparable] interface { + check(want T) +} + +type Val[T comparable] struct { + val T +} + +//go:noinline +func (l *Val[T]) check(want T) { + if l.val != want { + panic("hi") + } +} + +func Test1() { + var l Val[int] + if l.val != 0 { + panic("hi") + } + _ = IVal[int](&l) +} + +func Test2() { + var l Val[float64] + l.val = 3.0 + l.check(float64(3)) + _ = IVal[float64](&l) +} + +type privateVal[T comparable] struct { + val T +} + +//go:noinline +func (l *privateVal[T]) check(want T) { + if l.val != want { + panic("hi") + } +} + +type Outer struct { + val privateVal[string] +} + +func Test3() { + var o Outer + o.val.check("") + _ = IVal[string](&o.val) +} diff --git a/test/typeparam/geninline.dir/main.go b/test/typeparam/geninline.dir/main.go new file mode 100644 index 0000000000..6dc36ba8af --- /dev/null +++ b/test/typeparam/geninline.dir/main.go @@ -0,0 +1,16 @@ +// Copyright 2021 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 main + +import "a" + +// Testing inlining of functions that refer to instantiated exported and non-exported +// generic types. + +func main() { + a.Test1() + a.Test2() + a.Test3() +} diff --git a/test/typeparam/geninline.go b/test/typeparam/geninline.go new file mode 100644 index 0000000000..76930e5e4f --- /dev/null +++ b/test/typeparam/geninline.go @@ -0,0 +1,7 @@ +// rundir -G=3 + +// Copyright 2021 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 ignored From 8c99421f01aca303240a8f809bc65fa0c56db861 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 13 Oct 2021 18:50:06 -0700 Subject: [PATCH 032/406] cmd/compile/internal/types2: add debugging support for delayed actions Add a simple mechanism to provide formatted descriptions for delayed actions. The comment strings are printed when tracing is enabled and the delayed action is executed. This results in more easily decipherable tracing output. Requires debug mode in order to minimize the overhead during normal execution. Use the mechanism in a few places to show typical use. Also cleaned up a few unrelated comments. Change-Id: Ic273c380c3963341500396ec62b694d143c25de2 Reviewed-on: https://go-review.googlesource.com/c/go/+/355871 Trust: Robert Griesemer Run-TryBot: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/check.go | 40 +++++++++++++++++-- src/cmd/compile/internal/types2/decl.go | 2 +- .../compile/internal/types2/instantiate.go | 3 +- src/cmd/compile/internal/types2/interface.go | 2 +- src/cmd/compile/internal/types2/struct.go | 2 +- src/cmd/compile/internal/types2/typexpr.go | 2 - 6 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/cmd/compile/internal/types2/check.go b/src/cmd/compile/internal/types2/check.go index d89ec3d29f..470376f8e8 100644 --- a/src/cmd/compile/internal/types2/check.go +++ b/src/cmd/compile/internal/types2/check.go @@ -74,6 +74,28 @@ type dotImportKey struct { name string } +// An action describes a (delayed) action. +type action struct { + f func() // action to be executed + desc *actionDesc // action description; may be nil, requires debug to be set +} + +// If debug is set, describef sets a printf-formatted description for action a. +// Otherwise, it is a no-op. +func (a *action) describef(pos poser, format string, args ...interface{}) { + if debug { + a.desc = &actionDesc{pos, format, args} + } +} + +// An actionDesc provides information on an action. +// For debugging only. +type actionDesc struct { + pos poser + format string + args []interface{} +} + // A Checker maintains the state of the type checker. // It must be created with NewChecker. type Checker struct { @@ -108,7 +130,7 @@ type Checker struct { firstErr error // first error encountered methods map[*TypeName][]*Func // maps package scope type names to associated non-blank (non-interface) methods untyped map[syntax.Expr]exprInfo // map of expressions without final type - delayed []func() // stack of delayed action segments; segments are processed in FIFO order + delayed []action // stack of delayed action segments; segments are processed in FIFO order objPath []Object // path of object dependencies during type inference (for cycle reporting) // context within which the current object is type-checked @@ -144,8 +166,12 @@ func (check *Checker) rememberUntyped(e syntax.Expr, lhs bool, mode operandMode, // either at the end of the current statement, or in case of a local constant // or variable declaration, before the constant or variable is in scope // (so that f still sees the scope before any new declarations). -func (check *Checker) later(f func()) { - check.delayed = append(check.delayed, f) +// later returns the pushed action so one can provide a description +// via action.describef for debugging, if desired. +func (check *Checker) later(f func()) *action { + i := len(check.delayed) + check.delayed = append(check.delayed, action{f: f}) + return &check.delayed[i] } // push pushes obj onto the object path and returns its index in the path. @@ -259,6 +285,7 @@ func (check *Checker) checkFiles(files []*syntax.File) (err error) { print := func(msg string) { if check.conf.Trace { + fmt.Println() fmt.Println(msg) } } @@ -309,7 +336,12 @@ func (check *Checker) processDelayed(top int) { // add more actions (such as nested functions), so // this is a sufficiently bounded process. for i := top; i < len(check.delayed); i++ { - check.delayed[i]() // may append to check.delayed + a := &check.delayed[i] + if check.conf.Trace && a.desc != nil { + fmt.Println() + check.trace(a.desc.pos.Pos(), "-- "+a.desc.format, a.desc.args...) + } + a.f() // may append to check.delayed } assert(top <= len(check.delayed)) // stack must not have shrunk check.delayed = check.delayed[:top] diff --git a/src/cmd/compile/internal/types2/decl.go b/src/cmd/compile/internal/types2/decl.go index 9fd60d6aa2..a605057579 100644 --- a/src/cmd/compile/internal/types2/decl.go +++ b/src/cmd/compile/internal/types2/decl.go @@ -557,7 +557,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *Named if check.isImportedConstraint(rhs) && !check.allowVersion(check.pkg, 1, 18) { check.errorf(tdecl.Type.Pos(), "using type constraint %s requires go1.18 or later", rhs) } - }) + }).describef(obj, "validType(%s)", obj.Name()) alias := tdecl.Alias if alias && tdecl.TParamList != nil { diff --git a/src/cmd/compile/internal/types2/instantiate.go b/src/cmd/compile/internal/types2/instantiate.go index 5da371f201..5e45ea33ce 100644 --- a/src/cmd/compile/internal/types2/instantiate.go +++ b/src/cmd/compile/internal/types2/instantiate.go @@ -63,7 +63,6 @@ func (check *Checker) instantiate(pos syntax.Pos, typ Type, targs []Type, posLis if res != nil { // Calling under() here may lead to endless instantiations. // Test case: type T[P any] T[P] - // TODO(gri) investigate if that's a bug or to be expected. under = safeUnderlying(res) } check.trace(pos, "=> %s (under = %s)", res, under) @@ -115,7 +114,7 @@ func (check *Checker) instance(pos syntax.Pos, typ Type, targs []Type, ctxt *Con } } tname := NewTypeName(pos, t.obj.pkg, t.obj.name, nil) - named := check.newNamed(tname, t, nil, nil, nil) // methods and tparams are set when named is resolved + named := check.newNamed(tname, t, nil, nil, nil) // underlying, tparams, and methods are set when named is resolved named.targs = NewTypeList(targs) named.resolver = func(ctxt *Context, n *Named) (*TypeParamList, Type, []*Func) { return expandNamed(ctxt, n, pos) diff --git a/src/cmd/compile/internal/types2/interface.go b/src/cmd/compile/internal/types2/interface.go index 0879d29d3d..0704628dc6 100644 --- a/src/cmd/compile/internal/types2/interface.go +++ b/src/cmd/compile/internal/types2/interface.go @@ -172,7 +172,7 @@ func (check *Checker) interfaceType(ityp *Interface, iface *syntax.InterfaceType check.later(func() { computeInterfaceTypeSet(check, iface.Pos(), ityp) ityp.check = nil - }) + }).describef(iface, "compute type set for %s", ityp) } func flattenUnion(list []syntax.Expr, x syntax.Expr) []syntax.Expr { diff --git a/src/cmd/compile/internal/types2/struct.go b/src/cmd/compile/internal/types2/struct.go index f0c27c0150..933d7ef947 100644 --- a/src/cmd/compile/internal/types2/struct.go +++ b/src/cmd/compile/internal/types2/struct.go @@ -154,7 +154,7 @@ func (check *Checker) structType(styp *Struct, e *syntax.StructType) { check.error(embeddedPos, "embedded field type cannot be a pointer to an interface") } } - }) + }).describef(embeddedPos, "check embedded type %s", embeddedTyp) } } diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go index 746fe78b38..646becbdae 100644 --- a/src/cmd/compile/internal/types2/typexpr.go +++ b/src/cmd/compile/internal/types2/typexpr.go @@ -214,8 +214,6 @@ func (check *Checker) typInternal(e0 syntax.Expr, def *Named) (T Type) { if T != nil { // Calling under() here may lead to endless instantiations. // Test case: type T[P any] *T[P] - // TODO(gri) investigate if that's a bug or to be expected - // (see also analogous comment in Checker.instantiate). under = safeUnderlying(T) } if T == under { From 8331f25e96d6120bb0ec212bd03abcae53282769 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Wed, 15 Sep 2021 09:56:09 -0700 Subject: [PATCH 033/406] reflect: make Elem panic on bad notinheap pointers This CL fixes the subtle issue that Elem can promote a not-in-heap pointer, which could be any bit pattern, into an unsafe.Pointer, which the garbage collector can see. If that resulting value is bad, it can crash the GC. Make sure that we don't introduce bad pointers that way. We can make Elem() panic, because any such bad pointers are in the Go heap, and not-in-heap pointers are not allowed to point into the Go heap. Update #48399 Change-Id: Ieaf35a611b16b4dfb5e907e229ed4a2aed30e18c Reviewed-on: https://go-review.googlesource.com/c/go/+/350153 Trust: Keith Randall Trust: Ian Lance Taylor Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/reflect/all_test.go | 20 ++++++++++++++++++++ src/reflect/value.go | 17 +++++++++++++++++ src/runtime/mbitmap.go | 9 +++++++++ 3 files changed, 46 insertions(+) diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 427855b02e..8642d60f8b 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -7697,3 +7697,23 @@ func TestSetIter(t *testing.T) { t.Errorf("pointer incorrect: got %d want %d", got, b) } } + +//go:notinheap +type nih struct{ x int } + +var global_nih = nih{x: 7} + +func TestNotInHeapDeref(t *testing.T) { + // See issue 48399. + v := ValueOf((*nih)(nil)) + v.Elem() + shouldPanic("reflect: call of reflect.Value.Field on zero Value", func() { v.Elem().Field(0) }) + + v = ValueOf(&global_nih) + if got := v.Elem().Field(0).Int(); got != 7 { + t.Fatalf("got %d, want 7", got) + } + + v = ValueOf((*nih)(unsafe.Pointer(new(int)))) + shouldPanic("reflect: reflect.Value.Elem on an invalid notinheap pointer", func() { v.Elem() }) +} diff --git a/src/reflect/value.go b/src/reflect/value.go index abcc346de8..449f3bbb3c 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -1169,6 +1169,21 @@ func (v Value) Elem() Value { case Ptr: ptr := v.ptr if v.flag&flagIndir != 0 { + if ifaceIndir(v.typ) { + // This is a pointer to a not-in-heap object. ptr points to a uintptr + // in the heap. That uintptr is the address of a not-in-heap object. + // In general, pointers to not-in-heap objects can be total junk. + // But Elem() is asking to dereference it, so the user has asserted + // that at least it is a valid pointer (not just an integer stored in + // a pointer slot). So let's check, to make sure that it isn't a pointer + // that the runtime will crash on if it sees it during GC or write barriers. + // Since it is a not-in-heap pointer, all pointers to the heap are + // forbidden! That makes the test pretty easy. + // See issue 48399. + if !verifyNotInHeapPtr(*(*uintptr)(ptr)) { + panic("reflect: reflect.Value.Elem on an invalid notinheap pointer") + } + } ptr = *(*unsafe.Pointer)(ptr) } // The returned value's address is v's value. @@ -3406,6 +3421,8 @@ func typedslicecopy(elemType *rtype, dst, src unsafeheader.Slice) int //go:noescape func typehash(t *rtype, p unsafe.Pointer, h uintptr) uintptr +func verifyNotInHeapPtr(p uintptr) bool + // Dummy annotation marking that the value x escapes, // for use in cases where the reflect code is so clever that // the compiler cannot follow. diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go index daf1fcfbc0..3330ddd62e 100644 --- a/src/runtime/mbitmap.go +++ b/src/runtime/mbitmap.go @@ -417,6 +417,15 @@ func findObject(p, refBase, refOff uintptr) (base uintptr, s *mspan, objIndex ui return } +// verifyNotInHeapPtr reports whether converting the not-in-heap pointer into a unsafe.Pointer is ok. +//go:linkname reflect_verifyNotInHeapPtr reflect.verifyNotInHeapPtr +func reflect_verifyNotInHeapPtr(p uintptr) bool { + // Conversion to a pointer is ok as long as findObject above does not call badPointer. + // Since we're already promised that p doesn't point into the heap, just disallow heap + // pointers and the special clobbered pointer. + return spanOf(p) == nil && p != clobberdeadPtr +} + // next returns the heapBits describing the next pointer-sized word in memory. // That is, if h describes address p, h.next() describes p+ptrSize. // Note that next does not modify h. The caller must record the result. From cfe6763783615233ec7ae863784b898718d14c40 Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Wed, 13 Oct 2021 16:49:27 -0400 Subject: [PATCH 034/406] internal/fuzz: fix bugs with minimization This pulls in some code and tests from CL 353355. This change makes some refactors for when we read to and write from memory during minimization. That fixes a bug when minimizing interesting inputs. Now, if an error occurs while minimizing an interesting input, that value will continue to be minimized as a crash, and returned to the user. This change also allows minimization of a crash that occurred during the warmup phase. We don't want to minimize failures in the seed corpus, but if an entry in the cache causes a new failure, then there's no compelling reason why we shouldn't try to minimize it. Fixes #48731 Change-Id: I7262cecd8ea7ae6fdf932f3a36db55fb062a1f2a Reviewed-on: https://go-review.googlesource.com/c/go/+/355691 Trust: Katie Hockman Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Roland Shoemaker --- .../go/testdata/script/test_fuzz_minimize.txt | 116 +++++++++++------- .../testdata/script/test_fuzz_seed_corpus.txt | 38 +++++- src/internal/fuzz/fuzz.go | 6 +- src/internal/fuzz/minimize_test.go | 13 +- src/internal/fuzz/worker.go | 71 ++++++----- 5 files changed, 153 insertions(+), 91 deletions(-) diff --git a/src/cmd/go/testdata/script/test_fuzz_minimize.txt b/src/cmd/go/testdata/script/test_fuzz_minimize.txt index 0a0359fabb..56abc68104 100644 --- a/src/cmd/go/testdata/script/test_fuzz_minimize.txt +++ b/src/cmd/go/testdata/script/test_fuzz_minimize.txt @@ -7,56 +7,72 @@ env GOCACHE=$WORK/gocache # Test that fuzzminimizetime cannot be negative seconds -! go test -fuzz=FuzzMinimizerRecoverable -run=FuzzMinimizerRecoverable -fuzztime=10000x -fuzzminimizetime=-1ms minimizer_test.go +! go test -fuzz=FuzzMinimizerRecoverable -run=FuzzMinimizerRecoverable -fuzztime=10000x -fuzzminimizetime=-1ms . ! stdout '^ok' ! stdout 'contains a non-zero byte' stdout 'invalid duration' stdout FAIL # Test that fuzzminimizetime cannot be negative times -! go test -fuzz=FuzzMinimizerRecoverable -run=FuzzMinimizerRecoverable -fuzztime=10000x -fuzzminimizetime=-1x minimizer_test.go +! go test -fuzz=FuzzMinimizerRecoverable -run=FuzzMinimizerRecoverable -fuzztime=10000x -fuzzminimizetime=-1x . ! stdout '^ok' ! stdout 'contains a non-zero byte' stdout 'invalid count' stdout FAIL # Test that fuzzminimizetime can be zero seconds, and minimization is disabled -! go test -fuzz=FuzzMinimizeZeroDurationSet -run=FuzzMinimizeZeroDurationSet -fuzztime=10000x -fuzzminimizetime=0s minimizer_test.go +! go test -fuzz=FuzzMinimizeZeroDurationSet -run=FuzzMinimizeZeroDurationSet -fuzztime=10000x -fuzzminimizetime=0s . ! stdout '^ok' ! stdout 'minimizing' stdout 'there was an Error' stdout FAIL # Test that fuzzminimizetime can be zero times, and minimization is disabled -! go test -fuzz=FuzzMinimizeZeroLimitSet -run=FuzzMinimizeZeroLimitSet -fuzztime=10000x -fuzzminimizetime=0x minimizer_test.go +! go test -fuzz=FuzzMinimizeZeroLimitSet -run=FuzzMinimizeZeroLimitSet -fuzztime=10000x -fuzzminimizetime=0x . ! stdout '^ok' ! stdout 'minimizing' stdout 'there was an Error' stdout FAIL -# Test that minimization is working for recoverable errors. -! go test -fuzz=FuzzMinimizerRecoverable -run=FuzzMinimizerRecoverable -fuzztime=10000x minimizer_test.go +# Test that minimization occurs for a crash that appears while minimizing a +# newly found interesting input. There must be only one worker for this test to +# be flaky like we want. +! go test -fuzz=FuzzMinimizerCrashInMinimization -run=FuzzMinimizerCrashInMinimization -fuzztime=10000x -parallel=1 . ! stdout '^ok' stdout 'got the minimum size!' -stdout 'contains a non-zero byte' +stdout 'flaky failure' +stdout FAIL + +# Make sure the crash that was written will fail when run with go test +! go test -run=FuzzMinimizerCrashInMinimization . + +# Clear testdata. +rm testdata + +# Test that minimization is working for recoverable errors. +! go test -fuzz=FuzzMinimizerRecoverable -run=FuzzMinimizerRecoverable -fuzztime=10000x . +! stdout '^ok' +stdout 'got the minimum size!' +# The error message that was printed should be for the one written to testdata. +stdout 'contains a non-zero byte of length 50' stdout FAIL # Check that the bytes written to testdata are of length 50 (the minimum size) -go run check_testdata.go FuzzMinimizerRecoverable 50 +go run ./check_testdata FuzzMinimizerRecoverable 50 # Test that re-running the minimized value causes a crash. -! go test -run=FuzzMinimizerRecoverable minimizer_test.go +! go test -run=FuzzMinimizerRecoverable . rm testdata # Test that minimization doesn't run for non-recoverable errors. -! go test -fuzz=FuzzMinimizerNonrecoverable -run=FuzzMinimizerNonrecoverable -fuzztime=10000x minimizer_test.go +! go test -fuzz=FuzzMinimizerNonrecoverable -run=FuzzMinimizerNonrecoverable -fuzztime=10000x . ! stdout '^ok' ! stdout 'minimizing' stdout 'fuzzing process terminated unexpectedly: exit status 99' stdout FAIL # Check that re-running the value causes a crash. -! go test -run=FuzzMinimizerNonrecoverable minimizer_test.go +! go test -run=FuzzMinimizerNonrecoverable . rm testdata # Clear the fuzzing cache. There may already be minimized inputs that would @@ -65,35 +81,43 @@ go clean -fuzzcache # Test that minimization can be cancelled by fuzzminimizetime and the latest # crash will still be logged and written to testdata. -! go test -fuzz=FuzzMinimizerRecoverable -run=FuzzMinimizerRecoverable -fuzztime=100x -fuzzminimizetime=1x minimizer_test.go +! go test -fuzz=FuzzMinimizerRecoverable -run=FuzzMinimizerRecoverable -fuzztime=100x -fuzzminimizetime=1x . ! stdout '^ok' stdout 'testdata[/\\]fuzz[/\\]FuzzMinimizerRecoverable[/\\]' ! stdout 'got the minimum size!' # it shouldn't have had enough time to minimize it stdout FAIL # Test that re-running the unminimized value causes a crash. -! go test -run=FuzzMinimizerRecoverable minimizer_test.go - -! go test -fuzz=FuzzMinimizerTooSlow -run=FuzzMinimizerTooSlow -fuzzminimizetime=3s minimizer_test.go -stdout 'fuzz: minimizing' -stdout 'fuzz: elapsed: \d+s, minimizing' -stdout 'testdata[/\\]fuzz[/\\]FuzzMinimizerTooSlow[/\\]' -stdout FAIL +! go test -run=FuzzMinimizerRecoverable . # TODO(jayconrod,katiehockman): add a test which verifies that the right bytes # are written to testdata in the case of an interrupt during minimization. -- go.mod -- -module m +module example.com/y go 1.16 --- minimizer_test.go -- -package fuzz_test +-- y.go -- +package y import ( + "bytes" + "io" +) + +func Y(w io.Writer, b []byte) { + if !bytes.Equal(b, []byte("y")) { + w.Write([]byte("not equal")) + } +} +-- y_test.go -- +package y + +import ( + "bytes" + "io" "os" "testing" - "time" ) func FuzzMinimizeZeroDurationSet(f *testing.F) { @@ -126,42 +150,42 @@ func FuzzMinimizerRecoverable(f *testing.F) { if len(b) == 50 { t.Log("got the minimum size!") } - t.Fatal("contains a non-zero byte") + t.Fatalf("contains a non-zero byte of length %d", len(b)) } } }) } func FuzzMinimizerNonrecoverable(f *testing.F) { - f.Add(make([]byte, 100)) f.Fuzz(func(t *testing.T, b []byte) { - if len(b) < 50 { + os.Exit(99) + }) +} + +func FuzzMinimizerCrashInMinimization(f *testing.F) { + seed := make([]byte, 1000) + f.Add(seed) + f.Fuzz(func(t *testing.T, b []byte) { + if len(b) < 50 || len(b) > 1100 { // Make sure that b is large enough that it can be minimized return } - // Given the randomness of the mutations, this should allow the - // minimizer to trim down the value a bit. - for _, n := range b { - if n != 0 { - t.Log("contains a non-zero byte") - os.Exit(99) - } + if !bytes.Equal(b, seed) { + // This should have hit a new edge, and the interesting input + // should be attempting minimization + Y(io.Discard, b) + } + if len(b) < 350 { + t.Error("flaky failure") + } + if len(b) == 50 { + t.Log("got the minimum size!") } }) } - -func FuzzMinimizerTooSlow(f *testing.F) { - f.Fuzz(func(t *testing.T, b []byte) { - if len(b) > 50 { - t.Error("error here") - time.Sleep(2 * time.Second) - } - }) -} - --- check_testdata.go -- -// +build ignore - +-- empty/empty.go -- +package empty +-- check_testdata/check_testdata.go -- package main import ( diff --git a/src/cmd/go/testdata/script/test_fuzz_seed_corpus.txt b/src/cmd/go/testdata/script/test_fuzz_seed_corpus.txt index 5d04d8c022..18f634a3b6 100644 --- a/src/cmd/go/testdata/script/test_fuzz_seed_corpus.txt +++ b/src/cmd/go/testdata/script/test_fuzz_seed_corpus.txt @@ -47,6 +47,23 @@ cp cache-file $GOCACHE/fuzz/example.com/x/FuzzWithCache/1 stdout 'Crash written to testdata[/\\]fuzz[/\\]FuzzWithCache[/\\]' stdout FAIL +# Write a crashing input to the cache +mkdir $GOCACHE/fuzz/example.com/x/FuzzWithMinimizableCache +cp cache-file-bytes $GOCACHE/fuzz/example.com/x/FuzzWithMinimizableCache/1 + +# Test that fuzzing a target with a failure in the cache minimizes it and writes +# the new crash to testdata/fuzz +! go test -fuzz=FuzzWithMinimizableCache -run=FuzzWithMinimizableCache -fuzztime=10000x +! stdout ^ok +stdout 'gathering baseline coverage' +stdout 'got the minimum size!' +stdout 'contains a non-zero byte of length 10' +stdout 'Crash written to testdata[/\\]fuzz[/\\]FuzzWithMinimizableCache[/\\]' +stdout FAIL +# Make sure this crash didn't come from fuzzing +# (the log line that states fuzzing began shouldn't have printed) +! stdout 'execs' + # Clear the fuzz cache and make sure it's gone go clean -fuzzcache ! exists $GOCACHE/fuzz @@ -158,6 +175,22 @@ func FuzzWithCache(f *testing.F) { }) } +func FuzzWithMinimizableCache(f *testing.F) { + f.Fuzz(func(t *testing.T, b []byte) { + if len(b) < 10 { + return + } + for _, n := range b { + if n != 0 { + if len(b) == 10 { + t.Log("got the minimum size!") + } + t.Fatalf("contains a non-zero byte of length %d", len(b)) + } + } + }) +} + func FuzzRunNoneWithCache(f *testing.F) { f.Fuzz(func(t *testing.T, i int) { if i == 10 { @@ -170,4 +203,7 @@ go test fuzz v1 int(10) -- cache-file -- go test fuzz v1 -int(10) \ No newline at end of file +int(10) +-- cache-file-bytes -- +go test fuzz v1 +[]byte("11111111111111111111") \ No newline at end of file diff --git a/src/internal/fuzz/fuzz.go b/src/internal/fuzz/fuzz.go index 03071d5521..5b3819be75 100644 --- a/src/internal/fuzz/fuzz.go +++ b/src/internal/fuzz/fuzz.go @@ -875,12 +875,10 @@ func (c *coordinator) updateCoverage(newCoverage []byte) int { } // canMinimize returns whether the coordinator should attempt to find smaller -// inputs that reproduce a crash or new coverage. It shouldn't do this if it -// is in the warmup phase. +// inputs that reproduce a crash or new coverage. func (c *coordinator) canMinimize() bool { return c.minimizationAllowed && - (c.opts.Limit == 0 || c.count+c.countWaiting < c.opts.Limit) && - !c.warmupRun() + (c.opts.Limit == 0 || c.count+c.countWaiting < c.opts.Limit) } func (c *coordinator) elapsed() time.Duration { diff --git a/src/internal/fuzz/minimize_test.go b/src/internal/fuzz/minimize_test.go index 410b78310b..dd76baff51 100644 --- a/src/internal/fuzz/minimize_test.go +++ b/src/internal/fuzz/minimize_test.go @@ -262,13 +262,12 @@ func TestMinimizeInput(t *testing.T) { } } -// TestMinimizeInputCoverageError checks that if we're minimizing an interesting -// input (one that we don't expect to cause an error), and the fuzz function -// returns an error, minimizing fails, and we return the error quickly. -func TestMinimizeInputCoverageError(t *testing.T) { - errOhNo := errors.New("ohno") +// TestMinimizeFlaky checks that if we're minimizing an interesting +// input and a flaky failure occurs, that minimization was not indicated +// to be successful, and the error isn't returned (since it's flaky). +func TestMinimizeFlaky(t *testing.T) { ws := &workerServer{fuzzFn: func(e CorpusEntry) error { - return errOhNo + return errors.New("ohno") }} keepCoverage := make([]byte, len(coverageSnapshot)) count := int64(0) @@ -277,7 +276,7 @@ func TestMinimizeInputCoverageError(t *testing.T) { if success { t.Error("unexpected success") } - if err != errOhNo { + if err != nil { t.Errorf("unexpected error: %v", err) } if count != 1 { diff --git a/src/internal/fuzz/worker.go b/src/internal/fuzz/worker.go index 0c428ed832..e3827b112a 100644 --- a/src/internal/fuzz/worker.go +++ b/src/internal/fuzz/worker.go @@ -261,8 +261,8 @@ func (w *worker) minimize(ctx context.Context, input fuzzMinimizeInput) (min fuz return fuzzResult{}, fmt.Errorf("fuzzing process terminated unexpectedly while minimizing: %w", w.waitErr) } - if input.crasherMsg != "" && resp.Err == "" && !resp.Success { - return fuzzResult{}, fmt.Errorf("attempted to minimize but could not reproduce") + if input.crasherMsg != "" && resp.Err == "" { + return fuzzResult{}, fmt.Errorf("attempted to minimize a crash but could not reproduce") } return fuzzResult{ @@ -509,12 +509,11 @@ type minimizeArgs struct { // minimizeResponse contains results from workerServer.minimize. type minimizeResponse struct { - // Success is true if the worker found a smaller input, stored in shared - // memory, that was "interesting" for the same reason as the original input. - // If minimizeArgs.KeepCoverage was set, the minimized input preserved at - // least one coverage bit and did not cause an error. Otherwise, the - // minimized input caused some error, recorded in Err. - Success bool + // WroteToMem is true if the worker found a smaller input and wrote it to + // shared memory. If minimizeArgs.KeepCoverage was set, the minimized input + // preserved at least one coverage bit and did not cause an error. + // Otherwise, the minimized input caused some error, recorded in Err. + WroteToMem bool // Err is the error string caused by the value in shared memory, if any. Err string @@ -777,32 +776,31 @@ func (ws *workerServer) minimize(ctx context.Context, args minimizeArgs) (resp m } // Minimize the values in vals, then write to shared memory. We only write - // to shared memory after completing minimization. If the worker terminates - // unexpectedly before then, the coordinator will use the original input. - resp.Success, err = ws.minimizeInput(ctx, vals, &mem.header().count, args.Limit, args.KeepCoverage) - if resp.Success { + // to shared memory after completing minimization. + // TODO(48165): If the worker terminates unexpectedly during minimization, + // the coordinator has no way of retrieving the crashing input. + success, err := ws.minimizeInput(ctx, vals, &mem.header().count, args.Limit, args.KeepCoverage) + if success { writeToMem(vals, mem) - } - if err != nil { - resp.Err = err.Error() - } else if resp.Success { - resp.CoverageData = coverageSnapshot + resp.WroteToMem = true + if err != nil { + resp.Err = err.Error() + } else { + resp.CoverageData = coverageSnapshot + } } return resp } // minimizeInput applies a series of minimizing transformations on the provided -// vals, ensuring that each minimization still causes an error in fuzzFn. Before -// every call to fuzzFn, it marshals the new vals and writes it to the provided -// mem just in case an unrecoverable error occurs. It uses the context to -// determine how long to run, stopping once closed. It returns a bool -// indicating whether minimization was successful and an error if one was found. +// vals, ensuring that each minimization still causes an error in fuzzFn. It +// uses the context to determine how long to run, stopping once closed. It +// returns a bool indicating whether minimization was successful and an error if +// one was found. func (ws *workerServer) minimizeInput(ctx context.Context, vals []interface{}, count *int64, limit int64, keepCoverage []byte) (success bool, retErr error) { - wantError := keepCoverage == nil shouldStop := func() bool { return ctx.Err() != nil || - (limit > 0 && *count >= limit) || - (retErr != nil && !wantError) + (limit > 0 && *count >= limit) } if shouldStop() { return false, nil @@ -812,11 +810,12 @@ func (ws *workerServer) minimizeInput(ctx context.Context, vals []interface{}, c // If not, then whatever caused us to think the value was interesting may // have been a flake, and we can't minimize it. *count++ - if retErr = ws.fuzzFn(CorpusEntry{Values: vals}); retErr == nil && wantError { - return false, nil - } else if retErr != nil && !wantError { - return false, retErr - } else if keepCoverage != nil && !hasCoverageBit(keepCoverage, coverageSnapshot) { + retErr = ws.fuzzFn(CorpusEntry{Values: vals}) + if keepCoverage != nil { + if !hasCoverageBit(keepCoverage, coverageSnapshot) || retErr != nil { + return false, nil + } + } else if retErr == nil { return false, nil } @@ -881,7 +880,13 @@ func (ws *workerServer) minimizeInput(ctx context.Context, vals []interface{}, c err := ws.fuzzFn(CorpusEntry{Values: vals}) if err != nil { retErr = err - return wantError + if keepCoverage != nil { + // Now that we've found a crash, that's more important than any + // minimization of interesting inputs that was being done. Clear out + // keepCoverage to only minimize the crash going forward. + keepCoverage = nil + } + return true } if keepCoverage != nil && hasCoverageBit(keepCoverage, coverageSnapshot) { return true @@ -939,7 +944,7 @@ func (ws *workerServer) minimizeInput(ctx context.Context, vals []interface{}, c panic("unreachable") } } - return (wantError || retErr == nil), retErr + return true, retErr } func writeToMem(vals []interface{}, mem *sharedMem) { @@ -1024,7 +1029,7 @@ func (wc *workerClient) minimize(ctx context.Context, entryIn CorpusEntry, args } defer func() { wc.memMu <- mem }() resp.Count = mem.header().count - if resp.Success { + if resp.WroteToMem { entryOut.Data = mem.valueCopy() entryOut.Values, err = unmarshalCorpusFile(entryOut.Data) h := sha256.Sum256(entryOut.Data) From 22951fbc89a1bc3c5cc38f4e71b4a682f5149361 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Fri, 15 Oct 2021 08:06:58 -0700 Subject: [PATCH 035/406] cmd/compile: make for loops with range statements not terminating Fixes #49003 Change-Id: If09c6f028dce5440b1be238612653ffdd626113a Reviewed-on: https://go-review.googlesource.com/c/go/+/356189 Trust: Keith Randall Reviewed-by: roger peppe Reviewed-by: Matthew Dempsky Reviewed-by: Robert Griesemer Reviewed-by: Cuong Manh Le --- doc/go_spec.html | 5 +++-- src/cmd/compile/internal/types2/return.go | 5 +++++ test/fixedbugs/issue49003.go | 12 ++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 test/fixedbugs/issue49003.go diff --git a/doc/go_spec.html b/doc/go_spec.html index c8051f58af..46eebb5713 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -4598,7 +4598,8 @@ a block. The following statements are terminating: A "for" statement in which:

  • there are no "break" statements referring to the "for" statement, and
  • -
  • the loop condition is absent.
  • +
  • the loop condition is absent, and
  • +
  • the "for" statement does not use a range clause.
diff --git a/src/cmd/compile/internal/types2/return.go b/src/cmd/compile/internal/types2/return.go index 204e456a91..6c3e1842ce 100644 --- a/src/cmd/compile/internal/types2/return.go +++ b/src/cmd/compile/internal/types2/return.go @@ -62,6 +62,11 @@ func (check *Checker) isTerminating(s syntax.Stmt, label string) bool { return true case *syntax.ForStmt: + if _, ok := s.Init.(*syntax.RangeClause); ok { + // Range clauses guarantee that the loop terminates, + // so the loop is not a terminating statement. See issue 49003. + break + } if s.Cond == nil && !hasBreak(s.Body, label, true) { return true } diff --git a/test/fixedbugs/issue49003.go b/test/fixedbugs/issue49003.go new file mode 100644 index 0000000000..da6c19b8cb --- /dev/null +++ b/test/fixedbugs/issue49003.go @@ -0,0 +1,12 @@ +// errorcheck + +// Copyright 2021 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 p + +func f(s string) int { + for range s { + } +} // ERROR "missing return" From a17b2e865551ebdeccd6aafcdc23c1b63932b258 Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Fri, 15 Oct 2021 11:57:58 -0700 Subject: [PATCH 036/406] cmd/go: allow nested VCS repositories when preparing build stamp The go command no longer reports an error when invoked in a repository nested inside another. This check is still used by 'go get' in GOPATH mode when locating a repository, but it's not needed when preparing the build stamp. Fixes #49004 Change-Id: I4ed4dcc04174d2d42da8651d47e52ab1d7d66e35 Reviewed-on: https://go-review.googlesource.com/c/go/+/356309 Trust: Jay Conrod Run-TryBot: Jay Conrod Reviewed-by: Bryan C. Mills TryBot-Result: Go Bot --- src/cmd/go/internal/get/get.go | 3 ++- src/cmd/go/internal/load/pkg.go | 7 ++++--- src/cmd/go/internal/vcs/vcs.go | 11 ++++++++--- src/cmd/go/internal/vcs/vcs_test.go | 2 +- .../script/version_buildvcs_nested.txt | 19 ++++++++++--------- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/cmd/go/internal/get/get.go b/src/cmd/go/internal/get/get.go index c96459297a..0412506b9e 100644 --- a/src/cmd/go/internal/get/get.go +++ b/src/cmd/go/internal/get/get.go @@ -446,7 +446,8 @@ func downloadPackage(p *load.Package) error { if p.Internal.Build.SrcRoot != "" { // Directory exists. Look for checkout along path to src. - repoDir, vcsCmd, err = vcs.FromDir(p.Dir, p.Internal.Build.SrcRoot) + const allowNesting = false + repoDir, vcsCmd, err = vcs.FromDir(p.Dir, p.Internal.Build.SrcRoot, allowNesting) if err != nil { return err } diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 58dc242383..99c4a9c62e 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -2318,8 +2318,9 @@ func (p *Package) setBuildInfo() { var repoDir string var vcsCmd *vcs.Cmd var err error + const allowNesting = true if cfg.BuildBuildvcs && p.Module != nil && p.Module.Version == "" && !p.Standard { - repoDir, vcsCmd, err = vcs.FromDir(base.Cwd(), "") + repoDir, vcsCmd, err = vcs.FromDir(base.Cwd(), "", allowNesting) if err != nil && !errors.Is(err, os.ErrNotExist) { setVCSError(err) return @@ -2338,7 +2339,7 @@ func (p *Package) setBuildInfo() { // repository. vcs.FromDir allows nested Git repositories, but nesting // is not allowed for other VCS tools. The current directory may be outside // p.Module.Dir when a workspace is used. - pkgRepoDir, _, err := vcs.FromDir(p.Dir, "") + pkgRepoDir, _, err := vcs.FromDir(p.Dir, "", allowNesting) if err != nil { setVCSError(err) return @@ -2347,7 +2348,7 @@ func (p *Package) setBuildInfo() { setVCSError(fmt.Errorf("main package is in repository %q but current directory is in repository %q", pkgRepoDir, repoDir)) return } - modRepoDir, _, err := vcs.FromDir(p.Module.Dir, "") + modRepoDir, _, err := vcs.FromDir(p.Module.Dir, "", allowNesting) if err != nil { setVCSError(err) return diff --git a/src/cmd/go/internal/vcs/vcs.go b/src/cmd/go/internal/vcs/vcs.go index ebb4850443..d1272b66e9 100644 --- a/src/cmd/go/internal/vcs/vcs.go +++ b/src/cmd/go/internal/vcs/vcs.go @@ -603,7 +603,7 @@ type vcsPath struct { // version control system and code repository to use. // If no repository is found, FromDir returns an error // equivalent to os.ErrNotExist. -func FromDir(dir, srcRoot string) (repoDir string, vcsCmd *Cmd, err error) { +func FromDir(dir, srcRoot string, allowNesting bool) (repoDir string, vcsCmd *Cmd, err error) { // Clean and double-check that dir is in (a subdirectory of) srcRoot. dir = filepath.Clean(dir) if srcRoot != "" { @@ -617,11 +617,16 @@ func FromDir(dir, srcRoot string) (repoDir string, vcsCmd *Cmd, err error) { for len(dir) > len(srcRoot) { for _, vcs := range vcsList { if _, err := os.Stat(filepath.Join(dir, "."+vcs.Cmd)); err == nil { - // Record first VCS we find, but keep looking, - // to detect mistakes like one kind of VCS inside another. + // Record first VCS we find. + // If allowNesting is false (as it is in GOPATH), keep looking for + // repositories in parent directories and report an error if one is + // found to mitigate VCS injection attacks. if vcsCmd == nil { vcsCmd = vcs repoDir = dir + if allowNesting { + return repoDir, vcsCmd, nil + } continue } // Allow .git inside .git, which can arise due to submodules. diff --git a/src/cmd/go/internal/vcs/vcs_test.go b/src/cmd/go/internal/vcs/vcs_test.go index 248c541014..9ac0a56a07 100644 --- a/src/cmd/go/internal/vcs/vcs_test.go +++ b/src/cmd/go/internal/vcs/vcs_test.go @@ -233,7 +233,7 @@ func TestFromDir(t *testing.T) { } wantRepoDir := filepath.Dir(dir) - gotRepoDir, gotVCS, err := FromDir(dir, tempDir) + gotRepoDir, gotVCS, err := FromDir(dir, tempDir, false) if err != nil { t.Errorf("FromDir(%q, %q): %v", dir, tempDir, err) continue diff --git a/src/cmd/go/testdata/script/version_buildvcs_nested.txt b/src/cmd/go/testdata/script/version_buildvcs_nested.txt index f904c41bf8..08d4c92baf 100644 --- a/src/cmd/go/testdata/script/version_buildvcs_nested.txt +++ b/src/cmd/go/testdata/script/version_buildvcs_nested.txt @@ -1,5 +1,6 @@ [!exec:git] skip [!exec:hg] skip +[short] skip env GOFLAGS=-n # Create a root module in a root Git repository. @@ -8,25 +9,25 @@ cd root go mod init example.com/root exec git init -# It's an error to build a package from a nested Mercurial repository -# without -buildvcs=false, even if the package is in a separate module. +# Nesting repositories in parent directories are ignored, as the current +# directory main package, and containing main module are in the same repository. +# This is an error in GOPATH mode (to prevent VCS injection), but for modules, +# we assume users have control over repositories they've checked out. mkdir hgsub cd hgsub exec hg init cp ../../main.go main.go ! go build -stderr '^error obtaining VCS status: directory ".*hgsub" uses hg, but parent ".*root" uses git$' -stderr '\tUse -buildvcs=false to disable VCS stamping.$' -go mod init example.com/root/hgsub -! go build -stderr '^error obtaining VCS status: directory ".*hgsub" uses hg, but parent ".*root" uses git$' +stderr '^error obtaining VCS status: main module is in repository ".*root" but current directory is in repository ".*hgsub"$' +stderr '^\tUse -buildvcs=false to disable VCS stamping.$' go build -buildvcs=false +go mod init example.com/root/hgsub +go build cd .. # It's an error to build a package from a nested Git repository if the package # is in a separate repository from the current directory or from the module -# root directory. However, unlike with other VCS, it's okay for a Git repository -# to be nested within another Git repository. This happens with submodules. +# root directory. mkdir gitsub cd gitsub exec git init From 85cbdda5a6d8525973580776c835e725452db898 Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Thu, 14 Oct 2021 15:40:44 -0700 Subject: [PATCH 037/406] doc/go1.18: add release notes for build and VCS info Fixes #37475 For #39301 Change-Id: I765bc667004931ff8973b947f2e95624a4a0375d Reviewed-on: https://go-review.googlesource.com/c/go/+/356013 Reviewed-by: Bryan C. Mills Trust: Jay Conrod --- doc/go1.18.html | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/doc/go1.18.html b/doc/go1.18.html index f4d097d06b..d95e55e1ad 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -65,6 +65,30 @@ Do not send CLs removing the interior tags from such phrases. and installs packages, as before.

+

+ The go command now embeds version control information in + binaries including the currently checked-out revision and a flag indicating + whether edited or untracked files are present. Version control information + is embedded if the go command is invoked in a directory within a + Git or Mercurial repository, and the main package and its + containing main module are in the same repository. This information may be + omitted using the flag -buildvcs=false. +

+ +

+ Additionally, the go command embeds information about the build + including build and tool tags (set with -tags), compiler, + assembler, and linker flags (like -gcflags), whether cgo was + enabled, and if it was, the values of the cgo environment variables + (like CGO_CFLAGS). This information may be omitted using the + flag -buildinfo=false. Both VCS and build information may be + read together with module information using go + version -m file or + runtime/debug.ReadBuildInfo (for the currently running binary) + or the new debug/buildinfo + package. +

+

TODO: complete this section, or delete if not needed

@@ -114,6 +138,19 @@ Do not send CLs removing the interior tags from such phrases. TODO: complete this section

+
debug/buildinfo
+
+

+ This new package provides access to module versions, version control + information, and build flags embedded in executable files built by + the go command. The same information is also available via + runtime/debug.ReadBuildInfo + for the currently running binary and via go + version -m on the command line. +

+
+
+
image/draw

From 1b072b3ed56c18619587354f499fcda5279718a2 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 14 Oct 2021 18:18:49 -0400 Subject: [PATCH 038/406] runtime: consistently access pollDesc r/w Gs with atomics Both netpollblock and netpollunblock read gpp using a non-atomic load. When consuming a ready event, netpollblock clears gpp using a non-atomic store, thus skipping a barrier. Thus on systems with weak memory ordering, a sequence like so this is possible: T1 T2 1. netpollblock: read gpp -> pdReady 2. netpollblock: store gpp -> 0 3. netpollunblock: read gpp -> pdReady 4. netpollunblock: return i.e., without a happens-before edge between (2) and (3), netpollunblock may read the stale value of gpp. Switch these access to use atomic loads and stores in order to create these edges. For ease of future maintainance, I've simply changed rg and wg to always be accessed atomically, though I don't believe pollOpen or pollClose require atomics today. Fixes #48925 Change-Id: I903ea667eea320277610b4f969129935731520c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/355952 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Michael Knyszek Reviewed-by: David Chase --- src/runtime/netpoll.go | 43 +++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/src/runtime/netpoll.go b/src/runtime/netpoll.go index 239371158f..1008b4422c 100644 --- a/src/runtime/netpoll.go +++ b/src/runtime/netpoll.go @@ -78,6 +78,7 @@ type pollDesc struct { // pollReset, pollWait, pollWaitCanceled and runtime·netpollready (IO readiness notification) // proceed w/o taking the lock. So closing, everr, rg, rd, wg and wd are manipulated // in a lock-free way by all operations. + // TODO(golang.org/issue/49008): audit these lock-free fields for continued correctness. // NOTE(dvyukov): the following code uses uintptr to store *g (rg/wg), // that will blow up when GC starts moving objects. lock mutex // protects the following fields @@ -86,11 +87,11 @@ type pollDesc struct { everr bool // marks event scanning error happened user uint32 // user settable cookie rseq uintptr // protects from stale read timers - rg uintptr // pdReady, pdWait, G waiting for read or nil + rg uintptr // pdReady, pdWait, G waiting for read or nil. Accessed atomically. rt timer // read deadline timer (set if rt.f != nil) rd int64 // read deadline wseq uintptr // protects from stale write timers - wg uintptr // pdReady, pdWait, G waiting for write or nil + wg uintptr // pdReady, pdWait, G waiting for write or nil. Accessed atomically. wt timer // write deadline timer wd int64 // write deadline self *pollDesc // storage for indirect interface. See (*pollDesc).makeArg. @@ -147,20 +148,22 @@ func poll_runtime_isPollServerDescriptor(fd uintptr) bool { func poll_runtime_pollOpen(fd uintptr) (*pollDesc, int) { pd := pollcache.alloc() lock(&pd.lock) - if pd.wg != 0 && pd.wg != pdReady { + wg := atomic.Loaduintptr(&pd.wg) + if wg != 0 && wg != pdReady { throw("runtime: blocked write on free polldesc") } - if pd.rg != 0 && pd.rg != pdReady { + rg := atomic.Loaduintptr(&pd.rg) + if rg != 0 && rg != pdReady { throw("runtime: blocked read on free polldesc") } pd.fd = fd pd.closing = false pd.everr = false pd.rseq++ - pd.rg = 0 + atomic.Storeuintptr(&pd.rg, 0) pd.rd = 0 pd.wseq++ - pd.wg = 0 + atomic.Storeuintptr(&pd.wg, 0) pd.wd = 0 pd.self = pd unlock(&pd.lock) @@ -178,10 +181,12 @@ func poll_runtime_pollClose(pd *pollDesc) { if !pd.closing { throw("runtime: close polldesc w/o unblock") } - if pd.wg != 0 && pd.wg != pdReady { + wg := atomic.Loaduintptr(&pd.wg) + if wg != 0 && wg != pdReady { throw("runtime: blocked write on closing polldesc") } - if pd.rg != 0 && pd.rg != pdReady { + rg := atomic.Loaduintptr(&pd.rg) + if rg != 0 && rg != pdReady { throw("runtime: blocked read on closing polldesc") } netpollclose(pd.fd) @@ -205,9 +210,9 @@ func poll_runtime_pollReset(pd *pollDesc, mode int) int { return errcode } if mode == 'r' { - pd.rg = 0 + atomic.Storeuintptr(&pd.rg, 0) } else if mode == 'w' { - pd.wg = 0 + atomic.Storeuintptr(&pd.wg, 0) } return pollNoError } @@ -417,6 +422,8 @@ func netpollgoready(gp *g, traceskip int) { // returns true if IO is ready, or false if timedout or closed // waitio - wait only for completed IO, ignore errors +// Concurrent calls to netpollblock in the same mode are forbidden, as pollDesc +// can hold only a single waiting goroutine for each mode. func netpollblock(pd *pollDesc, mode int32, waitio bool) bool { gpp := &pd.rg if mode == 'w' { @@ -425,17 +432,19 @@ func netpollblock(pd *pollDesc, mode int32, waitio bool) bool { // set the gpp semaphore to pdWait for { - old := *gpp - if old == pdReady { - *gpp = 0 + // Consume notification if already ready. + if atomic.Casuintptr(gpp, pdReady, 0) { return true } - if old != 0 { - throw("runtime: double wait") - } if atomic.Casuintptr(gpp, 0, pdWait) { break } + + // Double check that this isn't corrupt; otherwise we'd loop + // forever. + if v := atomic.Loaduintptr(gpp); v != pdReady && v != 0 { + throw("runtime: double wait") + } } // need to recheck error states after setting gpp to pdWait @@ -459,7 +468,7 @@ func netpollunblock(pd *pollDesc, mode int32, ioready bool) *g { } for { - old := *gpp + old := atomic.Loaduintptr(gpp) if old == pdReady { return nil } From 4a7975e73a2815b93caf6697fec4f4e777e729a1 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Fri, 15 Oct 2021 11:54:25 -0700 Subject: [PATCH 039/406] cmd/compile: convert to using a map in getInstInfo, rather than SetImplicit() SetImplicit() has an explicit meaning and really shouldn't be used in this way - its use is left over from early prototype of the dictionary code. Convert from using SetImplicit to just using a map during traversal. Change-Id: I3d257c101a859f000e159d7ced307d1b7cf990d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/356310 Run-TryBot: Dan Scales TryBot-Result: Go Bot Reviewed-by: Keith Randall Trust: Dan Scales --- src/cmd/compile/internal/noder/stencil.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index cfa90e4399..3a1baeae88 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -1854,14 +1854,19 @@ func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instI } } + // Map to remember when we have seen an instantiated function value or method + // expression/value as part of a call, so we can determine when we encounter + // an uncalled function value or method expression/value. + callMap := make(map[ir.Node]bool) + var visitFunc func(ir.Node) visitFunc = func(n ir.Node) { - if n.Op() == ir.OFUNCINST && !n.(*ir.InstExpr).Implicit() { + if n.Op() == ir.OFUNCINST && !callMap[n] { if hasShapeNodes(n.(*ir.InstExpr).Targs) { infoPrint(" Closure&subdictionary required at generic function value %v\n", n.(*ir.InstExpr).X) info.subDictCalls = append(info.subDictCalls, n) } - } else if (n.Op() == ir.OMETHEXPR || n.Op() == ir.OMETHVALUE) && !n.(*ir.SelectorExpr).Implicit() && + } else if (n.Op() == ir.OMETHEXPR || n.Op() == ir.OMETHVALUE) && !callMap[n] && !types.IsInterfaceMethod(n.(*ir.SelectorExpr).Selection.Type) && len(deref(n.(*ir.SelectorExpr).X.Type()).RParams()) > 0 { if hasShapeTypes(deref(n.(*ir.SelectorExpr).X.Type()).RParams()) { @@ -1874,16 +1879,15 @@ func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instI } } if n.Op() == ir.OCALL && n.(*ir.CallExpr).X.Op() == ir.OFUNCINST { - n.(*ir.CallExpr).X.(*ir.InstExpr).SetImplicit(true) + callMap[n.(*ir.CallExpr).X] = true if hasShapeNodes(n.(*ir.CallExpr).X.(*ir.InstExpr).Targs) { infoPrint(" Subdictionary at generic function/method call: %v - %v\n", n.(*ir.CallExpr).X.(*ir.InstExpr).X, n) info.subDictCalls = append(info.subDictCalls, n) } } if n.Op() == ir.OCALLMETH && n.(*ir.CallExpr).X.Op() == ir.ODOTMETH && - //n.(*ir.CallExpr).X.(*ir.SelectorExpr).Selection != nil && len(deref(n.(*ir.CallExpr).X.(*ir.SelectorExpr).X.Type()).RParams()) > 0 { - n.(*ir.CallExpr).X.(*ir.SelectorExpr).SetImplicit(true) + callMap[n.(*ir.CallExpr).X] = true if hasShapeTypes(deref(n.(*ir.CallExpr).X.(*ir.SelectorExpr).X.Type()).RParams()) { infoPrint(" Subdictionary at generic method call: %v\n", n) info.subDictCalls = append(info.subDictCalls, n) @@ -1891,7 +1895,7 @@ func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instI } if n.Op() == ir.OCALL && n.(*ir.CallExpr).X.Op() == ir.OXDOT && isShapeDeref(n.(*ir.CallExpr).X.(*ir.SelectorExpr).X.Type()) { - n.(*ir.CallExpr).X.(*ir.SelectorExpr).SetImplicit(true) + callMap[n.(*ir.CallExpr).X] = true infoPrint(" Optional subdictionary at generic bound call: %v\n", n) info.subDictCalls = append(info.subDictCalls, n) } From ed1c8db308029bd82e6de4d547196f7f841236bb Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Fri, 15 Oct 2021 12:31:39 -0700 Subject: [PATCH 040/406] cmd/compile: cleanup code in getInstInfo to use switch statement Simple cleanup: convert a bunch of if's to a switch statement in getInstInfo. Also, use a few extra variables to avoid repeated node conversions (such as n.(*ir.CallExpr)) Change-Id: I7a2a4efb569415256a8bc9350fb100bd2d8cfb39 Reviewed-on: https://go-review.googlesource.com/c/go/+/356311 Run-TryBot: Dan Scales TryBot-Result: Go Bot Reviewed-by: Keith Randall Trust: Dan Scales --- src/cmd/compile/internal/noder/stencil.go | 115 ++++++++++++---------- 1 file changed, 62 insertions(+), 53 deletions(-) diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 3a1baeae88..592de7017f 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -28,8 +28,8 @@ func assert(p bool) { base.Assert(p) } -// Temporary - for outputting information on derived types, dictionaries, sub-dictionaries. -// Turn off when running tests. +// For outputting debug information on dictionary format and instantiated dictionaries +// (type arg, derived types, sub-dictionary, and itab entries). var infoPrintMode = false func infoPrint(format string, a ...interface{}) { @@ -1861,15 +1861,16 @@ func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instI var visitFunc func(ir.Node) visitFunc = func(n ir.Node) { - if n.Op() == ir.OFUNCINST && !callMap[n] { - if hasShapeNodes(n.(*ir.InstExpr).Targs) { + switch n.Op() { + case ir.OFUNCINST: + if !callMap[n] && hasShapeNodes(n.(*ir.InstExpr).Targs) { infoPrint(" Closure&subdictionary required at generic function value %v\n", n.(*ir.InstExpr).X) info.subDictCalls = append(info.subDictCalls, n) } - } else if (n.Op() == ir.OMETHEXPR || n.Op() == ir.OMETHVALUE) && !callMap[n] && - !types.IsInterfaceMethod(n.(*ir.SelectorExpr).Selection.Type) && - len(deref(n.(*ir.SelectorExpr).X.Type()).RParams()) > 0 { - if hasShapeTypes(deref(n.(*ir.SelectorExpr).X.Type()).RParams()) { + case ir.OMETHEXPR, ir.OMETHVALUE: + if !callMap[n] && !types.IsInterfaceMethod(n.(*ir.SelectorExpr).Selection.Type) && + len(deref(n.(*ir.SelectorExpr).X.Type()).RParams()) > 0 && + hasShapeTypes(deref(n.(*ir.SelectorExpr).X.Type()).RParams()) { if n.(*ir.SelectorExpr).X.Op() == ir.OTYPE { infoPrint(" Closure&subdictionary required at generic meth expr %v\n", n) } else { @@ -1877,43 +1878,48 @@ func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instI } info.subDictCalls = append(info.subDictCalls, n) } - } - if n.Op() == ir.OCALL && n.(*ir.CallExpr).X.Op() == ir.OFUNCINST { - callMap[n.(*ir.CallExpr).X] = true - if hasShapeNodes(n.(*ir.CallExpr).X.(*ir.InstExpr).Targs) { - infoPrint(" Subdictionary at generic function/method call: %v - %v\n", n.(*ir.CallExpr).X.(*ir.InstExpr).X, n) + case ir.OCALL: + ce := n.(*ir.CallExpr) + if ce.X.Op() == ir.OFUNCINST { + callMap[ce.X] = true + if hasShapeNodes(ce.X.(*ir.InstExpr).Targs) { + infoPrint(" Subdictionary at generic function/method call: %v - %v\n", ce.X.(*ir.InstExpr).X, n) + info.subDictCalls = append(info.subDictCalls, n) + } + } + if ce.X.Op() == ir.OXDOT && + isShapeDeref(ce.X.(*ir.SelectorExpr).X.Type()) { + callMap[ce.X] = true + infoPrint(" Optional subdictionary at generic bound call: %v\n", n) info.subDictCalls = append(info.subDictCalls, n) } - } - if n.Op() == ir.OCALLMETH && n.(*ir.CallExpr).X.Op() == ir.ODOTMETH && - len(deref(n.(*ir.CallExpr).X.(*ir.SelectorExpr).X.Type()).RParams()) > 0 { - callMap[n.(*ir.CallExpr).X] = true - if hasShapeTypes(deref(n.(*ir.CallExpr).X.(*ir.SelectorExpr).X.Type()).RParams()) { - infoPrint(" Subdictionary at generic method call: %v\n", n) - info.subDictCalls = append(info.subDictCalls, n) + case ir.OCALLMETH: + ce := n.(*ir.CallExpr) + if ce.X.Op() == ir.ODOTMETH && + len(deref(ce.X.(*ir.SelectorExpr).X.Type()).RParams()) > 0 { + callMap[ce.X] = true + if hasShapeTypes(deref(ce.X.(*ir.SelectorExpr).X.Type()).RParams()) { + infoPrint(" Subdictionary at generic method call: %v\n", n) + info.subDictCalls = append(info.subDictCalls, n) + } } - } - if n.Op() == ir.OCALL && n.(*ir.CallExpr).X.Op() == ir.OXDOT && - isShapeDeref(n.(*ir.CallExpr).X.(*ir.SelectorExpr).X.Type()) { - callMap[n.(*ir.CallExpr).X] = true - infoPrint(" Optional subdictionary at generic bound call: %v\n", n) - info.subDictCalls = append(info.subDictCalls, n) - } - if n.Op() == ir.OCONVIFACE && n.Type().IsInterface() && - !n.Type().IsEmptyInterface() && - n.(*ir.ConvExpr).X.Type().HasShape() { - infoPrint(" Itab for interface conv: %v\n", n) - info.itabConvs = append(info.itabConvs, n) - } - if n.Op() == ir.OXDOT && n.(*ir.SelectorExpr).X.Type().IsShape() { - infoPrint(" Itab for bound call: %v\n", n) - info.itabConvs = append(info.itabConvs, n) - } - if (n.Op() == ir.ODOTTYPE || n.Op() == ir.ODOTTYPE2) && !n.(*ir.TypeAssertExpr).Type().IsInterface() && !n.(*ir.TypeAssertExpr).X.Type().IsEmptyInterface() { - infoPrint(" Itab for dot type: %v\n", n) - info.itabConvs = append(info.itabConvs, n) - } - if n.Op() == ir.OCLOSURE { + case ir.OCONVIFACE: + if n.Type().IsInterface() && !n.Type().IsEmptyInterface() && + n.(*ir.ConvExpr).X.Type().HasShape() { + infoPrint(" Itab for interface conv: %v\n", n) + info.itabConvs = append(info.itabConvs, n) + } + case ir.OXDOT: + if n.(*ir.SelectorExpr).X.Type().IsShape() { + infoPrint(" Itab for bound call: %v\n", n) + info.itabConvs = append(info.itabConvs, n) + } + case ir.ODOTTYPE, ir.ODOTTYPE2: + if !n.(*ir.TypeAssertExpr).Type().IsInterface() && !n.(*ir.TypeAssertExpr).X.Type().IsEmptyInterface() { + infoPrint(" Itab for dot type: %v\n", n) + info.itabConvs = append(info.itabConvs, n) + } + case ir.OCLOSURE: // Visit the closure body and add all relevant entries to the // dictionary of the outer function (closure will just use // the dictionary of the outer function). @@ -1924,18 +1930,21 @@ func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instI for _, n := range cfunc.Dcl { n.DictIndex = uint16(findDictType(instInfo, n.Type()) + 1) } - } - if n.Op() == ir.OSWITCH && n.(*ir.SwitchStmt).Tag != nil && n.(*ir.SwitchStmt).Tag.Op() == ir.OTYPESW && !n.(*ir.SwitchStmt).Tag.(*ir.TypeSwitchGuard).X.Type().IsEmptyInterface() { - for _, cc := range n.(*ir.SwitchStmt).Cases { - for _, c := range cc.List { - if c.Op() == ir.OTYPE && c.Type().HasShape() { - // Type switch from a non-empty interface - might need an itab. - infoPrint(" Itab for type switch: %v\n", c) - info.itabConvs = append(info.itabConvs, c) - if info.type2switchType == nil { - info.type2switchType = map[ir.Node]*types.Type{} + case ir.OSWITCH: + ss := n.(*ir.SwitchStmt) + if ss.Tag != nil && ss.Tag.Op() == ir.OTYPESW && + !ss.Tag.(*ir.TypeSwitchGuard).X.Type().IsEmptyInterface() { + for _, cc := range ss.Cases { + for _, c := range cc.List { + if c.Op() == ir.OTYPE && c.Type().HasShape() { + // Type switch from a non-empty interface - might need an itab. + infoPrint(" Itab for type switch: %v\n", c) + info.itabConvs = append(info.itabConvs, c) + if info.type2switchType == nil { + info.type2switchType = map[ir.Node]*types.Type{} + } + info.type2switchType[c] = ss.Tag.(*ir.TypeSwitchGuard).X.Type() } - info.type2switchType[c] = n.(*ir.SwitchStmt).Tag.(*ir.TypeSwitchGuard).X.Type() } } } From 680caf15355057ca84857a2a291b6f5c44e73329 Mon Sep 17 00:00:00 2001 From: Richard Musiol Date: Fri, 3 Sep 2021 21:58:57 +0200 Subject: [PATCH 041/406] misc/wasm: expect environment to provide polyfills The list of environments to support with wasm_exec.js was becoming too large to maintain. With this change, wasm_exec.js expects that the environment provides all necessary polyfills. The standardized "globalThis" is used for accessing the environment. wasm_exec.js now only provides stub fallbacks for globalThis.fs and globalThis.process. All code specific to Node.js is now in a separate file. Change-Id: I076febbd94d4d7845260faad972f450f74a7b983 Reviewed-on: https://go-review.googlesource.com/c/go/+/347353 Trust: Richard Musiol Reviewed-by: Cherry Mui --- misc/wasm/go_js_wasm_exec | 2 +- misc/wasm/wasm_exec.js | 115 +++++------------------------------- misc/wasm/wasm_exec_node.js | 49 +++++++++++++++ 3 files changed, 66 insertions(+), 100 deletions(-) create mode 100644 misc/wasm/wasm_exec_node.js diff --git a/misc/wasm/go_js_wasm_exec b/misc/wasm/go_js_wasm_exec index b700722dfe..fcbd0e4fc8 100755 --- a/misc/wasm/go_js_wasm_exec +++ b/misc/wasm/go_js_wasm_exec @@ -11,4 +11,4 @@ while [ -h "$SOURCE" ]; do done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" -exec node "$DIR/wasm_exec.js" "$@" +exec node "$DIR/wasm_exec_node.js" "$@" diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js index e2f3cda995..30044a6f85 100644 --- a/misc/wasm/wasm_exec.js +++ b/misc/wasm/wasm_exec.js @@ -1,49 +1,19 @@ // Copyright 2018 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. + "use strict"; (() => { - // Map multiple JavaScript environments to a single common API, - // preferring web standards over Node.js API. - // - // Environments considered: - // - Browsers - // - Node.js - // - Electron - // - Parcel - // - Webpack - - if (typeof global !== "undefined") { - // global already exists - } else if (typeof window !== "undefined") { - window.global = window; - } else if (typeof self !== "undefined") { - self.global = self; - } else { - throw new Error("cannot export Go (neither global, window nor self is defined)"); - } - - if (!global.require && typeof require !== "undefined") { - global.require = require; - } - - if (!global.fs && global.require) { - const fs = require("fs"); - if (typeof fs === "object" && fs !== null && Object.keys(fs).length !== 0) { - global.fs = fs; - } - } - const enosys = () => { const err = new Error("not implemented"); err.code = "ENOSYS"; return err; }; - if (!global.fs) { + if (!globalThis.fs) { let outputBuf = ""; - global.fs = { + globalThis.fs = { constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused writeSync(fd, buf) { outputBuf += decoder.decode(buf); @@ -88,8 +58,8 @@ }; } - if (!global.process) { - global.process = { + if (!globalThis.process) { + globalThis.process = { getuid() { return -1; }, getgid() { return -1; }, geteuid() { return -1; }, @@ -103,47 +73,26 @@ } } - if (!global.crypto && global.require) { - const nodeCrypto = require("crypto"); - global.crypto = { - getRandomValues(b) { - nodeCrypto.randomFillSync(b); - }, - }; - } - if (!global.crypto) { - throw new Error("global.crypto is not available, polyfill required (getRandomValues only)"); + if (!globalThis.crypto) { + throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)"); } - if (!global.performance) { - global.performance = { - now() { - const [sec, nsec] = process.hrtime(); - return sec * 1000 + nsec / 1000000; - }, - }; + if (!globalThis.performance) { + throw new Error("globalThis.performance is not available, polyfill required (performance.now only)"); } - if (!global.TextEncoder && global.require) { - global.TextEncoder = require("util").TextEncoder; - } - if (!global.TextEncoder) { - throw new Error("global.TextEncoder is not available, polyfill required"); + if (!globalThis.TextEncoder) { + throw new Error("globalThis.TextEncoder is not available, polyfill required"); } - if (!global.TextDecoder && global.require) { - global.TextDecoder = require("util").TextDecoder; + if (!globalThis.TextDecoder) { + throw new Error("globalThis.TextDecoder is not available, polyfill required"); } - if (!global.TextDecoder) { - throw new Error("global.TextDecoder is not available, polyfill required"); - } - - // End of polyfills for common API. const encoder = new TextEncoder("utf-8"); const decoder = new TextDecoder("utf-8"); - global.Go = class { + globalThis.Go = class { constructor() { this.argv = ["js"]; this.env = {}; @@ -518,7 +467,7 @@ null, true, false, - global, + globalThis, this, ]; this._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id @@ -527,7 +476,7 @@ [null, 2], [true, 3], [false, 4], - [global, 5], + [globalThis, 5], [this, 6], ]); this._idPool = []; // unused ids that have been garbage collected @@ -602,36 +551,4 @@ }; } } - - if ( - typeof module !== "undefined" && - global.require && - global.require.main === module && - global.process && - global.process.versions && - !global.process.versions.electron - ) { - if (process.argv.length < 3) { - console.error("usage: go_js_wasm_exec [wasm binary] [arguments]"); - process.exit(1); - } - - const go = new Go(); - go.argv = process.argv.slice(2); - go.env = Object.assign({ TMPDIR: require("os").tmpdir() }, process.env); - go.exit = process.exit; - WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => { - process.on("exit", (code) => { // Node.js exits if no event handler is pending - if (code === 0 && !go.exited) { - // deadlock, make Go print error and stack traces - go._pendingEvent = { id: 0 }; - go._resume(); - } - }); - return go.run(result.instance); - }).catch((err) => { - console.error(err); - process.exit(1); - }); - } })(); diff --git a/misc/wasm/wasm_exec_node.js b/misc/wasm/wasm_exec_node.js new file mode 100644 index 0000000000..f9200ca950 --- /dev/null +++ b/misc/wasm/wasm_exec_node.js @@ -0,0 +1,49 @@ +// Copyright 2021 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. + +"use strict"; + +if (process.argv.length < 3) { + console.error("usage: go_js_wasm_exec [wasm binary] [arguments]"); + process.exit(1); +} + +globalThis.require = require; +globalThis.fs = require("fs"); +globalThis.TextEncoder = require("util").TextEncoder; +globalThis.TextDecoder = require("util").TextDecoder; + +globalThis.performance = { + now() { + const [sec, nsec] = process.hrtime(); + return sec * 1000 + nsec / 1000000; + }, +}; + +const crypto = require("crypto"); +globalThis.crypto = { + getRandomValues(b) { + crypto.randomFillSync(b); + }, +}; + +require("./wasm_exec"); + +const go = new Go(); +go.argv = process.argv.slice(2); +go.env = Object.assign({ TMPDIR: require("os").tmpdir() }, process.env); +go.exit = process.exit; +WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => { + process.on("exit", (code) => { // Node.js exits if no event handler is pending + if (code === 0 && !go.exited) { + // deadlock, make Go print error and stack traces + go._pendingEvent = { id: 0 }; + go._resume(); + } + }); + return go.run(result.instance); +}).catch((err) => { + console.error(err); + process.exit(1); +}); From 640a49b8d45760b7c965fc1529dffc8e000cc846 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Fri, 15 Oct 2021 15:05:36 -0700 Subject: [PATCH 042/406] test: add a test for parameterized embedded field Make sure that an embedded field like "MyStruct[T]" works and can be referenced via the name MyStruct. Change-Id: I8be1f1184dd42c4e54e4144aff2fd85e30af722f Reviewed-on: https://go-review.googlesource.com/c/go/+/356312 Trust: Dan Scales Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/typecheck/subr.go | 3 -- test/typeparam/genembed2.go | 46 ++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 test/typeparam/genembed2.go diff --git a/src/cmd/compile/internal/typecheck/subr.go b/src/cmd/compile/internal/typecheck/subr.go index b3fc7459e1..b4d5302525 100644 --- a/src/cmd/compile/internal/typecheck/subr.go +++ b/src/cmd/compile/internal/typecheck/subr.go @@ -1324,9 +1324,6 @@ func (ts *Tsubster) tstruct(t *types.Type, force bool) *types.Type { } } if newfields != nil { - // TODO(danscales): make sure this works for the field - // names of embedded types (which should keep the name of - // the type param, not the instantiated type). newfields[i] = types.NewField(f.Pos, f.Sym, t2) newfields[i].Embedded = f.Embedded newfields[i].Note = f.Note diff --git a/test/typeparam/genembed2.go b/test/typeparam/genembed2.go new file mode 100644 index 0000000000..6effd2e6bc --- /dev/null +++ b/test/typeparam/genembed2.go @@ -0,0 +1,46 @@ +// run -gcflags=-G=3 + +// Copyright 2021 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. + +// Test for declaration and use of a parameterized embedded field. + +package main + +import ( + "fmt" + "sync" +) + +type MyStruct[T any] struct { + val T +} + +type Lockable[T any] struct { + MyStruct[T] + mu sync.Mutex +} + +// Get returns the value stored in a Lockable. +func (l *Lockable[T]) Get() T { + l.mu.Lock() + defer l.mu.Unlock() + return l.MyStruct.val +} + +// Set sets the value in a Lockable. +func (l *Lockable[T]) Set(v T) { + l.mu.Lock() + defer l.mu.Unlock() + l.MyStruct = MyStruct[T]{v} +} + +func main() { + var li Lockable[int] + + li.Set(5) + if got, want := li.Get(), 5; got != want { + panic(fmt.Sprintf("got %d, want %d", got, want)) + } +} From fa7d11a0e9c0ed469111ba5fdd86f7462a48ef49 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Sat, 16 Oct 2021 14:54:42 -0700 Subject: [PATCH 043/406] go/types, types2: add test case for missing return The respective issue was fixed in types2 with CL 356189; and the problem didn't exist in go/types. This CL simply adds the test case to the type checkers as well. For #49003. Change-Id: Ib50ee8bb0ad21f2916f2b79d4f77593302899a3e Reviewed-on: https://go-review.googlesource.com/c/go/+/356411 Trust: Robert Griesemer Run-TryBot: Robert Griesemer TryBot-Result: Go Bot Reviewed-by: Cuong Manh Le --- .../internal/types2/testdata/fixedbugs/issue49003.go | 10 ++++++++++ src/go/types/testdata/fixedbugs/issue49003.go | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/cmd/compile/internal/types2/testdata/fixedbugs/issue49003.go create mode 100644 src/go/types/testdata/fixedbugs/issue49003.go diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49003.go b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49003.go new file mode 100644 index 0000000000..ece1a27bb9 --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49003.go @@ -0,0 +1,10 @@ +// Copyright 2021 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 p + +func f(s string) int { + for range s { + } +} // ERROR missing return diff --git a/src/go/types/testdata/fixedbugs/issue49003.go b/src/go/types/testdata/fixedbugs/issue49003.go new file mode 100644 index 0000000000..ece1a27bb9 --- /dev/null +++ b/src/go/types/testdata/fixedbugs/issue49003.go @@ -0,0 +1,10 @@ +// Copyright 2021 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 p + +func f(s string) int { + for range s { + } +} // ERROR missing return From cf51fb5d680a9a1ca98af3361e65722d07bff111 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Sat, 16 Oct 2021 20:30:12 -0700 Subject: [PATCH 044/406] cmd/compile, types2: avoid confusing follow-on error in invalid type assertion This CL avoids a useless follow-on error (that gets reported before the actual error due to source position). This addresses the first part of the issue below. Thanks to @cuonglm for the suggestion for the fix. For #49005. Change-Id: Ifdd83072a05c32e115dc58a0233868a64f336f3f Reviewed-on: https://go-review.googlesource.com/c/go/+/356449 Trust: Robert Griesemer Run-TryBot: Robert Griesemer TryBot-Result: Go Bot Reviewed-by: Cuong Manh Le --- src/cmd/compile/internal/types2/typexpr.go | 7 +++++++ test/fixedbugs/issue49005a.go | 13 +++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/fixedbugs/issue49005a.go diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go index 646becbdae..eae9330914 100644 --- a/src/cmd/compile/internal/types2/typexpr.go +++ b/src/cmd/compile/internal/types2/typexpr.go @@ -312,6 +312,13 @@ func (check *Checker) typInternal(e0 syntax.Expr, def *Named) (T Type) { typ := new(Pointer) def.setUnderlying(typ) typ.base = check.varType(e.X) + // If typ.base is invalid, it's unlikely that *base is particularly + // useful - even a valid dereferenciation will lead to an invalid + // type again, and in some cases we get unexpected follow-on errors + // (e.g., see #49005). Return an invalid type instead. + if typ.base == Typ[Invalid] { + return Typ[Invalid] + } return typ } diff --git a/test/fixedbugs/issue49005a.go b/test/fixedbugs/issue49005a.go new file mode 100644 index 0000000000..55d92c4650 --- /dev/null +++ b/test/fixedbugs/issue49005a.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2021 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 p + +type T interface{ M() } + +func F() T + +var _ = F().(*X) // ERROR "undefined: X" From 74acbaf94ab3c7aaa7e22fda4f90920e90f11ead Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Wed, 13 Oct 2021 19:44:38 +0800 Subject: [PATCH 045/406] cmd/compile: allow inlining labeled for-statement and switch-statement After CL 349012 and CL 350911, we can fully handle these labeled statements, so we can allow them when inlining. Updates #14768 Change-Id: I0ab3fd3f8d7436b49b1aedd946516b33c63f5747 Reviewed-on: https://go-review.googlesource.com/c/go/+/355497 Run-TryBot: David Chase TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky Reviewed-by: Dan Scales Reviewed-by: David Chase Trust: Dan Scales --- src/cmd/compile/internal/inline/inl.go | 21 --------------------- test/inline.go | 6 ++---- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index 51270a3315..a2268a5465 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -390,27 +390,6 @@ func (v *hairyVisitor) doNode(n ir.Node) bool { // These nodes don't produce code; omit from inlining budget. return false - case ir.OFOR, ir.OFORUNTIL: - n := n.(*ir.ForStmt) - if n.Label != nil { - v.reason = "labeled control" - return true - } - case ir.OSWITCH: - n := n.(*ir.SwitchStmt) - if n.Label != nil { - v.reason = "labeled control" - return true - } - // case ir.ORANGE, ir.OSELECT in "unhandled" above - - case ir.OBREAK, ir.OCONTINUE: - n := n.(*ir.BranchStmt) - if n.Label != nil { - // Should have short-circuited due to labeled control error above. - base.Fatalf("unexpected labeled break/continue: %v", n) - } - case ir.OIF: n := n.(*ir.IfStmt) if ir.IsConst(n.Cond, constant.Bool) { diff --git a/test/inline.go b/test/inline.go index a73c0ba7b1..599d5233e0 100644 --- a/test/inline.go +++ b/test/inline.go @@ -135,8 +135,7 @@ func s1(x int) int { // ERROR "can inline s1" return foo() // ERROR "inlining call to s1.func1" } -// can't currently inline functions with a break statement -func switchBreak(x, y int) int { +func switchBreak(x, y int) int { // ERROR "can inline switchBreak" var n int switch x { case 0: @@ -218,8 +217,7 @@ func for1(fn func() bool) { // ERROR "can inline for1" "fn does not escape" } } -// BAD: for2 should be inlineable too. -func for2(fn func() bool) { // ERROR "fn does not escape" +func for2(fn func() bool) { // ERROR "can inline for2" "fn does not escape" Loop: for { if fn() { From c091767d87b7a6ef6016286bc0fae8add59b92de Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Fri, 15 Oct 2021 13:52:05 -0700 Subject: [PATCH 046/406] cmd/asm: report an error when trying to do spectre on 386 The compiler refuses to do spectre mitigation on 386, but the assembler doesn't. Fix that. Fixes #49006 Change-Id: I887b6f7ed7523a47f463706f06ca4c2c6e828b6b Reviewed-on: https://go-review.googlesource.com/c/go/+/356190 Trust: Keith Randall Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/cmd/internal/obj/x86/asm6.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go index 43ce832b17..6555756fd3 100644 --- a/src/cmd/internal/obj/x86/asm6.go +++ b/src/cmd/internal/obj/x86/asm6.go @@ -2035,6 +2035,11 @@ type nopPad struct { } func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { + if ctxt.Retpoline && ctxt.Arch.Family == sys.I386 { + ctxt.Diag("-spectre=ret not supported on 386") + ctxt.Retpoline = false // don't keep printing + } + pjc := makePjcCtx(ctxt) if s.P != nil { From 3e5cc4d6f6befb284d7b2a5142a8b576bf5970ea Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Fri, 8 Oct 2021 16:06:42 +0800 Subject: [PATCH 047/406] cmd/compile: use MOVBE instruction for GOAMD64>=v3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit encoding/binary benchmark on my laptop: name old time/op new time/op delta ReadSlice1000Int32s-8 4.42µs ± 5% 4.20µs ± 1% -4.94% (p=0.046 n=9+8) ReadStruct-8 359ns ± 8% 368ns ± 5% +2.35% (p=0.041 n=9+10) WriteStruct-8 349ns ± 1% 357ns ± 1% +2.15% (p=0.000 n=8+10) ReadInts-8 235ns ± 1% 233ns ± 1% -1.01% (p=0.005 n=10+10) WriteInts-8 265ns ± 1% 274ns ± 1% +3.45% (p=0.000 n=10+10) WriteSlice1000Int32s-8 4.61µs ± 5% 4.59µs ± 5% ~ (p=0.986 n=10+10) PutUint16-8 0.56ns ± 4% 0.57ns ± 4% ~ (p=0.101 n=10+10) PutUint32-8 0.83ns ± 2% 0.56ns ± 6% -32.91% (p=0.000 n=10+10) PutUint64-8 0.81ns ± 3% 0.62ns ± 4% -23.82% (p=0.000 n=10+10) LittleEndianPutUint16-8 0.55ns ± 4% 0.55ns ± 3% ~ (p=0.926 n=10+10) LittleEndianPutUint32-8 0.41ns ± 4% 0.42ns ± 3% ~ (p=0.148 n=10+9) LittleEndianPutUint64-8 0.55ns ± 2% 0.56ns ± 6% ~ (p=0.897 n=10+10) ReadFloats-8 60.4ns ± 4% 59.0ns ± 1% -2.25% (p=0.007 n=10+10) WriteFloats-8 72.3ns ± 2% 71.5ns ± 7% ~ (p=0.089 n=10+10) ReadSlice1000Float32s-8 4.21µs ± 3% 4.18µs ± 2% ~ (p=0.197 n=10+10) WriteSlice1000Float32s-8 4.61µs ± 2% 4.68µs ± 7% ~ (p=1.000 n=8+10) ReadSlice1000Uint8s-8 250ns ± 4% 247ns ± 4% ~ (p=0.324 n=10+10) WriteSlice1000Uint8s-8 227ns ± 5% 229ns ± 2% ~ (p=0.193 n=10+7) PutUvarint32-8 15.3ns ± 2% 15.4ns ± 4% ~ (p=0.782 n=10+10) PutUvarint64-8 38.5ns ± 1% 38.6ns ± 5% ~ (p=0.396 n=8+10) name old speed new speed delta ReadSlice1000Int32s-8 890MB/s ±17% 953MB/s ± 1% +7.00% (p=0.027 n=10+8) ReadStruct-8 209MB/s ± 8% 204MB/s ± 5% -2.42% (p=0.043 n=9+10) WriteStruct-8 214MB/s ± 3% 210MB/s ± 1% -1.75% (p=0.003 n=9+10) ReadInts-8 127MB/s ± 1% 129MB/s ± 1% +1.01% (p=0.006 n=10+10) WriteInts-8 113MB/s ± 1% 109MB/s ± 1% -3.34% (p=0.000 n=10+10) WriteSlice1000Int32s-8 868MB/s ± 5% 872MB/s ± 5% ~ (p=1.000 n=10+10) PutUint16-8 3.55GB/s ± 4% 3.50GB/s ± 4% ~ (p=0.093 n=10+10) PutUint32-8 4.83GB/s ± 2% 7.21GB/s ± 6% +49.16% (p=0.000 n=10+10) PutUint64-8 9.89GB/s ± 3% 12.99GB/s ± 4% +31.26% (p=0.000 n=10+10) LittleEndianPutUint16-8 3.65GB/s ± 4% 3.65GB/s ± 4% ~ (p=0.912 n=10+10) LittleEndianPutUint32-8 9.74GB/s ± 3% 9.63GB/s ± 3% ~ (p=0.222 n=9+9) LittleEndianPutUint64-8 14.4GB/s ± 2% 14.3GB/s ± 5% ~ (p=0.912 n=10+10) ReadFloats-8 199MB/s ± 4% 203MB/s ± 1% +2.27% (p=0.007 n=10+10) WriteFloats-8 166MB/s ± 2% 168MB/s ± 7% ~ (p=0.089 n=10+10) ReadSlice1000Float32s-8 949MB/s ± 3% 958MB/s ± 2% ~ (p=0.218 n=10+10) WriteSlice1000Float32s-8 867MB/s ± 2% 857MB/s ± 6% ~ (p=1.000 n=8+10) ReadSlice1000Uint8s-8 4.00GB/s ± 4% 4.06GB/s ± 4% ~ (p=0.353 n=10+10) WriteSlice1000Uint8s-8 4.40GB/s ± 4% 4.36GB/s ± 2% ~ (p=0.193 n=10+7) PutUvarint32-8 262MB/s ± 2% 260MB/s ± 4% ~ (p=0.739 n=10+10) PutUvarint64-8 208MB/s ± 1% 207MB/s ± 5% ~ (p=0.408 n=8+10) Updates #45453 Change-Id: Ifda0d48d54665cef45d46d3aad974062633142c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/354670 Run-TryBot: Alberto Donizetti TryBot-Result: Go Bot Reviewed-by: Keith Randall Trust: Matthew Dempsky --- src/cmd/compile/internal/amd64/ssa.go | 7 +- .../compile/internal/amd64/versions_test.go | 27 +- src/cmd/compile/internal/ssa/gen/AMD64.rules | 26 ++ src/cmd/compile/internal/ssa/gen/AMD64Ops.go | 6 + src/cmd/compile/internal/ssa/opGen.go | 64 +++++ src/cmd/compile/internal/ssa/rewriteAMD64.go | 243 ++++++++++++++++++ test/codegen/memcombine.go | 36 ++- 7 files changed, 389 insertions(+), 20 deletions(-) diff --git a/src/cmd/compile/internal/amd64/ssa.go b/src/cmd/compile/internal/amd64/ssa.go index 0e74574422..b0e5c34030 100644 --- a/src/cmd/compile/internal/amd64/ssa.go +++ b/src/cmd/compile/internal/amd64/ssa.go @@ -772,7 +772,9 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { p.From.Val = math.Float64frombits(uint64(v.AuxInt)) p.To.Type = obj.TYPE_REG p.To.Reg = x - case ssa.OpAMD64MOVQload, ssa.OpAMD64MOVSSload, ssa.OpAMD64MOVSDload, ssa.OpAMD64MOVLload, ssa.OpAMD64MOVWload, ssa.OpAMD64MOVBload, ssa.OpAMD64MOVBQSXload, ssa.OpAMD64MOVWQSXload, ssa.OpAMD64MOVLQSXload, ssa.OpAMD64MOVOload: + case ssa.OpAMD64MOVQload, ssa.OpAMD64MOVLload, ssa.OpAMD64MOVWload, ssa.OpAMD64MOVBload, ssa.OpAMD64MOVOload, + ssa.OpAMD64MOVSSload, ssa.OpAMD64MOVSDload, ssa.OpAMD64MOVBQSXload, ssa.OpAMD64MOVWQSXload, ssa.OpAMD64MOVLQSXload, + ssa.OpAMD64MOVBEQload, ssa.OpAMD64MOVBELload: p := s.Prog(v.Op.Asm()) p.From.Type = obj.TYPE_MEM p.From.Reg = v.Args[0].Reg() @@ -788,7 +790,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { p.To.Reg = v.Reg() case ssa.OpAMD64MOVQstore, ssa.OpAMD64MOVSSstore, ssa.OpAMD64MOVSDstore, ssa.OpAMD64MOVLstore, ssa.OpAMD64MOVWstore, ssa.OpAMD64MOVBstore, ssa.OpAMD64MOVOstore, ssa.OpAMD64ADDQmodify, ssa.OpAMD64SUBQmodify, ssa.OpAMD64ANDQmodify, ssa.OpAMD64ORQmodify, ssa.OpAMD64XORQmodify, - ssa.OpAMD64ADDLmodify, ssa.OpAMD64SUBLmodify, ssa.OpAMD64ANDLmodify, ssa.OpAMD64ORLmodify, ssa.OpAMD64XORLmodify: + ssa.OpAMD64ADDLmodify, ssa.OpAMD64SUBLmodify, ssa.OpAMD64ANDLmodify, ssa.OpAMD64ORLmodify, ssa.OpAMD64XORLmodify, + ssa.OpAMD64MOVBEQstore, ssa.OpAMD64MOVBELstore: p := s.Prog(v.Op.Asm()) p.From.Type = obj.TYPE_REG p.From.Reg = v.Args[1].Reg() diff --git a/src/cmd/compile/internal/amd64/versions_test.go b/src/cmd/compile/internal/amd64/versions_test.go index de677f3a69..ee1a8ca3aa 100644 --- a/src/cmd/compile/internal/amd64/versions_test.go +++ b/src/cmd/compile/internal/amd64/versions_test.go @@ -53,7 +53,9 @@ func TestGoAMD64v1(t *testing.T) { opcodes := map[string]bool{} var features []string for feature, opcodeList := range featureToOpcodes { - features = append(features, fmt.Sprintf("cpu.%s=off", feature)) + if runtimeFeatures[feature] { + features = append(features, fmt.Sprintf("cpu.%s=off", feature)) + } for _, op := range opcodeList { opcodes[op] = true } @@ -204,14 +206,28 @@ func clobber(t *testing.T, src string, dst *os.File, opcodes map[string]bool) { f.Close() } +func setOf(keys ...string) map[string]bool { + m := make(map[string]bool, len(keys)) + for _, key := range keys { + m[key] = true + } + return m +} + +var runtimeFeatures = setOf( + "adx", "aes", "avx", "avx2", "bmi1", "bmi2", "erms", "fma", + "pclmulqdq", "popcnt", "rdtscp", "sse3", "sse41", "sse42", "ssse3", +) + var featureToOpcodes = map[string][]string{ // Note: we include *q, *l, and plain opcodes here. // go tool objdump doesn't include a [QL] on popcnt instructions, until CL 351889 // native objdump doesn't include [QL] on linux. - "popcnt": []string{"popcntq", "popcntl", "popcnt"}, - "bmi1": []string{"andnq", "andnl", "andn", "blsiq", "blsil", "blsi", "blsmskq", "blsmskl", "blsmsk", "blsrq", "blsrl", "blsr", "tzcntq", "tzcntl", "tzcnt"}, - "sse41": []string{"roundsd"}, - "fma": []string{"vfmadd231sd"}, + "popcnt": {"popcntq", "popcntl", "popcnt"}, + "bmi1": {"andnq", "andnl", "andn", "blsiq", "blsil", "blsi", "blsmskq", "blsmskl", "blsmsk", "blsrq", "blsrl", "blsr", "tzcntq", "tzcntl", "tzcnt"}, + "sse41": {"roundsd"}, + "fma": {"vfmadd231sd"}, + "movbe": {"movbeqq", "movbeq", "movbell", "movbel", "movbe"}, } // Test to use POPCNT instruction, if available @@ -364,5 +380,4 @@ func TestFMA(t *testing.T) { t.Errorf("FMA(%f,%f,%f) = %f, want %f", tt.x, tt.y, tt.z, got, tt.want) } } - } diff --git a/src/cmd/compile/internal/ssa/gen/AMD64.rules b/src/cmd/compile/internal/ssa/gen/AMD64.rules index 8b73ee14ea..507d701999 100644 --- a/src/cmd/compile/internal/ssa/gen/AMD64.rules +++ b/src/cmd/compile/internal/ssa/gen/AMD64.rules @@ -2219,3 +2219,29 @@ (AND(Q|L) x (ADD(Q|L)const [-1] x)) && buildcfg.GOAMD64 >= 3 => (BLSR(Q|L) x) (BSWAP(Q|L) (BSWAP(Q|L) p)) => p + +// CPUID feature: MOVBE. +(MOV(Q|L)store [i] {s} p x:(BSWAP(Q|L) w) mem) && x.Uses == 1 && buildcfg.GOAMD64 >= 3 => (MOVBE(Q|L)store [i] {s} p w mem) +(BSWAP(Q|L) x:(MOV(Q|L)load [i] {s} p mem)) && x.Uses == 1 && buildcfg.GOAMD64 >= 3 => (MOVBE(Q|L)load [i] {s} p mem) +(BSWAP(Q|L) (MOVBE(Q|L)load [i] {s} p m)) => (MOV(Q|L)load [i] {s} p m) +(MOVBE(Q|L)store [i] {s} p (BSWAP(Q|L) x) m) => (MOV(Q|L)store [i] {s} p x m) + +(ORQ x0:(MOVBELload [i0] {s} p mem) + sh:(SHLQconst [32] x1:(MOVBELload [i1] {s} p mem))) + && i0 == i1+4 + && x0.Uses == 1 + && x1.Uses == 1 + && sh.Uses == 1 + && mergePoint(b,x0,x1) != nil + && clobber(x0, x1, sh) + => @mergePoint(b,x0,x1) (MOVBEQload [i1] {s} p mem) + +(ORQ x0:(MOVBELload [i] {s} p0 mem) + sh:(SHLQconst [32] x1:(MOVBELload [i] {s} p1 mem))) + && x0.Uses == 1 + && x1.Uses == 1 + && sh.Uses == 1 + && sequentialAddresses(p1, p0, 4) + && mergePoint(b,x0,x1) != nil + && clobber(x0, x1, sh) + => @mergePoint(b,x0,x1) (MOVBEQload [i] {s} p0 mem) diff --git a/src/cmd/compile/internal/ssa/gen/AMD64Ops.go b/src/cmd/compile/internal/ssa/gen/AMD64Ops.go index 731454c761..e3c94e4b2e 100644 --- a/src/cmd/compile/internal/ssa/gen/AMD64Ops.go +++ b/src/cmd/compile/internal/ssa/gen/AMD64Ops.go @@ -922,6 +922,12 @@ func init() { // and BSFQ(0) is undefined. Same for TZCNTL(0)==32 {name: "TZCNTQ", argLength: 1, reg: gp11, asm: "TZCNTQ", clobberFlags: true}, {name: "TZCNTL", argLength: 1, reg: gp11, asm: "TZCNTL", clobberFlags: true}, + + // CPUID feature: MOVBE + {name: "MOVBELload", argLength: 2, reg: gpload, asm: "MOVBEL", aux: "SymOff", typ: "UInt32", faultOnNilArg0: true, symEffect: "Read"}, // load and swap 4 bytes from arg0+auxint+aux. arg1=mem. Zero extend. + {name: "MOVBELstore", argLength: 3, reg: gpstore, asm: "MOVBEL", aux: "SymOff", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"}, // swap and store 4 bytes in arg1 to arg0+auxint+aux. arg2=mem + {name: "MOVBEQload", argLength: 2, reg: gpload, asm: "MOVBEQ", aux: "SymOff", typ: "UInt64", faultOnNilArg0: true, symEffect: "Read"}, // load and swap 8 bytes from arg0+auxint+aux. arg1=mem + {name: "MOVBEQstore", argLength: 3, reg: gpstore, asm: "MOVBEQ", aux: "SymOff", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"}, // swap and store 8 bytes in arg1 to arg0+auxint+aux. arg2=mem } var AMD64blocks = []blockData{ diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go index 640e517fe7..091f43f40a 100644 --- a/src/cmd/compile/internal/ssa/opGen.go +++ b/src/cmd/compile/internal/ssa/opGen.go @@ -1043,6 +1043,10 @@ const ( OpAMD64BLSRL OpAMD64TZCNTQ OpAMD64TZCNTL + OpAMD64MOVBELload + OpAMD64MOVBELstore + OpAMD64MOVBEQload + OpAMD64MOVBEQstore OpARMADD OpARMADDconst @@ -13780,6 +13784,66 @@ var opcodeTable = [...]opInfo{ }, }, }, + { + name: "MOVBELload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVBEL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295032831}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBELstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVBEL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 4295032831}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBEQload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVBEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295032831}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBEQstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVBEQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 4295032831}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, { name: "ADD", diff --git a/src/cmd/compile/internal/ssa/rewriteAMD64.go b/src/cmd/compile/internal/ssa/rewriteAMD64.go index 201fbf2954..88b545a465 100644 --- a/src/cmd/compile/internal/ssa/rewriteAMD64.go +++ b/src/cmd/compile/internal/ssa/rewriteAMD64.go @@ -222,6 +222,10 @@ func rewriteValueAMD64(v *Value) bool { return rewriteValueAMD64_OpAMD64LEAQ4(v) case OpAMD64LEAQ8: return rewriteValueAMD64_OpAMD64LEAQ8(v) + case OpAMD64MOVBELstore: + return rewriteValueAMD64_OpAMD64MOVBELstore(v) + case OpAMD64MOVBEQstore: + return rewriteValueAMD64_OpAMD64MOVBEQstore(v) case OpAMD64MOVBQSX: return rewriteValueAMD64_OpAMD64MOVBQSX(v) case OpAMD64MOVBQSXload: @@ -3623,6 +3627,43 @@ func rewriteValueAMD64_OpAMD64BSWAPL(v *Value) bool { v.copyOf(p) return true } + // match: (BSWAPL x:(MOVLload [i] {s} p mem)) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: (MOVBELload [i] {s} p mem) + for { + x := v_0 + if x.Op != OpAMD64MOVLload { + break + } + i := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64MOVBELload) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg2(p, mem) + return true + } + // match: (BSWAPL (MOVBELload [i] {s} p m)) + // result: (MOVLload [i] {s} p m) + for { + if v_0.Op != OpAMD64MOVBELload { + break + } + i := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + m := v_0.Args[1] + p := v_0.Args[0] + v.reset(OpAMD64MOVLload) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg2(p, m) + return true + } return false } func rewriteValueAMD64_OpAMD64BSWAPQ(v *Value) bool { @@ -3637,6 +3678,43 @@ func rewriteValueAMD64_OpAMD64BSWAPQ(v *Value) bool { v.copyOf(p) return true } + // match: (BSWAPQ x:(MOVQload [i] {s} p mem)) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: (MOVBEQload [i] {s} p mem) + for { + x := v_0 + if x.Op != OpAMD64MOVQload { + break + } + i := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64MOVBEQload) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg2(p, mem) + return true + } + // match: (BSWAPQ (MOVBEQload [i] {s} p m)) + // result: (MOVQload [i] {s} p m) + for { + if v_0.Op != OpAMD64MOVBEQload { + break + } + i := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + m := v_0.Args[1] + p := v_0.Args[0] + v.reset(OpAMD64MOVQload) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg2(p, m) + return true + } return false } func rewriteValueAMD64_OpAMD64BTCLconst(v *Value) bool { @@ -9395,6 +9473,52 @@ func rewriteValueAMD64_OpAMD64LEAQ8(v *Value) bool { } return false } +func rewriteValueAMD64_OpAMD64MOVBELstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBELstore [i] {s} p (BSWAPL x) m) + // result: (MOVLstore [i] {s} p x m) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + if v_1.Op != OpAMD64BSWAPL { + break + } + x := v_1.Args[0] + m := v_2 + v.reset(OpAMD64MOVLstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, x, m) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVBEQstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBEQstore [i] {s} p (BSWAPQ x) m) + // result: (MOVQstore [i] {s} p x m) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + if v_1.Op != OpAMD64BSWAPQ { + break + } + x := v_1.Args[0] + m := v_2 + v.reset(OpAMD64MOVQstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, x, m) + return true + } + return false +} func rewriteValueAMD64_OpAMD64MOVBQSX(v *Value) bool { v_0 := v.Args[0] b := v.Block @@ -12225,6 +12349,28 @@ func rewriteValueAMD64_OpAMD64MOVLstore(v *Value) bool { v.AddArg3(ptr, val, mem) return true } + // match: (MOVLstore [i] {s} p x:(BSWAPL w) mem) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: (MOVBELstore [i] {s} p w mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + x := v_1 + if x.Op != OpAMD64BSWAPL { + break + } + w := x.Args[0] + mem := v_2 + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64MOVBELstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, w, mem) + return true + } return false } func rewriteValueAMD64_OpAMD64MOVLstoreconst(v *Value) bool { @@ -13164,6 +13310,28 @@ func rewriteValueAMD64_OpAMD64MOVQstore(v *Value) bool { v.AddArg3(ptr, val, mem) return true } + // match: (MOVQstore [i] {s} p x:(BSWAPQ w) mem) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: (MOVBEQstore [i] {s} p w mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + x := v_1 + if x.Op != OpAMD64BSWAPQ { + break + } + w := x.Args[0] + mem := v_2 + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64MOVBEQstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, w, mem) + return true + } return false } func rewriteValueAMD64_OpAMD64MOVQstoreconst(v *Value) bool { @@ -18657,6 +18825,81 @@ func rewriteValueAMD64_OpAMD64ORQ(v *Value) bool { } break } + // match: (ORQ x0:(MOVBELload [i0] {s} p mem) sh:(SHLQconst [32] x1:(MOVBELload [i1] {s} p mem))) + // cond: i0 == i1+4 && x0.Uses == 1 && x1.Uses == 1 && sh.Uses == 1 && mergePoint(b,x0,x1) != nil && clobber(x0, x1, sh) + // result: @mergePoint(b,x0,x1) (MOVBEQload [i1] {s} p mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + if x0.Op != OpAMD64MOVBELload { + continue + } + i0 := auxIntToInt32(x0.AuxInt) + s := auxToSym(x0.Aux) + mem := x0.Args[1] + p := x0.Args[0] + sh := v_1 + if sh.Op != OpAMD64SHLQconst || auxIntToInt8(sh.AuxInt) != 32 { + continue + } + x1 := sh.Args[0] + if x1.Op != OpAMD64MOVBELload { + continue + } + i1 := auxIntToInt32(x1.AuxInt) + if auxToSym(x1.Aux) != s { + continue + } + _ = x1.Args[1] + if p != x1.Args[0] || mem != x1.Args[1] || !(i0 == i1+4 && x0.Uses == 1 && x1.Uses == 1 && sh.Uses == 1 && mergePoint(b, x0, x1) != nil && clobber(x0, x1, sh)) { + continue + } + b = mergePoint(b, x0, x1) + v0 := b.NewValue0(x1.Pos, OpAMD64MOVBEQload, typ.UInt64) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(i1) + v0.Aux = symToAux(s) + v0.AddArg2(p, mem) + return true + } + break + } + // match: (ORQ x0:(MOVBELload [i] {s} p0 mem) sh:(SHLQconst [32] x1:(MOVBELload [i] {s} p1 mem))) + // cond: x0.Uses == 1 && x1.Uses == 1 && sh.Uses == 1 && sequentialAddresses(p1, p0, 4) && mergePoint(b,x0,x1) != nil && clobber(x0, x1, sh) + // result: @mergePoint(b,x0,x1) (MOVBEQload [i] {s} p0 mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + if x0.Op != OpAMD64MOVBELload { + continue + } + i := auxIntToInt32(x0.AuxInt) + s := auxToSym(x0.Aux) + mem := x0.Args[1] + p0 := x0.Args[0] + sh := v_1 + if sh.Op != OpAMD64SHLQconst || auxIntToInt8(sh.AuxInt) != 32 { + continue + } + x1 := sh.Args[0] + if x1.Op != OpAMD64MOVBELload || auxIntToInt32(x1.AuxInt) != i || auxToSym(x1.Aux) != s { + continue + } + _ = x1.Args[1] + p1 := x1.Args[0] + if mem != x1.Args[1] || !(x0.Uses == 1 && x1.Uses == 1 && sh.Uses == 1 && sequentialAddresses(p1, p0, 4) && mergePoint(b, x0, x1) != nil && clobber(x0, x1, sh)) { + continue + } + b = mergePoint(b, x0, x1) + v0 := b.NewValue0(x1.Pos, OpAMD64MOVBEQload, typ.UInt64) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(i) + v0.Aux = symToAux(s) + v0.AddArg2(p0, mem) + return true + } + break + } return false } func rewriteValueAMD64_OpAMD64ORQconst(v *Value) bool { diff --git a/test/codegen/memcombine.go b/test/codegen/memcombine.go index 2a0c534df0..97e1d4bdfb 100644 --- a/test/codegen/memcombine.go +++ b/test/codegen/memcombine.go @@ -70,7 +70,8 @@ func load_le16_idx(b []byte, idx int) { } func load_be64(b []byte) { - // amd64:`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` + // amd64/v1,amd64/v2:`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` + // amd64/v3:`MOVBEQ` // s390x:`MOVD\s\(.*\),` // arm64:`REV`,`MOVD\s\(R[0-9]+\),`,-`MOV[BHW]`,-`REVW`,-`REV16W` // ppc64le:`MOVDBR`,-`MOV[BHW]Z` @@ -78,7 +79,8 @@ func load_be64(b []byte) { } func load_be64_idx(b []byte, idx int) { - // amd64:`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` + // amd64/v1,amd64/v2:`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` + // amd64/v3: `MOVBEQ` // s390x:`MOVD\s\(.*\)\(.*\*1\),` // arm64:`REV`,`MOVD\s\(R[0-9]+\)\(R[0-9]+\),`,-`MOV[WHB]`,-`REVW`,-`REV16W` // ppc64le:`MOVDBR`,-`MOV[BHW]Z` @@ -86,7 +88,8 @@ func load_be64_idx(b []byte, idx int) { } func load_be32(b []byte) { - // amd64:`BSWAPL`,-`MOV[BW]`,-`OR` + // amd64/v1,amd64/v2:`BSWAPL`,-`MOV[BW]`,-`OR` + // amd64/v3: `MOVBEL` // s390x:`MOVWZ\s\(.*\),` // arm64:`REVW`,`MOVWU\s\(R[0-9]+\),`,-`MOV[BH]`,-`REV16W` // ppc64le:`MOVWBR`,-`MOV[BH]Z` @@ -94,7 +97,8 @@ func load_be32(b []byte) { } func load_be32_idx(b []byte, idx int) { - // amd64:`BSWAPL`,-`MOV[BW]`,-`OR` + // amd64/v1,amd64/v2:`BSWAPL`,-`MOV[BW]`,-`OR` + // amd64/v3: `MOVBEL` // s390x:`MOVWZ\s\(.*\)\(.*\*1\),` // arm64:`REVW`,`MOVWU\s\(R[0-9]+\)\(R[0-9]+\),`,-`MOV[HB]`,-`REV16W` // ppc64le:`MOVWBR`,-`MOV[BH]Z` @@ -179,7 +183,8 @@ func load_be_byte4_uint32(s []byte) uint32 { func load_be_byte4_uint32_inv(s []byte) uint32 { // arm64:`MOVWU\t\(R[0-9]+\)`,`REVW`,-`ORR`,-`REV16W`,-`MOV[BH]` - // amd64:`MOVL\s\([A-Z]+\)`,`BSWAPL`,-`MOV[BW]`,-`OR` + // amd64/v1,amd64/v2:`MOVL\s\([A-Z]+\)`,`BSWAPL`,-`MOV[BW]`,-`OR` + // amd64/v3: `MOVBEL` return uint32(s[3]) | uint32(s[2])<<8 | uint32(s[1])<<16 | uint32(s[0])<<24 } @@ -191,7 +196,8 @@ func load_be_byte8_uint64(s []byte) uint64 { func load_be_byte8_uint64_inv(s []byte) uint64 { // arm64:`MOVD\t\(R[0-9]+\)`,`REV`,-`ORR`,-`REVW`,-`REV16W`,-`MOV[BHW]` - // amd64:`MOVQ\s\([A-Z]+\),\s[A-Z]+`,`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` + // amd64/v1,amd64/v2:`MOVQ\s\([A-Z]+\),\s[A-Z]+`,`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` + // amd64/v3: `MOVBEQ` // ppc64le:`MOVDBR\t\(R[0-9]+\)`,-`MOV[BHW]Z` return uint64(s[7]) | uint64(s[6])<<8 | uint64(s[5])<<16 | uint64(s[4])<<24 | uint64(s[3])<<32 | uint64(s[2])<<40 | uint64(s[1])<<48 | uint64(s[0])<<56 } @@ -409,7 +415,8 @@ func store_le16_idx(b []byte, idx int) { } func store_be64(b []byte) { - // amd64:`BSWAPQ`,-`SHR.` + // amd64/v1,amd64/v2:`BSWAPQ`,-`SHR.` + // amd64/v3: `MOVBEQ` // arm64:`MOVD`,`REV`,-`MOV[WBH]`,-`REVW`,-`REV16W` // ppc64le:`MOVDBR` // s390x:`MOVD\s.*\(.*\)$`,-`SRW\s`,-`SRD\s` @@ -417,7 +424,8 @@ func store_be64(b []byte) { } func store_be64_idx(b []byte, idx int) { - // amd64:`BSWAPQ`,-`SHR.` + // amd64/v1,amd64/v2:`BSWAPQ`,-`SHR.` + // amd64/v3:`MOVBEQ` // arm64:`REV`,`MOVD\sR[0-9]+,\s\(R[0-9]+\)\(R[0-9]+\)`,-`MOV[BHW]`,-`REV16W`,-`REVW` // ppc64le:`MOVDBR` // s390x:`MOVD\s.*\(.*\)\(.*\*1\)$`,-`SRW\s`,-`SRD\s` @@ -425,7 +433,8 @@ func store_be64_idx(b []byte, idx int) { } func store_be32(b []byte) { - // amd64:`BSWAPL`,-`SHR.` + // amd64/v1,amd64/v2:`BSWAPL`,-`SHR.` + // amd64/v3:`MOVBEL` // arm64:`MOVW`,`REVW`,-`MOV[BH]`,-`REV16W` // ppc64le:`MOVWBR` // s390x:`MOVW\s.*\(.*\)$`,-`SRW\s`,-`SRD\s` @@ -445,7 +454,8 @@ func store_be32_load(b, x *[8]byte) { } func store_be32_idx(b []byte, idx int) { - // amd64:`BSWAPL`,-`SHR.` + // amd64/v1,amd64/v2:`BSWAPL`,-`SHR.` + // amd64/v3:`MOVBEL` // arm64:`REVW`,`MOVW\sR[0-9]+,\s\(R[0-9]+\)\(R[0-9]+\)`,-`MOV[BH]`,-`REV16W` // ppc64le:`MOVWBR` // s390x:`MOVW\s.*\(.*\)\(.*\*1\)$`,-`SRW\s`,-`SRD\s` @@ -508,14 +518,16 @@ func store_be_byte_2(b []byte, val uint16) { func store_be_byte_4(b []byte, val uint32) { _ = b[4] // arm64:`REVW`,`MOVW\sR[0-9]+,\s1\(R[0-9]+\)`,-`MOVB`,-`MOVH`,-`REV16W` - // amd64:`MOVL\s[A-Z]+,\s1\([A-Z]+\)`,-`MOVB`,-`MOVW` + // amd64/v1,amd64/v2:`MOVL\s[A-Z]+,\s1\([A-Z]+\)`,-`MOVB`,-`MOVW` + // amd64/v3:`MOVBEL\s[A-Z]+,\s1\([A-Z]+\)` b[1], b[2], b[3], b[4] = byte(val>>24), byte(val>>16), byte(val>>8), byte(val) } func store_be_byte_8(b []byte, val uint64) { _ = b[8] // arm64:`REV`,`MOVD\sR[0-9]+,\s1\(R[0-9]+\)`,-`MOVB`,-`MOVH`,-`MOVW`,-`REV16W`,-`REVW` - // amd64:`MOVQ\s[A-Z]+,\s1\([A-Z]+\)`,-`MOVB`,-`MOVW`,-`MOVL` + // amd64/v1,amd64/v2:`MOVQ\s[A-Z]+,\s1\([A-Z]+\)`,-`MOVB`,-`MOVW`,-`MOVL` + // amd64/v3:`MOVBEQ\s[A-Z]+,\s1\([A-Z]+\)`, -`MOVBEL` b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8] = byte(val>>56), byte(val>>48), byte(val>>40), byte(val>>32), byte(val>>24), byte(val>>16), byte(val>>8), byte(val) } From 417100ec1b08bb1046e207fd08de105944668d27 Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Mon, 18 Oct 2021 10:24:00 -0400 Subject: [PATCH 048/406] cmd/go: fix broken fuzz test Fixes test breakage caused by CL 355691. Change-Id: I85fcb1491dc39c45342f4cae91fdfda6aedecd1a Reviewed-on: https://go-review.googlesource.com/c/go/+/356530 Trust: Katie Hockman Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- .../go/testdata/script/test_fuzz_minimize.txt | 52 ----------------- .../script/test_fuzz_minimize_interesting.txt | 56 ++++++++++++++++++- 2 files changed, 53 insertions(+), 55 deletions(-) diff --git a/src/cmd/go/testdata/script/test_fuzz_minimize.txt b/src/cmd/go/testdata/script/test_fuzz_minimize.txt index 56abc68104..8b11621bbd 100644 --- a/src/cmd/go/testdata/script/test_fuzz_minimize.txt +++ b/src/cmd/go/testdata/script/test_fuzz_minimize.txt @@ -34,21 +34,6 @@ stdout FAIL stdout 'there was an Error' stdout FAIL -# Test that minimization occurs for a crash that appears while minimizing a -# newly found interesting input. There must be only one worker for this test to -# be flaky like we want. -! go test -fuzz=FuzzMinimizerCrashInMinimization -run=FuzzMinimizerCrashInMinimization -fuzztime=10000x -parallel=1 . -! stdout '^ok' -stdout 'got the minimum size!' -stdout 'flaky failure' -stdout FAIL - -# Make sure the crash that was written will fail when run with go test -! go test -run=FuzzMinimizerCrashInMinimization . - -# Clear testdata. -rm testdata - # Test that minimization is working for recoverable errors. ! go test -fuzz=FuzzMinimizerRecoverable -run=FuzzMinimizerRecoverable -fuzztime=10000x . ! stdout '^ok' @@ -97,25 +82,10 @@ stdout FAIL module example.com/y go 1.16 --- y.go -- -package y - -import ( - "bytes" - "io" -) - -func Y(w io.Writer, b []byte) { - if !bytes.Equal(b, []byte("y")) { - w.Write([]byte("not equal")) - } -} -- y_test.go -- package y import ( - "bytes" - "io" "os" "testing" ) @@ -161,28 +131,6 @@ func FuzzMinimizerNonrecoverable(f *testing.F) { os.Exit(99) }) } - -func FuzzMinimizerCrashInMinimization(f *testing.F) { - seed := make([]byte, 1000) - f.Add(seed) - f.Fuzz(func(t *testing.T, b []byte) { - if len(b) < 50 || len(b) > 1100 { - // Make sure that b is large enough that it can be minimized - return - } - if !bytes.Equal(b, seed) { - // This should have hit a new edge, and the interesting input - // should be attempting minimization - Y(io.Discard, b) - } - if len(b) < 350 { - t.Error("flaky failure") - } - if len(b) == 50 { - t.Log("got the minimum size!") - } - }) -} -- empty/empty.go -- package empty -- check_testdata/check_testdata.go -- diff --git a/src/cmd/go/testdata/script/test_fuzz_minimize_interesting.txt b/src/cmd/go/testdata/script/test_fuzz_minimize_interesting.txt index 5e1d90d8d9..fc66201eb3 100644 --- a/src/cmd/go/testdata/script/test_fuzz_minimize_interesting.txt +++ b/src/cmd/go/testdata/script/test_fuzz_minimize_interesting.txt @@ -18,22 +18,72 @@ go test -c -fuzz=. # Build using shared build cache for speed. env GOCACHE=$WORK/gocache -exec ./fuzz.test$GOEXE -test.fuzzcachedir=$GOCACHE/fuzz -test.fuzz=. -test.fuzztime=1000x -go run check_cache.go $GOCACHE/fuzz/FuzzMin +exec ./fuzz.test$GOEXE -test.fuzzcachedir=$GOCACHE/fuzz -test.fuzz=FuzzMinCache -test.fuzztime=1000x +go run check_cache.go $GOCACHE/fuzz/FuzzMinCache + +# Test that minimization occurs for a crash that appears while minimizing a +# newly found interesting input. There must be only one worker for this test to +# be flaky like we want. +go test -c -fuzz=. # Build using shared build cache for speed. +env GOCACHE=$WORK/gocache +! exec ./fuzz.test$GOEXE -test.fuzzcachedir=$GOCACHE/fuzz -test.fuzz=FuzzMinimizerCrashInMinimization -test.fuzztime=10000x -test.parallel=1 +! stdout '^ok' +stdout 'got the minimum size!' +stdout 'flaky failure' +stdout FAIL + +# Make sure the crash that was written will fail when run with go test +! go test -run=FuzzMinimizerCrashInMinimization . -- go.mod -- module fuzz go 1.17 +-- y.go -- +package fuzz + +import ( + "bytes" + "io" +) + +func Y(w io.Writer, b []byte) { + if !bytes.Equal(b, []byte("y")) { + w.Write([]byte("not equal")) + } +} -- fuzz_test.go -- package fuzz import ( "bytes" + "io" "testing" ) -func FuzzMin(f *testing.F) { +func FuzzMinimizerCrashInMinimization(f *testing.F) { + seed := make([]byte, 1000) + f.Add(seed) + f.Fuzz(func(t *testing.T, b []byte) { + if len(b) < 50 || len(b) > 1100 { + // Make sure that b is large enough that it can be minimized + return + } + if !bytes.Equal(b, seed) { + // This should have hit a new edge, and the interesting input + // should be attempting minimization + Y(io.Discard, b) + } + if len(b) < 350 { + t.Error("flaky failure") + } + if len(b) == 50 { + t.Log("got the minimum size!") + } + }) +} + +func FuzzMinCache(f *testing.F) { seed := bytes.Repeat([]byte("a"), 20) f.Add(seed) f.Fuzz(func(t *testing.T, buf []byte) { From 42515418a99f2540427a5d32189f6d44fb06939e Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sat, 18 Sep 2021 10:24:31 +0700 Subject: [PATCH 049/406] reflect: correct documentation of Value.UnsafeAddr The doc mentions that "UnsafeAddr returns a _pointer_ to v's data", but it returns a uintptr instead, which don't have pointer semantic. Change-Id: I557d5597cbc485356ca803eb496a99d6db8c63ba Reviewed-on: https://go-review.googlesource.com/c/go/+/350690 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Reviewed-by: Matthew Dempsky --- src/reflect/value.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reflect/value.go b/src/reflect/value.go index 449f3bbb3c..6bc02c1c8c 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -2473,7 +2473,7 @@ func (v Value) Uint() uint64 { // which ensures cmd/compile can recognize unsafe.Pointer(v.UnsafeAddr()) // and make an exception. -// UnsafeAddr returns a pointer to v's data. +// UnsafeAddr returns a pointer to v's data, as a uintptr. // It is for advanced clients that also import the "unsafe" package. // It panics if v is not addressable. func (v Value) UnsafeAddr() uintptr { From 543a513304c35d42b162790a6e70191aac68225c Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sun, 17 Oct 2021 01:18:20 +0700 Subject: [PATCH 050/406] reflect: add test that method values have the same code pointers Updates #40592 Change-Id: I16252dd57aceb5c49ddc11d8c12c601ca87ca902 Reviewed-on: https://go-review.googlesource.com/c/go/+/356252 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Keith Randall --- src/reflect/all_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 8642d60f8b..0370906f7d 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -2511,6 +2511,11 @@ func TestMethodValue(t *testing.T) { p := Point{3, 4} var i int64 + // Check that method value have the same underlying code pointers. + if p1, p2 := ValueOf(Point{1, 1}).Method(1), ValueOf(Point{2, 2}).Method(1); p1.Pointer() != p2.Pointer() { + t.Errorf("methodValueCall mismatched: %v - %v", p1, p2) + } + // Curried method of value. tfunc := TypeOf((func(int) int)(nil)) v := ValueOf(p).Method(1) From 4d550727f8b85e9f8866f22c8a02b8f56fa64159 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sat, 18 Sep 2021 10:32:22 +0700 Subject: [PATCH 051/406] reflect: add Value.UnsafePointer Allowing eliminates a class of possible misuse of unsafe.Pointer, and allow callers to migrate from Value.Addr and Value.Pointer, thus they can be now deprecated. Fixes #40592 Change-Id: I798e507c748922cac5cc1c1971c1b2cc7095a068 Reviewed-on: https://go-review.googlesource.com/c/go/+/350691 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Keith Randall Reviewed-by: Ian Lance Taylor --- src/reflect/all_test.go | 22 +++++----- src/reflect/deepequal.go | 6 +-- src/reflect/set_test.go | 6 +-- src/reflect/type.go | 4 +- src/reflect/value.go | 94 ++++++++++++++++++++++++---------------- 5 files changed, 75 insertions(+), 57 deletions(-) diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 0370906f7d..141cc8f73d 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -3223,11 +3223,11 @@ func (*outer) M() {} func TestNestedMethods(t *testing.T) { typ := TypeOf((*outer)(nil)) - if typ.NumMethod() != 1 || typ.Method(0).Func.Pointer() != ValueOf((*outer).M).Pointer() { + if typ.NumMethod() != 1 || typ.Method(0).Func.UnsafePointer() != ValueOf((*outer).M).UnsafePointer() { t.Errorf("Wrong method table for outer: (M=%p)", (*outer).M) for i := 0; i < typ.NumMethod(); i++ { m := typ.Method(i) - t.Errorf("\t%d: %s %#x\n", i, m.Name, m.Func.Pointer()) + t.Errorf("\t%d: %s %p\n", i, m.Name, m.Func.UnsafePointer()) } } } @@ -3266,11 +3266,11 @@ func (i *InnerInt) M() int { func TestEmbeddedMethods(t *testing.T) { typ := TypeOf((*OuterInt)(nil)) - if typ.NumMethod() != 1 || typ.Method(0).Func.Pointer() != ValueOf((*OuterInt).M).Pointer() { + if typ.NumMethod() != 1 || typ.Method(0).Func.UnsafePointer() != ValueOf((*OuterInt).M).UnsafePointer() { t.Errorf("Wrong method table for OuterInt: (m=%p)", (*OuterInt).M) for i := 0; i < typ.NumMethod(); i++ { m := typ.Method(i) - t.Errorf("\t%d: %s %#x\n", i, m.Name, m.Func.Pointer()) + t.Errorf("\t%d: %s %p\n", i, m.Name, m.Func.UnsafePointer()) } } @@ -3528,11 +3528,11 @@ func TestSlice(t *testing.T) { rv := ValueOf(&xs).Elem() rv = rv.Slice(3, 4) - ptr2 := rv.Pointer() + ptr2 := rv.UnsafePointer() rv = rv.Slice(5, 5) - ptr3 := rv.Pointer() + ptr3 := rv.UnsafePointer() if ptr3 != ptr2 { - t.Errorf("xs.Slice(3,4).Slice3(5,5).Pointer() = %#x, want %#x", ptr3, ptr2) + t.Errorf("xs.Slice(3,4).Slice3(5,5).UnsafePointer() = %p, want %p", ptr3, ptr2) } } @@ -3575,11 +3575,11 @@ func TestSlice3(t *testing.T) { rv = ValueOf(&xs).Elem() rv = rv.Slice3(3, 5, 7) - ptr2 := rv.Pointer() + ptr2 := rv.UnsafePointer() rv = rv.Slice3(4, 4, 4) - ptr3 := rv.Pointer() + ptr3 := rv.UnsafePointer() if ptr3 != ptr2 { - t.Errorf("xs.Slice3(3,5,7).Slice3(4,4,4).Pointer() = %#x, want %#x", ptr3, ptr2) + t.Errorf("xs.Slice3(3,5,7).Slice3(4,4,4).UnsafePointer() = %p, want %p", ptr3, ptr2) } } @@ -6818,7 +6818,7 @@ func verifyGCBitsSlice(t *testing.T, typ Type, cap int, bits []byte) { // repeat a bitmap for a small array or executing a repeat in // a GC program. val := MakeSlice(typ, 0, cap) - data := NewAt(ArrayOf(cap, typ), unsafe.Pointer(val.Pointer())) + data := NewAt(ArrayOf(cap, typ), val.UnsafePointer()) heapBits := GCBits(data.Interface()) // Repeat the bitmap for the slice size, trimming scalars in // the last element. diff --git a/src/reflect/deepequal.go b/src/reflect/deepequal.go index 94174dec04..7f1ecb2809 100644 --- a/src/reflect/deepequal.go +++ b/src/reflect/deepequal.go @@ -102,7 +102,7 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool) bool { if v1.Len() != v2.Len() { return false } - if v1.Pointer() == v2.Pointer() { + if v1.UnsafePointer() == v2.UnsafePointer() { return true } // Special case for []byte, which is common. @@ -121,7 +121,7 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool) bool { } return deepValueEqual(v1.Elem(), v2.Elem(), visited) case Ptr: - if v1.Pointer() == v2.Pointer() { + if v1.UnsafePointer() == v2.UnsafePointer() { return true } return deepValueEqual(v1.Elem(), v2.Elem(), visited) @@ -139,7 +139,7 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool) bool { if v1.Len() != v2.Len() { return false } - if v1.Pointer() == v2.Pointer() { + if v1.UnsafePointer() == v2.UnsafePointer() { return true } for _, k := range v1.MapKeys() { diff --git a/src/reflect/set_test.go b/src/reflect/set_test.go index a633e6eee2..566dc7fb65 100644 --- a/src/reflect/set_test.go +++ b/src/reflect/set_test.go @@ -79,7 +79,7 @@ func TestImplicitMapConversion(t *testing.T) { if x != b2 { t.Errorf("#5 after SetMapIndex(b1, b2): %p (!= %p), %t (map=%v)", x, b2, ok, m) } - if p := mv.MapIndex(ValueOf(b1)).Elem().Pointer(); p != uintptr(unsafe.Pointer(b2)) { + if p := mv.MapIndex(ValueOf(b1)).Elem().UnsafePointer(); p != unsafe.Pointer(b2) { t.Errorf("#5 MapIndex(b1) = %#x want %p", p, b2) } } @@ -94,7 +94,7 @@ func TestImplicitMapConversion(t *testing.T) { if x != c2 { t.Errorf("#6 after SetMapIndex(c1, c2): %p (!= %p), %t (map=%v)", x, c2, ok, m) } - if p := mv.MapIndex(ValueOf(c1)).Pointer(); p != ValueOf(c2).Pointer() { + if p := mv.MapIndex(ValueOf(c1)).UnsafePointer(); p != ValueOf(c2).UnsafePointer() { t.Errorf("#6 MapIndex(c1) = %#x want %p", p, c2) } } @@ -110,7 +110,7 @@ func TestImplicitMapConversion(t *testing.T) { if x != b2 { t.Errorf("#7 after SetMapIndex(b1, b2): %p (!= %p), %t (map=%v)", x, b2, ok, m) } - if p := mv.MapIndex(ValueOf(b1)).Pointer(); p != uintptr(unsafe.Pointer(b2)) { + if p := mv.MapIndex(ValueOf(b1)).UnsafePointer(); p != unsafe.Pointer(b2) { t.Errorf("#7 MapIndex(b1) = %#x want %p", p, b2) } } diff --git a/src/reflect/type.go b/src/reflect/type.go index afb802e641..96f589ca9c 100644 --- a/src/reflect/type.go +++ b/src/reflect/type.go @@ -2666,8 +2666,8 @@ func StructOf(fields []StructField) Type { {Name: "M", Type: ArrayOf(len(methods), TypeOf(methods[0]))}, })) - typ = (*structType)(unsafe.Pointer(tt.Elem().Field(0).UnsafeAddr())) - ut = (*uncommonType)(unsafe.Pointer(tt.Elem().Field(1).UnsafeAddr())) + typ = (*structType)(tt.Elem().Field(0).Addr().UnsafePointer()) + ut = (*uncommonType)(tt.Elem().Field(1).Addr().UnsafePointer()) copy(tt.Elem().Field(2).Slice(0, len(methods)).Interface().([]method), methods) } diff --git a/src/reflect/value.go b/src/reflect/value.go index 6bc02c1c8c..a272714ac9 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -1933,44 +1933,10 @@ func (v Value) OverflowUint(x uint64) bool { // If v's Kind is Slice, the returned pointer is to the first // element of the slice. If the slice is nil the returned value // is 0. If the slice is empty but non-nil the return value is non-zero. +// +// Deprecated: use uintptr(Value.UnsafePointer()) to get the equivalent result. func (v Value) Pointer() uintptr { - // TODO: deprecate - k := v.kind() - switch k { - case Ptr: - if v.typ.ptrdata == 0 { - // Handle pointers to go:notinheap types directly, - // so we never materialize such pointers as an - // unsafe.Pointer. (Such pointers are always indirect.) - // See issue 42076. - return *(*uintptr)(v.ptr) - } - fallthrough - case Chan, Map, UnsafePointer: - return uintptr(v.pointer()) - case Func: - if v.flag&flagMethod != 0 { - // As the doc comment says, the returned pointer is an - // underlying code pointer but not necessarily enough to - // identify a single function uniquely. All method expressions - // created via reflect have the same underlying code pointer, - // so their Pointers are equal. The function used here must - // match the one used in makeMethodValue. - f := methodValueCall - return **(**uintptr)(unsafe.Pointer(&f)) - } - p := v.pointer() - // Non-nil func value points at data block. - // First word of data block is actual code. - if p != nil { - p = *(*unsafe.Pointer)(p) - } - return uintptr(p) - - case Slice: - return (*SliceHeader)(v.ptr).Data - } - panic(&ValueError{"reflect.Value.Pointer", v.kind()}) + return uintptr(v.UnsafePointer()) } // Recv receives and returns a value from the channel v. @@ -2476,8 +2442,9 @@ func (v Value) Uint() uint64 { // UnsafeAddr returns a pointer to v's data, as a uintptr. // It is for advanced clients that also import the "unsafe" package. // It panics if v is not addressable. +// +// Deprecated: use uintptr(Value.Addr().UnsafePointer()) to get the equivalent result. func (v Value) UnsafeAddr() uintptr { - // TODO: deprecate if v.typ == nil { panic(&ValueError{"reflect.Value.UnsafeAddr", Invalid}) } @@ -2487,6 +2454,57 @@ func (v Value) UnsafeAddr() uintptr { return uintptr(v.ptr) } +// UnsafePointer returns v's value as a unsafe.Pointer. +// It panics if v's Kind is not Chan, Func, Map, Ptr, Slice, or UnsafePointer. +// +// If v's Kind is Func, the returned pointer is an underlying +// code pointer, but not necessarily enough to identify a +// single function uniquely. The only guarantee is that the +// result is zero if and only if v is a nil func Value. +// +// If v's Kind is Slice, the returned pointer is to the first +// element of the slice. If the slice is nil the returned value +// is nil. If the slice is empty but non-nil the return value is non-nil. +func (v Value) UnsafePointer() unsafe.Pointer { + k := v.kind() + switch k { + case Ptr: + if v.typ.ptrdata == 0 { + // Since it is a not-in-heap pointer, all pointers to the heap are + // forbidden! See comment in Value.Elem and issue #48399. + if !verifyNotInHeapPtr(*(*uintptr)(v.ptr)) { + panic("reflect: reflect.Value.UnsafePointer on an invalid notinheap pointer") + } + return *(*unsafe.Pointer)(v.ptr) + } + fallthrough + case Chan, Map, UnsafePointer: + return v.pointer() + case Func: + if v.flag&flagMethod != 0 { + // As the doc comment says, the returned pointer is an + // underlying code pointer but not necessarily enough to + // identify a single function uniquely. All method expressions + // created via reflect have the same underlying code pointer, + // so their Pointers are equal. The function used here must + // match the one used in makeMethodValue. + f := methodValueCall + return **(**unsafe.Pointer)(unsafe.Pointer(&f)) + } + p := v.pointer() + // Non-nil func value points at data block. + // First word of data block is actual code. + if p != nil { + p = *(*unsafe.Pointer)(p) + } + return p + + case Slice: + return (*unsafeheader.Slice)(v.ptr).Data + } + panic(&ValueError{"reflect.Value.UnsafePointer", v.kind()}) +} + // StringHeader is the runtime representation of a string. // It cannot be used safely or portably and its representation may // change in a later release. From 394a1ad2956f0397e83b5f0234ea7e972a307848 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Mon, 18 Oct 2021 10:26:18 -0700 Subject: [PATCH 052/406] cmd/compile: allow importing and exporting of ODYANMICDOTTYPE[2] Fixes #49027 Change-Id: I4520b5c754027bfffbc5cd92c9c27002b248c99a Reviewed-on: https://go-review.googlesource.com/c/go/+/356569 Trust: Keith Randall Trust: Dan Scales Run-TryBot: Keith Randall Reviewed-by: Dan Scales --- src/cmd/compile/internal/typecheck/iexport.go | 8 ++++++ src/cmd/compile/internal/typecheck/iimport.go | 5 ++++ test/typeparam/issue49027.dir/a.go | 21 ++++++++++++++++ test/typeparam/issue49027.dir/main.go | 25 +++++++++++++++++++ test/typeparam/issue49027.go | 7 ++++++ 5 files changed, 66 insertions(+) create mode 100644 test/typeparam/issue49027.dir/a.go create mode 100644 test/typeparam/issue49027.dir/main.go create mode 100644 test/typeparam/issue49027.go diff --git a/src/cmd/compile/internal/typecheck/iexport.go b/src/cmd/compile/internal/typecheck/iexport.go index 3c0b8bc319..e3dd10a56b 100644 --- a/src/cmd/compile/internal/typecheck/iexport.go +++ b/src/cmd/compile/internal/typecheck/iexport.go @@ -1888,6 +1888,14 @@ func (w *exportWriter) expr(n ir.Node) { w.expr(n.X) w.typ(n.Type()) + case ir.ODYNAMICDOTTYPE, ir.ODYNAMICDOTTYPE2: + n := n.(*ir.DynamicTypeAssertExpr) + w.op(n.Op()) + w.pos(n.Pos()) + w.expr(n.X) + w.expr(n.T) + w.typ(n.Type()) + case ir.OINDEX, ir.OINDEXMAP: n := n.(*ir.IndexExpr) if go117ExportTypes { diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index df49d74a40..52236ce837 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -1457,6 +1457,11 @@ func (r *importReader) node() ir.Node { } return n + case ir.ODYNAMICDOTTYPE, ir.ODYNAMICDOTTYPE2: + n := ir.NewDynamicTypeAssertExpr(r.pos(), op, r.expr(), r.expr()) + n.SetType(r.typ()) + return n + case ir.OINDEX, ir.OINDEXMAP: n := ir.NewIndexExpr(r.pos(), r.expr(), r.expr()) if go117ExportTypes { diff --git a/test/typeparam/issue49027.dir/a.go b/test/typeparam/issue49027.dir/a.go new file mode 100644 index 0000000000..d3ec27deab --- /dev/null +++ b/test/typeparam/issue49027.dir/a.go @@ -0,0 +1,21 @@ +// Copyright 2021 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 a + +func Conv(v interface{}) string { + return conv[string](v) +} + +func conv[T any](v interface{}) T { + return v.(T) +} + +func Conv2(v interface{}) (string, bool) { + return conv2[string](v) +} +func conv2[T any](v interface{}) (T, bool) { + x, ok := v.(T) + return x, ok +} diff --git a/test/typeparam/issue49027.dir/main.go b/test/typeparam/issue49027.dir/main.go new file mode 100644 index 0000000000..d0dc33d734 --- /dev/null +++ b/test/typeparam/issue49027.dir/main.go @@ -0,0 +1,25 @@ +// Copyright 2021 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 main + +import ( + "a" + "fmt" +) + +func main() { + s := "foo" + x := a.Conv(s) + if x != s { + panic(fmt.Sprintf("got %s wanted %s", x, s)) + } + y, ok := a.Conv2(s) + if !ok { + panic("conversion failed") + } + if y != s { + panic(fmt.Sprintf("got %s wanted %s", y, s)) + } +} diff --git a/test/typeparam/issue49027.go b/test/typeparam/issue49027.go new file mode 100644 index 0000000000..76930e5e4f --- /dev/null +++ b/test/typeparam/issue49027.go @@ -0,0 +1,7 @@ +// rundir -G=3 + +// Copyright 2021 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 ignored From 267abbe3ba9dda96a8694e8aad8892e3ba2be60e Mon Sep 17 00:00:00 2001 From: Gusted Date: Mon, 18 Oct 2021 17:38:22 +0000 Subject: [PATCH 053/406] html/template: remove unused `mode` field on `Tree` struct This changes Go, to remove this unused field on the `Tree` struct. Which seems to replaced by the non-private field `Mode`. Change-Id: I5b384424cf60aa0af36eb8aad1d8db3f99b9838e GitHub-Last-Rev: 4b033f967b55ff99df8a969ac1c91c358b82b726 GitHub-Pull-Request: golang/go#48028 Reviewed-on: https://go-review.googlesource.com/c/go/+/345789 Trust: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Go Bot Reviewed-by: Rob Pike --- src/text/template/parse/parse.go | 1 - 1 file changed, 1 deletion(-) diff --git a/src/text/template/parse/parse.go b/src/text/template/parse/parse.go index d92bed5d3d..64b29a2e16 100644 --- a/src/text/template/parse/parse.go +++ b/src/text/template/parse/parse.go @@ -32,7 +32,6 @@ type Tree struct { treeSet map[string]*Tree actionLine int // line of left delim starting action rangeDepth int - mode Mode } // A mode value is a set of flags (or 0). Modes control parser behavior. From 6c0daa733192031eab23d09ed6515c4cd959aa92 Mon Sep 17 00:00:00 2001 From: Richard Musiol Date: Sat, 16 Oct 2021 17:17:21 +0200 Subject: [PATCH 054/406] syscall/js: remove Wrapper interface This change removes the js.Wrapper interface for performance reasons. See proposal #44006 for details. This is a breaking change, but syscall/js is exempt from Go's compatibility promise. Fixes #44006 Change-Id: I968cd14b1e61cc72ea9f84240b6bd29e8b8ae673 Reviewed-on: https://go-review.googlesource.com/c/go/+/356430 Trust: Richard Musiol Reviewed-by: Cherry Mui Reviewed-by: Emmanuel Odeke --- src/syscall/js/func.go | 2 -- src/syscall/js/js.go | 17 +++-------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/syscall/js/func.go b/src/syscall/js/func.go index ab23e5fbfc..dde1e68100 100644 --- a/src/syscall/js/func.go +++ b/src/syscall/js/func.go @@ -15,8 +15,6 @@ var ( nextFuncID uint32 = 1 ) -var _ Wrapper = Func{} // Func must implement Wrapper - // Func is a wrapped Go function to be called by JavaScript. type Func struct { Value // the JavaScript function that invokes the Go function diff --git a/src/syscall/js/js.go b/src/syscall/js/js.go index d805d69166..0da0ddfa0f 100644 --- a/src/syscall/js/js.go +++ b/src/syscall/js/js.go @@ -28,12 +28,6 @@ type ref uint64 // nanHead are the upper 32 bits of a ref which are set if the value is not encoded as an IEEE 754 number (see above). const nanHead = 0x7FF80000 -// Wrapper is implemented by types that are backed by a JavaScript value. -type Wrapper interface { - // JSValue returns a JavaScript value associated with an object. - JSValue() Value -} - // Value represents a JavaScript value. The zero value is the JavaScript value "undefined". // Values can be checked for equality with the Equal method. type Value struct { @@ -51,11 +45,6 @@ const ( typeFlagFunction ) -// JSValue implements Wrapper interface. -func (v Value) JSValue() Value { - return v -} - func makeValue(r ref) Value { var gcPtr *ref typeFlag := (r >> 32) & 7 @@ -162,10 +151,10 @@ func Global() Value { // Panics if x is not one of the expected types. func ValueOf(x interface{}) Value { switch x := x.(type) { - case Value: // should precede Wrapper to avoid a loop + case Value: return x - case Wrapper: - return x.JSValue() + case Func: + return x.Value case nil: return valueNull case bool: From 33b3260c1e765ef66500ce155c6d5a526d8852e9 Mon Sep 17 00:00:00 2001 From: Lynn Boger Date: Thu, 14 Oct 2021 10:48:08 -0500 Subject: [PATCH 055/406] cmd/compile/internal/ssagen: set BitLen32 as intrinsic on PPC64 It was noticed through some other investigation that BitLen32 was not generating the best code and found that it wasn't recognized as an intrinsic. This corrects that and enables the test for PPC64. Change-Id: Iab496a8830c8552f507b7292649b1b660f3848b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/355872 Run-TryBot: Lynn Boger TryBot-Result: Go Bot Trust: Lynn Boger Reviewed-by: Cherry Mui --- src/cmd/compile/internal/ssagen/ssa.go | 4 ++-- test/codegen/mathbits.go | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go index 08114b7828..5a958a569d 100644 --- a/src/cmd/compile/internal/ssagen/ssa.go +++ b/src/cmd/compile/internal/ssagen/ssa.go @@ -4421,7 +4421,7 @@ func InitTables() { func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return s.newValue1(ssa.OpBitLen32, types.Types[types.TINT], args[0]) }, - sys.AMD64, sys.ARM64) + sys.AMD64, sys.ARM64, sys.PPC64) addF("math/bits", "Len32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { if s.config.PtrSize == 4 { @@ -4430,7 +4430,7 @@ func InitTables() { x := s.newValue1(ssa.OpZeroExt32to64, types.Types[types.TUINT64], args[0]) return s.newValue1(ssa.OpBitLen64, types.Types[types.TINT], x) }, - sys.ARM, sys.S390X, sys.MIPS, sys.PPC64, sys.Wasm) + sys.ARM, sys.S390X, sys.MIPS, sys.Wasm) addF("math/bits", "Len16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { if s.config.PtrSize == 4 { diff --git a/test/codegen/mathbits.go b/test/codegen/mathbits.go index 2d8790c1de..859490c363 100644 --- a/test/codegen/mathbits.go +++ b/test/codegen/mathbits.go @@ -93,6 +93,8 @@ func Len32(n uint32) int { // arm:"CLZ" arm64:"CLZ" // mips:"CLZ" // wasm:"I64Clz" + // ppc64: "CNTLZW" + // ppc64le: "CNTLZW" return bits.Len32(n) } From 425db64811285fd0b35ed12eaed7568ec547da78 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Fri, 6 Aug 2021 13:23:13 -0700 Subject: [PATCH 056/406] bufio: use underlying ReadFrom even when data is buffered When (*bufio.Writer).ReadFrom is called with a partially filled buffer, fill out and flush the buffer and then call the underlying writer's ReadFrom method if present. Fixes #44815. Change-Id: I15b3ef0746d0d60fd62041189a9b9df11254dd29 Reviewed-on: https://go-review.googlesource.com/c/go/+/340530 Trust: Damien Neil Run-TryBot: Damien Neil TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/bufio/bufio.go | 19 ++++++++-------- src/bufio/bufio_test.go | 48 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/src/bufio/bufio.go b/src/bufio/bufio.go index a58df25494..063a7785f3 100644 --- a/src/bufio/bufio.go +++ b/src/bufio/bufio.go @@ -745,19 +745,14 @@ func (b *Writer) WriteString(s string) (int, error) { } // ReadFrom implements io.ReaderFrom. If the underlying writer -// supports the ReadFrom method, and b has no buffered data yet, -// this calls the underlying ReadFrom without buffering. +// supports the ReadFrom method, this calls the underlying ReadFrom. +// If there is buffered data and an underlying ReadFrom, this fills +// the buffer and writes it before calling ReadFrom. func (b *Writer) ReadFrom(r io.Reader) (n int64, err error) { if b.err != nil { return 0, b.err } - if b.Buffered() == 0 { - if w, ok := b.wr.(io.ReaderFrom); ok { - n, err = w.ReadFrom(r) - b.err = err - return n, err - } - } + readerFrom, readerFromOK := b.wr.(io.ReaderFrom) var m int for { if b.Available() == 0 { @@ -765,6 +760,12 @@ func (b *Writer) ReadFrom(r io.Reader) (n int64, err error) { return n, err1 } } + if readerFromOK && b.Buffered() == 0 { + nn, err := readerFrom.ReadFrom(r) + b.err = err + n += nn + return n, err + } nr := 0 for nr < maxConsecutiveEmptyReads { m, err = r.Read(b.buf[b.n:]) diff --git a/src/bufio/bufio_test.go b/src/bufio/bufio_test.go index 8e8a8a1778..66b3e70053 100644 --- a/src/bufio/bufio_test.go +++ b/src/bufio/bufio_test.go @@ -1351,6 +1351,54 @@ func TestWriterReadFromErrNoProgress(t *testing.T) { } } +type readFromWriter struct { + buf []byte + writeBytes int + readFromBytes int +} + +func (w *readFromWriter) Write(p []byte) (int, error) { + w.buf = append(w.buf, p...) + w.writeBytes += len(p) + return len(p), nil +} + +func (w *readFromWriter) ReadFrom(r io.Reader) (int64, error) { + b, err := io.ReadAll(r) + w.buf = append(w.buf, b...) + w.readFromBytes += len(b) + return int64(len(b)), err +} + +// Test that calling (*Writer).ReadFrom with a partially-filled buffer +// fills the buffer before switching over to ReadFrom. +func TestWriterReadFromWithBufferedData(t *testing.T) { + const bufsize = 16 + + input := createTestInput(64) + rfw := &readFromWriter{} + w := NewWriterSize(rfw, bufsize) + + const writeSize = 8 + if n, err := w.Write(input[:writeSize]); n != writeSize || err != nil { + t.Errorf("w.Write(%v bytes) = %v, %v; want %v, nil", writeSize, n, err, writeSize) + } + n, err := w.ReadFrom(bytes.NewReader(input[writeSize:])) + if wantn := len(input[writeSize:]); int(n) != wantn || err != nil { + t.Errorf("io.Copy(w, %v bytes) = %v, %v; want %v, nil", wantn, n, err, wantn) + } + if err := w.Flush(); err != nil { + t.Errorf("w.Flush() = %v, want nil", err) + } + + if got, want := rfw.writeBytes, bufsize; got != want { + t.Errorf("wrote %v bytes with Write, want %v", got, want) + } + if got, want := rfw.readFromBytes, len(input)-bufsize; got != want { + t.Errorf("wrote %v bytes with ReadFrom, want %v", got, want) + } +} + func TestReadZero(t *testing.T) { for _, size := range []int{100, 2} { t.Run(fmt.Sprintf("bufsize=%d", size), func(t *testing.T) { From 3befaf0cdb18420f45acfa7cee725297aa550faf Mon Sep 17 00:00:00 2001 From: jiahua wang Date: Sat, 16 Oct 2021 23:19:57 +0800 Subject: [PATCH 057/406] net/url: fix stale RFC 3986 links The URLs for RFC 3986 have been changed from: http://tools.ietf.org/html/rfc3986 to: https://datatracker.ietf.org/doc/html/rfc3986 Change-Id: I0662557d91bbb7de51d7ca4bc64e838741cd9074 Reviewed-on: https://go-review.googlesource.com/c/go/+/356429 Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Emmanuel Odeke Trust: Cherry Mui --- src/net/url/url_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/net/url/url_test.go b/src/net/url/url_test.go index 5059d34bf1..6807d58f1a 100644 --- a/src/net/url/url_test.go +++ b/src/net/url/url_test.go @@ -1172,7 +1172,7 @@ var resolveReferenceTests = []struct { {"http://foo.com/bar/baz", "quux/./dotdot/../dotdot/../dot/./tail/..", "http://foo.com/bar/quux/dot/"}, // Remove any dot-segments prior to forming the target URI. - // http://tools.ietf.org/html/rfc3986#section-5.2.4 + // https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4 {"http://foo.com/dot/./dotdot/../foo/bar", "../baz", "http://foo.com/dot/baz"}, // Triple dot isn't special @@ -1192,7 +1192,7 @@ var resolveReferenceTests = []struct { {"http://foo.com/foo%2dbar/", "./baz-quux", "http://foo.com/foo%2dbar/baz-quux"}, // RFC 3986: Normal Examples - // http://tools.ietf.org/html/rfc3986#section-5.4.1 + // https://datatracker.ietf.org/doc/html/rfc3986#section-5.4.1 {"http://a/b/c/d;p?q", "g:h", "g:h"}, {"http://a/b/c/d;p?q", "g", "http://a/b/c/g"}, {"http://a/b/c/d;p?q", "./g", "http://a/b/c/g"}, @@ -1218,7 +1218,7 @@ var resolveReferenceTests = []struct { {"http://a/b/c/d;p?q", "../../g", "http://a/g"}, // RFC 3986: Abnormal Examples - // http://tools.ietf.org/html/rfc3986#section-5.4.2 + // https://datatracker.ietf.org/doc/html/rfc3986#section-5.4.2 {"http://a/b/c/d;p?q", "../../../g", "http://a/g"}, {"http://a/b/c/d;p?q", "../../../../g", "http://a/g"}, {"http://a/b/c/d;p?q", "/./g", "http://a/g"}, From 73971784dc586a5db3b81dfdd41954f650d493ac Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Fri, 15 Oct 2021 10:52:55 -0400 Subject: [PATCH 058/406] go/types: add support for inferring type instances Add constraint type inference for type instances, to be consistent with inference of function values. Fixes #47990 Change-Id: Ib99b5215cb2da5c10badc4de7e9e60ca0e48489f Reviewed-on: https://go-review.googlesource.com/c/go/+/356489 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/call.go | 32 +++++++- src/go/types/instantiate.go | 50 ------------ src/go/types/named.go | 3 +- .../{tinference.go2 => funcinference.go2} | 30 +++---- src/go/types/testdata/check/typeinference.go2 | 47 +++++++++++ src/go/types/testdata/check/typeinst2.go2 | 4 + .../types/testdata/check/typeinstcycles.go2 | 11 +++ src/go/types/typexpr.go | 79 ++++++++++++++++--- 8 files changed, 175 insertions(+), 81 deletions(-) rename src/go/types/testdata/check/{tinference.go2 => funcinference.go2} (77%) create mode 100644 src/go/types/testdata/check/typeinference.go2 create mode 100644 src/go/types/testdata/check/typeinstcycles.go2 diff --git a/src/go/types/call.go b/src/go/types/call.go index a642f6f295..4731c69619 100644 --- a/src/go/types/call.go +++ b/src/go/types/call.go @@ -60,7 +60,7 @@ func (check *Checker) funcInst(x *operand, ix *typeparams.IndexExpr) { } // instantiate function signature - res := check.instantiate(x.Pos(), sig, targs, poslist).(*Signature) + res := check.instantiateSignature(x.Pos(), sig, targs, poslist) assert(res.TypeParams().Len() == 0) // signature is not generic anymore check.recordInstance(ix.Orig, targs, res) x.typ = res @@ -68,6 +68,34 @@ func (check *Checker) funcInst(x *operand, ix *typeparams.IndexExpr) { x.expr = ix.Orig } +func (check *Checker) instantiateSignature(pos token.Pos, typ *Signature, targs []Type, posList []token.Pos) (res *Signature) { + assert(check != nil) + assert(len(targs) == typ.TypeParams().Len()) + + if trace { + check.trace(pos, "-- instantiating %s with %s", typ, targs) + check.indent++ + defer func() { + check.indent-- + check.trace(pos, "=> %s (under = %s)", res, res.Underlying()) + }() + } + + inst := check.instance(pos, typ, targs, check.conf.Context).(*Signature) + assert(len(posList) <= len(targs)) + tparams := typ.TypeParams().list() + if i, err := check.verify(pos, tparams, targs); err != nil { + // best position for error reporting + pos := pos + if i < len(posList) { + pos = posList[i] + } + check.softErrorf(atPos(pos), _Todo, err.Error()) + } + + return inst +} + func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind { ix := typeparams.UnpackIndexExpr(call.Fun) if ix != nil { @@ -352,7 +380,7 @@ func (check *Checker) arguments(call *ast.CallExpr, sig *Signature, targs []Type } // compute result signature - rsig = check.instantiate(call.Pos(), sig, targs, nil).(*Signature) + rsig = check.instantiateSignature(call.Pos(), sig, targs, nil) assert(rsig.TypeParams().Len() == 0) // signature is not generic anymore check.recordInstance(call.Fun, targs, rsig) diff --git a/src/go/types/instantiate.go b/src/go/types/instantiate.go index 2a255bcb87..65c935a192 100644 --- a/src/go/types/instantiate.go +++ b/src/go/types/instantiate.go @@ -49,56 +49,6 @@ func Instantiate(ctxt *Context, typ Type, targs []Type, validate bool) (Type, er return inst, err } -// instantiate creates an instance and defers verification of constraints to -// later in the type checking pass. For Named types the resulting instance will -// be unexpanded. -func (check *Checker) instantiate(pos token.Pos, typ Type, targs []Type, posList []token.Pos) (res Type) { - assert(check != nil) - if trace { - check.trace(pos, "-- instantiating %s with %s", typ, NewTypeList(targs)) - check.indent++ - defer func() { - check.indent-- - var under Type - if res != nil { - // Calling under() here may lead to endless instantiations. - // Test case: type T[P any] T[P] - // TODO(gri) investigate if that's a bug or to be expected. - under = safeUnderlying(res) - } - check.trace(pos, "=> %s (under = %s)", res, under) - }() - } - - inst := check.instance(pos, typ, targs, check.conf.Context) - - assert(len(posList) <= len(targs)) - check.later(func() { - // Collect tparams again because lazily loaded *Named types may not have - // had tparams set up above. - var tparams []*TypeParam - switch t := typ.(type) { - case *Named: - tparams = t.TypeParams().list() - case *Signature: - tparams = t.TypeParams().list() - } - // Avoid duplicate errors; instantiate will have complained if tparams - // and targs do not have the same length. - if len(tparams) == len(targs) { - if i, err := check.verify(pos, tparams, targs); err != nil { - // best position for error reporting - pos := pos - if i < len(posList) { - pos = posList[i] - } - check.softErrorf(atPos(pos), _Todo, err.Error()) - } - } - }) - return inst -} - // instance creates a type or function instance using the given original type // typ and arguments targs. For Named types the resulting instance will be // unexpanded. diff --git a/src/go/types/named.go b/src/go/types/named.go index 82b2afcb63..595863a01b 100644 --- a/src/go/types/named.go +++ b/src/go/types/named.go @@ -241,7 +241,8 @@ func expandNamed(ctxt *Context, n *Named, instPos token.Pos) (tparams *TypeParam check := n.check - if check.validateTArgLen(instPos, n.orig.tparams.Len(), n.targs.Len()) { + // Mismatching arg and tparam length may be checked elsewhere. + if n.orig.tparams.Len() == n.targs.Len() { // We must always have a context, to avoid infinite recursion. ctxt = check.bestContext(ctxt) h := ctxt.typeHash(n.orig, n.targs.list()) diff --git a/src/go/types/testdata/check/tinference.go2 b/src/go/types/testdata/check/funcinference.go2 similarity index 77% rename from src/go/types/testdata/check/tinference.go2 rename to src/go/types/testdata/check/funcinference.go2 index 28516ef639..f04b76ca1a 100644 --- a/src/go/types/testdata/check/tinference.go2 +++ b/src/go/types/testdata/check/funcinference.go2 @@ -2,29 +2,25 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package tinferenceB +package funcInference import "strconv" type any interface{} -// TODO(rFindley) the below partially applied function types should probably -// not be permitted (spec question). +func f0[A any, B interface{~*C}, C interface{~*D}, D interface{~*A}](A, B, C, D) {} +func _() { + f := f0[string] + f("a", nil, nil, nil) + f0("a", nil, nil, nil) +} -// Embedding stand-alone type parameters is not permitted for now. Disabled. -// func f0[A any, B interface{~C}, C interface{~D}, D interface{~A}](A, B, C, D) -// func _() { -// f := f0[string] -// f("a", "b", "c", "d") -// f0("a", "b", "c", "d") -// } -// -// func f1[A any, B interface{~A}](A, B) -// func _() { -// f := f1[int] -// f(int(0), int(0)) -// f1(int(0), int(0)) -// } +func f1[A any, B interface{~*A}](A, B) {} +func _() { + f := f1[int] + f(int(0), new(int)) + f1(int(0), new(int)) +} func f2[A any, B interface{~[]A}](A, B) {} func _() { diff --git a/src/go/types/testdata/check/typeinference.go2 b/src/go/types/testdata/check/typeinference.go2 new file mode 100644 index 0000000000..8876ccaa4e --- /dev/null +++ b/src/go/types/testdata/check/typeinference.go2 @@ -0,0 +1,47 @@ +// Copyright 2021 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 typeInference + +// basic inference +type Tb[P ~*Q, Q any] int +func _() { + var x Tb[*int] + var y Tb[*int, int] + x = y + _ = x +} + +// recursive inference +type Tr[A any, B ~*C, C ~*D, D ~*A] int +func _() { + var x Tr[string] + var y Tr[string, ***string, **string, *string] + var z Tr[int, ***int, **int, *int] + x = y + x = z // ERROR cannot use z .* as Tr + _ = x +} + +// other patterns of inference +type To0[A any, B ~[]A] int +type To1[A any, B ~struct{a A}] int +type To2[A any, B ~[][]A] int +type To3[A any, B ~[3]*A] int +type To4[A any, B any, C ~struct{a A; b B}] int +func _() { + var _ To0[int] + var _ To1[int] + var _ To2[int] + var _ To3[int] + var _ To4[int, string] +} + +// failed inference +type Tf0[A, B any] int +type Tf1[A any, B ~struct{a A; c C}, C any] int +func _() { + var _ Tf0 /* ERROR cannot infer B */ /* ERROR got 1 arguments but 2 type parameters */ [int] + var _ Tf1 /* ERROR cannot infer B */ /* ERROR got 1 arguments but 3 type parameters */ [int] +} diff --git a/src/go/types/testdata/check/typeinst2.go2 b/src/go/types/testdata/check/typeinst2.go2 index 95c249d529..88913785c8 100644 --- a/src/go/types/testdata/check/typeinst2.go2 +++ b/src/go/types/testdata/check/typeinst2.go2 @@ -255,3 +255,7 @@ var _ = f0_[int] var _ = f0_[bool /* ERROR does not satisfy I0_ */ ] var _ = f0_[string /* ERROR does not satisfy I0_ */ ] var _ = f0_[float64 /* ERROR does not satisfy I0_ */ ] + +// Using a function instance as a type is an error. +var _ f0 // ERROR not a type +var _ f0 /* ERROR not a type */ [int] diff --git a/src/go/types/testdata/check/typeinstcycles.go2 b/src/go/types/testdata/check/typeinstcycles.go2 new file mode 100644 index 0000000000..74fe19195a --- /dev/null +++ b/src/go/types/testdata/check/typeinstcycles.go2 @@ -0,0 +1,11 @@ +// Copyright 2021 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 p + +import "unsafe" + +func F1[T any](_ [unsafe.Sizeof(F1[int])]T) (res T) { return } +func F2[T any](_ T) (res [unsafe.Sizeof(F2[string])]int) { return } +func F3[T any](_ [unsafe.Sizeof(F1[string])]int) {} diff --git a/src/go/types/typexpr.go b/src/go/types/typexpr.go index 71623c336e..e812c3d5d5 100644 --- a/src/go/types/typexpr.go +++ b/src/go/types/typexpr.go @@ -265,7 +265,6 @@ func (check *Checker) typInternal(e0 ast.Expr, def *Named) (T Type) { if !check.allowVersion(check.pkg, 1, 18) { check.softErrorf(inNode(e, ix.Lbrack), _Todo, "type instantiation requires go1.18 or later") } - // TODO(rfindley): type instantiation should require go1.18 return check.instantiatedType(ix.X, ix.Indices, def) case *ast.ParenExpr: @@ -375,13 +374,24 @@ func (check *Checker) typInternal(e0 ast.Expr, def *Named) (T Type) { return typ } -func (check *Checker) instantiatedType(x ast.Expr, targsx []ast.Expr, def *Named) Type { +func (check *Checker) instantiatedType(x ast.Expr, targsx []ast.Expr, def *Named) (res Type) { + if trace { + check.trace(x.Pos(), "-- instantiating %s with %s", x, targsx) + check.indent++ + defer func() { + check.indent-- + // Don't format the underlying here. It will always be nil. + check.trace(x.Pos(), "=> %s", res) + }() + } + gtyp := check.genericType(x, true) if gtyp == Typ[Invalid] { return gtyp // error already reported } - base, _ := gtyp.(*Named) - if base == nil { + + origin, _ := gtyp.(*Named) + if origin == nil { panic(fmt.Sprintf("%v: cannot instantiate %v", x.Pos(), gtyp)) } @@ -398,17 +408,64 @@ func (check *Checker) instantiatedType(x ast.Expr, targsx []ast.Expr, def *Named posList[i] = arg.Pos() } - typ := check.instantiate(x.Pos(), base, targs, posList) - def.setUnderlying(typ) - check.recordInstance(x, targs, typ) + // create the instance + h := check.conf.Context.typeHash(origin, targs) + // targs may be incomplete, and require inference. In any case we should de-duplicate. + inst := check.conf.Context.typeForHash(h, nil) + // If inst is non-nil, we can't just return here. Inst may have been + // constructed via recursive substitution, in which case we wouldn't do the + // validation below. Ensure that the validation (and resulting errors) runs + // for each instantiated type in the source. + if inst == nil { + tname := NewTypeName(x.Pos(), origin.obj.pkg, origin.obj.name, nil) + inst = check.newNamed(tname, origin, nil, nil, nil) // underlying, methods and tparams are set when named is resolved + inst.targs = NewTypeList(targs) + inst = check.conf.Context.typeForHash(h, inst) + } + def.setUnderlying(inst) - // make sure we check instantiation works at least once - // and that the resulting type is valid + inst.resolver = func(ctxt *Context, n *Named) (*TypeParamList, Type, []*Func) { + tparams := origin.TypeParams().list() + + inferred := targs + if len(targs) < len(tparams) { + // If inference fails, len(inferred) will be 0, and inst.underlying will + // be set to Typ[Invalid] in expandNamed. + inferred = check.infer(x, tparams, targs, nil, nil) + if len(inferred) > len(targs) { + inst.targs = NewTypeList(inferred) + } + } + + check.recordInstance(x, inferred, inst) + return expandNamed(ctxt, n, x.Pos()) + } + + // origin.tparams may not be set up, so we need to do expansion later. check.later(func() { - check.validType(typ, nil) + // This is an instance from the source, not from recursive substitution, + // and so it must be resolved during type-checking so that we can report + // errors. + inst.resolve(check.conf.Context) + // Since check is non-nil, we can still mutate inst. Unpinning the resolver + // frees some memory. + inst.resolver = nil + + if check.validateTArgLen(x.Pos(), inst.tparams.Len(), inst.targs.Len()) { + if i, err := check.verify(x.Pos(), inst.tparams.list(), inst.targs.list()); err != nil { + // best position for error reporting + pos := x.Pos() + if i < len(posList) { + pos = posList[i] + } + check.softErrorf(atPos(pos), _Todo, err.Error()) + } + } + + check.validType(inst, nil) }) - return typ + return inst } // arrayLength type-checks the array length expression e From 323e009c757229bdf58f68fde1c5bf07e9e65b61 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Fri, 15 Oct 2021 16:39:39 -0400 Subject: [PATCH 059/406] go/types: ensure named types are expanded after type-checking Rather than using Checker.later in newNamed, add a Checker.defTypes field to track named types that have been created during type-checking, and use this to expand named types as a final phase in type checking. We have encountered several bugs related to infinite recursion while expanding named types, because (I would argue) we have two conflicting requirements in the type checker: ensuring that we eventually collapse underlying chains, and yet allowing lazy substitution of the underlying type in instances. The former is necessary for correctness, and to ensure that we detect cycles during the type-checking pass. The latter is necessary to allow infinitely expanding patterns of instances through underlying or method definitions. I believe this CL reconciles these conflicting requirements, by creating a boundary between types that are encountered in the source during type checking, and instances that are created by recursive evaluation. At the end of the type checking pass, Checker.defTypes should contain all possible origin types for instantiation. Once we compute the true underlying for these origin types, any remaining instances that are unresolved are guaranteed to have an origin with a valid underlying. Therefore, we can return from the type-checking pass without calling under() for these remaining instances. Fixes #48703 Fixes #48974 Change-Id: I1474f514e2ab71c1ad4c3704fe32bfba11d59394 Reviewed-on: https://go-review.googlesource.com/c/go/+/356490 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/check.go | 27 +++++++++++++++++++ src/go/types/named.go | 23 ++++++---------- .../types/testdata/fixedbugs/issue48703.go2 | 27 +++++++++++++++++++ .../types/testdata/fixedbugs/issue48974.go2 | 22 +++++++++++++++ 4 files changed, 84 insertions(+), 15 deletions(-) create mode 100644 src/go/types/testdata/fixedbugs/issue48703.go2 create mode 100644 src/go/types/testdata/fixedbugs/issue48974.go2 diff --git a/src/go/types/check.go b/src/go/types/check.go index 46a0000940..3fc9c03917 100644 --- a/src/go/types/check.go +++ b/src/go/types/check.go @@ -113,6 +113,7 @@ type Checker struct { untyped map[ast.Expr]exprInfo // map of expressions without final type delayed []func() // stack of delayed action segments; segments are processed in FIFO order objPath []Object // path of object dependencies during type inference (for cycle reporting) + defTypes []*Named // defined types created during type checking, for final validation. // context within which the current object is type-checked // (valid only for the duration of type-checking a specific object) @@ -269,6 +270,8 @@ func (check *Checker) checkFiles(files []*ast.File) (err error) { check.processDelayed(0) // incl. all functions + check.expandDefTypes() + check.initOrder() if !check.conf.DisableUnusedImportCheck { @@ -285,6 +288,7 @@ func (check *Checker) checkFiles(files []*ast.File) (err error) { check.pkgPathMap = nil check.seenPkgMap = nil check.recvTParamMap = nil + check.defTypes = nil // TODO(rFindley) There's more memory we should release at this point. @@ -306,6 +310,29 @@ func (check *Checker) processDelayed(top int) { check.delayed = check.delayed[:top] } +func (check *Checker) expandDefTypes() { + // Ensure that every defined type created in the course of type-checking has + // either non-*Named underlying, or is unresolved. + // + // This guarantees that we don't leak any types whose underlying is *Named, + // because any unresolved instances will lazily compute their underlying by + // substituting in the underlying of their origin. The origin must have + // either been imported or type-checked and expanded here, and in either case + // its underlying will be fully expanded. + for i := 0; i < len(check.defTypes); i++ { + n := check.defTypes[i] + switch n.underlying.(type) { + case nil: + if n.resolver == nil { + panic("nil underlying") + } + case *Named: + n.under() // n.under may add entries to check.defTypes + } + n.check = nil + } +} + func (check *Checker) record(x *operand) { // convert x into a user-friendly set of values // TODO(gri) this code can be simplified diff --git a/src/go/types/named.go b/src/go/types/named.go index 595863a01b..c81383810e 100644 --- a/src/go/types/named.go +++ b/src/go/types/named.go @@ -65,22 +65,9 @@ func (check *Checker) newNamed(obj *TypeName, orig *Named, underlying Type, tpar if obj.typ == nil { obj.typ = typ } - // Ensure that typ is always expanded, at which point the check field can be - // nilled out. - // - // Note that currently we cannot nil out check inside typ.under(), because - // it's possible that typ is expanded multiple times. - // - // TODO(rFindley): clean this up so that under is the only function mutating - // named types. + // Ensure that typ is always expanded and sanity-checked. if check != nil { - check.later(func() { - switch typ.under().(type) { - case *Named: - panic("unexpanded underlying type") - } - typ.check = nil - }) + check.defTypes = append(check.defTypes, typ) } return typ } @@ -241,6 +228,12 @@ func expandNamed(ctxt *Context, n *Named, instPos token.Pos) (tparams *TypeParam check := n.check + if _, unexpanded := n.orig.underlying.(*Named); unexpanded { + // We should only get an unexpanded underlying here during type checking + // (for example, in recursive type declarations). + assert(check != nil) + } + // Mismatching arg and tparam length may be checked elsewhere. if n.orig.tparams.Len() == n.targs.Len() { // We must always have a context, to avoid infinite recursion. diff --git a/src/go/types/testdata/fixedbugs/issue48703.go2 b/src/go/types/testdata/fixedbugs/issue48703.go2 new file mode 100644 index 0000000000..8a32c1ecf2 --- /dev/null +++ b/src/go/types/testdata/fixedbugs/issue48703.go2 @@ -0,0 +1,27 @@ +// Copyright 2021 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 p + +import "unsafe" + +// The actual example from the issue. +type List[P any] struct{} + +func (_ List[P]) m() (_ List[List[P]]) { return } + +// Other types of recursion through methods. +type R[P any] int + +func (*R[R /* ERROR must be an identifier */ [int]]) m0() {} +func (R[P]) m1(R[R[P]]) {} +func (R[P]) m2(R[*P]) {} +func (R[P]) m3([unsafe.Sizeof(new(R[P]))]int) {} +func (R[P]) m4([unsafe.Sizeof(new(R[R[P]]))]int) {} + +// Mutual recursion +type M[P any] int + +func (R[P]) m5(M[M[P]]) {} +func (M[P]) m(R[R[P]]) {} diff --git a/src/go/types/testdata/fixedbugs/issue48974.go2 b/src/go/types/testdata/fixedbugs/issue48974.go2 new file mode 100644 index 0000000000..ca4b6d9321 --- /dev/null +++ b/src/go/types/testdata/fixedbugs/issue48974.go2 @@ -0,0 +1,22 @@ +// Copyright 2021 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 p + +type Fooer interface { + Foo() +} + +type Fooable[F Fooer] struct { + ptr F +} + +func (f *Fooable[F]) Adapter() *Fooable[*FooerImpl[F]] { + return &Fooable[*FooerImpl[F]]{&FooerImpl[F]{}} +} + +type FooerImpl[F Fooer] struct { +} + +func (fi *FooerImpl[F]) Foo() {} From eba0e866fafe3f8223d654a29fb953e02c07364a Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Sun, 17 Oct 2021 18:27:53 -0400 Subject: [PATCH 060/406] go/types: delay expansion of underlying in typeDecl Even after type-checking the RHS of a type declaration, we may not yet be able to expand, if the RHS is itself an instance (see #49043). We can instead rely on the mechanisms we have in place for delayed expansion. Fixes #49043 Change-Id: Ibffa4c1b1163c824b5c7e151aaac35f3e8c84ec7 Reviewed-on: https://go-review.googlesource.com/c/go/+/356533 Trust: Robert Findley Run-TryBot: Robert Findley Reviewed-by: Robert Griesemer --- src/go/types/decl.go | 23 +++++------------- src/go/types/named.go | 17 ++++++++++++- src/go/types/testdata/check/typeinst.go2 | 2 +- .../types/testdata/fixedbugs/issue49043.go2 | 24 +++++++++++++++++++ 4 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 src/go/types/testdata/fixedbugs/issue49043.go2 diff --git a/src/go/types/decl.go b/src/go/types/decl.go index 4aa49b17ca..3e97fbbccd 100644 --- a/src/go/types/decl.go +++ b/src/go/types/decl.go @@ -647,22 +647,11 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *Named) { assert(rhs != nil) named.fromRHS = rhs - // The underlying type of named may be itself a named type that is - // incomplete: - // - // type ( - // A B - // B *C - // C A - // ) - // - // The type of C is the (named) type of A which is incomplete, - // and which has as its underlying type the named type B. - // Determine the (final, unnamed) underlying type by resolving - // any forward chain. - // TODO(gri) Investigate if we can just use named.fromRHS here - // and rely on lazy computation of the underlying type. - named.underlying = under(named) + // If the underlying was not set while type-checking the right-hand side, it + // is invalid and an error should have been reported elsewhere. + if named.underlying == nil { + named.underlying = Typ[Invalid] + } // If the RHS is a type parameter, it must be from this type declaration. if tpar, _ := named.underlying.(*TypeParam); tpar != nil && tparamIndex(named.TypeParams().list(), tpar) < 0 { @@ -776,7 +765,7 @@ func (check *Checker) collectMethods(obj *TypeName) { // and field names must be distinct." base := asNamed(obj.typ) // shouldn't fail but be conservative if base != nil { - u := safeUnderlying(base) // base should be expanded, but use safeUnderlying to be conservative + u := base.under() if t, _ := u.(*Struct); t != nil { for _, fld := range t.fields { if fld.name != "_" { diff --git a/src/go/types/named.go b/src/go/types/named.go index c81383810e..393d40b127 100644 --- a/src/go/types/named.go +++ b/src/go/types/named.go @@ -132,6 +132,18 @@ func (t *Named) String() string { return TypeString(t, nil) } // chain before returning it. If no underlying type is found or a cycle // is detected, the result is Typ[Invalid]. If a cycle is detected and // n0.check != nil, the cycle is reported. +// +// This is necessary because the underlying type of named may be itself a +// named type that is incomplete: +// +// type ( +// A B +// B *C +// C A +// ) +// +// The type of C is the (named) type of A which is incomplete, +// and which has as its underlying type the named type B. func (n0 *Named) under() Type { u := n0.Underlying() @@ -141,7 +153,9 @@ func (n0 *Named) under() Type { var n1 *Named switch u1 := u.(type) { case nil: - return Typ[Invalid] + // After expansion via Underlying(), we should never encounter a nil + // underlying. + panic("nil underlying") default: // common case return u @@ -225,6 +239,7 @@ func (check *Checker) bestContext(ctxt *Context) *Context { // The underlying type will be Typ[Invalid] if there was an error. func expandNamed(ctxt *Context, n *Named, instPos token.Pos) (tparams *TypeParamList, underlying Type, methods []*Func) { n.orig.resolve(ctxt) + assert(n.orig.underlying != nil) check := n.check diff --git a/src/go/types/testdata/check/typeinst.go2 b/src/go/types/testdata/check/typeinst.go2 index 4a8918ab86..f4f6c0264b 100644 --- a/src/go/types/testdata/check/typeinst.go2 +++ b/src/go/types/testdata/check/typeinst.go2 @@ -57,5 +57,5 @@ var _ T3[int] = T3[int](List[int]{1, 2, 3}) // Self-recursive generic types are not permitted -type self1[P any] self1 /* ERROR illegal cycle */ [P] +type self1 /* ERROR illegal cycle */ [P any] self1[P] type self2[P any] *self2[P] // this is ok diff --git a/src/go/types/testdata/fixedbugs/issue49043.go2 b/src/go/types/testdata/fixedbugs/issue49043.go2 new file mode 100644 index 0000000000..c37b0f1267 --- /dev/null +++ b/src/go/types/testdata/fixedbugs/issue49043.go2 @@ -0,0 +1,24 @@ +// Copyright 2021 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 p + +// The example from the issue. +type ( + N /* ERROR illegal cycle */ [P any] M[P] + M[P any] N[P] +) + +// A slightly more complicated case. +type ( + A /* ERROR illegal cycle */ [P any] B[P] + B[P any] C[P] + C[P any] A[P] +) + +// Confusing but valid (note that `type T *T` is valid). +type ( + N1[P any] *M1[P] + M1[P any] *N1[P] +) From 8838a3b53fccc7b3aa83312326bfd38bcb8f2281 Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Fri, 8 Oct 2021 20:28:58 +1100 Subject: [PATCH 061/406] cmd/internal/obj/riscv: fix and enable test in short mode The branch test only takes a few seconds so enable it in short mode. Also fix a typo that currently prevents the code from compiling. Change-Id: I25fc646b002a66c042c61fb1f56d5efa8e47903c Reviewed-on: https://go-review.googlesource.com/c/go/+/356249 Trust: Joel Sing Reviewed-by: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Go Bot --- src/cmd/internal/obj/riscv/asm_test.go | 3 --- src/cmd/internal/obj/riscv/testdata/testbranch/branch_test.go | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cmd/internal/obj/riscv/asm_test.go b/src/cmd/internal/obj/riscv/asm_test.go index f8f7b4f2ce..684c6b61f2 100644 --- a/src/cmd/internal/obj/riscv/asm_test.go +++ b/src/cmd/internal/obj/riscv/asm_test.go @@ -134,9 +134,6 @@ TEXT _stub(SB),$0-0 } func TestBranch(t *testing.T) { - if testing.Short() { - t.Skip("Skipping in short mode") - } if runtime.GOARCH != "riscv64" { t.Skip("Requires riscv64 to run") } diff --git a/src/cmd/internal/obj/riscv/testdata/testbranch/branch_test.go b/src/cmd/internal/obj/riscv/testdata/testbranch/branch_test.go index de412c64a7..68d9589bf2 100644 --- a/src/cmd/internal/obj/riscv/testdata/testbranch/branch_test.go +++ b/src/cmd/internal/obj/riscv/testdata/testbranch/branch_test.go @@ -32,7 +32,7 @@ func testGoBGTU(a, b int64) bool { return uint64(a) > uint64(b) } func testGoBLE(a, b int64) bool { return a <= b } func testGoBLEU(a, b int64) bool { return uint64(a) <= uint64(b) } func testGoBLT(a, b int64) bool { return a < b } -func testGoBLTZ(a, b int64) bool { return uint64(a) < uint64(b) } +func testGoBLTU(a, b int64) bool { return uint64(a) < uint64(b) } func TestBranchCondition(t *testing.T) { tests := []struct { From ee92daae25029882979eb694bd7246491e364d3c Mon Sep 17 00:00:00 2001 From: Meng Zhuo Date: Mon, 20 Sep 2021 20:44:50 +0800 Subject: [PATCH 062/406] runtime: ensure at least 1 tick between events ticks might be same after tick division, although the real cputicks is linear growth Fixes #46737 Change-Id: I1d98866fbf21b426c6c1c96cc9cf802d7f440f18 Reviewed-on: https://go-review.googlesource.com/c/go/+/330849 Trust: Meng Zhuo Trust: Bryan C. Mills Run-TryBot: Meng Zhuo Reviewed-by: Michael Knyszek TryBot-Result: Go Bot --- src/runtime/trace.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/runtime/trace.go b/src/runtime/trace.go index 00544e4283..5b14a5f553 100644 --- a/src/runtime/trace.go +++ b/src/runtime/trace.go @@ -551,8 +551,15 @@ func traceEventLocked(extraBytes int, mp *m, pid int32, bufp *traceBufPtr, ev by bufp.set(buf) } + // NOTE: ticks might be same after tick division, although the real cputicks is + // linear growth. ticks := uint64(cputicks()) / traceTickDiv tickDiff := ticks - buf.lastTicks + if tickDiff == 0 { + ticks = buf.lastTicks + 1 + tickDiff = 1 + } + buf.lastTicks = ticks narg := byte(len(args)) if skip >= 0 { @@ -653,6 +660,9 @@ func traceFlush(buf traceBufPtr, pid int32) traceBufPtr { // initialize the buffer for a new batch ticks := uint64(cputicks()) / traceTickDiv + if ticks == bufp.lastTicks { + ticks = bufp.lastTicks + 1 + } bufp.lastTicks = ticks bufp.byte(traceEvBatch | 1< Date: Thu, 9 Sep 2021 00:32:03 +0800 Subject: [PATCH 063/406] encoding/base64: add examples for Encode/Decode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #37595 Change-Id: I83e5f6105748a0a9238322a4f7ec4b0bbf61a263 Reviewed-on: https://go-review.googlesource.com/c/go/+/348394 Reviewed-by: Daniel Martí Reviewed-by: Ian Lance Taylor Trust: Daniel Martí Trust: Cherry Mui --- src/encoding/base64/example_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/encoding/base64/example_test.go b/src/encoding/base64/example_test.go index 73f119ac5e..61a3adc5ad 100644 --- a/src/encoding/base64/example_test.go +++ b/src/encoding/base64/example_test.go @@ -35,6 +35,15 @@ func ExampleEncoding_EncodeToString() { // YW55ICsgb2xkICYgZGF0YQ== } +func ExampleEncoding_Encode() { + data := []byte("Hello, world!") + dst := make([]byte, base64.StdEncoding.EncodedLen(len(data))) + base64.StdEncoding.Encode(dst, data) + fmt.Println(string(dst)) + // Output: + // SGVsbG8sIHdvcmxkIQ== +} + func ExampleEncoding_DecodeString() { str := "c29tZSBkYXRhIHdpdGggACBhbmQg77u/" data, err := base64.StdEncoding.DecodeString(str) @@ -47,6 +56,20 @@ func ExampleEncoding_DecodeString() { // "some data with \x00 and \ufeff" } +func ExampleEncoding_Decode() { + str := "SGVsbG8sIHdvcmxkIQ==" + dst := make([]byte, base64.StdEncoding.DecodedLen(len(str))) + n, err := base64.StdEncoding.Decode(dst, []byte(str)) + if err != nil { + fmt.Println("decode error:", err) + return + } + dst = dst[:n] + fmt.Printf("%q\n", dst) + // Output: + // "Hello, world!" +} + func ExampleNewEncoder() { input := []byte("foo\x00bar") encoder := base64.NewEncoder(base64.StdEncoding, os.Stdout) From b0351bfd7d5f0d367c27aa07789b2e6317442ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 19 Oct 2021 09:09:55 +0000 Subject: [PATCH 064/406] Revert "cmd/compile: use MOVBE instruction for GOAMD64>=v3" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts CL 354670. Reason for revert: broke make.bash with GOAMD64=v3. Fixes #49061. Change-Id: I7f2ed99b7c10100c4e0c1462ea91c4c9d8c609b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/356790 Trust: Daniel Martí Run-TryBot: Daniel Martí TryBot-Result: Go Bot Reviewed-by: Koichi Shiraishi Reviewed-by: Cuong Manh Le --- src/cmd/compile/internal/amd64/ssa.go | 7 +- .../compile/internal/amd64/versions_test.go | 27 +- src/cmd/compile/internal/ssa/gen/AMD64.rules | 26 -- src/cmd/compile/internal/ssa/gen/AMD64Ops.go | 6 - src/cmd/compile/internal/ssa/opGen.go | 64 ----- src/cmd/compile/internal/ssa/rewriteAMD64.go | 243 ------------------ test/codegen/memcombine.go | 36 +-- 7 files changed, 20 insertions(+), 389 deletions(-) diff --git a/src/cmd/compile/internal/amd64/ssa.go b/src/cmd/compile/internal/amd64/ssa.go index b0e5c34030..0e74574422 100644 --- a/src/cmd/compile/internal/amd64/ssa.go +++ b/src/cmd/compile/internal/amd64/ssa.go @@ -772,9 +772,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { p.From.Val = math.Float64frombits(uint64(v.AuxInt)) p.To.Type = obj.TYPE_REG p.To.Reg = x - case ssa.OpAMD64MOVQload, ssa.OpAMD64MOVLload, ssa.OpAMD64MOVWload, ssa.OpAMD64MOVBload, ssa.OpAMD64MOVOload, - ssa.OpAMD64MOVSSload, ssa.OpAMD64MOVSDload, ssa.OpAMD64MOVBQSXload, ssa.OpAMD64MOVWQSXload, ssa.OpAMD64MOVLQSXload, - ssa.OpAMD64MOVBEQload, ssa.OpAMD64MOVBELload: + case ssa.OpAMD64MOVQload, ssa.OpAMD64MOVSSload, ssa.OpAMD64MOVSDload, ssa.OpAMD64MOVLload, ssa.OpAMD64MOVWload, ssa.OpAMD64MOVBload, ssa.OpAMD64MOVBQSXload, ssa.OpAMD64MOVWQSXload, ssa.OpAMD64MOVLQSXload, ssa.OpAMD64MOVOload: p := s.Prog(v.Op.Asm()) p.From.Type = obj.TYPE_MEM p.From.Reg = v.Args[0].Reg() @@ -790,8 +788,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { p.To.Reg = v.Reg() case ssa.OpAMD64MOVQstore, ssa.OpAMD64MOVSSstore, ssa.OpAMD64MOVSDstore, ssa.OpAMD64MOVLstore, ssa.OpAMD64MOVWstore, ssa.OpAMD64MOVBstore, ssa.OpAMD64MOVOstore, ssa.OpAMD64ADDQmodify, ssa.OpAMD64SUBQmodify, ssa.OpAMD64ANDQmodify, ssa.OpAMD64ORQmodify, ssa.OpAMD64XORQmodify, - ssa.OpAMD64ADDLmodify, ssa.OpAMD64SUBLmodify, ssa.OpAMD64ANDLmodify, ssa.OpAMD64ORLmodify, ssa.OpAMD64XORLmodify, - ssa.OpAMD64MOVBEQstore, ssa.OpAMD64MOVBELstore: + ssa.OpAMD64ADDLmodify, ssa.OpAMD64SUBLmodify, ssa.OpAMD64ANDLmodify, ssa.OpAMD64ORLmodify, ssa.OpAMD64XORLmodify: p := s.Prog(v.Op.Asm()) p.From.Type = obj.TYPE_REG p.From.Reg = v.Args[1].Reg() diff --git a/src/cmd/compile/internal/amd64/versions_test.go b/src/cmd/compile/internal/amd64/versions_test.go index ee1a8ca3aa..de677f3a69 100644 --- a/src/cmd/compile/internal/amd64/versions_test.go +++ b/src/cmd/compile/internal/amd64/versions_test.go @@ -53,9 +53,7 @@ func TestGoAMD64v1(t *testing.T) { opcodes := map[string]bool{} var features []string for feature, opcodeList := range featureToOpcodes { - if runtimeFeatures[feature] { - features = append(features, fmt.Sprintf("cpu.%s=off", feature)) - } + features = append(features, fmt.Sprintf("cpu.%s=off", feature)) for _, op := range opcodeList { opcodes[op] = true } @@ -206,28 +204,14 @@ func clobber(t *testing.T, src string, dst *os.File, opcodes map[string]bool) { f.Close() } -func setOf(keys ...string) map[string]bool { - m := make(map[string]bool, len(keys)) - for _, key := range keys { - m[key] = true - } - return m -} - -var runtimeFeatures = setOf( - "adx", "aes", "avx", "avx2", "bmi1", "bmi2", "erms", "fma", - "pclmulqdq", "popcnt", "rdtscp", "sse3", "sse41", "sse42", "ssse3", -) - var featureToOpcodes = map[string][]string{ // Note: we include *q, *l, and plain opcodes here. // go tool objdump doesn't include a [QL] on popcnt instructions, until CL 351889 // native objdump doesn't include [QL] on linux. - "popcnt": {"popcntq", "popcntl", "popcnt"}, - "bmi1": {"andnq", "andnl", "andn", "blsiq", "blsil", "blsi", "blsmskq", "blsmskl", "blsmsk", "blsrq", "blsrl", "blsr", "tzcntq", "tzcntl", "tzcnt"}, - "sse41": {"roundsd"}, - "fma": {"vfmadd231sd"}, - "movbe": {"movbeqq", "movbeq", "movbell", "movbel", "movbe"}, + "popcnt": []string{"popcntq", "popcntl", "popcnt"}, + "bmi1": []string{"andnq", "andnl", "andn", "blsiq", "blsil", "blsi", "blsmskq", "blsmskl", "blsmsk", "blsrq", "blsrl", "blsr", "tzcntq", "tzcntl", "tzcnt"}, + "sse41": []string{"roundsd"}, + "fma": []string{"vfmadd231sd"}, } // Test to use POPCNT instruction, if available @@ -380,4 +364,5 @@ func TestFMA(t *testing.T) { t.Errorf("FMA(%f,%f,%f) = %f, want %f", tt.x, tt.y, tt.z, got, tt.want) } } + } diff --git a/src/cmd/compile/internal/ssa/gen/AMD64.rules b/src/cmd/compile/internal/ssa/gen/AMD64.rules index 507d701999..8b73ee14ea 100644 --- a/src/cmd/compile/internal/ssa/gen/AMD64.rules +++ b/src/cmd/compile/internal/ssa/gen/AMD64.rules @@ -2219,29 +2219,3 @@ (AND(Q|L) x (ADD(Q|L)const [-1] x)) && buildcfg.GOAMD64 >= 3 => (BLSR(Q|L) x) (BSWAP(Q|L) (BSWAP(Q|L) p)) => p - -// CPUID feature: MOVBE. -(MOV(Q|L)store [i] {s} p x:(BSWAP(Q|L) w) mem) && x.Uses == 1 && buildcfg.GOAMD64 >= 3 => (MOVBE(Q|L)store [i] {s} p w mem) -(BSWAP(Q|L) x:(MOV(Q|L)load [i] {s} p mem)) && x.Uses == 1 && buildcfg.GOAMD64 >= 3 => (MOVBE(Q|L)load [i] {s} p mem) -(BSWAP(Q|L) (MOVBE(Q|L)load [i] {s} p m)) => (MOV(Q|L)load [i] {s} p m) -(MOVBE(Q|L)store [i] {s} p (BSWAP(Q|L) x) m) => (MOV(Q|L)store [i] {s} p x m) - -(ORQ x0:(MOVBELload [i0] {s} p mem) - sh:(SHLQconst [32] x1:(MOVBELload [i1] {s} p mem))) - && i0 == i1+4 - && x0.Uses == 1 - && x1.Uses == 1 - && sh.Uses == 1 - && mergePoint(b,x0,x1) != nil - && clobber(x0, x1, sh) - => @mergePoint(b,x0,x1) (MOVBEQload [i1] {s} p mem) - -(ORQ x0:(MOVBELload [i] {s} p0 mem) - sh:(SHLQconst [32] x1:(MOVBELload [i] {s} p1 mem))) - && x0.Uses == 1 - && x1.Uses == 1 - && sh.Uses == 1 - && sequentialAddresses(p1, p0, 4) - && mergePoint(b,x0,x1) != nil - && clobber(x0, x1, sh) - => @mergePoint(b,x0,x1) (MOVBEQload [i] {s} p0 mem) diff --git a/src/cmd/compile/internal/ssa/gen/AMD64Ops.go b/src/cmd/compile/internal/ssa/gen/AMD64Ops.go index e3c94e4b2e..731454c761 100644 --- a/src/cmd/compile/internal/ssa/gen/AMD64Ops.go +++ b/src/cmd/compile/internal/ssa/gen/AMD64Ops.go @@ -922,12 +922,6 @@ func init() { // and BSFQ(0) is undefined. Same for TZCNTL(0)==32 {name: "TZCNTQ", argLength: 1, reg: gp11, asm: "TZCNTQ", clobberFlags: true}, {name: "TZCNTL", argLength: 1, reg: gp11, asm: "TZCNTL", clobberFlags: true}, - - // CPUID feature: MOVBE - {name: "MOVBELload", argLength: 2, reg: gpload, asm: "MOVBEL", aux: "SymOff", typ: "UInt32", faultOnNilArg0: true, symEffect: "Read"}, // load and swap 4 bytes from arg0+auxint+aux. arg1=mem. Zero extend. - {name: "MOVBELstore", argLength: 3, reg: gpstore, asm: "MOVBEL", aux: "SymOff", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"}, // swap and store 4 bytes in arg1 to arg0+auxint+aux. arg2=mem - {name: "MOVBEQload", argLength: 2, reg: gpload, asm: "MOVBEQ", aux: "SymOff", typ: "UInt64", faultOnNilArg0: true, symEffect: "Read"}, // load and swap 8 bytes from arg0+auxint+aux. arg1=mem - {name: "MOVBEQstore", argLength: 3, reg: gpstore, asm: "MOVBEQ", aux: "SymOff", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"}, // swap and store 8 bytes in arg1 to arg0+auxint+aux. arg2=mem } var AMD64blocks = []blockData{ diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go index 091f43f40a..640e517fe7 100644 --- a/src/cmd/compile/internal/ssa/opGen.go +++ b/src/cmd/compile/internal/ssa/opGen.go @@ -1043,10 +1043,6 @@ const ( OpAMD64BLSRL OpAMD64TZCNTQ OpAMD64TZCNTL - OpAMD64MOVBELload - OpAMD64MOVBELstore - OpAMD64MOVBEQload - OpAMD64MOVBEQstore OpARMADD OpARMADDconst @@ -13784,66 +13780,6 @@ var opcodeTable = [...]opInfo{ }, }, }, - { - name: "MOVBELload", - auxType: auxSymOff, - argLen: 2, - faultOnNilArg0: true, - symEffect: SymRead, - asm: x86.AMOVBEL, - reg: regInfo{ - inputs: []inputInfo{ - {0, 4295032831}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB - }, - outputs: []outputInfo{ - {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 - }, - }, - }, - { - name: "MOVBELstore", - auxType: auxSymOff, - argLen: 3, - faultOnNilArg0: true, - symEffect: SymWrite, - asm: x86.AMOVBEL, - reg: regInfo{ - inputs: []inputInfo{ - {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 - {0, 4295032831}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB - }, - }, - }, - { - name: "MOVBEQload", - auxType: auxSymOff, - argLen: 2, - faultOnNilArg0: true, - symEffect: SymRead, - asm: x86.AMOVBEQ, - reg: regInfo{ - inputs: []inputInfo{ - {0, 4295032831}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB - }, - outputs: []outputInfo{ - {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 - }, - }, - }, - { - name: "MOVBEQstore", - auxType: auxSymOff, - argLen: 3, - faultOnNilArg0: true, - symEffect: SymWrite, - asm: x86.AMOVBEQ, - reg: regInfo{ - inputs: []inputInfo{ - {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 - {0, 4295032831}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB - }, - }, - }, { name: "ADD", diff --git a/src/cmd/compile/internal/ssa/rewriteAMD64.go b/src/cmd/compile/internal/ssa/rewriteAMD64.go index 88b545a465..201fbf2954 100644 --- a/src/cmd/compile/internal/ssa/rewriteAMD64.go +++ b/src/cmd/compile/internal/ssa/rewriteAMD64.go @@ -222,10 +222,6 @@ func rewriteValueAMD64(v *Value) bool { return rewriteValueAMD64_OpAMD64LEAQ4(v) case OpAMD64LEAQ8: return rewriteValueAMD64_OpAMD64LEAQ8(v) - case OpAMD64MOVBELstore: - return rewriteValueAMD64_OpAMD64MOVBELstore(v) - case OpAMD64MOVBEQstore: - return rewriteValueAMD64_OpAMD64MOVBEQstore(v) case OpAMD64MOVBQSX: return rewriteValueAMD64_OpAMD64MOVBQSX(v) case OpAMD64MOVBQSXload: @@ -3627,43 +3623,6 @@ func rewriteValueAMD64_OpAMD64BSWAPL(v *Value) bool { v.copyOf(p) return true } - // match: (BSWAPL x:(MOVLload [i] {s} p mem)) - // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 - // result: (MOVBELload [i] {s} p mem) - for { - x := v_0 - if x.Op != OpAMD64MOVLload { - break - } - i := auxIntToInt32(x.AuxInt) - s := auxToSym(x.Aux) - mem := x.Args[1] - p := x.Args[0] - if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { - break - } - v.reset(OpAMD64MOVBELload) - v.AuxInt = int32ToAuxInt(i) - v.Aux = symToAux(s) - v.AddArg2(p, mem) - return true - } - // match: (BSWAPL (MOVBELload [i] {s} p m)) - // result: (MOVLload [i] {s} p m) - for { - if v_0.Op != OpAMD64MOVBELload { - break - } - i := auxIntToInt32(v_0.AuxInt) - s := auxToSym(v_0.Aux) - m := v_0.Args[1] - p := v_0.Args[0] - v.reset(OpAMD64MOVLload) - v.AuxInt = int32ToAuxInt(i) - v.Aux = symToAux(s) - v.AddArg2(p, m) - return true - } return false } func rewriteValueAMD64_OpAMD64BSWAPQ(v *Value) bool { @@ -3678,43 +3637,6 @@ func rewriteValueAMD64_OpAMD64BSWAPQ(v *Value) bool { v.copyOf(p) return true } - // match: (BSWAPQ x:(MOVQload [i] {s} p mem)) - // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 - // result: (MOVBEQload [i] {s} p mem) - for { - x := v_0 - if x.Op != OpAMD64MOVQload { - break - } - i := auxIntToInt32(x.AuxInt) - s := auxToSym(x.Aux) - mem := x.Args[1] - p := x.Args[0] - if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { - break - } - v.reset(OpAMD64MOVBEQload) - v.AuxInt = int32ToAuxInt(i) - v.Aux = symToAux(s) - v.AddArg2(p, mem) - return true - } - // match: (BSWAPQ (MOVBEQload [i] {s} p m)) - // result: (MOVQload [i] {s} p m) - for { - if v_0.Op != OpAMD64MOVBEQload { - break - } - i := auxIntToInt32(v_0.AuxInt) - s := auxToSym(v_0.Aux) - m := v_0.Args[1] - p := v_0.Args[0] - v.reset(OpAMD64MOVQload) - v.AuxInt = int32ToAuxInt(i) - v.Aux = symToAux(s) - v.AddArg2(p, m) - return true - } return false } func rewriteValueAMD64_OpAMD64BTCLconst(v *Value) bool { @@ -9473,52 +9395,6 @@ func rewriteValueAMD64_OpAMD64LEAQ8(v *Value) bool { } return false } -func rewriteValueAMD64_OpAMD64MOVBELstore(v *Value) bool { - v_2 := v.Args[2] - v_1 := v.Args[1] - v_0 := v.Args[0] - // match: (MOVBELstore [i] {s} p (BSWAPL x) m) - // result: (MOVLstore [i] {s} p x m) - for { - i := auxIntToInt32(v.AuxInt) - s := auxToSym(v.Aux) - p := v_0 - if v_1.Op != OpAMD64BSWAPL { - break - } - x := v_1.Args[0] - m := v_2 - v.reset(OpAMD64MOVLstore) - v.AuxInt = int32ToAuxInt(i) - v.Aux = symToAux(s) - v.AddArg3(p, x, m) - return true - } - return false -} -func rewriteValueAMD64_OpAMD64MOVBEQstore(v *Value) bool { - v_2 := v.Args[2] - v_1 := v.Args[1] - v_0 := v.Args[0] - // match: (MOVBEQstore [i] {s} p (BSWAPQ x) m) - // result: (MOVQstore [i] {s} p x m) - for { - i := auxIntToInt32(v.AuxInt) - s := auxToSym(v.Aux) - p := v_0 - if v_1.Op != OpAMD64BSWAPQ { - break - } - x := v_1.Args[0] - m := v_2 - v.reset(OpAMD64MOVQstore) - v.AuxInt = int32ToAuxInt(i) - v.Aux = symToAux(s) - v.AddArg3(p, x, m) - return true - } - return false -} func rewriteValueAMD64_OpAMD64MOVBQSX(v *Value) bool { v_0 := v.Args[0] b := v.Block @@ -12349,28 +12225,6 @@ func rewriteValueAMD64_OpAMD64MOVLstore(v *Value) bool { v.AddArg3(ptr, val, mem) return true } - // match: (MOVLstore [i] {s} p x:(BSWAPL w) mem) - // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 - // result: (MOVBELstore [i] {s} p w mem) - for { - i := auxIntToInt32(v.AuxInt) - s := auxToSym(v.Aux) - p := v_0 - x := v_1 - if x.Op != OpAMD64BSWAPL { - break - } - w := x.Args[0] - mem := v_2 - if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { - break - } - v.reset(OpAMD64MOVBELstore) - v.AuxInt = int32ToAuxInt(i) - v.Aux = symToAux(s) - v.AddArg3(p, w, mem) - return true - } return false } func rewriteValueAMD64_OpAMD64MOVLstoreconst(v *Value) bool { @@ -13310,28 +13164,6 @@ func rewriteValueAMD64_OpAMD64MOVQstore(v *Value) bool { v.AddArg3(ptr, val, mem) return true } - // match: (MOVQstore [i] {s} p x:(BSWAPQ w) mem) - // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 - // result: (MOVBEQstore [i] {s} p w mem) - for { - i := auxIntToInt32(v.AuxInt) - s := auxToSym(v.Aux) - p := v_0 - x := v_1 - if x.Op != OpAMD64BSWAPQ { - break - } - w := x.Args[0] - mem := v_2 - if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { - break - } - v.reset(OpAMD64MOVBEQstore) - v.AuxInt = int32ToAuxInt(i) - v.Aux = symToAux(s) - v.AddArg3(p, w, mem) - return true - } return false } func rewriteValueAMD64_OpAMD64MOVQstoreconst(v *Value) bool { @@ -18825,81 +18657,6 @@ func rewriteValueAMD64_OpAMD64ORQ(v *Value) bool { } break } - // match: (ORQ x0:(MOVBELload [i0] {s} p mem) sh:(SHLQconst [32] x1:(MOVBELload [i1] {s} p mem))) - // cond: i0 == i1+4 && x0.Uses == 1 && x1.Uses == 1 && sh.Uses == 1 && mergePoint(b,x0,x1) != nil && clobber(x0, x1, sh) - // result: @mergePoint(b,x0,x1) (MOVBEQload [i1] {s} p mem) - for { - for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { - x0 := v_0 - if x0.Op != OpAMD64MOVBELload { - continue - } - i0 := auxIntToInt32(x0.AuxInt) - s := auxToSym(x0.Aux) - mem := x0.Args[1] - p := x0.Args[0] - sh := v_1 - if sh.Op != OpAMD64SHLQconst || auxIntToInt8(sh.AuxInt) != 32 { - continue - } - x1 := sh.Args[0] - if x1.Op != OpAMD64MOVBELload { - continue - } - i1 := auxIntToInt32(x1.AuxInt) - if auxToSym(x1.Aux) != s { - continue - } - _ = x1.Args[1] - if p != x1.Args[0] || mem != x1.Args[1] || !(i0 == i1+4 && x0.Uses == 1 && x1.Uses == 1 && sh.Uses == 1 && mergePoint(b, x0, x1) != nil && clobber(x0, x1, sh)) { - continue - } - b = mergePoint(b, x0, x1) - v0 := b.NewValue0(x1.Pos, OpAMD64MOVBEQload, typ.UInt64) - v.copyOf(v0) - v0.AuxInt = int32ToAuxInt(i1) - v0.Aux = symToAux(s) - v0.AddArg2(p, mem) - return true - } - break - } - // match: (ORQ x0:(MOVBELload [i] {s} p0 mem) sh:(SHLQconst [32] x1:(MOVBELload [i] {s} p1 mem))) - // cond: x0.Uses == 1 && x1.Uses == 1 && sh.Uses == 1 && sequentialAddresses(p1, p0, 4) && mergePoint(b,x0,x1) != nil && clobber(x0, x1, sh) - // result: @mergePoint(b,x0,x1) (MOVBEQload [i] {s} p0 mem) - for { - for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { - x0 := v_0 - if x0.Op != OpAMD64MOVBELload { - continue - } - i := auxIntToInt32(x0.AuxInt) - s := auxToSym(x0.Aux) - mem := x0.Args[1] - p0 := x0.Args[0] - sh := v_1 - if sh.Op != OpAMD64SHLQconst || auxIntToInt8(sh.AuxInt) != 32 { - continue - } - x1 := sh.Args[0] - if x1.Op != OpAMD64MOVBELload || auxIntToInt32(x1.AuxInt) != i || auxToSym(x1.Aux) != s { - continue - } - _ = x1.Args[1] - p1 := x1.Args[0] - if mem != x1.Args[1] || !(x0.Uses == 1 && x1.Uses == 1 && sh.Uses == 1 && sequentialAddresses(p1, p0, 4) && mergePoint(b, x0, x1) != nil && clobber(x0, x1, sh)) { - continue - } - b = mergePoint(b, x0, x1) - v0 := b.NewValue0(x1.Pos, OpAMD64MOVBEQload, typ.UInt64) - v.copyOf(v0) - v0.AuxInt = int32ToAuxInt(i) - v0.Aux = symToAux(s) - v0.AddArg2(p0, mem) - return true - } - break - } return false } func rewriteValueAMD64_OpAMD64ORQconst(v *Value) bool { diff --git a/test/codegen/memcombine.go b/test/codegen/memcombine.go index 97e1d4bdfb..2a0c534df0 100644 --- a/test/codegen/memcombine.go +++ b/test/codegen/memcombine.go @@ -70,8 +70,7 @@ func load_le16_idx(b []byte, idx int) { } func load_be64(b []byte) { - // amd64/v1,amd64/v2:`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` - // amd64/v3:`MOVBEQ` + // amd64:`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` // s390x:`MOVD\s\(.*\),` // arm64:`REV`,`MOVD\s\(R[0-9]+\),`,-`MOV[BHW]`,-`REVW`,-`REV16W` // ppc64le:`MOVDBR`,-`MOV[BHW]Z` @@ -79,8 +78,7 @@ func load_be64(b []byte) { } func load_be64_idx(b []byte, idx int) { - // amd64/v1,amd64/v2:`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` - // amd64/v3: `MOVBEQ` + // amd64:`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` // s390x:`MOVD\s\(.*\)\(.*\*1\),` // arm64:`REV`,`MOVD\s\(R[0-9]+\)\(R[0-9]+\),`,-`MOV[WHB]`,-`REVW`,-`REV16W` // ppc64le:`MOVDBR`,-`MOV[BHW]Z` @@ -88,8 +86,7 @@ func load_be64_idx(b []byte, idx int) { } func load_be32(b []byte) { - // amd64/v1,amd64/v2:`BSWAPL`,-`MOV[BW]`,-`OR` - // amd64/v3: `MOVBEL` + // amd64:`BSWAPL`,-`MOV[BW]`,-`OR` // s390x:`MOVWZ\s\(.*\),` // arm64:`REVW`,`MOVWU\s\(R[0-9]+\),`,-`MOV[BH]`,-`REV16W` // ppc64le:`MOVWBR`,-`MOV[BH]Z` @@ -97,8 +94,7 @@ func load_be32(b []byte) { } func load_be32_idx(b []byte, idx int) { - // amd64/v1,amd64/v2:`BSWAPL`,-`MOV[BW]`,-`OR` - // amd64/v3: `MOVBEL` + // amd64:`BSWAPL`,-`MOV[BW]`,-`OR` // s390x:`MOVWZ\s\(.*\)\(.*\*1\),` // arm64:`REVW`,`MOVWU\s\(R[0-9]+\)\(R[0-9]+\),`,-`MOV[HB]`,-`REV16W` // ppc64le:`MOVWBR`,-`MOV[BH]Z` @@ -183,8 +179,7 @@ func load_be_byte4_uint32(s []byte) uint32 { func load_be_byte4_uint32_inv(s []byte) uint32 { // arm64:`MOVWU\t\(R[0-9]+\)`,`REVW`,-`ORR`,-`REV16W`,-`MOV[BH]` - // amd64/v1,amd64/v2:`MOVL\s\([A-Z]+\)`,`BSWAPL`,-`MOV[BW]`,-`OR` - // amd64/v3: `MOVBEL` + // amd64:`MOVL\s\([A-Z]+\)`,`BSWAPL`,-`MOV[BW]`,-`OR` return uint32(s[3]) | uint32(s[2])<<8 | uint32(s[1])<<16 | uint32(s[0])<<24 } @@ -196,8 +191,7 @@ func load_be_byte8_uint64(s []byte) uint64 { func load_be_byte8_uint64_inv(s []byte) uint64 { // arm64:`MOVD\t\(R[0-9]+\)`,`REV`,-`ORR`,-`REVW`,-`REV16W`,-`MOV[BHW]` - // amd64/v1,amd64/v2:`MOVQ\s\([A-Z]+\),\s[A-Z]+`,`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` - // amd64/v3: `MOVBEQ` + // amd64:`MOVQ\s\([A-Z]+\),\s[A-Z]+`,`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` // ppc64le:`MOVDBR\t\(R[0-9]+\)`,-`MOV[BHW]Z` return uint64(s[7]) | uint64(s[6])<<8 | uint64(s[5])<<16 | uint64(s[4])<<24 | uint64(s[3])<<32 | uint64(s[2])<<40 | uint64(s[1])<<48 | uint64(s[0])<<56 } @@ -415,8 +409,7 @@ func store_le16_idx(b []byte, idx int) { } func store_be64(b []byte) { - // amd64/v1,amd64/v2:`BSWAPQ`,-`SHR.` - // amd64/v3: `MOVBEQ` + // amd64:`BSWAPQ`,-`SHR.` // arm64:`MOVD`,`REV`,-`MOV[WBH]`,-`REVW`,-`REV16W` // ppc64le:`MOVDBR` // s390x:`MOVD\s.*\(.*\)$`,-`SRW\s`,-`SRD\s` @@ -424,8 +417,7 @@ func store_be64(b []byte) { } func store_be64_idx(b []byte, idx int) { - // amd64/v1,amd64/v2:`BSWAPQ`,-`SHR.` - // amd64/v3:`MOVBEQ` + // amd64:`BSWAPQ`,-`SHR.` // arm64:`REV`,`MOVD\sR[0-9]+,\s\(R[0-9]+\)\(R[0-9]+\)`,-`MOV[BHW]`,-`REV16W`,-`REVW` // ppc64le:`MOVDBR` // s390x:`MOVD\s.*\(.*\)\(.*\*1\)$`,-`SRW\s`,-`SRD\s` @@ -433,8 +425,7 @@ func store_be64_idx(b []byte, idx int) { } func store_be32(b []byte) { - // amd64/v1,amd64/v2:`BSWAPL`,-`SHR.` - // amd64/v3:`MOVBEL` + // amd64:`BSWAPL`,-`SHR.` // arm64:`MOVW`,`REVW`,-`MOV[BH]`,-`REV16W` // ppc64le:`MOVWBR` // s390x:`MOVW\s.*\(.*\)$`,-`SRW\s`,-`SRD\s` @@ -454,8 +445,7 @@ func store_be32_load(b, x *[8]byte) { } func store_be32_idx(b []byte, idx int) { - // amd64/v1,amd64/v2:`BSWAPL`,-`SHR.` - // amd64/v3:`MOVBEL` + // amd64:`BSWAPL`,-`SHR.` // arm64:`REVW`,`MOVW\sR[0-9]+,\s\(R[0-9]+\)\(R[0-9]+\)`,-`MOV[BH]`,-`REV16W` // ppc64le:`MOVWBR` // s390x:`MOVW\s.*\(.*\)\(.*\*1\)$`,-`SRW\s`,-`SRD\s` @@ -518,16 +508,14 @@ func store_be_byte_2(b []byte, val uint16) { func store_be_byte_4(b []byte, val uint32) { _ = b[4] // arm64:`REVW`,`MOVW\sR[0-9]+,\s1\(R[0-9]+\)`,-`MOVB`,-`MOVH`,-`REV16W` - // amd64/v1,amd64/v2:`MOVL\s[A-Z]+,\s1\([A-Z]+\)`,-`MOVB`,-`MOVW` - // amd64/v3:`MOVBEL\s[A-Z]+,\s1\([A-Z]+\)` + // amd64:`MOVL\s[A-Z]+,\s1\([A-Z]+\)`,-`MOVB`,-`MOVW` b[1], b[2], b[3], b[4] = byte(val>>24), byte(val>>16), byte(val>>8), byte(val) } func store_be_byte_8(b []byte, val uint64) { _ = b[8] // arm64:`REV`,`MOVD\sR[0-9]+,\s1\(R[0-9]+\)`,-`MOVB`,-`MOVH`,-`MOVW`,-`REV16W`,-`REVW` - // amd64/v1,amd64/v2:`MOVQ\s[A-Z]+,\s1\([A-Z]+\)`,-`MOVB`,-`MOVW`,-`MOVL` - // amd64/v3:`MOVBEQ\s[A-Z]+,\s1\([A-Z]+\)`, -`MOVBEL` + // amd64:`MOVQ\s[A-Z]+,\s1\([A-Z]+\)`,-`MOVB`,-`MOVW`,-`MOVL` b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8] = byte(val>>56), byte(val>>48), byte(val>>40), byte(val>>32), byte(val>>24), byte(val>>16), byte(val>>8), byte(val) } From bde0463da3f31934791b0bb2ccacdf6206314073 Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Sat, 16 Oct 2021 03:59:41 +1100 Subject: [PATCH 065/406] cmd/internal/obj/riscv: fix trampoline calls from large functions On riscv64, the JAL instruction is only capable of reaching +/-1MB. In the case where a single function and its trampolines exceeds this size, it is possible that the JAL is unable to reach the trampoline, which is laid down after the function text. In the case of large functions, switch back to using a AUIPC+JALR pairs rather than using trampolines. Fixes #48791 Change-Id: I119cf3bc20ce4933a9b7ab41a8e514437c6addb9 Reviewed-on: https://go-review.googlesource.com/c/go/+/356250 Trust: Joel Sing Reviewed-by: Cherry Mui --- src/cmd/internal/obj/riscv/asm_test.go | 95 ++++++++++++++++++++++---- src/cmd/internal/obj/riscv/obj.go | 36 ++++++++-- 2 files changed, 113 insertions(+), 18 deletions(-) diff --git a/src/cmd/internal/obj/riscv/asm_test.go b/src/cmd/internal/obj/riscv/asm_test.go index 684c6b61f2..b23142dbe8 100644 --- a/src/cmd/internal/obj/riscv/asm_test.go +++ b/src/cmd/internal/obj/riscv/asm_test.go @@ -16,32 +16,30 @@ import ( "testing" ) -// TestLarge generates a very large file to verify that large -// program builds successfully, in particular, too-far -// conditional branches are fixed. -func TestLarge(t *testing.T) { +// TestLargeBranch generates a large function with a very far conditional +// branch, in order to ensure that it assembles successfully. +func TestLargeBranch(t *testing.T) { if testing.Short() { - t.Skip("Skip in short mode") + t.Skip("Skipping test in short mode") } testenv.MustHaveGoBuild(t) - dir, err := ioutil.TempDir("", "testlarge") + dir, err := ioutil.TempDir("", "testlargebranch") if err != nil { - t.Fatalf("could not create directory: %v", err) + t.Fatalf("Could not create directory: %v", err) } defer os.RemoveAll(dir) // Generate a very large function. buf := bytes.NewBuffer(make([]byte, 0, 7000000)) - gen(buf) + genLargeBranch(buf) tmpfile := filepath.Join(dir, "x.s") - err = ioutil.WriteFile(tmpfile, buf.Bytes(), 0644) - if err != nil { - t.Fatalf("can't write output: %v\n", err) + if err := ioutil.WriteFile(tmpfile, buf.Bytes(), 0644); err != nil { + t.Fatalf("Failed to write file: %v", err) } - // Build generated file. + // Assemble generated file. cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-o", filepath.Join(dir, "x.o"), tmpfile) cmd.Env = append(os.Environ(), "GOARCH=riscv64", "GOOS=linux") out, err := cmd.CombinedOutput() @@ -50,8 +48,7 @@ func TestLarge(t *testing.T) { } } -// gen generates a very large program, with a very far conditional branch. -func gen(buf *bytes.Buffer) { +func genLargeBranch(buf *bytes.Buffer) { fmt.Fprintln(buf, "TEXT f(SB),0,$0-0") fmt.Fprintln(buf, "BEQ X0, X0, label") for i := 0; i < 1<<19; i++ { @@ -61,6 +58,76 @@ func gen(buf *bytes.Buffer) { fmt.Fprintln(buf, "ADD $0, X0, X0") } +// TestLargeCall generates a large function (>1MB of text) with a call to +// a following function, in order to ensure that it assembles and links +// correctly. +func TestLargeCall(t *testing.T) { + if testing.Short() { + t.Skip("Skipping test in short mode") + } + testenv.MustHaveGoBuild(t) + + dir, err := ioutil.TempDir("", "testlargecall") + if err != nil { + t.Fatalf("could not create directory: %v", err) + } + defer os.RemoveAll(dir) + + if err := ioutil.WriteFile(filepath.Join(dir, "go.mod"), []byte("module largecall"), 0644); err != nil { + t.Fatalf("Failed to write file: %v\n", err) + } + main := `package main +func main() { + x() +} + +func x() +func y() +` + if err := ioutil.WriteFile(filepath.Join(dir, "x.go"), []byte(main), 0644); err != nil { + t.Fatalf("failed to write main: %v\n", err) + } + + // Generate a very large function with call. + buf := bytes.NewBuffer(make([]byte, 0, 7000000)) + genLargeCall(buf) + + if err := ioutil.WriteFile(filepath.Join(dir, "x.s"), buf.Bytes(), 0644); err != nil { + t.Fatalf("Failed to write file: %v\n", err) + } + + // Build generated files. + cmd := exec.Command(testenv.GoToolPath(t), "build", "-ldflags=-linkmode=internal") + cmd.Dir = dir + cmd.Env = append(os.Environ(), "GOARCH=riscv64", "GOOS=linux") + out, err := cmd.CombinedOutput() + if err != nil { + t.Errorf("Build failed: %v, output: %s", err, out) + } + + if runtime.GOARCH == "riscv64" && testenv.HasCGO() { + cmd := exec.Command(testenv.GoToolPath(t), "build", "-ldflags=-linkmode=external") + cmd.Dir = dir + cmd.Env = append(os.Environ(), "GOARCH=riscv64", "GOOS=linux") + out, err := cmd.CombinedOutput() + if err != nil { + t.Errorf("Build failed: %v, output: %s", err, out) + } + } +} + +func genLargeCall(buf *bytes.Buffer) { + fmt.Fprintln(buf, "TEXT ·x(SB),0,$0-0") + fmt.Fprintln(buf, "CALL ·y(SB)") + for i := 0; i < 1<<19; i++ { + fmt.Fprintln(buf, "ADD $0, X0, X0") + } + fmt.Fprintln(buf, "RET") + fmt.Fprintln(buf, "TEXT ·y(SB),0,$0-0") + fmt.Fprintln(buf, "ADD $0, X0, X0") + fmt.Fprintln(buf, "RET") +} + // Issue 20348. func TestNoRet(t *testing.T) { dir, err := ioutil.TempDir("", "testnoret") diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go index b346b13577..d98806edb5 100644 --- a/src/cmd/internal/obj/riscv/obj.go +++ b/src/cmd/internal/obj/riscv/obj.go @@ -280,14 +280,15 @@ func containsCall(sym *obj.LSym) bool { } // setPCs sets the Pc field in all instructions reachable from p. -// It uses pc as the initial value. -func setPCs(p *obj.Prog, pc int64) { +// It uses pc as the initial value and returns the next available pc. +func setPCs(p *obj.Prog, pc int64) int64 { for ; p != nil; p = p.Link { p.Pc = pc for _, ins := range instructionsForProg(p) { pc += int64(ins.length()) } } + return pc } // stackOffset updates Addr offsets based on the current stack size. @@ -582,17 +583,26 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { } } + var callCount int for p := cursym.Func().Text; p != nil; p = p.Link { markRelocs(p) + if p.Mark&NEED_CALL_RELOC == NEED_CALL_RELOC { + callCount++ + } } + const callTrampSize = 8 // 2 machine instructions. + maxTrampSize := int64(callCount * callTrampSize) // Compute instruction addresses. Once we do that, we need to check for // overextended jumps and branches. Within each iteration, Pc differences // are always lower bounds (since the program gets monotonically longer, // a fixed point will be reached). No attempt to handle functions > 2GiB. for { - rescan := false - setPCs(cursym.Func().Text, 0) + big, rescan := false, false + maxPC := setPCs(cursym.Func().Text, 0) + if maxPC+maxTrampSize > (1 << 20) { + big = true + } for p := cursym.Func().Text; p != nil; p = p.Link { switch p.As { @@ -619,6 +629,24 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { case AJAL: // Linker will handle the intersymbol case and trampolines. if p.To.Target() == nil { + if !big { + break + } + // This function is going to be too large for JALs + // to reach trampolines. Replace with AUIPC+JALR. + jmp := obj.Appendp(p, newprog) + jmp.As = AJALR + jmp.From = p.From + jmp.To = obj.Addr{Type: obj.TYPE_REG, Reg: REG_TMP} + + p.As = AAUIPC + p.Mark = (p.Mark &^ NEED_CALL_RELOC) | NEED_PCREL_ITYPE_RELOC + p.SetFrom3(obj.Addr{Type: obj.TYPE_CONST, Offset: p.To.Offset, Sym: p.To.Sym}) + p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: 0} + p.Reg = obj.REG_NONE + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: REG_TMP} + + rescan = true break } offset := p.To.Target().Pc - p.Pc From 6294207a1c79e318124850155c7b6c23997c8c13 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Mon, 18 Oct 2021 16:15:43 -0400 Subject: [PATCH 066/406] cmd/go: skip flaky fuzz tests (Temporarily, until they can be fixed.) For #49046 For #49047 Change-Id: Ib580a5e45a0955aabdfc1899ed38a262a37f66ab Reviewed-on: https://go-review.googlesource.com/c/go/+/356649 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Roland Shoemaker Reviewed-by: Katie Hockman --- src/cmd/go/testdata/script/test_fuzz_fuzztime.txt | 2 ++ src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/cmd/go/testdata/script/test_fuzz_fuzztime.txt b/src/cmd/go/testdata/script/test_fuzz_fuzztime.txt index 9c9972f9e9..6264aca17d 100644 --- a/src/cmd/go/testdata/script/test_fuzz_fuzztime.txt +++ b/src/cmd/go/testdata/script/test_fuzz_fuzztime.txt @@ -1,3 +1,5 @@ +skip # Flaky: https://golang.org/issue/49046 + # TODO(jayconrod): support shared memory on more platforms. [!darwin] [!linux] [!windows] skip diff --git a/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt b/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt index 0924ed37e6..f2952c349b 100644 --- a/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt +++ b/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt @@ -1,3 +1,5 @@ +skip # Flaky: https://golang.org/issue/49047 + # TODO(jayconrod): support shared memory on more platforms. [!darwin] [!linux] [!windows] skip From 067d796549242bec2d33226c9da1e67f092a7be2 Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Thu, 14 Oct 2021 12:32:58 -0400 Subject: [PATCH 067/406] testing: write output to buffer when fuzzing Fixes #48709 Change-Id: Ia6376a2f792946498d6565a53605b3e6c985ea7c Reviewed-on: https://go-review.googlesource.com/c/go/+/355909 Trust: Katie Hockman Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Jay Conrod Reviewed-by: Roland Shoemaker Reviewed-by: Bryan C. Mills --- .../go/testdata/script/test_fuzz_minimize.txt | 20 +++++++++++-- .../script/test_fuzz_minimize_interesting.txt | 2 +- src/testing/fuzz.go | 28 +++++++++++++------ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/cmd/go/testdata/script/test_fuzz_minimize.txt b/src/cmd/go/testdata/script/test_fuzz_minimize.txt index 8b11621bbd..3293e878bb 100644 --- a/src/cmd/go/testdata/script/test_fuzz_minimize.txt +++ b/src/cmd/go/testdata/script/test_fuzz_minimize.txt @@ -31,7 +31,7 @@ stdout FAIL ! go test -fuzz=FuzzMinimizeZeroLimitSet -run=FuzzMinimizeZeroLimitSet -fuzztime=10000x -fuzzminimizetime=0x . ! stdout '^ok' ! stdout 'minimizing' -stdout 'there was an Error' +stdout -count=1 'there was an Error' stdout FAIL # Test that minimization is working for recoverable errors. @@ -49,11 +49,27 @@ go run ./check_testdata FuzzMinimizerRecoverable 50 ! go test -run=FuzzMinimizerRecoverable . rm testdata +# Test that minimization is working for recoverable errors. Run it with -v this +# time to ensure the command line output still looks right. +! go test -v -fuzz=FuzzMinimizerRecoverable -run=FuzzMinimizerRecoverable -fuzztime=10000x . +! stdout '^ok' +stdout 'got the minimum size!' +# The error message that was printed should be for the one written to testdata. +stdout 'contains a non-zero byte of length 50' +stdout FAIL + +# Check that the bytes written to testdata are of length 50 (the minimum size) +go run ./check_testdata FuzzMinimizerRecoverable 50 + +# Test that re-running the minimized value causes a crash. +! go test -run=FuzzMinimizerRecoverable . +rm testdata + # Test that minimization doesn't run for non-recoverable errors. ! go test -fuzz=FuzzMinimizerNonrecoverable -run=FuzzMinimizerNonrecoverable -fuzztime=10000x . ! stdout '^ok' ! stdout 'minimizing' -stdout 'fuzzing process terminated unexpectedly: exit status 99' +stdout -count=1 'fuzzing process terminated unexpectedly: exit status 99' stdout FAIL # Check that re-running the value causes a crash. diff --git a/src/cmd/go/testdata/script/test_fuzz_minimize_interesting.txt b/src/cmd/go/testdata/script/test_fuzz_minimize_interesting.txt index fc66201eb3..8ea4cdb8a5 100644 --- a/src/cmd/go/testdata/script/test_fuzz_minimize_interesting.txt +++ b/src/cmd/go/testdata/script/test_fuzz_minimize_interesting.txt @@ -29,7 +29,7 @@ env GOCACHE=$WORK/gocache ! exec ./fuzz.test$GOEXE -test.fuzzcachedir=$GOCACHE/fuzz -test.fuzz=FuzzMinimizerCrashInMinimization -test.fuzztime=10000x -test.parallel=1 ! stdout '^ok' stdout 'got the minimum size!' -stdout 'flaky failure' +stdout -count=1 'flaky failure' stdout FAIL # Make sure the crash that was written will fail when run with go test diff --git a/src/testing/fuzz.go b/src/testing/fuzz.go index 0429f8243d..d5cb5e853f 100644 --- a/src/testing/fuzz.go +++ b/src/testing/fuzz.go @@ -5,6 +5,7 @@ package testing import ( + "bytes" "errors" "flag" "fmt" @@ -367,14 +368,14 @@ func (f *F) Fuzz(ff interface{}) { // run calls fn on a given input, as a subtest with its own T. // run is analogous to T.Run. The test filtering and cleanup works similarly. // fn is called in its own goroutine. - run := func(e corpusEntry) error { + run := func(captureOut io.Writer, e corpusEntry) (ok bool) { if e.Values == nil { // The corpusEntry must have non-nil Values in order to run the // test. If Values is nil, it is a bug in our code. panic(fmt.Sprintf("corpus file %q was not unmarshaled", e.Path)) } if shouldFailFast() { - return nil + return true } testName := f.name if e.Path != "" { @@ -405,6 +406,10 @@ func (f *F) Fuzz(ff interface{}) { }, context: f.testContext, } + if captureOut != nil { + // t.parent aliases f.common. + t.parent.w = captureOut + } t.w = indenter{&t.common} if t.chatty != nil { // TODO(#48132): adjust this to work with test2json. @@ -426,10 +431,7 @@ func (f *F) Fuzz(ff interface{}) { }) <-t.signal f.inFuzzFn = false - if t.Failed() { - return errors.New(string(f.output)) - } - return nil + return !t.Failed() } switch f.fuzzContext.mode { @@ -466,7 +468,17 @@ func (f *F) Fuzz(ff interface{}) { case fuzzWorker: // Fuzzing is enabled, and this is a worker process. Follow instructions // from the coordinator. - if err := f.fuzzContext.deps.RunFuzzWorker(run); err != nil { + if err := f.fuzzContext.deps.RunFuzzWorker(func(e corpusEntry) error { + // Don't write to f.w (which points to Stdout) if running from a + // fuzz worker. This would become very verbose, particularly during + // minimization. Return the error instead, and let the caller deal + // with the output. + var buf bytes.Buffer + if ok := run(&buf, e); !ok { + return errors.New(buf.String()) + } + return nil + }); err != nil { // Internal errors are marked with f.Fail; user code may call this too, before F.Fuzz. // The worker will exit with fuzzWorkerExitCode, indicating this is a failure // (and 'go test' should exit non-zero) but a crasher should not be recorded. @@ -479,7 +491,7 @@ func (f *F) Fuzz(ff interface{}) { for _, e := range f.corpus { name := fmt.Sprintf("%s/%s", f.name, filepath.Base(e.Path)) if _, ok, _ := f.testContext.match.fullName(nil, name); ok { - run(e) + run(f.w, e) } } } From fe7df4c4d043fc65800bbec7f575c1ba50327aa9 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Tue, 19 Oct 2021 19:39:21 +0800 Subject: [PATCH 068/406] cmd/compile: use MOVBE instruction for GOAMD64>=v3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In CL 354670, I copied some existing rules for convenience but forgot to update the last rule which broke `GOAMD64=v3 ./make.bat` Revive CL 354670 Change-Id: Ic1e2047c603f0122482a4b293ce1ef74d806c019 Reviewed-on: https://go-review.googlesource.com/c/go/+/356810 Reviewed-by: Daniel Martí Reviewed-by: Keith Randall Trust: Daniel Martí Run-TryBot: Daniel Martí TryBot-Result: Go Bot --- src/cmd/compile/internal/amd64/ssa.go | 7 +- .../compile/internal/amd64/versions_test.go | 27 +- src/cmd/compile/internal/ssa/gen/AMD64.rules | 26 ++ src/cmd/compile/internal/ssa/gen/AMD64Ops.go | 6 + src/cmd/compile/internal/ssa/opGen.go | 64 +++++ src/cmd/compile/internal/ssa/rewriteAMD64.go | 243 ++++++++++++++++++ test/codegen/memcombine.go | 36 ++- 7 files changed, 389 insertions(+), 20 deletions(-) diff --git a/src/cmd/compile/internal/amd64/ssa.go b/src/cmd/compile/internal/amd64/ssa.go index 0e74574422..b0e5c34030 100644 --- a/src/cmd/compile/internal/amd64/ssa.go +++ b/src/cmd/compile/internal/amd64/ssa.go @@ -772,7 +772,9 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { p.From.Val = math.Float64frombits(uint64(v.AuxInt)) p.To.Type = obj.TYPE_REG p.To.Reg = x - case ssa.OpAMD64MOVQload, ssa.OpAMD64MOVSSload, ssa.OpAMD64MOVSDload, ssa.OpAMD64MOVLload, ssa.OpAMD64MOVWload, ssa.OpAMD64MOVBload, ssa.OpAMD64MOVBQSXload, ssa.OpAMD64MOVWQSXload, ssa.OpAMD64MOVLQSXload, ssa.OpAMD64MOVOload: + case ssa.OpAMD64MOVQload, ssa.OpAMD64MOVLload, ssa.OpAMD64MOVWload, ssa.OpAMD64MOVBload, ssa.OpAMD64MOVOload, + ssa.OpAMD64MOVSSload, ssa.OpAMD64MOVSDload, ssa.OpAMD64MOVBQSXload, ssa.OpAMD64MOVWQSXload, ssa.OpAMD64MOVLQSXload, + ssa.OpAMD64MOVBEQload, ssa.OpAMD64MOVBELload: p := s.Prog(v.Op.Asm()) p.From.Type = obj.TYPE_MEM p.From.Reg = v.Args[0].Reg() @@ -788,7 +790,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { p.To.Reg = v.Reg() case ssa.OpAMD64MOVQstore, ssa.OpAMD64MOVSSstore, ssa.OpAMD64MOVSDstore, ssa.OpAMD64MOVLstore, ssa.OpAMD64MOVWstore, ssa.OpAMD64MOVBstore, ssa.OpAMD64MOVOstore, ssa.OpAMD64ADDQmodify, ssa.OpAMD64SUBQmodify, ssa.OpAMD64ANDQmodify, ssa.OpAMD64ORQmodify, ssa.OpAMD64XORQmodify, - ssa.OpAMD64ADDLmodify, ssa.OpAMD64SUBLmodify, ssa.OpAMD64ANDLmodify, ssa.OpAMD64ORLmodify, ssa.OpAMD64XORLmodify: + ssa.OpAMD64ADDLmodify, ssa.OpAMD64SUBLmodify, ssa.OpAMD64ANDLmodify, ssa.OpAMD64ORLmodify, ssa.OpAMD64XORLmodify, + ssa.OpAMD64MOVBEQstore, ssa.OpAMD64MOVBELstore: p := s.Prog(v.Op.Asm()) p.From.Type = obj.TYPE_REG p.From.Reg = v.Args[1].Reg() diff --git a/src/cmd/compile/internal/amd64/versions_test.go b/src/cmd/compile/internal/amd64/versions_test.go index de677f3a69..ee1a8ca3aa 100644 --- a/src/cmd/compile/internal/amd64/versions_test.go +++ b/src/cmd/compile/internal/amd64/versions_test.go @@ -53,7 +53,9 @@ func TestGoAMD64v1(t *testing.T) { opcodes := map[string]bool{} var features []string for feature, opcodeList := range featureToOpcodes { - features = append(features, fmt.Sprintf("cpu.%s=off", feature)) + if runtimeFeatures[feature] { + features = append(features, fmt.Sprintf("cpu.%s=off", feature)) + } for _, op := range opcodeList { opcodes[op] = true } @@ -204,14 +206,28 @@ func clobber(t *testing.T, src string, dst *os.File, opcodes map[string]bool) { f.Close() } +func setOf(keys ...string) map[string]bool { + m := make(map[string]bool, len(keys)) + for _, key := range keys { + m[key] = true + } + return m +} + +var runtimeFeatures = setOf( + "adx", "aes", "avx", "avx2", "bmi1", "bmi2", "erms", "fma", + "pclmulqdq", "popcnt", "rdtscp", "sse3", "sse41", "sse42", "ssse3", +) + var featureToOpcodes = map[string][]string{ // Note: we include *q, *l, and plain opcodes here. // go tool objdump doesn't include a [QL] on popcnt instructions, until CL 351889 // native objdump doesn't include [QL] on linux. - "popcnt": []string{"popcntq", "popcntl", "popcnt"}, - "bmi1": []string{"andnq", "andnl", "andn", "blsiq", "blsil", "blsi", "blsmskq", "blsmskl", "blsmsk", "blsrq", "blsrl", "blsr", "tzcntq", "tzcntl", "tzcnt"}, - "sse41": []string{"roundsd"}, - "fma": []string{"vfmadd231sd"}, + "popcnt": {"popcntq", "popcntl", "popcnt"}, + "bmi1": {"andnq", "andnl", "andn", "blsiq", "blsil", "blsi", "blsmskq", "blsmskl", "blsmsk", "blsrq", "blsrl", "blsr", "tzcntq", "tzcntl", "tzcnt"}, + "sse41": {"roundsd"}, + "fma": {"vfmadd231sd"}, + "movbe": {"movbeqq", "movbeq", "movbell", "movbel", "movbe"}, } // Test to use POPCNT instruction, if available @@ -364,5 +380,4 @@ func TestFMA(t *testing.T) { t.Errorf("FMA(%f,%f,%f) = %f, want %f", tt.x, tt.y, tt.z, got, tt.want) } } - } diff --git a/src/cmd/compile/internal/ssa/gen/AMD64.rules b/src/cmd/compile/internal/ssa/gen/AMD64.rules index 8b73ee14ea..47a6af003c 100644 --- a/src/cmd/compile/internal/ssa/gen/AMD64.rules +++ b/src/cmd/compile/internal/ssa/gen/AMD64.rules @@ -2219,3 +2219,29 @@ (AND(Q|L) x (ADD(Q|L)const [-1] x)) && buildcfg.GOAMD64 >= 3 => (BLSR(Q|L) x) (BSWAP(Q|L) (BSWAP(Q|L) p)) => p + +// CPUID feature: MOVBE. +(MOV(Q|L)store [i] {s} p x:(BSWAP(Q|L) w) mem) && x.Uses == 1 && buildcfg.GOAMD64 >= 3 => (MOVBE(Q|L)store [i] {s} p w mem) +(BSWAP(Q|L) x:(MOV(Q|L)load [i] {s} p mem)) && x.Uses == 1 && buildcfg.GOAMD64 >= 3 => (MOVBE(Q|L)load [i] {s} p mem) +(BSWAP(Q|L) (MOVBE(Q|L)load [i] {s} p m)) => (MOV(Q|L)load [i] {s} p m) +(MOVBE(Q|L)store [i] {s} p (BSWAP(Q|L) x) m) => (MOV(Q|L)store [i] {s} p x m) + +(ORQ x0:(MOVBELload [i0] {s} p mem) + sh:(SHLQconst [32] x1:(MOVBELload [i1] {s} p mem))) + && i0 == i1+4 + && x0.Uses == 1 + && x1.Uses == 1 + && sh.Uses == 1 + && mergePoint(b,x0,x1) != nil + && clobber(x0, x1, sh) + => @mergePoint(b,x0,x1) (MOVBEQload [i1] {s} p mem) + +(ORQ x0:(MOVBELload [i] {s} p0 mem) + sh:(SHLQconst [32] x1:(MOVBELload [i] {s} p1 mem))) + && x0.Uses == 1 + && x1.Uses == 1 + && sh.Uses == 1 + && sequentialAddresses(p1, p0, 4) + && mergePoint(b,x0,x1) != nil + && clobber(x0, x1, sh) + => @mergePoint(b,x0,x1) (MOVBEQload [i] {s} p1 mem) diff --git a/src/cmd/compile/internal/ssa/gen/AMD64Ops.go b/src/cmd/compile/internal/ssa/gen/AMD64Ops.go index 731454c761..e3c94e4b2e 100644 --- a/src/cmd/compile/internal/ssa/gen/AMD64Ops.go +++ b/src/cmd/compile/internal/ssa/gen/AMD64Ops.go @@ -922,6 +922,12 @@ func init() { // and BSFQ(0) is undefined. Same for TZCNTL(0)==32 {name: "TZCNTQ", argLength: 1, reg: gp11, asm: "TZCNTQ", clobberFlags: true}, {name: "TZCNTL", argLength: 1, reg: gp11, asm: "TZCNTL", clobberFlags: true}, + + // CPUID feature: MOVBE + {name: "MOVBELload", argLength: 2, reg: gpload, asm: "MOVBEL", aux: "SymOff", typ: "UInt32", faultOnNilArg0: true, symEffect: "Read"}, // load and swap 4 bytes from arg0+auxint+aux. arg1=mem. Zero extend. + {name: "MOVBELstore", argLength: 3, reg: gpstore, asm: "MOVBEL", aux: "SymOff", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"}, // swap and store 4 bytes in arg1 to arg0+auxint+aux. arg2=mem + {name: "MOVBEQload", argLength: 2, reg: gpload, asm: "MOVBEQ", aux: "SymOff", typ: "UInt64", faultOnNilArg0: true, symEffect: "Read"}, // load and swap 8 bytes from arg0+auxint+aux. arg1=mem + {name: "MOVBEQstore", argLength: 3, reg: gpstore, asm: "MOVBEQ", aux: "SymOff", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"}, // swap and store 8 bytes in arg1 to arg0+auxint+aux. arg2=mem } var AMD64blocks = []blockData{ diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go index 640e517fe7..091f43f40a 100644 --- a/src/cmd/compile/internal/ssa/opGen.go +++ b/src/cmd/compile/internal/ssa/opGen.go @@ -1043,6 +1043,10 @@ const ( OpAMD64BLSRL OpAMD64TZCNTQ OpAMD64TZCNTL + OpAMD64MOVBELload + OpAMD64MOVBELstore + OpAMD64MOVBEQload + OpAMD64MOVBEQstore OpARMADD OpARMADDconst @@ -13780,6 +13784,66 @@ var opcodeTable = [...]opInfo{ }, }, }, + { + name: "MOVBELload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVBEL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295032831}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBELstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVBEL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 4295032831}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBEQload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVBEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295032831}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBEQstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVBEQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 4295032831}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, { name: "ADD", diff --git a/src/cmd/compile/internal/ssa/rewriteAMD64.go b/src/cmd/compile/internal/ssa/rewriteAMD64.go index 201fbf2954..0c789d6b49 100644 --- a/src/cmd/compile/internal/ssa/rewriteAMD64.go +++ b/src/cmd/compile/internal/ssa/rewriteAMD64.go @@ -222,6 +222,10 @@ func rewriteValueAMD64(v *Value) bool { return rewriteValueAMD64_OpAMD64LEAQ4(v) case OpAMD64LEAQ8: return rewriteValueAMD64_OpAMD64LEAQ8(v) + case OpAMD64MOVBELstore: + return rewriteValueAMD64_OpAMD64MOVBELstore(v) + case OpAMD64MOVBEQstore: + return rewriteValueAMD64_OpAMD64MOVBEQstore(v) case OpAMD64MOVBQSX: return rewriteValueAMD64_OpAMD64MOVBQSX(v) case OpAMD64MOVBQSXload: @@ -3623,6 +3627,43 @@ func rewriteValueAMD64_OpAMD64BSWAPL(v *Value) bool { v.copyOf(p) return true } + // match: (BSWAPL x:(MOVLload [i] {s} p mem)) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: (MOVBELload [i] {s} p mem) + for { + x := v_0 + if x.Op != OpAMD64MOVLload { + break + } + i := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64MOVBELload) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg2(p, mem) + return true + } + // match: (BSWAPL (MOVBELload [i] {s} p m)) + // result: (MOVLload [i] {s} p m) + for { + if v_0.Op != OpAMD64MOVBELload { + break + } + i := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + m := v_0.Args[1] + p := v_0.Args[0] + v.reset(OpAMD64MOVLload) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg2(p, m) + return true + } return false } func rewriteValueAMD64_OpAMD64BSWAPQ(v *Value) bool { @@ -3637,6 +3678,43 @@ func rewriteValueAMD64_OpAMD64BSWAPQ(v *Value) bool { v.copyOf(p) return true } + // match: (BSWAPQ x:(MOVQload [i] {s} p mem)) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: (MOVBEQload [i] {s} p mem) + for { + x := v_0 + if x.Op != OpAMD64MOVQload { + break + } + i := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64MOVBEQload) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg2(p, mem) + return true + } + // match: (BSWAPQ (MOVBEQload [i] {s} p m)) + // result: (MOVQload [i] {s} p m) + for { + if v_0.Op != OpAMD64MOVBEQload { + break + } + i := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + m := v_0.Args[1] + p := v_0.Args[0] + v.reset(OpAMD64MOVQload) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg2(p, m) + return true + } return false } func rewriteValueAMD64_OpAMD64BTCLconst(v *Value) bool { @@ -9395,6 +9473,52 @@ func rewriteValueAMD64_OpAMD64LEAQ8(v *Value) bool { } return false } +func rewriteValueAMD64_OpAMD64MOVBELstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBELstore [i] {s} p (BSWAPL x) m) + // result: (MOVLstore [i] {s} p x m) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + if v_1.Op != OpAMD64BSWAPL { + break + } + x := v_1.Args[0] + m := v_2 + v.reset(OpAMD64MOVLstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, x, m) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVBEQstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBEQstore [i] {s} p (BSWAPQ x) m) + // result: (MOVQstore [i] {s} p x m) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + if v_1.Op != OpAMD64BSWAPQ { + break + } + x := v_1.Args[0] + m := v_2 + v.reset(OpAMD64MOVQstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, x, m) + return true + } + return false +} func rewriteValueAMD64_OpAMD64MOVBQSX(v *Value) bool { v_0 := v.Args[0] b := v.Block @@ -12225,6 +12349,28 @@ func rewriteValueAMD64_OpAMD64MOVLstore(v *Value) bool { v.AddArg3(ptr, val, mem) return true } + // match: (MOVLstore [i] {s} p x:(BSWAPL w) mem) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: (MOVBELstore [i] {s} p w mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + x := v_1 + if x.Op != OpAMD64BSWAPL { + break + } + w := x.Args[0] + mem := v_2 + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64MOVBELstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, w, mem) + return true + } return false } func rewriteValueAMD64_OpAMD64MOVLstoreconst(v *Value) bool { @@ -13164,6 +13310,28 @@ func rewriteValueAMD64_OpAMD64MOVQstore(v *Value) bool { v.AddArg3(ptr, val, mem) return true } + // match: (MOVQstore [i] {s} p x:(BSWAPQ w) mem) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: (MOVBEQstore [i] {s} p w mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + x := v_1 + if x.Op != OpAMD64BSWAPQ { + break + } + w := x.Args[0] + mem := v_2 + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64MOVBEQstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, w, mem) + return true + } return false } func rewriteValueAMD64_OpAMD64MOVQstoreconst(v *Value) bool { @@ -18657,6 +18825,81 @@ func rewriteValueAMD64_OpAMD64ORQ(v *Value) bool { } break } + // match: (ORQ x0:(MOVBELload [i0] {s} p mem) sh:(SHLQconst [32] x1:(MOVBELload [i1] {s} p mem))) + // cond: i0 == i1+4 && x0.Uses == 1 && x1.Uses == 1 && sh.Uses == 1 && mergePoint(b,x0,x1) != nil && clobber(x0, x1, sh) + // result: @mergePoint(b,x0,x1) (MOVBEQload [i1] {s} p mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + if x0.Op != OpAMD64MOVBELload { + continue + } + i0 := auxIntToInt32(x0.AuxInt) + s := auxToSym(x0.Aux) + mem := x0.Args[1] + p := x0.Args[0] + sh := v_1 + if sh.Op != OpAMD64SHLQconst || auxIntToInt8(sh.AuxInt) != 32 { + continue + } + x1 := sh.Args[0] + if x1.Op != OpAMD64MOVBELload { + continue + } + i1 := auxIntToInt32(x1.AuxInt) + if auxToSym(x1.Aux) != s { + continue + } + _ = x1.Args[1] + if p != x1.Args[0] || mem != x1.Args[1] || !(i0 == i1+4 && x0.Uses == 1 && x1.Uses == 1 && sh.Uses == 1 && mergePoint(b, x0, x1) != nil && clobber(x0, x1, sh)) { + continue + } + b = mergePoint(b, x0, x1) + v0 := b.NewValue0(x1.Pos, OpAMD64MOVBEQload, typ.UInt64) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(i1) + v0.Aux = symToAux(s) + v0.AddArg2(p, mem) + return true + } + break + } + // match: (ORQ x0:(MOVBELload [i] {s} p0 mem) sh:(SHLQconst [32] x1:(MOVBELload [i] {s} p1 mem))) + // cond: x0.Uses == 1 && x1.Uses == 1 && sh.Uses == 1 && sequentialAddresses(p1, p0, 4) && mergePoint(b,x0,x1) != nil && clobber(x0, x1, sh) + // result: @mergePoint(b,x0,x1) (MOVBEQload [i] {s} p1 mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + if x0.Op != OpAMD64MOVBELload { + continue + } + i := auxIntToInt32(x0.AuxInt) + s := auxToSym(x0.Aux) + mem := x0.Args[1] + p0 := x0.Args[0] + sh := v_1 + if sh.Op != OpAMD64SHLQconst || auxIntToInt8(sh.AuxInt) != 32 { + continue + } + x1 := sh.Args[0] + if x1.Op != OpAMD64MOVBELload || auxIntToInt32(x1.AuxInt) != i || auxToSym(x1.Aux) != s { + continue + } + _ = x1.Args[1] + p1 := x1.Args[0] + if mem != x1.Args[1] || !(x0.Uses == 1 && x1.Uses == 1 && sh.Uses == 1 && sequentialAddresses(p1, p0, 4) && mergePoint(b, x0, x1) != nil && clobber(x0, x1, sh)) { + continue + } + b = mergePoint(b, x0, x1) + v0 := b.NewValue0(x1.Pos, OpAMD64MOVBEQload, typ.UInt64) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(i) + v0.Aux = symToAux(s) + v0.AddArg2(p1, mem) + return true + } + break + } return false } func rewriteValueAMD64_OpAMD64ORQconst(v *Value) bool { diff --git a/test/codegen/memcombine.go b/test/codegen/memcombine.go index 2a0c534df0..97e1d4bdfb 100644 --- a/test/codegen/memcombine.go +++ b/test/codegen/memcombine.go @@ -70,7 +70,8 @@ func load_le16_idx(b []byte, idx int) { } func load_be64(b []byte) { - // amd64:`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` + // amd64/v1,amd64/v2:`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` + // amd64/v3:`MOVBEQ` // s390x:`MOVD\s\(.*\),` // arm64:`REV`,`MOVD\s\(R[0-9]+\),`,-`MOV[BHW]`,-`REVW`,-`REV16W` // ppc64le:`MOVDBR`,-`MOV[BHW]Z` @@ -78,7 +79,8 @@ func load_be64(b []byte) { } func load_be64_idx(b []byte, idx int) { - // amd64:`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` + // amd64/v1,amd64/v2:`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` + // amd64/v3: `MOVBEQ` // s390x:`MOVD\s\(.*\)\(.*\*1\),` // arm64:`REV`,`MOVD\s\(R[0-9]+\)\(R[0-9]+\),`,-`MOV[WHB]`,-`REVW`,-`REV16W` // ppc64le:`MOVDBR`,-`MOV[BHW]Z` @@ -86,7 +88,8 @@ func load_be64_idx(b []byte, idx int) { } func load_be32(b []byte) { - // amd64:`BSWAPL`,-`MOV[BW]`,-`OR` + // amd64/v1,amd64/v2:`BSWAPL`,-`MOV[BW]`,-`OR` + // amd64/v3: `MOVBEL` // s390x:`MOVWZ\s\(.*\),` // arm64:`REVW`,`MOVWU\s\(R[0-9]+\),`,-`MOV[BH]`,-`REV16W` // ppc64le:`MOVWBR`,-`MOV[BH]Z` @@ -94,7 +97,8 @@ func load_be32(b []byte) { } func load_be32_idx(b []byte, idx int) { - // amd64:`BSWAPL`,-`MOV[BW]`,-`OR` + // amd64/v1,amd64/v2:`BSWAPL`,-`MOV[BW]`,-`OR` + // amd64/v3: `MOVBEL` // s390x:`MOVWZ\s\(.*\)\(.*\*1\),` // arm64:`REVW`,`MOVWU\s\(R[0-9]+\)\(R[0-9]+\),`,-`MOV[HB]`,-`REV16W` // ppc64le:`MOVWBR`,-`MOV[BH]Z` @@ -179,7 +183,8 @@ func load_be_byte4_uint32(s []byte) uint32 { func load_be_byte4_uint32_inv(s []byte) uint32 { // arm64:`MOVWU\t\(R[0-9]+\)`,`REVW`,-`ORR`,-`REV16W`,-`MOV[BH]` - // amd64:`MOVL\s\([A-Z]+\)`,`BSWAPL`,-`MOV[BW]`,-`OR` + // amd64/v1,amd64/v2:`MOVL\s\([A-Z]+\)`,`BSWAPL`,-`MOV[BW]`,-`OR` + // amd64/v3: `MOVBEL` return uint32(s[3]) | uint32(s[2])<<8 | uint32(s[1])<<16 | uint32(s[0])<<24 } @@ -191,7 +196,8 @@ func load_be_byte8_uint64(s []byte) uint64 { func load_be_byte8_uint64_inv(s []byte) uint64 { // arm64:`MOVD\t\(R[0-9]+\)`,`REV`,-`ORR`,-`REVW`,-`REV16W`,-`MOV[BHW]` - // amd64:`MOVQ\s\([A-Z]+\),\s[A-Z]+`,`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` + // amd64/v1,amd64/v2:`MOVQ\s\([A-Z]+\),\s[A-Z]+`,`BSWAPQ`,-`MOV[BWL]\t[^$]`,-`OR` + // amd64/v3: `MOVBEQ` // ppc64le:`MOVDBR\t\(R[0-9]+\)`,-`MOV[BHW]Z` return uint64(s[7]) | uint64(s[6])<<8 | uint64(s[5])<<16 | uint64(s[4])<<24 | uint64(s[3])<<32 | uint64(s[2])<<40 | uint64(s[1])<<48 | uint64(s[0])<<56 } @@ -409,7 +415,8 @@ func store_le16_idx(b []byte, idx int) { } func store_be64(b []byte) { - // amd64:`BSWAPQ`,-`SHR.` + // amd64/v1,amd64/v2:`BSWAPQ`,-`SHR.` + // amd64/v3: `MOVBEQ` // arm64:`MOVD`,`REV`,-`MOV[WBH]`,-`REVW`,-`REV16W` // ppc64le:`MOVDBR` // s390x:`MOVD\s.*\(.*\)$`,-`SRW\s`,-`SRD\s` @@ -417,7 +424,8 @@ func store_be64(b []byte) { } func store_be64_idx(b []byte, idx int) { - // amd64:`BSWAPQ`,-`SHR.` + // amd64/v1,amd64/v2:`BSWAPQ`,-`SHR.` + // amd64/v3:`MOVBEQ` // arm64:`REV`,`MOVD\sR[0-9]+,\s\(R[0-9]+\)\(R[0-9]+\)`,-`MOV[BHW]`,-`REV16W`,-`REVW` // ppc64le:`MOVDBR` // s390x:`MOVD\s.*\(.*\)\(.*\*1\)$`,-`SRW\s`,-`SRD\s` @@ -425,7 +433,8 @@ func store_be64_idx(b []byte, idx int) { } func store_be32(b []byte) { - // amd64:`BSWAPL`,-`SHR.` + // amd64/v1,amd64/v2:`BSWAPL`,-`SHR.` + // amd64/v3:`MOVBEL` // arm64:`MOVW`,`REVW`,-`MOV[BH]`,-`REV16W` // ppc64le:`MOVWBR` // s390x:`MOVW\s.*\(.*\)$`,-`SRW\s`,-`SRD\s` @@ -445,7 +454,8 @@ func store_be32_load(b, x *[8]byte) { } func store_be32_idx(b []byte, idx int) { - // amd64:`BSWAPL`,-`SHR.` + // amd64/v1,amd64/v2:`BSWAPL`,-`SHR.` + // amd64/v3:`MOVBEL` // arm64:`REVW`,`MOVW\sR[0-9]+,\s\(R[0-9]+\)\(R[0-9]+\)`,-`MOV[BH]`,-`REV16W` // ppc64le:`MOVWBR` // s390x:`MOVW\s.*\(.*\)\(.*\*1\)$`,-`SRW\s`,-`SRD\s` @@ -508,14 +518,16 @@ func store_be_byte_2(b []byte, val uint16) { func store_be_byte_4(b []byte, val uint32) { _ = b[4] // arm64:`REVW`,`MOVW\sR[0-9]+,\s1\(R[0-9]+\)`,-`MOVB`,-`MOVH`,-`REV16W` - // amd64:`MOVL\s[A-Z]+,\s1\([A-Z]+\)`,-`MOVB`,-`MOVW` + // amd64/v1,amd64/v2:`MOVL\s[A-Z]+,\s1\([A-Z]+\)`,-`MOVB`,-`MOVW` + // amd64/v3:`MOVBEL\s[A-Z]+,\s1\([A-Z]+\)` b[1], b[2], b[3], b[4] = byte(val>>24), byte(val>>16), byte(val>>8), byte(val) } func store_be_byte_8(b []byte, val uint64) { _ = b[8] // arm64:`REV`,`MOVD\sR[0-9]+,\s1\(R[0-9]+\)`,-`MOVB`,-`MOVH`,-`MOVW`,-`REV16W`,-`REVW` - // amd64:`MOVQ\s[A-Z]+,\s1\([A-Z]+\)`,-`MOVB`,-`MOVW`,-`MOVL` + // amd64/v1,amd64/v2:`MOVQ\s[A-Z]+,\s1\([A-Z]+\)`,-`MOVB`,-`MOVW`,-`MOVL` + // amd64/v3:`MOVBEQ\s[A-Z]+,\s1\([A-Z]+\)`, -`MOVBEL` b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8] = byte(val>>56), byte(val>>48), byte(val>>40), byte(val>>32), byte(val>>24), byte(val>>16), byte(val>>8), byte(val) } From f92a3589fa04285dccab3ca7454eaaf2d0e7cde3 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 19 Oct 2021 16:34:43 +0700 Subject: [PATCH 069/406] reflect: fix methodValueCall code pointer mismatched CL 322350 changed how to take address of assembly functions, using abi.FuncPCABI0 intrinsic. But we forgot to update the code in Value.UnsafePointer (was Value.Pointer) to reflect that change. This CL fixes that bug, and also add a test to make sure the code pointer is in sync. Change-Id: I05ae7df31c706583a0f374d8af027066528f5ceb Reviewed-on: https://go-review.googlesource.com/c/go/+/356809 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- src/reflect/all_test.go | 8 ++++++++ src/reflect/export_test.go | 2 ++ src/reflect/makefunc.go | 6 +++++- src/reflect/value.go | 4 ++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 141cc8f73d..91aac9cccb 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -7722,3 +7722,11 @@ func TestNotInHeapDeref(t *testing.T) { v = ValueOf((*nih)(unsafe.Pointer(new(int)))) shouldPanic("reflect: reflect.Value.Elem on an invalid notinheap pointer", func() { v.Elem() }) } + +func TestMethodCallValueCodePtr(t *testing.T) { + p := ValueOf(Point{}).Method(1).UnsafePointer() + want := MethodValueCallCodePtr() + if got := uintptr(p); got != want { + t.Errorf("methodValueCall code pointer mismatched, want: %v, got: %v", want, got) + } +} diff --git a/src/reflect/export_test.go b/src/reflect/export_test.go index 01749e30d8..ba7fb68067 100644 --- a/src/reflect/export_test.go +++ b/src/reflect/export_test.go @@ -161,3 +161,5 @@ func SetArgRegs(ints, floats int, floatSize uintptr) (oldInts, oldFloats int, ol clearLayoutCache() return } + +var MethodValueCallCodePtr = methodValueCallCodePtr diff --git a/src/reflect/makefunc.go b/src/reflect/makefunc.go index 588be8bcc1..d0b0935cb8 100644 --- a/src/reflect/makefunc.go +++ b/src/reflect/makefunc.go @@ -107,7 +107,7 @@ func makeMethodValue(op string, v Value) Value { // v.Type returns the actual type of the method value. ftyp := (*funcType)(unsafe.Pointer(v.Type().(*rtype))) - code := abi.FuncPCABI0(methodValueCall) + code := methodValueCallCodePtr() // methodValue contains a stack map for use by the runtime _, _, abi := funcLayout(ftyp, nil) @@ -130,6 +130,10 @@ func makeMethodValue(op string, v Value) Value { return Value{&ftyp.rtype, unsafe.Pointer(fv), v.flag&flagRO | flag(Func)} } +func methodValueCallCodePtr() uintptr { + return abi.FuncPCABI0(methodValueCall) +} + // methodValueCall is an assembly function that is the code half of // the function returned from makeMethodValue. It expects a *methodValue // as its context register, and its job is to invoke callMethod(ctxt, frame) diff --git a/src/reflect/value.go b/src/reflect/value.go index a272714ac9..1d385f6bf9 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -2488,8 +2488,8 @@ func (v Value) UnsafePointer() unsafe.Pointer { // created via reflect have the same underlying code pointer, // so their Pointers are equal. The function used here must // match the one used in makeMethodValue. - f := methodValueCall - return **(**unsafe.Pointer)(unsafe.Pointer(&f)) + code := methodValueCallCodePtr() + return *(*unsafe.Pointer)(unsafe.Pointer(&code)) } p := v.pointer() // Non-nil func value points at data block. From 254c497e5c5628be115b966808d6e76d335313a3 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 18 Oct 2021 14:56:08 -0700 Subject: [PATCH 070/406] cmd/compile, types2: better error message for invalid type assertion This CL addresses the 2nd part of the issue below. - For types2, now use the same error messages as the compiler in this case. - Make the mechanism for reporting clarifying error messages handle the case where we don't have additional position information. - Provide context information (type assertion vs type switch). Fixes #49005. Change-Id: I4eeaf4f0c3f2f8735b63993778f58d713fef21ee Reviewed-on: https://go-review.googlesource.com/c/go/+/356512 Trust: Robert Griesemer Reviewed-by: Cuong Manh Le Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/errors.go | 5 ++- .../compile/internal/types2/errors_test.go | 2 +- src/cmd/compile/internal/types2/expr.go | 22 +++++++----- src/cmd/compile/internal/types2/stmt.go | 4 +-- .../internal/types2/testdata/check/expr3.src | 4 +-- .../internal/types2/testdata/check/issues.src | 4 +-- .../internal/types2/testdata/check/stmt0.src | 2 +- .../types2/testdata/fixedbugs/issue49005.go | 34 +++++++++++++++++++ test/fixedbugs/issue49005b.go | 15 ++++++++ test/switch6.go | 4 +-- 10 files changed, 77 insertions(+), 19 deletions(-) create mode 100644 src/cmd/compile/internal/types2/testdata/fixedbugs/issue49005.go create mode 100644 test/fixedbugs/issue49005b.go diff --git a/src/cmd/compile/internal/types2/errors.go b/src/cmd/compile/internal/types2/errors.go index ea43fab178..0c8a4a90ff 100644 --- a/src/cmd/compile/internal/types2/errors.go +++ b/src/cmd/compile/internal/types2/errors.go @@ -61,7 +61,10 @@ func (err *error_) msg(qf Qualifier) string { for i := range err.desc { p := &err.desc[i] if i > 0 { - fmt.Fprintf(&buf, "\n\t%s: ", p.pos) + fmt.Fprint(&buf, "\n\t") + if p.pos.IsKnown() { + fmt.Fprintf(&buf, "%s: ", p.pos) + } } buf.WriteString(sprintf(qf, p.format, p.args...)) } diff --git a/src/cmd/compile/internal/types2/errors_test.go b/src/cmd/compile/internal/types2/errors_test.go index 72a2ce3655..ac73ca4650 100644 --- a/src/cmd/compile/internal/types2/errors_test.go +++ b/src/cmd/compile/internal/types2/errors_test.go @@ -19,7 +19,7 @@ func TestError(t *testing.T) { t.Errorf("simple error: got %q, want %q", got, want) } - want = ": foo 42\n\t: bar 43" + want = ": foo 42\n\tbar 43" err.errorf(nopos, "bar %d", 43) if got := err.String(); got != want { t.Errorf("simple error: got %q, want %q", got, want) diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index 3a3a139156..2d22c027eb 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -1463,7 +1463,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin if T == Typ[Invalid] { goto Error } - check.typeAssertion(posFor(x), x, xtyp, T) + check.typeAssertion(e, x, xtyp, T, false) x.mode = commaok x.typ = T @@ -1605,26 +1605,32 @@ func keyVal(x constant.Value) interface{} { } // typeAssertion checks that x.(T) is legal; xtyp must be the type of x. -func (check *Checker) typeAssertion(pos syntax.Pos, x *operand, xtyp *Interface, T Type) { +func (check *Checker) typeAssertion(e syntax.Expr, x *operand, xtyp *Interface, T Type, typeSwitch bool) { method, wrongType := check.assertableTo(xtyp, T) if method == nil { return } + var msg string if wrongType != nil { if Identical(method.typ, wrongType.typ) { - msg = fmt.Sprintf("missing method %s (%s has pointer receiver)", method.name, method.name) + msg = fmt.Sprintf("%s method has pointer receiver", method.name) } else { - msg = fmt.Sprintf("wrong type for method %s (have %s, want %s)", method.name, wrongType.typ, method.typ) + msg = fmt.Sprintf("wrong type for method %s: have %s, want %s", method.name, wrongType.typ, method.typ) } } else { - msg = "missing method " + method.name + msg = fmt.Sprintf("missing %s method", method.name) } - if check.conf.CompilerErrorMessages { - check.errorf(pos, "impossible type assertion: %s (%s)", x, msg) + + var err error_ + if typeSwitch { + err.errorf(e.Pos(), "impossible type switch case: %s", e) + err.errorf(nopos, "%s cannot have dynamic type %s (%s)", x, T, msg) } else { - check.errorf(pos, "%s cannot have dynamic type %s (%s)", x, T, msg) + err.errorf(e.Pos(), "impossible type assertion: %s", e) + err.errorf(nopos, "%s does not implement %s (%s)", T, x.typ, msg) } + check.report(&err) } // expr typechecks expression e and initializes x with the expression value. diff --git a/src/cmd/compile/internal/types2/stmt.go b/src/cmd/compile/internal/types2/stmt.go index f3f345fd2f..e826f35105 100644 --- a/src/cmd/compile/internal/types2/stmt.go +++ b/src/cmd/compile/internal/types2/stmt.go @@ -306,7 +306,7 @@ L: } seen[T] = e if T != nil { - check.typeAssertion(e.Pos(), x, xtyp, T) + check.typeAssertion(e, x, xtyp, T, true) } } return @@ -347,7 +347,7 @@ L: // } // seen[hash] = e // if T != nil { -// check.typeAssertion(e.Pos(), x, xtyp, T) +// check.typeAssertion(e, x, xtyp, T, true) // } // } // return diff --git a/src/cmd/compile/internal/types2/testdata/check/expr3.src b/src/cmd/compile/internal/types2/testdata/check/expr3.src index fd28421dc8..df4cf6a840 100644 --- a/src/cmd/compile/internal/types2/testdata/check/expr3.src +++ b/src/cmd/compile/internal/types2/testdata/check/expr3.src @@ -459,9 +459,9 @@ func type_asserts() { var t I _ = t /* ERROR "use of .* outside type switch" */ .(type) - _ = t /* ERROR "missing method m" */ .(T) + _ = t /* ERROR "m method has pointer receiver" */ .(T) _ = t.(*T) - _ = t /* ERROR "missing method m" */ .(T1) + _ = t /* ERROR "missing m method" */ .(T1) _ = t /* ERROR "wrong type for method m" */ .(T2) _ = t /* STRICT "wrong type for method m" */ .(I2) // only an error in strict mode (issue 8561) diff --git a/src/cmd/compile/internal/types2/testdata/check/issues.src b/src/cmd/compile/internal/types2/testdata/check/issues.src index d83a95af0e..dfd51006b9 100644 --- a/src/cmd/compile/internal/types2/testdata/check/issues.src +++ b/src/cmd/compile/internal/types2/testdata/check/issues.src @@ -132,12 +132,12 @@ func issue10260() { var x I1 x = T1 /* ERROR cannot use .*: missing method foo \(foo has pointer receiver\) */ {} - _ = x /* ERROR .* cannot have dynamic type T1 \(missing method foo \(foo has pointer receiver\)\) */ .(T1) + _ = x. /* ERROR impossible type assertion: x.\(T1\)\n\tT1 does not implement I1 \(foo method has pointer receiver\) */ (T1) T1{}.foo /* ERROR cannot call pointer method foo on T1 */ () x.Foo /* ERROR "x.Foo undefined \(type I1 has no field or method Foo, but does have foo\)" */ () - _ = i2 /* ERROR i2 .* cannot have dynamic type \*T1 \(wrong type for method foo \(have func\(\), want func\(x int\)\)\) */ .(*T1) + _ = i2. /* ERROR impossible type assertion: i2.\(\*T1\)\n\t\*T1 does not implement I2 \(wrong type for method foo: have func\(\), want func\(x int\)\) */ (*T1) i1 = i0 /* ERROR cannot use .* missing method foo */ i1 = t0 /* ERROR cannot use .* missing method foo */ diff --git a/src/cmd/compile/internal/types2/testdata/check/stmt0.src b/src/cmd/compile/internal/types2/testdata/check/stmt0.src index d744f2ba81..5ec37b4ace 100644 --- a/src/cmd/compile/internal/types2/testdata/check/stmt0.src +++ b/src/cmd/compile/internal/types2/testdata/check/stmt0.src @@ -715,7 +715,7 @@ func typeswitches() { var t I switch t.(type) { case T: - case T1 /* ERROR "missing method m" */ : + case T1 /* ERROR "missing m method" */ : case T2 /* ERROR "wrong type for method m" */ : case I2 /* STRICT "wrong type for method m" */ : // only an error in strict mode (issue 8561) } diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49005.go b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49005.go new file mode 100644 index 0000000000..6225e68488 --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49005.go @@ -0,0 +1,34 @@ +// Copyright 2021 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. + +// This file is tested when running "go test -run Manual" +// without source arguments. Use for one-off debugging. + +package p + +type T1 interface{ M() } + +func F1() T1 + +var _ = F1().(*X1 /* ERROR undeclared name: X1 */) + +func _() { + switch F1().(type) { + case *X1 /* ERROR undeclared name: X1 */ : + } +} + +type T2 interface{ M() } + +func F2() T2 + +var _ = F2(). /* ERROR impossible type assertion: F2\(\).\(\*X2\)\n\t\*X2 does not implement T2 \(missing M method\) */ (*X2) + +type X2 struct{} + +func _() { + switch F2().(type) { + case * /* ERROR impossible type switch case: \*X2\n\tF2\(\) \(value of type T2\) cannot have dynamic type \*X2 \(missing M method\) */ X2: + } +} diff --git a/test/fixedbugs/issue49005b.go b/test/fixedbugs/issue49005b.go new file mode 100644 index 0000000000..9bff4e9d18 --- /dev/null +++ b/test/fixedbugs/issue49005b.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2021 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 p + +type T interface{ M() } + +func F() T + +var _ = F().(*X) // ERROR "impossible type assertion:( F\(\).\(\*X\))?\n\t\*X does not implement T \(missing M method\)" + +type X struct{} diff --git a/test/switch6.go b/test/switch6.go index 4f95d02615..b9d9800391 100644 --- a/test/switch6.go +++ b/test/switch6.go @@ -15,7 +15,7 @@ package main // Verify that type switch statements with impossible cases are detected by the compiler. func f0(e error) { switch e.(type) { - case int: // ERROR "impossible type switch case: e \(type error\) cannot have dynamic type int \(missing Error method\)|impossible type assertion" + case int: // ERROR "impossible type switch case: (int\n\t)?e \(.*type error\) cannot have dynamic type int \(missing Error method\)" } } @@ -41,6 +41,6 @@ func (*X) Foo() {} func f2() { var i I switch i.(type) { - case X: // ERROR "impossible type switch case: i \(type I\) cannot have dynamic type X \(Foo method has pointer receiver\)|impossible type assertion" + case X: // ERROR "impossible type switch case: (X\n\t)?i \(.*type I\) cannot have dynamic type X \(Foo method has pointer receiver\)" } } From 3a07ab70a2d63e3ac1fc126529dde29852a972f5 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 18 Oct 2021 17:17:08 -0700 Subject: [PATCH 071/406] cmd/compile/internal/types2: add support for inferring type instances This is an essentially clean port of CL 356489 from go/types to types2, with minor adjustments due to the different AST packages and error reporting. Fixes #47990. Change-Id: I52187872474bfc1fb49eb77905f22fc820b7295b Reviewed-on: https://go-review.googlesource.com/c/go/+/356514 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/call.go | 32 +++++++- .../compile/internal/types2/instantiate.go | 49 ------------ src/cmd/compile/internal/types2/named.go | 3 +- .../{tinference.go2 => funcinference.go2} | 29 ++++--- .../types2/testdata/check/typeinference.go2 | 47 +++++++++++ .../types2/testdata/check/typeinst2.go2 | 4 + .../types2/testdata/check/typeinstcycles.go2 | 11 +++ src/cmd/compile/internal/types2/typexpr.go | 80 ++++++++++++++++--- 8 files changed, 177 insertions(+), 78 deletions(-) rename src/cmd/compile/internal/types2/testdata/check/{tinference.go2 => funcinference.go2} (82%) create mode 100644 src/cmd/compile/internal/types2/testdata/check/typeinference.go2 create mode 100644 src/cmd/compile/internal/types2/testdata/check/typeinstcycles.go2 diff --git a/src/cmd/compile/internal/types2/call.go b/src/cmd/compile/internal/types2/call.go index 8b45b28017..3859e39550 100644 --- a/src/cmd/compile/internal/types2/call.go +++ b/src/cmd/compile/internal/types2/call.go @@ -57,7 +57,7 @@ func (check *Checker) funcInst(x *operand, inst *syntax.IndexExpr) { } // instantiate function signature - res := check.instantiate(x.Pos(), sig, targs, poslist).(*Signature) + res := check.instantiateSignature(x.Pos(), sig, targs, poslist) assert(res.TypeParams().Len() == 0) // signature is not generic anymore check.recordInstance(inst.X, targs, res) x.typ = res @@ -65,6 +65,34 @@ func (check *Checker) funcInst(x *operand, inst *syntax.IndexExpr) { x.expr = inst } +func (check *Checker) instantiateSignature(pos syntax.Pos, typ *Signature, targs []Type, posList []syntax.Pos) (res *Signature) { + assert(check != nil) + assert(len(targs) == typ.TypeParams().Len()) + + if check.conf.Trace { + check.trace(pos, "-- instantiating %s with %s", typ, targs) + check.indent++ + defer func() { + check.indent-- + check.trace(pos, "=> %s (under = %s)", res, res.Underlying()) + }() + } + + inst := check.instance(pos, typ, targs, check.conf.Context).(*Signature) + assert(len(posList) <= len(targs)) + tparams := typ.TypeParams().list() + if i, err := check.verify(pos, tparams, targs); err != nil { + // best position for error reporting + pos := pos + if i < len(posList) { + pos = posList[i] + } + check.softErrorf(pos, err.Error()) + } + + return inst +} + func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind { var inst *syntax.IndexExpr // function instantiation, if any if iexpr, _ := call.Fun.(*syntax.IndexExpr); iexpr != nil { @@ -345,7 +373,7 @@ func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []T } // compute result signature - rsig = check.instantiate(call.Pos(), sig, targs, nil).(*Signature) + rsig = check.instantiateSignature(call.Pos(), sig, targs, nil) assert(rsig.TypeParams().Len() == 0) // signature is not generic anymore check.recordInstance(call.Fun, targs, rsig) diff --git a/src/cmd/compile/internal/types2/instantiate.go b/src/cmd/compile/internal/types2/instantiate.go index 5e45ea33ce..d6cefb4bfe 100644 --- a/src/cmd/compile/internal/types2/instantiate.go +++ b/src/cmd/compile/internal/types2/instantiate.go @@ -49,55 +49,6 @@ func Instantiate(ctxt *Context, typ Type, targs []Type, validate bool) (Type, er return inst, err } -// instantiate creates an instance and defers verification of constraints to -// later in the type checking pass. For Named types the resulting instance will -// be unexpanded. -func (check *Checker) instantiate(pos syntax.Pos, typ Type, targs []Type, posList []syntax.Pos) (res Type) { - assert(check != nil) - if check.conf.Trace { - check.trace(pos, "-- instantiating %s with %s", typ, NewTypeList(targs)) - check.indent++ - defer func() { - check.indent-- - var under Type - if res != nil { - // Calling under() here may lead to endless instantiations. - // Test case: type T[P any] T[P] - under = safeUnderlying(res) - } - check.trace(pos, "=> %s (under = %s)", res, under) - }() - } - - inst := check.instance(pos, typ, targs, check.conf.Context) - - assert(len(posList) <= len(targs)) - check.later(func() { - // Collect tparams again because lazily loaded *Named types may not have - // had tparams set up above. - var tparams []*TypeParam - switch t := typ.(type) { - case *Named: - tparams = t.TypeParams().list() - case *Signature: - tparams = t.TypeParams().list() - } - // Avoid duplicate errors; instantiate will have complained if tparams - // and targs do not have the same length. - if len(tparams) == len(targs) { - if i, err := check.verify(pos, tparams, targs); err != nil { - // best position for error reporting - pos := pos - if i < len(posList) { - pos = posList[i] - } - check.softErrorf(pos, err.Error()) - } - } - }) - return inst -} - // instance creates a type or function instance using the given original type // typ and arguments targs. For Named types the resulting instance will be // unexpanded. diff --git a/src/cmd/compile/internal/types2/named.go b/src/cmd/compile/internal/types2/named.go index 3971e03179..8f2a52b4f2 100644 --- a/src/cmd/compile/internal/types2/named.go +++ b/src/cmd/compile/internal/types2/named.go @@ -239,7 +239,8 @@ func expandNamed(ctxt *Context, n *Named, instPos syntax.Pos) (tparams *TypePara check := n.check - if check.validateTArgLen(instPos, n.orig.tparams.Len(), n.targs.Len()) { + // Mismatching arg and tparam length may be checked elsewhere. + if n.orig.tparams.Len() == n.targs.Len() { // We must always have a context, to avoid infinite recursion. ctxt = check.bestContext(ctxt) h := ctxt.TypeHash(n.orig, n.targs.list()) diff --git a/src/cmd/compile/internal/types2/testdata/check/tinference.go2 b/src/cmd/compile/internal/types2/testdata/check/funcinference.go2 similarity index 82% rename from src/cmd/compile/internal/types2/testdata/check/tinference.go2 rename to src/cmd/compile/internal/types2/testdata/check/funcinference.go2 index 2409fef4ae..7160e18b19 100644 --- a/src/cmd/compile/internal/types2/testdata/check/tinference.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/funcinference.go2 @@ -2,26 +2,25 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package tinferenceB +package funcInference import "strconv" type any interface{} -// Embedding stand-alone type parameters is not permitted for now. Disabled. -// func f0[A any, B interface{~C}, C interface{~D}, D interface{~A}](A, B, C, D) -// func _() { -// f := f0[string] -// f("a", "b", "c", "d") -// f0("a", "b", "c", "d") -// } -// -// func f1[A any, B interface{~A}](A, B) -// func _() { -// f := f1[int] -// f(int(0), int(0)) -// f1(int(0), int(0)) -// } +func f0[A any, B interface{~*C}, C interface{~*D}, D interface{~*A}](A, B, C, D) {} +func _() { + f := f0[string] + f("a", nil, nil, nil) + f0("a", nil, nil, nil) +} + +func f1[A any, B interface{~*A}](A, B) {} +func _() { + f := f1[int] + f(int(0), new(int)) + f1(int(0), new(int)) +} func f2[A any, B interface{~[]A}](A, B) {} func _() { diff --git a/src/cmd/compile/internal/types2/testdata/check/typeinference.go2 b/src/cmd/compile/internal/types2/testdata/check/typeinference.go2 new file mode 100644 index 0000000000..8876ccaa4e --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/check/typeinference.go2 @@ -0,0 +1,47 @@ +// Copyright 2021 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 typeInference + +// basic inference +type Tb[P ~*Q, Q any] int +func _() { + var x Tb[*int] + var y Tb[*int, int] + x = y + _ = x +} + +// recursive inference +type Tr[A any, B ~*C, C ~*D, D ~*A] int +func _() { + var x Tr[string] + var y Tr[string, ***string, **string, *string] + var z Tr[int, ***int, **int, *int] + x = y + x = z // ERROR cannot use z .* as Tr + _ = x +} + +// other patterns of inference +type To0[A any, B ~[]A] int +type To1[A any, B ~struct{a A}] int +type To2[A any, B ~[][]A] int +type To3[A any, B ~[3]*A] int +type To4[A any, B any, C ~struct{a A; b B}] int +func _() { + var _ To0[int] + var _ To1[int] + var _ To2[int] + var _ To3[int] + var _ To4[int, string] +} + +// failed inference +type Tf0[A, B any] int +type Tf1[A any, B ~struct{a A; c C}, C any] int +func _() { + var _ Tf0 /* ERROR cannot infer B */ /* ERROR got 1 arguments but 2 type parameters */ [int] + var _ Tf1 /* ERROR cannot infer B */ /* ERROR got 1 arguments but 3 type parameters */ [int] +} diff --git a/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 b/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 index 49f48c7283..ecf4b0f714 100644 --- a/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 @@ -252,3 +252,7 @@ var _ = f0_[int] var _ = f0_[bool /* ERROR does not satisfy I0_ */ ] var _ = f0_[string /* ERROR does not satisfy I0_ */ ] var _ = f0_[float64 /* ERROR does not satisfy I0_ */ ] + +// Using a function instance as a type is an error. +var _ f0 // ERROR not a type +var _ f0 /* ERROR not a type */ [int] diff --git a/src/cmd/compile/internal/types2/testdata/check/typeinstcycles.go2 b/src/cmd/compile/internal/types2/testdata/check/typeinstcycles.go2 new file mode 100644 index 0000000000..74fe19195a --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/check/typeinstcycles.go2 @@ -0,0 +1,11 @@ +// Copyright 2021 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 p + +import "unsafe" + +func F1[T any](_ [unsafe.Sizeof(F1[int])]T) (res T) { return } +func F2[T any](_ T) (res [unsafe.Sizeof(F2[string])]int) { return } +func F3[T any](_ [unsafe.Sizeof(F1[string])]int) {} diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go index eae9330914..20e56caf1e 100644 --- a/src/cmd/compile/internal/types2/typexpr.go +++ b/src/cmd/compile/internal/types2/typexpr.go @@ -396,13 +396,24 @@ func (check *Checker) typInternal(e0 syntax.Expr, def *Named) (T Type) { return typ } -func (check *Checker) instantiatedType(x syntax.Expr, targsx []syntax.Expr, def *Named) Type { +func (check *Checker) instantiatedType(x syntax.Expr, targsx []syntax.Expr, def *Named) (res Type) { + if check.conf.Trace { + check.trace(x.Pos(), "-- instantiating %s with %s", x, targsx) + check.indent++ + defer func() { + check.indent-- + // Don't format the underlying here. It will always be nil. + check.trace(x.Pos(), "=> %s", res) + }() + } + gtyp := check.genericType(x, true) if gtyp == Typ[Invalid] { return gtyp // error already reported } - base, _ := gtyp.(*Named) - if base == nil { + + origin, _ := gtyp.(*Named) + if origin == nil { panic(fmt.Sprintf("%v: cannot instantiate %v", x.Pos(), gtyp)) } @@ -416,20 +427,67 @@ func (check *Checker) instantiatedType(x syntax.Expr, targsx []syntax.Expr, def // determine argument positions posList := make([]syntax.Pos, len(targs)) for i, arg := range targsx { - posList[i] = syntax.StartPos(arg) + posList[i] = arg.Pos() } - typ := check.instantiate(x.Pos(), base, targs, posList) - def.setUnderlying(typ) - check.recordInstance(x, targs, typ) + // create the instance + h := check.conf.Context.TypeHash(origin, targs) + // targs may be incomplete, and require inference. In any case we should de-duplicate. + inst := check.conf.Context.typeForHash(h, nil) + // If inst is non-nil, we can't just return here. Inst may have been + // constructed via recursive substitution, in which case we wouldn't do the + // validation below. Ensure that the validation (and resulting errors) runs + // for each instantiated type in the source. + if inst == nil { + tname := NewTypeName(x.Pos(), origin.obj.pkg, origin.obj.name, nil) + inst = check.newNamed(tname, origin, nil, nil, nil) // underlying, methods and tparams are set when named is resolved + inst.targs = NewTypeList(targs) + inst = check.conf.Context.typeForHash(h, inst) + } + def.setUnderlying(inst) - // make sure we check instantiation works at least once - // and that the resulting type is valid + inst.resolver = func(ctxt *Context, n *Named) (*TypeParamList, Type, []*Func) { + tparams := origin.TypeParams().list() + + inferred := targs + if len(targs) < len(tparams) { + // If inference fails, len(inferred) will be 0, and inst.underlying will + // be set to Typ[Invalid] in expandNamed. + inferred = check.infer(x.Pos(), tparams, targs, nil, nil) + if len(inferred) > len(targs) { + inst.targs = NewTypeList(inferred) + } + } + + check.recordInstance(x, inferred, inst) + return expandNamed(ctxt, n, x.Pos()) + } + + // origin.tparams may not be set up, so we need to do expansion later. check.later(func() { - check.validType(typ, nil) + // This is an instance from the source, not from recursive substitution, + // and so it must be resolved during type-checking so that we can report + // errors. + inst.resolve(check.conf.Context) + // Since check is non-nil, we can still mutate inst. Unpinning the resolver + // frees some memory. + inst.resolver = nil + + if check.validateTArgLen(x.Pos(), inst.tparams.Len(), inst.targs.Len()) { + if i, err := check.verify(x.Pos(), inst.tparams.list(), inst.targs.list()); err != nil { + // best position for error reporting + pos := x.Pos() + if i < len(posList) { + pos = posList[i] + } + check.softErrorf(pos, err.Error()) + } + } + + check.validType(inst, nil) }) - return typ + return inst } // arrayLength type-checks the array length expression e From a73c6cf762560b458eb938e4461cd8debc479fd9 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 18 Oct 2021 17:31:23 -0700 Subject: [PATCH 072/406] cmd/compile/internal/types2: ensure named types are expanded after type-checking This is a clean port of CL 356490 from go/types to types2. Fixes #48703. Fixes #48974. Change-Id: I08c0db0b92250cbb043325541b21a577726b40ca Reviewed-on: https://go-review.googlesource.com/c/go/+/356515 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/check.go | 28 +++++++++++++++++++ src/cmd/compile/internal/types2/named.go | 23 ++++++--------- .../types2/testdata/fixedbugs/issue48703.go2 | 27 ++++++++++++++++++ .../types2/testdata/fixedbugs/issue48974.go2 | 22 +++++++++++++++ 4 files changed, 85 insertions(+), 15 deletions(-) create mode 100644 src/cmd/compile/internal/types2/testdata/fixedbugs/issue48703.go2 create mode 100644 src/cmd/compile/internal/types2/testdata/fixedbugs/issue48974.go2 diff --git a/src/cmd/compile/internal/types2/check.go b/src/cmd/compile/internal/types2/check.go index 470376f8e8..6e8883e5de 100644 --- a/src/cmd/compile/internal/types2/check.go +++ b/src/cmd/compile/internal/types2/check.go @@ -132,6 +132,7 @@ type Checker struct { untyped map[syntax.Expr]exprInfo // map of expressions without final type delayed []action // stack of delayed action segments; segments are processed in FIFO order objPath []Object // path of object dependencies during type inference (for cycle reporting) + defTypes []*Named // defined types created during type checking, for final validation. // context within which the current object is type-checked // (valid only for the duration of type-checking a specific object) @@ -302,6 +303,9 @@ func (check *Checker) checkFiles(files []*syntax.File) (err error) { print("== processDelayed ==") check.processDelayed(0) // incl. all functions + print("== expandDefTypes ==") + check.expandDefTypes() + print("== initOrder ==") check.initOrder() @@ -321,6 +325,7 @@ func (check *Checker) checkFiles(files []*syntax.File) (err error) { check.pkgPathMap = nil check.seenPkgMap = nil check.recvTParamMap = nil + check.defTypes = nil // TODO(gri) There's more memory we should release at this point. @@ -347,6 +352,29 @@ func (check *Checker) processDelayed(top int) { check.delayed = check.delayed[:top] } +func (check *Checker) expandDefTypes() { + // Ensure that every defined type created in the course of type-checking has + // either non-*Named underlying, or is unresolved. + // + // This guarantees that we don't leak any types whose underlying is *Named, + // because any unresolved instances will lazily compute their underlying by + // substituting in the underlying of their origin. The origin must have + // either been imported or type-checked and expanded here, and in either case + // its underlying will be fully expanded. + for i := 0; i < len(check.defTypes); i++ { + n := check.defTypes[i] + switch n.underlying.(type) { + case nil: + if n.resolver == nil { + panic("nil underlying") + } + case *Named: + n.under() // n.under may add entries to check.defTypes + } + n.check = nil + } +} + func (check *Checker) record(x *operand) { // convert x into a user-friendly set of values // TODO(gri) this code can be simplified diff --git a/src/cmd/compile/internal/types2/named.go b/src/cmd/compile/internal/types2/named.go index 8f2a52b4f2..eb8b5d1ba8 100644 --- a/src/cmd/compile/internal/types2/named.go +++ b/src/cmd/compile/internal/types2/named.go @@ -65,22 +65,9 @@ func (check *Checker) newNamed(obj *TypeName, orig *Named, underlying Type, tpar if obj.typ == nil { obj.typ = typ } - // Ensure that typ is always expanded, at which point the check field can be - // nilled out. - // - // Note that currently we cannot nil out check inside typ.under(), because - // it's possible that typ is expanded multiple times. - // - // TODO(gri): clean this up so that under is the only function mutating - // named types. + // Ensure that typ is always expanded and sanity-checked. if check != nil { - check.later(func() { - switch typ.under().(type) { - case *Named: - panic("unexpanded underlying type") - } - typ.check = nil - }) + check.defTypes = append(check.defTypes, typ) } return typ } @@ -239,6 +226,12 @@ func expandNamed(ctxt *Context, n *Named, instPos syntax.Pos) (tparams *TypePara check := n.check + if _, unexpanded := n.orig.underlying.(*Named); unexpanded { + // We should only get an unexpanded underlying here during type checking + // (for example, in recursive type declarations). + assert(check != nil) + } + // Mismatching arg and tparam length may be checked elsewhere. if n.orig.tparams.Len() == n.targs.Len() { // We must always have a context, to avoid infinite recursion. diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48703.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48703.go2 new file mode 100644 index 0000000000..8a32c1ecf2 --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48703.go2 @@ -0,0 +1,27 @@ +// Copyright 2021 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 p + +import "unsafe" + +// The actual example from the issue. +type List[P any] struct{} + +func (_ List[P]) m() (_ List[List[P]]) { return } + +// Other types of recursion through methods. +type R[P any] int + +func (*R[R /* ERROR must be an identifier */ [int]]) m0() {} +func (R[P]) m1(R[R[P]]) {} +func (R[P]) m2(R[*P]) {} +func (R[P]) m3([unsafe.Sizeof(new(R[P]))]int) {} +func (R[P]) m4([unsafe.Sizeof(new(R[R[P]]))]int) {} + +// Mutual recursion +type M[P any] int + +func (R[P]) m5(M[M[P]]) {} +func (M[P]) m(R[R[P]]) {} diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48974.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48974.go2 new file mode 100644 index 0000000000..ca4b6d9321 --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48974.go2 @@ -0,0 +1,22 @@ +// Copyright 2021 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 p + +type Fooer interface { + Foo() +} + +type Fooable[F Fooer] struct { + ptr F +} + +func (f *Fooable[F]) Adapter() *Fooable[*FooerImpl[F]] { + return &Fooable[*FooerImpl[F]]{&FooerImpl[F]{}} +} + +type FooerImpl[F Fooer] struct { +} + +func (fi *FooerImpl[F]) Foo() {} From 99fad12e4788fdf67e49dadd16571238f935b408 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 18 Oct 2021 17:42:21 -0700 Subject: [PATCH 073/406] cmd/compile/internal/types2: delay expansion of underlying in typeDecl This is a clean port of CL 356533 from go/types to types2. Fixes #49043. Change-Id: If389b94ece28042b0c8b436959dd21f26147a144 Reviewed-on: https://go-review.googlesource.com/c/go/+/356517 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/decl.go | 24 ++++++------------- src/cmd/compile/internal/types2/named.go | 17 ++++++++++++- .../types2/testdata/check/typeinst.go2 | 2 +- .../types2/testdata/fixedbugs/issue49043.go2 | 24 +++++++++++++++++++ 4 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 src/cmd/compile/internal/types2/testdata/fixedbugs/issue49043.go2 diff --git a/src/cmd/compile/internal/types2/decl.go b/src/cmd/compile/internal/types2/decl.go index a605057579..63be4b3223 100644 --- a/src/cmd/compile/internal/types2/decl.go +++ b/src/cmd/compile/internal/types2/decl.go @@ -597,22 +597,12 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *Named rhs = check.definedType(tdecl.Type, named) assert(rhs != nil) named.fromRHS = rhs - // The underlying type of named may be itself a named type that is - // incomplete: - // - // type ( - // A B - // B *C - // C A - // ) - // - // The type of C is the (named) type of A which is incomplete, - // and which has as its underlying type the named type B. - // Determine the (final, unnamed) underlying type by resolving - // any forward chain. - // TODO(gri) Investigate if we can just use named.fromRHS here - // and rely on lazy computation of the underlying type. - named.underlying = under(named) + + // If the underlying was not set while type-checking the right-hand side, it + // is invalid and an error should have been reported elsewhere. + if named.underlying == nil { + named.underlying = Typ[Invalid] + } // If the RHS is a type parameter, it must be from this type declaration. if tpar, _ := named.underlying.(*TypeParam); tpar != nil && tparamIndex(named.TypeParams().list(), tpar) < 0 { @@ -711,7 +701,7 @@ func (check *Checker) collectMethods(obj *TypeName) { // and field names must be distinct." base := asNamed(obj.typ) // shouldn't fail but be conservative if base != nil { - u := safeUnderlying(base) // base should be expanded, but use safeUnderlying to be conservative + u := base.under() if t, _ := u.(*Struct); t != nil { for _, fld := range t.fields { if fld.name != "_" { diff --git a/src/cmd/compile/internal/types2/named.go b/src/cmd/compile/internal/types2/named.go index eb8b5d1ba8..6ebad8fbb5 100644 --- a/src/cmd/compile/internal/types2/named.go +++ b/src/cmd/compile/internal/types2/named.go @@ -130,6 +130,18 @@ func (t *Named) String() string { return TypeString(t, nil) } // chain before returning it. If no underlying type is found or a cycle // is detected, the result is Typ[Invalid]. If a cycle is detected and // n0.check != nil, the cycle is reported. +// +// This is necessary because the underlying type of named may be itself a +// named type that is incomplete: +// +// type ( +// A B +// B *C +// C A +// ) +// +// The type of C is the (named) type of A which is incomplete, +// and which has as its underlying type the named type B. func (n0 *Named) under() Type { u := n0.Underlying() @@ -139,7 +151,9 @@ func (n0 *Named) under() Type { var n1 *Named switch u1 := u.(type) { case nil: - return Typ[Invalid] + // After expansion via Underlying(), we should never encounter a nil + // underlying. + panic("nil underlying") default: // common case return u @@ -223,6 +237,7 @@ func (check *Checker) bestContext(ctxt *Context) *Context { // The underlying type will be Typ[Invalid] if there was an error. func expandNamed(ctxt *Context, n *Named, instPos syntax.Pos) (tparams *TypeParamList, underlying Type, methods []*Func) { n.orig.resolve(ctxt) + assert(n.orig.underlying != nil) check := n.check diff --git a/src/cmd/compile/internal/types2/testdata/check/typeinst.go2 b/src/cmd/compile/internal/types2/testdata/check/typeinst.go2 index 3fab2cb9ad..14f1b07ee2 100644 --- a/src/cmd/compile/internal/types2/testdata/check/typeinst.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/typeinst.go2 @@ -57,5 +57,5 @@ var _ T3[int] = T3[int](List[int]{1, 2, 3}) // Self-recursive generic types are not permitted -type self1[P any] self1 /* ERROR illegal cycle */ [P] +type self1 /* ERROR illegal cycle */ [P any] self1[P] type self2[P any] *self2[P] // this is ok diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49043.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49043.go2 new file mode 100644 index 0000000000..c37b0f1267 --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49043.go2 @@ -0,0 +1,24 @@ +// Copyright 2021 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 p + +// The example from the issue. +type ( + N /* ERROR illegal cycle */ [P any] M[P] + M[P any] N[P] +) + +// A slightly more complicated case. +type ( + A /* ERROR illegal cycle */ [P any] B[P] + B[P any] C[P] + C[P any] A[P] +) + +// Confusing but valid (note that `type T *T` is valid). +type ( + N1[P any] *M1[P] + M1[P any] *N1[P] +) From 404f84d417ceed0f47e51d2c4f933a6dee96dca5 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 15 Oct 2021 23:24:28 +0000 Subject: [PATCH 074/406] runtime: remove reference to crypto/tls GODEBUG usage crypto/tls briefly used GODEBUG. That usage was removed in CL 191999. Change-Id: I759b6f1b02db8160075cba30d73823018e19ad9d GitHub-Last-Rev: 12d2a4a82b1467e4c2214aa78eb9a0af4938a9de GitHub-Pull-Request: golang/go#49012 Reviewed-on: https://go-review.googlesource.com/c/go/+/356313 Reviewed-by: Austin Clements Trust: Michael Pratt --- src/runtime/extern.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/extern.go b/src/runtime/extern.go index eca4062e68..b2003ba543 100644 --- a/src/runtime/extern.go +++ b/src/runtime/extern.go @@ -144,7 +144,7 @@ It is a comma-separated list of name=val pairs setting these named variables: because it also disables the conservative stack scanning used for asynchronously preempted goroutines. -The net, net/http, and crypto/tls packages also refer to debugging variables in GODEBUG. +The net and net/http packages also refer to debugging variables in GODEBUG. See the documentation for those packages for details. The GOMAXPROCS variable limits the number of operating system threads that From 982060203c26b60fd74e4fa2fd967600c65ee7fc Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Fri, 15 Oct 2021 11:16:54 -0400 Subject: [PATCH 075/406] testing: don't allow f.Log/Logf or f.Skipped inside f.Fuzz This change also does some refactors around how we prevent many (*F) methods from being called inside (*F).Fuzz. Previously, there was a lot of comment/code duplication, which was going to be difficult to maintain and brittle. The refactor lessens this duplication. Previously, the methods Log, Logf, Failed, Name and Skipped were the only (*common) methods that were allowed to be called inside (*F).Fuzz. After this change, Failed and Name are still allowed, but Log, Logf, and Skipped are not (t.Log, t.Logf, or t.Skipped should be used instead). Fixes #48988 Change-Id: I4066247d551ea1908e8a2ca2889509fc68e3bb44 Reviewed-on: https://go-review.googlesource.com/c/go/+/356151 Trust: Katie Hockman Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills Reviewed-by: Jay Conrod --- src/cmd/go/testdata/script/test_fuzz.txt | 39 ++++++ src/testing/fuzz.go | 147 ++++------------------- src/testing/testing.go | 28 ++++- 3 files changed, 87 insertions(+), 127 deletions(-) diff --git a/src/cmd/go/testdata/script/test_fuzz.txt b/src/cmd/go/testdata/script/test_fuzz.txt index c9930aa37e..4665202bf0 100644 --- a/src/cmd/go/testdata/script/test_fuzz.txt +++ b/src/cmd/go/testdata/script/test_fuzz.txt @@ -70,6 +70,12 @@ stdout 'f.Fuzz function' stdout FAIL stdout 'f.Fuzz function' +# Test that f.Fail within f.Fuzz panics +! go test fail_fuzz_fn_fuzz_test.go +! stdout ^ok +stdout FAIL +stdout 'f.Fuzz function' + # Test that f.Skip within f.Fuzz panics ! go test skip_fuzz_fn_fuzz_test.go ! stdout ^ok @@ -77,6 +83,14 @@ stdout 'f.Fuzz function' stdout FAIL stdout 'f.Fuzz function' +# Test that f.Skipped within f.Fuzz panics +! go test skipped_fuzz_fn_fuzz_test.go +! stdout ^ok +! stdout 'f.Skipped is' +stdout FAIL +stdout 'f.Fuzz function' +stdout 't.Skipped is false' + # Test that runtime.Goexit within the fuzz function is an error. ! go test goexit_fuzz_fn_fuzz_test.go ! stdout ^ok @@ -260,6 +274,18 @@ func Fuzz(f *testing.F) { }) } +-- fail_fuzz_fn_fuzz_test.go -- +package skip_fuzz_fn_fuzz + +import "testing" + +func Fuzz(f *testing.F) { + f.Add([]byte("aa")) + f.Fuzz(func(t *testing.T, b []byte) { + f.Fail() + }) +} + -- skip_fuzz_fn_fuzz_test.go -- package skip_fuzz_fn_fuzz @@ -272,6 +298,19 @@ func Fuzz(f *testing.F) { }) } +-- skipped_fuzz_fn_fuzz_test.go -- +package skipped_fuzz_fn_fuzz + +import "testing" + +func Fuzz(f *testing.F) { + f.Add([]byte("aa")) + f.Fuzz(func(t *testing.T, b []byte) { + t.Logf("t.Skipped is %t\n", t.Skipped()) + t.Logf("f.Skipped is %t\n", f.Skipped()) + }) +} + -- goexit_fuzz_fn_fuzz_test.go -- package goexit_fuzz_fn_fuzz diff --git a/src/testing/fuzz.go b/src/testing/fuzz.go index d5cb5e853f..10665168f4 100644 --- a/src/testing/fuzz.go +++ b/src/testing/fuzz.go @@ -57,6 +57,10 @@ type InternalFuzzTarget struct { // call F.Fuzz once to provide a fuzz function. See the testing package // documentation for an example, and see the F.Fuzz and F.Add method // documentation for details. +// +// *F methods can only be called before (*F).Fuzz. Once inside the function +// passed to (*F).Fuzz, only (*T) methods can be used. The only *F methods that +// are allowed in the (*F).Fuzz function are (*F).Failed and (*F).Name. type F struct { common fuzzContext *fuzzContext @@ -88,78 +92,6 @@ type corpusEntry = struct { IsSeed bool } -// Cleanup registers a function to be called after the fuzz function has been -// called on all seed corpus entries, and after fuzzing completes (if enabled). -// Cleanup functions will be called in last added, first called order. -func (f *F) Cleanup(fn func()) { - if f.inFuzzFn { - panic("testing: f.Cleanup was called inside the f.Fuzz function, use t.Cleanup instead") - } - f.common.Helper() - f.common.Cleanup(fn) -} - -// Error is equivalent to Log followed by Fail. -func (f *F) Error(args ...interface{}) { - if f.inFuzzFn { - panic("testing: f.Error was called inside the f.Fuzz function, use t.Error instead") - } - f.common.Helper() - f.common.Error(args...) -} - -// Errorf is equivalent to Logf followed by Fail. -func (f *F) Errorf(format string, args ...interface{}) { - if f.inFuzzFn { - panic("testing: f.Errorf was called inside the f.Fuzz function, use t.Errorf instead") - } - f.common.Helper() - f.common.Errorf(format, args...) -} - -// Fail marks the function as having failed but continues execution. -func (f *F) Fail() { - if f.inFuzzFn { - panic("testing: f.Fail was called inside the f.Fuzz function, use t.Fail instead") - } - f.common.Helper() - f.common.Fail() -} - -// FailNow marks the function as having failed and stops its execution -// by calling runtime.Goexit (which then runs all deferred calls in the -// current goroutine). -// Execution will continue at the next test, benchmark, or fuzz function. -// FailNow must be called from the goroutine running the -// fuzz target, not from other goroutines -// created during the test. Calling FailNow does not stop -// those other goroutines. -func (f *F) FailNow() { - if f.inFuzzFn { - panic("testing: f.FailNow was called inside the f.Fuzz function, use t.FailNow instead") - } - f.common.Helper() - f.common.FailNow() -} - -// Fatal is equivalent to Log followed by FailNow. -func (f *F) Fatal(args ...interface{}) { - if f.inFuzzFn { - panic("testing: f.Fatal was called inside the f.Fuzz function, use t.Fatal instead") - } - f.common.Helper() - f.common.Fatal(args...) -} - -// Fatalf is equivalent to Logf followed by FailNow. -func (f *F) Fatalf(format string, args ...interface{}) { - if f.inFuzzFn { - panic("testing: f.Fatalf was called inside the f.Fuzz function, use t.Fatalf instead") - } - f.common.Helper() - f.common.Fatalf(format, args...) -} - // Helper marks the calling function as a test helper function. // When printing file and line information, that function will be skipped. // Helper may be called simultaneously from multiple goroutines. @@ -188,65 +120,26 @@ func (f *F) Helper() { } } -// Setenv calls os.Setenv(key, value) and uses Cleanup to restore the -// environment variable to its original value after the test. -// -// When fuzzing is enabled, the fuzzing engine spawns worker processes running -// the test binary. Each worker process inherits the environment of the parent -// process, including environment variables set with F.Setenv. -func (f *F) Setenv(key, value string) { +// Fail marks the function as having failed but continues execution. +func (f *F) Fail() { + // (*F).Fail may be called by (*T).Fail, which we should allow. However, we + // shouldn't allow direct (*F).Fail calls from inside the (*F).Fuzz function. if f.inFuzzFn { - panic("testing: f.Setenv was called inside the f.Fuzz function, use t.Setenv instead") + panic("testing: f.Fail was called inside the f.Fuzz function, use t.Fail instead") } f.common.Helper() - f.common.Setenv(key, value) + f.common.Fail() } -// Skip is equivalent to Log followed by SkipNow. -func (f *F) Skip(args ...interface{}) { +// Skipped reports whether the test was skipped. +func (f *F) Skipped() bool { + // (*F).Skipped may be called by tRunner, which we should allow. However, we + // shouldn't allow direct (*F).Skipped calls from inside the (*F).Fuzz function. if f.inFuzzFn { - panic("testing: f.Skip was called inside the f.Fuzz function, use t.Skip instead") + panic("testing: f.Skipped was called inside the f.Fuzz function, use t.Skipped instead") } f.common.Helper() - f.common.Skip(args...) -} - -// SkipNow marks the test as having been skipped and stops its execution -// by calling runtime.Goexit. -// If a test fails (see Error, Errorf, Fail) and is then skipped, -// it is still considered to have failed. -// Execution will continue at the next test or benchmark. See also FailNow. -// SkipNow must be called from the goroutine running the test, not from -// other goroutines created during the test. Calling SkipNow does not stop -// those other goroutines. -func (f *F) SkipNow() { - if f.inFuzzFn { - panic("testing: f.SkipNow was called inside the f.Fuzz function, use t.SkipNow instead") - } - f.common.Helper() - f.common.SkipNow() -} - -// Skipf is equivalent to Logf followed by SkipNow. -func (f *F) Skipf(format string, args ...interface{}) { - if f.inFuzzFn { - panic("testing: f.Skipf was called inside the f.Fuzz function, use t.Skipf instead") - } - f.common.Helper() - f.common.Skipf(format, args...) -} - -// TempDir returns a temporary directory for the test to use. -// The directory is automatically removed by Cleanup when the test and -// all its subtests complete. -// Each subsequent call to t.TempDir returns a unique directory; -// if the directory creation fails, TempDir terminates the test by calling Fatal. -func (f *F) TempDir() string { - if f.inFuzzFn { - panic("testing: f.TempDir was called inside the f.Fuzz function, use t.TempDir instead") - } - f.common.Helper() - return f.common.TempDir() + return f.common.Skipped() } // Add will add the arguments to the seed corpus for the fuzz target. This will @@ -297,6 +190,10 @@ var supportedTypes = map[reflect.Type]bool{ // float64, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64. // More types may be supported in the future. // +// ff must not call any *F methods, e.g. (*F).Log, (*F).Error, (*F).Skip. Use +// the corresponding *T method instead. The only *F methods that are allowed in +// the (*F).Fuzz function are (*F).Failed and (*F).Name. +// // This function sould be fast and deterministic, and its behavior should not // depend on shared state. No mutatable input arguments, or pointers to them, // should be retained between executions of the fuzz function, as the memory @@ -415,7 +312,7 @@ func (f *F) Fuzz(ff interface{}) { // TODO(#48132): adjust this to work with test2json. t.chatty.Updatef(t.name, "=== RUN %s\n", t.name) } - f.inFuzzFn = true + f.common.inFuzzFn, f.inFuzzFn = true, true go tRunner(t, func(t *T) { args := []reflect.Value{reflect.ValueOf(t)} for _, v := range e.Values { @@ -430,7 +327,7 @@ func (f *F) Fuzz(ff interface{}) { fn.Call(args) }) <-t.signal - f.inFuzzFn = false + f.common.inFuzzFn, f.inFuzzFn = false, false return !t.Failed() } diff --git a/src/testing/testing.go b/src/testing/testing.go index 57ac580051..d03c0b1cf9 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -492,6 +492,7 @@ type common struct { cleanupName string // Name of the cleanup function. cleanupPc []uintptr // The stack trace at the point where Cleanup was called. finished bool // Test function has completed. + inFuzzFn bool // Whether the fuzz function, if this is one, is running. chatty *chattyPrinter // A copy of chattyPrinter, if the chatty flag is set. bench bool // Whether the current test is a benchmark. @@ -547,6 +548,12 @@ func Verbose() bool { return *chatty } +func (c *common) checkFuzzFn(name string) { + if c.inFuzzFn { + panic(fmt.Sprintf("testing: f.%s was called inside the f.Fuzz function, use t.%s instead", name, name)) + } +} + // frameSkip searches, starting after skip frames, for the first caller frame // in a function not marked as a helper and returns that frame. // The search stops if it finds a tRunner function that @@ -821,6 +828,7 @@ func (c *common) Failed() bool { // created during the test. Calling FailNow does not stop // those other goroutines. func (c *common) FailNow() { + c.checkFuzzFn("FailNow") c.Fail() // Calling runtime.Goexit will exit the goroutine, which @@ -889,47 +897,59 @@ func (c *common) logDepth(s string, depth int) { // and records the text in the error log. For tests, the text will be printed only if // the test fails or the -test.v flag is set. For benchmarks, the text is always // printed to avoid having performance depend on the value of the -test.v flag. -func (c *common) Log(args ...interface{}) { c.log(fmt.Sprintln(args...)) } +func (c *common) Log(args ...interface{}) { + c.checkFuzzFn("Log") + c.log(fmt.Sprintln(args...)) +} // Logf formats its arguments according to the format, analogous to Printf, and // records the text in the error log. A final newline is added if not provided. For // tests, the text will be printed only if the test fails or the -test.v flag is // set. For benchmarks, the text is always printed to avoid having performance // depend on the value of the -test.v flag. -func (c *common) Logf(format string, args ...interface{}) { c.log(fmt.Sprintf(format, args...)) } +func (c *common) Logf(format string, args ...interface{}) { + c.checkFuzzFn("Logf") + c.log(fmt.Sprintf(format, args...)) +} // Error is equivalent to Log followed by Fail. func (c *common) Error(args ...interface{}) { + c.checkFuzzFn("Error") c.log(fmt.Sprintln(args...)) c.Fail() } // Errorf is equivalent to Logf followed by Fail. func (c *common) Errorf(format string, args ...interface{}) { + c.checkFuzzFn("Errorf") c.log(fmt.Sprintf(format, args...)) c.Fail() } // Fatal is equivalent to Log followed by FailNow. func (c *common) Fatal(args ...interface{}) { + c.checkFuzzFn("Fatal") c.log(fmt.Sprintln(args...)) c.FailNow() } // Fatalf is equivalent to Logf followed by FailNow. func (c *common) Fatalf(format string, args ...interface{}) { + c.checkFuzzFn("Fatalf") c.log(fmt.Sprintf(format, args...)) c.FailNow() } // Skip is equivalent to Log followed by SkipNow. func (c *common) Skip(args ...interface{}) { + c.checkFuzzFn("Skip") c.log(fmt.Sprintln(args...)) c.SkipNow() } // Skipf is equivalent to Logf followed by SkipNow. func (c *common) Skipf(format string, args ...interface{}) { + c.checkFuzzFn("Skipf") c.log(fmt.Sprintf(format, args...)) c.SkipNow() } @@ -943,6 +963,7 @@ func (c *common) Skipf(format string, args ...interface{}) { // other goroutines created during the test. Calling SkipNow does not stop // those other goroutines. func (c *common) SkipNow() { + c.checkFuzzFn("SkipNow") c.mu.Lock() c.skipped = true c.finished = true @@ -982,6 +1003,7 @@ func (c *common) Helper() { // subtests complete. Cleanup functions will be called in last added, // first called order. func (c *common) Cleanup(f func()) { + c.checkFuzzFn("Cleanup") var pc [maxStackLen]uintptr // Skip two extra frames to account for this function and runtime.Callers itself. n := runtime.Callers(2, pc[:]) @@ -1015,6 +1037,7 @@ func (c *common) Cleanup(f func()) { // Each subsequent call to t.TempDir returns a unique directory; // if the directory creation fails, TempDir terminates the test by calling Fatal. func (c *common) TempDir() string { + c.checkFuzzFn("TempDir") // Use a single parent directory for all the temporary directories // created by a test, each numbered sequentially. c.tempDirMu.Lock() @@ -1080,6 +1103,7 @@ func (c *common) TempDir() string { // // This cannot be used in parallel tests. func (c *common) Setenv(key, value string) { + c.checkFuzzFn("Setenv") prevValue, ok := os.LookupEnv(key) if err := os.Setenv(key, value); err != nil { From ad7db1f90fb66f00f5b020360aabd9f27d1c764f Mon Sep 17 00:00:00 2001 From: Carlo Alberto Ferraris Date: Thu, 14 Oct 2021 16:50:41 +0900 Subject: [PATCH 076/406] sync: avoid a dynamic check in WaitGroup on 64-bit architectures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit uint64 is guaranteed by the compiler to be aligned on 64-bit archs. By using uint64+uint32 instead of [3]uint32 we can make use of the guaranteed alignment to avoid the run-time alignment check. On linux/amd64: name old time/op new time/op delta WaitGroupUncontended-4 8.84ns ± 3% 7.62ns ± 4% -13.72% (p=0.000 n=17+18) WaitGroupAddDone-4 66.8ns ± 3% 45.9ns ± 2% -31.31% (p=0.000 n=20+18) WaitGroupAddDoneWork-4 79.2ns ± 1% 56.6ns ± 1% -28.54% (p=0.000 n=17+20) WaitGroupWait-4 2.83ns ± 2% 2.58ns ± 2% -9.05% (p=0.000 n=18+20) WaitGroupWaitWork-4 16.8ns ± 6% 16.5ns ± 6% ~ (p=0.072 n=20+18) WaitGroupActuallyWait-4 263ns ± 2% 261ns ± 5% ~ (p=0.063 n=18+20) Change-Id: I314340f2ed8a47d8b9c15f8a3b07e41f252f4831 Reviewed-on: https://go-review.googlesource.com/c/go/+/189837 Reviewed-by: Cherry Mui Reviewed-by: Ian Lance Taylor Run-TryBot: Cherry Mui TryBot-Result: Go Bot --- src/sync/waitgroup.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/sync/waitgroup.go b/src/sync/waitgroup.go index e81a493dea..9c6662d04b 100644 --- a/src/sync/waitgroup.go +++ b/src/sync/waitgroup.go @@ -22,18 +22,24 @@ type WaitGroup struct { // 64-bit value: high 32 bits are counter, low 32 bits are waiter count. // 64-bit atomic operations require 64-bit alignment, but 32-bit - // compilers do not ensure it. So we allocate 12 bytes and then use - // the aligned 8 bytes in them as state, and the other 4 as storage - // for the sema. - state1 [3]uint32 + // compilers only guarantee that 64-bit fields are 32-bit aligned. + // For this reason on 32 bit architectures we need to check in state() + // if state1 is aligned or not, and dynamically "swap" the field order if + // needed. + state1 uint64 + state2 uint32 } -// state returns pointers to the state and sema fields stored within wg.state1. +// state returns pointers to the state and sema fields stored within wg.state*. func (wg *WaitGroup) state() (statep *uint64, semap *uint32) { - if uintptr(unsafe.Pointer(&wg.state1))%8 == 0 { - return (*uint64)(unsafe.Pointer(&wg.state1)), &wg.state1[2] + if unsafe.Alignof(wg.state1) == 8 || uintptr(unsafe.Pointer(&wg.state1))%8 == 0 { + // state1 is 64-bit aligned: nothing to do. + return &wg.state1, &wg.state2 } else { - return (*uint64)(unsafe.Pointer(&wg.state1[1])), &wg.state1[0] + // state1 is 32-bit aligned but not 64-bit aligned: this means that + // (&state1)+4 is 64-bit aligned. + state := (*[3]uint32)(unsafe.Pointer(&wg.state1)) + return (*uint64)(unsafe.Pointer(&state[1])), &state[0] } } From 6c3cd5d2eb7149c9c1ced7d70c3f4157f27c1588 Mon Sep 17 00:00:00 2001 From: Archana R Date: Wed, 13 Oct 2021 03:50:06 -0500 Subject: [PATCH 077/406] internal/bytealg: port bytes.Index and bytes.Count to reg ABI on ppc64x MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds support for the reg ABI to the Index and Count functions for ppc64/ppc64le. Most Index and Count benchmarks show improvement in performance on POWER9 with this change. Similar numbers observed on POWER8 and POWER10. name old time/op new time/op delta Index/32 71.0ns ± 0% 67.9ns ± 0% -4.42% (p=0.001 n=7+6) IndexEasy/10 17.5ns ± 0% 17.2ns ± 0% -1.30% (p=0.001 n=7+7) name old time/op new time/op delta Count/10 26.6ns ± 0% 25.0ns ± 1% -6.02% (p=0.001 n=7+7) Count/32 78.6ns ± 0% 74.7ns ± 0% -4.97% (p=0.001 n=7+7) Count/4K 5.03µs ± 0% 5.03µs ± 0% -0.07% (p=0.000 n=6+7) CountEasy/10 26.9ns ± 0% 25.2ns ± 1% -6.31% (p=0.001 n=7+7) CountSingle/32 11.8ns ± 0% 9.9ns ± 0% -15.70% (p=0.002 n=6+6) Change-Id: Ibd146c04f8107291c55f9e6100b8264dfccc41ae Reviewed-on: https://go-review.googlesource.com/c/go/+/355509 Reviewed-by: Cherry Mui Reviewed-by: Lynn Boger Run-TryBot: Cherry Mui TryBot-Result: Go Bot --- src/internal/bytealg/count_ppc64x.s | 24 +++++++++++++++--- src/internal/bytealg/index_ppc64x.s | 39 +++++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/src/internal/bytealg/count_ppc64x.s b/src/internal/bytealg/count_ppc64x.s index 94163cbd8a..dbafd06edc 100644 --- a/src/internal/bytealg/count_ppc64x.s +++ b/src/internal/bytealg/count_ppc64x.s @@ -8,24 +8,37 @@ #include "go_asm.h" #include "textflag.h" -TEXT ·Count(SB), NOSPLIT|NOFRAME, $0-40 +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 BR countbytebody<>(SB) -TEXT ·CountString(SB), NOSPLIT|NOFRAME, $0-32 +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 BR countbytebody<>(SB) // R3: addr of string // R4: len of string // R5: byte to count -// R14: addr for return value +// R14: addr for return value when not regabi // endianness shouldn't matter since we are just counting and order // is irrelevant TEXT countbytebody<>(SB), NOSPLIT|NOFRAME, $0-0 @@ -94,5 +107,10 @@ next2: BR small done: +#ifdef GOEXPERIMENT_regabiargs + MOVD R18, R3 // return count +#else MOVD R18, (R14) // return count +#endif + RET diff --git a/src/internal/bytealg/index_ppc64x.s b/src/internal/bytealg/index_ppc64x.s index 3ed9442125..f587a8ae25 100644 --- a/src/internal/bytealg/index_ppc64x.s +++ b/src/internal/bytealg/index_ppc64x.s @@ -46,12 +46,20 @@ DATA byteswap<>+8(SB)/8, $0x0f0e0d0c0b0a0908 GLOBL byteswap<>+0(SB), RODATA, $16 -TEXT ·Index(SB), NOSPLIT|NOFRAME, $0-56 +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 + #ifdef GOARCH_ppc64le MOVBZ internal∕cpu·PPC64+const_offsetPPC64HasPOWER9(SB), R7 @@ -63,12 +71,15 @@ TEXT ·Index(SB), NOSPLIT|NOFRAME, $0-56 power8: BR indexbody<>(SB) -TEXT ·IndexString(SB), NOSPLIT|NOFRAME, $0-40 +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 + #ifdef GOARCH_ppc64le MOVBZ internal∕cpu·PPC64+const_offsetPPC64HasPOWER9(SB), R7 @@ -420,8 +431,12 @@ 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 RET index33plus: @@ -432,12 +447,20 @@ 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 RET found: SUB R3, R7 // Return byte where found +#ifdef GOEXPERIMENT_regabiargs + MOVD R7, R3 +#else MOVD R7, (R14) +#endif RET TEXT indexbodyp9<>(SB), NOSPLIT|NOFRAME, $0 @@ -746,8 +769,12 @@ 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 RET index33plus: @@ -758,11 +785,19 @@ 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 RET found: SUB R3, R7 // Return byte where found +#ifdef GOEXPERIMENT_regabiargs + MOVD R7, R3 +#else MOVD R7, (R14) +#endif RET From 7999fd4710e7f987e86d7b32dd9af31ced4810ba Mon Sep 17 00:00:00 2001 From: "Matt T. Proud" Date: Tue, 19 Oct 2021 10:09:06 +0200 Subject: [PATCH 078/406] errors: mention Is methods should not call Unwrap errors.Is internally unwraps the error until the error matches the target. Because of this, a user-authored Is method on an error type need not call errors.Unwrap on itself or the target, because that would make the unwrapping operation O(N^2). It is a subtle detail to remind authors for resource efficiency reasons. Change-Id: Ic1ba59a5bdbfe2c7cb51a2cba2537ab6de4a13ff Reviewed-on: https://go-review.googlesource.com/c/go/+/356789 Reviewed-by: Jean de Klerk Reviewed-by: Damien Neil Trust: Jean de Klerk Trust: Damien Neil Run-TryBot: Jean de Klerk TryBot-Result: Go Bot --- src/errors/wrap.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/errors/wrap.go b/src/errors/wrap.go index 4eb4f9ae37..b73d5a8ce2 100644 --- a/src/errors/wrap.go +++ b/src/errors/wrap.go @@ -35,7 +35,8 @@ func Unwrap(err error) error { // func (m MyError) Is(target error) bool { return target == fs.ErrExist } // // then Is(MyError{}, fs.ErrExist) returns true. See syscall.Errno.Is for -// an example in the standard library. +// an example in the standard library. An Is method should only shallowly +// compare err and the target and not call Unwrap on either. func Is(err, target error) bool { if target == nil { return err == target From 1d63052782a7535a3d4ce4557fd23fd97699b249 Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Fri, 17 Sep 2021 19:38:33 -0400 Subject: [PATCH 079/406] cmd/go: support replaces in the go.work file Add support for replace directives in the go.work file. If there are conflicting replaces in go.mod files, suggest that users add an overriding replace in the go.work file. Add HighestReplaced to MainModules so that it accounts for the replacements in the go.work file. (Reviewers: I'm not totally sure that HighestReplace is computed correctly. Could you take a closer look at that?) For #45713 Change-Id: I1d789219ca1dd065ba009ce5d38db9a1fc38ba83 Reviewed-on: https://go-review.googlesource.com/c/go/+/352812 Trust: Michael Matloob Run-TryBot: Michael Matloob TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/cmd/go/internal/modcmd/vendor.go | 2 +- src/cmd/go/internal/modget/get.go | 4 +- src/cmd/go/internal/modload/build.go | 14 +- src/cmd/go/internal/modload/import.go | 60 ++++--- src/cmd/go/internal/modload/init.go | 157 ++++++++++++------ src/cmd/go/internal/modload/load.go | 6 +- src/cmd/go/internal/modload/modfile.go | 157 ++++++++++-------- src/cmd/go/internal/modload/query.go | 40 +---- src/cmd/go/internal/modload/vendor.go | 2 +- src/cmd/go/testdata/script/work_edit.txt | 2 +- src/cmd/go/testdata/script/work_replace.txt | 55 ++++++ .../testdata/script/work_replace_conflict.txt | 53 ++++++ .../script/work_replace_conflict_override.txt | 57 +++++++ 13 files changed, 409 insertions(+), 200 deletions(-) create mode 100644 src/cmd/go/testdata/script/work_replace.txt create mode 100644 src/cmd/go/testdata/script/work_replace_conflict.txt create mode 100644 src/cmd/go/testdata/script/work_replace_conflict_override.txt diff --git a/src/cmd/go/internal/modcmd/vendor.go b/src/cmd/go/internal/modcmd/vendor.go index 92348b8897..57189b4607 100644 --- a/src/cmd/go/internal/modcmd/vendor.go +++ b/src/cmd/go/internal/modcmd/vendor.go @@ -128,7 +128,7 @@ func runVendor(ctx context.Context, cmd *base.Command, args []string) { } for _, m := range vendorMods { - replacement, _ := modload.Replacement(m) + replacement := modload.Replacement(m) line := moduleLine(m, replacement) io.WriteString(w, line) diff --git a/src/cmd/go/internal/modget/get.go b/src/cmd/go/internal/modget/get.go index c634512072..2c48c3c444 100644 --- a/src/cmd/go/internal/modget/get.go +++ b/src/cmd/go/internal/modget/get.go @@ -1575,7 +1575,7 @@ func (r *resolver) checkPackageProblems(ctx context.Context, pkgPatterns []strin i := i m := r.buildList[i] mActual := m - if mRepl, _ := modload.Replacement(m); mRepl.Path != "" { + if mRepl := modload.Replacement(m); mRepl.Path != "" { mActual = mRepl } old := module.Version{Path: m.Path, Version: r.initialVersion[m.Path]} @@ -1583,7 +1583,7 @@ func (r *resolver) checkPackageProblems(ctx context.Context, pkgPatterns []strin continue } oldActual := old - if oldRepl, _ := modload.Replacement(old); oldRepl.Path != "" { + if oldRepl := modload.Replacement(old); oldRepl.Path != "" { oldActual = oldRepl } if mActual == oldActual || mActual.Version == "" || !modfetch.HaveSum(oldActual) { diff --git a/src/cmd/go/internal/modload/build.go b/src/cmd/go/internal/modload/build.go index da50743138..0e0292ec15 100644 --- a/src/cmd/go/internal/modload/build.go +++ b/src/cmd/go/internal/modload/build.go @@ -239,7 +239,7 @@ func moduleInfo(ctx context.Context, rs *Requirements, m module.Version, mode Li } // completeFromModCache fills in the extra fields in m using the module cache. - completeFromModCache := func(m *modinfo.ModulePublic, replacedFrom string) { + completeFromModCache := func(m *modinfo.ModulePublic) { checksumOk := func(suffix string) bool { return rs == nil || m.Version == "" || cfg.BuildMod == "mod" || modfetch.HaveSum(module.Version{Path: m.Path, Version: m.Version + suffix}) @@ -258,7 +258,7 @@ func moduleInfo(ctx context.Context, rs *Requirements, m module.Version, mode Li if m.GoVersion == "" && checksumOk("/go.mod") { // Load the go.mod file to determine the Go version, since it hasn't // already been populated from rawGoVersion. - if summary, err := rawGoModSummary(mod, replacedFrom); err == nil && summary.goVersion != "" { + if summary, err := rawGoModSummary(mod); err == nil && summary.goVersion != "" { m.GoVersion = summary.goVersion } } @@ -288,11 +288,11 @@ func moduleInfo(ctx context.Context, rs *Requirements, m module.Version, mode Li if rs == nil { // If this was an explicitly-versioned argument to 'go mod download' or // 'go list -m', report the actual requested version, not its replacement. - completeFromModCache(info, "") // Will set m.Error in vendor mode. + completeFromModCache(info) // Will set m.Error in vendor mode. return info } - r, replacedFrom := Replacement(m) + r := Replacement(m) if r.Path == "" { if cfg.BuildMod == "vendor" { // It's tempting to fill in the "Dir" field to point within the vendor @@ -301,7 +301,7 @@ func moduleInfo(ctx context.Context, rs *Requirements, m module.Version, mode Li // interleave packages from different modules if one module path is a // prefix of the other. } else { - completeFromModCache(info, "") + completeFromModCache(info) } return info } @@ -321,12 +321,12 @@ func moduleInfo(ctx context.Context, rs *Requirements, m module.Version, mode Li if filepath.IsAbs(r.Path) { info.Replace.Dir = r.Path } else { - info.Replace.Dir = filepath.Join(replacedFrom, r.Path) + info.Replace.Dir = filepath.Join(replaceRelativeTo(), r.Path) } info.Replace.GoMod = filepath.Join(info.Replace.Dir, "go.mod") } if cfg.BuildMod != "vendor" { - completeFromModCache(info.Replace, replacedFrom) + completeFromModCache(info.Replace) info.Dir = info.Replace.Dir info.GoMod = info.Replace.GoMod info.Retracted = info.Replace.Retracted diff --git a/src/cmd/go/internal/modload/import.go b/src/cmd/go/internal/modload/import.go index e64677acd0..bc2b0a0230 100644 --- a/src/cmd/go/internal/modload/import.go +++ b/src/cmd/go/internal/modload/import.go @@ -426,35 +426,33 @@ func queryImport(ctx context.Context, path string, rs *Requirements) (module.Ver // To avoid spurious remote fetches, try the latest replacement for each // module (golang.org/issue/26241). var mods []module.Version - for _, v := range MainModules.Versions() { - if index := MainModules.Index(v); index != nil { - for mp, mv := range index.highestReplaced { - if !maybeInModule(path, mp) { - continue - } - if mv == "" { - // The only replacement is a wildcard that doesn't specify a version, so - // synthesize a pseudo-version with an appropriate major version and a - // timestamp below any real timestamp. That way, if the main module is - // used from within some other module, the user will be able to upgrade - // the requirement to any real version they choose. - if _, pathMajor, ok := module.SplitPathVersion(mp); ok && len(pathMajor) > 0 { - mv = module.ZeroPseudoVersion(pathMajor[1:]) - } else { - mv = module.ZeroPseudoVersion("v0") - } - } - mg, err := rs.Graph(ctx) - if err != nil { - return module.Version{}, err - } - if cmpVersion(mg.Selected(mp), mv) >= 0 { - // We can't resolve the import by adding mp@mv to the module graph, - // because the selected version of mp is already at least mv. - continue - } - mods = append(mods, module.Version{Path: mp, Version: mv}) + if MainModules != nil { // TODO(#48912): Ensure MainModules exists at this point, and remove the check. + for mp, mv := range MainModules.HighestReplaced() { + if !maybeInModule(path, mp) { + continue } + if mv == "" { + // The only replacement is a wildcard that doesn't specify a version, so + // synthesize a pseudo-version with an appropriate major version and a + // timestamp below any real timestamp. That way, if the main module is + // used from within some other module, the user will be able to upgrade + // the requirement to any real version they choose. + if _, pathMajor, ok := module.SplitPathVersion(mp); ok && len(pathMajor) > 0 { + mv = module.ZeroPseudoVersion(pathMajor[1:]) + } else { + mv = module.ZeroPseudoVersion("v0") + } + } + mg, err := rs.Graph(ctx) + if err != nil { + return module.Version{}, err + } + if cmpVersion(mg.Selected(mp), mv) >= 0 { + // We can't resolve the import by adding mp@mv to the module graph, + // because the selected version of mp is already at least mv. + continue + } + mods = append(mods, module.Version{Path: mp, Version: mv}) } } @@ -485,7 +483,7 @@ func queryImport(ctx context.Context, path string, rs *Requirements) (module.Ver // The package path is not valid to fetch remotely, // so it can only exist in a replaced module, // and we know from the above loop that it is not. - replacement, _ := Replacement(mods[0]) + replacement := Replacement(mods[0]) return module.Version{}, &PackageNotInModuleError{ Mod: mods[0], Query: "latest", @@ -659,11 +657,11 @@ func fetch(ctx context.Context, mod module.Version, needSum bool) (dir string, i if modRoot := MainModules.ModRoot(mod); modRoot != "" { return modRoot, true, nil } - if r, replacedFrom := Replacement(mod); r.Path != "" { + if r := Replacement(mod); r.Path != "" { if r.Version == "" { dir = r.Path if !filepath.IsAbs(dir) { - dir = filepath.Join(replacedFrom, dir) + dir = filepath.Join(replaceRelativeTo(), dir) } // Ensure that the replacement directory actually exists: // dirInModule does not report errors for missing modules, diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go index 621099beb3..0602aee0cc 100644 --- a/src/cmd/go/internal/modload/init.go +++ b/src/cmd/go/internal/modload/init.go @@ -69,9 +69,8 @@ var ( // roots are required but MainModules hasn't been initialized yet. Set to // the modRoots of the main modules. // modRoots != nil implies len(modRoots) > 0 - modRoots []string - gopath string - workFileGoVersion string + modRoots []string + gopath string ) // Variable set in InitWorkfile @@ -104,6 +103,10 @@ type MainModuleSet struct { workFileGoVersion string + workFileReplaceMap map[module.Version]module.Version + // highest replaced version of each module path; empty string for wildcard-only replacements + highestReplaced map[string]string + indexMu sync.Mutex indices map[module.Version]*modFileIndex } @@ -203,6 +206,10 @@ func (mms *MainModuleSet) ModContainingCWD() module.Version { return mms.modContainingCWD } +func (mms *MainModuleSet) HighestReplaced() map[string]string { + return mms.highestReplaced +} + // GoVersion returns the go version set on the single module, in module mode, // or the go.work file in workspace mode. func (mms *MainModuleSet) GoVersion() string { @@ -217,6 +224,10 @@ func (mms *MainModuleSet) GoVersion() string { return v } +func (mms *MainModuleSet) WorkFileReplaceMap() map[module.Version]module.Version { + return mms.workFileReplaceMap +} + var MainModules *MainModuleSet type Root int @@ -275,6 +286,9 @@ func InitWorkfile() { case "", "auto": workFilePath = findWorkspaceFile(base.Cwd()) default: + if !filepath.IsAbs(cfg.WorkFile) { + base.Errorf("the path provided to -workfile must be an absolute path") + } workFilePath = cfg.WorkFile } } @@ -403,37 +417,6 @@ func Init() { base.Fatalf("$GOPATH/go.mod exists but should not") } } - - if inWorkspaceMode() { - var err error - workFileGoVersion, modRoots, err = loadWorkFile(workFilePath) - if err != nil { - base.Fatalf("reading go.work: %v", err) - } - _ = TODOWorkspaces("Support falling back to individual module go.sum " + - "files for sums not in the workspace sum file.") - modfetch.GoSumFile = workFilePath + ".sum" - } else if modRoots == nil { - // We're in module mode, but not inside a module. - // - // Commands like 'go build', 'go run', 'go list' have no go.mod file to - // read or write. They would need to find and download the latest versions - // of a potentially large number of modules with no way to save version - // information. We can succeed slowly (but not reproducibly), but that's - // not usually a good experience. - // - // Instead, we forbid resolving import paths to modules other than std and - // cmd. Users may still build packages specified with .go files on the - // command line, but they'll see an error if those files import anything - // outside std. - // - // This can be overridden by calling AllowMissingModuleImports. - // For example, 'go get' does this, since it is expected to resolve paths. - // - // See golang.org/issue/32027. - } else { - modfetch.GoSumFile = strings.TrimSuffix(modFilePath(modRoots[0]), ".mod") + ".sum" - } } // WillBeEnabled checks whether modules should be enabled but does not @@ -568,16 +551,16 @@ func (goModDirtyError) Error() string { var errGoModDirty error = goModDirtyError{} -func loadWorkFile(path string) (goVersion string, modRoots []string, err error) { +func loadWorkFile(path string) (goVersion string, modRoots []string, replaces []*modfile.Replace, err error) { _ = TODOWorkspaces("Clean up and write back the go.work file: add module paths for workspace modules.") workDir := filepath.Dir(path) workData, err := lockedfile.Read(path) if err != nil { - return "", nil, err + return "", nil, nil, err } wf, err := modfile.ParseWork(path, workData, nil) if err != nil { - return "", nil, err + return "", nil, nil, err } if wf.Go != nil { goVersion = wf.Go.Version @@ -589,12 +572,12 @@ func loadWorkFile(path string) (goVersion string, modRoots []string, err error) modRoot = filepath.Join(workDir, modRoot) } if seen[modRoot] { - return "", nil, fmt.Errorf("path %s appears multiple times in workspace", modRoot) + return "", nil, nil, fmt.Errorf("path %s appears multiple times in workspace", modRoot) } seen[modRoot] = true modRoots = append(modRoots, modRoot) } - return goVersion, modRoots, nil + return goVersion, modRoots, wf.Replace, nil } // LoadModFile sets Target and, if there is a main module, parses the initial @@ -621,10 +604,44 @@ func LoadModFile(ctx context.Context) *Requirements { } Init() + var ( + workFileGoVersion string + workFileReplaces []*modfile.Replace + ) + if inWorkspaceMode() { + var err error + workFileGoVersion, modRoots, workFileReplaces, err = loadWorkFile(workFilePath) + if err != nil { + base.Fatalf("reading go.work: %v", err) + } + _ = TODOWorkspaces("Support falling back to individual module go.sum " + + "files for sums not in the workspace sum file.") + modfetch.GoSumFile = workFilePath + ".sum" + } else if modRoots == nil { + // We're in module mode, but not inside a module. + // + // Commands like 'go build', 'go run', 'go list' have no go.mod file to + // read or write. They would need to find and download the latest versions + // of a potentially large number of modules with no way to save version + // information. We can succeed slowly (but not reproducibly), but that's + // not usually a good experience. + // + // Instead, we forbid resolving import paths to modules other than std and + // cmd. Users may still build packages specified with .go files on the + // command line, but they'll see an error if those files import anything + // outside std. + // + // This can be overridden by calling AllowMissingModuleImports. + // For example, 'go get' does this, since it is expected to resolve paths. + // + // See golang.org/issue/32027. + } else { + modfetch.GoSumFile = strings.TrimSuffix(modFilePath(modRoots[0]), ".mod") + ".sum" + } if len(modRoots) == 0 { _ = TODOWorkspaces("Instead of creating a fake module with an empty modroot, make MainModules.Len() == 0 mean that we're in module mode but not inside any module.") mainModule := module.Version{Path: "command-line-arguments"} - MainModules = makeMainModules([]module.Version{mainModule}, []string{""}, []*modfile.File{nil}, []*modFileIndex{nil}, "") + MainModules = makeMainModules([]module.Version{mainModule}, []string{""}, []*modfile.File{nil}, []*modFileIndex{nil}, "", nil) goVersion := LatestGoVersion() rawGoVersion.Store(mainModule, goVersion) requirements = newRequirements(pruningForGoVersion(goVersion), nil, nil) @@ -655,7 +672,7 @@ func LoadModFile(ctx context.Context) *Requirements { } } - MainModules = makeMainModules(mainModules, modRoots, modFiles, indices, workFileGoVersion) + MainModules = makeMainModules(mainModules, modRoots, modFiles, indices, workFileGoVersion, workFileReplaces) setDefaultBuildMod() // possibly enable automatic vendoring rs := requirementsFromModFiles(ctx, modFiles) @@ -758,7 +775,7 @@ func CreateModFile(ctx context.Context, modPath string) { fmt.Fprintf(os.Stderr, "go: creating new go.mod: module %s\n", modPath) modFile := new(modfile.File) modFile.AddModuleStmt(modPath) - MainModules = makeMainModules([]module.Version{modFile.Module.Mod}, []string{modRoot}, []*modfile.File{modFile}, []*modFileIndex{nil}, "") + MainModules = makeMainModules([]module.Version{modFile.Module.Mod}, []string{modRoot}, []*modfile.File{modFile}, []*modFileIndex{nil}, "", nil) addGoStmt(modFile, modFile.Module.Mod, LatestGoVersion()) // Add the go directive before converted module requirements. convertedFrom, err := convertLegacyConfig(modFile, modRoot) @@ -893,7 +910,7 @@ func AllowMissingModuleImports() { // makeMainModules creates a MainModuleSet and associated variables according to // the given main modules. -func makeMainModules(ms []module.Version, rootDirs []string, modFiles []*modfile.File, indices []*modFileIndex, workFileGoVersion string) *MainModuleSet { +func makeMainModules(ms []module.Version, rootDirs []string, modFiles []*modfile.File, indices []*modFileIndex, workFileGoVersion string, workFileReplaces []*modfile.Replace) *MainModuleSet { for _, m := range ms { if m.Version != "" { panic("mainModulesCalled with module.Version with non empty Version field: " + fmt.Sprintf("%#v", m)) @@ -901,13 +918,25 @@ func makeMainModules(ms []module.Version, rootDirs []string, modFiles []*modfile } modRootContainingCWD := findModuleRoot(base.Cwd()) mainModules := &MainModuleSet{ - versions: ms[:len(ms):len(ms)], - inGorootSrc: map[module.Version]bool{}, - pathPrefix: map[module.Version]string{}, - modRoot: map[module.Version]string{}, - modFiles: map[module.Version]*modfile.File{}, - indices: map[module.Version]*modFileIndex{}, - workFileGoVersion: workFileGoVersion, + versions: ms[:len(ms):len(ms)], + inGorootSrc: map[module.Version]bool{}, + pathPrefix: map[module.Version]string{}, + modRoot: map[module.Version]string{}, + modFiles: map[module.Version]*modfile.File{}, + indices: map[module.Version]*modFileIndex{}, + workFileGoVersion: workFileGoVersion, + workFileReplaceMap: toReplaceMap(workFileReplaces), + highestReplaced: map[string]string{}, + } + replacedByWorkFile := make(map[string]bool) + replacements := make(map[module.Version]module.Version) + for _, r := range workFileReplaces { + replacedByWorkFile[r.Old.Path] = true + v, ok := mainModules.highestReplaced[r.Old.Path] + if !ok || semver.Compare(r.Old.Version, v) > 0 { + mainModules.highestReplaced[r.Old.Path] = r.Old.Version + } + replacements[r.Old] = r.New } for i, m := range ms { mainModules.pathPrefix[m] = m.Path @@ -933,6 +962,24 @@ func makeMainModules(ms []module.Version, rootDirs []string, modFiles []*modfile mainModules.pathPrefix[m] = "" } } + + if modFiles[i] != nil { + curModuleReplaces := make(map[module.Version]bool) + for _, r := range modFiles[i].Replace { + if replacedByWorkFile[r.Old.Path] { + continue + } else if prev, ok := replacements[r.Old]; ok && !curModuleReplaces[r.Old] { + base.Fatalf("go: conflicting replacements for %v:\n\t%v\n\t%v\nuse \"go mod editwork -replace %v=[override]\" to resolve", r.Old, prev, r.New, r.Old) + } + curModuleReplaces[r.Old] = true + replacements[r.Old] = r.New + + v, ok := mainModules.highestReplaced[r.Old.Path] + if !ok || semver.Compare(r.Old.Version, v) > 0 { + mainModules.highestReplaced[r.Old.Path] = r.Old.Version + } + } + } } return mainModules } @@ -1471,7 +1518,7 @@ func keepSums(ctx context.Context, ld *loader, rs *Requirements, which whichSums for prefix := pkg.path; prefix != "."; prefix = path.Dir(prefix) { if v, ok := rs.rootSelected(prefix); ok && v != "none" { m := module.Version{Path: prefix, Version: v} - r, _ := resolveReplacement(m) + r := resolveReplacement(m) keep[r] = true } } @@ -1483,7 +1530,7 @@ func keepSums(ctx context.Context, ld *loader, rs *Requirements, which whichSums for prefix := pkg.path; prefix != "."; prefix = path.Dir(prefix) { if v := mg.Selected(prefix); v != "none" { m := module.Version{Path: prefix, Version: v} - r, _ := resolveReplacement(m) + r := resolveReplacement(m) keep[r] = true } } @@ -1495,7 +1542,7 @@ func keepSums(ctx context.Context, ld *loader, rs *Requirements, which whichSums // Save sums for the root modules (or their replacements), but don't // incur the cost of loading the graph just to find and retain the sums. for _, m := range rs.rootModules { - r, _ := resolveReplacement(m) + r := resolveReplacement(m) keep[modkey(r)] = true if which == addBuildListZipSums { keep[r] = true @@ -1508,14 +1555,14 @@ func keepSums(ctx context.Context, ld *loader, rs *Requirements, which whichSums // The requirements from m's go.mod file are present in the module graph, // so they are relevant to the MVS result regardless of whether m was // actually selected. - r, _ := resolveReplacement(m) + r := resolveReplacement(m) keep[modkey(r)] = true } }) if which == addBuildListZipSums { for _, m := range mg.BuildList() { - r, _ := resolveReplacement(m) + r := resolveReplacement(m) keep[r] = true } } diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go index 3498c662f3..0f5b015000 100644 --- a/src/cmd/go/internal/modload/load.go +++ b/src/cmd/go/internal/modload/load.go @@ -607,10 +607,10 @@ func pathInModuleCache(ctx context.Context, dir string, rs *Requirements) string tryMod := func(m module.Version) (string, bool) { var root string var err error - if repl, replModRoot := Replacement(m); repl.Path != "" && repl.Version == "" { + if repl := Replacement(m); repl.Path != "" && repl.Version == "" { root = repl.Path if !filepath.IsAbs(root) { - root = filepath.Join(replModRoot, root) + root = filepath.Join(replaceRelativeTo(), root) } } else if repl.Path != "" { root, err = modfetch.DownloadDir(repl) @@ -1834,7 +1834,7 @@ func (ld *loader) checkMultiplePaths() { firstPath := map[module.Version]string{} for _, mod := range mods { - src, _ := resolveReplacement(mod) + src := resolveReplacement(mod) if prev, ok := firstPath[src]; !ok { firstPath[src] = mod.Path } else if prev != mod.Path { diff --git a/src/cmd/go/internal/modload/modfile.go b/src/cmd/go/internal/modload/modfile.go index bf05e92ba2..87e8a5e83d 100644 --- a/src/cmd/go/internal/modload/modfile.go +++ b/src/cmd/go/internal/modload/modfile.go @@ -99,14 +99,13 @@ func modFileGoVersion(modFile *modfile.File) string { // A modFileIndex is an index of data corresponding to a modFile // at a specific point in time. type modFileIndex struct { - data []byte - dataNeedsFix bool // true if fixVersion applied a change while parsing data - module module.Version - goVersionV string // GoVersion with "v" prefix - require map[module.Version]requireMeta - replace map[module.Version]module.Version - highestReplaced map[string]string // highest replaced version of each module path; empty string for wildcard-only replacements - exclude map[module.Version]bool + data []byte + dataNeedsFix bool // true if fixVersion applied a change while parsing data + module module.Version + goVersionV string // GoVersion with "v" prefix + require map[module.Version]requireMeta + replace map[module.Version]module.Version + exclude map[module.Version]bool } type requireMeta struct { @@ -187,7 +186,7 @@ func CheckRetractions(ctx context.Context, m module.Version) (err error) { // Cannot be retracted. return nil } - if repl, _ := Replacement(module.Version{Path: m.Path}); repl.Path != "" { + if repl := Replacement(module.Version{Path: m.Path}); repl.Path != "" { // All versions of the module were replaced. // Don't load retractions, since we'd just load the replacement. return nil @@ -204,11 +203,11 @@ func CheckRetractions(ctx context.Context, m module.Version) (err error) { // We load the raw file here: the go.mod file may have a different module // path that we expect if the module or its repository was renamed. // We still want to apply retractions to other aliases of the module. - rm, replacedFrom, err := queryLatestVersionIgnoringRetractions(ctx, m.Path) + rm, err := queryLatestVersionIgnoringRetractions(ctx, m.Path) if err != nil { return err } - summary, err := rawGoModSummary(rm, replacedFrom) + summary, err := rawGoModSummary(rm) if err != nil { return err } @@ -306,66 +305,107 @@ func CheckDeprecation(ctx context.Context, m module.Version) (deprecation string // Don't look up deprecation. return "", nil } - if repl, _ := Replacement(module.Version{Path: m.Path}); repl.Path != "" { + if repl := Replacement(module.Version{Path: m.Path}); repl.Path != "" { // All versions of the module were replaced. // We'll look up deprecation separately for the replacement. return "", nil } - latest, replacedFrom, err := queryLatestVersionIgnoringRetractions(ctx, m.Path) + latest, err := queryLatestVersionIgnoringRetractions(ctx, m.Path) if err != nil { return "", err } - summary, err := rawGoModSummary(latest, replacedFrom) + summary, err := rawGoModSummary(latest) if err != nil { return "", err } return summary.deprecated, nil } -func replacement(mod module.Version, index *modFileIndex) (fromVersion string, to module.Version, ok bool) { - if r, ok := index.replace[mod]; ok { +func replacement(mod module.Version, replace map[module.Version]module.Version) (fromVersion string, to module.Version, ok bool) { + if r, ok := replace[mod]; ok { return mod.Version, r, true } - if r, ok := index.replace[module.Version{Path: mod.Path}]; ok { + if r, ok := replace[module.Version{Path: mod.Path}]; ok { return "", r, true } return "", module.Version{}, false } -// Replacement returns the replacement for mod, if any, and and the module root -// directory of the main module containing the replace directive. -// If there is no replacement for mod, Replacement returns -// a module.Version with Path == "". -func Replacement(mod module.Version) (module.Version, string) { - _ = TODOWorkspaces("Support replaces in the go.work file.") +// Replacement returns the replacement for mod, if any. If the path in the +// module.Version is relative it's relative to the single main module outside +// workspace mode, or the workspace's directory in workspace mode. +func Replacement(mod module.Version) module.Version { foundFrom, found, foundModRoot := "", module.Version{}, "" + if MainModules == nil { + return module.Version{} + } + if _, r, ok := replacement(mod, MainModules.WorkFileReplaceMap()); ok { + return r + } for _, v := range MainModules.Versions() { if index := MainModules.Index(v); index != nil { - if from, r, ok := replacement(mod, index); ok { + if from, r, ok := replacement(mod, index.replace); ok { modRoot := MainModules.ModRoot(v) if foundModRoot != "" && foundFrom != from && found != r { - _ = TODOWorkspaces("once the go.work file supports replaces, recommend them as a way to override conflicts") base.Errorf("conflicting replacements found for %v in workspace modules defined by %v and %v", mod, modFilePath(foundModRoot), modFilePath(modRoot)) - return found, foundModRoot + return canonicalizeReplacePath(found, foundModRoot) } found, foundModRoot = r, modRoot } } } - return found, foundModRoot + return canonicalizeReplacePath(found, foundModRoot) +} + +func replaceRelativeTo() string { + if workFilePath := WorkFilePath(); workFilePath != "" { + return filepath.Dir(workFilePath) + } + return MainModules.ModRoot(MainModules.mustGetSingleMainModule()) +} + +// canonicalizeReplacePath ensures that relative, on-disk, replaced module paths +// are relative to the workspace directory (in workspace mode) or to the module's +// directory (in module mode, as they already are). +func canonicalizeReplacePath(r module.Version, modRoot string) module.Version { + if filepath.IsAbs(r.Path) || r.Version != "" { + return r + } + workFilePath := WorkFilePath() + if workFilePath == "" { + return r + } + abs := filepath.Join(modRoot, r.Path) + if rel, err := filepath.Rel(workFilePath, abs); err == nil { + return module.Version{Path: rel, Version: r.Version} + } + // We couldn't make the version's path relative to the workspace's path, + // so just return the absolute path. It's the best we can do. + return module.Version{Path: abs, Version: r.Version} } // resolveReplacement returns the module actually used to load the source code // for m: either m itself, or the replacement for m (iff m is replaced). // It also returns the modroot of the module providing the replacement if // one was found. -func resolveReplacement(m module.Version) (module.Version, string) { - if r, replacedFrom := Replacement(m); r.Path != "" { - return r, replacedFrom +func resolveReplacement(m module.Version) module.Version { + if r := Replacement(m); r.Path != "" { + return r } - return m, "" + return m +} + +func toReplaceMap(replacements []*modfile.Replace) map[module.Version]module.Version { + replaceMap := make(map[module.Version]module.Version, len(replacements)) + for _, r := range replacements { + if prev, dup := replaceMap[r.Old]; dup && prev != r.New { + base.Fatalf("go: conflicting replacements for %v:\n\t%v\n\t%v", r.Old, prev, r.New) + } + replaceMap[r.Old] = r.New + } + return replaceMap } // indexModFile rebuilds the index of modFile. @@ -396,21 +436,7 @@ func indexModFile(data []byte, modFile *modfile.File, mod module.Version, needsF i.require[r.Mod] = requireMeta{indirect: r.Indirect} } - i.replace = make(map[module.Version]module.Version, len(modFile.Replace)) - for _, r := range modFile.Replace { - if prev, dup := i.replace[r.Old]; dup && prev != r.New { - base.Fatalf("go: conflicting replacements for %v:\n\t%v\n\t%v", r.Old, prev, r.New) - } - i.replace[r.Old] = r.New - } - - i.highestReplaced = make(map[string]string) - for _, r := range modFile.Replace { - v, ok := i.highestReplaced[r.Old.Path] - if !ok || semver.Compare(r.Old.Version, v) > 0 { - i.highestReplaced[r.Old.Path] = r.Old.Version - } - } + i.replace = toReplaceMap(modFile.Replace) i.exclude = make(map[module.Version]bool, len(modFile.Exclude)) for _, x := range modFile.Exclude { @@ -552,7 +578,7 @@ func goModSummary(m module.Version) (*modFileSummary, error) { return summary, nil } - actual, replacedFrom := resolveReplacement(m) + actual := resolveReplacement(m) if HasModRoot() && cfg.BuildMod == "readonly" && !inWorkspaceMode() && actual.Version != "" { key := module.Version{Path: actual.Path, Version: actual.Version + "/go.mod"} if !modfetch.HaveSum(key) { @@ -560,7 +586,7 @@ func goModSummary(m module.Version) (*modFileSummary, error) { return nil, module.VersionError(actual, &sumMissingError{suggestion: suggestion}) } } - summary, err := rawGoModSummary(actual, replacedFrom) + summary, err := rawGoModSummary(actual) if err != nil { return nil, err } @@ -625,22 +651,21 @@ func goModSummary(m module.Version) (*modFileSummary, error) { // // rawGoModSummary cannot be used on the Target module. -func rawGoModSummary(m module.Version, replacedFrom string) (*modFileSummary, error) { +func rawGoModSummary(m module.Version) (*modFileSummary, error) { if m.Path == "" && MainModules.Contains(m.Path) { panic("internal error: rawGoModSummary called on the Target module") } type key struct { - m module.Version - replacedFrom string + m module.Version } type cached struct { summary *modFileSummary err error } - c := rawGoModSummaryCache.Do(key{m, replacedFrom}, func() interface{} { + c := rawGoModSummaryCache.Do(key{m}, func() interface{} { summary := new(modFileSummary) - name, data, err := rawGoModData(m, replacedFrom) + name, data, err := rawGoModData(m) if err != nil { return cached{nil, err} } @@ -690,15 +715,12 @@ var rawGoModSummaryCache par.Cache // module.Version → rawGoModSummary result // // Unlike rawGoModSummary, rawGoModData does not cache its results in memory. // Use rawGoModSummary instead unless you specifically need these bytes. -func rawGoModData(m module.Version, replacedFrom string) (name string, data []byte, err error) { +func rawGoModData(m module.Version) (name string, data []byte, err error) { if m.Version == "" { // m is a replacement module with only a file path. dir := m.Path if !filepath.IsAbs(dir) { - if replacedFrom == "" { - panic(fmt.Errorf("missing module root of main module providing replacement with relative path: %v", dir)) - } - dir = filepath.Join(replacedFrom, dir) + dir = filepath.Join(replaceRelativeTo(), dir) } name = filepath.Join(dir, "go.mod") if gomodActual, ok := fsys.OverlayPath(name); ok { @@ -733,20 +755,19 @@ func rawGoModData(m module.Version, replacedFrom string) (name string, data []by // // If the queried latest version is replaced, // queryLatestVersionIgnoringRetractions returns the replacement. -func queryLatestVersionIgnoringRetractions(ctx context.Context, path string) (latest module.Version, replacedFrom string, err error) { +func queryLatestVersionIgnoringRetractions(ctx context.Context, path string) (latest module.Version, err error) { type entry struct { - latest module.Version - replacedFrom string // if latest is a replacement - err error + latest module.Version + err error } e := latestVersionIgnoringRetractionsCache.Do(path, func() interface{} { ctx, span := trace.StartSpan(ctx, "queryLatestVersionIgnoringRetractions "+path) defer span.Done() - if repl, replFrom := Replacement(module.Version{Path: path}); repl.Path != "" { + if repl := Replacement(module.Version{Path: path}); repl.Path != "" { // All versions of the module were replaced. // No need to query. - return &entry{latest: repl, replacedFrom: replFrom} + return &entry{latest: repl} } // Find the latest version of the module. @@ -758,12 +779,12 @@ func queryLatestVersionIgnoringRetractions(ctx context.Context, path string) (la return &entry{err: err} } latest := module.Version{Path: path, Version: rev.Version} - if repl, replFrom := resolveReplacement(latest); repl.Path != "" { - latest, replacedFrom = repl, replFrom + if repl := resolveReplacement(latest); repl.Path != "" { + latest = repl } - return &entry{latest: latest, replacedFrom: replacedFrom} + return &entry{latest: latest} }).(*entry) - return e.latest, e.replacedFrom, e.err + return e.latest, e.err } var latestVersionIgnoringRetractionsCache par.Cache // path → queryLatestVersionIgnoringRetractions result diff --git a/src/cmd/go/internal/modload/query.go b/src/cmd/go/internal/modload/query.go index 82979fbda1..c9ed129dbf 100644 --- a/src/cmd/go/internal/modload/query.go +++ b/src/cmd/go/internal/modload/query.go @@ -513,7 +513,7 @@ func QueryPackages(ctx context.Context, pattern, query string, current func(stri pkgMods, modOnly, err := QueryPattern(ctx, pattern, query, current, allowed) if len(pkgMods) == 0 && err == nil { - replacement, _ := Replacement(modOnly.Mod) + replacement := Replacement(modOnly.Mod) return nil, &PackageNotInModuleError{ Mod: modOnly.Mod, Replacement: replacement, @@ -669,7 +669,7 @@ func QueryPattern(ctx context.Context, pattern, query string, current func(strin if err := firstError(m); err != nil { return r, err } - replacement, _ := Replacement(r.Mod) + replacement := Replacement(r.Mod) return r, &PackageNotInModuleError{ Mod: r.Mod, Replacement: replacement, @@ -969,7 +969,7 @@ func moduleHasRootPackage(ctx context.Context, m module.Version) (bool, error) { // we don't need to verify it in go.sum. This makes 'go list -m -u' faster // and simpler. func versionHasGoMod(_ context.Context, m module.Version) (bool, error) { - _, data, err := rawGoModData(m, "") + _, data, err := rawGoModData(m) if err != nil { return false, err } @@ -996,15 +996,10 @@ func lookupRepo(proxy, path string) (repo versionRepo, err error) { repo = emptyRepo{path: path, err: err} } - // TODO(#45713): Join all the highestReplaced fields into a single value. - for _, mm := range MainModules.Versions() { - index := MainModules.Index(mm) - if index == nil { - continue - } - if _, ok := index.highestReplaced[path]; ok { - return &replacementRepo{repo: repo}, nil - } + if MainModules == nil { + return repo, err + } else if _, ok := MainModules.HighestReplaced()[path]; ok { + return &replacementRepo{repo: repo}, nil } return repo, err @@ -1098,7 +1093,7 @@ func (rr *replacementRepo) Stat(rev string) (*modfetch.RevInfo, error) { } } - if r, _ := Replacement(module.Version{Path: path, Version: v}); r.Path == "" { + if r := Replacement(module.Version{Path: path, Version: v}); r.Path == "" { return info, err } return rr.replacementStat(v) @@ -1108,24 +1103,7 @@ func (rr *replacementRepo) Latest() (*modfetch.RevInfo, error) { info, err := rr.repo.Latest() path := rr.ModulePath() - highestReplaced, found := "", false - for _, mm := range MainModules.Versions() { - if index := MainModules.Index(mm); index != nil { - if v, ok := index.highestReplaced[path]; ok { - if !found { - highestReplaced, found = v, true - continue - } - if semver.Compare(v, highestReplaced) > 0 { - highestReplaced = v - } - } - } - } - - if found { - v := highestReplaced - + if v, ok := MainModules.HighestReplaced()[path]; ok { if v == "" { // The only replacement is a wildcard that doesn't specify a version, so // synthesize a pseudo-version with an appropriate major version and a diff --git a/src/cmd/go/internal/modload/vendor.go b/src/cmd/go/internal/modload/vendor.go index daa5888075..a735cad905 100644 --- a/src/cmd/go/internal/modload/vendor.go +++ b/src/cmd/go/internal/modload/vendor.go @@ -209,7 +209,7 @@ func checkVendorConsistency(index *modFileIndex, modFile *modfile.File) { } for _, mod := range vendorReplaced { - r, _ := Replacement(mod) + r := Replacement(mod) if r == (module.Version{}) { vendErrorf(mod, "is marked as replaced in vendor/modules.txt, but not replaced in go.mod") continue diff --git a/src/cmd/go/testdata/script/work_edit.txt b/src/cmd/go/testdata/script/work_edit.txt index 001ac7f65c..979c1f98e0 100644 --- a/src/cmd/go/testdata/script/work_edit.txt +++ b/src/cmd/go/testdata/script/work_edit.txt @@ -30,7 +30,7 @@ cmp stdout go.work.want_print go mod editwork -json -go 1.19 -directory b -dropdirectory c -replace 'x.1@v1.4.0 = ../z' -dropreplace x.1 -dropreplace x.1@v1.3.0 cmp stdout go.work.want_json -go mod editwork -print -fmt -workfile unformatted +go mod editwork -print -fmt -workfile $GOPATH/src/unformatted cmp stdout formatted -- m/go.mod -- diff --git a/src/cmd/go/testdata/script/work_replace.txt b/src/cmd/go/testdata/script/work_replace.txt new file mode 100644 index 0000000000..5a4cb0eebb --- /dev/null +++ b/src/cmd/go/testdata/script/work_replace.txt @@ -0,0 +1,55 @@ +# Support replace statement in go.work file + +# Replacement in go.work file, and none in go.mod file. +go list -m example.com/dep +stdout 'example.com/dep v1.0.0 => ./dep' + +# Wildcard replacement in go.work file overrides version replacement in go.mod +# file. +go list -m example.com/other +stdout 'example.com/other v1.0.0 => ./other2' + +-- go.work -- +directory m + +replace example.com/dep => ./dep +replace example.com/other => ./other2 + +-- m/go.mod -- +module example.com/m + +require example.com/dep v1.0.0 +require example.com/other v1.0.0 + +replace example.com/other v1.0.0 => ./other +-- m/m.go -- +package m + +import "example.com/dep" +import "example.com/other" + +func F() { + dep.G() + other.H() +} +-- dep/go.mod -- +module example.com/dep +-- dep/dep.go -- +package dep + +func G() { +} +-- other/go.mod -- +module example.com/other +-- other/dep.go -- +package other + +func G() { +} +-- other2/go.mod -- +module example.com/other +-- other2/dep.go -- +package other + +func G() { +} \ No newline at end of file diff --git a/src/cmd/go/testdata/script/work_replace_conflict.txt b/src/cmd/go/testdata/script/work_replace_conflict.txt new file mode 100644 index 0000000000..a2f76d13a0 --- /dev/null +++ b/src/cmd/go/testdata/script/work_replace_conflict.txt @@ -0,0 +1,53 @@ +# Conflicting replaces in workspace modules returns error that suggests +# overriding it in the go.work file. + +! go list -m example.com/dep +stderr 'go: conflicting replacements for example.com/dep@v1.0.0:\n\t./dep1\n\t./dep2\nuse "go mod editwork -replace example.com/dep@v1.0.0=\[override\]" to resolve' +go mod editwork -replace example.com/dep@v1.0.0=./dep1 +go list -m example.com/dep +stdout 'example.com/dep v1.0.0 => ./dep1' + +-- foo -- +-- go.work -- +directory m +directory n +-- m/go.mod -- +module example.com/m + +require example.com/dep v1.0.0 +replace example.com/dep v1.0.0 => ./dep1 +-- m/m.go -- +package m + +import "example.com/dep" + +func F() { + dep.G() +} +-- n/go.mod -- +module example.com/n + +require example.com/dep v1.0.0 +replace example.com/dep v1.0.0 => ./dep2 +-- n/n.go -- +package n + +import "example.com/dep" + +func F() { + dep.G() +} +-- dep1/go.mod -- +module example.com/dep +-- dep1/dep.go -- +package dep + +func G() { +} +-- dep2/go.mod -- +module example.com/dep +-- dep2/dep.go -- +package dep + +func G() { +} diff --git a/src/cmd/go/testdata/script/work_replace_conflict_override.txt b/src/cmd/go/testdata/script/work_replace_conflict_override.txt new file mode 100644 index 0000000000..ebb517dd7c --- /dev/null +++ b/src/cmd/go/testdata/script/work_replace_conflict_override.txt @@ -0,0 +1,57 @@ +# Conflicting workspace module replaces can be overridden by a replace in the +# go.work file. + +go list -m example.com/dep +stdout 'example.com/dep v1.0.0 => ./dep3' + +-- go.work -- +directory m +directory n +replace example.com/dep => ./dep3 +-- m/go.mod -- +module example.com/m + +require example.com/dep v1.0.0 +replace example.com/dep => ./dep1 +-- m/m.go -- +package m + +import "example.com/dep" + +func F() { + dep.G() +} +-- n/go.mod -- +module example.com/n + +require example.com/dep v1.0.0 +replace example.com/dep => ./dep2 +-- n/n.go -- +package n + +import "example.com/dep" + +func F() { + dep.G() +} +-- dep1/go.mod -- +module example.com/dep +-- dep1/dep.go -- +package dep + +func G() { +} +-- dep2/go.mod -- +module example.com/dep +-- dep2/dep.go -- +package dep + +func G() { +} +-- dep3/go.mod -- +module example.com/dep +-- dep3/dep.go -- +package dep + +func G() { +} From d94498470bb09bb0606b0eff3248cb5b35e1a145 Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Fri, 17 Sep 2021 19:38:33 -0400 Subject: [PATCH 080/406] cmd/go: add GOWORK to go env command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GOWORK will be set to the go.work file's path, if in workspace mode or will be empty otherwise. For #45713 Fixes #48589 Change-Id: I163ffaf274e0a41469c1f3b8514d6f90e20423b0 Reviewed-on: https://go-review.googlesource.com/c/go/+/355689 Trust: Michael Matloob Trust: Daniel Martí Run-TryBot: Michael Matloob TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/cmd/go/internal/envcmd/env.go | 5 ++++- src/cmd/go/testdata/script/work.txt | 4 ++++ src/cmd/go/testdata/script/work_env.txt | 24 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/cmd/go/testdata/script/work_env.txt diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go index 1eb773407e..181d2a2ca1 100644 --- a/src/cmd/go/internal/envcmd/env.go +++ b/src/cmd/go/internal/envcmd/env.go @@ -152,8 +152,11 @@ func ExtraEnvVars() []cfg.EnvVar { } else if modload.Enabled() { gomod = os.DevNull } + modload.InitWorkfile() + gowork := modload.WorkFilePath() return []cfg.EnvVar{ {Name: "GOMOD", Value: gomod}, + {Name: "GOWORK", Value: gowork}, } } @@ -431,7 +434,7 @@ func getOrigEnv(key string) string { func checkEnvWrite(key, val string) error { switch key { - case "GOEXE", "GOGCCFLAGS", "GOHOSTARCH", "GOHOSTOS", "GOMOD", "GOTOOLDIR", "GOVERSION": + case "GOEXE", "GOGCCFLAGS", "GOHOSTARCH", "GOHOSTOS", "GOMOD", "GOWORK", "GOTOOLDIR", "GOVERSION": return fmt.Errorf("%s cannot be modified", key) case "GOENV": return fmt.Errorf("%s can only be set using the OS environment", key) diff --git a/src/cmd/go/testdata/script/work.txt b/src/cmd/go/testdata/script/work.txt index 657cd060cc..613f037615 100644 --- a/src/cmd/go/testdata/script/work.txt +++ b/src/cmd/go/testdata/script/work.txt @@ -1,8 +1,12 @@ ! go mod initwork doesnotexist stderr 'go: creating workspace file: no go.mod file exists in directory doesnotexist' +go env GOWORK +! stdout . go mod initwork ./a ./b cmp go.work go.work.want +go env GOWORK +stdout '^'$WORK'(\\|/)gopath(\\|/)src(\\|/)go.work$' ! go run example.com/b stderr 'a(\\|/)a.go:4:8: no required module provides package rsc.io/quote; to add it:\n\tcd '$WORK(\\|/)gopath(\\|/)src(\\|/)a'\n\tgo get rsc.io/quote' diff --git a/src/cmd/go/testdata/script/work_env.txt b/src/cmd/go/testdata/script/work_env.txt new file mode 100644 index 0000000000..de67255696 --- /dev/null +++ b/src/cmd/go/testdata/script/work_env.txt @@ -0,0 +1,24 @@ +go env GOWORK +stdout '^'$GOPATH'[\\/]src[\\/]go.work$' +go env +stdout '^(set )?GOWORK="?'$GOPATH'[\\/]src[\\/]go.work"?$' + +cd .. +go env GOWORK +! stdout . +go env +stdout 'GOWORK=("")?' + +cd src +go env GOWORK +stdout 'go.work' + +! go env -w GOWORK=off +stderr '^go: GOWORK cannot be modified$' + +-- go.work -- +go 1.18 + +directory a +-- a/go.mod -- +module example.com/a From d7149e502dfb13fdc94439eebaf1823a6c6dd84f Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 20 Oct 2021 00:09:09 +0700 Subject: [PATCH 081/406] reflect: restore Value.Pointer implementation CL 350691 added Value.UnsafePointer and make Value.Pointer call it internally. It has a downside that Value.Pointer can now eligible to be inlined, thus making un-intentional side effect, like the test in fixedbugs/issue15329.go becomes flaky. This CL restore Value.Pointer original implementation, pre CL 350691, with the deprecation TODO removed. Fixes #49067 Change-Id: I735af182f8e729294333ca906ffc062f477cfc99 Reviewed-on: https://go-review.googlesource.com/c/go/+/356949 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Keith Randall --- src/reflect/value.go | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/reflect/value.go b/src/reflect/value.go index 1d385f6bf9..63faa04964 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -1936,7 +1936,42 @@ func (v Value) OverflowUint(x uint64) bool { // // Deprecated: use uintptr(Value.UnsafePointer()) to get the equivalent result. func (v Value) Pointer() uintptr { - return uintptr(v.UnsafePointer()) + k := v.kind() + switch k { + case Ptr: + if v.typ.ptrdata == 0 { + // Handle pointers to go:notinheap types directly, + // so we never materialize such pointers as an + // unsafe.Pointer. (Such pointers are always indirect.) + // See issue 42076. + return *(*uintptr)(v.ptr) + } + fallthrough + case Chan, Map, UnsafePointer: + return uintptr(v.pointer()) + case Func: + if v.flag&flagMethod != 0 { + // As the doc comment says, the returned pointer is an + // underlying code pointer but not necessarily enough to + // identify a single function uniquely. All method expressions + // created via reflect have the same underlying code pointer, + // so their Pointers are equal. The function used here must + // match the one used in makeMethodValue. + f := methodValueCall + return **(**uintptr)(unsafe.Pointer(&f)) + } + p := v.pointer() + // Non-nil func value points at data block. + // First word of data block is actual code. + if p != nil { + p = *(*unsafe.Pointer)(p) + } + return uintptr(p) + + case Slice: + return (*SliceHeader)(v.ptr).Data + } + panic(&ValueError{"reflect.Value.Pointer", v.kind()}) } // Recv receives and returns a value from the channel v. From 07e5527249cb0b152a3807d67ea83bafd71d2496 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 20 Oct 2021 00:16:23 +0700 Subject: [PATCH 082/406] reflect: fix methodValueCall code pointer mismatch in Value.Pointer This is the port of CL 356809 for Value.Pointer to fix the mismatch of methodValueCall code pointer. Change-Id: I080ac41b94b44d878cd5896207a76a28c57fd48b Reviewed-on: https://go-review.googlesource.com/c/go/+/356950 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- src/reflect/all_test.go | 7 +++++-- src/reflect/value.go | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 91aac9cccb..fcd0e15f0a 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -7724,9 +7724,12 @@ func TestNotInHeapDeref(t *testing.T) { } func TestMethodCallValueCodePtr(t *testing.T) { - p := ValueOf(Point{}).Method(1).UnsafePointer() + m := ValueOf(Point{}).Method(1) want := MethodValueCallCodePtr() - if got := uintptr(p); got != want { + if got := uintptr(m.UnsafePointer()); got != want { + t.Errorf("methodValueCall code pointer mismatched, want: %v, got: %v", want, got) + } + if got := m.Pointer(); got != want { t.Errorf("methodValueCall code pointer mismatched, want: %v, got: %v", want, got) } } diff --git a/src/reflect/value.go b/src/reflect/value.go index 63faa04964..7bb8ae5b97 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -1957,8 +1957,7 @@ func (v Value) Pointer() uintptr { // created via reflect have the same underlying code pointer, // so their Pointers are equal. The function used here must // match the one used in makeMethodValue. - f := methodValueCall - return **(**uintptr)(unsafe.Pointer(&f)) + return methodValueCallCodePtr() } p := v.pointer() // Non-nil func value points at data block. From 1b24c9e42e527b93a39b6a6b16c20672dd2d9a03 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 19 Oct 2021 13:44:01 -0700 Subject: [PATCH 083/406] go/types, types2: always accept type parameters when running Manual test This makes it easier to run tests on existing generic code that is not using the `.go2` ending currently used by type checker tests. For #49074. Change-Id: I1501463c55dbe1d709918786e1a43b6d1bf1629a Reviewed-on: https://go-review.googlesource.com/c/go/+/357050 Trust: Robert Griesemer Run-TryBot: Robert Griesemer Reviewed-by: Robert Findley TryBot-Result: Go Bot --- src/cmd/compile/internal/types2/check_test.go | 2 +- src/go/types/check_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/types2/check_test.go b/src/cmd/compile/internal/types2/check_test.go index bc68e76407..e71df87f2c 100644 --- a/src/cmd/compile/internal/types2/check_test.go +++ b/src/cmd/compile/internal/types2/check_test.go @@ -99,7 +99,7 @@ func testFiles(t *testing.T, filenames []string, colDelta uint, manual bool) { } var mode syntax.Mode - if strings.HasSuffix(filenames[0], ".go2") { + if strings.HasSuffix(filenames[0], ".go2") || manual { mode |= syntax.AllowGenerics } // parse files and collect parser errors diff --git a/src/go/types/check_test.go b/src/go/types/check_test.go index e9df90c4ea..e6176738d1 100644 --- a/src/go/types/check_test.go +++ b/src/go/types/check_test.go @@ -210,7 +210,7 @@ func testFiles(t *testing.T, sizes Sizes, filenames []string, srcs [][]byte, man } mode := parser.AllErrors - if !strings.HasSuffix(filenames[0], ".go2") { + if !strings.HasSuffix(filenames[0], ".go2") && !manual { mode |= typeparams.DisallowParsing } From 9fa85518ff84420af644b1dd82ff311a39cd99c1 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Mon, 18 Oct 2021 12:19:07 -0700 Subject: [PATCH 084/406] cmd/compile: substitute "". prefix with package in more import locations The "" stand-in for the current package needs to be substituted in more places when importing, because of generics. ""..dict.conv4["".MyString] when imported in main and then exported, this becomes a..dict.conv4["".MyString] and then the linker makes that into a..dict.conv4[main.MyString] Which isn't correct. We need to replace on import not just function names, but also globals, which this CL does. Change-Id: Ia04a23b5ffd60aeeaba72c807f69261105670f8e Reviewed-on: https://go-review.googlesource.com/c/go/+/356570 Trust: Keith Randall Trust: Dan Scales Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/typecheck/iimport.go | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index 52236ce837..6351fc37de 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -176,7 +176,7 @@ func ReadImports(pkg *types.Pkg, data string) { } for nSyms := ird.uint64(); nSyms > 0; nSyms-- { - s := pkg.Lookup(p.stringAt(ird.uint64())) + s := pkg.Lookup(p.nameAt(ird.uint64())) off := ird.uint64() if _, ok := DeclImporter[s]; !ok { @@ -188,18 +188,9 @@ func ReadImports(pkg *types.Pkg, data string) { // Inline body index. for nPkgs := ird.uint64(); nPkgs > 0; nPkgs-- { pkg := p.pkgAt(ird.uint64()) - pkgPrefix := pkg.Prefix + "." for nSyms := ird.uint64(); nSyms > 0; nSyms-- { - s2 := p.stringAt(ird.uint64()) - // Function/method instantiation names may include "" to - // represent the path name of the imported package (in type - // names), so replace "" with pkg.Prefix. The "" in the names - // will get replaced by the linker as well, so will not - // appear in the executable. Include the dot to avoid - // matching with struct tags ending in '"'. - s2 = strings.Replace(s2, "\"\".", pkgPrefix, -1) - s := pkg.Lookup(s2) + s := pkg.Lookup(p.nameAt(ird.uint64())) off := ird.uint64() if _, ok := inlineImporter[s]; !ok { @@ -233,6 +224,22 @@ func (p *iimporter) stringAt(off uint64) string { return p.stringData[spos : spos+slen] } +// nameAt is the same as stringAt, except it replaces instances +// of "" with the path of the package being imported. +func (p *iimporter) nameAt(off uint64) string { + s := p.stringAt(off) + // Names of objects (functions, methods, globals) may include "" + // to represent the path name of the imported package. + // Replace "" with the imported package prefix. This occurs + // specifically for generics where the names of instantiations + // and dictionaries contain package-qualified type names. + // Include the dot to avoid matching with struct tags ending in '"'. + if strings.Contains(s, "\"\".") { + s = strings.Replace(s, "\"\".", p.ipkg.Prefix+".", -1) + } + return s +} + func (p *iimporter) posBaseAt(off uint64) *src.PosBase { if posBase, ok := p.posBaseCache[off]; ok { return posBase @@ -288,6 +295,7 @@ func (p *iimporter) newReader(off uint64, pkg *types.Pkg) *importReader { } func (r *importReader) string() string { return r.p.stringAt(r.uint64()) } +func (r *importReader) name() string { return r.p.nameAt(r.uint64()) } func (r *importReader) posBase() *src.PosBase { return r.p.posBaseAt(r.uint64()) } func (r *importReader) pkg() *types.Pkg { return r.p.pkgAt(r.uint64()) } @@ -539,7 +547,7 @@ func (r *importReader) localIdent() *types.Sym { return r.ident(false) } func (r *importReader) selector() *types.Sym { return r.ident(true) } func (r *importReader) qualifiedIdent() *ir.Ident { - name := r.string() + name := r.name() pkg := r.pkg() sym := pkg.Lookup(name) return ir.NewIdent(src.NoXPos, sym) From 2be5b846650aa4674a4eca7c11f303673b69a35a Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Mon, 18 Oct 2021 10:59:29 -0700 Subject: [PATCH 085/406] cmd/compile: allow importing and exporting of ODYNAMICTYPE Change-Id: I2fca7a801c85ed93c002c23bfcb0cf9593f1bdf4 Reviewed-on: https://go-review.googlesource.com/c/go/+/356571 Trust: Keith Randall Trust: Dan Scales Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/typecheck/iexport.go | 13 +++++++ src/cmd/compile/internal/typecheck/iimport.go | 8 +++++ test/typeparam/issue49027.dir/a.go | 34 +++++++++++++++++++ test/typeparam/issue49027.dir/main.go | 8 +++++ 4 files changed, 63 insertions(+) diff --git a/src/cmd/compile/internal/typecheck/iexport.go b/src/cmd/compile/internal/typecheck/iexport.go index e3dd10a56b..46865ba3fa 100644 --- a/src/cmd/compile/internal/typecheck/iexport.go +++ b/src/cmd/compile/internal/typecheck/iexport.go @@ -1763,6 +1763,19 @@ func (w *exportWriter) expr(n ir.Node) { w.op(ir.OTYPE) w.typ(n.Type()) + case ir.ODYNAMICTYPE: + n := n.(*ir.DynamicType) + w.op(ir.ODYNAMICTYPE) + w.pos(n.Pos()) + w.expr(n.X) + if n.ITab != nil { + w.bool(true) + w.expr(n.ITab) + } else { + w.bool(false) + } + w.typ(n.Type()) + case ir.OTYPESW: n := n.(*ir.TypeSwitchGuard) w.op(ir.OTYPESW) diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index 6351fc37de..cb1e56bf51 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -1312,6 +1312,14 @@ func (r *importReader) node() ir.Node { case ir.OTYPE: return ir.TypeNode(r.typ()) + case ir.ODYNAMICTYPE: + n := ir.NewDynamicType(r.pos(), r.expr()) + if r.bool() { + n.ITab = r.expr() + } + n.SetType(r.typ()) + return n + case ir.OTYPESW: pos := r.pos() var tag *ir.Ident diff --git a/test/typeparam/issue49027.dir/a.go b/test/typeparam/issue49027.dir/a.go index d3ec27deab..da88297965 100644 --- a/test/typeparam/issue49027.dir/a.go +++ b/test/typeparam/issue49027.dir/a.go @@ -15,7 +15,41 @@ func conv[T any](v interface{}) T { func Conv2(v interface{}) (string, bool) { return conv2[string](v) } + func conv2[T any](v interface{}) (T, bool) { x, ok := v.(T) return x, ok } + +func Conv3(v interface{}) string { + return conv3[string](v) +} + +func conv3[T any](v interface{}) T { + switch v := v.(type) { + case T: + return v + default: + var z T + return z + } +} + +type Mystring string + +func (Mystring) Foo() { +} + +func Conv4(v interface{Foo()}) Mystring { + return conv4[Mystring](v) +} + +func conv4[T interface{Foo()}](v interface{Foo()}) T { + switch v := v.(type) { + case T: + return v + default: + var z T + return z + } +} diff --git a/test/typeparam/issue49027.dir/main.go b/test/typeparam/issue49027.dir/main.go index d0dc33d734..aa20a2fdfb 100644 --- a/test/typeparam/issue49027.dir/main.go +++ b/test/typeparam/issue49027.dir/main.go @@ -22,4 +22,12 @@ func main() { if y != s { panic(fmt.Sprintf("got %s wanted %s", y, s)) } + z := a.Conv3(s) + if z != s { + panic(fmt.Sprintf("got %s wanted %s", z, s)) + } + w := a.Conv4(a.Mystring(s)) + if w != a.Mystring(s) { + panic(fmt.Sprintf("got %s wanted %s", w, s)) + } } From 4cc6a919077f27d9255536d6539118e65c1650a2 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 14 Oct 2021 10:04:10 -0700 Subject: [PATCH 086/406] cmd/compile/internal/types2: implement generic conversions Fixes #47150. Change-Id: I7531ca5917d4e52ca0b9211d6f2114495b19ba09 Reviewed-on: https://go-review.googlesource.com/c/go/+/356010 Trust: Robert Griesemer Reviewed-by: Robert Findley --- .../compile/internal/types2/conversions.go | 33 +++++ .../types2/testdata/examples/conversions.go2 | 130 ++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 src/cmd/compile/internal/types2/testdata/examples/conversions.go2 diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index 6c26a4c446..8cd74b8f9a 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -89,6 +89,39 @@ func (x *operand) convertibleTo(check *Checker, T Type) bool { return true } + // TODO(gri) consider passing under(x.typ), under(T) into convertibleToImpl (optimization) + Vp, _ := under(x.typ).(*TypeParam) + Tp, _ := under(T).(*TypeParam) + + // generic cases + // (generic operands cannot be constants, so we can ignore x.val) + switch { + case Vp != nil && Tp != nil: + x := *x // don't modify outer x + return Vp.underIs(func(V Type) bool { + x.typ = V + return Tp.underIs(func(T Type) bool { + return x.convertibleToImpl(check, T) + }) + }) + case Vp != nil: + x := *x // don't modify outer x + return Vp.underIs(func(V Type) bool { + x.typ = V + return x.convertibleToImpl(check, T) + }) + case Tp != nil: + return Tp.underIs(func(T Type) bool { + return x.convertibleToImpl(check, T) + }) + } + + // non-generic case + return x.convertibleToImpl(check, T) +} + +// convertibleToImpl should only be called by convertibleTo +func (x *operand) convertibleToImpl(check *Checker, T Type) bool { // "x's type and T have identical underlying types if tags are ignored" V := x.typ Vu := under(V) diff --git a/src/cmd/compile/internal/types2/testdata/examples/conversions.go2 b/src/cmd/compile/internal/types2/testdata/examples/conversions.go2 new file mode 100644 index 0000000000..7e9e9745bb --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/examples/conversions.go2 @@ -0,0 +1,130 @@ +// Copyright 2021 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 conversions + +import "unsafe" + +// "x is assignable to T" +// - tested via assignability tests + +// "x's type and T have identical underlying types if tags are ignored" + +func _[X ~int, T ~int](x X) T { return T(x) } +func _[X struct{f int "foo"}, T struct{f int "bar"}](x X) T { return T(x) } + +type Foo struct{f int "foo"} +type Bar struct{f int "bar"} +type Far struct{f float64 } + +func _[X Foo, T Bar](x X) T { return T(x) } +func _[X Foo|Bar, T Bar](x X) T { return T(x) } +func _[X Foo, T Foo|Bar](x X) T { return T(x) } +func _[X Foo, T Far](x X) T { return T(x /* ERROR cannot convert */ ) } + +// "x's type and T are unnamed pointer types and their pointer base types +// have identical underlying types if tags are ignored" + +func _[X ~*Foo, T ~*Bar](x X) T { return T(x) } +func _[X ~*Foo|~*Bar, T ~*Bar](x X) T { return T(x) } +func _[X ~*Foo, T ~*Foo|~*Bar](x X) T { return T(x) } +func _[X ~*Foo, T ~*Far](x X) T { return T(x /* ERROR cannot convert */ ) } + +// "x's type and T are both integer or floating point types" + +func _[X Integer, T Integer](x X) T { return T(x) } +func _[X Unsigned, T Integer](x X) T { return T(x) } +func _[X Float, T Integer](x X) T { return T(x) } + +func _[X Integer, T Unsigned](x X) T { return T(x) } +func _[X Unsigned, T Unsigned](x X) T { return T(x) } +func _[X Float, T Unsigned](x X) T { return T(x) } + +func _[X Integer, T Float](x X) T { return T(x) } +func _[X Unsigned, T Float](x X) T { return T(x) } +func _[X Float, T Float](x X) T { return T(x) } + +func _[X, T Integer|Unsigned|Float](x X) T { return T(x) } +func _[X, T Integer|~string](x X) T { return T(x /* ERROR cannot convert */ ) } + +// "x's type and T are both complex types" + +func _[X, T Complex](x X) T { return T(x) } +func _[X, T Float|Complex](x X) T { return T(x /* ERROR cannot convert */ ) } + +// "x is an integer or a slice of bytes or runes and T is a string type" + +type myInt int +type myString string + +func _[T ~string](x int) T { return T(x) } +func _[T ~string](x myInt) T { return T(x) } +func _[X Integer](x X) string { return string(x) } +func _[X Integer](x X) myString { return myString(x) } +func _[X Integer](x X) *string { return (*string)(x /* ERROR cannot convert */ ) } + +func _[T ~string](x []byte) T { return T(x) } +func _[T ~string](x []rune) T { return T(x) } +func _[X ~[]byte, T ~string](x X) T { return T(x) } +func _[X ~[]rune, T ~string](x X) T { return T(x) } +func _[X Integer|~[]byte|~[]rune, T ~string](x X) T { return T(x) } +func _[X Integer|~[]byte|~[]rune, T ~*string](x X) T { return T(x /* ERROR cannot convert */ ) } + +// "x is a string and T is a slice of bytes or runes" + +func _[T ~[]byte](x string) T { return T(x) } +func _[T ~[]rune](x string) T { return T(x) } +func _[T ~[]rune](x *string) T { return T(x /* ERROR cannot convert */ ) } + +func _[X ~string, T ~[]byte](x X) T { return T(x) } +func _[X ~string, T ~[]rune](x X) T { return T(x) } +func _[X ~string, T ~[]byte|~[]rune](x X) T { return T(x) } +func _[X ~*string, T ~[]byte|~[]rune](x X) T { return T(x /* ERROR cannot convert */ ) } + +// package unsafe: +// "any pointer or value of underlying type uintptr can be converted into a unsafe.Pointer" + +type myUintptr uintptr + +func _[X ~uintptr](x X) unsafe.Pointer { return unsafe.Pointer(x) } +func _[T unsafe.Pointer](x myUintptr) T { return T(x) } +func _[T unsafe.Pointer](x int64) T { return T(x /* ERROR cannot convert */ ) } + +// "and vice versa" + +func _[T ~uintptr](x unsafe.Pointer) T { return T(x) } +func _[X unsafe.Pointer](x X) uintptr { return uintptr(x) } +func _[X unsafe.Pointer](x X) myUintptr { return myUintptr(x) } +func _[X unsafe.Pointer](x X) int64 { return int64(x /* ERROR cannot convert */ ) } + +// "x is a slice, T is a pointer-to-array type, +// and the slice and array types have identical element types." + +func _[X ~[]E, T ~*[10]E, E any](x X) T { return T(x) } +func _[X ~[]E, T ~[10]E, E any](x X) T { return T(x /* ERROR cannot convert */ ) } + +// ---------------------------------------------------------------------------- +// The following declarations can be replaced by the exported types of the +// constraints package once all builders support importing interfaces with +// type constraints. + +type Signed interface { + ~int | ~int8 | ~int16 | ~int32 | ~int64 +} + +type Unsigned interface { + ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr +} + +type Integer interface { + Signed | Unsigned +} + +type Float interface { + ~float32 | ~float64 +} + +type Complex interface { + ~complex64 | ~complex128 +} From b091189762980836527c4aa50e3693632aea5144 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 20 Oct 2021 09:55:26 +0700 Subject: [PATCH 087/406] cmd/compile/internal/types2: print assignment operation for invalid operation errors When invoking check.binary for assignment operation, the expression will be nil, thus for printing the assignment operation error message, we need to reconstruct the statement from lhs, op, rhs. Fixes #48472 Change-Id: Ie38c3dd8069b47e508968d6e43cedcf7536559ef Reviewed-on: https://go-review.googlesource.com/c/go/+/357229 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/types2/expr.go | 6 +++++- .../internal/types2/testdata/fixedbugs/issue48472.go2 | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index 2d22c027eb..1001554739 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -1025,7 +1025,11 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op // only report an error if we have valid types // (otherwise we had an error reported elsewhere already) if x.typ != Typ[Invalid] && y.typ != Typ[Invalid] { - check.errorf(x, invalidOp+"%s (mismatched types %s and %s)", e, x.typ, y.typ) + if e != nil { + check.errorf(x, invalidOp+"%s (mismatched types %s and %s)", e, x.typ, y.typ) + } else { + check.errorf(x, invalidOp+"%s %s= %s (mismatched types %s and %s)", lhs, op, rhs, x.typ, y.typ) + } } x.mode = invalid return diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48472.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48472.go2 index 5fefcaf22b..2d908f4c8b 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48472.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48472.go2 @@ -9,3 +9,8 @@ func g() { var i int _ = s /* ERROR invalid operation: s \+ i \(mismatched types string and int\) */ + i } + +func f(i int) int { + i /* ERROR invalid operation: i \+= "1" \(mismatched types int and untyped string\) */ += "1" + return i +} From d9421cec00a5e171699b00966bebc85a36593bf2 Mon Sep 17 00:00:00 2001 From: Alexander Yastrebov Date: Sat, 16 Oct 2021 02:19:20 +0000 Subject: [PATCH 088/406] net/http/internal: return unexpected EOF on incomplete chunk read MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #48861 Change-Id: I3f55bfbdc4f2cf5b33d1ab2d76e01335bb497c6f GitHub-Last-Rev: 0ecd790b87ddd31d0cf08e8f2726f918a2edd1fb GitHub-Pull-Request: golang/go#48903 Reviewed-on: https://go-review.googlesource.com/c/go/+/355029 Trust: Damien Neil Trust: Daniel Martí Run-TryBot: Damien Neil TryBot-Result: Go Bot Reviewed-by: Damien Neil --- src/net/http/internal/chunked.go | 7 +++++++ src/net/http/internal/chunked_test.go | 28 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/net/http/internal/chunked.go b/src/net/http/internal/chunked.go index 923e6a6d2c..37a72e9031 100644 --- a/src/net/http/internal/chunked.go +++ b/src/net/http/internal/chunked.go @@ -81,6 +81,11 @@ func (cr *chunkedReader) Read(b []uint8) (n int, err error) { cr.err = errors.New("malformed chunked encoding") break } + } else { + if cr.err == io.EOF { + cr.err = io.ErrUnexpectedEOF + } + break } cr.checkEnd = false } @@ -109,6 +114,8 @@ func (cr *chunkedReader) Read(b []uint8) (n int, err error) { // bytes to verify they are "\r\n". if cr.n == 0 && cr.err == nil { cr.checkEnd = true + } else if cr.err == io.EOF { + cr.err = io.ErrUnexpectedEOF } } return n, cr.err diff --git a/src/net/http/internal/chunked_test.go b/src/net/http/internal/chunked_test.go index 08152ed1e2..5e29a786dd 100644 --- a/src/net/http/internal/chunked_test.go +++ b/src/net/http/internal/chunked_test.go @@ -11,6 +11,7 @@ import ( "io" "strings" "testing" + "testing/iotest" ) func TestChunk(t *testing.T) { @@ -211,3 +212,30 @@ func TestChunkReadPartial(t *testing.T) { } } + +// Issue 48861: ChunkedReader should report incomplete chunks +func TestIncompleteChunk(t *testing.T) { + const valid = "4\r\nabcd\r\n" + "5\r\nabc\r\n\r\n" + "0\r\n" + + for i := 0; i < len(valid); i++ { + incomplete := valid[:i] + r := NewChunkedReader(strings.NewReader(incomplete)) + if _, err := io.ReadAll(r); err != io.ErrUnexpectedEOF { + t.Errorf("expected io.ErrUnexpectedEOF for %q, got %v", incomplete, err) + } + } + + r := NewChunkedReader(strings.NewReader(valid)) + if _, err := io.ReadAll(r); err != nil { + t.Errorf("unexpected error for %q: %v", valid, err) + } +} + +func TestChunkEndReadError(t *testing.T) { + readErr := fmt.Errorf("chunk end read error") + + r := NewChunkedReader(io.MultiReader(strings.NewReader("4\r\nabcd"), iotest.ErrReader(readErr))) + if _, err := io.ReadAll(r); err != readErr { + t.Errorf("expected %v, got %v", readErr, err) + } +} From d2ec73c1bfb556c5736f900a8e4a07e281450eb2 Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 20 Oct 2021 07:46:23 +0000 Subject: [PATCH 089/406] math/big: remove stray whitespace in addMulVVW on amd64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Minor leftover from CL 74851. Change-Id: I1b56afcde3c505ba77a0f79e8ae9b01000362298 GitHub-Last-Rev: 87e97571a58d5eadd63a28226543aaf1510a7b02 GitHub-Pull-Request: golang/go#48942 Reviewed-on: https://go-review.googlesource.com/c/go/+/355629 Reviewed-by: Robert Griesemer Trust: Daniel Martí Trust: Alexander Rakoczy --- src/math/big/arith_amd64.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/math/big/arith_amd64.s b/src/math/big/arith_amd64.s index 59be952200..5c72a27d8d 100644 --- a/src/math/big/arith_amd64.s +++ b/src/math/big/arith_amd64.s @@ -379,7 +379,7 @@ E5: CMPQ BX, R11 // i < n // func addMulVVW(z, x []Word, y Word) (c Word) TEXT ·addMulVVW(SB),NOSPLIT,$0 - CMPB ·support_adx(SB), $1 + CMPB ·support_adx(SB), $1 JEQ adx MOVQ z+0(FP), R10 MOVQ x+24(FP), R8 From 27a1454ee09b1923ddcf0cdc5e17b4dd7de8ea2a Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Wed, 20 Oct 2021 10:43:43 -0400 Subject: [PATCH 090/406] cmd/internal/goobj: minor dead code cleanup Remove a bit of dead code from the Go object file reader (io.ReaderAt no longer needed in goobj.Reader). Change-Id: I04150d37fb90b59c9dbe930878d4dd21cdcd7ca7 Reviewed-on: https://go-review.googlesource.com/c/go/+/357309 Trust: Than McIntosh Run-TryBot: Than McIntosh Reviewed-by: Cherry Mui TryBot-Result: Go Bot --- src/cmd/internal/goobj/objfile.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cmd/internal/goobj/objfile.go b/src/cmd/internal/goobj/objfile.go index 2c44696f84..4dfea84539 100644 --- a/src/cmd/internal/goobj/objfile.go +++ b/src/cmd/internal/goobj/objfile.go @@ -19,14 +19,12 @@ package goobj import ( - "bytes" "cmd/internal/bio" "crypto/sha1" "encoding/binary" "errors" "fmt" "internal/unsafeheader" - "io" "unsafe" ) @@ -594,13 +592,12 @@ type Reader struct { b []byte // mmapped bytes, if not nil readonly bool // whether b is backed with read-only memory - rd io.ReaderAt start uint32 h Header // keep block offsets } func NewReaderFromBytes(b []byte, readonly bool) *Reader { - r := &Reader{b: b, readonly: readonly, rd: bytes.NewReader(b), start: 0} + r := &Reader{b: b, readonly: readonly, start: 0} err := r.h.Read(r) if err != nil { return nil From 4e565f7372494c9c46e33a35e84f0fe4fc7d2774 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Mon, 18 Oct 2021 14:31:48 +0700 Subject: [PATCH 091/406] cmd/compile: fix crawling of embeddable types during inline In CL 327872, there's a fix for crawling of embeddable types directly reached by the user, so all of its methods need to be re-exported. But we missed the cased when an un-exported type may be reachable by embedding in exported type. Example: type t struct {} func (t) M() {} func F() interface{} { return struct{ t }{} } We generate the wrapper for "struct{ t }".M, and when inlining call to "struct{ t }".M makes "t.M" reachable. It works well, and only be revealed in CL 327871, when we changed methodWrapper to always call inline.InlineCalls, thus causes the crash in #49016, which involve dot type in inlined function. Fixes #49016 Change-Id: If174fa5575132da5cf60e4bd052f7011c4e76c5d Reviewed-on: https://go-review.googlesource.com/c/go/+/356254 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/typecheck/crawler.go | 33 ++++++++++++----- test/fixedbugs/issue49016.dir/a.go | 36 +++++++++++++++++++ test/fixedbugs/issue49016.dir/b.go | 13 +++++++ test/fixedbugs/issue49016.dir/c.go | 9 +++++ test/fixedbugs/issue49016.dir/d.go | 9 +++++ test/fixedbugs/issue49016.dir/e.go | 11 ++++++ test/fixedbugs/issue49016.dir/f.go | 9 +++++ test/fixedbugs/issue49016.dir/g.go | 9 +++++ test/fixedbugs/issue49016.go | 7 ++++ 9 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 test/fixedbugs/issue49016.dir/a.go create mode 100644 test/fixedbugs/issue49016.dir/b.go create mode 100644 test/fixedbugs/issue49016.dir/c.go create mode 100644 test/fixedbugs/issue49016.dir/d.go create mode 100644 test/fixedbugs/issue49016.dir/e.go create mode 100644 test/fixedbugs/issue49016.dir/f.go create mode 100644 test/fixedbugs/issue49016.dir/g.go create mode 100644 test/fixedbugs/issue49016.go diff --git a/src/cmd/compile/internal/typecheck/crawler.go b/src/cmd/compile/internal/typecheck/crawler.go index 667e76e130..b214ef2279 100644 --- a/src/cmd/compile/internal/typecheck/crawler.go +++ b/src/cmd/compile/internal/typecheck/crawler.go @@ -195,18 +195,35 @@ func (p *crawler) markInlBody(n *ir.Name) { var doFlood func(n ir.Node) doFlood = func(n ir.Node) { t := n.Type() - if t != nil && (t.HasTParam() || t.IsFullyInstantiated()) { - // Ensure that we call markType() on any base generic type - // that is written to the export file (even if not explicitly - // marked for export), so we will call markInlBody on its - // methods, and the methods will be available for - // instantiation if needed. - p.markType(t) + if t != nil { + if t.HasTParam() || t.IsFullyInstantiated() { + // Ensure that we call markType() on any base generic type + // that is written to the export file (even if not explicitly + // marked for export), so we will call markInlBody on its + // methods, and the methods will be available for + // instantiation if needed. + p.markType(t) + } + if base.Debug.Unified == 0 { + // If a method of un-exported type is promoted and accessible by + // embedding in an exported type, it makes that type reachable. + // + // Example: + // + // type t struct {} + // func (t) M() {} + // + // func F() interface{} { return struct{ t }{} } + // + // We generate the wrapper for "struct{ t }".M, and inline call + // to "struct{ t }".M, which makes "t.M" reachable. + p.markEmbed(t) + } } + switch n.Op() { case ir.OMETHEXPR, ir.ODOTMETH: p.markInlBody(ir.MethodExprName(n)) - case ir.ONAME: n := n.(*ir.Name) switch n.Class { diff --git a/test/fixedbugs/issue49016.dir/a.go b/test/fixedbugs/issue49016.dir/a.go new file mode 100644 index 0000000000..36639b73d4 --- /dev/null +++ b/test/fixedbugs/issue49016.dir/a.go @@ -0,0 +1,36 @@ +// Copyright 2021 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 a + +type Node interface { + Position() +} + +type noder struct{} + +func (noder) Position() {} + +type Scope map[int][]Node + +func (s Scope) M1() Scope { + if x, ok := s[0]; ok { + return x[0].(struct { + noder + Scope + }).Scope + } + return nil +} + +func (s Scope) M2() Scope { + if x, ok := s[0]; ok { + st, _ := x[0].(struct { + noder + Scope + }) + return st.Scope + } + return nil +} diff --git a/test/fixedbugs/issue49016.dir/b.go b/test/fixedbugs/issue49016.dir/b.go new file mode 100644 index 0000000000..1dd63f87b6 --- /dev/null +++ b/test/fixedbugs/issue49016.dir/b.go @@ -0,0 +1,13 @@ +// Copyright 2021 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 b + +type t int + +func (t) m() {} + +func F1() interface{} { return struct{ t }{} } +func F2() interface{} { return *new(struct{ t }) } +func F3() interface{} { var x [1]struct{ t }; return x[0] } diff --git a/test/fixedbugs/issue49016.dir/c.go b/test/fixedbugs/issue49016.dir/c.go new file mode 100644 index 0000000000..2cc6681b95 --- /dev/null +++ b/test/fixedbugs/issue49016.dir/c.go @@ -0,0 +1,9 @@ +// Copyright 2021 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 c + +import "./a" + +var _ = (&a.Scope{}).M1() diff --git a/test/fixedbugs/issue49016.dir/d.go b/test/fixedbugs/issue49016.dir/d.go new file mode 100644 index 0000000000..e933dc08e4 --- /dev/null +++ b/test/fixedbugs/issue49016.dir/d.go @@ -0,0 +1,9 @@ +// Copyright 2021 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 d + +import "./a" + +var _ = (&a.Scope{}).M2() diff --git a/test/fixedbugs/issue49016.dir/e.go b/test/fixedbugs/issue49016.dir/e.go new file mode 100644 index 0000000000..5f43179c37 --- /dev/null +++ b/test/fixedbugs/issue49016.dir/e.go @@ -0,0 +1,11 @@ +// Copyright 2021 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 e + +import ( + "./b" +) + +var _ = b.F1() diff --git a/test/fixedbugs/issue49016.dir/f.go b/test/fixedbugs/issue49016.dir/f.go new file mode 100644 index 0000000000..2cd978eace --- /dev/null +++ b/test/fixedbugs/issue49016.dir/f.go @@ -0,0 +1,9 @@ +// Copyright 2021 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 f + +import "./b" + +var _ = b.F2() diff --git a/test/fixedbugs/issue49016.dir/g.go b/test/fixedbugs/issue49016.dir/g.go new file mode 100644 index 0000000000..b90353fcff --- /dev/null +++ b/test/fixedbugs/issue49016.dir/g.go @@ -0,0 +1,9 @@ +// Copyright 2021 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 g + +import "./b" + +var _ = b.F3() diff --git a/test/fixedbugs/issue49016.go b/test/fixedbugs/issue49016.go new file mode 100644 index 0000000000..b83fbd7af1 --- /dev/null +++ b/test/fixedbugs/issue49016.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2021 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 ignored From 4320949f36f5f523a08ce8da6bdcd35ef51b8941 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Wed, 20 Oct 2021 14:54:13 -0400 Subject: [PATCH 092/406] go/internal/gcimporter: avoid setting unnecessary lines in fakeFileSet This is a clean port of CL 357291 from x/tools. For #46586 Change-Id: Ib22087ae7fe8477d368acd230b263b83cdad4d36 Reviewed-on: https://go-review.googlesource.com/c/go/+/357429 Trust: Robert Findley Run-TryBot: Robert Findley Reviewed-by: Matthew Dempsky TryBot-Result: Go Bot --- src/go/internal/gcimporter/iimport.go | 3 +- src/go/internal/gcimporter/support.go | 47 +++++++++++++++++---------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/go/internal/gcimporter/iimport.go b/src/go/internal/gcimporter/iimport.go index 9aae2a31f3..0771fa3c26 100644 --- a/src/go/internal/gcimporter/iimport.go +++ b/src/go/internal/gcimporter/iimport.go @@ -135,9 +135,10 @@ func iImportData(fset *token.FileSet, imports map[string]*types.Package, dataRea fake: fakeFileSet{ fset: fset, - files: make(map[string]*token.File), + files: make(map[string]*fileInfo), }, } + defer p.fake.setLines() // set lines for files in fset for i, pt := range predeclared { p.typCache[uint64(i)] = pt diff --git a/src/go/internal/gcimporter/support.go b/src/go/internal/gcimporter/support.go index 09810dd85b..5aef63ec1e 100644 --- a/src/go/internal/gcimporter/support.go +++ b/src/go/internal/gcimporter/support.go @@ -25,37 +25,50 @@ const deltaNewFile = -64 // Synthesize a token.Pos type fakeFileSet struct { fset *token.FileSet - files map[string]*token.File + files map[string]*fileInfo } +type fileInfo struct { + file *token.File + lastline int +} + +const maxlines = 64 * 1024 + func (s *fakeFileSet) pos(file string, line, column int) token.Pos { // TODO(mdempsky): Make use of column. - // Since we don't know the set of needed file positions, we - // reserve maxlines positions per file. - const maxlines = 64 * 1024 + // Since we don't know the set of needed file positions, we reserve + // maxlines positions per file. We delay calling token.File.SetLines until + // all positions have been calculated (by way of fakeFileSet.setLines), so + // that we can avoid setting unnecessary lines. See also golang/go#46586. f := s.files[file] if f == nil { - f = s.fset.AddFile(file, -1, maxlines) + f = &fileInfo{file: s.fset.AddFile(file, -1, maxlines)} s.files[file] = f - // Allocate the fake linebreak indices on first use. - // TODO(adonovan): opt: save ~512KB using a more complex scheme? - fakeLinesOnce.Do(func() { - fakeLines = make([]int, maxlines) - for i := range fakeLines { - fakeLines[i] = i - } - }) - f.SetLines(fakeLines) } if line > maxlines { line = 1 } + if line > f.lastline { + f.lastline = line + } - // Treat the file as if it contained only newlines - // and column=1: use the line number as the offset. - return f.Pos(line - 1) + // Return a fake position assuming that f.file consists only of newlines. + return token.Pos(f.file.Base() + line - 1) +} + +func (s *fakeFileSet) setLines() { + fakeLinesOnce.Do(func() { + fakeLines = make([]int, maxlines) + for i := range fakeLines { + fakeLines[i] = i + } + }) + for _, f := range s.files { + f.file.SetLines(fakeLines[:f.lastline]) + } } var ( From 3ff39c5eda6aa869cbc3a19237750fa7cf495832 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 20 Oct 2021 12:18:40 -0700 Subject: [PATCH 093/406] cmd/compile/internal/types2: use correct types when checking generic conversions Iterate through the actual, possibly defined types of constraints when type-checking generic conversions, not the underlying types. For #47150. Change-Id: Ia7af313bf46d6f6b0ad5292ff793b030b8e2d3d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/357333 Trust: Robert Griesemer Run-TryBot: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/conversions.go | 16 ++++++++-------- .../types2/testdata/examples/conversions.go2 | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index 8cd74b8f9a..112d728188 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -98,21 +98,21 @@ func (x *operand) convertibleTo(check *Checker, T Type) bool { switch { case Vp != nil && Tp != nil: x := *x // don't modify outer x - return Vp.underIs(func(V Type) bool { - x.typ = V - return Tp.underIs(func(T Type) bool { - return x.convertibleToImpl(check, T) + return Vp.is(func(V *term) bool { + x.typ = V.typ + return Tp.is(func(T *term) bool { + return x.convertibleToImpl(check, T.typ) }) }) case Vp != nil: x := *x // don't modify outer x - return Vp.underIs(func(V Type) bool { - x.typ = V + return Vp.is(func(V *term) bool { + x.typ = V.typ return x.convertibleToImpl(check, T) }) case Tp != nil: - return Tp.underIs(func(T Type) bool { - return x.convertibleToImpl(check, T) + return Tp.is(func(T *term) bool { + return x.convertibleToImpl(check, T.typ) }) } diff --git a/src/cmd/compile/internal/types2/testdata/examples/conversions.go2 b/src/cmd/compile/internal/types2/testdata/examples/conversions.go2 index 7e9e9745bb..5c1b30a2b5 100644 --- a/src/cmd/compile/internal/types2/testdata/examples/conversions.go2 +++ b/src/cmd/compile/internal/types2/testdata/examples/conversions.go2 @@ -31,6 +31,20 @@ func _[X ~*Foo|~*Bar, T ~*Bar](x X) T { return T(x) } func _[X ~*Foo, T ~*Foo|~*Bar](x X) T { return T(x) } func _[X ~*Foo, T ~*Far](x X) T { return T(x /* ERROR cannot convert */ ) } +// Verify that the defined types in constraints are considered for the rule above. + +type ( + B int + C int + X0 *B + T0 *C +) + +func _(x X0) T0 { return T0(x /* ERROR cannot convert */ ) } // non-generic reference +func _[X X0, T T0](x X) T { return T(x /* ERROR cannot convert */ ) } +func _[T T0](x X0) T { return T(x /* ERROR cannot convert */ ) } +func _[X X0](x X) T0 { return T0(x /* ERROR cannot convert */ ) } + // "x's type and T are both integer or floating point types" func _[X Integer, T Integer](x X) T { return T(x) } From 3ec8d4b5ed5db74f84f8d493e4160e97481e436d Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Fri, 24 Sep 2021 16:01:03 +0000 Subject: [PATCH 094/406] runtime/internal/atomic: add atomic types for all functions Change-Id: I74f365316484feb819c31c77fbffd78fadfe32a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/356169 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Austin Clements Reviewed-by: Michael Pratt --- src/runtime/internal/atomic/doc.go | 18 + src/runtime/internal/atomic/types.go | 395 +++++++++++++++++++++ src/runtime/internal/atomic/types_64bit.go | 30 ++ 3 files changed, 443 insertions(+) create mode 100644 src/runtime/internal/atomic/doc.go create mode 100644 src/runtime/internal/atomic/types.go create mode 100644 src/runtime/internal/atomic/types_64bit.go diff --git a/src/runtime/internal/atomic/doc.go b/src/runtime/internal/atomic/doc.go new file mode 100644 index 0000000000..08e6b6ce0b --- /dev/null +++ b/src/runtime/internal/atomic/doc.go @@ -0,0 +1,18 @@ +// Copyright 2021 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 atomic provides atomic operations, independent of sync/atomic, +to the runtime. + +On most platforms, the compiler is aware of the functions defined +in this package, and they're replaced with platform-specific intrinsics. +On other platforms, generic implementations are made available. + +Unless otherwise noted, operations defined in this package are sequentially +consistent across threads with respect to the values they manipulate. More +specifically, operations that happen in a specific order on one thread, +will always be observed to happen in exactly that order by another thread. +*/ +package atomic diff --git a/src/runtime/internal/atomic/types.go b/src/runtime/internal/atomic/types.go new file mode 100644 index 0000000000..1a240d7c91 --- /dev/null +++ b/src/runtime/internal/atomic/types.go @@ -0,0 +1,395 @@ +// Copyright 2021 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 atomic + +import "unsafe" + +// Int32 is an atomically accessed int32 value. +// +// An Int32 must not be copied. +type Int32 struct { + noCopy noCopy + value int32 +} + +// Load accesses and returns the value atomically. +func (i *Int32) Load() int32 { + return Loadint32(&i.value) +} + +// Store updates the value atomically. +func (i *Int32) Store(value int32) { + Storeint32(&i.value, value) +} + +// CompareAndSwap atomically compares i's value with old, +// and if they're equal, swaps i's value with new. +// +// Returns true if the operation succeeded. +func (i *Int32) CompareAndSwap(old, new int32) bool { + return Casint32(&i.value, old, new) +} + +// Swap replaces i's value with new, returning +// i's value before the replacement. +func (i *Int32) Swap(new int32) int32 { + return Xchgint32(&i.value, new) +} + +// Add adds delta to i atomically, returning +// the new updated value. +// +// This operation wraps around in the usual +// two's-complement way. +func (i *Int32) Add(delta int32) int32 { + return Xaddint32(&i.value, delta) +} + +// Int64 is an atomically accessed int64 value. +// +// An Int64 must not be copied. +type Int64 struct { + noCopy noCopy + value int64 +} + +// Load accesses and returns the value atomically. +func (i *Int64) Load() int64 { + return Loadint64(&i.value) +} + +// Store updates the value atomically. +func (i *Int64) Store(value int64) { + Storeint64(&i.value, value) +} + +// CompareAndSwap atomically compares i's value with old, +// and if they're equal, swaps i's value with new. +// +// Returns true if the operation succeeded. +func (i *Int64) CompareAndSwap(old, new int64) bool { + return Casint64(&i.value, old, new) +} + +// Swap replaces i's value with new, returning +// i's value before the replacement. +func (i *Int64) Swap(new int64) int64 { + return Xchgint64(&i.value, new) +} + +// Add adds delta to i atomically, returning +// the new updated value. +// +// This operation wraps around in the usual +// two's-complement way. +func (i *Int64) Add(delta int64) int64 { + return Xaddint64(&i.value, delta) +} + +// Uint8 is an atomically accessed uint8 value. +// +// A Uint8 must not be copied. +type Uint8 struct { + noCopy noCopy + value uint8 +} + +// Load accesses and returns the value atomically. +func (u *Uint8) Load() uint8 { + return Load8(&u.value) +} + +// Store updates the value atomically. +func (u *Uint8) Store(value uint8) { + Store8(&u.value, value) +} + +// And takes value and performs a bit-wise +// "and" operation with the value of u, storing +// the result into u. +// +// The full process is performed atomically. +func (u *Uint8) And(value uint8) { + And8(&u.value, value) +} + +// Or takes value and performs a bit-wise +// "or" operation with the value of u, storing +// the result into u. +// +// The full process is performed atomically. +func (u *Uint8) Or(value uint8) { + Or8(&u.value, value) +} + +// Uint32 is an atomically accessed uint32 value. +// +// A Uint32 must not be copied. +type Uint32 struct { + noCopy noCopy + value uint32 +} + +// Load accesses and returns the value atomically. +func (u *Uint32) Load() uint32 { + return Load(&u.value) +} + +// LoadAcquire is a partially unsynchronized version +// of Load that relaxes ordering constraints. Other threads +// may observe operations that precede this operation to +// occur after it, but no operation that occurs after it +// on this thread can be observed to occur before it. +// +// WARNING: Use sparingly and with great care. +func (u *Uint32) LoadAcquire() uint32 { + return LoadAcq(&u.value) +} + +// Store updates the value atomically. +func (u *Uint32) Store(value uint32) { + Store(&u.value, value) +} + +// StoreRelease is a partially unsynchronized version +// of Store that relaxes ordering constraints. Other threads +// may observe operations that occur after this operation to +// precede it, but no operation that precedes it +// on this thread can be observed to occur after it. +// +// WARNING: Use sparingly and with great care. +func (u *Uint32) StoreRelease(value uint32) { + StoreRel(&u.value, value) +} + +// CompareAndSwap atomically compares u's value with old, +// and if they're equal, swaps u's value with new. +// +// Returns true if the operation succeeded. +func (u *Uint32) CompareAndSwap(old, new uint32) bool { + return Cas(&u.value, old, new) +} + +// CompareAndSwapRelease is a partially unsynchronized version +// of Cas that relaxes ordering constraints. Other threads +// may observe operations that occur after this operation to +// precede it, but no operation that precedes it +// on this thread can be observed to occur after it. +// +// Returns true if the operation succeeded. +// +// WARNING: Use sparingly and with great care. +func (u *Uint32) CompareAndSwapRelease(old, new uint32) bool { + return CasRel(&u.value, old, new) +} + +// Swap replaces u's value with new, returning +// u's value before the replacement. +func (u *Uint32) Swap(value uint32) uint32 { + return Xchg(&u.value, value) +} + +// And takes value and performs a bit-wise +// "and" operation with the value of u, storing +// the result into u. +// +// The full process is performed atomically. +func (u *Uint32) And(value uint32) { + And(&u.value, value) +} + +// Or takes value and performs a bit-wise +// "or" operation with the value of u, storing +// the result into u. +// +// The full process is performed atomically. +func (u *Uint32) Or(value uint32) { + Or(&u.value, value) +} + +// Add adds delta to u atomically, returning +// the new updated value. +// +// This operation wraps around in the usual +// two's-complement way. +func (u *Uint32) Add(delta int32) uint32 { + return Xadd(&u.value, delta) +} + +// Uint64 is an atomically accessed uint64 value. +// +// A Uint64 must not be copied. +type Uint64 struct { + noCopy noCopy + value uint64 +} + +// Load accesses and returns the value atomically. +func (u *Uint64) Load() uint64 { + return Load64(&u.value) +} + +// Store updates the value atomically. +func (u *Uint64) Store(value uint64) { + Store64(&u.value, value) +} + +// CompareAndSwap atomically compares u's value with old, +// and if they're equal, swaps u's value with new. +// +// Returns true if the operation succeeded. +func (u *Uint64) CompareAndSwap(old, new uint64) bool { + return Cas64(&u.value, old, new) +} + +// Swap replaces u's value with new, returning +// u's value before the replacement. +func (u *Uint64) Swap(value uint64) uint64 { + return Xchg64(&u.value, value) +} + +// Add adds delta to u atomically, returning +// the new updated value. +// +// This operation wraps around in the usual +// two's-complement way. +func (u *Uint64) Add(delta int64) uint64 { + return Xadd64(&u.value, delta) +} + +// Uintptr is an atomically accessed uintptr value. +// +// A Uintptr must not be copied. +type Uintptr struct { + noCopy noCopy + value uintptr +} + +// Load accesses and returns the value atomically. +func (u *Uintptr) Load() uintptr { + return Loaduintptr(&u.value) +} + +// LoadAcquire is a partially unsynchronized version +// of Load that relaxes ordering constraints. Other threads +// may observe operations that precede this operation to +// occur after it, but no operation that occurs after it +// on this thread can be observed to occur before it. +// +// WARNING: Use sparingly and with great care. +func (u *Uintptr) LoadAcquire() uintptr { + return LoadAcquintptr(&u.value) +} + +// Store updates the value atomically. +func (u *Uintptr) Store(value uintptr) { + Storeuintptr(&u.value, value) +} + +// StoreRelease is a partially unsynchronized version +// of Store that relaxes ordering constraints. Other threads +// may observe operations that occur after this operation to +// precede it, but no operation that precedes it +// on this thread can be observed to occur after it. +// +// WARNING: Use sparingly and with great care. +func (u *Uintptr) StoreRelease(value uintptr) { + StoreReluintptr(&u.value, value) +} + +// CompareAndSwap atomically compares u's value with old, +// and if they're equal, swaps u's value with new. +// +// Returns true if the operation succeeded. +func (u *Uintptr) CompareAndSwap(old, new uintptr) bool { + return Casuintptr(&u.value, old, new) +} + +// Swap replaces u's value with new, returning +// u's value before the replacement. +func (u *Uintptr) Swap(value uintptr) uintptr { + return Xchguintptr(&u.value, value) +} + +// Add adds delta to u atomically, returning +// the new updated value. +// +// This operation wraps around in the usual +// two's-complement way. +func (u *Uintptr) Add(delta uintptr) uintptr { + return Xadduintptr(&u.value, delta) +} + +// Float64 is an atomically accessed float64 value. +// +// A Float64 must not be copied. +type Float64 struct { + u Uint64 +} + +// Load accesses and returns the value atomically. +func (f *Float64) Load() float64 { + r := f.u.Load() + return *(*float64)(unsafe.Pointer(&r)) +} + +// Store updates the value atomically. +func (f *Float64) Store(value float64) { + f.u.Store(*(*uint64)(unsafe.Pointer(&value))) +} + +// UnsafePointer is an atomically accessed unsafe.Pointer value. +// +// Note that because of the atomicity guarantees, stores to values +// of this type never trigger a write barrier, and the relevant +// methods are suffixed with "NoWB" to indicate that explicitly. +// As a result, this type should be used carefully, and sparingly, +// mostly with values that do not live in the Go heap anyway. +// +// An UnsafePointer must not be copied. +type UnsafePointer struct { + noCopy noCopy + value unsafe.Pointer +} + +// Load accesses and returns the value atomically. +func (u *UnsafePointer) Load() unsafe.Pointer { + return Loadp(unsafe.Pointer(&u.value)) +} + +// StoreNoWB updates the value atomically. +// +// WARNING: As the name implies this operation does *not* +// perform a write barrier on value, and so this operation may +// hide pointers from the GC. Use with care and sparingly. +// It is safe to use with values not found in the Go heap. +func (u *UnsafePointer) StoreNoWB(value unsafe.Pointer) { + StorepNoWB(unsafe.Pointer(&u.value), value) +} + +// CompareAndSwapNoWB atomically (with respect to other methods) +// compares u's value with old, and if they're equal, +// swaps u's value with new. +// +// Returns true if the operation succeeded. +// +// WARNING: As the name implies this operation does *not* +// perform a write barrier on value, and so this operation may +// hide pointers from the GC. Use with care and sparingly. +// It is safe to use with values not found in the Go heap. +func (u *UnsafePointer) CompareAndSwapNoWB(old, new unsafe.Pointer) bool { + return Casp1(&u.value, old, new) +} + +// noCopy may be embedded into structs which must not be copied +// after the first use. +// +// See https://golang.org/issues/8005#issuecomment-190753527 +// for details. +type noCopy struct{} + +// Lock is a no-op used by -copylocks checker from `go vet`. +func (*noCopy) Lock() {} +func (*noCopy) Unlock() {} diff --git a/src/runtime/internal/atomic/types_64bit.go b/src/runtime/internal/atomic/types_64bit.go new file mode 100644 index 0000000000..9e5ed68419 --- /dev/null +++ b/src/runtime/internal/atomic/types_64bit.go @@ -0,0 +1,30 @@ +// Copyright 2021 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. + +//go:build amd64 || arm64 || mips64 || mips64le || ppc64 || ppc64le || riscv64 || s390x || wasm +// +build amd64 arm64 mips64 mips64le ppc64 ppc64le riscv64 s390x wasm + +package atomic + +// LoadAcquire is a partially unsynchronized version +// of Load that relaxes ordering constraints. Other threads +// may observe operations that precede this operation to +// occur after it, but no operation that occurs after it +// on this thread can be observed to occur before it. +// +// WARNING: Use sparingly and with great care. +func (u *Uint64) LoadAcquire() uint64 { + return LoadAcq64(&u.value) +} + +// StoreRelease is a partially unsynchronized version +// of Store that relaxes ordering constraints. Other threads +// may observe operations that occur after this operation to +// precede it, but no operation that precedes it +// on this thread can be observed to occur after it. +// +// WARNING: Use sparingly and with great care. +func (u *Uint64) StoreRelease(value uint64) { + StoreRel64(&u.value, value) +} From 75b73d68b332a90e05cf45fa2c850667b3a0f777 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Fri, 24 Sep 2021 16:06:07 +0000 Subject: [PATCH 095/406] runtime: use atomic.Float64 for assist ratio Change-Id: Ie7f09a7c9545ef9dd1860b1e332c4edbcbf8165e Reviewed-on: https://go-review.googlesource.com/c/go/+/356170 Reviewed-by: Austin Clements Trust: Michael Knyszek --- src/runtime/mgcmark.go | 10 +++++----- src/runtime/mgcpacer.go | 20 +++++--------------- src/runtime/proc.go | 2 +- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go index 246907e538..efda65fe1e 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -400,8 +400,8 @@ retry: // balance positive. When the required amount of work is low, // we over-assist to build up credit for future allocations // and amortize the cost of assisting. - assistWorkPerByte := float64frombits(atomic.Load64(&gcController.assistWorkPerByte)) - assistBytesPerWork := float64frombits(atomic.Load64(&gcController.assistBytesPerWork)) + assistWorkPerByte := gcController.assistWorkPerByte.Load() + assistBytesPerWork := gcController.assistBytesPerWork.Load() debtBytes := -gp.gcAssistBytes scanWork := int64(assistWorkPerByte * float64(debtBytes)) if scanWork < gcOverAssistWork { @@ -545,7 +545,7 @@ func gcAssistAlloc1(gp *g, scanWork int64) { // this scan work counts for. The "1+" is a poor man's // round-up, to ensure this adds credit even if // assistBytesPerWork is very low. - assistBytesPerWork := float64frombits(atomic.Load64(&gcController.assistBytesPerWork)) + assistBytesPerWork := gcController.assistBytesPerWork.Load() gp.gcAssistBytes += 1 + int64(assistBytesPerWork*float64(workDone)) // If this is the last worker and we ran out of work, @@ -638,7 +638,7 @@ func gcFlushBgCredit(scanWork int64) { return } - assistBytesPerWork := float64frombits(atomic.Load64(&gcController.assistBytesPerWork)) + assistBytesPerWork := gcController.assistBytesPerWork.Load() scanBytes := int64(float64(scanWork) * assistBytesPerWork) lock(&work.assistQueue.lock) @@ -672,7 +672,7 @@ func gcFlushBgCredit(scanWork int64) { if scanBytes > 0 { // Convert from scan bytes back to work. - assistWorkPerByte := float64frombits(atomic.Load64(&gcController.assistWorkPerByte)) + assistWorkPerByte := gcController.assistWorkPerByte.Load() scanWork = int64(float64(scanBytes) * assistWorkPerByte) atomic.Xaddint64(&gcController.bgScanCredit, scanWork) } diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 9338359de7..342ea419fe 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -222,24 +222,14 @@ type gcControllerState struct { // bytes that should be performed by mutator assists. This is // computed at the beginning of each cycle and updated every // time heapScan is updated. - // - // Stored as a uint64, but it's actually a float64. Use - // float64frombits to get the value. - // - // Read and written atomically. - assistWorkPerByte uint64 + assistWorkPerByte atomic.Float64 // assistBytesPerWork is 1/assistWorkPerByte. // - // Stored as a uint64, but it's actually a float64. Use - // float64frombits to get the value. - // - // Read and written atomically. - // // Note that because this is read and written independently // from assistWorkPerByte users may notice a skew between // the two values, and such a state should be safe. - assistBytesPerWork uint64 + assistBytesPerWork atomic.Float64 // fractionalUtilizationGoal is the fraction of wall clock // time that should be spent in the fractional mark worker on @@ -333,7 +323,7 @@ func (c *gcControllerState) startCycle() { c.revise() if debug.gcpacertrace > 0 { - assistRatio := float64frombits(atomic.Load64(&c.assistWorkPerByte)) + assistRatio := c.assistWorkPerByte.Load() print("pacer: assist ratio=", assistRatio, " (scan ", gcController.heapScan>>20, " MB in ", work.initialHeapLive>>20, "->", @@ -439,8 +429,8 @@ func (c *gcControllerState) revise() { // cycle. assistWorkPerByte := float64(scanWorkRemaining) / float64(heapRemaining) assistBytesPerWork := float64(heapRemaining) / float64(scanWorkRemaining) - atomic.Store64(&c.assistWorkPerByte, float64bits(assistWorkPerByte)) - atomic.Store64(&c.assistBytesPerWork, float64bits(assistBytesPerWork)) + c.assistWorkPerByte.Store(assistWorkPerByte) + c.assistBytesPerWork.Store(assistBytesPerWork) } // endCycle computes the trigger ratio for the next cycle. diff --git a/src/runtime/proc.go b/src/runtime/proc.go index c14a1f143c..b80f09f993 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -3646,7 +3646,7 @@ func goexit0(gp *g) { // Flush assist credit to the global pool. This gives // better information to pacing if the application is // rapidly creating an exiting goroutines. - assistWorkPerByte := float64frombits(atomic.Load64(&gcController.assistWorkPerByte)) + assistWorkPerByte := gcController.assistWorkPerByte.Load() scanCredit := int64(assistWorkPerByte * float64(gp.gcAssistBytes)) atomic.Xaddint64(&gcController.bgScanCredit, scanCredit) gp.gcAssistBytes = 0 From d419a80bc76cf18d321f9bf37c2deb2b8c0a1415 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Fri, 15 Oct 2021 19:22:10 +0000 Subject: [PATCH 096/406] runtime: retype mheap.pagesInUse as atomic.Uint64 [git-generate] cd src/runtime mv export_test.go export.go GOROOT=$(dirname $(dirname $PWD)) rf ' add mheap.pagesInUse \ // Proportional sweep \ // \ // These parameters represent a linear function from gcController.heapLive \ // to page sweep count. The proportional sweep system works to \ // stay in the black by keeping the current page sweep count \ // above this line at the current gcController.heapLive. \ // \ // The line has slope sweepPagesPerByte and passes through a \ // basis point at (sweepHeapLiveBasis, pagesSweptBasis). At \ // any given time, the system is at (gcController.heapLive, \ // pagesSwept) in this space. \ // \ // It is important that the line pass through a point we \ // control rather than simply starting at a 0,0 origin \ // because that lets us adjust sweep pacing at any time while \ // accounting for current progress. If we could only adjust \ // the slope, it would create a discontinuity in debt if any \ // progress has already been made. \ pagesInUse_ atomic.Uint64 // pages of spans in stats mSpanInUse ex { import "runtime/internal/atomic" var t mheap var v, w uint64 var d int64 t.pagesInUse -> t.pagesInUse_.Load() t.pagesInUse = v -> t.pagesInUse_.Store(v) atomic.Load64(&t.pagesInUse) -> t.pagesInUse_.Load() atomic.LoadAcq64(&t.pagesInUse) -> t.pagesInUse_.LoadAcquire() atomic.Store64(&t.pagesInUse, v) -> t.pagesInUse_.Store(v) atomic.StoreRel64(&t.pagesInUse, v) -> t.pagesInUse_.StoreRelease(v) atomic.Cas64(&t.pagesInUse, v, w) -> t.pagesInUse_.CompareAndSwap(v, w) atomic.Xchg64(&t.pagesInUse, v) -> t.pagesInUse_.Swap(v) atomic.Xadd64(&t.pagesInUse, d) -> t.pagesInUse_.Add(d) } rm mheap.pagesInUse mv mheap.pagesInUse_ mheap.pagesInUse ' mv export.go export_test.go Change-Id: I495d188683dba0778518563c46755b5ad43be298 Reviewed-on: https://go-review.googlesource.com/c/go/+/356549 Trust: Michael Knyszek Reviewed-by: Austin Clements --- src/runtime/export_test.go | 2 +- src/runtime/mgcpacer.go | 2 +- src/runtime/mheap.go | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index 01fd1dbd97..01f917bded 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -263,7 +263,7 @@ var ReadUnaligned64 = readUnaligned64 func CountPagesInUse() (pagesInUse, counted uintptr) { stopTheWorld("CountPagesInUse") - pagesInUse = uintptr(mheap_.pagesInUse) + pagesInUse = uintptr(mheap_.pagesInUse.Load()) for _, s := range mheap_.allspans { if s.state.get() == mSpanInUse { diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 342ea419fe..3cd4ea2fde 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -752,7 +752,7 @@ func (c *gcControllerState) commit(triggerRatio float64) { heapDistance = _PageSize } pagesSwept := atomic.Load64(&mheap_.pagesSwept) - pagesInUse := atomic.Load64(&mheap_.pagesInUse) + pagesInUse := mheap_.pagesInUse.Load() sweepDistancePages := int64(pagesInUse) - int64(pagesSwept) if sweepDistancePages <= 0 { mheap_.sweepPagesPerByte = 0 diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index b78f752ded..a787f67460 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -96,17 +96,17 @@ type mheap struct { // any given time, the system is at (gcController.heapLive, // pagesSwept) in this space. // - // It's important that the line pass through a point we - // control rather than simply starting at a (0,0) origin + // It is important that the line pass through a point we + // control rather than simply starting at a 0,0 origin // because that lets us adjust sweep pacing at any time while // accounting for current progress. If we could only adjust // the slope, it would create a discontinuity in debt if any // progress has already been made. - pagesInUse uint64 // pages of spans in stats mSpanInUse; updated atomically - pagesSwept uint64 // pages swept this cycle; updated atomically - pagesSweptBasis uint64 // pagesSwept to use as the origin of the sweep ratio; updated atomically - sweepHeapLiveBasis uint64 // value of gcController.heapLive to use as the origin of sweep ratio; written with lock, read without - sweepPagesPerByte float64 // proportional sweep ratio; written with lock, read without + pagesInUse atomic.Uint64 // pages of spans in stats mSpanInUse + pagesSwept uint64 // pages swept this cycle; updated atomically + pagesSweptBasis uint64 // pagesSwept to use as the origin of the sweep ratio; updated atomically + sweepHeapLiveBasis uint64 // value of gcController.heapLive to use as the origin of sweep ratio; written with lock, read without + sweepPagesPerByte float64 // proportional sweep ratio; written with lock, read without // TODO(austin): pagesInUse should be a uintptr, but the 386 // compiler can't 8-byte align fields. @@ -1311,7 +1311,7 @@ HaveSpan: atomic.Or8(&arena.pageInUse[pageIdx], pageMask) // Update related page sweeper stats. - atomic.Xadd64(&h.pagesInUse, int64(npages)) + h.pagesInUse.Add(int64(npages)) } // Make sure the newly allocated span will be observed @@ -1468,7 +1468,7 @@ func (h *mheap) freeSpanLocked(s *mspan, typ spanAllocType) { print("mheap.freeSpanLocked - span ", s, " ptr ", hex(s.base()), " allocCount ", s.allocCount, " sweepgen ", s.sweepgen, "/", h.sweepgen, "\n") throw("mheap.freeSpanLocked - invalid free") } - atomic.Xadd64(&h.pagesInUse, -int64(s.npages)) + h.pagesInUse.Add(-int64(s.npages)) // Clear in-use bit in arena page bitmap. arena, pageIdx, pageMask := pageIndexOf(s.base()) From e90492882a7fd580b7dac88675a1c907a7441b40 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 18 Oct 2021 23:07:59 +0000 Subject: [PATCH 097/406] runtime: retype mheap.pagesSwept as atomic.Uint64 [git-generate] cd src/runtime mv export_test.go export.go GOROOT=$(dirname $(dirname $PWD)) rf ' add mheap.pagesSwept pagesSwept_ atomic.Uint64 // pages swept this cycle ex { import "runtime/internal/atomic" var t mheap var v, w uint64 var d int64 t.pagesSwept -> t.pagesSwept_.Load() t.pagesSwept = v -> t.pagesSwept_.Store(v) atomic.Load64(&t.pagesSwept) -> t.pagesSwept_.Load() atomic.LoadAcq64(&t.pagesSwept) -> t.pagesSwept_.LoadAcquire() atomic.Store64(&t.pagesSwept, v) -> t.pagesSwept_.Store(v) atomic.StoreRel64(&t.pagesSwept, v) -> t.pagesSwept_.StoreRelease(v) atomic.Cas64(&t.pagesSwept, v, w) -> t.pagesSwept_.CompareAndSwap(v, w) atomic.Xchg64(&t.pagesSwept, v) -> t.pagesSwept_.Swap(v) atomic.Xadd64(&t.pagesSwept, d) -> t.pagesSwept_.Add(d) } rm mheap.pagesSwept mv mheap.pagesSwept_ mheap.pagesSwept ' mv export.go export_test.go Change-Id: Ife99893d90a339655f604bc3a64ee3decec645ea Reviewed-on: https://go-review.googlesource.com/c/go/+/356709 Trust: Michael Knyszek Reviewed-by: Austin Clements --- src/runtime/mgc.go | 2 +- src/runtime/mgcpacer.go | 2 +- src/runtime/mgcsweep.go | 6 +++--- src/runtime/mheap.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 34b5b482a3..654fa4118a 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -1457,7 +1457,7 @@ func gcSweep(mode gcMode) { lock(&mheap_.lock) mheap_.sweepgen += 2 mheap_.sweepDrained = 0 - mheap_.pagesSwept = 0 + mheap_.pagesSwept.Store(0) mheap_.sweepArenas = mheap_.allArenas mheap_.reclaimIndex = 0 mheap_.reclaimCredit = 0 diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 3cd4ea2fde..f858ab08d0 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -751,7 +751,7 @@ func (c *gcControllerState) commit(triggerRatio float64) { // Avoid setting the sweep ratio extremely high heapDistance = _PageSize } - pagesSwept := atomic.Load64(&mheap_.pagesSwept) + pagesSwept := mheap_.pagesSwept.Load() pagesInUse := mheap_.pagesInUse.Load() sweepDistancePages := int64(pagesInUse) - int64(pagesSwept) if sweepDistancePages <= 0 { diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go index 1812644623..78d1f33925 100644 --- a/src/runtime/mgcsweep.go +++ b/src/runtime/mgcsweep.go @@ -245,7 +245,7 @@ func (l *sweepLocker) dispose() { func (l *sweepLocker) sweepIsDone() { if debug.gcpacertrace > 0 { - print("pacer: sweep done at heap size ", gcController.heapLive>>20, "MB; allocated ", (gcController.heapLive-mheap_.sweepHeapLiveBasis)>>20, "MB during sweep; swept ", mheap_.pagesSwept, " pages at ", mheap_.sweepPagesPerByte, " pages/byte\n") + print("pacer: sweep done at heap size ", gcController.heapLive>>20, "MB; allocated ", (gcController.heapLive-mheap_.sweepHeapLiveBasis)>>20, "MB during sweep; swept ", mheap_.pagesSwept.Load(), " pages at ", mheap_.sweepPagesPerByte, " pages/byte\n") } } @@ -408,7 +408,7 @@ func (sl *sweepLocked) sweep(preserve bool) bool { traceGCSweepSpan(s.npages * _PageSize) } - atomic.Xadd64(&mheap_.pagesSwept, int64(s.npages)) + mheap_.pagesSwept.Add(int64(s.npages)) spc := s.spanclass size := s.elemsize @@ -724,7 +724,7 @@ retry: // Fix debt if necessary. newHeapLive := uintptr(atomic.Load64(&gcController.heapLive)-mheap_.sweepHeapLiveBasis) + spanBytes pagesTarget := int64(mheap_.sweepPagesPerByte*float64(newHeapLive)) - int64(callerSweepPages) - for pagesTarget > int64(atomic.Load64(&mheap_.pagesSwept)-sweptBasis) { + for pagesTarget > int64(mheap_.pagesSwept.Load()-sweptBasis) { if sweepone() == ^uintptr(0) { mheap_.sweepPagesPerByte = 0 break diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index a787f67460..27f60771eb 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -103,7 +103,7 @@ type mheap struct { // the slope, it would create a discontinuity in debt if any // progress has already been made. pagesInUse atomic.Uint64 // pages of spans in stats mSpanInUse - pagesSwept uint64 // pages swept this cycle; updated atomically + pagesSwept atomic.Uint64 // pages swept this cycle pagesSweptBasis uint64 // pagesSwept to use as the origin of the sweep ratio; updated atomically sweepHeapLiveBasis uint64 // value of gcController.heapLive to use as the origin of sweep ratio; written with lock, read without sweepPagesPerByte float64 // proportional sweep ratio; written with lock, read without From 1dff8f0a056517f0a8adfda663402ffb2e089281 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 18 Oct 2021 23:10:43 +0000 Subject: [PATCH 098/406] runtime: retype mheap.pagesSweptBasis as atomic.Uint64 [git-generate] cd src/runtime mv export_test.go export.go GOROOT=$(dirname $(dirname $PWD)) rf ' add mheap.pagesSweptBasis pagesSweptBasis_ atomic.Uint64 // pagesSwept to use as the origin of the sweep ratio ex { import "runtime/internal/atomic" var t mheap var v, w uint64 var d int64 t.pagesSweptBasis -> t.pagesSweptBasis_.Load() t.pagesSweptBasis = v -> t.pagesSweptBasis_.Store(v) atomic.Load64(&t.pagesSweptBasis) -> t.pagesSweptBasis_.Load() atomic.LoadAcq64(&t.pagesSweptBasis) -> t.pagesSweptBasis_.LoadAcquire() atomic.Store64(&t.pagesSweptBasis, v) -> t.pagesSweptBasis_.Store(v) atomic.StoreRel64(&t.pagesSweptBasis, v) -> t.pagesSweptBasis_.StoreRelease(v) atomic.Cas64(&t.pagesSweptBasis, v, w) -> t.pagesSweptBasis_.CompareAndSwap(v, w) atomic.Xchg64(&t.pagesSweptBasis, v) -> t.pagesSweptBasis_.Swap(v) atomic.Xadd64(&t.pagesSweptBasis, d) -> t.pagesSweptBasis_.Add(d) } rm mheap.pagesSweptBasis mv mheap.pagesSweptBasis_ mheap.pagesSweptBasis ' mv export.go export_test.go Change-Id: Id9438184b9bd06d96894c02376385bad45dee154 Reviewed-on: https://go-review.googlesource.com/c/go/+/356710 Reviewed-by: Austin Clements Trust: Michael Knyszek --- src/runtime/mgcpacer.go | 2 +- src/runtime/mgcsweep.go | 4 ++-- src/runtime/mheap.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index f858ab08d0..55f3bc926d 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -762,7 +762,7 @@ func (c *gcControllerState) commit(triggerRatio float64) { // Write pagesSweptBasis last, since this // signals concurrent sweeps to recompute // their debt. - atomic.Store64(&mheap_.pagesSweptBasis, pagesSwept) + mheap_.pagesSweptBasis.Store(pagesSwept) } } diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go index 78d1f33925..aedd6c316e 100644 --- a/src/runtime/mgcsweep.go +++ b/src/runtime/mgcsweep.go @@ -719,7 +719,7 @@ func deductSweepCredit(spanBytes uintptr, callerSweepPages uintptr) { } retry: - sweptBasis := atomic.Load64(&mheap_.pagesSweptBasis) + sweptBasis := mheap_.pagesSweptBasis.Load() // Fix debt if necessary. newHeapLive := uintptr(atomic.Load64(&gcController.heapLive)-mheap_.sweepHeapLiveBasis) + spanBytes @@ -729,7 +729,7 @@ retry: mheap_.sweepPagesPerByte = 0 break } - if atomic.Load64(&mheap_.pagesSweptBasis) != sweptBasis { + if mheap_.pagesSweptBasis.Load() != sweptBasis { // Sweep pacing changed. Recompute debt. goto retry } diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index 27f60771eb..90e55315a6 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -104,7 +104,7 @@ type mheap struct { // progress has already been made. pagesInUse atomic.Uint64 // pages of spans in stats mSpanInUse pagesSwept atomic.Uint64 // pages swept this cycle - pagesSweptBasis uint64 // pagesSwept to use as the origin of the sweep ratio; updated atomically + pagesSweptBasis atomic.Uint64 // pagesSwept to use as the origin of the sweep ratio sweepHeapLiveBasis uint64 // value of gcController.heapLive to use as the origin of sweep ratio; written with lock, read without sweepPagesPerByte float64 // proportional sweep ratio; written with lock, read without // TODO(austin): pagesInUse should be a uintptr, but the 386 From a91e976fd2cc6f1c156877eae40262d7e47c745c Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 18 Oct 2021 23:12:16 +0000 Subject: [PATCH 099/406] runtime: retype mheap.reclaimIndex as atomic.Uint64 [git-generate] cd src/runtime mv export_test.go export.go GOROOT=$(dirname $(dirname $PWD)) rf ' add mheap.reclaimIndex \ // reclaimIndex is the page index in allArenas of next page to \ // reclaim. Specifically, it refers to page (i % \ // pagesPerArena) of arena allArenas[i / pagesPerArena]. \ // \ // If this is >= 1<<63, the page reclaimer is done scanning \ // the page marks. \ reclaimIndex_ atomic.Uint64 ex { import "runtime/internal/atomic" var t mheap var v, w uint64 var d int64 t.reclaimIndex -> t.reclaimIndex_.Load() t.reclaimIndex = v -> t.reclaimIndex_.Store(v) atomic.Load64(&t.reclaimIndex) -> t.reclaimIndex_.Load() atomic.LoadAcq64(&t.reclaimIndex) -> t.reclaimIndex_.LoadAcquire() atomic.Store64(&t.reclaimIndex, v) -> t.reclaimIndex_.Store(v) atomic.StoreRel64(&t.reclaimIndex, v) -> t.reclaimIndex_.StoreRelease(v) atomic.Cas64(&t.reclaimIndex, v, w) -> t.reclaimIndex_.CompareAndSwap(v, w) atomic.Xchg64(&t.reclaimIndex, v) -> t.reclaimIndex_.Swap(v) atomic.Xadd64(&t.reclaimIndex, d) -> t.reclaimIndex_.Add(d) } rm mheap.reclaimIndex mv mheap.reclaimIndex_ mheap.reclaimIndex ' mv export.go export_test.go Change-Id: I1d619e3ac032285b5f7eb6c563a5188c8e36d089 Reviewed-on: https://go-review.googlesource.com/c/go/+/356711 Reviewed-by: Austin Clements Trust: Michael Knyszek --- src/runtime/mgc.go | 2 +- src/runtime/mheap.go | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 654fa4118a..56ef1c4e38 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -1459,7 +1459,7 @@ func gcSweep(mode gcMode) { mheap_.sweepDrained = 0 mheap_.pagesSwept.Store(0) mheap_.sweepArenas = mheap_.allArenas - mheap_.reclaimIndex = 0 + mheap_.reclaimIndex.Store(0) mheap_.reclaimCredit = 0 unlock(&mheap_.lock) diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index 90e55315a6..fc86023f4d 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -123,9 +123,7 @@ type mheap struct { // // If this is >= 1<<63, the page reclaimer is done scanning // the page marks. - // - // This is accessed atomically. - reclaimIndex uint64 + reclaimIndex atomic.Uint64 // reclaimCredit is spare credit for extra pages swept. Since // the page reclaimer works in large chunks, it may reclaim // more than requested. Any spare pages released go to this @@ -739,7 +737,7 @@ func (h *mheap) reclaim(npage uintptr) { // batching heap frees. // Bail early if there's no more reclaim work. - if atomic.Load64(&h.reclaimIndex) >= 1<<63 { + if h.reclaimIndex.Load() >= 1<<63 { return } @@ -769,10 +767,10 @@ func (h *mheap) reclaim(npage uintptr) { } // Claim a chunk of work. - idx := uintptr(atomic.Xadd64(&h.reclaimIndex, pagesPerReclaimerChunk) - pagesPerReclaimerChunk) + idx := uintptr(h.reclaimIndex.Add(pagesPerReclaimerChunk) - pagesPerReclaimerChunk) if idx/pagesPerArena >= uintptr(len(arenas)) { // Page reclaiming is done. - atomic.Store64(&h.reclaimIndex, 1<<63) + h.reclaimIndex.Store(1 << 63) break } From 016d5eea118445f5b3ca46f85b65c6afd180c946 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 18 Oct 2021 23:14:20 +0000 Subject: [PATCH 100/406] runtime: retype mheap.reclaimCredit as atomic.Uintptr [git-generate] cd src/runtime mv export_test.go export.go GOROOT=$(dirname $(dirname $PWD)) rf ' add mheap.reclaimCredit \ // reclaimCredit is spare credit for extra pages swept. Since \ // the page reclaimer works in large chunks, it may reclaim \ // more than requested. Any spare pages released go to this \ // credit pool. \ reclaimCredit_ atomic.Uintptr ex { import "runtime/internal/atomic" var t mheap var v, w uintptr var d uintptr t.reclaimCredit -> t.reclaimCredit_.Load() t.reclaimCredit = v -> t.reclaimCredit_.Store(v) atomic.Loaduintptr(&t.reclaimCredit) -> t.reclaimCredit_.Load() atomic.LoadAcquintptr(&t.reclaimCredit) -> t.reclaimCredit_.LoadAcquire() atomic.Storeuintptr(&t.reclaimCredit, v) -> t.reclaimCredit_.Store(v) atomic.StoreReluintptr(&t.reclaimCredit, v) -> t.reclaimCredit_.StoreRelease(v) atomic.Casuintptr(&t.reclaimCredit, v, w) -> t.reclaimCredit_.CompareAndSwap(v, w) atomic.Xchguintptr(&t.reclaimCredit, v) -> t.reclaimCredit_.Swap(v) atomic.Xadduintptr(&t.reclaimCredit, d) -> t.reclaimCredit_.Add(d) } rm mheap.reclaimCredit mv mheap.reclaimCredit_ mheap.reclaimCredit ' mv export.go export_test.go Change-Id: I2c567781a28f5d8c2275ff18f2cf605b82f22d09 Reviewed-on: https://go-review.googlesource.com/c/go/+/356712 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Austin Clements --- src/runtime/mgc.go | 2 +- src/runtime/mgcsweep.go | 2 +- src/runtime/mheap.go | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 56ef1c4e38..6f8463c253 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -1460,7 +1460,7 @@ func gcSweep(mode gcMode) { mheap_.pagesSwept.Store(0) mheap_.sweepArenas = mheap_.allArenas mheap_.reclaimIndex.Store(0) - mheap_.reclaimCredit = 0 + mheap_.reclaimCredit.Store(0) unlock(&mheap_.lock) sweep.centralIndex.clear() diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go index aedd6c316e..9c7f9d340d 100644 --- a/src/runtime/mgcsweep.go +++ b/src/runtime/mgcsweep.go @@ -291,7 +291,7 @@ func sweepone() uintptr { // Whole span was freed. Count it toward the // page reclaimer credit since these pages can // now be used for span allocation. - atomic.Xadduintptr(&mheap_.reclaimCredit, npages) + mheap_.reclaimCredit.Add(npages) } else { // Span is still in-use, so this returned no // pages to the heap and the span needs to diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index fc86023f4d..0e7694aab7 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -124,13 +124,12 @@ type mheap struct { // If this is >= 1<<63, the page reclaimer is done scanning // the page marks. reclaimIndex atomic.Uint64 + // reclaimCredit is spare credit for extra pages swept. Since // the page reclaimer works in large chunks, it may reclaim // more than requested. Any spare pages released go to this // credit pool. - // - // This is accessed atomically. - reclaimCredit uintptr + reclaimCredit atomic.Uintptr // arenas is the heap arena map. It points to the metadata for // the heap for every arena frame of the entire usable virtual @@ -754,13 +753,13 @@ func (h *mheap) reclaim(npage uintptr) { locked := false for npage > 0 { // Pull from accumulated credit first. - if credit := atomic.Loaduintptr(&h.reclaimCredit); credit > 0 { + if credit := h.reclaimCredit.Load(); credit > 0 { take := credit if take > npage { // Take only what we need. take = npage } - if atomic.Casuintptr(&h.reclaimCredit, credit, credit-take) { + if h.reclaimCredit.CompareAndSwap(credit, credit-take) { npage -= take } continue @@ -786,7 +785,7 @@ func (h *mheap) reclaim(npage uintptr) { npage -= nfound } else { // Put spare pages toward global credit. - atomic.Xadduintptr(&h.reclaimCredit, nfound-npage) + h.reclaimCredit.Add(nfound - npage) npage = 0 } } From 73652af80d9f33de946fc3a91c6900a81247df18 Mon Sep 17 00:00:00 2001 From: hkhere <33268704+hkhere@users.noreply.github.com> Date: Wed, 20 Oct 2021 17:26:41 +0000 Subject: [PATCH 101/406] cmd/compile: use `else if` for mutually exclusive `if` statements Change-Id: I43e5bb778fbba1398c8006b1644524a9885157db GitHub-Last-Rev: fa76473ab8b207b8cfc350ca8a26de37dfe57f82 GitHub-Pull-Request: golang/go#47155 Reviewed-on: https://go-review.googlesource.com/c/go/+/334169 Trust: Keith Randall Trust: Robert Griesemer Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/typecheck/dcl.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/typecheck/dcl.go b/src/cmd/compile/internal/typecheck/dcl.go index 76fc6de621..68ab05a538 100644 --- a/src/cmd/compile/internal/typecheck/dcl.go +++ b/src/cmd/compile/internal/typecheck/dcl.go @@ -360,8 +360,7 @@ func funcargs(nt *ir.FuncType) { if n.Sym == nil { // Name so that escape analysis can track it. ~r stands for 'result'. n.Sym = LookupNum("~r", i) - } - if n.Sym.IsBlank() { + } else if n.Sym.IsBlank() { // Give it a name so we can assign to it during return. ~b stands for 'blank'. // The name must be different from ~r above because if you have // func f() (_ int) From fca46d0b36c10250713ec0f4c9bf13d626f358d1 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 20 Oct 2021 12:31:53 +0700 Subject: [PATCH 102/406] go/types: print assignment operation for invalid operation errors This is port of CL 357229 for types2 to go/types. Change-Id: I35ed6b784969210a00ea5b36238df7d6b7fa18bc Reviewed-on: https://go-review.googlesource.com/c/go/+/357230 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Robert Findley --- src/go/types/expr.go | 6 +++++- src/go/types/testdata/fixedbugs/issue48472.go2 | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/go/types/expr.go b/src/go/types/expr.go index fac5a5e31d..3a09dfd85f 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -1000,7 +1000,11 @@ func (check *Checker) binary(x *operand, e ast.Expr, lhs, rhs ast.Expr, op token if e != nil { posn = e } - check.invalidOp(posn, _MismatchedTypes, "%s (mismatched types %s and %s)", e, x.typ, y.typ) + if e != nil { + check.invalidOp(posn, _MismatchedTypes, "%s (mismatched types %s and %s)", e, x.typ, y.typ) + } else { + check.invalidOp(posn, _MismatchedTypes, "%s %s= %s (mismatched types %s and %s)", lhs, op, rhs, x.typ, y.typ) + } } x.mode = invalid return diff --git a/src/go/types/testdata/fixedbugs/issue48472.go2 b/src/go/types/testdata/fixedbugs/issue48472.go2 index 5fefcaf22b..2d908f4c8b 100644 --- a/src/go/types/testdata/fixedbugs/issue48472.go2 +++ b/src/go/types/testdata/fixedbugs/issue48472.go2 @@ -9,3 +9,8 @@ func g() { var i int _ = s /* ERROR invalid operation: s \+ i \(mismatched types string and int\) */ + i } + +func f(i int) int { + i /* ERROR invalid operation: i \+= "1" \(mismatched types int and untyped string\) */ += "1" + return i +} From 8b9c0d1a79251969e46731e46e72e4e8f8998817 Mon Sep 17 00:00:00 2001 From: Archana R Date: Wed, 20 Oct 2021 04:11:57 -0500 Subject: [PATCH 103/406] test/codegen: updated comparison test to verify on ppc64,ppc64le Updated test/codegen/comparison.go to verify memequal is inlined as implemented in CL 328291. Change-Id: If7824aed37ee1f8640e54fda0f9b7610582ba316 Reviewed-on: https://go-review.googlesource.com/c/go/+/357289 Run-TryBot: Lynn Boger TryBot-Result: Go Bot Trust: Lynn Boger Reviewed-by: Cherry Mui --- test/codegen/comparisons.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/codegen/comparisons.go b/test/codegen/comparisons.go index 35a181f83b..fd32ea335c 100644 --- a/test/codegen/comparisons.go +++ b/test/codegen/comparisons.go @@ -546,6 +546,8 @@ func equalConstString1() bool { b := string("Z") // amd64:-".*memequal" // arm64:-".*memequal" + // ppc64:-".*memequal" + // ppc64le:-".*memequal" return a == b } @@ -553,6 +555,8 @@ func equalVarString1(a string) bool { b := string("Z") // amd64:-".*memequal" // arm64:-".*memequal" + // ppc64:-".*memequal" + // ppc64le:-".*memequal" return a[:1] == b } @@ -561,6 +565,8 @@ func equalConstString2() bool { b := string("ZZ") // amd64:-".*memequal" // arm64:-".*memequal" + // ppc64:-".*memequal" + // ppc64le:-".*memequal" return a == b } @@ -568,6 +574,8 @@ func equalVarString2(a string) bool { b := string("ZZ") // amd64:-".*memequal" // arm64:-".*memequal" + // ppc64:-".*memequal" + // ppc64le:-".*memequal" return a[:2] == b } @@ -576,6 +584,8 @@ func equalConstString4() bool { b := string("ZZZZ") // amd64:-".*memequal" // arm64:-".*memequal" + // ppc64:-".*memequal" + // ppc64le:-".*memequal" return a == b } @@ -583,6 +593,8 @@ func equalVarString4(a string) bool { b := string("ZZZZ") // amd64:-".*memequal" // arm64:-".*memequal" + // ppc64:-".*memequal" + // ppc64le:-".*memequal" return a[:4] == b } @@ -591,6 +603,8 @@ func equalConstString8() bool { b := string("ZZZZZZZZ") // amd64:-".*memequal" // arm64:-".*memequal" + // ppc64:-".*memequal" + // ppc64le:-".*memequal" return a == b } @@ -598,5 +612,7 @@ func equalVarString8(a string) bool { b := string("ZZZZZZZZ") // amd64:-".*memequal" // arm64:-".*memequal" + // ppc64:-".*memequal" + // ppc64le:-".*memequal" return a[:8] == b } From 8b0bea993d452ef7861642a9c04bae213246ded1 Mon Sep 17 00:00:00 2001 From: Lynn Boger Date: Thu, 14 Oct 2021 12:55:43 -0500 Subject: [PATCH 104/406] cmd/compile/internal/ssa/gen: eliminate unnecessary neg and xori on PPC64 This adds a few rules to PPC64 to eliminate some instructions: - when an isel is used to generate a boolean value based on a condition and followed by an xori to flip the result, it can instead flip the operands in the isel and avoid the xori. = when a neg follows a sub the operands to the sub can be swapped and the neg avoided. There are several opportunities in reflect.DeepEqual to omit xori which improves some of its benchmarks by as much as 5% Change-Id: I81bbc02c0f16995c65934b6f045867b731ab302b Reviewed-on: https://go-review.googlesource.com/c/go/+/357509 Trust: Lynn Boger Reviewed-by: Cherry Mui --- src/cmd/compile/internal/ssa/gen/PPC64.rules | 6 +- src/cmd/compile/internal/ssa/gen/PPC64Ops.go | 2 +- src/cmd/compile/internal/ssa/rewritePPC64.go | 68 ++++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/ssa/gen/PPC64.rules b/src/cmd/compile/internal/ssa/gen/PPC64.rules index 8e42bae215..ccca72a416 100644 --- a/src/cmd/compile/internal/ssa/gen/PPC64.rules +++ b/src/cmd/compile/internal/ssa/gen/PPC64.rules @@ -848,6 +848,7 @@ (ADDconst [c] (SUBFCconst [d] x)) && is32Bit(c+d) => (SUBFCconst [c+d] x) (NEG (ADDconst [c] x)) && is32Bit(-c) => (SUBFCconst [-c] x) (NEG (SUBFCconst [c] x)) && is32Bit(-c) => (ADDconst [-c] x) +(NEG (SUB x y)) => (SUB y x) // Use register moves instead of stores and loads to move int<=>float values // Common with math Float64bits, Float64frombits @@ -1087,7 +1088,7 @@ ((CMP|CMPW|CMPU|CMPWU) x y) && canonLessThan(x,y) => (InvertFlags ((CMP|CMPW|CMPU|CMPWU) y x)) // ISEL auxInt values 0=LT 1=GT 2=EQ arg2 ? arg0 : arg1 -// ISEL auxInt values 4=GE 5=LE 6=NE arg2 ? arg1 : arg0 +// ISEL auxInt values 4=GE 5=LE 6=NE !arg2 ? arg1 : arg0 // ISELB special case where arg0, arg1 values are 0, 1 (Equal cmp) => (ISELB [2] (MOVDconst [1]) cmp) @@ -1138,6 +1139,9 @@ (ISEL [n] x y (InvertFlags bool)) && n%4 == 0 => (ISEL [n+1] x y bool) (ISEL [n] x y (InvertFlags bool)) && n%4 == 1 => (ISEL [n-1] x y bool) (ISEL [n] x y (InvertFlags bool)) && n%4 == 2 => (ISEL [n] x y bool) +(XORconst [1] (ISELB [6] (MOVDconst [1]) cmp)) => (ISELB [2] (MOVDconst [1]) cmp) +(XORconst [1] (ISELB [5] (MOVDconst [1]) cmp)) => (ISELB [1] (MOVDconst [1]) cmp) +(XORconst [1] (ISELB [4] (MOVDconst [1]) cmp)) => (ISELB [0] (MOVDconst [1]) cmp) // A particular pattern seen in cgo code: (AND (MOVDconst [c]) x:(MOVBZload _ _)) => (ANDconst [c&0xFF] x) diff --git a/src/cmd/compile/internal/ssa/gen/PPC64Ops.go b/src/cmd/compile/internal/ssa/gen/PPC64Ops.go index ff9ce64e18..42775fa3c2 100644 --- a/src/cmd/compile/internal/ssa/gen/PPC64Ops.go +++ b/src/cmd/compile/internal/ssa/gen/PPC64Ops.go @@ -396,7 +396,7 @@ func init() { {name: "CMPWUconst", argLength: 1, reg: gp1cr, asm: "CMPWU", aux: "Int32", typ: "Flags"}, // ISEL auxInt values 0=LT 1=GT 2=EQ arg2 ? arg0 : arg1 - // ISEL auxInt values 4=GE 5=LE 6=NE arg2 ? arg1 : arg0 + // ISEL auxInt values 4=GE 5=LE 6=NE !arg2 ? arg1 : arg0 // ISELB special case where arg0, arg1 values are 0, 1 for boolean result {name: "ISEL", argLength: 3, reg: crgp21, asm: "ISEL", aux: "Int32", typ: "Int32"}, // see above {name: "ISELB", argLength: 2, reg: crgp11, asm: "ISEL", aux: "Int32", typ: "Int32"}, // see above diff --git a/src/cmd/compile/internal/ssa/rewritePPC64.go b/src/cmd/compile/internal/ssa/rewritePPC64.go index 1e6624e906..ea1c1fa60a 100644 --- a/src/cmd/compile/internal/ssa/rewritePPC64.go +++ b/src/cmd/compile/internal/ssa/rewritePPC64.go @@ -11372,6 +11372,18 @@ func rewriteValuePPC64_OpPPC64NEG(v *Value) bool { v.AddArg(x) return true } + // match: (NEG (SUB x y)) + // result: (SUB y x) + for { + if v_0.Op != OpPPC64SUB { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpPPC64SUB) + v.AddArg2(y, x) + return true + } return false } func rewriteValuePPC64_OpPPC64NOR(v *Value) bool { @@ -13912,6 +13924,8 @@ func rewriteValuePPC64_OpPPC64XOR(v *Value) bool { } func rewriteValuePPC64_OpPPC64XORconst(v *Value) bool { v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types // match: (XORconst [c] (XORconst [d] x)) // result: (XORconst [c^d] x) for { @@ -13936,6 +13950,60 @@ func rewriteValuePPC64_OpPPC64XORconst(v *Value) bool { v.copyOf(x) return true } + // match: (XORconst [1] (ISELB [6] (MOVDconst [1]) cmp)) + // result: (ISELB [2] (MOVDconst [1]) cmp) + for { + if auxIntToInt64(v.AuxInt) != 1 || v_0.Op != OpPPC64ISELB || auxIntToInt32(v_0.AuxInt) != 6 { + break + } + cmp := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v.reset(OpPPC64ISELB) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(1) + v.AddArg2(v0, cmp) + return true + } + // match: (XORconst [1] (ISELB [5] (MOVDconst [1]) cmp)) + // result: (ISELB [1] (MOVDconst [1]) cmp) + for { + if auxIntToInt64(v.AuxInt) != 1 || v_0.Op != OpPPC64ISELB || auxIntToInt32(v_0.AuxInt) != 5 { + break + } + cmp := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v.reset(OpPPC64ISELB) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(1) + v.AddArg2(v0, cmp) + return true + } + // match: (XORconst [1] (ISELB [4] (MOVDconst [1]) cmp)) + // result: (ISELB [0] (MOVDconst [1]) cmp) + for { + if auxIntToInt64(v.AuxInt) != 1 || v_0.Op != OpPPC64ISELB || auxIntToInt32(v_0.AuxInt) != 4 { + break + } + cmp := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v.reset(OpPPC64ISELB) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(1) + v.AddArg2(v0, cmp) + return true + } return false } func rewriteValuePPC64_OpPanicBounds(v *Value) bool { From 6ec9a1da2d48fdc94093feb0ea3465129e11fc24 Mon Sep 17 00:00:00 2001 From: Archana R Date: Tue, 19 Oct 2021 04:11:46 -0500 Subject: [PATCH 105/406] internal/bytealg: fix Separator length check for Index/ppc64le Modified condition in the ASM implementation of indexbody to determine if separator length crosses 16 bytes to BGT from BGE to avoid incorrectly crossing a page. Also fixed IndexString to invoke indexbodyp9 when on the POWER9 platform Change-Id: I0602a797cc75287990eea1972e9e473744f6f5a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/356849 Run-TryBot: Lynn Boger TryBot-Result: Go Bot Reviewed-by: Lynn Boger Trust: Keith Randall --- src/internal/bytealg/index_ppc64x.s | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/internal/bytealg/index_ppc64x.s b/src/internal/bytealg/index_ppc64x.s index f587a8ae25..ab47495427 100644 --- a/src/internal/bytealg/index_ppc64x.s +++ b/src/internal/bytealg/index_ppc64x.s @@ -85,7 +85,7 @@ TEXT ·IndexString(SB),NOSPLIT|NOFRAME,$0-40 MOVBZ internal∕cpu·PPC64+const_offsetPPC64HasPOWER9(SB), R7 CMP R7, $1 BNE power8 - BR indexbody<>(SB) + BR indexbodyp9<>(SB) #endif power8: @@ -152,7 +152,7 @@ loadge16: ANDCC $15, R5, R9 // Find byte offset of sep ADD R9, R6, R10 // Add sep len CMP R10, $16 // Check if sep len+offset > 16 - BGE sepcross16 // Sep crosses 16 byte boundary + BGT sepcross16 // Sep crosses 16 byte boundary RLDICR $0, R5, $59, R8 // Adjust addr to 16 byte container VLOADSWAP(R8, R0, V0, V0_)// Load 16 bytes @R8 into V0 @@ -490,7 +490,7 @@ loadge16: ANDCC $15, R5, R9 // Find byte offset of sep ADD R9, R6, R10 // Add sep len CMP R10, $16 // Check if sep len+offset > 16 - BGE sepcross16 // Sep crosses 16 byte boundary + BGT sepcross16 // Sep crosses 16 byte boundary RLDICR $0, R5, $59, R8 // Adjust addr to 16 byte container LXVB16X (R8)(R0), V0_ // Load 16 bytes @R8 into V0 From 02a36668aa13c3182d29da678764c8f4f5a9499b Mon Sep 17 00:00:00 2001 From: emahiro Date: Fri, 22 Oct 2021 00:34:33 +0900 Subject: [PATCH 106/406] runtime: fix typo of pushBackAll MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: #49081 Change-Id: Ie6742f1e7a60c2d92ce1283bcfaa3eac521440a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/357629 Reviewed-by: Daniel Martí Trust: Daniel Martí Trust: Cherry Mui --- src/runtime/proc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/proc.go b/src/runtime/proc.go index b80f09f993..990637e21a 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -6123,7 +6123,7 @@ func (q *gQueue) pushBack(gp *g) { q.tail.set(gp) } -// pushBackAll adds all Gs in l2 to the tail of q. After this q2 must +// pushBackAll adds all Gs in q2 to the tail of q. After this q2 must // not be used. func (q *gQueue) pushBackAll(q2 gQueue) { if q2.tail == 0 { From 24999c3a8a811807ce096c5a39c5e2f2f213d2e3 Mon Sep 17 00:00:00 2001 From: Amelia Downs Date: Mon, 18 Oct 2021 13:06:58 -0400 Subject: [PATCH 107/406] net/url: add testable examples for url pkg funcs Change-Id: I61011b75128478aa50308d84f4cba23b3e241b3f Reviewed-on: https://go-review.googlesource.com/c/go/+/356536 Trust: Damien Neil Trust: Cherry Mui Run-TryBot: Damien Neil TryBot-Result: Go Bot Reviewed-by: Damien Neil --- src/net/url/example_test.go | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/net/url/example_test.go b/src/net/url/example_test.go index 476132a1c9..dfce2fc11c 100644 --- a/src/net/url/example_test.go +++ b/src/net/url/example_test.go @@ -12,6 +12,46 @@ import ( "strings" ) +func ExamplePathEscape() { + path := url.PathEscape("my/cool+blog&about,stuff") + fmt.Println(path) + + // Output: + // my%2Fcool+blog&about%2Cstuff +} + +func ExamplePathUnescape() { + escapedPath := "my%2Fcool+blog&about%2Cstuff" + path, err := url.PathUnescape(escapedPath) + if err != nil { + log.Fatal(err) + } + fmt.Println(path) + + // Output: + // my/cool+blog&about,stuff +} + +func ExampleQueryEscape() { + query := url.QueryEscape("my/cool+blog&about,stuff") + fmt.Println(query) + + // Output: + // my%2Fcool%2Bblog%26about%2Cstuff +} + +func ExampleQueryUnescape() { + escapedQuery := "my%2Fcool%2Bblog%26about%2Cstuff" + query, err := url.QueryUnescape(escapedQuery) + if err != nil { + log.Fatal(err) + } + fmt.Println(query) + + // Output: + // my/cool+blog&about,stuff +} + func ExampleValues() { v := url.Values{} v.Set("name", "Ava") From 392bb0677cfe6e6058d4f11953de80cdc20c52a8 Mon Sep 17 00:00:00 2001 From: Amelia Downs Date: Mon, 18 Oct 2021 12:36:07 -0400 Subject: [PATCH 108/406] net/url: add testable examples for Values funcs Change-Id: Id71f3d8d7c1ef7910d5d9497167dc677f2f0a2ef Reviewed-on: https://go-review.googlesource.com/c/go/+/356535 Trust: Damien Neil Trust: Cherry Mui Run-TryBot: Damien Neil TryBot-Result: Go Bot Reviewed-by: Damien Neil --- src/net/url/example_test.go | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/net/url/example_test.go b/src/net/url/example_test.go index dfce2fc11c..87b6e74a85 100644 --- a/src/net/url/example_test.go +++ b/src/net/url/example_test.go @@ -68,6 +68,84 @@ func ExampleValues() { // [Jess Sarah Zoe] } +func ExampleValues_Add() { + v := url.Values{} + v.Add("cat sounds", "meow") + v.Add("cat sounds", "mew") + v.Add("cat sounds", "mau") + fmt.Println(v["cat sounds"]) + + // Output: + // [meow mew mau] +} + +func ExampleValues_Del() { + v := url.Values{} + v.Add("cat sounds", "meow") + v.Add("cat sounds", "mew") + v.Add("cat sounds", "mau") + fmt.Println(v["cat sounds"]) + + v.Del("cat sounds") + fmt.Println(v["cat sounds"]) + + // Output: + // [meow mew mau] + // [] +} + +func ExampleValues_Encode() { + v := url.Values{} + v.Add("cat sounds", "meow") + v.Add("cat sounds", "mew/") + v.Add("cat sounds", "mau$") + fmt.Println(v.Encode()) + + // Output: + // cat+sounds=meow&cat+sounds=mew%2F&cat+sounds=mau%24 +} + +func ExampleValues_Get() { + v := url.Values{} + v.Add("cat sounds", "meow") + v.Add("cat sounds", "mew") + v.Add("cat sounds", "mau") + fmt.Printf("%q\n", v.Get("cat sounds")) + fmt.Printf("%q\n", v.Get("dog sounds")) + + // Output: + // "meow" + // "" +} + +func ExampleValues_Has() { + v := url.Values{} + v.Add("cat sounds", "meow") + v.Add("cat sounds", "mew") + v.Add("cat sounds", "mau") + fmt.Println(v.Has("cat sounds")) + fmt.Println(v.Has("dog sounds")) + + // Output: + // true + // false +} + +func ExampleValues_Set() { + v := url.Values{} + v.Add("cat sounds", "meow") + v.Add("cat sounds", "mew") + v.Add("cat sounds", "mau") + fmt.Println(v["cat sounds"]) + + v.Set("cat sounds", "meow") + fmt.Println(v["cat sounds"]) + + // Output: + // [meow mew mau] + // [meow] +} + func ExampleURL() { u, err := url.Parse("http://bing.com/search?q=dotnet") if err != nil { From 8151b56c5d1de8f654a6e6789a0e607b55845c1e Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Thu, 21 Oct 2021 13:23:29 -0400 Subject: [PATCH 109/406] go/types, types2: always return an underlying type from optype Optype should never return a defined type. Change-Id: I37b29e0c958e127e75e834e71d6392ea80827773 Reviewed-on: https://go-review.googlesource.com/c/go/+/357694 Trust: Robert Findley Run-TryBot: Robert Findley Reviewed-by: Robert Griesemer TryBot-Result: Go Bot --- .../compile/internal/types2/testdata/examples/types.go2 | 8 ++++++++ src/cmd/compile/internal/types2/type.go | 2 +- src/go/types/testdata/examples/types.go2 | 8 ++++++++ src/go/types/type.go | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/types2/testdata/examples/types.go2 b/src/cmd/compile/internal/types2/testdata/examples/types.go2 index 55b1b0da57..f177c78d06 100644 --- a/src/cmd/compile/internal/types2/testdata/examples/types.go2 +++ b/src/cmd/compile/internal/types2/testdata/examples/types.go2 @@ -304,3 +304,11 @@ func _[P interface{ ~[]E }, E interface{ map[string]P } ]() P { return P{E{"foo": x}} return P{{"foo": x}, {}} } + +// This is a degenerate case with a singleton type set, but we can create +// composite literals even if the structural type is a defined type. +type MyInts []int + +func _[P MyInts]() P { + return P{} +} diff --git a/src/cmd/compile/internal/types2/type.go b/src/cmd/compile/internal/types2/type.go index 400d6f7128..3fb05e9d63 100644 --- a/src/cmd/compile/internal/types2/type.go +++ b/src/cmd/compile/internal/types2/type.go @@ -57,7 +57,7 @@ func optype(typ Type) Type { // See also issue #39680. if u := t.structuralType(); u != nil { assert(u != typ) // "naked" type parameters cannot be embedded - return u + return under(u) // optype should always return an underlying type } return theTop } diff --git a/src/go/types/testdata/examples/types.go2 b/src/go/types/testdata/examples/types.go2 index 2e6eeb2204..807c03238f 100644 --- a/src/go/types/testdata/examples/types.go2 +++ b/src/go/types/testdata/examples/types.go2 @@ -310,3 +310,11 @@ func _[P interface{ ~[]E }, E interface{ map[string]P } ]() P { return P{E{"foo": x}} return P{{"foo": x}, {}} } + +// This is a degenerate case with a singleton type set, but we can create +// composite literals even if the structural type is a defined type. +type MyInts []int + +func _[P MyInts]() P { + return P{} +} diff --git a/src/go/types/type.go b/src/go/types/type.go index 31149cfd36..502c9b2d52 100644 --- a/src/go/types/type.go +++ b/src/go/types/type.go @@ -57,7 +57,7 @@ func optype(typ Type) Type { // See also issue #39680. if u := t.structuralType(); u != nil { assert(u != typ) // "naked" type parameters cannot be embedded - return u + return under(u) // optype should always return an underlying type } return theTop } From 6508fdad9d83d6792314639c9819a15894728682 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Thu, 8 Apr 2021 21:07:02 +0000 Subject: [PATCH 110/406] runtime: formalize and fix gcPercent synchronization Currently gcController.gcPercent is read non-atomically by gcControllerState.revise and gcTrigger.test, but these users may execute concurrently with an update to gcPercent. Although revise's results are best-effort, reading it directly in this way is, generally speaking, unsafe. This change makes gcPercent atomically updated for concurrent readers and documents the complete synchronization semantics. Because gcPercent otherwise only updated with the heap lock held or the world stopped, all other reads can remain unsynchronized. For #44167. Change-Id: If09af103aae84a1e133e2d4fed8ab888d4b8f457 Reviewed-on: https://go-review.googlesource.com/c/go/+/308690 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/runtime/mgc.go | 2 +- src/runtime/mgcpacer.go | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 6f8463c253..f937287281 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -545,7 +545,7 @@ func (t gcTrigger) test() bool { // own write. return gcController.heapLive >= gcController.trigger case gcTriggerTime: - if gcController.gcPercent < 0 { + if atomic.Loadint32(&gcController.gcPercent) < 0 { return false } lastgc := int64(atomic.Load64(&memstats.last_gc_nanotime)) diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 55f3bc926d..44b870446f 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -73,6 +73,10 @@ var gcController gcControllerState type gcControllerState struct { // Initialized from $GOGC. GOGC=off means no GC. + // + // Updated atomically with mheap_.lock held or during a STW. + // Safe to read atomically at any time, or non-atomically with + // mheap_.lock or STW. gcPercent int32 _ uint32 // padding so following 64-bit values are 8-byte aligned @@ -355,7 +359,7 @@ func (c *gcControllerState) startCycle() { // is when assists are enabled and the necessary statistics are // available). func (c *gcControllerState) revise() { - gcPercent := c.gcPercent + gcPercent := atomic.Loadint32(&c.gcPercent) if gcPercent < 0 { // If GC is disabled but we're running a forced GC, // act like GOGC is huge for the below calculations. @@ -800,7 +804,8 @@ func (c *gcControllerState) setGCPercent(in int32) int32 { if in < 0 { in = -1 } - c.gcPercent = in + // Write it atomically so readers like revise() can read it safely. + atomic.Storeint32(&c.gcPercent, in) c.heapMinimum = defaultHeapMinimum * uint64(c.gcPercent) / 100 // Update pacing in response to gcPercent change. c.commit(c.triggerRatio) From f99e40aac023d818e8c2594e5b8c075786087132 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Thu, 8 Apr 2021 22:01:13 +0000 Subject: [PATCH 111/406] runtime: detangle gcPaceScavenger from the pacer Currently gcPaceScavenger is called by gcControllerState.commit, but it manipulates global state which precludes testing. This change detangles the two. Change-Id: I10d8ebdf426d99ba49d2f2cb4fb64891e9fd6091 Reviewed-on: https://go-review.googlesource.com/c/go/+/309272 Reviewed-by: Michael Pratt Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot --- src/runtime/mgc.go | 1 + src/runtime/mgcpacer.go | 5 +++-- src/runtime/mgcscavenge.go | 13 +++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index f937287281..429b907322 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -971,6 +971,7 @@ func gcMarkTermination(nextTriggerRatio float64) { // Update GC trigger and pacing for the next cycle. gcController.commit(nextTriggerRatio) + gcPaceScavenger(gcController.heapGoal, gcController.lastHeapGoal) // Update timing memstats now := nanotime() diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 44b870446f..73fe6e15e4 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -769,8 +769,6 @@ func (c *gcControllerState) commit(triggerRatio float64) { mheap_.pagesSweptBasis.Store(pagesSwept) } } - - gcPaceScavenger() } // effectiveGrowthRatio returns the current effective heap growth @@ -796,6 +794,8 @@ func (c *gcControllerState) effectiveGrowthRatio() float64 { // setGCPercent updates gcPercent and all related pacer state. // Returns the old value of gcPercent. // +// Calls gcControllerState.commit. +// // The world must be stopped, or mheap_.lock must be held. func (c *gcControllerState) setGCPercent(in int32) int32 { assertWorldStoppedOrLockHeld(&mheap_.lock) @@ -819,6 +819,7 @@ func setGCPercent(in int32) (out int32) { systemstack(func() { lock(&mheap_.lock) out = gcController.setGCPercent(in) + gcPaceScavenger(gcController.heapGoal, gcController.lastHeapGoal) unlock(&mheap_.lock) }) diff --git a/src/runtime/mgcscavenge.go b/src/runtime/mgcscavenge.go index 2bb19985db..fb9b5c8694 100644 --- a/src/runtime/mgcscavenge.go +++ b/src/runtime/mgcscavenge.go @@ -105,7 +105,8 @@ func heapRetained() uint64 { } // gcPaceScavenger updates the scavenger's pacing, particularly -// its rate and RSS goal. +// its rate and RSS goal. For this, it requires the current heapGoal, +// and the heapGoal for the previous GC cycle. // // The RSS goal is based on the current heap goal with a small overhead // to accommodate non-determinism in the allocator. @@ -113,18 +114,22 @@ func heapRetained() uint64 { // The pacing is based on scavengePageRate, which applies to both regular and // huge pages. See that constant for more information. // +// Must be called whenever GC pacing is updated. +// // mheap_.lock must be held or the world must be stopped. -func gcPaceScavenger() { +func gcPaceScavenger(heapGoal, lastHeapGoal uint64) { + assertWorldStoppedOrLockHeld(&mheap_.lock) + // If we're called before the first GC completed, disable scavenging. // We never scavenge before the 2nd GC cycle anyway (we don't have enough // information about the heap yet) so this is fine, and avoids a fault // or garbage data later. - if gcController.lastHeapGoal == 0 { + if lastHeapGoal == 0 { mheap_.scavengeGoal = ^uint64(0) return } // Compute our scavenging goal. - goalRatio := float64(atomic.Load64(&gcController.heapGoal)) / float64(gcController.lastHeapGoal) + goalRatio := float64(heapGoal) / float64(lastHeapGoal) retainedGoal := uint64(float64(memstats.last_heap_inuse) * goalRatio) // Add retainExtraPercent overhead to retainedGoal. This calculation // looks strange but the purpose is to arrive at an integer division From b8da7e4c4c9e97b3d1ebfb07506acdd61277b988 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Wed, 20 Oct 2021 13:56:15 -0700 Subject: [PATCH 112/406] cmd/compile: fix inlining of labeled for loops There is already a mechanism using inlgen to rename labels insided inlined functions so that they are unique and don't clash with loops in the outer function. This is used for OLABEL and OGOTO. Now that we are doing inlining of OFOR loops, we need to do this translation for OBREAK, OCONTINUE, and OFOR. I also added the translation for ORANGE loops, in anticipation of a CL that will allow inlining of ORANGE for loops. Fixes #49100 Change-Id: I2ccddc3350370825c386965f4a1e4bc54d3c369b Reviewed-on: https://go-review.googlesource.com/c/go/+/357649 Run-TryBot: Dan Scales TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky Trust: Dan Scales --- src/cmd/compile/internal/inline/inl.go | 35 +++++++++++++++++++++----- test/fixedbugs/issue49100.go | 27 ++++++++++++++++++++ test/fixedbugs/issue49100.out | 12 +++++++++ 3 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 test/fixedbugs/issue49100.go create mode 100644 test/fixedbugs/issue49100.out diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index a2268a5465..fb6cf53155 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -1223,7 +1223,7 @@ func (subst *inlsubst) node(n ir.Node) ir.Node { // Don't do special substitutions if inside a closure break } - // Since we don't handle bodies with closures, + // Because of the above test for subst.newclofn, // this return is guaranteed to belong to the current inlined function. n := n.(*ir.ReturnStmt) init := subst.list(n.Init()) @@ -1251,7 +1251,7 @@ func (subst *inlsubst) node(n ir.Node) ir.Node { typecheck.Stmts(init) return ir.NewBlockStmt(base.Pos, init) - case ir.OGOTO: + case ir.OGOTO, ir.OBREAK, ir.OCONTINUE: if subst.newclofn != nil { // Don't do special substitutions if inside a closure break @@ -1260,8 +1260,7 @@ func (subst *inlsubst) node(n ir.Node) ir.Node { m := ir.Copy(n).(*ir.BranchStmt) m.SetPos(subst.updatedPos(m.Pos())) *m.PtrInit() = nil - p := fmt.Sprintf("%s·%d", n.Label.Name, inlgen) - m.Label = typecheck.Lookup(p) + m.Label = translateLabel(n.Label) return m case ir.OLABEL: @@ -1273,8 +1272,7 @@ func (subst *inlsubst) node(n ir.Node) ir.Node { m := ir.Copy(n).(*ir.LabelStmt) m.SetPos(subst.updatedPos(m.Pos())) *m.PtrInit() = nil - p := fmt.Sprintf("%s·%d", n.Label.Name, inlgen) - m.Label = typecheck.Lookup(p) + m.Label = translateLabel(n.Label) return m case ir.OCLOSURE: @@ -1286,6 +1284,21 @@ func (subst *inlsubst) node(n ir.Node) ir.Node { m.SetPos(subst.updatedPos(m.Pos())) ir.EditChildren(m, subst.edit) + if subst.newclofn == nil { + // Translate any label on FOR or RANGE loops + if m.Op() == ir.OFOR { + m := m.(*ir.ForStmt) + m.Label = translateLabel(m.Label) + return m + } + + if m.Op() == ir.ORANGE { + m := m.(*ir.RangeStmt) + m.Label = translateLabel(m.Label) + return m + } + } + switch m := m.(type) { case *ir.AssignStmt: if lhs, ok := m.X.(*ir.Name); ok && lhs.Defn == &subst.defnMarker { @@ -1302,6 +1315,16 @@ func (subst *inlsubst) node(n ir.Node) ir.Node { return m } +// translateLabel makes a label from an inlined function (if non-nil) be unique by +// adding "·inlgen". +func translateLabel(l *types.Sym) *types.Sym { + if l == nil { + return nil + } + p := fmt.Sprintf("%s·%d", l.Name, inlgen) + return typecheck.Lookup(p) +} + func (subst *inlsubst) updatedPos(xpos src.XPos) src.XPos { if subst.noPosUpdate { return xpos diff --git a/test/fixedbugs/issue49100.go b/test/fixedbugs/issue49100.go new file mode 100644 index 0000000000..3a2e972751 --- /dev/null +++ b/test/fixedbugs/issue49100.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2015 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 main + +func f(j int) { +loop: + for i := 0; i < 4; i++ { + if i == 1 { + continue loop + } + println(j, i) + } +} + +func main() { +loop: + for j := 0; j < 5; j++ { + f(j) + if j == 3 { + break loop + } + } +} diff --git a/test/fixedbugs/issue49100.out b/test/fixedbugs/issue49100.out new file mode 100644 index 0000000000..326d41365a --- /dev/null +++ b/test/fixedbugs/issue49100.out @@ -0,0 +1,12 @@ +0 0 +0 2 +0 3 +1 0 +1 2 +1 3 +2 0 +2 2 +2 3 +3 0 +3 2 +3 3 From 5a3d0f5a6361a2a1ccba19ad8d8da8b4367ea2c9 Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Mon, 9 Aug 2021 11:17:08 -0500 Subject: [PATCH 113/406] cmd/internal/obj/ppc64: rework argument classifications This introduces a number of new classifications which will make it easier to generate functions to assemble the new instructions of ISA 3.1, and potentially earlier versions. No code generation changes should occur as a result of these. These allow finer control over how an opcode is matched to an optab entry. Literal values are now classified based on the smallest number of bits needed to encode, and matching rules will accept a literal if it can be zero/sign extended to fit a larger literal class. Likewise, support classifying even register numbers for GPR, VSX, and FPR instructions. Some instructions require and even/odd register pair, and these are usually represented by specifying the even register, and similarly encoded. Likewise, add a unit test for the argument classifier function (aclass). This caught an off-by-one bug in aclass which is also fixed. Updates #44549 Change-Id: Ia03013aea8b56c4d59b7c3812cdd67ddb3b720b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/350152 Reviewed-by: Cherry Mui Reviewed-by: Lynn Boger Run-TryBot: Cherry Mui TryBot-Result: Go Bot --- src/cmd/internal/obj/ppc64/a.out.go | 89 +++++---- src/cmd/internal/obj/ppc64/anames9.go | 22 ++- src/cmd/internal/obj/ppc64/asm9.go | 248 +++++++++++++------------ src/cmd/internal/obj/ppc64/asm_test.go | 114 ++++++++++++ 4 files changed, 315 insertions(+), 158 deletions(-) diff --git a/src/cmd/internal/obj/ppc64/a.out.go b/src/cmd/internal/obj/ppc64/a.out.go index dd6d903e28..fe18296034 100644 --- a/src/cmd/internal/obj/ppc64/a.out.go +++ b/src/cmd/internal/obj/ppc64/a.out.go @@ -350,41 +350,64 @@ const ( ) const ( - C_NONE = iota - C_REG - C_FREG - C_VREG - C_VSREG - C_CREG - C_SPR /* special processor register */ - C_ZCON - C_SCON /* 16 bit signed */ - C_UCON /* 32 bit signed, low 16 bits 0 */ - C_ADDCON /* -0x8000 <= v < 0 */ - C_ANDCON /* 0 < v <= 0xFFFF */ - C_LCON /* other 32 */ - C_DCON /* other 64 (could subdivide further) */ - C_SACON /* $n(REG) where n <= int16 */ - C_LACON /* $n(REG) where int16 < n <= int32 */ - C_DACON /* $n(REG) where int32 < n */ - C_SBRA - C_LBRA - C_LBRAPIC - C_ZOREG // conjecture: either (1) register + zeroed offset, or (2) "R0" implies zero or C_REG - C_SOREG // D/DS form memory operation - C_LOREG // 32 bit addis + D/DS-form memory operation - C_FPSCR - C_XER - C_LR - C_CTR - C_ANY - C_GOK - C_ADDR - C_TLS_LE - C_TLS_IE - C_TEXTSIZE + C_NONE = iota + C_REGP /* An even numbered gpr which can be used a gpr pair argument */ + C_REG /* Any gpr register */ + C_FREGP /* An even numbered fpr which can be used a fpr pair argument */ + C_FREG /* Any fpr register */ + C_VREG /* Any vector register */ + C_VSREGP /* An even numbered vsx register which can be used as a vsx register pair argument */ + C_VSREG /* Any vector-scalar register */ + C_CREG /* The condition registor (CR) or a condition register field (CRx) */ + C_SPR /* special processor register */ + C_ZCON /* The constant zero */ + C_U1CON /* 1 bit unsigned constant */ + C_U2CON /* 2 bit unsigned constant */ + C_U3CON /* 3 bit unsigned constant */ + C_U4CON /* 4 bit unsigned constant */ + C_U5CON /* 5 bit unsigned constant */ + C_U8CON /* 8 bit unsigned constant */ + C_U15CON /* 15 bit unsigned constant */ + C_S16CON /* 16 bit signed constant */ + C_U16CON /* 16 bit unsigned constant */ + C_32S16CON /* Any 32 bit constant of the form 0x....0000, signed or unsigned */ + C_32CON /* Any constant which fits into 32 bits. Can be signed or unsigned */ + C_S34CON /* 34 bit signed constant */ + C_64CON /* Any constant which fits into 64 bits. Can be signed or unsigned */ + C_SACON /* $n(REG) where n <= int16 */ + C_LACON /* $n(REG) where n <= int32 */ + C_DACON /* $n(REG) where n <= int64 */ + C_SBRA /* A short offset argument to a branching instruction */ + C_LBRA /* A long offset argument to a branching instruction */ + C_LBRAPIC /* Like C_LBRA, but requires an extra NOP for potential TOC restore by the linker. */ + C_ZOREG /* An reg+reg memory arg, or a $0+reg memory op */ + C_SOREG /* An $n+reg memory arg where n is a 16 bit signed offset */ + C_LOREG /* An $n+reg memory arg where n is a 32 bit signed offset */ + C_FPSCR /* The fpscr register */ + C_XER /* The xer, holds the carry bit */ + C_LR /* The link register */ + C_CTR /* The count register */ + C_ANY /* Any argument */ + C_GOK /* A non-matched argument */ + C_ADDR /* A symbolic memory location */ + C_TLS_LE /* A thread local, local-exec, type memory arg */ + C_TLS_IE /* A thread local, initial-exec, type memory arg */ + C_TEXTSIZE /* An argument with Type obj.TYPE_TEXTSIZE */ C_NCLASS /* must be the last */ + + /* Aliased names which should be cleaned up, or integrated. */ + C_SCON = C_U15CON + C_UCON = C_32S16CON + C_ADDCON = C_S16CON + C_ANDCON = C_U16CON + C_LCON = C_32CON + + /* Aliased names which may be generated by ppc64map for the optab. */ + C_S3216CON = C_32S16CON // TODO: these should be treated differently (e.g xoris vs addis) + C_U3216CON = C_32S16CON + C_S32CON = C_32CON + C_U32CON = C_32CON ) const ( diff --git a/src/cmd/internal/obj/ppc64/anames9.go b/src/cmd/internal/obj/ppc64/anames9.go index b2632aa9ed..3b2aba77ab 100644 --- a/src/cmd/internal/obj/ppc64/anames9.go +++ b/src/cmd/internal/obj/ppc64/anames9.go @@ -6,19 +6,29 @@ package ppc64 var cnames9 = []string{ "NONE", + "REGP", "REG", + "FREGP", "FREG", "VREG", + "VSREGP", "VSREG", "CREG", "SPR", "ZCON", - "SCON", - "UCON", - "ADDCON", - "ANDCON", - "LCON", - "DCON", + "U1CON", + "U2CON", + "U3CON", + "U4CON", + "U5CON", + "U8CON", + "U15CON", + "S16CON", + "U16CON", + "32S16CON", + "32CON", + "S34CON", + "64CON", "SACON", "LACON", "DACON", diff --git a/src/cmd/internal/obj/ppc64/asm9.go b/src/cmd/internal/obj/ppc64/asm9.go index 6ed11b3f7e..08fb5118f0 100644 --- a/src/cmd/internal/obj/ppc64/asm9.go +++ b/src/cmd/internal/obj/ppc64/asm9.go @@ -307,8 +307,7 @@ var optab = []Optab{ {as: ABC, a6: C_ZOREG, type_: 15, size: 8}, {as: ASYNC, type_: 46, size: 4}, {as: AWORD, a1: C_LCON, type_: 40, size: 4}, - {as: ADWORD, a1: C_LCON, type_: 31, size: 8}, - {as: ADWORD, a1: C_DCON, type_: 31, size: 8}, + {as: ADWORD, a1: C_64CON, type_: 31, size: 8}, {as: ADWORD, a1: C_LACON, type_: 31, size: 8}, {as: AADDME, a1: C_REG, a6: C_REG, type_: 47, size: 4}, {as: AEXTSB, a1: C_REG, a6: C_REG, type_: 48, size: 4}, @@ -336,7 +335,7 @@ var optab = []Optab{ {as: ALDMX, a1: C_SOREG, a6: C_REG, type_: 45, size: 4}, /* load doubleword monitored, x-form */ {as: AMADDHD, a1: C_REG, a2: C_REG, a3: C_REG, a6: C_REG, type_: 83, size: 4}, /* multiply-add high/low doubleword, va-form */ {as: AADDEX, a1: C_REG, a2: C_REG, a3: C_SCON, a6: C_REG, type_: 94, size: 4}, /* add extended using alternate carry, z23-form */ - {as: ACRAND, a1: C_CREG, a6: C_CREG, type_: 2, size: 4}, /* logical ops for condition registers xl-form */ + {as: ACRAND, a1: C_CREG, a2: C_CREG, a6: C_CREG, type_: 2, size: 4}, /* logical ops for condition register bits xl-form */ /* Vector instructions */ @@ -485,15 +484,15 @@ var optab = []Optab{ {as: AXVCVSXDDP, a1: C_VSREG, a6: C_VSREG, type_: 89, size: 4}, /* vsx vector integer-fp conversion, xx2-form */ {as: ACMP, a1: C_REG, a6: C_REG, type_: 70, size: 4}, - {as: ACMP, a1: C_REG, a2: C_REG, a6: C_REG, type_: 70, size: 4}, + {as: ACMP, a1: C_REG, a2: C_CREG, a6: C_REG, type_: 70, size: 4}, {as: ACMP, a1: C_REG, a6: C_ADDCON, type_: 71, size: 4}, - {as: ACMP, a1: C_REG, a2: C_REG, a6: C_ADDCON, type_: 71, size: 4}, + {as: ACMP, a1: C_REG, a2: C_CREG, a6: C_ADDCON, type_: 71, size: 4}, {as: ACMPU, a1: C_REG, a6: C_REG, type_: 70, size: 4}, - {as: ACMPU, a1: C_REG, a2: C_REG, a6: C_REG, type_: 70, size: 4}, + {as: ACMPU, a1: C_REG, a2: C_CREG, a6: C_REG, type_: 70, size: 4}, {as: ACMPU, a1: C_REG, a6: C_ANDCON, type_: 71, size: 4}, - {as: ACMPU, a1: C_REG, a2: C_REG, a6: C_ANDCON, type_: 71, size: 4}, + {as: ACMPU, a1: C_REG, a2: C_CREG, a6: C_ANDCON, type_: 71, size: 4}, {as: AFCMPO, a1: C_FREG, a6: C_FREG, type_: 70, size: 4}, - {as: AFCMPO, a1: C_FREG, a2: C_REG, a6: C_FREG, type_: 70, size: 4}, + {as: AFCMPO, a1: C_FREG, a2: C_CREG, a6: C_FREG, type_: 70, size: 4}, {as: ATW, a1: C_LCON, a2: C_REG, a6: C_REG, type_: 60, size: 4}, {as: ATW, a1: C_LCON, a2: C_REG, a6: C_ADDCON, type_: 61, size: 4}, {as: ADCBF, a1: C_ZOREG, type_: 43, size: 4}, @@ -584,9 +583,11 @@ func addpad(pc, a int64, ctxt *obj.Link, cursym *obj.LSym) int { // or "MOVD R5, foo+10(SP) or pseudo-register is used. The other common case is when // generating constants in register like "MOVD $constant, Rx". func (c *ctxt9) getimpliedreg(a *obj.Addr, p *obj.Prog) int { - switch oclass(a) { - case C_ADDCON, C_ANDCON, C_UCON, C_LCON, C_SCON, C_ZCON: + class := oclass(a) + if class >= C_ZCON && class <= C_64CON { return REGZERO + } + switch class { case C_SACON, C_LACON: return REGSP case C_LOREG, C_SOREG, C_ZOREG: @@ -839,45 +840,49 @@ func isuint32(v uint64) bool { return uint64(uint32(v)) == v } +func (c *ctxt9) aclassreg(reg int16) int { + if REG_R0 <= reg && reg <= REG_R31 { + return C_REGP + int(reg&1) + } + if REG_F0 <= reg && reg <= REG_F31 { + return C_FREGP + int(reg&1) + } + if REG_V0 <= reg && reg <= REG_V31 { + return C_VREG + } + if REG_VS0 <= reg && reg <= REG_VS63 { + return C_VSREGP + int(reg&1) + } + if REG_CR0 <= reg && reg <= REG_CR7 || reg == REG_CR { + return C_CREG + } + if REG_SPR0 <= reg && reg <= REG_SPR0+1023 { + switch reg { + case REG_LR: + return C_LR + + case REG_XER: + return C_XER + + case REG_CTR: + return C_CTR + } + + return C_SPR + } + if reg == REG_FPSCR { + return C_FPSCR + } + return C_GOK +} + func (c *ctxt9) aclass(a *obj.Addr) int { switch a.Type { case obj.TYPE_NONE: return C_NONE case obj.TYPE_REG: - if REG_R0 <= a.Reg && a.Reg <= REG_R31 { - return C_REG - } - if REG_F0 <= a.Reg && a.Reg <= REG_F31 { - return C_FREG - } - if REG_V0 <= a.Reg && a.Reg <= REG_V31 { - return C_VREG - } - if REG_VS0 <= a.Reg && a.Reg <= REG_VS63 { - return C_VSREG - } - if REG_CR0 <= a.Reg && a.Reg <= REG_CR7 || a.Reg == REG_CR { - return C_CREG - } - if REG_SPR0 <= a.Reg && a.Reg <= REG_SPR0+1023 { - switch a.Reg { - case REG_LR: - return C_LR - - case REG_XER: - return C_XER - - case REG_CTR: - return C_CTR - } - - return C_SPR - } - if a.Reg == REG_FPSCR { - return C_FPSCR - } - return C_GOK + return c.aclassreg(a.Reg) case obj.TYPE_MEM: switch a.Name { @@ -948,7 +953,7 @@ func (c *ctxt9) aclass(a *obj.Addr) int { case obj.NAME_NONE: c.instoffset = a.Offset if a.Reg != 0 { - if -BIG <= c.instoffset && c.instoffset <= BIG { + if -BIG <= c.instoffset && c.instoffset < BIG { return C_SACON } if isint32(c.instoffset) { @@ -985,35 +990,47 @@ func (c *ctxt9) aclass(a *obj.Addr) int { } if c.instoffset >= 0 { - if c.instoffset == 0 { - return C_ZCON + sbits := bits.Len64(uint64(c.instoffset)) + switch { + case sbits <= 5: + return C_ZCON + sbits + case sbits <= 8: + return C_U8CON + case sbits <= 15: + return C_U15CON + case sbits <= 16: + return C_U16CON + case sbits <= 31: + // Special case, a positive int32 value which is a multiple of 2^16 + if c.instoffset&0xFFFF == 0 { + return C_U3216CON + } + return C_U32CON + case sbits <= 32: + return C_U32CON + case sbits <= 33: + return C_S34CON + default: + return C_64CON } - if c.instoffset <= 0x7fff { - return C_SCON + } else { + sbits := bits.Len64(uint64(^c.instoffset)) + switch { + case sbits <= 15: + return C_S16CON + case sbits <= 31: + // Special case, a negative int32 value which is a multiple of 2^16 + if c.instoffset&0xFFFF == 0 { + return C_S3216CON + } + return C_S32CON + case sbits <= 33: + return C_S34CON + default: + return C_64CON } - if c.instoffset <= 0xffff { - return C_ANDCON - } - if c.instoffset&0xffff == 0 && isuint32(uint64(c.instoffset)) { /* && (instoffset & (1<<31)) == 0) */ - return C_UCON - } - if isint32(c.instoffset) || isuint32(uint64(c.instoffset)) { - return C_LCON - } - return C_DCON } - if c.instoffset >= -0x8000 { - return C_ADDCON - } - if c.instoffset&0xffff == 0 && isint32(c.instoffset) { - return C_UCON - } - if isint32(c.instoffset) { - return C_LCON - } - return C_DCON - case obj.TYPE_BRANCH: if a.Sym != nil && c.ctxt.Flag_dynlink { return C_LBRAPIC @@ -1062,15 +1079,7 @@ func (c *ctxt9) oplook(p *obj.Prog) *Optab { a2 := C_NONE if p.Reg != 0 { - if REG_R0 <= p.Reg && p.Reg <= REG_R31 { - a2 = C_REG - } else if REG_V0 <= p.Reg && p.Reg <= REG_V31 { - a2 = C_VREG - } else if REG_VS0 <= p.Reg && p.Reg <= REG_VS63 { - a2 = C_VSREG - } else if REG_F0 <= p.Reg && p.Reg <= REG_F31 { - a2 = C_FREG - } + a2 = c.aclassreg(p.Reg) } // c.ctxt.Logf("oplook %v %d %d %d %d\n", p, a1, a2, a3, a4, a5, a6) @@ -1097,71 +1106,72 @@ func (c *ctxt9) oplook(p *obj.Prog) *Optab { return &ops[0] } +// Compare two operand types (ex C_REG, or C_SCON) +// and return true if b is compatible with a. +// +// Argument comparison isn't reflexitive, so care must be taken. +// a is the argument type as found in optab, b is the argument as +// fitted by aclass. func cmp(a int, b int) bool { if a == b { return true } switch a { - case C_LCON: - if b == C_ZCON || b == C_SCON || b == C_UCON || b == C_ADDCON || b == C_ANDCON { - return true - } - - case C_ADDCON: - if b == C_ZCON || b == C_SCON { - return true - } - - case C_ANDCON: - if b == C_ZCON || b == C_SCON { - return true - } case C_SPR: if b == C_LR || b == C_XER || b == C_CTR { return true } - case C_UCON: - if b == C_ZCON { - return true - } + case C_U1CON: + return cmp(C_ZCON, b) + case C_U2CON: + return cmp(C_U1CON, b) + case C_U3CON: + return cmp(C_U2CON, b) + case C_U4CON: + return cmp(C_U3CON, b) + case C_U5CON: + return cmp(C_U4CON, b) + case C_U8CON: + return cmp(C_U5CON, b) + case C_U15CON: + return cmp(C_U8CON, b) + case C_U16CON: + return cmp(C_U15CON, b) - case C_SCON: - if b == C_ZCON { - return true - } + case C_S16CON: + return cmp(C_U15CON, b) + case C_32CON: + return cmp(C_S16CON, b) || cmp(C_U16CON, b) || cmp(C_32S16CON, b) + case C_S34CON: + return cmp(C_32CON, b) + case C_64CON: + return cmp(C_S34CON, b) + + case C_32S16CON: + return cmp(C_ZCON, b) case C_LACON: - if b == C_SACON { - return true - } + return cmp(C_SACON, b) case C_LBRA: - if b == C_SBRA { - return true - } + return cmp(C_SBRA, b) case C_SOREG: - if b == C_ZOREG { - return true - } + return cmp(C_ZOREG, b) case C_LOREG: - if b == C_SOREG || b == C_ZOREG { - return true - } + return cmp(C_SOREG, b) + // An even/odd register input always matches the regular register types. case C_REG: - if b == C_ZCON { - return r0iszero != 0 /*TypeKind(100016)*/ - } - + return cmp(C_REGP, b) || (b == C_ZCON && r0iszero != 0) + case C_FREG: + return cmp(C_FREGP, b) case C_VSREG: /* Allow any VR argument as a VSR operand. */ - if b == C_VREG { - return true - } + return cmp(C_VSREGP, b) || cmp(C_VREG, b) case C_ANY: return true diff --git a/src/cmd/internal/obj/ppc64/asm_test.go b/src/cmd/internal/obj/ppc64/asm_test.go index ec0ba19e37..3a9b87363c 100644 --- a/src/cmd/internal/obj/ppc64/asm_test.go +++ b/src/cmd/internal/obj/ppc64/asm_test.go @@ -6,9 +6,12 @@ package ppc64 import ( "bytes" + "cmd/internal/obj" + "cmd/internal/objabi" "fmt" "internal/testenv" "io/ioutil" + "math" "os" "os/exec" "path/filepath" @@ -437,3 +440,114 @@ func TestRegValueAlignment(t *testing.T) { tstFunc(t.rstart, t.rend, t.msk, t.rout) } } + +// Verify interesting obj.Addr arguments are classified correctly. +func TestAddrClassifier(t *testing.T) { + type cmplx struct { + pic int + pic_dyn int + dyn int + nonpic int + } + tsts := [...]struct { + arg obj.Addr + output interface{} + }{ + // Supported register type args + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_R1}, C_REG}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_R2}, C_REGP}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_F1}, C_FREG}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_F2}, C_FREGP}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_V2}, C_VREG}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_VS1}, C_VSREG}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_VS2}, C_VSREGP}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_CR}, C_CREG}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_CR1}, C_CREG}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_SPR0}, C_SPR}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_SPR0 + 1}, C_XER}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_SPR0 + 8}, C_LR}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_SPR0 + 9}, C_CTR}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_FPSCR}, C_FPSCR}, + + // Memory type arguments. + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_GOTREF}, C_ADDR}, + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_TOCREF}, C_ADDR}, + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_EXTERN, Sym: &obj.LSym{Type: objabi.STLSBSS}}, cmplx{C_TLS_IE, C_TLS_IE, C_TLS_LE, C_TLS_LE}}, + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_EXTERN, Sym: &obj.LSym{Type: objabi.SDATA}}, C_ADDR}, + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_AUTO}, C_SOREG}, + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_AUTO, Offset: BIG}, C_LOREG}, + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_AUTO, Offset: -BIG - 1}, C_LOREG}, + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_PARAM}, C_SOREG}, + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_PARAM, Offset: BIG}, C_LOREG}, + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_PARAM, Offset: -BIG - 33}, C_LOREG}, // 33 is FixedFrameSize-1 + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_NONE}, C_ZOREG}, + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_NONE, Offset: 1}, C_SOREG}, + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_NONE, Offset: BIG}, C_LOREG}, + {obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_NONE, Offset: -BIG - 33}, C_LOREG}, + + // Misc (golang initializes -0.0 to 0.0, hence the obfuscation below) + {obj.Addr{Type: obj.TYPE_TEXTSIZE}, C_TEXTSIZE}, + {obj.Addr{Type: obj.TYPE_FCONST, Val: 0.0}, C_ZCON}, + {obj.Addr{Type: obj.TYPE_FCONST, Val: math.Float64frombits(0x8000000000000000)}, C_S16CON}, + + // Address type arguments + {obj.Addr{Type: obj.TYPE_ADDR, Reg: REG_R0, Name: obj.NAME_NONE, Offset: 1}, C_SACON}, + {obj.Addr{Type: obj.TYPE_ADDR, Reg: REG_R0, Name: obj.NAME_NONE, Offset: BIG}, C_LACON}, + {obj.Addr{Type: obj.TYPE_ADDR, Reg: REG_R0, Name: obj.NAME_NONE, Offset: -BIG - 1}, C_LACON}, + {obj.Addr{Type: obj.TYPE_ADDR, Reg: REG_R0, Name: obj.NAME_NONE, Offset: 1 << 32}, C_DACON}, + {obj.Addr{Type: obj.TYPE_ADDR, Name: obj.NAME_EXTERN, Sym: &obj.LSym{Type: objabi.SDATA}}, C_LACON}, + {obj.Addr{Type: obj.TYPE_ADDR, Name: obj.NAME_STATIC, Sym: &obj.LSym{Type: objabi.SDATA}}, C_LACON}, + {obj.Addr{Type: obj.TYPE_ADDR, Reg: REG_R0, Name: obj.NAME_AUTO, Offset: 1}, C_SACON}, + {obj.Addr{Type: obj.TYPE_ADDR, Reg: REG_R0, Name: obj.NAME_AUTO, Offset: BIG}, C_LACON}, + {obj.Addr{Type: obj.TYPE_ADDR, Reg: REG_R0, Name: obj.NAME_AUTO, Offset: -BIG - 1}, C_LACON}, + {obj.Addr{Type: obj.TYPE_ADDR, Reg: REG_R0, Name: obj.NAME_PARAM, Offset: 1}, C_SACON}, + {obj.Addr{Type: obj.TYPE_ADDR, Reg: REG_R0, Name: obj.NAME_PARAM, Offset: BIG}, C_LACON}, + {obj.Addr{Type: obj.TYPE_ADDR, Reg: REG_R0, Name: obj.NAME_PARAM, Offset: -BIG - 33}, C_LACON}, // 33 is FixedFrameSize-1 + + // Constant type arguments + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 0}, C_ZCON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1}, C_U1CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 2}, C_U2CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 4}, C_U3CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 8}, C_U4CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 16}, C_U5CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 32}, C_U8CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 << 14}, C_U15CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 << 15}, C_U16CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 << 16}, C_U3216CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 + 1<<16}, C_U32CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 << 32}, C_S34CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 << 33}, C_64CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: -1}, C_S16CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: -0x10000}, C_S3216CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: -0x10001}, C_S32CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: -(1 << 33)}, C_S34CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: -(1 << 34)}, C_64CON}, + + // Branch like arguments + {obj.Addr{Type: obj.TYPE_BRANCH, Sym: &obj.LSym{Type: objabi.SDATA}}, cmplx{C_SBRA, C_LBRAPIC, C_LBRAPIC, C_SBRA}}, + {obj.Addr{Type: obj.TYPE_BRANCH}, C_SBRA}, + } + + pic_ctxt9 := ctxt9{ctxt: &obj.Link{Flag_shared: true, Arch: &Linkppc64}, autosize: 0} + pic_dyn_ctxt9 := ctxt9{ctxt: &obj.Link{Flag_shared: true, Flag_dynlink: true, Arch: &Linkppc64}, autosize: 0} + dyn_ctxt9 := ctxt9{ctxt: &obj.Link{Flag_dynlink: true, Arch: &Linkppc64}, autosize: 0} + nonpic_ctxt9 := ctxt9{ctxt: &obj.Link{Arch: &Linkppc64}, autosize: 0} + ctxts := [...]*ctxt9{&pic_ctxt9, &pic_dyn_ctxt9, &dyn_ctxt9, &nonpic_ctxt9} + name := [...]string{"pic", "pic_dyn", "dyn", "nonpic"} + for _, tst := range tsts { + var expect []int + switch tst.output.(type) { + case cmplx: + v := tst.output.(cmplx) + expect = []int{v.pic, v.pic_dyn, v.dyn, v.nonpic} + case int: + expect = []int{tst.output.(int), tst.output.(int), tst.output.(int), tst.output.(int)} + } + for i, _ := range ctxts { + if output := ctxts[i].aclass(&tst.arg); output != expect[i] { + t.Errorf("%s.aclass(%v) = %v, expected %v\n", name[i], tst.arg, DRconv(output), DRconv(expect[i])) + } + } + } +} From 3beab0cd71e9e4fedba13d762ed35db04851f1be Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Thu, 21 Oct 2021 18:59:10 -0400 Subject: [PATCH 114/406] go/types, types2: add the Interface.MarkImplicit method Add a new interface method, MarkImplicit, to allow marking interfaces as implicit from outside the type-checker. This is necessary so that we can capture the implicit bit in export data, and use it from importers. For #48424 For #49040 Change-Id: I999aba2a298f92432326d7ccbd87fe133a2e1a72 Reviewed-on: https://go-review.googlesource.com/c/go/+/357796 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/types2/interface.go | 8 ++++++++ src/go/types/interface.go | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/cmd/compile/internal/types2/interface.go b/src/cmd/compile/internal/types2/interface.go index 0704628dc6..048fcab024 100644 --- a/src/cmd/compile/internal/types2/interface.go +++ b/src/cmd/compile/internal/types2/interface.go @@ -54,6 +54,14 @@ func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface { return typ } +// MarkImplicit marks the interface t as implicit, meaning this interface +// corresponds to a constraint literal such as ~T or A|B without explicit +// interface embedding. MarkImplicit should be called before any concurrent use +// of implicit interfaces. +func (t *Interface) MarkImplicit() { + t.implicit = true +} + // NumExplicitMethods returns the number of explicitly declared methods of interface t. func (t *Interface) NumExplicitMethods() int { return len(t.methods) } diff --git a/src/go/types/interface.go b/src/go/types/interface.go index 2f4f10d45f..3d5573373f 100644 --- a/src/go/types/interface.go +++ b/src/go/types/interface.go @@ -73,6 +73,14 @@ func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface { return typ } +// MarkImplicit marks the interface t as implicit, meaning this interface +// corresponds to a constraint literal such as ~T or A|B without explicit +// interface embedding. MarkImplicit should be called before any concurrent use +// of implicit interfaces. +func (t *Interface) MarkImplicit() { + t.implicit = true +} + // NumExplicitMethods returns the number of explicitly declared methods of interface t. func (t *Interface) NumExplicitMethods() int { return len(t.methods) } From 23e57e59556f42d6935b65be63b59a8b0fc0e6ad Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Thu, 21 Oct 2021 23:35:05 +0700 Subject: [PATCH 115/406] reflect: make Value.Pointer panic on bad notinheap pointers Same as CL 350153 did for Value.Elem to panic on bad notinheap pointers. While at it, also add more tests for notinheap deref. Change-Id: Id7d9d12ad8467de5926b6a7e8f9d659fea5fedb5 Reviewed-on: https://go-review.googlesource.com/c/go/+/357630 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Keith Randall --- src/reflect/all_test.go | 2 ++ src/reflect/value.go | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index fcd0e15f0a..922998125b 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -7721,6 +7721,8 @@ func TestNotInHeapDeref(t *testing.T) { v = ValueOf((*nih)(unsafe.Pointer(new(int)))) shouldPanic("reflect: reflect.Value.Elem on an invalid notinheap pointer", func() { v.Elem() }) + shouldPanic("reflect: reflect.Value.Pointer on an invalid notinheap pointer", func() { v.Pointer() }) + shouldPanic("reflect: reflect.Value.UnsafePointer on an invalid notinheap pointer", func() { v.UnsafePointer() }) } func TestMethodCallValueCodePtr(t *testing.T) { diff --git a/src/reflect/value.go b/src/reflect/value.go index 7bb8ae5b97..3e723e82a4 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -1940,11 +1940,13 @@ func (v Value) Pointer() uintptr { switch k { case Ptr: if v.typ.ptrdata == 0 { - // Handle pointers to go:notinheap types directly, - // so we never materialize such pointers as an - // unsafe.Pointer. (Such pointers are always indirect.) - // See issue 42076. - return *(*uintptr)(v.ptr) + val := *(*uintptr)(v.ptr) + // Since it is a not-in-heap pointer, all pointers to the heap are + // forbidden! See comment in Value.Elem and issue #48399. + if !verifyNotInHeapPtr(val) { + panic("reflect: reflect.Value.Pointer on an invalid notinheap pointer") + } + return val } fallthrough case Chan, Map, UnsafePointer: From 9ff91b90988945c7bbe85fdef4a16d5f1af6b2c2 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Thu, 21 Oct 2021 14:31:40 +0700 Subject: [PATCH 116/406] cmd/compile: only look for struct type when crawling inline body CL 356254 fixed crawling of embeddable types during inline. However, we are too agressive, since when we call markEmbed for every type seen during inlining function body. That leads to false positive that for a non-embedded type, its unexported methods are also marked inline. Instead, we should only look at struct type that we seen during inlining function body, and calling markEmbed for all of its embedded fields. Fixes #49094 Change-Id: I6ef9a8bf1fc649ec6bf75e4883f6031ec8560ba1 Reviewed-on: https://go-review.googlesource.com/c/go/+/357232 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/typecheck/crawler.go | 8 +++++++- test/fixedbugs/issue49094.dir/a.go | 11 +++++++++++ test/fixedbugs/issue49094.dir/b.go | 11 +++++++++++ test/fixedbugs/issue49094.dir/p.go | 15 +++++++++++++++ test/fixedbugs/issue49094.go | 7 +++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/issue49094.dir/a.go create mode 100644 test/fixedbugs/issue49094.dir/b.go create mode 100644 test/fixedbugs/issue49094.dir/p.go create mode 100644 test/fixedbugs/issue49094.go diff --git a/src/cmd/compile/internal/typecheck/crawler.go b/src/cmd/compile/internal/typecheck/crawler.go index b214ef2279..e1489ceedd 100644 --- a/src/cmd/compile/internal/typecheck/crawler.go +++ b/src/cmd/compile/internal/typecheck/crawler.go @@ -217,7 +217,13 @@ func (p *crawler) markInlBody(n *ir.Name) { // // We generate the wrapper for "struct{ t }".M, and inline call // to "struct{ t }".M, which makes "t.M" reachable. - p.markEmbed(t) + if t.IsStruct() { + for _, f := range t.FieldSlice() { + if f.Embedded != 0 { + p.markEmbed(f.Type) + } + } + } } } diff --git a/test/fixedbugs/issue49094.dir/a.go b/test/fixedbugs/issue49094.dir/a.go new file mode 100644 index 0000000000..9ec0fd9f93 --- /dev/null +++ b/test/fixedbugs/issue49094.dir/a.go @@ -0,0 +1,11 @@ +// Copyright 2021 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 a + +type A struct{} + +func (a *A) f() bool { + return true +} diff --git a/test/fixedbugs/issue49094.dir/b.go b/test/fixedbugs/issue49094.dir/b.go new file mode 100644 index 0000000000..f2361958ac --- /dev/null +++ b/test/fixedbugs/issue49094.dir/b.go @@ -0,0 +1,11 @@ +// Copyright 2021 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 b + +import "./a" + +func M(r *a.A) string { + return "" +} diff --git a/test/fixedbugs/issue49094.dir/p.go b/test/fixedbugs/issue49094.dir/p.go new file mode 100644 index 0000000000..581faf19ac --- /dev/null +++ b/test/fixedbugs/issue49094.dir/p.go @@ -0,0 +1,15 @@ +// Copyright 2021 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 p + +import ( + "./b" +) + +type S struct{} + +func (S) M() { + b.M(nil) +} diff --git a/test/fixedbugs/issue49094.go b/test/fixedbugs/issue49094.go new file mode 100644 index 0000000000..b83fbd7af1 --- /dev/null +++ b/test/fixedbugs/issue49094.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2021 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 ignored From ff8115d1a1b3bcaadfea10f6913e9fe083013799 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Fri, 22 Oct 2021 15:29:41 +0800 Subject: [PATCH 117/406] internal/poll: fix a few function names on comments Change-Id: I5b1dfeeb0ae5ac32667633151ef83bcf4654c43f Reviewed-on: https://go-review.googlesource.com/c/go/+/357957 Reviewed-by: Tobias Klauser Reviewed-by: Emmanuel Odeke Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot --- src/internal/poll/fd_unix.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internal/poll/fd_unix.go b/src/internal/poll/fd_unix.go index 60b59df2e3..5489662889 100644 --- a/src/internal/poll/fd_unix.go +++ b/src/internal/poll/fd_unix.go @@ -230,7 +230,7 @@ func (fd *FD) ReadFrom(p []byte) (int, syscall.Sockaddr, error) { } } -// ReadFrom wraps the recvfrom network call for IPv4. +// ReadFromInet4 wraps the recvfrom network call for IPv4. func (fd *FD) ReadFromInet4(p []byte, from *syscall.SockaddrInet4) (int, error) { if err := fd.readLock(); err != nil { return 0, err @@ -257,7 +257,7 @@ func (fd *FD) ReadFromInet4(p []byte, from *syscall.SockaddrInet4) (int, error) } } -// ReadFrom wraps the recvfrom network call for IPv6. +// ReadFromInet6 wraps the recvfrom network call for IPv6. func (fd *FD) ReadFromInet6(p []byte, from *syscall.SockaddrInet6) (int, error) { if err := fd.readLock(); err != nil { return 0, err From 76dd01f45786757a08f1e070245d174cd64559be Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 20 Oct 2021 13:12:43 -0700 Subject: [PATCH 118/406] cmd/compile/internal/types2: reduce output when describing type parameters There's no need to say "type parameter" for a type parameter. The name is sufficient (they are always named), and the prose is followed by "constrained by". Change-Id: I98df8caa1432b8b7a874e58da6e3ed6be102b4a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/357410 Trust: Robert Griesemer Run-TryBot: Robert Griesemer TryBot-Result: Go Bot Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/operand.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cmd/compile/internal/types2/operand.go b/src/cmd/compile/internal/types2/operand.go index 19326b8342..a5b2729451 100644 --- a/src/cmd/compile/internal/types2/operand.go +++ b/src/cmd/compile/internal/types2/operand.go @@ -176,17 +176,14 @@ func operandString(x *operand, qf Qualifier) string { if hasType { if x.typ != Typ[Invalid] { var intro string - var tpar *TypeParam if isGeneric(x.typ) { intro = " of parameterized type " - } else if tpar = asTypeParam(x.typ); tpar != nil { - intro = " of type parameter " } else { intro = " of type " } buf.WriteString(intro) WriteType(&buf, x.typ, qf) - if tpar != nil { + if tpar := asTypeParam(x.typ); tpar != nil { buf.WriteString(" constrained by ") WriteType(&buf, tpar.bound, qf) // do not compute interface type sets here } From 5d414d180bfb631d3835f819f7f524ec271f11eb Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 19 Oct 2021 18:09:30 -0700 Subject: [PATCH 119/406] cmd/compile/internal/types2: more detailed error messages for generic conversions - slightly refactor convertibleTo and convertibleToImpl - provide ability to return a conversion failure cause - add detailed cause for generic conversions For #47150. Change-Id: Ie97d89be0234414ef4df22a6920e18acc944a102 Reviewed-on: https://go-review.googlesource.com/c/go/+/357249 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/api.go | 2 +- .../compile/internal/types2/conversions.go | 84 ++++++++++++------- src/cmd/compile/internal/types2/operand.go | 1 + .../types2/testdata/examples/conversions.go2 | 22 ++--- 4 files changed, 67 insertions(+), 42 deletions(-) diff --git a/src/cmd/compile/internal/types2/api.go b/src/cmd/compile/internal/types2/api.go index e6d28af3c8..f13fa95b62 100644 --- a/src/cmd/compile/internal/types2/api.go +++ b/src/cmd/compile/internal/types2/api.go @@ -438,7 +438,7 @@ func AssignableTo(V, T Type) bool { // ConvertibleTo reports whether a value of type V is convertible to a value of type T. func ConvertibleTo(V, T Type) bool { x := operand{mode: value, typ: V} - return x.convertibleTo(nil, T) // check not needed for non-constant x + return x.convertibleTo(nil, T, nil) // check not needed for non-constant x; if check == nil, cause can be nil } // Implements reports whether type V implements interface T. diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index 112d728188..a4fba28fce 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -17,6 +17,7 @@ func (check *Checker) conversion(x *operand, T Type) { constArg := x.mode == constant_ var ok bool + var cause string switch { case constArg && isConstType(T): // constant conversion @@ -31,17 +32,20 @@ func (check *Checker) conversion(x *operand, T Type) { x.val = constant.MakeString(string(codepoint)) ok = true } - case x.convertibleTo(check, T): + case x.convertibleTo(check, T, &cause): // non-constant conversion x.mode = value ok = true } if !ok { - if x.mode != invalid { - check.errorf(x, "cannot convert %s to %s", x, T) - x.mode = invalid + var err error_ + err.errorf(x, "cannot convert %s to %s", x, T) + if cause != "" { + err.errorf(nopos, cause) } + check.report(&err) + x.mode = invalid return } @@ -80,57 +84,74 @@ func (check *Checker) conversion(x *operand, T Type) { // is tricky because we'd have to run updateExprType on the argument first. // (Issue #21982.) -// convertibleTo reports whether T(x) is valid. +// convertibleTo reports whether T(x) is valid. In the failure case, *cause +// may be set to the cause for the failure. // The check parameter may be nil if convertibleTo is invoked through an // exported API call, i.e., when all methods have been type-checked. -func (x *operand) convertibleTo(check *Checker, T Type) bool { +func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { // "x is assignable to T" - if ok, _ := x.assignableTo(check, T, nil); ok { + if ok, _ := x.assignableTo(check, T, cause); ok { return true } - // TODO(gri) consider passing under(x.typ), under(T) into convertibleToImpl (optimization) Vp, _ := under(x.typ).(*TypeParam) Tp, _ := under(T).(*TypeParam) + errorf := func(format string, args ...interface{}) { + if check != nil && cause != nil { + msg := check.sprintf(format, args...) + if *cause != "" { + msg += "\n\t" + *cause + } + *cause = msg + } + } + // generic cases // (generic operands cannot be constants, so we can ignore x.val) switch { case Vp != nil && Tp != nil: - x := *x // don't modify outer x return Vp.is(func(V *term) bool { - x.typ = V.typ return Tp.is(func(T *term) bool { - return x.convertibleToImpl(check, T.typ) + if !convertibleToImpl(check, V.typ, T.typ, cause) { + errorf("cannot convert %s (in %s) to %s (in %s)", V.typ, Vp, T.typ, Tp) + return false + } + return true }) }) case Vp != nil: - x := *x // don't modify outer x return Vp.is(func(V *term) bool { - x.typ = V.typ - return x.convertibleToImpl(check, T) + if !convertibleToImpl(check, V.typ, T, cause) { + errorf("cannot convert %s (in %s) to %s", V.typ, Vp, T) + return false + } + return true }) case Tp != nil: return Tp.is(func(T *term) bool { - return x.convertibleToImpl(check, T.typ) + if !convertibleToImpl(check, x.typ, T.typ, cause) { + errorf("cannot convert %s to %s (in %s)", x.typ, T.typ, Tp) + return false + } + return true }) } // non-generic case - return x.convertibleToImpl(check, T) + return convertibleToImpl(check, x.typ, T, cause) } // convertibleToImpl should only be called by convertibleTo -func (x *operand) convertibleToImpl(check *Checker, T Type) bool { - // "x's type and T have identical underlying types if tags are ignored" - V := x.typ +func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { + // "V and T have identical underlying types if tags are ignored" Vu := under(V) Tu := under(T) if IdenticalIgnoreTags(Vu, Tu) { return true } - // "x's type and T are unnamed pointer types and their pointer base types + // "V and T are unnamed pointer types and their pointer base types // have identical underlying types if tags are ignored" if V, ok := V.(*Pointer); ok { if T, ok := T.(*Pointer); ok { @@ -140,22 +161,22 @@ func (x *operand) convertibleToImpl(check *Checker, T Type) bool { } } - // "x's type and T are both integer or floating point types" + // "V and T are both integer or floating point types" if isIntegerOrFloat(V) && isIntegerOrFloat(T) { return true } - // "x's type and T are both complex types" + // "V and T are both complex types" if isComplex(V) && isComplex(T) { return true } - // "x is an integer or a slice of bytes or runes and T is a string type" + // "V an integer or a slice of bytes or runes and T is a string type" if (isInteger(V) || isBytesOrRunes(Vu)) && isString(T) { return true } - // "x is a string and T is a slice of bytes or runes" + // "V a string and T is a slice of bytes or runes" if isString(V) && isBytesOrRunes(Tu) { return true } @@ -170,7 +191,7 @@ func (x *operand) convertibleToImpl(check *Checker, T Type) bool { return true } - // "x is a slice, T is a pointer-to-array type, + // "V a slice, T is a pointer-to-array type, // and the slice and array types have identical element types." if s := asSlice(V); s != nil { if p := asPointer(T); p != nil { @@ -180,12 +201,15 @@ func (x *operand) convertibleToImpl(check *Checker, T Type) bool { return true } // check != nil - if check.conf.CompilerErrorMessages { - check.error(x, "conversion of slices to array pointers only supported as of -lang=go1.17") - } else { - check.error(x, "conversion of slices to array pointers requires go1.17 or later") + if cause != nil { + if check.conf.CompilerErrorMessages { + // compiler error message assumes a -lang flag + *cause = "conversion of slices to array pointers only supported as of -lang=go1.17" + } else { + *cause = "conversion of slices to array pointers requires go1.17 or later" + } } - x.mode = invalid // avoid follow-up error + return false } } } diff --git a/src/cmd/compile/internal/types2/operand.go b/src/cmd/compile/internal/types2/operand.go index a5b2729451..5c8654dbf1 100644 --- a/src/cmd/compile/internal/types2/operand.go +++ b/src/cmd/compile/internal/types2/operand.go @@ -296,6 +296,7 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er if Ti, ok := Tu.(*Interface); ok { if m, wrongType := check.missingMethod(V, Ti, true); m != nil /* Implements(V, Ti) */ { if reason != nil { + // TODO(gri) the error messages here should follow the style in Checker.typeAssertion (factor!) if wrongType != nil { if Identical(m.typ, wrongType.typ) { *reason = fmt.Sprintf("missing method %s (%s has pointer receiver)", m.name, m.name) diff --git a/src/cmd/compile/internal/types2/testdata/examples/conversions.go2 b/src/cmd/compile/internal/types2/testdata/examples/conversions.go2 index 5c1b30a2b5..0acd2762a1 100644 --- a/src/cmd/compile/internal/types2/testdata/examples/conversions.go2 +++ b/src/cmd/compile/internal/types2/testdata/examples/conversions.go2 @@ -21,7 +21,7 @@ type Far struct{f float64 } func _[X Foo, T Bar](x X) T { return T(x) } func _[X Foo|Bar, T Bar](x X) T { return T(x) } func _[X Foo, T Foo|Bar](x X) T { return T(x) } -func _[X Foo, T Far](x X) T { return T(x /* ERROR cannot convert */ ) } +func _[X Foo, T Far](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by Foo\) to T\n\tcannot convert Foo \(in X\) to Far \(in T\) */ ) } // "x's type and T are unnamed pointer types and their pointer base types // have identical underlying types if tags are ignored" @@ -29,7 +29,7 @@ func _[X Foo, T Far](x X) T { return T(x /* ERROR cannot convert */ ) } func _[X ~*Foo, T ~*Bar](x X) T { return T(x) } func _[X ~*Foo|~*Bar, T ~*Bar](x X) T { return T(x) } func _[X ~*Foo, T ~*Foo|~*Bar](x X) T { return T(x) } -func _[X ~*Foo, T ~*Far](x X) T { return T(x /* ERROR cannot convert */ ) } +func _[X ~*Foo, T ~*Far](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by ~\*Foo\) to T\n\tcannot convert \*Foo \(in X\) to \*Far \(in T\) */ ) } // Verify that the defined types in constraints are considered for the rule above. @@ -60,12 +60,12 @@ func _[X Unsigned, T Float](x X) T { return T(x) } func _[X Float, T Float](x X) T { return T(x) } func _[X, T Integer|Unsigned|Float](x X) T { return T(x) } -func _[X, T Integer|~string](x X) T { return T(x /* ERROR cannot convert */ ) } +func _[X, T Integer|~string](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by Integer\|~string\) to T\n\tcannot convert string \(in X\) to int \(in T\) */ ) } // "x's type and T are both complex types" func _[X, T Complex](x X) T { return T(x) } -func _[X, T Float|Complex](x X) T { return T(x /* ERROR cannot convert */ ) } +func _[X, T Float|Complex](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by Float\|Complex\) to T\n\tcannot convert float32 \(in X\) to complex64 \(in T\) */ ) } // "x is an integer or a slice of bytes or runes and T is a string type" @@ -76,25 +76,25 @@ func _[T ~string](x int) T { return T(x) } func _[T ~string](x myInt) T { return T(x) } func _[X Integer](x X) string { return string(x) } func _[X Integer](x X) myString { return myString(x) } -func _[X Integer](x X) *string { return (*string)(x /* ERROR cannot convert */ ) } +func _[X Integer](x X) *string { return (*string)(x /* ERROR cannot convert x \(variable of type X constrained by Integer\) to \*string\n\tcannot convert int \(in X\) to \*string */ ) } func _[T ~string](x []byte) T { return T(x) } func _[T ~string](x []rune) T { return T(x) } func _[X ~[]byte, T ~string](x X) T { return T(x) } func _[X ~[]rune, T ~string](x X) T { return T(x) } func _[X Integer|~[]byte|~[]rune, T ~string](x X) T { return T(x) } -func _[X Integer|~[]byte|~[]rune, T ~*string](x X) T { return T(x /* ERROR cannot convert */ ) } +func _[X Integer|~[]byte|~[]rune, T ~*string](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by Integer\|~\[\]byte\|~\[\]rune\) to T\n\tcannot convert int \(in X\) to \*string \(in T\) */ ) } // "x is a string and T is a slice of bytes or runes" func _[T ~[]byte](x string) T { return T(x) } func _[T ~[]rune](x string) T { return T(x) } -func _[T ~[]rune](x *string) T { return T(x /* ERROR cannot convert */ ) } +func _[T ~[]rune](x *string) T { return T(x /* ERROR cannot convert x \(variable of type \*string\) to T\n\tcannot convert \*string to \[\]rune \(in T\) */ ) } func _[X ~string, T ~[]byte](x X) T { return T(x) } func _[X ~string, T ~[]rune](x X) T { return T(x) } func _[X ~string, T ~[]byte|~[]rune](x X) T { return T(x) } -func _[X ~*string, T ~[]byte|~[]rune](x X) T { return T(x /* ERROR cannot convert */ ) } +func _[X ~*string, T ~[]byte|~[]rune](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by ~\*string\) to T\n\tcannot convert \*string \(in X\) to \[\]byte \(in T\) */ ) } // package unsafe: // "any pointer or value of underlying type uintptr can be converted into a unsafe.Pointer" @@ -103,20 +103,20 @@ type myUintptr uintptr func _[X ~uintptr](x X) unsafe.Pointer { return unsafe.Pointer(x) } func _[T unsafe.Pointer](x myUintptr) T { return T(x) } -func _[T unsafe.Pointer](x int64) T { return T(x /* ERROR cannot convert */ ) } +func _[T unsafe.Pointer](x int64) T { return T(x /* ERROR cannot convert x \(variable of type int64\) to T\n\tcannot convert int64 to unsafe\.Pointer \(in T\) */ ) } // "and vice versa" func _[T ~uintptr](x unsafe.Pointer) T { return T(x) } func _[X unsafe.Pointer](x X) uintptr { return uintptr(x) } func _[X unsafe.Pointer](x X) myUintptr { return myUintptr(x) } -func _[X unsafe.Pointer](x X) int64 { return int64(x /* ERROR cannot convert */ ) } +func _[X unsafe.Pointer](x X) int64 { return int64(x /* ERROR cannot convert x \(variable of type X constrained by unsafe\.Pointer\) to int64\n\tcannot convert unsafe\.Pointer \(in X\) to int64 */ ) } // "x is a slice, T is a pointer-to-array type, // and the slice and array types have identical element types." func _[X ~[]E, T ~*[10]E, E any](x X) T { return T(x) } -func _[X ~[]E, T ~[10]E, E any](x X) T { return T(x /* ERROR cannot convert */ ) } +func _[X ~[]E, T ~[10]E, E any](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by ~\[\]E\) to T\n\tcannot convert \[\]E \(in X\) to \[10\]E \(in T\) */ ) } // ---------------------------------------------------------------------------- // The following declarations can be replaced by the exported types of the From ae4d67c89dfef1cf9f30921e8f717ed5f56b6866 Mon Sep 17 00:00:00 2001 From: fanzha02 Date: Mon, 4 Jan 2021 16:23:01 +0800 Subject: [PATCH 120/406] cmd/link: add -asan option The -asan option causes the linker to link against the runtime/asan package in order to use the C/C++ address sanitizer. This CL passes tests but is not usable by itself. The actual runtime/asan package, and support for -asan in the go tool and the compiler, and tests, are in separate CLs. Updates #44853. Change-Id: Ifc6046c1f75ba52777cbb3d937a4b66e91d5798d Reviewed-on: https://go-review.googlesource.com/c/go/+/298610 Trust: fannie zhang Reviewed-by: Ian Lance Taylor --- src/cmd/link/doc.go | 2 ++ src/cmd/link/internal/ld/config.go | 4 ++++ src/cmd/link/internal/ld/lib.go | 7 +++++++ src/cmd/link/internal/ld/main.go | 1 + 4 files changed, 14 insertions(+) diff --git a/src/cmd/link/doc.go b/src/cmd/link/doc.go index 604675caec..98c954f0f1 100644 --- a/src/cmd/link/doc.go +++ b/src/cmd/link/doc.go @@ -45,6 +45,8 @@ Flags: Note that before Go 1.5 this option took two separate arguments. -a Disassemble output. + -asan + Link with C/C++ address sanitizer support. -buildid id Record id as Go toolchain build id. -buildmode mode diff --git a/src/cmd/link/internal/ld/config.go b/src/cmd/link/internal/ld/config.go index 4045c97dd7..72616ff62f 100644 --- a/src/cmd/link/internal/ld/config.go +++ b/src/cmd/link/internal/ld/config.go @@ -193,6 +193,10 @@ func mustLinkExternal(ctxt *Link) (res bool, reason string) { return true, "msan" } + if *flagAsan { + return true, "asan" + } + // Internally linking cgo is incomplete on some architectures. // https://golang.org/issue/14449 if iscgo && ctxt.Arch.InFamily(sys.MIPS64, sys.MIPS, sys.RISCV64) { diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 3221d60f80..01ab6474b8 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -385,6 +385,9 @@ func libinit(ctxt *Link) { } else if *flagMsan { suffixsep = "_" suffix = "msan" + } else if *flagAsan { + suffixsep = "_" + suffix = "asan" } Lflag(ctxt, filepath.Join(buildcfg.GOROOT, "pkg", fmt.Sprintf("%s_%s%s%s", buildcfg.GOOS, buildcfg.GOARCH, suffixsep, suffix))) @@ -529,6 +532,9 @@ func (ctxt *Link) loadlib() { if *flagMsan { loadinternal(ctxt, "runtime/msan") } + if *flagAsan { + loadinternal(ctxt, "runtime/asan") + } loadinternal(ctxt, "runtime") for ; i < len(ctxt.Library); i++ { lib := ctxt.Library[i] @@ -1015,6 +1021,7 @@ var internalpkg = []string{ "runtime/cgo", "runtime/race", "runtime/msan", + "runtime/asan", } func ldhostobj(ld func(*Link, *bio.Reader, string, int64, string), headType objabi.HeadType, f *bio.Reader, pkg string, length int64, pn string, file string) *Hostobj { diff --git a/src/cmd/link/internal/ld/main.go b/src/cmd/link/internal/ld/main.go index 4d3b8b904c..a5a5a71250 100644 --- a/src/cmd/link/internal/ld/main.go +++ b/src/cmd/link/internal/ld/main.go @@ -69,6 +69,7 @@ var ( flagDumpDep = flag.Bool("dumpdep", false, "dump symbol dependency graph") flagRace = flag.Bool("race", false, "enable race detector") flagMsan = flag.Bool("msan", false, "enable MSan interface") + flagAsan = flag.Bool("asan", false, "enable ASan interface") flagAslr = flag.Bool("aslr", true, "enable ASLR for buildmode=c-shared on windows") flagFieldTrack = flag.String("k", "", "set field tracking `symbol`") From 6c200017bf0ad9987453d5c265e5a3063ad72dc5 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Mon, 18 Oct 2021 23:54:02 +0700 Subject: [PATCH 121/406] doc: document new reflect.UnsafePointer function Updates #40592 Change-Id: If66629e47ca9859128ee3ad8fb584e022d7a6982 Reviewed-on: https://go-review.googlesource.com/c/go/+/356255 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le Reviewed-by: Keith Randall TryBot-Result: Go Bot --- doc/go1.18.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/go1.18.html b/doc/go1.18.html index d95e55e1ad..087a06c280 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -175,6 +175,16 @@ Do not send CLs removing the interior tags from such phrases. do fewer allocations.

+
+

+ The new + Value.UnsafePointer + method returns the Value's value as an unsafe.Pointer. + This allows callers to migrate from Value.UnsafeAddr + and Value.Pointer + to eliminate the need to perform uintptr to unsafe.Pointer conversions at the callsite (as unsafe.Pointer rules require). +

+
syscall
From 85d2751d2ea38b10127df0b27d04b1a26f54bcfa Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Fri, 22 Oct 2021 17:05:35 +0700 Subject: [PATCH 122/406] cmd/compile: prevent compiling closures more than once Since CL 282892, functions are always compiled before closures. To do that, when walking the closure, it is added to its outer function queue for scheduling compilation later. Thus, a closure may be added to queue more than once, causing the ICE dues to being compiled twice. To fix this, catching the re-walking of the closure expression and do not add it to the compilation queue. Fixes #49029 Change-Id: I7d188e8f5b4d5c4248a0d8e6389da26f1084e464 Reviewed-on: https://go-review.googlesource.com/c/go/+/357960 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Keith Randall --- src/cmd/compile/internal/walk/closure.go | 11 ++++++++++- test/fixedbugs/issue49029.go | 25 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/issue49029.go diff --git a/src/cmd/compile/internal/walk/closure.go b/src/cmd/compile/internal/walk/closure.go index 40535afa7a..4d1c5621fe 100644 --- a/src/cmd/compile/internal/walk/closure.go +++ b/src/cmd/compile/internal/walk/closure.go @@ -107,7 +107,16 @@ func walkClosure(clo *ir.ClosureExpr, init *ir.Nodes) ir.Node { // The closure is not trivial or directly called, so it's going to stay a closure. ir.ClosureDebugRuntimeCheck(clo) clofn.SetNeedctxt(true) - ir.CurFunc.Closures = append(ir.CurFunc.Closures, clofn) + + // The closure expression may be walked more than once if it appeared in composite + // literal initialization (e.g, see issue #49029). + // + // Don't add the closure function to compilation queue more than once, since when + // compiling a function twice would lead to an ICE. + if !clofn.Walked() { + clofn.SetWalked(true) + ir.CurFunc.Closures = append(ir.CurFunc.Closures, clofn) + } typ := typecheck.ClosureType(clo) diff --git a/test/fixedbugs/issue49029.go b/test/fixedbugs/issue49029.go new file mode 100644 index 0000000000..51c9a78cfc --- /dev/null +++ b/test/fixedbugs/issue49029.go @@ -0,0 +1,25 @@ +// compile + +// Copyright 2021 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 p + +type s struct { + f func() +} + +func f() { + ch := make(chan struct{}, 1) + _ = [...]struct{ slice []s }{ + {}, {}, {}, {}, + { + slice: []s{ + { + f: func() { ch <- struct{}{} }, + }, + }, + }, + } +} From b0f7eb6c0dee68c91d622cc5fcba1074626753b3 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 22 Oct 2021 16:57:58 -0700 Subject: [PATCH 123/406] cmd/go: update test script for reformatted error message (fix long builds) TBR=iant Change-Id: Ic72af52e5ff8d28f8102c07b03e4930df61445ca Reviewed-on: https://go-review.googlesource.com/c/go/+/358115 Trust: Robert Griesemer Trust: Cuong Manh Le Run-TryBot: Robert Griesemer TryBot-Result: Go Bot Reviewed-by: Cuong Manh Le Reviewed-by: Robert Findley --- src/cmd/go/testdata/script/mod_vendor_goversion.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/go/testdata/script/mod_vendor_goversion.txt b/src/cmd/go/testdata/script/mod_vendor_goversion.txt index 7f1966c8e8..b4489dae7e 100644 --- a/src/cmd/go/testdata/script/mod_vendor_goversion.txt +++ b/src/cmd/go/testdata/script/mod_vendor_goversion.txt @@ -26,7 +26,7 @@ go mod vendor ! grep 1.17 vendor/modules.txt ! go build example.net/need117 -stderr '^vendor[/\\]example\.net[/\\]need117[/\\]need117.go:5:1[89]: .*conversion of slices to array pointers only supported as of -lang=go1\.17' +stderr '^vendor[/\\]example\.net[/\\]need117[/\\]need117.go:5:1[89]:.*\n\tconversion of slices to array pointers only supported as of -lang=go1\.17' ! grep 1.13 vendor/modules.txt go build example.net/bad114 From 3cd28baffd2c97d53cbc703a8787365e68050466 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 20 Oct 2021 15:06:35 -0700 Subject: [PATCH 124/406] cmd/compile/internal/types2: factor out slice elem computation for copy built-in Implement singleUnder[String] which determines a single underlying type for a given type: either the underlying type, or the single underlying type for a type parameter, if it exists. Use singleUnder[String] instead of optype for copy built-in. This CL removes a dependency on optype and also makes the copy built-in slighty more general for generic arguments (the source argument may be constrained by a slice or string simultaneously). Change-Id: Ia329e96afc69a09d2ca3b1f82fe712d4f7ba1d9f Reviewed-on: https://go-review.googlesource.com/c/go/+/357413 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/builtins.go | 59 ++++++++++++++----- .../types2/testdata/check/builtins.go2 | 10 +++- 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index cb4d93c6c4..154395cddb 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -325,33 +325,22 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( case _Copy: // copy(x, y []T) int - var dst Type - if t := asSlice(x.typ); t != nil { - dst = t.elem - } + dst, _ := singleUnder(x.typ).(*Slice) var y operand arg(&y, 1) if y.mode == invalid { return } - var src Type - switch t := optype(y.typ).(type) { - case *Basic: - if isString(y.typ) { - src = universeByte - } - case *Slice: - src = t.elem - } + src, _ := singleUnderString(y.typ).(*Slice) if dst == nil || src == nil { check.errorf(x, invalidArg+"copy expects slice arguments; found %s and %s", x, &y) return } - if !Identical(dst, src) { - check.errorf(x, invalidArg+"arguments to copy %s and %s have different element types %s and %s", x, &y, dst, src) + if !Identical(dst.elem, src.elem) { + check.errorf(x, invalidArg+"arguments to copy %s and %s have different element types %s and %s", x, &y, dst.elem, src.elem) return } @@ -774,6 +763,46 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( return true } +// If typ is a type parameter, single under returns the single underlying +// type of all types in the corresponding type constraint if it exists, or +// nil if it doesn't exist. If typ is not a type parameter, singleUnder +// just returns the underlying type. +func singleUnder(typ Type) Type { + var su Type + if underIs(typ, func(u Type) bool { + if su != nil && !Identical(su, u) { + return false + } + // su == nil || Identical(su, u) + su = u + return true + }) { + return su + } + return nil +} + +// singleUnderString is like singleUnder but also considers []byte and +// string as "identical". In this case, if successful, the result is always +// []byte. +func singleUnderString(typ Type) Type { + var su Type + if underIs(typ, func(u Type) bool { + if isString(u) { + u = NewSlice(universeByte) + } + if su != nil && !Identical(su, u) { + return false + } + // su == nil || Identical(su, u) + su = u + return true + }) { + return su + } + return nil +} + // hasVarSize reports if the size of type t is variable due to type parameters. func hasVarSize(t Type) bool { switch t := under(t).(type) { diff --git a/src/cmd/compile/internal/types2/testdata/check/builtins.go2 b/src/cmd/compile/internal/types2/testdata/check/builtins.go2 index 243e888ff7..8376440439 100644 --- a/src/cmd/compile/internal/types2/testdata/check/builtins.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/builtins.go2 @@ -78,8 +78,14 @@ func _[T ~string](x []byte, y T) { func _[T ~[]byte|~string](x T, y []byte) { copy(x /* ERROR expects slice arguments */ , y) - // TODO(gri) should this be valid? - copy(y /* ERROR expects slice arguments */ , x) + copy(y, x) +} + +type L0 []int +type L1 []int + +func _[T L0 | L1](x, y T) { + copy(x, y) } // delete From 2d205ebb96460b500480d144b99d2d5f5d4c06ed Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 21 Oct 2021 13:29:00 -0700 Subject: [PATCH 125/406] cmd/compile/internal/types2: make built-in to accept type sets with single underlying types This generalizes make the same way copy was generalized and eliminates a use of optype. Change-Id: I8221abd53d77dde8ead47c0075c13fd2a3221642 Reviewed-on: https://go-review.googlesource.com/c/go/+/357776 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/builtins.go | 6 ++--- .../types2/testdata/check/builtins.go2 | 22 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index 154395cddb..37e1f00d26 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -460,13 +460,13 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( } var min int // minimum number of arguments - switch optype(T).(type) { + switch singleUnder(T).(type) { case *Slice: min = 2 case *Map, *Chan: min = 1 - case *top: - check.errorf(arg0, invalidArg+"cannot make %s; type parameter has no structural type", arg0) + case nil: + check.errorf(arg0, invalidArg+"cannot make %s; type set has no single underlying type", arg0) return default: check.errorf(arg0, invalidArg+"cannot make %s; type must be slice, map, or channel", arg0) diff --git a/src/cmd/compile/internal/types2/testdata/check/builtins.go2 b/src/cmd/compile/internal/types2/testdata/check/builtins.go2 index 8376440439..d1067a190f 100644 --- a/src/cmd/compile/internal/types2/testdata/check/builtins.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/builtins.go2 @@ -127,15 +127,18 @@ func _[T M4[K, V], K comparable, V any](m T) { // make +type myChan chan int + func _[ - S1 interface{ []int }, - S2 interface{ []int | chan int }, + S1 ~[]int, + S2 ~[]int | ~chan int, - M1 interface{ map[string]int }, - M2 interface{ map[string]int | chan int }, + M1 ~map[string]int, + M2 ~map[string]int | ~chan int, - C1 interface{ chan int }, - C2 interface{ chan int | chan string }, + C1 ~chan int, + C2 ~chan int | ~chan string, + C3 chan int | myChan, // single underlying type ]() { type S0 []int _ = make([]int, 10) @@ -145,7 +148,7 @@ func _[ _ = make /* ERROR expects 2 or 3 arguments */ (S1) _ = make(S1, 10, 20) _ = make /* ERROR expects 2 or 3 arguments */ (S1, 10, 20, 30) - _ = make(S2 /* ERROR cannot make .* no structural type */ , 10) + _ = make(S2 /* ERROR cannot make .* no single underlying type */ , 10) type M0 map[string]int _ = make(map[string]int) @@ -153,7 +156,7 @@ func _[ _ = make(M1) _ = make(M1, 10) _ = make/* ERROR expects 1 or 2 arguments */(M1, 10, 20) - _ = make(M2 /* ERROR cannot make .* no structural type */ ) + _ = make(M2 /* ERROR cannot make .* no single underlying type */ ) type C0 chan int _ = make(chan int) @@ -161,7 +164,8 @@ func _[ _ = make(C1) _ = make(C1, 10) _ = make/* ERROR expects 1 or 2 arguments */(C1, 10, 20) - _ = make(C2 /* ERROR cannot make .* no structural type */ ) + _ = make(C2 /* ERROR cannot make .* no single underlying type */ ) + _ = make(C3) } // unsafe.Alignof From c526cf8c1ea535de6a30fc8c553c377bda4d6781 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 21 Oct 2021 15:56:08 -0700 Subject: [PATCH 126/406] cmd/compile/internal/types2: range clause to accept type sets with single underlying types This generalizes range clauses. Removed some dead code and cleaned up the surrounding bits. Change-Id: Icd8384205afa3f52b7e7df9abed5de2bb556861d Reviewed-on: https://go-review.googlesource.com/c/go/+/357778 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/stmt.go | 72 ++++++++----------- .../types2/testdata/check/typeparams.go2 | 12 ++-- 2 files changed, 36 insertions(+), 48 deletions(-) diff --git a/src/cmd/compile/internal/types2/stmt.go b/src/cmd/compile/internal/types2/stmt.go index e826f35105..10741a90e2 100644 --- a/src/cmd/compile/internal/types2/stmt.go +++ b/src/cmd/compile/internal/types2/stmt.go @@ -834,19 +834,28 @@ func (check *Checker) rangeStmt(inner stmtContext, s *syntax.ForStmt, rclause *s // determine key/value types var key, val Type if x.mode != invalid { - // Ranging over a type parameter is permitted if it has a structural type. - typ := optype(x.typ) - if _, ok := typ.(*Chan); ok && sValue != nil { - check.softErrorf(sValue, "range over %s permits only one iteration variable", &x) - // ok to continue - } - var msg string - key, val, msg = rangeKeyVal(typ, isVarName(sKey), isVarName(sValue)) - if key == nil || msg != "" { - if msg != "" { - msg = ": " + msg + // Ranging over a type parameter is permitted if it has a single underlying type. + var cause string + u := singleUnder(x.typ) + switch t := u.(type) { + case nil: + cause = "type set has no single underlying type" + case *Chan: + if sValue != nil { + check.softErrorf(sValue, "range over %s permits only one iteration variable", &x) + // ok to continue + } + if t.dir == SendOnly { + cause = "receive from send-only channel" + } + } + key, val = rangeKeyVal(u) + if key == nil || cause != "" { + if cause == "" { + check.softErrorf(&x, "cannot range over %s", &x) + } else { + check.softErrorf(&x, "cannot range over %s (%s)", &x, cause) } - check.softErrorf(&x, "cannot range over %s%s", &x, msg) // ok to continue } } @@ -927,44 +936,23 @@ func (check *Checker) rangeStmt(inner stmtContext, s *syntax.ForStmt, rclause *s check.stmt(inner, s.Body) } -// isVarName reports whether x is a non-nil, non-blank (_) expression. -func isVarName(x syntax.Expr) bool { - if x == nil { - return false - } - ident, _ := unparen(x).(*syntax.Name) - return ident == nil || ident.Value != "_" -} - // rangeKeyVal returns the key and value type produced by a range clause -// over an expression of type typ, and possibly an error message. If the -// range clause is not permitted the returned key is nil or msg is not -// empty (in that case we still may have a non-nil key type which can be -// used to reduce the chance for follow-on errors). -// The wantKey, wantVal, and hasVal flags indicate which of the iteration -// variables are used or present; this matters if we range over a generic -// type where not all keys or values are of the same type. -func rangeKeyVal(typ Type, wantKey, wantVal bool) (Type, Type, string) { +// over an expression of type typ. If the range clause is not permitted +// the results are nil. +func rangeKeyVal(typ Type) (key, val Type) { switch typ := arrayPtrDeref(typ).(type) { case *Basic: if isString(typ) { - return Typ[Int], universeRune, "" // use 'rune' name + return Typ[Int], universeRune // use 'rune' name } case *Array: - return Typ[Int], typ.elem, "" + return Typ[Int], typ.elem case *Slice: - return Typ[Int], typ.elem, "" + return Typ[Int], typ.elem case *Map: - return typ.key, typ.elem, "" + return typ.key, typ.elem case *Chan: - var msg string - if typ.dir == SendOnly { - msg = "receive from send-only channel" - } - return typ.elem, Typ[Invalid], msg - case *top: - // we have a type parameter with no structural type - return nil, nil, "no structural type" + return typ.elem, Typ[Invalid] } - return nil, nil, "" + return } diff --git a/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 b/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 index 29c25b0bb4..d1f07a20d4 100644 --- a/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 @@ -184,7 +184,7 @@ func _[ for _, _ = range b1 {} var b2 B2 - for range b2 /* ERROR cannot range over b2 .* no structural type */ {} + for range b2 {} var c0 chan int for range c0 {} @@ -197,7 +197,7 @@ func _[ for _, _ /* ERROR permits only one iteration variable */ = range c1 {} var c2 C2 - for range c2 /* ERROR cannot range over c2 .* no structural type */ {} + for range c2 /* ERROR cannot range over c2.*no single underlying type */ {} var c3 C3 for range c3 /* ERROR receive from send-only channel */ {} @@ -213,7 +213,7 @@ func _[ for _, _ = range s1 {} var s2 S2 - for range s2 /* ERROR cannot range over s2 .* no structural type */ {} + for range s2 /* ERROR cannot range over s2.*no single underlying type */ {} var a0 []int for range a0 {} @@ -226,7 +226,7 @@ func _[ for _, _ = range a1 {} var a2 A2 - for range a2 /* ERROR cannot range over a2 .* no structural type */ {} + for range a2 /* ERROR cannot range over a2.*no single underlying type */ {} var p0 *[10]int for range p0 {} @@ -239,7 +239,7 @@ func _[ for _, _ = range p1 {} var p2 P2 - for range p2 /* ERROR cannot range over p2 .* no structural type */ {} + for range p2 /* ERROR cannot range over p2.*no single underlying type */ {} var m0 map[string]int for range m0 {} @@ -252,7 +252,7 @@ func _[ for _, _ = range m1 {} var m2 M2 - for range m2 /* ERROR cannot range over m2 .* no structural type */ {} + for range m2 /* ERROR cannot range over m2.*no single underlying type */ {} } // type inference checks From 12e4404a0a0f03cee4fd29a6eb80379824d4aeb6 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 21 Oct 2021 16:17:07 -0700 Subject: [PATCH 127/406] cmd/compile/internal/types2: slice exprs to accept type sets with single underlying types Change-Id: Ib9bd08ab6153129aaf8b77b41fc6ea302d0c1589 Reviewed-on: https://go-review.googlesource.com/c/go/+/357779 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/index.go | 21 ++++++++++++------- .../types2/testdata/check/typeparams.go2 | 5 +++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/cmd/compile/internal/types2/index.go b/src/cmd/compile/internal/types2/index.go index 47a5e50f62..62f49b95da 100644 --- a/src/cmd/compile/internal/types2/index.go +++ b/src/cmd/compile/internal/types2/index.go @@ -207,9 +207,14 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) { valid := false length := int64(-1) // valid if >= 0 - switch typ := optype(x.typ).(type) { + switch u := singleUnder(x.typ).(type) { + case nil: + check.errorf(x, invalidOp+"cannot slice %s: type set has no single underlying type", x) + x.mode = invalid + return + case *Basic: - if isString(typ) { + if isString(u) { if e.Full { check.error(x, invalidOp+"3-index slice of string") x.mode = invalid @@ -221,26 +226,26 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) { } // spec: "For untyped string operands the result // is a non-constant value of type string." - if typ.kind == UntypedString { + if u.kind == UntypedString { x.typ = Typ[String] } } case *Array: valid = true - length = typ.len + length = u.len if x.mode != variable { check.errorf(x, invalidOp+"%s (slice of unaddressable value)", x) x.mode = invalid return } - x.typ = &Slice{elem: typ.elem} + x.typ = &Slice{elem: u.elem} case *Pointer: - if typ := asArray(typ.base); typ != nil { + if u := asArray(u.base); u != nil { valid = true - length = typ.len - x.typ = &Slice{elem: typ.elem} + length = u.len + x.typ = &Slice{elem: u.elem} } case *Slice: diff --git a/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 b/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 index d1f07a20d4..1200a6e874 100644 --- a/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 @@ -123,6 +123,11 @@ func _[T interface{ ~[]byte }] (x T, i, j, k int) { var _ T = x[i:j:k] } func _[T interface{ ~string }] (x T, i, j, k int) { var _ T = x[i:j] } func _[T interface{ ~string }] (x T, i, j, k int) { var _ T = x /* ERROR 3-index slice of string */ [i:j:k] } +type myByte1 []byte +type myByte2 []byte +func _[T interface{ []byte | myByte1 | myByte2 }] (x T, i, j, k int) { var _ T = x[i:j:k] } +func _[T interface{ []byte | myByte1 | []int }] (x T, i, j, k int) { var _ T = x[ /* ERROR no single underlying type */ i:j:k] } + // len/cap built-ins func _[T any](x T) { _ = len(x /* ERROR invalid argument */ ) } From 16318df4a225928c2f24874f6fcd11c3e13a112e Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 21 Oct 2021 20:01:51 -0700 Subject: [PATCH 128/406] cmd/compile/internal/types2: comp literals to accept type sets with single underlying types Change-Id: Ib51bcdf023910d244739ec176880a16e700851e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/357915 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/expr.go | 2 +- .../types2/testdata/check/compliterals.go2 | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/cmd/compile/internal/types2/testdata/check/compliterals.go2 diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index 1001554739..3a39de7406 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -1253,7 +1253,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin goto Error } - switch utyp := optype(base).(type) { + switch utyp := singleUnder(base).(type) { case *Struct: if len(e.ElemList) == 0 { break diff --git a/src/cmd/compile/internal/types2/testdata/check/compliterals.go2 b/src/cmd/compile/internal/types2/testdata/check/compliterals.go2 new file mode 100644 index 0000000000..60eac97a3f --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/check/compliterals.go2 @@ -0,0 +1,22 @@ +// Copyright 2012 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. + +// Composite literals with parameterized types + +package comp_literals + +type myStruct struct { + f int +} + +type slice[E any] []E + +func struct_literals[S struct{f int}|myStruct]() { + _ = S{} + _ = S{0} + _ = S{f: 0} + + _ = slice[int]{1, 2, 3} + _ = slice[S]{{}, {0}, {f:0}} +} From 8dbf3e9393400d72d313e5616c88873e07692c70 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Sat, 23 Oct 2021 10:16:41 -0700 Subject: [PATCH 129/406] cmd/compile: fix fuse pass to do CFG surgery correctly removePred and removeArg do different things. removePred moves the last predecessor to index k, whereas removeArg slides all the args k or greater down by 1 index. Kind of unfortunate different behavior in things named similarly. Fixes #49122 Change-Id: I9ae409bdac744e713f4c121f948e43db6fdc8542 Reviewed-on: https://go-review.googlesource.com/c/go/+/358117 Trust: Keith Randall Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Cuong Manh Le --- .../compile/internal/ssa/fuse_branchredirect.go | 6 +++++- test/fixedbugs/issue49122.go | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/issue49122.go diff --git a/src/cmd/compile/internal/ssa/fuse_branchredirect.go b/src/cmd/compile/internal/ssa/fuse_branchredirect.go index 1b8b307bca..ba5220bd87 100644 --- a/src/cmd/compile/internal/ssa/fuse_branchredirect.go +++ b/src/cmd/compile/internal/ssa/fuse_branchredirect.go @@ -78,7 +78,11 @@ func fuseBranchRedirect(f *Func) bool { if v.Op != OpPhi { continue } - v.RemoveArg(k) + n := len(v.Args) + v.Args[k].Uses-- + v.Args[k] = v.Args[n-1] + v.Args[n-1] = nil + v.Args = v.Args[:n-1] phielimValue(v) } // Fix up child to have one more predecessor. diff --git a/test/fixedbugs/issue49122.go b/test/fixedbugs/issue49122.go new file mode 100644 index 0000000000..c62a627dae --- /dev/null +++ b/test/fixedbugs/issue49122.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2021 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 main + +var B []bool +var N int + +func f(p bool, m map[bool]bool) bool { + var q bool + _ = p || N&N < N || B[0] || B[0] + return p && q && m[q] +} From f686f6a963cdfa66b6087993663f53a10272d262 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Mon, 25 Oct 2021 01:02:12 +0700 Subject: [PATCH 130/406] cmd/compile: remove Value.RemoveArg It's only used in two places: - The one in regalloc.go can be replaced with v.resetArgs() - The one in rewrite.go can be open coded and can cause wrong usage like the bug that CL 358117 fixed. Change-Id: I125baf237db159d056fe4b1c73072331eea4d06a Reviewed-on: https://go-review.googlesource.com/c/go/+/357965 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Keith Randall --- src/cmd/compile/internal/ssa/regalloc.go | 2 +- src/cmd/compile/internal/ssa/rewrite.go | 6 +++++- src/cmd/compile/internal/ssa/value.go | 6 ------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/cmd/compile/internal/ssa/regalloc.go b/src/cmd/compile/internal/ssa/regalloc.go index 28fac6ccd0..431059ae69 100644 --- a/src/cmd/compile/internal/ssa/regalloc.go +++ b/src/cmd/compile/internal/ssa/regalloc.go @@ -1840,7 +1840,7 @@ func (s *regAllocState) regalloc(f *Func) { if s.f.pass.debug > regDebug { fmt.Printf("delete copied value %s\n", c.LongString()) } - c.RemoveArg(0) + c.resetArgs() f.freeValue(c) delete(s.copies, c) progress = true diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go index 2fe0ca64c8..9136c59e65 100644 --- a/src/cmd/compile/internal/ssa/rewrite.go +++ b/src/cmd/compile/internal/ssa/rewrite.go @@ -816,7 +816,11 @@ func devirtLECall(v *Value, sym *obj.LSym) *Value { v.Op = OpStaticLECall auxcall := v.Aux.(*AuxCall) auxcall.Fn = sym - v.RemoveArg(0) + // Remove first arg + v.Args[0].Uses-- + copy(v.Args[0:], v.Args[1:]) + v.Args[len(v.Args)-1] = nil // aid GC + v.Args = v.Args[:len(v.Args)-1] return v } diff --git a/src/cmd/compile/internal/ssa/value.go b/src/cmd/compile/internal/ssa/value.go index 630143cc50..7b411a4612 100644 --- a/src/cmd/compile/internal/ssa/value.go +++ b/src/cmd/compile/internal/ssa/value.go @@ -302,12 +302,6 @@ func (v *Value) SetArg(i int, w *Value) { v.Args[i] = w w.Uses++ } -func (v *Value) RemoveArg(i int) { - v.Args[i].Uses-- - copy(v.Args[i:], v.Args[i+1:]) - v.Args[len(v.Args)-1] = nil // aid GC - v.Args = v.Args[:len(v.Args)-1] -} func (v *Value) SetArgs1(a *Value) { v.resetArgs() v.AddArg(a) From 7b554575e46d1df9b68f71e051c8133aaf953fb7 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sun, 24 Oct 2021 13:46:54 +0700 Subject: [PATCH 131/406] cmd/compile: factor out code to remove phi argument CL 358117 fixed a bug that Phi's argument wasn't updated correctly after removing a predecessor of Block. This CL factor out the code that updates phi argument into a Block's method, so it's easier to use, maintain and hopefully prevent that kind of bug in the future. Change-Id: Ie9741e19ea28f56860425089b6093a381aa10f5b Reviewed-on: https://go-review.googlesource.com/c/go/+/357964 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Keith Randall --- src/cmd/compile/internal/ssa/block.go | 25 ++++++++++++++++++- src/cmd/compile/internal/ssa/critical.go | 11 ++++---- src/cmd/compile/internal/ssa/deadcode.go | 6 +---- .../internal/ssa/fuse_branchredirect.go | 6 +---- src/cmd/compile/internal/ssa/shortcircuit.go | 6 +---- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/cmd/compile/internal/ssa/block.go b/src/cmd/compile/internal/ssa/block.go index 71ca774431..6ff3188f9b 100644 --- a/src/cmd/compile/internal/ssa/block.go +++ b/src/cmd/compile/internal/ssa/block.go @@ -279,7 +279,8 @@ func (b *Block) AddEdgeTo(c *Block) { // removePred removes the ith input edge from b. // It is the responsibility of the caller to remove -// the corresponding successor edge. +// the corresponding successor edge, and adjust any +// phi values by calling b.removePhiArg(v, i). func (b *Block) removePred(i int) { n := len(b.Preds) - 1 if i != n { @@ -322,6 +323,28 @@ func (b *Block) swapSuccessors() { b.Likely *= -1 } +// removePhiArg removes the ith arg from phi. +// It must be called after calling b.removePred(i) to +// adjust the corresponding phi value of the block: +// +// b.removePred(i) +// for _, v := range b.Values { +// if v.Op != OpPhi { +// continue +// } +// b.removeArg(v, i) +// } +func (b *Block) removePhiArg(phi *Value, i int) { + n := len(b.Preds) + if numPhiArgs := len(phi.Args); numPhiArgs-1 != n { + b.Fatalf("inconsistent state, num predecessors: %d, num phi args: %d", n, numPhiArgs) + } + phi.Args[i].Uses-- + phi.Args[i] = phi.Args[n] + phi.Args[n] = nil + phi.Args = phi.Args[:n] +} + // LackingPos indicates whether b is a block whose position should be inherited // from its successors. This is true if all the values within it have unreliable positions // and if it is "plain", meaning that there is no control flow that is also very likely diff --git a/src/cmd/compile/internal/ssa/critical.go b/src/cmd/compile/internal/ssa/critical.go index b85721eba4..500ce3ae61 100644 --- a/src/cmd/compile/internal/ssa/critical.go +++ b/src/cmd/compile/internal/ssa/critical.go @@ -91,14 +91,13 @@ func critical(f *Func) { b.removePred(i) // Update corresponding phi args - n := len(b.Preds) - phi.Args[i].Uses-- - phi.Args[i] = phi.Args[n] - phi.Args[n] = nil - phi.Args = phi.Args[:n] + b.removePhiArg(phi, i) + // splitting occasionally leads to a phi having // a single argument (occurs with -N) - if n == 1 { + // TODO(cuonglm,khr): replace this with phielimValue, and + // make removePhiArg incorporates that. + if len(b.Preds) == 1 { phi.Op = OpCopy } // Don't increment i in this case because we moved diff --git a/src/cmd/compile/internal/ssa/deadcode.go b/src/cmd/compile/internal/ssa/deadcode.go index 5d10dfe025..b47b106975 100644 --- a/src/cmd/compile/internal/ssa/deadcode.go +++ b/src/cmd/compile/internal/ssa/deadcode.go @@ -348,15 +348,11 @@ func (b *Block) removeEdge(i int) { c.removePred(j) // Remove phi args from c's phis. - n := len(c.Preds) for _, v := range c.Values { if v.Op != OpPhi { continue } - v.Args[j].Uses-- - v.Args[j] = v.Args[n] - v.Args[n] = nil - v.Args = v.Args[:n] + c.removePhiArg(v, j) phielimValue(v) // Note: this is trickier than it looks. Replacing // a Phi with a Copy can in general cause problems because diff --git a/src/cmd/compile/internal/ssa/fuse_branchredirect.go b/src/cmd/compile/internal/ssa/fuse_branchredirect.go index ba5220bd87..751dca7468 100644 --- a/src/cmd/compile/internal/ssa/fuse_branchredirect.go +++ b/src/cmd/compile/internal/ssa/fuse_branchredirect.go @@ -78,11 +78,7 @@ func fuseBranchRedirect(f *Func) bool { if v.Op != OpPhi { continue } - n := len(v.Args) - v.Args[k].Uses-- - v.Args[k] = v.Args[n-1] - v.Args[n-1] = nil - v.Args = v.Args[:n-1] + b.removePhiArg(v, k) phielimValue(v) } // Fix up child to have one more predecessor. diff --git a/src/cmd/compile/internal/ssa/shortcircuit.go b/src/cmd/compile/internal/ssa/shortcircuit.go index 29abf3c591..c0b9eacf41 100644 --- a/src/cmd/compile/internal/ssa/shortcircuit.go +++ b/src/cmd/compile/internal/ssa/shortcircuit.go @@ -196,11 +196,7 @@ func shortcircuitBlock(b *Block) bool { // Remove b's incoming edge from p. b.removePred(cidx) - n := len(b.Preds) - ctl.Args[cidx].Uses-- - ctl.Args[cidx] = ctl.Args[n] - ctl.Args[n] = nil - ctl.Args = ctl.Args[:n] + b.removePhiArg(ctl, cidx) // Redirect p's outgoing edge to t. p.Succs[pi] = Edge{t, len(t.Preds)} From fcd2d9cd75e6307b5b72fed2201044e231bef40a Mon Sep 17 00:00:00 2001 From: Olivier Wulveryck Date: Mon, 31 May 2021 08:03:57 +0200 Subject: [PATCH 132/406] image/draw: improve performances if mask is *image.Alpha MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The existing DrawMask method is generic and is therefore calling the At().RGBA() method for every pixel of the mask and the source. Do a specific implementation when the mask is *image.Alpha (which is common) and use use the PixOffset method to increase performances. name old time/op new time/op delta RGBA2-12 1.60ms ± 0% 1.13ms ± 1% -29.16% (p=0.008 n=5+5) GenericMaskOver-12 915µs ± 4% 926µs ± 1% ~ (p=0.190 n=5+4) RGBA64Over-12 1.53ms ± 3% 1.21ms ± 2% -20.74% (p=0.008 n=5+5) GrayOver-12 1.36ms ± 2% 1.01ms ± 7% -26.27% (p=0.008 n=5+5) Fixes: #46395 Change-Id: Iaeaa8cfcc6a3fe93eb19b361f3bf076e41cac5b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/323749 Reviewed-by: Nigel Tao Trust: Nigel Tao Trust: Andrew Gerrand Run-TryBot: Nigel Tao --- src/image/draw/bench_test.go | 8 ++ src/image/draw/draw.go | 159 +++++++++++++++++++++++++++++++++++ src/image/draw/draw_test.go | 4 + 3 files changed, 171 insertions(+) diff --git a/src/image/draw/bench_test.go b/src/image/draw/bench_test.go index 524ead2b8e..2b7c6d6ac4 100644 --- a/src/image/draw/bench_test.go +++ b/src/image/draw/bench_test.go @@ -266,3 +266,11 @@ func BenchmarkGenericSrc(b *testing.B) { func BenchmarkGenericMaskSrc(b *testing.B) { bench(b, color.RGBA64Model, color.RGBA64Model, color.AlphaModel, Src) } + +func BenchmarkRGBA64Over(b *testing.B) { + bench(b, color.RGBAModel, color.RGBA64Model, color.AlphaModel, Over) +} + +func BenchmarkGrayOver(b *testing.B) { + bench(b, color.RGBAModel, color.GrayModel, color.AlphaModel, Over) +} diff --git a/src/image/draw/draw.go b/src/image/draw/draw.go index 5e81ddc395..d3c5b29097 100644 --- a/src/image/draw/draw.go +++ b/src/image/draw/draw.go @@ -160,6 +160,15 @@ func DrawMask(dst Image, r image.Rectangle, src image.Image, sp image.Point, mas case *image.Uniform: drawGlyphOver(dst0, r, src0, mask0, mp) return + case *image.RGBA: + drawRGBAMaskOver(dst0, r, src0, sp, mask0, mp) + return + case *image.Gray: + drawGrayMaskOver(dst0, r, src0, sp, mask0, mp) + return + case image.RGBA64Image: + drawRGBA64ImageMaskOver(dst0, r, src0, sp, mask0, mp) + return } } } else { @@ -602,6 +611,156 @@ func drawGlyphOver(dst *image.RGBA, r image.Rectangle, src *image.Uniform, mask } } +func drawGrayMaskOver(dst *image.RGBA, r image.Rectangle, src *image.Gray, sp image.Point, mask *image.Alpha, mp image.Point) { + x0, x1, dx := r.Min.X, r.Max.X, 1 + y0, y1, dy := r.Min.Y, r.Max.Y, 1 + if r.Overlaps(r.Add(sp.Sub(r.Min))) { + if sp.Y < r.Min.Y || sp.Y == r.Min.Y && sp.X < r.Min.X { + x0, x1, dx = x1-1, x0-1, -1 + y0, y1, dy = y1-1, y0-1, -1 + } + } + + sy := sp.Y + y0 - r.Min.Y + my := mp.Y + y0 - r.Min.Y + sx0 := sp.X + x0 - r.Min.X + mx0 := mp.X + x0 - r.Min.X + sx1 := sx0 + (x1 - x0) + i0 := dst.PixOffset(x0, y0) + di := dx * 4 + for y := y0; y != y1; y, sy, my = y+dy, sy+dy, my+dy { + for i, sx, mx := i0, sx0, mx0; sx != sx1; i, sx, mx = i+di, sx+dx, mx+dx { + mi := mask.PixOffset(mx, my) + ma := uint32(mask.Pix[mi]) + ma |= ma << 8 + si := src.PixOffset(sx, sy) + sy := uint32(src.Pix[si]) + sy |= sy << 8 + sa := uint32(0xffff) + + d := dst.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + dr := uint32(d[0]) + dg := uint32(d[1]) + db := uint32(d[2]) + da := uint32(d[3]) + + // dr, dg, db and da are all 8-bit color at the moment, ranging in [0,255]. + // We work in 16-bit color, and so would normally do: + // dr |= dr << 8 + // and similarly for dg, db and da, but instead we multiply a + // (which is a 16-bit color, ranging in [0,65535]) by 0x101. + // This yields the same result, but is fewer arithmetic operations. + a := (m - (sa * ma / m)) * 0x101 + + d[0] = uint8((dr*a + sy*ma) / m >> 8) + d[1] = uint8((dg*a + sy*ma) / m >> 8) + d[2] = uint8((db*a + sy*ma) / m >> 8) + d[3] = uint8((da*a + sa*ma) / m >> 8) + } + i0 += dy * dst.Stride + } +} + +func drawRGBAMaskOver(dst *image.RGBA, r image.Rectangle, src *image.RGBA, sp image.Point, mask *image.Alpha, mp image.Point) { + x0, x1, dx := r.Min.X, r.Max.X, 1 + y0, y1, dy := r.Min.Y, r.Max.Y, 1 + if dst == src && r.Overlaps(r.Add(sp.Sub(r.Min))) { + if sp.Y < r.Min.Y || sp.Y == r.Min.Y && sp.X < r.Min.X { + x0, x1, dx = x1-1, x0-1, -1 + y0, y1, dy = y1-1, y0-1, -1 + } + } + + sy := sp.Y + y0 - r.Min.Y + my := mp.Y + y0 - r.Min.Y + sx0 := sp.X + x0 - r.Min.X + mx0 := mp.X + x0 - r.Min.X + sx1 := sx0 + (x1 - x0) + i0 := dst.PixOffset(x0, y0) + di := dx * 4 + for y := y0; y != y1; y, sy, my = y+dy, sy+dy, my+dy { + for i, sx, mx := i0, sx0, mx0; sx != sx1; i, sx, mx = i+di, sx+dx, mx+dx { + mi := mask.PixOffset(mx, my) + ma := uint32(mask.Pix[mi]) + ma |= ma << 8 + si := src.PixOffset(sx, sy) + sr := uint32(src.Pix[si+0]) + sg := uint32(src.Pix[si+1]) + sb := uint32(src.Pix[si+2]) + sa := uint32(src.Pix[si+3]) + sr |= sr << 8 + sg |= sg << 8 + sb |= sb << 8 + sa |= sa << 8 + d := dst.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + dr := uint32(d[0]) + dg := uint32(d[1]) + db := uint32(d[2]) + da := uint32(d[3]) + + // dr, dg, db and da are all 8-bit color at the moment, ranging in [0,255]. + // We work in 16-bit color, and so would normally do: + // dr |= dr << 8 + // and similarly for dg, db and da, but instead we multiply a + // (which is a 16-bit color, ranging in [0,65535]) by 0x101. + // This yields the same result, but is fewer arithmetic operations. + a := (m - (sa * ma / m)) * 0x101 + + d[0] = uint8((dr*a + sr*ma) / m >> 8) + d[1] = uint8((dg*a + sg*ma) / m >> 8) + d[2] = uint8((db*a + sb*ma) / m >> 8) + d[3] = uint8((da*a + sa*ma) / m >> 8) + } + i0 += dy * dst.Stride + } +} + +func drawRGBA64ImageMaskOver(dst *image.RGBA, r image.Rectangle, src image.RGBA64Image, sp image.Point, mask *image.Alpha, mp image.Point) { + x0, x1, dx := r.Min.X, r.Max.X, 1 + y0, y1, dy := r.Min.Y, r.Max.Y, 1 + if image.Image(dst) == src && r.Overlaps(r.Add(sp.Sub(r.Min))) { + if sp.Y < r.Min.Y || sp.Y == r.Min.Y && sp.X < r.Min.X { + x0, x1, dx = x1-1, x0-1, -1 + y0, y1, dy = y1-1, y0-1, -1 + } + } + + sy := sp.Y + y0 - r.Min.Y + my := mp.Y + y0 - r.Min.Y + sx0 := sp.X + x0 - r.Min.X + mx0 := mp.X + x0 - r.Min.X + sx1 := sx0 + (x1 - x0) + i0 := dst.PixOffset(x0, y0) + di := dx * 4 + for y := y0; y != y1; y, sy, my = y+dy, sy+dy, my+dy { + for i, sx, mx := i0, sx0, mx0; sx != sx1; i, sx, mx = i+di, sx+dx, mx+dx { + mi := mask.PixOffset(mx, my) + ma := uint32(mask.Pix[mi]) + ma |= ma << 8 + srgba := src.RGBA64At(sx, sy) + d := dst.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + dr := uint32(d[0]) + dg := uint32(d[1]) + db := uint32(d[2]) + da := uint32(d[3]) + + // dr, dg, db and da are all 8-bit color at the moment, ranging in [0,255]. + // We work in 16-bit color, and so would normally do: + // dr |= dr << 8 + // and similarly for dg, db and da, but instead we multiply a + // (which is a 16-bit color, ranging in [0,65535]) by 0x101. + // This yields the same result, but is fewer arithmetic operations. + a := (m - (uint32(srgba.A) * ma / m)) * 0x101 + + d[0] = uint8((dr*a + uint32(srgba.R)*ma) / m >> 8) + d[1] = uint8((dg*a + uint32(srgba.G)*ma) / m >> 8) + d[2] = uint8((db*a + uint32(srgba.B)*ma) / m >> 8) + d[3] = uint8((da*a + uint32(srgba.A)*ma) / m >> 8) + } + i0 += dy * dst.Stride + } +} + func drawRGBA(dst *image.RGBA, r image.Rectangle, src image.Image, sp image.Point, mask image.Image, mp image.Point, op Op) { x0, x1, dx := r.Min.X, r.Max.X, 1 y0, y1, dy := r.Min.Y, r.Max.Y, 1 diff --git a/src/image/draw/draw_test.go b/src/image/draw/draw_test.go index 8a51409526..75a2896631 100644 --- a/src/image/draw/draw_test.go +++ b/src/image/draw/draw_test.go @@ -397,6 +397,10 @@ var drawTests = []drawTest{ Over, color.RGBA{81, 0, 102, 255}}, {"genericSrcSlowest", fillBlue(255), convertToSlowestRGBA(vgradAlpha(192)), Src, color.RGBA{0, 0, 102, 102}}, + // The source pixel is {0, 48, 0, 90}. + {"rgbaVariableMaskOver", vgradGreen(255), vgradAlpha(192), Over, color.RGBA{81, 54, 0, 255}}, + // The source pixel is {136} in Gray-space, which is {136, 136, 136, 255} in RGBA-space. + {"grayVariableMaskOver", vgradGray(), vgradAlpha(192), Over, color.RGBA{136, 54, 54, 255}}, } func makeGolden(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, mask image.Image, mp image.Point, op Op) image.Image { From 1ed060cf87ec887ad76c51e3f7a2148cc2a7bf9b Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 21 Oct 2021 11:11:13 -0400 Subject: [PATCH 133/406] testing: reference benchmark format spec This updates the testing package documentation to reference the specification for the benchmark format, and points users to our standard tools for working with benchmark data. (It's somewhat remarkable how widely used benchstat appears to be given that we don't mention it anywhere!) Change-Id: Idbb4416d2fde9606ea7e6c15595f3b9e6a38f3b0 Reviewed-on: https://go-review.googlesource.com/c/go/+/357589 Trust: Austin Clements Reviewed-by: Ian Lance Taylor --- src/testing/testing.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/testing/testing.go b/src/testing/testing.go index d03c0b1cf9..6fb1a71d43 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -75,6 +75,14 @@ // }) // } // +// A detailed specification of the benchmark results format is given +// in https://golang.org/design/14313-benchmark-format. +// +// There are standard tools for working with benchmark results at +// https://golang.org/x/perf/cmd. +// In particular, https://golang.org/x/perf/cmd/benchstat performs +// statistically robust A/B comparisons. +// // Examples // // The package also runs and verifies example code. Example functions may From 89cc528e430c18c6c36b8e8bbfb1bab26ed110e3 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Sat, 23 Oct 2021 16:39:32 -0700 Subject: [PATCH 134/406] cmd/compile/internal/types2: better error messages for empty type sets - change _TypeSet.hasTerms() to report if a type set has actual types (excluding a "universe" term) - handle empty type set type arguments correctly - bring comments up-to-date in Checker.satisfies Change-Id: I87f9a1096ebb21a1b08c87a9b59f400f3bc2f040 Reviewed-on: https://go-review.googlesource.com/c/go/+/358175 Trust: Robert Griesemer Reviewed-by: Robert Findley --- .../compile/internal/types2/instantiate.go | 32 +++++++++++++------ .../types2/testdata/check/typeinst2.go2 | 28 +++++++++++++--- .../types2/testdata/fixedbugs/issue47411.go2 | 2 +- src/cmd/compile/internal/types2/typeset.go | 2 +- 4 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/cmd/compile/internal/types2/instantiate.go b/src/cmd/compile/internal/types2/instantiate.go index d6cefb4bfe..8228ef2c31 100644 --- a/src/cmd/compile/internal/types2/instantiate.go +++ b/src/cmd/compile/internal/types2/instantiate.go @@ -135,8 +135,16 @@ func (check *Checker) verify(pos syntax.Pos, tparams []*TypeParam, targs []Type) // TODO(gri) This should be a method of interfaces or type sets. func (check *Checker) satisfies(pos syntax.Pos, targ Type, tpar *TypeParam, smap substMap) error { iface := tpar.iface() + + // Every type argument satisfies interface{}. if iface.Empty() { - return nil // no type bound + return nil + } + + // A type argument that is a type parameter with an empty type set satisfies any constraint. + // (The empty set is a subset of any set.) + if targ := asTypeParam(targ); targ != nil && targ.iface().typeSet().IsEmpty() { + return nil } // TODO(rfindley): it would be great if users could pass in a qualifier here, @@ -150,6 +158,11 @@ func (check *Checker) satisfies(pos syntax.Pos, targ Type, tpar *TypeParam, smap return errors.New(sprintf(qf, format, args...)) } + // No type argument with non-empty type set satisfies the empty type set. + if iface.typeSet().IsEmpty() { + return errorf("%s does not satisfy %s (constraint type set is empty)", targ, tpar.bound) + } + // The type parameter bound is parameterized with the same type parameters // as the instantiated type; before we can use it for bounds checking we // need to instantiate it with the type arguments with which we instantiate @@ -190,28 +203,27 @@ func (check *Checker) satisfies(pos syntax.Pos, targ Type, tpar *TypeParam, smap } } - // targ's underlying type must also be one of the interface types listed, if any + // targ must also be in the set of types of iface, if any. + // Constraints with empty type sets were already excluded above. if !iface.typeSet().hasTerms() { return nil // nothing to do } - // If targ is itself a type parameter, each of its possible types, but at least one, must be in the - // list of iface types (i.e., the targ type list must be a non-empty subset of the iface types). + // If targ is itself a type parameter, each of its possible types must be in the set + // of iface types (i.e., the targ type set must be a subset of the iface type set). + // Type arguments with empty type sets were already excluded above. if targ := asTypeParam(targ); targ != nil { targBound := targ.iface() - if !targBound.typeSet().hasTerms() { - return errorf("%s does not satisfy %s (%s has no type constraints)", targ, tpar.bound, targ) - } if !targBound.typeSet().subsetOf(iface.typeSet()) { - // TODO(gri) need better error message + // TODO(gri) report which type is missing return errorf("%s does not satisfy %s", targ, tpar.bound) } return nil } - // Otherwise, targ's type or underlying type must also be one of the interface types listed, if any. + // Otherwise, targ's type must be included in the iface type set. if !iface.typeSet().includes(targ) { - // TODO(gri) better error message + // TODO(gri) report which type is missing return errorf("%s does not satisfy %s", targ, tpar.bound) } diff --git a/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 b/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 index ecf4b0f714..783ff346c9 100644 --- a/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 @@ -226,10 +226,10 @@ type I012 interface { } func f012[T I012]() {} -var _ = f012[int /* ERROR does not satisfy I012 */ ] -var _ = f012[bool /* ERROR does not satisfy I012 */ ] -var _ = f012[string /* ERROR does not satisfy I012 */ ] -var _ = f012[float64 /* ERROR does not satisfy I012 */ ] +var _ = f012[int /* ERROR does not satisfy I012.*type set is empty */ ] +var _ = f012[bool /* ERROR does not satisfy I012.*type set is empty */ ] +var _ = f012[string /* ERROR does not satisfy I012.*type set is empty */ ] +var _ = f012[float64 /* ERROR does not satisfy I012.*type set is empty */ ] type I12 interface { E1 @@ -256,3 +256,23 @@ var _ = f0_[float64 /* ERROR does not satisfy I0_ */ ] // Using a function instance as a type is an error. var _ f0 // ERROR not a type var _ f0 /* ERROR not a type */ [int] + +// Empty type sets can only be satisfied by empty type sets. +type none interface { + // force an empty type set + int + string +} + +func ff[T none]() {} +func gg[T any]() {} +func hh[T ~int]() {} + +func _[T none]() { + _ = ff[int /* ERROR int does not satisfy none \(constraint type set is empty\) */ ] + _ = ff[T] // pathological but ok because T's type set is empty, too + _ = gg[int] + _ = gg[T] + _ = hh[int] + _ = hh[T] +} \ No newline at end of file diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue47411.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue47411.go2 index 77281a19a2..ccf4bcf782 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue47411.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue47411.go2 @@ -19,7 +19,7 @@ func _[P comparable, _ = f[R /* ERROR R has no constraints */ ] _ = g[int] - _ = g[P /* ERROR P has no type constraints */ ] + _ = g[P /* ERROR P does not satisfy interface{interface{comparable; ~int\|~string} */ ] _ = g[Q] _ = g[func( /* ERROR does not satisfy comparable */ )] _ = g[R /* ERROR R has no constraints */ ] diff --git a/src/cmd/compile/internal/types2/typeset.go b/src/cmd/compile/internal/types2/typeset.go index 8eb43a27e5..f9e3af7ba8 100644 --- a/src/cmd/compile/internal/types2/typeset.go +++ b/src/cmd/compile/internal/types2/typeset.go @@ -101,7 +101,7 @@ func (s *_TypeSet) String() string { // ---------------------------------------------------------------------------- // Implementation -func (s *_TypeSet) hasTerms() bool { return !s.terms.isAll() } +func (s *_TypeSet) hasTerms() bool { return !s.terms.isEmpty() && !s.terms.isAll() } func (s *_TypeSet) structuralType() Type { return s.terms.structuralType() } func (s *_TypeSet) includes(t Type) bool { return s.terms.includes(t) } func (s1 *_TypeSet) subsetOf(s2 *_TypeSet) bool { return s1.terms.subsetOf(s2.terms) } From 2c66cab8a7b569b2dc5a7ab112ba4579f39c5dbb Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Mon, 18 Oct 2021 18:34:24 -0400 Subject: [PATCH 135/406] testing: skip extra -count iterations if there are no tests When running benchmarks with high -count and no tests (either at all or filtered with -run), the time for runTests to check for tests -count times can add a significant delay to starting benchmarks. To avoid this delay, make runTests bail out on the second iteration if the first found no tests to run. We expect the same tests to run every time, so there is no reason to duplicate work. One caveat: the testing docs do not explicitly require the same subtests to be run on every call, so this could break tests that depend on multiple runs to actually run all tests. I consider such tests invalid, but some may exist. Fixes #49050 Change-Id: I7b34f3832b31493cc089ee0555e231f4dc690154 Reviewed-on: https://go-review.googlesource.com/c/go/+/356669 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/testing/testing.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/testing/testing.go b/src/testing/testing.go index 6fb1a71d43..2ad2266e2d 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -1785,6 +1785,12 @@ func runTests(matchString func(pat, str string) (bool, error), tests []InternalT if shouldFailFast() { break } + if i > 0 && !ran { + // There were no tests to run on the first + // iteration. This won't change, so no reason + // to keep trying. + break + } ctx := newTestContext(*parallel, newMatcher(matchString, *match, "-test.run")) ctx.deadline = deadline t := &T{ From c6e82e5808f4fb6da0fcc9754e29a220451a0dfd Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Mon, 25 Oct 2021 17:54:11 +0800 Subject: [PATCH 136/406] cmd/compile: fix inlining labeled switch statements CL 357649 fixes inlining labeled FOR/RANGE loops, we should do same translation for inlined SWITCH's label Fixes #49145 Change-Id: I9a6f365f57e974271a1eb279b38e81f9b5148788 Reviewed-on: https://go-review.googlesource.com/c/go/+/358315 Trust: Cuong Manh Le Trust: Dan Scales Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Keith Randall Reviewed-by: Dan Scales --- src/cmd/compile/internal/inline/inl.go | 20 ++++++++++++------- test/fixedbugs/issue49145.go | 27 ++++++++++++++++++++++++++ test/fixedbugs/issue49145.out | 3 +++ 3 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 test/fixedbugs/issue49145.go create mode 100644 test/fixedbugs/issue49145.out diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index fb6cf53155..1ae6a58de0 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -1285,18 +1285,24 @@ func (subst *inlsubst) node(n ir.Node) ir.Node { ir.EditChildren(m, subst.edit) if subst.newclofn == nil { - // Translate any label on FOR or RANGE loops - if m.Op() == ir.OFOR { + // Translate any label on FOR, RANGE loops or SWITCH + switch m.Op() { + case ir.OFOR: m := m.(*ir.ForStmt) m.Label = translateLabel(m.Label) return m + + case ir.ORANGE: + m := m.(*ir.RangeStmt) + m.Label = translateLabel(m.Label) + return m + + case ir.OSWITCH: + m := m.(*ir.SwitchStmt) + m.Label = translateLabel(m.Label) + return m } - if m.Op() == ir.ORANGE { - m := m.(*ir.RangeStmt) - m.Label = translateLabel(m.Label) - return m - } } switch m := m.(type) { diff --git a/test/fixedbugs/issue49145.go b/test/fixedbugs/issue49145.go new file mode 100644 index 0000000000..d66668196e --- /dev/null +++ b/test/fixedbugs/issue49145.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2021 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 main + +func f(j int) { +loop: + switch j { + case 1: + break loop + default: + println(j) + } +} + +func main() { +loop: + for j := 0; j < 5; j++ { + f(j) + if j == 3 { + break loop + } + } +} diff --git a/test/fixedbugs/issue49145.out b/test/fixedbugs/issue49145.out new file mode 100644 index 0000000000..1556c06ea8 --- /dev/null +++ b/test/fixedbugs/issue49145.out @@ -0,0 +1,3 @@ +0 +2 +3 From 52b10ab79451df78797b87e40eb9371127bad260 Mon Sep 17 00:00:00 2001 From: Charlotte Brandhorst-Satzkorn Date: Fri, 22 Oct 2021 22:46:46 -0400 Subject: [PATCH 137/406] net/http: correct Content-Length parsing for js/wasm The Content-Length was incorrectly set to 0 for ill-formed and invalid values. In these cases, return an error. If the Content-Length header was omitted, it was incorrectly set to 0. In this case, set the Content-Length value to -1. Fixes #49108 Change-Id: I24fe9a31ed5b6ddb53f2b2bd10f2c84e428823e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/358134 Run-TryBot: Johan Brandhorst-Satzkorn Run-TryBot: Brad Fitzpatrick TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick Trust: Brad Fitzpatrick Trust: David Crawshaw --- src/net/http/roundtrip_js.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/net/http/roundtrip_js.go b/src/net/http/roundtrip_js.go index 74c83a9172..362dbcbdde 100644 --- a/src/net/http/roundtrip_js.go +++ b/src/net/http/roundtrip_js.go @@ -131,8 +131,24 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { } contentLength := int64(0) - if cl, err := strconv.ParseInt(header.Get("Content-Length"), 10, 64); err == nil { + clHeader := header.Get("Content-Length") + switch { + case clHeader != "": + cl, err := strconv.ParseInt(clHeader, 10, 64) + if err != nil { + errCh <- fmt.Errorf("net/http: ill-formed Content-Length header: %v", err) + return nil + } + if cl < 0 { + // Content-Length values less than 0 are invalid. + // See: https://datatracker.ietf.org/doc/html/rfc2616/#section-14.13 + errCh <- fmt.Errorf("net/http: invalid Content-Length header: %q", clHeader) + return nil + } contentLength = cl + default: + // If the response length is not declared, set it to -1. + contentLength = -1 } b := result.Get("body") From 70ffd852cc85f1c782f4f2e70518d4861939cd1b Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Thu, 21 Oct 2021 18:36:14 -0400 Subject: [PATCH 138/406] go/types: remove subscripts from type parameter names Now that we've removed the necessity for subscripts in importers, we can effectively eliminate them from the the type parameter API by removing them from the type string. Change-Id: Ic4491b0dea27b0e0ce2d0636dccfaf05168ef9e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/357814 Trust: Robert Findley Run-TryBot: Robert Findley Reviewed-by: Robert Griesemer TryBot-Result: Go Bot --- src/go/types/api_test.go | 12 ++++++------ src/go/types/builtins_test.go | 6 +++--- src/go/types/errors.go | 10 +++++----- src/go/types/instantiate.go | 2 +- src/go/types/typestring.go | 26 ++++++++++++++++++-------- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/go/types/api_test.go b/src/go/types/api_test.go index b331ad929b..7407426979 100644 --- a/src/go/types/api_test.go +++ b/src/go/types/api_test.go @@ -345,18 +345,18 @@ func TestTypesInfo(t *testing.T) { {broken + `x5; func _() { var x map[string][...]int; x = map[string][...]int{"": {1,2,3}} }`, `x`, `map[string][-1]int`}, // parameterized functions - {genericPkg + `p0; func f[T any](T) {}; var _ = f[int]`, `f`, `func[generic_p0.T₁ interface{}](generic_p0.T₁)`}, + {genericPkg + `p0; func f[T any](T) {}; var _ = f[int]`, `f`, `func[generic_p0.T interface{}](generic_p0.T)`}, {genericPkg + `p1; func f[T any](T) {}; var _ = f[int]`, `f[int]`, `func(int)`}, {genericPkg + `p2; func f[T any](T) {}; func _() { f(42) }`, `f`, `func(int)`}, {genericPkg + `p3; func f[T any](T) {}; func _() { f[int](42) }`, `f[int]`, `func(int)`}, - {genericPkg + `p4; func f[T any](T) {}; func _() { f[int](42) }`, `f`, `func[generic_p4.T₁ interface{}](generic_p4.T₁)`}, + {genericPkg + `p4; func f[T any](T) {}; func _() { f[int](42) }`, `f`, `func[generic_p4.T interface{}](generic_p4.T)`}, {genericPkg + `p5; func f[T any](T) {}; func _() { f(42) }`, `f(42)`, `()`}, // type parameters {genericPkg + `t0; type t[] int; var _ t`, `t`, `generic_t0.t`}, // t[] is a syntax error that is ignored in this test in favor of t - {genericPkg + `t1; type t[P any] int; var _ t[int]`, `t`, `generic_t1.t[generic_t1.P₁ interface{}]`}, - {genericPkg + `t2; type t[P interface{}] int; var _ t[int]`, `t`, `generic_t2.t[generic_t2.P₁ interface{}]`}, - {genericPkg + `t3; type t[P, Q interface{}] int; var _ t[int, int]`, `t`, `generic_t3.t[generic_t3.P₁, generic_t3.Q₂ interface{}]`}, + {genericPkg + `t1; type t[P any] int; var _ t[int]`, `t`, `generic_t1.t[generic_t1.P interface{}]`}, + {genericPkg + `t2; type t[P interface{}] int; var _ t[int]`, `t`, `generic_t2.t[generic_t2.P interface{}]`}, + {genericPkg + `t3; type t[P, Q interface{}] int; var _ t[int, int]`, `t`, `generic_t3.t[generic_t3.P, generic_t3.Q interface{}]`}, // TODO (rFindley): compare with types2, which resolves the type broken_t4.t[P₁, Q₂ interface{m()}] here {broken + `t4; type t[P, Q interface{ m() }] int; var _ t[int, int]`, `t`, `broken_t4.t`}, @@ -365,7 +365,7 @@ func TestTypesInfo(t *testing.T) { {genericPkg + `g0; type t[P any] int; var x struct{ f t[int] }; var _ = x.f`, `x.f`, `generic_g0.t[int]`}, // issue 45096 - {genericPkg + `issue45096; func _[T interface{ ~int8 | ~int16 | ~int32 }](x T) { _ = x < 0 }`, `0`, `generic_issue45096.T₁`}, + {genericPkg + `issue45096; func _[T interface{ ~int8 | ~int16 | ~int32 }](x T) { _ = x < 0 }`, `0`, `generic_issue45096.T`}, // issue 47895 {`package p; import "unsafe"; type S struct { f int }; var s S; var _ = unsafe.Offsetof(s.f)`, `s.f`, `int`}, diff --git a/src/go/types/builtins_test.go b/src/go/types/builtins_test.go index cee3d315e5..db56aea3fe 100644 --- a/src/go/types/builtins_test.go +++ b/src/go/types/builtins_test.go @@ -113,15 +113,15 @@ var builtinCalls = []struct { {"Alignof", `_ = unsafe.Alignof(0)`, `invalid type`}, // constant {"Alignof", `var x struct{}; _ = unsafe.Alignof(x)`, `invalid type`}, // constant - {"Alignof", `var x P; _ = unsafe.Alignof(x)`, `func(p.P₁) uintptr`}, + {"Alignof", `var x P; _ = unsafe.Alignof(x)`, `func(p.P) uintptr`}, {"Offsetof", `var x struct{f bool}; _ = unsafe.Offsetof(x.f)`, `invalid type`}, // constant {"Offsetof", `var x struct{_ int; f bool}; _ = unsafe.Offsetof((&x).f)`, `invalid type`}, // constant - {"Offsetof", `var x struct{_ int; f P}; _ = unsafe.Offsetof((&x).f)`, `func(p.P₁) uintptr`}, + {"Offsetof", `var x struct{_ int; f P}; _ = unsafe.Offsetof((&x).f)`, `func(p.P) uintptr`}, {"Sizeof", `_ = unsafe.Sizeof(0)`, `invalid type`}, // constant {"Sizeof", `var x struct{}; _ = unsafe.Sizeof(x)`, `invalid type`}, // constant - {"Sizeof", `var x P; _ = unsafe.Sizeof(x)`, `func(p.P₁) uintptr`}, + {"Sizeof", `var x P; _ = unsafe.Sizeof(x)`, `func(p.P) uintptr`}, {"Slice", `var p *int; _ = unsafe.Slice(p, 1)`, `func(*int, int) []int`}, {"Slice", `var p *byte; var n uintptr; _ = unsafe.Slice(p, n)`, `func(*byte, uintptr) []byte`}, diff --git a/src/go/types/errors.go b/src/go/types/errors.go index 2d48fe14da..92002add13 100644 --- a/src/go/types/errors.go +++ b/src/go/types/errors.go @@ -63,10 +63,10 @@ func (check *Checker) markImports(pkg *Package) { } func (check *Checker) sprintf(format string, args ...interface{}) string { - return sprintf(check.fset, check.qualifier, format, args...) + return sprintf(check.fset, check.qualifier, false, format, args...) } -func sprintf(fset *token.FileSet, qf Qualifier, format string, args ...interface{}) string { +func sprintf(fset *token.FileSet, qf Qualifier, debug bool, format string, args ...interface{}) string { for i, arg := range args { switch a := arg.(type) { case nil: @@ -84,7 +84,7 @@ func sprintf(fset *token.FileSet, qf Qualifier, format string, args ...interface case Object: arg = ObjectString(a, qf) case Type: - arg = TypeString(a, qf) + arg = typeString(a, qf, debug) } args[i] = arg } @@ -95,13 +95,13 @@ func (check *Checker) trace(pos token.Pos, format string, args ...interface{}) { fmt.Printf("%s:\t%s%s\n", check.fset.Position(pos), strings.Repeat(". ", check.indent), - check.sprintf(format, args...), + sprintf(check.fset, check.qualifier, true, format, args...), ) } // dump is only needed for debugging func (check *Checker) dump(format string, args ...interface{}) { - fmt.Println(check.sprintf(format, args...)) + fmt.Println(sprintf(check.fset, check.qualifier, true, format, args...)) } func (check *Checker) err(err error) { diff --git a/src/go/types/instantiate.go b/src/go/types/instantiate.go index 65c935a192..2bb31b17ee 100644 --- a/src/go/types/instantiate.go +++ b/src/go/types/instantiate.go @@ -146,7 +146,7 @@ func (check *Checker) satisfies(pos token.Pos, targ Type, tpar *TypeParam, smap qf = check.qualifier } errorf := func(format string, args ...interface{}) error { - return errors.New(sprintf(nil, qf, format, args...)) + return errors.New(sprintf(nil, qf, false, format, args...)) } // The type parameter bound is parameterized with the same type parameters diff --git a/src/go/types/typestring.go b/src/go/types/typestring.go index a0c78e8cc3..2feaf627d6 100644 --- a/src/go/types/typestring.go +++ b/src/go/types/typestring.go @@ -44,8 +44,14 @@ func RelativeTo(pkg *Package) Qualifier { // The Qualifier controls the printing of // package-level objects, and may be nil. func TypeString(typ Type, qf Qualifier) string { + return typeString(typ, qf, false) +} + +func typeString(typ Type, qf Qualifier, debug bool) string { var buf bytes.Buffer - WriteType(&buf, typ, qf) + w := newTypeWriter(&buf, qf) + w.debug = debug + w.typ(typ) return buf.String() } @@ -65,19 +71,20 @@ func WriteSignature(buf *bytes.Buffer, sig *Signature, qf Qualifier) { } type typeWriter struct { - buf *bytes.Buffer - seen map[Type]bool - qf Qualifier - ctxt *Context // if non-nil, we are type hashing + buf *bytes.Buffer + seen map[Type]bool + qf Qualifier + ctxt *Context // if non-nil, we are type hashing + debug bool // if true, write debug annotations } func newTypeWriter(buf *bytes.Buffer, qf Qualifier) *typeWriter { - return &typeWriter{buf, make(map[Type]bool), qf, nil} + return &typeWriter{buf, make(map[Type]bool), qf, nil, false} } func newTypeHasher(buf *bytes.Buffer, ctxt *Context) *typeWriter { assert(ctxt != nil) - return &typeWriter{buf, make(map[Type]bool), nil, ctxt} + return &typeWriter{buf, make(map[Type]bool), nil, ctxt, false} } func (w *typeWriter) byte(b byte) { @@ -274,7 +281,10 @@ func (w *typeWriter) typ(typ Type) { if t.obj.pkg != nil { writePackage(w.buf, t.obj.pkg, w.qf) } - w.string(t.obj.name + subscript(t.id)) + w.string(t.obj.name) + if w.debug || w.ctxt != nil { + w.string(subscript(t.id)) + } case *top: w.error("⊤") From bc0eb5789e01817823fd9707d2d4857691f898ad Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 19 Oct 2021 18:40:27 -0400 Subject: [PATCH 139/406] cmd/compile/internal/typecheck: record whether an interface is implicit In preparation for capturing the implicit interface bit in export data, thread through the IsImplicit property from types2 into typecheck. Change-Id: I9b46fe73de102935a127e6ececaacd76738b557e Reviewed-on: https://go-review.googlesource.com/c/go/+/357109 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky Reviewed-by: Cuong Manh Le --- src/cmd/compile/internal/noder/reader.go | 2 +- src/cmd/compile/internal/noder/stencil.go | 2 +- src/cmd/compile/internal/noder/types.go | 2 +- src/cmd/compile/internal/test/abiutils_test.go | 2 +- src/cmd/compile/internal/typecheck/iimport.go | 2 +- src/cmd/compile/internal/typecheck/subr.go | 4 ++-- src/cmd/compile/internal/typecheck/type.go | 2 +- src/cmd/compile/internal/types/sizeof_test.go | 2 +- src/cmd/compile/internal/types/type.go | 13 +++++++++++-- src/cmd/compile/internal/types/universe.go | 8 ++++---- 10 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go index 48f4368113..0bc9135999 100644 --- a/src/cmd/compile/internal/noder/reader.go +++ b/src/cmd/compile/internal/noder/reader.go @@ -466,7 +466,7 @@ func (r *reader) interfaceType() *types.Type { if len(fields) == 0 { return types.Types[types.TINTER] // empty interface } - return types.NewInterface(tpkg, fields) + return types.NewInterface(tpkg, fields, false) } func (r *reader) structType() *types.Type { diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 592de7017f..474a05973a 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -881,7 +881,7 @@ func (subst *subster) checkDictionary(name *ir.Name, targs []*types.Type) (code cond := ir.NewBinaryExpr(pos, ir.ONE, want, got) typed(types.Types[types.TBOOL], cond) panicArg := ir.NewNilExpr(pos) - typed(types.NewInterface(types.LocalPkg, nil), panicArg) + typed(types.NewInterface(types.LocalPkg, nil, false), panicArg) then := ir.NewUnaryExpr(pos, ir.OPANIC, panicArg) then.SetTypecheck(1) x := ir.NewIfStmt(pos, cond, []ir.Node{then}, nil) diff --git a/src/cmd/compile/internal/noder/types.go b/src/cmd/compile/internal/noder/types.go index 1a7cef4aa3..f035e0da97 100644 --- a/src/cmd/compile/internal/noder/types.go +++ b/src/cmd/compile/internal/noder/types.go @@ -213,7 +213,7 @@ func (g *irgen) typ0(typ types2.Type) *types.Type { methods[i] = types.NewField(g.pos(m), g.selector(m), mtyp) } - return types.NewInterface(g.tpkg(typ), append(embeddeds, methods...)) + return types.NewInterface(g.tpkg(typ), append(embeddeds, methods...), typ.IsImplicit()) case *types2.TypeParam: // Save the name of the type parameter in the sym of the type. diff --git a/src/cmd/compile/internal/test/abiutils_test.go b/src/cmd/compile/internal/test/abiutils_test.go index f26cb89c6d..12b4a0c361 100644 --- a/src/cmd/compile/internal/test/abiutils_test.go +++ b/src/cmd/compile/internal/test/abiutils_test.go @@ -313,7 +313,7 @@ func TestABIUtilsInterfaces(t *testing.T) { fldt := mkFuncType(types.FakeRecvType(), []*types.Type{}, []*types.Type{types.Types[types.TSTRING]}) field := types.NewField(src.NoXPos, typecheck.Lookup("F"), fldt) - nei := types.NewInterface(types.LocalPkg, []*types.Field{field}) + nei := types.NewInterface(types.LocalPkg, []*types.Field{field}, false) i16 := types.Types[types.TINT16] tb := types.Types[types.TBOOL] s1 := mkstruct([]*types.Type{i16, i16, tb}) diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index cb1e56bf51..fcfadc146c 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -815,7 +815,7 @@ func (r *importReader) typ1() *types.Type { return types.Types[types.TINTER] } - t := types.NewInterface(r.currPkg, append(embeddeds, methods...)) + t := types.NewInterface(r.currPkg, append(embeddeds, methods...), false) // Ensure we expand the interface in the frontend (#25055). types.CheckSize(t) diff --git a/src/cmd/compile/internal/typecheck/subr.go b/src/cmd/compile/internal/typecheck/subr.go index b4d5302525..9ebd8f1423 100644 --- a/src/cmd/compile/internal/typecheck/subr.go +++ b/src/cmd/compile/internal/typecheck/subr.go @@ -1369,7 +1369,7 @@ func (ts *Tsubster) tinter(t *types.Type, force bool) *types.Type { // For an empty interface, we need to return a new type, // since it may now be fully instantiated (HasTParam // becomes false). - return types.NewInterface(t.Pkg(), nil) + return types.NewInterface(t.Pkg(), nil, false) } return t } @@ -1390,7 +1390,7 @@ func (ts *Tsubster) tinter(t *types.Type, force bool) *types.Type { } } if newfields != nil { - return types.NewInterface(t.Pkg(), newfields) + return types.NewInterface(t.Pkg(), newfields, false) } return t } diff --git a/src/cmd/compile/internal/typecheck/type.go b/src/cmd/compile/internal/typecheck/type.go index af694c2d94..c4c1ef58ca 100644 --- a/src/cmd/compile/internal/typecheck/type.go +++ b/src/cmd/compile/internal/typecheck/type.go @@ -108,7 +108,7 @@ func tcInterfaceType(n *ir.InterfaceType) ir.Node { methods := tcFields(n.Methods, nil) base.Pos = lno - n.SetOTYPE(types.NewInterface(types.LocalPkg, methods)) + n.SetOTYPE(types.NewInterface(types.LocalPkg, methods, false)) return n } diff --git a/src/cmd/compile/internal/types/sizeof_test.go b/src/cmd/compile/internal/types/sizeof_test.go index 7349e52a73..d37c173058 100644 --- a/src/cmd/compile/internal/types/sizeof_test.go +++ b/src/cmd/compile/internal/types/sizeof_test.go @@ -26,7 +26,7 @@ func TestSizeof(t *testing.T) { {Forward{}, 20, 32}, {Func{}, 28, 48}, {Struct{}, 16, 32}, - {Interface{}, 4, 8}, + {Interface{}, 8, 16}, {Chan{}, 8, 16}, {Array{}, 12, 16}, {FuncArgs{}, 4, 8}, diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go index 392c54ba79..ec17fe8704 100644 --- a/src/cmd/compile/internal/types/type.go +++ b/src/cmd/compile/internal/types/type.go @@ -417,7 +417,8 @@ func (t *Type) StructType() *Struct { // Interface contains Type fields specific to interface types. type Interface struct { - pkg *Pkg + pkg *Pkg + implicit bool } // Typeparam contains Type fields specific to typeparam types. @@ -1820,7 +1821,7 @@ func newBasic(kind Kind, obj Object) *Type { // NewInterface returns a new interface for the given methods and // embedded types. Embedded types are specified as fields with no Sym. -func NewInterface(pkg *Pkg, methods []*Field) *Type { +func NewInterface(pkg *Pkg, methods []*Field, implicit bool) *Type { t := newType(TINTER) t.SetInterface(methods) for _, f := range methods { @@ -1838,6 +1839,7 @@ func NewInterface(pkg *Pkg, methods []*Field) *Type { t.SetBroke(true) } t.extra.(*Interface).pkg = pkg + t.extra.(*Interface).implicit = implicit return t } @@ -1875,6 +1877,13 @@ func (t *Type) Bound() *Type { return t.extra.(*Typeparam).bound } +// IsImplicit reports whether an interface is implicit (i.e. elided from a type +// parameter constraint). +func (t *Type) IsImplicit() bool { + t.wantEtype(TINTER) + return t.extra.(*Interface).implicit +} + // NewUnion returns a new union with the specified set of terms (types). If // tildes[i] is true, then terms[i] represents ~T, rather than just T. func NewUnion(terms []*Type, tildes []bool) *Type { diff --git a/src/cmd/compile/internal/types/universe.go b/src/cmd/compile/internal/types/universe.go index 8fa4b7cd20..d5239eb10c 100644 --- a/src/cmd/compile/internal/types/universe.go +++ b/src/cmd/compile/internal/types/universe.go @@ -58,7 +58,7 @@ func InitTypes(defTypeName func(sym *Sym, typ *Type) Object) { } Types[TANY] = newType(TANY) - Types[TINTER] = NewInterface(LocalPkg, nil) + Types[TINTER] = NewInterface(LocalPkg, nil, false) defBasic := func(kind Kind, pkg *Pkg, name string) *Type { typ := newType(kind) @@ -111,7 +111,7 @@ func InitTypes(defTypeName func(sym *Sym, typ *Type) Object) { if base.Flag.G > 0 { DeferCheckSize() AnyType = defBasic(TFORW, BuiltinPkg, "any") - AnyType.SetUnderlying(NewInterface(NoPkg, []*Field{})) + AnyType.SetUnderlying(NewInterface(NoPkg, []*Field{}, false)) ResumeCheckSize() } @@ -145,11 +145,11 @@ func makeErrorInterface() *Type { NewField(src.NoXPos, nil, Types[TSTRING]), }) method := NewField(src.NoXPos, LocalPkg.Lookup("Error"), sig) - return NewInterface(NoPkg, []*Field{method}) + return NewInterface(NoPkg, []*Field{method}, false) } func makeComparableInterface() *Type { sig := NewSignature(NoPkg, FakeRecv(), nil, nil, nil) method := NewField(src.NoXPos, LocalPkg.Lookup("=="), sig) - return NewInterface(NoPkg, []*Field{method}) + return NewInterface(NoPkg, []*Field{method}, false) } From 95372efc4d300c54738406fb81d84a72bd8149cc Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Mon, 25 Oct 2021 18:15:43 +0800 Subject: [PATCH 140/406] cmd/compile: use SetInit instead of *PtrInit Change-Id: Ie802ff27b611ed248d7b14f6e972e6300c181f43 Reviewed-on: https://go-review.googlesource.com/c/go/+/358316 Trust: Cuong Manh Le Trust: Dan Scales Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/inline/inl.go | 4 ++-- src/cmd/compile/internal/noder/noder.go | 4 ++-- src/cmd/compile/internal/walk/complit.go | 2 +- src/cmd/compile/internal/walk/select.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index 1ae6a58de0..483b3d5d46 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -1259,7 +1259,7 @@ func (subst *inlsubst) node(n ir.Node) ir.Node { n := n.(*ir.BranchStmt) m := ir.Copy(n).(*ir.BranchStmt) m.SetPos(subst.updatedPos(m.Pos())) - *m.PtrInit() = nil + m.SetInit(nil) m.Label = translateLabel(n.Label) return m @@ -1271,7 +1271,7 @@ func (subst *inlsubst) node(n ir.Node) ir.Node { n := n.(*ir.LabelStmt) m := ir.Copy(n).(*ir.LabelStmt) m.SetPos(subst.updatedPos(m.Pos())) - *m.PtrInit() = nil + m.SetInit(nil) m.Label = translateLabel(n.Label) return m diff --git a/src/cmd/compile/internal/noder/noder.go b/src/cmd/compile/internal/noder/noder.go index 7c14fcf041..fc1541f74e 100644 --- a/src/cmd/compile/internal/noder/noder.go +++ b/src/cmd/compile/internal/noder/noder.go @@ -1238,7 +1238,7 @@ func (p *noder) ifStmt(stmt *syntax.IfStmt) ir.Node { init := p.stmt(stmt.Init) n := ir.NewIfStmt(p.pos(stmt), p.expr(stmt.Cond), p.blockStmt(stmt.Then), nil) if init != nil { - *n.PtrInit() = []ir.Node{init} + n.SetInit([]ir.Node{init}) } if stmt.Else != nil { e := p.stmt(stmt.Else) @@ -1285,7 +1285,7 @@ func (p *noder) switchStmt(stmt *syntax.SwitchStmt) ir.Node { init := p.stmt(stmt.Init) n := ir.NewSwitchStmt(p.pos(stmt), p.expr(stmt.Tag), nil) if init != nil { - *n.PtrInit() = []ir.Node{init} + n.SetInit([]ir.Node{init}) } var tswitch *ir.TypeSwitchGuard diff --git a/src/cmd/compile/internal/walk/complit.go b/src/cmd/compile/internal/walk/complit.go index ad54fa7b96..b985b4caeb 100644 --- a/src/cmd/compile/internal/walk/complit.go +++ b/src/cmd/compile/internal/walk/complit.go @@ -482,7 +482,7 @@ func maplit(n *ir.CompLitExpr, m ir.Node, init *ir.Nodes) { loop := ir.NewForStmt(base.Pos, nil, cond, incr, nil) loop.Body = []ir.Node{body} - *loop.PtrInit() = []ir.Node{zero} + loop.SetInit([]ir.Node{zero}) appendWalkStmt(init, loop) return diff --git a/src/cmd/compile/internal/walk/select.go b/src/cmd/compile/internal/walk/select.go index d2b67ddf55..fde8f50895 100644 --- a/src/cmd/compile/internal/walk/select.go +++ b/src/cmd/compile/internal/walk/select.go @@ -105,7 +105,7 @@ func walkSelectCases(cases []*ir.CommClause) []ir.Node { n := cas.Comm ir.SetPos(n) r := ir.NewIfStmt(base.Pos, nil, nil, nil) - *r.PtrInit() = cas.Init() + r.SetInit(cas.Init()) var cond ir.Node switch n.Op() { default: From 9012996a9a127fd566c72baac5e7d8ba45b4865e Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Mon, 25 Oct 2021 11:51:25 -0400 Subject: [PATCH 141/406] cmd/compile: don't clobber LR for tail calls When doing a tail call the link register is live as the callee will directly return to the caller (of the function that does the tail call). Don't allocate or clobber the link register. Fixes #49032. Change-Id: I2d60f2354e5b6c14aa285c8983a9786687b90223 Reviewed-on: https://go-review.googlesource.com/c/go/+/358435 Trust: Cherry Mui Run-TryBot: Cherry Mui Reviewed-by: Cuong Manh Le TryBot-Result: Go Bot --- src/cmd/compile/internal/ssa/gen/386Ops.go | 2 +- src/cmd/compile/internal/ssa/gen/AMD64Ops.go | 2 +- src/cmd/compile/internal/ssa/gen/ARM64Ops.go | 2 +- src/cmd/compile/internal/ssa/gen/ARMOps.go | 2 +- src/cmd/compile/internal/ssa/gen/MIPS64Ops.go | 2 +- src/cmd/compile/internal/ssa/gen/MIPSOps.go | 2 +- src/cmd/compile/internal/ssa/gen/PPC64Ops.go | 2 +- .../compile/internal/ssa/gen/RISCV64Ops.go | 8 +++--- src/cmd/compile/internal/ssa/gen/S390XOps.go | 2 +- src/cmd/compile/internal/ssa/gen/WasmOps.go | 2 +- src/cmd/compile/internal/ssa/gen/main.go | 5 ++++ src/cmd/compile/internal/ssa/op.go | 1 + src/cmd/compile/internal/ssa/opGen.go | 27 +++++++++++++------ src/cmd/compile/internal/ssa/regalloc.go | 3 ++- 14 files changed, 40 insertions(+), 22 deletions(-) diff --git a/src/cmd/compile/internal/ssa/gen/386Ops.go b/src/cmd/compile/internal/ssa/gen/386Ops.go index a6da7a5fce..f4c89b0bb3 100644 --- a/src/cmd/compile/internal/ssa/gen/386Ops.go +++ b/src/cmd/compile/internal/ssa/gen/386Ops.go @@ -455,7 +455,7 @@ func init() { }, {name: "CALLstatic", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem - {name: "CALLtail", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem + {name: "CALLtail", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true, tailCall: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem {name: "CALLclosure", argLength: 3, reg: regInfo{inputs: []regMask{gpsp, buildReg("DX"), 0}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call function via closure. arg0=codeptr, arg1=closure, arg2=mem, auxint=argsize, returns mem {name: "CALLinter", argLength: 2, reg: regInfo{inputs: []regMask{gp}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call fn by pointer. arg0=codeptr, arg1=mem, auxint=argsize, returns mem diff --git a/src/cmd/compile/internal/ssa/gen/AMD64Ops.go b/src/cmd/compile/internal/ssa/gen/AMD64Ops.go index e3c94e4b2e..a6906bec7c 100644 --- a/src/cmd/compile/internal/ssa/gen/AMD64Ops.go +++ b/src/cmd/compile/internal/ssa/gen/AMD64Ops.go @@ -765,7 +765,7 @@ func init() { // With a register ABI, the actual register info for these instructions (i.e., what is used in regalloc) is augmented with per-call-site bindings of additional arguments to specific in and out registers. {name: "CALLstatic", argLength: -1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call static function aux.(*obj.LSym). last arg=mem, auxint=argsize, returns mem - {name: "CALLtail", argLength: -1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // tail call static function aux.(*obj.LSym). last arg=mem, auxint=argsize, returns mem + {name: "CALLtail", argLength: -1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true, tailCall: true}, // tail call static function aux.(*obj.LSym). last arg=mem, auxint=argsize, returns mem {name: "CALLclosure", argLength: -1, reg: regInfo{inputs: []regMask{gpsp, buildReg("DX"), 0}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call function via closure. arg0=codeptr, arg1=closure, last arg=mem, auxint=argsize, returns mem {name: "CALLinter", argLength: -1, reg: regInfo{inputs: []regMask{gp}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call fn by pointer. arg0=codeptr, last arg=mem, auxint=argsize, returns mem diff --git a/src/cmd/compile/internal/ssa/gen/ARM64Ops.go b/src/cmd/compile/internal/ssa/gen/ARM64Ops.go index a4a5b9bdcd..e052ce09f4 100644 --- a/src/cmd/compile/internal/ssa/gen/ARM64Ops.go +++ b/src/cmd/compile/internal/ssa/gen/ARM64Ops.go @@ -492,7 +492,7 @@ func init() { // function calls {name: "CALLstatic", argLength: -1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call static function aux.(*obj.LSym). last arg=mem, auxint=argsize, returns mem - {name: "CALLtail", argLength: -1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // tail call static function aux.(*obj.LSym). last arg=mem, auxint=argsize, returns mem + {name: "CALLtail", argLength: -1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true, tailCall: true}, // tail call static function aux.(*obj.LSym). last arg=mem, auxint=argsize, returns mem {name: "CALLclosure", argLength: -1, reg: regInfo{inputs: []regMask{gpsp, buildReg("R26"), 0}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call function via closure. arg0=codeptr, arg1=closure, last arg=mem, auxint=argsize, returns mem {name: "CALLinter", argLength: -1, reg: regInfo{inputs: []regMask{gp}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call fn by pointer. arg0=codeptr, last arg=mem, auxint=argsize, returns mem diff --git a/src/cmd/compile/internal/ssa/gen/ARMOps.go b/src/cmd/compile/internal/ssa/gen/ARMOps.go index 75ba769724..2f004205a5 100644 --- a/src/cmd/compile/internal/ssa/gen/ARMOps.go +++ b/src/cmd/compile/internal/ssa/gen/ARMOps.go @@ -432,7 +432,7 @@ func init() { // function calls {name: "CALLstatic", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem - {name: "CALLtail", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem + {name: "CALLtail", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true, tailCall: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem {name: "CALLclosure", argLength: 3, reg: regInfo{inputs: []regMask{gpsp, buildReg("R7"), 0}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call function via closure. arg0=codeptr, arg1=closure, arg2=mem, auxint=argsize, returns mem {name: "CALLinter", argLength: 2, reg: regInfo{inputs: []regMask{gp}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call fn by pointer. arg0=codeptr, arg1=mem, auxint=argsize, returns mem diff --git a/src/cmd/compile/internal/ssa/gen/MIPS64Ops.go b/src/cmd/compile/internal/ssa/gen/MIPS64Ops.go index 54c0741efd..7b18c42ffb 100644 --- a/src/cmd/compile/internal/ssa/gen/MIPS64Ops.go +++ b/src/cmd/compile/internal/ssa/gen/MIPS64Ops.go @@ -276,7 +276,7 @@ func init() { // function calls {name: "CALLstatic", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem - {name: "CALLtail", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem + {name: "CALLtail", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true, tailCall: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem {name: "CALLclosure", argLength: 3, reg: regInfo{inputs: []regMask{gpsp, buildReg("R22"), 0}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call function via closure. arg0=codeptr, arg1=closure, arg2=mem, auxint=argsize, returns mem {name: "CALLinter", argLength: 2, reg: regInfo{inputs: []regMask{gp}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call fn by pointer. arg0=codeptr, arg1=mem, auxint=argsize, returns mem diff --git a/src/cmd/compile/internal/ssa/gen/MIPSOps.go b/src/cmd/compile/internal/ssa/gen/MIPSOps.go index 5f73e9f2dc..523847badc 100644 --- a/src/cmd/compile/internal/ssa/gen/MIPSOps.go +++ b/src/cmd/compile/internal/ssa/gen/MIPSOps.go @@ -258,7 +258,7 @@ func init() { // function calls {name: "CALLstatic", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem - {name: "CALLtail", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem + {name: "CALLtail", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true, tailCall: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem {name: "CALLclosure", argLength: 3, reg: regInfo{inputs: []regMask{gpsp, buildReg("R22"), 0}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call function via closure. arg0=codeptr, arg1=closure, arg2=mem, auxint=argsize, returns mem {name: "CALLinter", argLength: 2, reg: regInfo{inputs: []regMask{gp}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call fn by pointer. arg0=codeptr, arg1=mem, auxint=argsize, returns mem diff --git a/src/cmd/compile/internal/ssa/gen/PPC64Ops.go b/src/cmd/compile/internal/ssa/gen/PPC64Ops.go index 42775fa3c2..59d8af1a9d 100644 --- a/src/cmd/compile/internal/ssa/gen/PPC64Ops.go +++ b/src/cmd/compile/internal/ssa/gen/PPC64Ops.go @@ -434,7 +434,7 @@ func init() { {name: "LoweredRound64F", argLength: 1, reg: fp11, resultInArg0: true, zeroWidth: true}, {name: "CALLstatic", argLength: -1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem - {name: "CALLtail", argLength: -1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem + {name: "CALLtail", argLength: -1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true, tailCall: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem {name: "CALLclosure", argLength: -1, reg: regInfo{inputs: []regMask{callptr, ctxt, 0}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call function via closure. arg0=codeptr, arg1=closure, arg2=mem, auxint=argsize, returns mem {name: "CALLinter", argLength: -1, reg: regInfo{inputs: []regMask{callptr}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call fn by pointer. arg0=codeptr, arg1=mem, auxint=argsize, returns mem diff --git a/src/cmd/compile/internal/ssa/gen/RISCV64Ops.go b/src/cmd/compile/internal/ssa/gen/RISCV64Ops.go index 8a3fdf75f7..880fad1c49 100644 --- a/src/cmd/compile/internal/ssa/gen/RISCV64Ops.go +++ b/src/cmd/compile/internal/ssa/gen/RISCV64Ops.go @@ -240,10 +240,10 @@ func init() { {name: "MOVconvert", argLength: 2, reg: gp11, asm: "MOV"}, // arg0, but converted to int/ptr as appropriate; arg1=mem // Calls - {name: "CALLstatic", argLength: 1, reg: call, aux: "CallOff", call: true}, // call static function aux.(*gc.Sym). arg0=mem, auxint=argsize, returns mem - {name: "CALLtail", argLength: 1, reg: call, aux: "CallOff", call: true}, // tail call static function aux.(*gc.Sym). arg0=mem, auxint=argsize, returns mem - {name: "CALLclosure", argLength: 3, reg: callClosure, aux: "CallOff", call: true}, // call function via closure. arg0=codeptr, arg1=closure, arg2=mem, auxint=argsize, returns mem - {name: "CALLinter", argLength: 2, reg: callInter, aux: "CallOff", call: true}, // call fn by pointer. arg0=codeptr, arg1=mem, auxint=argsize, returns mem + {name: "CALLstatic", argLength: 1, reg: call, aux: "CallOff", call: true}, // call static function aux.(*gc.Sym). arg0=mem, auxint=argsize, returns mem + {name: "CALLtail", argLength: 1, reg: call, aux: "CallOff", call: true, tailCall: true}, // tail call static function aux.(*gc.Sym). arg0=mem, auxint=argsize, returns mem + {name: "CALLclosure", argLength: 3, reg: callClosure, aux: "CallOff", call: true}, // call function via closure. arg0=codeptr, arg1=closure, arg2=mem, auxint=argsize, returns mem + {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) diff --git a/src/cmd/compile/internal/ssa/gen/S390XOps.go b/src/cmd/compile/internal/ssa/gen/S390XOps.go index 9b6ac2bfb6..cd7bad7acb 100644 --- a/src/cmd/compile/internal/ssa/gen/S390XOps.go +++ b/src/cmd/compile/internal/ssa/gen/S390XOps.go @@ -480,7 +480,7 @@ func init() { {name: "CLEAR", argLength: 2, reg: regInfo{inputs: []regMask{ptr, 0}}, asm: "CLEAR", aux: "SymValAndOff", typ: "Mem", clobberFlags: true, faultOnNilArg0: true, symEffect: "Write"}, {name: "CALLstatic", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem - {name: "CALLtail", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem + {name: "CALLtail", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true, tailCall: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem {name: "CALLclosure", argLength: 3, reg: regInfo{inputs: []regMask{ptrsp, buildReg("R12"), 0}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call function via closure. arg0=codeptr, arg1=closure, arg2=mem, auxint=argsize, returns mem {name: "CALLinter", argLength: 2, reg: regInfo{inputs: []regMask{ptr}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true}, // call fn by pointer. arg0=codeptr, arg1=mem, auxint=argsize, returns mem diff --git a/src/cmd/compile/internal/ssa/gen/WasmOps.go b/src/cmd/compile/internal/ssa/gen/WasmOps.go index 0d7327109a..edfba4ee99 100644 --- a/src/cmd/compile/internal/ssa/gen/WasmOps.go +++ b/src/cmd/compile/internal/ssa/gen/WasmOps.go @@ -124,7 +124,7 @@ func init() { var WasmOps = []opData{ {name: "LoweredStaticCall", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", call: true}, // call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem - {name: "LoweredTailCall", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", call: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem + {name: "LoweredTailCall", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", call: true, tailCall: true}, // tail call static function aux.(*obj.LSym). arg0=mem, auxint=argsize, returns mem {name: "LoweredClosureCall", argLength: 3, reg: regInfo{inputs: []regMask{gp, gp, 0}, clobbers: callerSave}, aux: "CallOff", call: true}, // call function via closure. arg0=codeptr, arg1=closure, arg2=mem, auxint=argsize, returns mem {name: "LoweredInterCall", argLength: 2, reg: regInfo{inputs: []regMask{gp}, clobbers: callerSave}, aux: "CallOff", call: true}, // call fn by pointer. arg0=codeptr, arg1=mem, auxint=argsize, returns mem diff --git a/src/cmd/compile/internal/ssa/gen/main.go b/src/cmd/compile/internal/ssa/gen/main.go index 8e5997b25a..2cf0a919fa 100644 --- a/src/cmd/compile/internal/ssa/gen/main.go +++ b/src/cmd/compile/internal/ssa/gen/main.go @@ -63,6 +63,7 @@ type opData struct { resultNotInArgs bool // outputs must not be allocated to the same registers as inputs clobberFlags bool // this op clobbers flags register call bool // is a function call + tailCall bool // is a tail call nilCheck bool // this op is a nil check on arg0 faultOnNilArg0 bool // this op will fault if arg0 is nil (and aux encodes a small offset) faultOnNilArg1 bool // this op will fault if arg1 is nil (and aux encodes a small offset) @@ -307,6 +308,9 @@ func genOp() { if v.call { fmt.Fprintln(w, "call: true,") } + if v.tailCall { + fmt.Fprintln(w, "tailCall: true,") + } if v.nilCheck { fmt.Fprintln(w, "nilCheck: true,") } @@ -405,6 +409,7 @@ func genOp() { fmt.Fprintln(w, "func (o Op) SymEffect() SymEffect { return opcodeTable[o].symEffect }") fmt.Fprintln(w, "func (o Op) IsCall() bool { return opcodeTable[o].call }") + fmt.Fprintln(w, "func (o Op) IsTailCall() bool { return opcodeTable[o].tailCall }") fmt.Fprintln(w, "func (o Op) HasSideEffects() bool { return opcodeTable[o].hasSideEffects }") fmt.Fprintln(w, "func (o Op) UnsafePoint() bool { return opcodeTable[o].unsafePoint }") fmt.Fprintln(w, "func (o Op) ResultInArg0() bool { return opcodeTable[o].resultInArg0 }") diff --git a/src/cmd/compile/internal/ssa/op.go b/src/cmd/compile/internal/ssa/op.go index 6f7b9fa8e9..421d856a4f 100644 --- a/src/cmd/compile/internal/ssa/op.go +++ b/src/cmd/compile/internal/ssa/op.go @@ -34,6 +34,7 @@ type opInfo struct { resultNotInArgs bool // outputs must not be allocated to the same registers as inputs clobberFlags bool // this op clobbers flags register call bool // is a function call + tailCall bool // is a tail call nilCheck bool // this op is a nil check on arg0 faultOnNilArg0 bool // this op will fault if arg0 is nil (and aux encodes a small offset) faultOnNilArg1 bool // this op will fault if arg1 is nil (and aux encodes a small offset) diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go index 091f43f40a..ed10f35fb9 100644 --- a/src/cmd/compile/internal/ssa/opGen.go +++ b/src/cmd/compile/internal/ssa/opGen.go @@ -5948,6 +5948,7 @@ var opcodeTable = [...]opInfo{ argLen: 1, clobberFlags: true, call: true, + tailCall: true, reg: regInfo{ clobbers: 65519, // AX CX DX BX BP SI DI X0 X1 X2 X3 X4 X5 X6 X7 }, @@ -13153,6 +13154,7 @@ var opcodeTable = [...]opInfo{ argLen: -1, clobberFlags: true, call: true, + tailCall: true, reg: regInfo{ clobbers: 2147483631, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 g R15 X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 }, @@ -17201,6 +17203,7 @@ var opcodeTable = [...]opInfo{ argLen: 1, clobberFlags: true, call: true, + tailCall: true, reg: regInfo{ clobbers: 4294924287, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 }, @@ -21094,6 +21097,7 @@ var opcodeTable = [...]opInfo{ argLen: -1, clobberFlags: true, call: true, + tailCall: true, reg: regInfo{ clobbers: 9223372035512336383, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, @@ -23045,6 +23049,7 @@ var opcodeTable = [...]opInfo{ argLen: 1, clobberFlags: true, call: true, + tailCall: true, reg: regInfo{ clobbers: 140737421246462, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 HI LO }, @@ -24614,6 +24619,7 @@ var opcodeTable = [...]opInfo{ argLen: 1, clobberFlags: true, call: true, + tailCall: true, reg: regInfo{ clobbers: 4611686018393833470, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 HI LO }, @@ -27464,6 +27470,7 @@ var opcodeTable = [...]opInfo{ argLen: -1, clobberFlags: true, call: true, + tailCall: true, reg: regInfo{ clobbers: 576460745860964344, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 g F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 }, @@ -28875,10 +28882,11 @@ var opcodeTable = [...]opInfo{ }, }, { - name: "CALLtail", - auxType: auxCallOff, - argLen: 1, - call: true, + name: "CALLtail", + auxType: auxCallOff, + argLen: 1, + call: true, + tailCall: true, reg: regInfo{ clobbers: 9223372035781033972, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, @@ -32644,6 +32652,7 @@ var opcodeTable = [...]opInfo{ argLen: 1, clobberFlags: true, call: true, + tailCall: true, reg: regInfo{ clobbers: 4294933503, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 g R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 }, @@ -33319,10 +33328,11 @@ var opcodeTable = [...]opInfo{ }, }, { - name: "LoweredTailCall", - auxType: auxCallOff, - argLen: 1, - call: true, + name: "LoweredTailCall", + auxType: auxCallOff, + argLen: 1, + call: true, + tailCall: true, reg: regInfo{ clobbers: 844424930131967, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 g }, @@ -36890,6 +36900,7 @@ func (o Op) Scale() int16 { return int16(opcodeTable[o].scale) } func (o Op) String() string { return opcodeTable[o].name } func (o Op) SymEffect() SymEffect { return opcodeTable[o].symEffect } func (o Op) IsCall() bool { return opcodeTable[o].call } +func (o Op) IsTailCall() bool { return opcodeTable[o].tailCall } func (o Op) HasSideEffects() bool { return opcodeTable[o].hasSideEffects } func (o Op) UnsafePoint() bool { return opcodeTable[o].unsafePoint } func (o Op) ResultInArg0() bool { return opcodeTable[o].resultInArg0 } diff --git a/src/cmd/compile/internal/ssa/regalloc.go b/src/cmd/compile/internal/ssa/regalloc.go index 431059ae69..126973a6e1 100644 --- a/src/cmd/compile/internal/ssa/regalloc.go +++ b/src/cmd/compile/internal/ssa/regalloc.go @@ -559,7 +559,8 @@ func (s *regAllocState) allocValToReg(v *Value, mask regMask, nospill bool, pos func isLeaf(f *Func) bool { for _, b := range f.Blocks { for _, v := range b.Values { - if opcodeTable[v.Op].call { + if v.Op.IsCall() && !v.Op.IsTailCall() { + // tail call is not counted as it does not save retur PC or need a frame return false } } From f47335e653ac37f68ada2b265ce4a2c869a27cae Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Sat, 5 Jun 2021 11:04:37 +0530 Subject: [PATCH 142/406] crypto/tls: add Conn.NetConn method NetConn method gives us access to the underlying net.Conn value. Fixes #29257 Change-Id: I68b2a92ed9dab4be9900807c94184f8c0aeb4f72 Reviewed-on: https://go-review.googlesource.com/c/go/+/325250 Reviewed-by: Filippo Valsorda Trust: Agniva De Sarker Trust: Katie Hockman --- src/crypto/tls/conn.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/crypto/tls/conn.go b/src/crypto/tls/conn.go index 969f357834..300e9a233c 100644 --- a/src/crypto/tls/conn.go +++ b/src/crypto/tls/conn.go @@ -151,6 +151,13 @@ func (c *Conn) SetWriteDeadline(t time.Time) error { return c.conn.SetWriteDeadline(t) } +// NetConn returns the underlying connection that is wrapped by c. +// Note that writing to or reading from this connection directly will corrupt the +// TLS session. +func (c *Conn) NetConn() net.Conn { + return c.conn +} + // A halfConn represents one direction of the record layer // connection, either sending or receiving. type halfConn struct { From 8c94aa40e6f5e61e8a570e9d20b7d0d4ad8c382d Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Fri, 22 Oct 2021 11:56:23 -0400 Subject: [PATCH 143/406] cmd/go/testdata/script: fix flaky test_fuzz_fuzztime test Previously, the test would panic if the short timeout was reached before fuzzing began. Increasing the timeout should stop this test from being flaky. Fixes #49046 Change-Id: Iaa0b3b3e8ea29d9a42ab5fc1c801fc73fffe1675 Reviewed-on: https://go-review.googlesource.com/c/go/+/358055 Trust: Katie Hockman Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/cmd/go/testdata/script/test_fuzz_fuzztime.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cmd/go/testdata/script/test_fuzz_fuzztime.txt b/src/cmd/go/testdata/script/test_fuzz_fuzztime.txt index 6264aca17d..c3933bc7e2 100644 --- a/src/cmd/go/testdata/script/test_fuzz_fuzztime.txt +++ b/src/cmd/go/testdata/script/test_fuzz_fuzztime.txt @@ -1,5 +1,3 @@ -skip # Flaky: https://golang.org/issue/49046 - # TODO(jayconrod): support shared memory on more platforms. [!darwin] [!linux] [!windows] skip @@ -9,11 +7,11 @@ skip # Flaky: https://golang.org/issue/49046 go test # Fuzzing should exit 0 after fuzztime, even if timeout is short. -go test -timeout=10ms -fuzz=FuzzFast -fuzztime=5s +go test -timeout=3s -fuzz=FuzzFast -fuzztime=5s # We should see the same behavior when invoking the test binary directly. go test -c -exec ./fuzz.test$GOEXE -test.timeout=10ms -test.fuzz=FuzzFast -test.fuzztime=5s -test.parallel=1 -test.fuzzcachedir=$WORK/cache +exec ./fuzz.test$GOEXE -test.timeout=3s -test.fuzz=FuzzFast -test.fuzztime=5s -test.parallel=1 -test.fuzzcachedir=$WORK/cache # Timeout should not cause inputs to be written as crashers. ! exists testdata/fuzz From 252324e879e32f948d885f787decf8af06f82be9 Mon Sep 17 00:00:00 2001 From: Richard Musiol Date: Sun, 24 Oct 2021 12:28:18 +0200 Subject: [PATCH 144/406] cmd/link: increase reserved space for passing env on wasm On wasm, the wasm_exec.js helper passes the command line arguments and environment variables via a reserved space in the wasm linear memory. Increase this reserved space from 4096 to 8192 bytes so more environment variables can fit into the limit. Later, after https://golang.org/cl/350737 landed, we can switch to the WASI interface for getting the arguments and environment. This would remove the limit entirely. Fixes #49011 Change-Id: I48a6e952a97d33404ed692c98e9b49c5cd6b269b Reviewed-on: https://go-review.googlesource.com/c/go/+/358194 Trust: Richard Musiol Run-TryBot: Richard Musiol TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- misc/wasm/wasm_exec.js | 4 ++-- src/cmd/link/internal/ld/data.go | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js index 30044a6f85..9ce6a20c3f 100644 --- a/misc/wasm/wasm_exec.js +++ b/misc/wasm/wasm_exec.js @@ -519,9 +519,9 @@ // The linker guarantees global data starts from at least wasmMinDataAddr. // Keep in sync with cmd/link/internal/ld/data.go:wasmMinDataAddr. - const wasmMinDataAddr = 4096 + 4096; + const wasmMinDataAddr = 4096 + 8192; if (offset >= wasmMinDataAddr) { - throw new Error("command line too long"); + throw new Error("total length of command line and environment variables exceeds limit"); } this._inst.exports.run(argc, argv); diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index 45e0e08793..0513a0d10b 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -2442,10 +2442,11 @@ func splitTextSections(ctxt *Link) bool { return (ctxt.IsPPC64() || (ctxt.IsARM64() && ctxt.IsDarwin())) && ctxt.IsExternal() } -// On Wasm, we reserve 4096 bytes for zero page, then 4096 bytes for wasm_exec.js -// to store command line args. Data sections starts from at least address 8192. +// On Wasm, we reserve 4096 bytes for zero page, then 8192 bytes for wasm_exec.js +// to store command line args and environment variables. +// Data sections starts from at least address 12288. // Keep in sync with wasm_exec.js. -const wasmMinDataAddr = 4096 + 4096 +const wasmMinDataAddr = 4096 + 8192 // address assigns virtual addresses to all segments and sections and // returns all segments in file order. From c26a32a5004afd4598f844ab49332c25d7613133 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 21 Oct 2021 18:04:55 -0700 Subject: [PATCH 145/406] cmd/compile,cmd/link: introduce generic interface call relocations To capture the fact that a method was called on a generic interface, so we can make sure the linker doesn't throw away any implementations that might be the method called. See the comment in reflect.go for details. Fixes #49049 Change-Id: I0be74b6e727c1ecefedae072b149f59d539dc1e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/357835 Trust: Keith Randall Trust: Dan Scales Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Cherry Mui Reviewed-by: Dan Scales Reviewed-by: Cuong Manh Le --- .../compile/internal/reflectdata/reflect.go | 28 ++++++- src/cmd/compile/internal/walk/expr.go | 12 +-- src/cmd/internal/objabi/reloctype.go | 5 ++ src/cmd/internal/objabi/reloctype_string.go | 79 ++++++++++--------- src/cmd/link/internal/ld/deadcode.go | 24 ++++-- test/typeparam/issue49049.go | 27 +++++++ 6 files changed, 119 insertions(+), 56 deletions(-) create mode 100644 test/typeparam/issue49049.go diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index 27e6188ab7..369ee75422 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -18,6 +18,7 @@ import ( "cmd/compile/internal/inline" "cmd/compile/internal/ir" "cmd/compile/internal/objw" + "cmd/compile/internal/staticdata" "cmd/compile/internal/typebits" "cmd/compile/internal/typecheck" "cmd/compile/internal/types" @@ -1995,8 +1996,33 @@ func MarkUsedIfaceMethod(n *ir.CallExpr) { dot := n.X.(*ir.SelectorExpr) ityp := dot.X.Type() if ityp.HasShape() { - base.Fatalf("marking method of shape type used %+v %s", ityp, dot.Sel.Name) + // Here we're calling a method on a generic interface. Something like: + // + // type I[T any] interface { foo() T } + // func f[T any](x I[T]) { + // ... = x.foo() + // } + // f[int](...) + // f[string](...) + // + // In this case, in f we're calling foo on a generic interface. + // Which method could that be? Normally we could match the method + // both by name and by type. But in this case we don't really know + // the type of the method we're calling. It could be func()int + // or func()string. So we match on just the function name, instead + // of both the name and the type used for the non-generic case below. + // TODO: instantiations at least know the shape of the instantiated + // type, and the linker could do more complicated matching using + // some sort of fuzzy shape matching. For now, only use the name + // of the method for matching. + r := obj.Addrel(ir.CurFunc.LSym) + // We use a separate symbol just to tell the linker the method name. + // (The symbol itself is not needed in the final binary.) + r.Sym = staticdata.StringSym(src.NoXPos, dot.Sel.Name) + r.Type = objabi.R_USEGENERICIFACEMETHOD + return } + tsym := TypeLinksym(ityp) r := obj.Addrel(ir.CurFunc.LSym) r.Sym = tsym diff --git a/src/cmd/compile/internal/walk/expr.go b/src/cmd/compile/internal/walk/expr.go index c452cecbed..e5bf6cf0b5 100644 --- a/src/cmd/compile/internal/walk/expr.go +++ b/src/cmd/compile/internal/walk/expr.go @@ -506,17 +506,7 @@ func walkCall(n *ir.CallExpr, init *ir.Nodes) ir.Node { usemethod(n) } if n.Op() == ir.OCALLINTER { - if n.X.(*ir.SelectorExpr).X.Type().HasShape() { - // There should be an entry in n.KeepAlive to keep the - // dictionary alive (added in ../noder/transformCall). - // The dictionary in turn marks the method as used. - if len(n.KeepAlive) == 0 { - // TODO(khr): this fails for issue44688.go. - //base.Fatalf("KeepAlive of dictionary arg missing") - } - } else { - reflectdata.MarkUsedIfaceMethod(n) - } + reflectdata.MarkUsedIfaceMethod(n) } if n.Op() == ir.OCALLFUNC && n.X.Op() == ir.OCLOSURE { diff --git a/src/cmd/internal/objabi/reloctype.go b/src/cmd/internal/objabi/reloctype.go index 0cc60fbe3b..a9c3030181 100644 --- a/src/cmd/internal/objabi/reloctype.go +++ b/src/cmd/internal/objabi/reloctype.go @@ -93,6 +93,11 @@ const ( // This is a marker relocation (0-sized), for the linker's reachabililty // analysis. R_USEIFACEMETHOD + // Similar to R_USEIFACEMETHOD, except instead of indicating a type + + // method offset with Sym+Add, Sym points to a symbol containing the name + // of the method being called. See the description in + // cmd/compile/internal/reflectdata/reflect.go:MarkUsedIfaceMethod for details. + R_USEGENERICIFACEMETHOD // R_METHODOFF resolves to a 32-bit offset from the beginning of the section // holding the data being relocated to the referenced symbol. // It is a variant of R_ADDROFF used when linking from the uncommonType of a diff --git a/src/cmd/internal/objabi/reloctype_string.go b/src/cmd/internal/objabi/reloctype_string.go index f2e06a5b21..d1b15b5a19 100644 --- a/src/cmd/internal/objabi/reloctype_string.go +++ b/src/cmd/internal/objabi/reloctype_string.go @@ -32,48 +32,49 @@ func _() { _ = x[R_USETYPE-22] _ = x[R_USEIFACE-23] _ = x[R_USEIFACEMETHOD-24] - _ = x[R_METHODOFF-25] - _ = x[R_KEEP-26] - _ = x[R_POWER_TOC-27] - _ = x[R_GOTPCREL-28] - _ = x[R_JMPMIPS-29] - _ = x[R_DWARFSECREF-30] - _ = x[R_DWARFFILEREF-31] - _ = x[R_ARM64_TLS_LE-32] - _ = x[R_ARM64_TLS_IE-33] - _ = x[R_ARM64_GOTPCREL-34] - _ = x[R_ARM64_GOT-35] - _ = x[R_ARM64_PCREL-36] - _ = x[R_ARM64_LDST8-37] - _ = x[R_ARM64_LDST16-38] - _ = x[R_ARM64_LDST32-39] - _ = x[R_ARM64_LDST64-40] - _ = x[R_ARM64_LDST128-41] - _ = x[R_POWER_TLS_LE-42] - _ = x[R_POWER_TLS_IE-43] - _ = x[R_POWER_TLS-44] - _ = x[R_ADDRPOWER_DS-45] - _ = x[R_ADDRPOWER_GOT-46] - _ = x[R_ADDRPOWER_PCREL-47] - _ = x[R_ADDRPOWER_TOCREL-48] - _ = x[R_ADDRPOWER_TOCREL_DS-49] - _ = x[R_RISCV_CALL-50] - _ = x[R_RISCV_CALL_TRAMP-51] - _ = x[R_RISCV_PCREL_ITYPE-52] - _ = x[R_RISCV_PCREL_STYPE-53] - _ = x[R_RISCV_TLS_IE_ITYPE-54] - _ = x[R_RISCV_TLS_IE_STYPE-55] - _ = x[R_PCRELDBL-56] - _ = x[R_ADDRMIPSU-57] - _ = x[R_ADDRMIPSTLS-58] - _ = x[R_ADDRCUOFF-59] - _ = x[R_WASMIMPORT-60] - _ = x[R_XCOFFREF-61] + _ = x[R_USEGENERICIFACEMETHOD-25] + _ = x[R_METHODOFF-26] + _ = x[R_KEEP-27] + _ = x[R_POWER_TOC-28] + _ = x[R_GOTPCREL-29] + _ = x[R_JMPMIPS-30] + _ = x[R_DWARFSECREF-31] + _ = x[R_DWARFFILEREF-32] + _ = x[R_ARM64_TLS_LE-33] + _ = x[R_ARM64_TLS_IE-34] + _ = x[R_ARM64_GOTPCREL-35] + _ = x[R_ARM64_GOT-36] + _ = x[R_ARM64_PCREL-37] + _ = x[R_ARM64_LDST8-38] + _ = x[R_ARM64_LDST16-39] + _ = x[R_ARM64_LDST32-40] + _ = x[R_ARM64_LDST64-41] + _ = x[R_ARM64_LDST128-42] + _ = x[R_POWER_TLS_LE-43] + _ = x[R_POWER_TLS_IE-44] + _ = x[R_POWER_TLS-45] + _ = x[R_ADDRPOWER_DS-46] + _ = x[R_ADDRPOWER_GOT-47] + _ = x[R_ADDRPOWER_PCREL-48] + _ = x[R_ADDRPOWER_TOCREL-49] + _ = x[R_ADDRPOWER_TOCREL_DS-50] + _ = x[R_RISCV_CALL-51] + _ = x[R_RISCV_CALL_TRAMP-52] + _ = x[R_RISCV_PCREL_ITYPE-53] + _ = x[R_RISCV_PCREL_STYPE-54] + _ = x[R_RISCV_TLS_IE_ITYPE-55] + _ = x[R_RISCV_TLS_IE_STYPE-56] + _ = x[R_PCRELDBL-57] + _ = x[R_ADDRMIPSU-58] + _ = x[R_ADDRMIPSTLS-59] + _ = x[R_ADDRCUOFF-60] + _ = x[R_WASMIMPORT-61] + _ = x[R_XCOFFREF-62] } -const _RelocType_name = "R_ADDRR_ADDRPOWERR_ADDRARM64R_ADDRMIPSR_ADDROFFR_SIZER_CALLR_CALLARMR_CALLARM64R_CALLINDR_CALLPOWERR_CALLMIPSR_CONSTR_PCRELR_TLS_LER_TLS_IER_GOTOFFR_PLT0R_PLT1R_PLT2R_USEFIELDR_USETYPER_USEIFACER_USEIFACEMETHODR_METHODOFFR_KEEPR_POWER_TOCR_GOTPCRELR_JMPMIPSR_DWARFSECREFR_DWARFFILEREFR_ARM64_TLS_LER_ARM64_TLS_IER_ARM64_GOTPCRELR_ARM64_GOTR_ARM64_PCRELR_ARM64_LDST8R_ARM64_LDST16R_ARM64_LDST32R_ARM64_LDST64R_ARM64_LDST128R_POWER_TLS_LER_POWER_TLS_IER_POWER_TLSR_ADDRPOWER_DSR_ADDRPOWER_GOTR_ADDRPOWER_PCRELR_ADDRPOWER_TOCRELR_ADDRPOWER_TOCREL_DSR_RISCV_CALLR_RISCV_CALL_TRAMPR_RISCV_PCREL_ITYPER_RISCV_PCREL_STYPER_RISCV_TLS_IE_ITYPER_RISCV_TLS_IE_STYPER_PCRELDBLR_ADDRMIPSUR_ADDRMIPSTLSR_ADDRCUOFFR_WASMIMPORTR_XCOFFREF" +const _RelocType_name = "R_ADDRR_ADDRPOWERR_ADDRARM64R_ADDRMIPSR_ADDROFFR_SIZER_CALLR_CALLARMR_CALLARM64R_CALLINDR_CALLPOWERR_CALLMIPSR_CONSTR_PCRELR_TLS_LER_TLS_IER_GOTOFFR_PLT0R_PLT1R_PLT2R_USEFIELDR_USETYPER_USEIFACER_USEIFACEMETHODR_USEGENERICIFACEMETHODR_METHODOFFR_KEEPR_POWER_TOCR_GOTPCRELR_JMPMIPSR_DWARFSECREFR_DWARFFILEREFR_ARM64_TLS_LER_ARM64_TLS_IER_ARM64_GOTPCRELR_ARM64_GOTR_ARM64_PCRELR_ARM64_LDST8R_ARM64_LDST16R_ARM64_LDST32R_ARM64_LDST64R_ARM64_LDST128R_POWER_TLS_LER_POWER_TLS_IER_POWER_TLSR_ADDRPOWER_DSR_ADDRPOWER_GOTR_ADDRPOWER_PCRELR_ADDRPOWER_TOCRELR_ADDRPOWER_TOCREL_DSR_RISCV_CALLR_RISCV_CALL_TRAMPR_RISCV_PCREL_ITYPER_RISCV_PCREL_STYPER_RISCV_TLS_IE_ITYPER_RISCV_TLS_IE_STYPER_PCRELDBLR_ADDRMIPSUR_ADDRMIPSTLSR_ADDRCUOFFR_WASMIMPORTR_XCOFFREF" -var _RelocType_index = [...]uint16{0, 6, 17, 28, 38, 47, 53, 59, 68, 79, 88, 99, 109, 116, 123, 131, 139, 147, 153, 159, 165, 175, 184, 194, 210, 221, 227, 238, 248, 257, 270, 284, 298, 312, 328, 339, 352, 365, 379, 393, 407, 422, 436, 450, 461, 475, 490, 507, 525, 546, 558, 576, 595, 614, 634, 654, 664, 675, 688, 699, 711, 721} +var _RelocType_index = [...]uint16{0, 6, 17, 28, 38, 47, 53, 59, 68, 79, 88, 99, 109, 116, 123, 131, 139, 147, 153, 159, 165, 175, 184, 194, 210, 233, 244, 250, 261, 271, 280, 293, 307, 321, 335, 351, 362, 375, 388, 402, 416, 430, 445, 459, 473, 484, 498, 513, 530, 548, 569, 581, 599, 618, 637, 657, 677, 687, 698, 711, 722, 734, 744} func (i RelocType) String() string { i -= 1 diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go index 79acd73387..7b57a85cde 100644 --- a/src/cmd/link/internal/ld/deadcode.go +++ b/src/cmd/link/internal/ld/deadcode.go @@ -22,10 +22,11 @@ type deadcodePass struct { ldr *loader.Loader wq heap // work queue, using min-heap for better locality - ifaceMethod map[methodsig]bool // methods declared in reached interfaces - markableMethods []methodref // methods of reached types - reflectSeen bool // whether we have seen a reflect method call - dynlink bool + ifaceMethod map[methodsig]bool // methods called from reached interface call sites + genericIfaceMethod map[string]bool // names of methods called from reached generic interface call sites + markableMethods []methodref // methods of reached types + reflectSeen bool // whether we have seen a reflect method call + dynlink bool methodsigstmp []methodsig // scratch buffer for decoding method signatures } @@ -33,6 +34,7 @@ type deadcodePass struct { func (d *deadcodePass) init() { d.ldr.InitReachable() d.ifaceMethod = make(map[methodsig]bool) + d.genericIfaceMethod = make(map[string]bool) if buildcfg.Experiment.FieldTrack { d.ldr.Reachparent = make([]loader.Sym, d.ldr.NSym()) } @@ -197,6 +199,13 @@ func (d *deadcodePass) flood() { } d.ifaceMethod[m] = true continue + case objabi.R_USEGENERICIFACEMETHOD: + name := d.decodeGenericIfaceMethod(d.ldr, r.Sym()) + if d.ctxt.Debugvlog > 1 { + d.ctxt.Logf("reached generic iface method: %s\n", name) + } + d.genericIfaceMethod[name] = true + continue // don't mark referenced symbol - it is not needed in the final binary. } rs := r.Sym() if isgotype && usedInIface && d.ldr.IsGoType(rs) && !d.ldr.AttrUsedInIface(rs) { @@ -352,7 +361,7 @@ func deadcode(ctxt *Link) { // in the last pass. rem := d.markableMethods[:0] for _, m := range d.markableMethods { - if (d.reflectSeen && m.isExported()) || d.ifaceMethod[m.m] { + if (d.reflectSeen && m.isExported()) || d.ifaceMethod[m.m] || d.genericIfaceMethod[m.m.name] { d.markMethod(m) } else { rem = append(rem, m) @@ -425,6 +434,11 @@ func (d *deadcodePass) decodeIfaceMethod(ldr *loader.Loader, arch *sys.Arch, sym return m } +// Decode the method name stored in symbol symIdx. The symbol should contain just the bytes of a method name. +func (d *deadcodePass) decodeGenericIfaceMethod(ldr *loader.Loader, symIdx loader.Sym) string { + return string(ldr.Data(symIdx)) +} + func (d *deadcodePass) decodetypeMethods(ldr *loader.Loader, arch *sys.Arch, symIdx loader.Sym, relocs *loader.Relocs) []methodsig { p := ldr.Data(symIdx) if !decodetypeHasUncommon(arch, p) { diff --git a/test/typeparam/issue49049.go b/test/typeparam/issue49049.go new file mode 100644 index 0000000000..f4fdd05d85 --- /dev/null +++ b/test/typeparam/issue49049.go @@ -0,0 +1,27 @@ +// run -gcflags=-G=3 + +// Copyright 2021 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 main + +type A[T any] interface { + m() +} + +type Z struct { + a,b int +} + +func (z *Z) m() { +} + +func test[T any]() { + var a A[T] = &Z{} + f := a.m + f() +} +func main() { + test[string]() +} From 0ae0d5c62eae1a4043d1d9cb41acc563a5e75daa Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 21 Oct 2021 19:15:24 -0700 Subject: [PATCH 146/406] cmd/compile: remove MarkUsedIfaceMethodIndex mechanism We don't need it any more, after CL 357835. Change-Id: I1ff5f24b5540c3e80c4b35be8215a1c378952274 Reviewed-on: https://go-review.googlesource.com/c/go/+/357894 Trust: Keith Randall Trust: Dan Scales Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/noder/stencil.go | 28 ++++--------------- .../compile/internal/reflectdata/reflect.go | 10 ------- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 474a05973a..fc5b0eefd4 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -1523,18 +1523,12 @@ func deref(t *types.Type) *types.Type { // needed methods. func markTypeUsed(t *types.Type, lsym *obj.LSym) { if t.IsInterface() { - // Mark all the methods of the interface as used. - // TODO: we should really only mark the interface methods - // that are actually called in the application. - for i, _ := range t.AllMethods().Slice() { - reflectdata.MarkUsedIfaceMethodIndex(lsym, t, i) - } - } else { - // TODO: This is somewhat overkill, we really only need it - // for types that are put into interfaces. - // Note: this relocation is also used in cmd/link/internal/ld/dwarf.go - reflectdata.MarkTypeUsedInInterface(t, lsym) + return } + // TODO: This is somewhat overkill, we really only need it + // for types that are put into interfaces. + // Note: this relocation is also used in cmd/link/internal/ld/dwarf.go + reflectdata.MarkTypeUsedInInterface(t, lsym) } // getDictionarySym returns the dictionary for the named generic function gf, which @@ -1735,18 +1729,6 @@ func (g *genInst) finalizeSyms() { se := n.(*ir.SelectorExpr) srctype = subst.Typ(se.X.Type()) dsttype = subst.Typ(info.shapeToBound[se.X.Type()]) - found := false - for i, m := range dsttype.AllMethods().Slice() { - if se.Sel == m.Sym { - // Mark that this method se.Sel is - // used for the dsttype interface, so - // it won't get deadcoded. - reflectdata.MarkUsedIfaceMethodIndex(lsym, dsttype, i) - found = true - break - } - } - assert(found) case ir.ODOTTYPE, ir.ODOTTYPE2: srctype = subst.Typ(n.(*ir.TypeAssertExpr).Type()) dsttype = subst.Typ(n.(*ir.TypeAssertExpr).X.Type()) diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index 369ee75422..b4ed96c18a 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -2033,16 +2033,6 @@ func MarkUsedIfaceMethod(n *ir.CallExpr) { r.Type = objabi.R_USEIFACEMETHOD } -// MarkUsedIfaceMethodIndex marks that that method number ix (in the AllMethods list) -// of interface type ityp is used, and should be attached to lsym. -func MarkUsedIfaceMethodIndex(lsym *obj.LSym, ityp *types.Type, ix int) { - tsym := TypeLinksym(ityp) - r := obj.Addrel(lsym) - r.Sym = tsym - r.Add = InterfaceMethodOffset(ityp, int64(ix)) - r.Type = objabi.R_USEIFACEMETHOD -} - // getDictionary returns the dictionary for the given named generic function // or method, with the given type arguments. func getDictionary(gf *types.Sym, targs []*types.Type) ir.Node { From 72b6a89ca5cd3c3bfd13b9b17be976e8feb91ecc Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 21 Oct 2021 18:09:07 -0700 Subject: [PATCH 147/406] cmd/compile: revert most of CL 349169 The method of using references to dictionaries to hold methods live during linker deadcode elimination wasn't working very well. I implemented a new scheme in the CL below this, so this CL strips out the old method. The new method has the added benefit of having 0 runtime overhead (unlike the stuff we're ripping out here, which does have a small overhead). Update #48047 Change-Id: I68ac57119792d53c58f1480f407de6ab2bb53211 Reviewed-on: https://go-review.googlesource.com/c/go/+/357836 Trust: Keith Randall Trust: Dan Scales Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/noder/helpers.go | 2 +- src/cmd/compile/internal/noder/stencil.go | 20 ++++++++++---------- src/cmd/compile/internal/noder/transform.go | 15 +-------------- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/cmd/compile/internal/noder/helpers.go b/src/cmd/compile/internal/noder/helpers.go index adb5a0e89f..5524673e66 100644 --- a/src/cmd/compile/internal/noder/helpers.go +++ b/src/cmd/compile/internal/noder/helpers.go @@ -183,7 +183,7 @@ func Call(pos src.XPos, typ *types.Type, fun ir.Node, args []ir.Node, dots bool) // If no type params, do the normal call transformations. This // will convert OCALL to OCALLFUNC. typed(typ, n) - transformCall(n, nil) + transformCall(n) return n } diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index fc5b0eefd4..68032e7082 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -185,7 +185,7 @@ func (g *genInst) scanForGenCalls(decl ir.Node) { // it before installing the instantiation, so we are // checking against non-shape param types in // typecheckaste. - transformCall(call, nil) + transformCall(call) // Replace the OFUNCINST with a direct reference to the // new stenciled function @@ -223,7 +223,7 @@ func (g *genInst) scanForGenCalls(decl ir.Node) { // Transform the Call now, which changes OCALL // to OCALLFUNC and does typecheckaste/assignconvfn. - transformCall(call, nil) + transformCall(call) st := g.getInstantiation(gf, targs, true).fun dictValue, usingSubdict := g.getDictOrSubdict(declInfo, n, gf, targs, true) @@ -1089,14 +1089,14 @@ func (subst *subster) node(n ir.Node) ir.Node { // transform the call. call.X.(*ir.SelectorExpr).SetOp(ir.OXDOT) transformDot(call.X.(*ir.SelectorExpr), true) - transformCall(call, subst.info.dictParam) + transformCall(call) case ir.ODOT, ir.ODOTPTR: // An OXDOT for a generic receiver was resolved to // an access to a field which has a function // value. Transform the call to that function, now // that the OXDOT was resolved. - transformCall(call, subst.info.dictParam) + transformCall(call) case ir.ONAME: name := call.X.Name() @@ -1113,24 +1113,24 @@ func (subst *subster) node(n ir.Node) ir.Node { // This is the case of a function value that was a // type parameter (implied to be a function via a // structural constraint) which is now resolved. - transformCall(call, subst.info.dictParam) + transformCall(call) } case ir.OCLOSURE: - transformCall(call, subst.info.dictParam) + transformCall(call) case ir.ODEREF, ir.OINDEX, ir.OINDEXMAP, ir.ORECV: // Transform a call that was delayed because of the // use of typeparam inside an expression that required // a pointer dereference, array indexing, map indexing, // or channel receive to compute function value. - transformCall(call, subst.info.dictParam) + transformCall(call) case ir.OCALL, ir.OCALLFUNC, ir.OCALLMETH, ir.OCALLINTER: - transformCall(call, subst.info.dictParam) + transformCall(call) case ir.OCONVNOP: - transformCall(call, subst.info.dictParam) + transformCall(call) case ir.OFUNCINST: // A call with an OFUNCINST will get transformed @@ -1276,7 +1276,7 @@ func (g *genInst) dictPass(info *instInfo) { m.(*ir.CallExpr).X.(*ir.SelectorExpr).SetOp(ir.OXDOT) transformDot(m.(*ir.CallExpr).X.(*ir.SelectorExpr), true) } - transformCall(m.(*ir.CallExpr), info.dictParam) + transformCall(m.(*ir.CallExpr)) } case ir.OCONVIFACE: diff --git a/src/cmd/compile/internal/noder/transform.go b/src/cmd/compile/internal/noder/transform.go index 29ee601d82..47e6397206 100644 --- a/src/cmd/compile/internal/noder/transform.go +++ b/src/cmd/compile/internal/noder/transform.go @@ -132,9 +132,7 @@ func transformConvCall(n *ir.CallExpr) ir.Node { // transformCall transforms a normal function/method call. Corresponds to last half // (non-conversion, non-builtin part) of typecheck.tcCall. This code should work even // in the case of OCALL/OFUNCINST. -// The dict parameter is used for OCALLINTER nodes to ensure that the called method -// is retained by the linker. -func transformCall(n *ir.CallExpr, dict *ir.Name) { +func transformCall(n *ir.CallExpr) { // n.Type() can be nil for calls with no return value assert(n.Typecheck() == 1) transformArgs(n) @@ -144,17 +142,6 @@ func transformCall(n *ir.CallExpr, dict *ir.Name) { switch l.Op() { case ir.ODOTINTER: n.SetOp(ir.OCALLINTER) - if n.X.(*ir.SelectorExpr).X.Type().HasShape() { - if dict == nil { - base.Fatalf("calls on shape interfaces need a dictionary reference") - } - dict.SetAddrtaken(true) - // KeepAlive isn't exactly the right thing here, as we only - // need to keep the dictionary live in the linker-deadcode - // sense, not the at-runtime sense. But the at-runtime sense - // is stronger, so it works. See issue 48047. - n.KeepAlive = append(n.KeepAlive, dict) - } case ir.ODOTMETH: l := l.(*ir.SelectorExpr) From f92c8f07ace7ae67b95e59bbb6ae6928dd6e4773 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 21 Oct 2021 18:28:50 -0700 Subject: [PATCH 148/406] cmd/link: escape % characters in symbols when reporting errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generic function symbols sometimes have % in them, like: main.B2[%2eshape.string_0].m2·f Which confuses this code because it doesn't esacpe % when using this string as a format string, instead of a format argument. Or could we get rid of the . -> %2e rewrite somehow? I think it comes from LinkString. Change-Id: I3275501f44cf30485e9d4577e0dfa77996d4939e Reviewed-on: https://go-review.googlesource.com/c/go/+/357837 Trust: Keith Randall Trust: Dan Scales Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/link/internal/loader/loader.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go index 9b7888e940..34c1c6a4c8 100644 --- a/src/cmd/link/internal/loader/loader.go +++ b/src/cmd/link/internal/loader/loader.go @@ -2592,7 +2592,9 @@ type ErrorReporter struct { // func (reporter *ErrorReporter) Errorf(s Sym, format string, args ...interface{}) { if s != 0 && reporter.ldr.SymName(s) != "" { - format = reporter.ldr.SymName(s) + ": " + format + // Note: Replace is needed here because symbol names might have % in them, + // due to the use of LinkString for names of instantiating types. + format = strings.Replace(reporter.ldr.SymName(s), "%", "%%", -1) + ": " + format } else { format = fmt.Sprintf("sym %d: %s", s, format) } From e35b5b25d976efb7c00b871cac452b84193e6179 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Mon, 25 Oct 2021 16:48:07 -0400 Subject: [PATCH 149/406] cmd/compile: fix typo in comment in CL 358435 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0d8128668fc7a80b29aabc58dbc9a2929b889ec9 Reviewed-on: https://go-review.googlesource.com/c/go/+/358614 Trust: Cherry Mui Trust: Daniel Martí Reviewed-by: Daniel Martí --- src/cmd/compile/internal/ssa/regalloc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/ssa/regalloc.go b/src/cmd/compile/internal/ssa/regalloc.go index 126973a6e1..91b04e99f4 100644 --- a/src/cmd/compile/internal/ssa/regalloc.go +++ b/src/cmd/compile/internal/ssa/regalloc.go @@ -560,7 +560,7 @@ func isLeaf(f *Func) bool { for _, b := range f.Blocks { for _, v := range b.Values { if v.Op.IsCall() && !v.Op.IsTailCall() { - // tail call is not counted as it does not save retur PC or need a frame + // tail call is not counted as it does not save the return PC or need a frame return false } } From 60c3069dd82eee30c00f2a8d829ba74b11bcf07e Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 22 Oct 2021 14:19:34 -0700 Subject: [PATCH 150/406] internal/poll: avoid tiny allocator for splicePipe We want to set a finalizer on splicePipe, so make it large enough to not use the tiny allocator. Otherwise the finalizer will not run until the rest of the tiny allocation can be freed. This only matters on 32-bit systems. Fixes #48968 Change-Id: I8eb3c9f48fdccab7dc79c5b918d4257b6151ee91 Reviewed-on: https://go-review.googlesource.com/c/go/+/358114 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/internal/poll/splice_linux.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/internal/poll/splice_linux.go b/src/internal/poll/splice_linux.go index 8062d98fae..6869a40b24 100644 --- a/src/internal/poll/splice_linux.go +++ b/src/internal/poll/splice_linux.go @@ -158,6 +158,10 @@ type splicePipe struct { rfd int wfd int data int + + // We want to use a finalizer, so ensure that the size is + // large enough to not use the tiny allocator. + _ [24 - 3*unsafe.Sizeof(int(0))]byte } // splicePipePool caches pipes to avoid high-frequency construction and destruction of pipe buffers. From 85b3b4ee036e7460bf7621f64c6781e5dd0eed98 Mon Sep 17 00:00:00 2001 From: fanzha02 Date: Mon, 4 Jan 2021 17:14:35 +0800 Subject: [PATCH 151/406] cmd/compile: add -asan option The -asan option causes the compiler to add instrumentation for the C/C++ address sanitizer. Every memory read/write will be replaced by a call to asanread/asanwrite. This CL also inserts asan instrumentation during SSA building. This CL passes tests but is not usable by itself. The actual implementation of asanread/asanwrite in the runtime package, and support for -asan in the go tool and tests, will follow in subsequent CLs. Updates #44853. Change-Id: Ia18c9c5d5c351857420d2f6835f0daec2ad31096 Reviewed-on: https://go-review.googlesource.com/c/go/+/298611 Trust: fannie zhang Run-TryBot: fannie zhang TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/cmd/compile/doc.go | 2 ++ src/cmd/compile/internal/base/base.go | 1 + src/cmd/compile/internal/base/flag.go | 16 ++++++++++++---- src/cmd/compile/internal/gc/main.go | 5 +++-- src/cmd/compile/internal/ir/func.go | 2 +- src/cmd/compile/internal/ir/symtab.go | 2 ++ src/cmd/compile/internal/noder/import.go | 2 ++ .../compile/internal/reflectdata/reflect.go | 3 +++ src/cmd/compile/internal/ssagen/ssa.go | 18 +++++++++++++++--- src/cmd/compile/internal/typecheck/builtin.go | 2 ++ .../internal/typecheck/builtin/runtime.go | 4 ++++ src/cmd/internal/sys/supported.go | 11 +++++++++++ 12 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/cmd/compile/doc.go b/src/cmd/compile/doc.go index b68ef274f3..ef7fa86749 100644 --- a/src/cmd/compile/doc.go +++ b/src/cmd/compile/doc.go @@ -44,6 +44,8 @@ Flags: Print compiler version and exit. -asmhdr file Write assembly header to file. + -asan + Insert calls to C/C++ address sanitizer. -buildid id Record id as the build id in the export metadata. -blockprofile file diff --git a/src/cmd/compile/internal/base/base.go b/src/cmd/compile/internal/base/base.go index 4c2516f60e..be6d49fac7 100644 --- a/src/cmd/compile/internal/base/base.go +++ b/src/cmd/compile/internal/base/base.go @@ -67,6 +67,7 @@ var NoInstrumentPkgs = []string{ "runtime", "runtime/race", "runtime/msan", + "runtime/asan", "internal/cpu", } diff --git a/src/cmd/compile/internal/base/flag.go b/src/cmd/compile/internal/base/flag.go index 241f5da185..51938e8fd5 100644 --- a/src/cmd/compile/internal/base/flag.go +++ b/src/cmd/compile/internal/base/flag.go @@ -84,6 +84,7 @@ type CmdFlags struct { // Longer names AsmHdr string "help:\"write assembly header to `file`\"" + ASan bool "help:\"build code compatible with C/C++ address sanitizer\"" Bench string "help:\"append benchmark times to `file`\"" BlockProfile string "help:\"write block profile to `file`\"" BuildID string "help:\"record `id` as the build id in the export metadata\"" @@ -177,6 +178,9 @@ func ParseFlags() { if Flag.MSan && !sys.MSanSupported(buildcfg.GOOS, buildcfg.GOARCH) { log.Fatalf("%s/%s does not support -msan", buildcfg.GOOS, buildcfg.GOARCH) } + if Flag.ASan && !sys.ASanSupported(buildcfg.GOOS, buildcfg.GOARCH) { + log.Fatalf("%s/%s does not support -asan", buildcfg.GOOS, buildcfg.GOARCH) + } if Flag.Race && !sys.RaceDetectorSupported(buildcfg.GOOS, buildcfg.GOARCH) { log.Fatalf("%s/%s does not support -race", buildcfg.GOOS, buildcfg.GOARCH) } @@ -217,12 +221,16 @@ func ParseFlags() { } Flag.LowerO = p + suffix } - - if Flag.Race && Flag.MSan { + switch { + case Flag.Race && Flag.MSan: log.Fatal("cannot use both -race and -msan") + case Flag.Race && Flag.ASan: + log.Fatal("cannot use both -race and -asan") + case Flag.MSan && Flag.ASan: + log.Fatal("cannot use both -msan and -asan") } - if Flag.Race || Flag.MSan { - // -race and -msan imply -d=checkptr for now. + if Flag.Race || Flag.MSan || Flag.ASan { + // -race, -msan and -asan imply -d=checkptr for now. if Debug.Checkptr == -1 { // if not set explicitly Debug.Checkptr = 1 } diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index 74b21571b3..ed81ef7bc0 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -107,7 +107,7 @@ func Main(archInit func(*ssagen.ArchInfo)) { // Record flags that affect the build result. (And don't // record flags that don't, since that would cause spurious // changes in the binary.) - dwarfgen.RecordFlags("B", "N", "l", "msan", "race", "shared", "dynlink", "dwarf", "dwarflocationlists", "dwarfbasentries", "smallframes", "spectre") + dwarfgen.RecordFlags("B", "N", "l", "msan", "race", "asan", "shared", "dynlink", "dwarf", "dwarflocationlists", "dwarfbasentries", "smallframes", "spectre") if !base.EnableTrace && base.Flag.LowerT { log.Fatalf("compiler not built with support for -t") @@ -149,11 +149,12 @@ func Main(archInit func(*ssagen.ArchInfo)) { if base.Compiling(base.NoInstrumentPkgs) { base.Flag.Race = false base.Flag.MSan = false + base.Flag.ASan = false } ssagen.Arch.LinkArch.Init(base.Ctxt) startProfile() - if base.Flag.Race || base.Flag.MSan { + if base.Flag.Race || base.Flag.MSan || base.Flag.ASan { base.Flag.Cfg.Instrumenting = true } if base.Flag.Dwarf { diff --git a/src/cmd/compile/internal/ir/func.go b/src/cmd/compile/internal/ir/func.go index 18d0b023ad..41c96079f7 100644 --- a/src/cmd/compile/internal/ir/func.go +++ b/src/cmd/compile/internal/ir/func.go @@ -201,7 +201,7 @@ const ( funcNilCheckDisabled // disable nil checks when compiling this function funcInlinabilityChecked // inliner has already determined whether the function is inlinable funcExportInline // include inline body in export data - funcInstrumentBody // add race/msan instrumentation during SSA construction + funcInstrumentBody // add race/msan/asan instrumentation during SSA construction funcOpenCodedDeferDisallowed // can't do open-coded defers funcClosureCalled // closure is only immediately called; used by escape analysis ) diff --git a/src/cmd/compile/internal/ir/symtab.go b/src/cmd/compile/internal/ir/symtab.go index 1435e4313e..b204a1d544 100644 --- a/src/cmd/compile/internal/ir/symtab.go +++ b/src/cmd/compile/internal/ir/symtab.go @@ -15,6 +15,8 @@ var Syms struct { AssertE2I2 *obj.LSym AssertI2I *obj.LSym AssertI2I2 *obj.LSym + Asanread *obj.LSym + Asanwrite *obj.LSym CheckPtrAlignment *obj.LSym Deferproc *obj.LSym DeferprocStack *obj.LSym diff --git a/src/cmd/compile/internal/noder/import.go b/src/cmd/compile/internal/noder/import.go index 0aaf894641..58dffbad1e 100644 --- a/src/cmd/compile/internal/noder/import.go +++ b/src/cmd/compile/internal/noder/import.go @@ -127,6 +127,8 @@ func openPackage(path string) (*os.File, error) { suffix = "_race" } else if base.Flag.MSan { suffix = "_msan" + } else if base.Flag.ASan { + suffix = "_asan" } if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.a", buildcfg.GOROOT, buildcfg.GOOS, buildcfg.GOARCH, suffix, path)); err == nil { diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index b4ed96c18a..ce41b8c934 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -1413,6 +1413,9 @@ func WriteBasicTypes() { if base.Flag.MSan { dimportpath(types.NewPkg("runtime/msan", "")) } + if base.Flag.ASan { + dimportpath(types.NewPkg("runtime/asan", "")) + } dimportpath(types.NewPkg("main", "")) } diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go index 5a958a569d..6b595ea75d 100644 --- a/src/cmd/compile/internal/ssagen/ssa.go +++ b/src/cmd/compile/internal/ssagen/ssa.go @@ -108,6 +108,8 @@ func InitConfig() { ir.Syms.Msanread = typecheck.LookupRuntimeFunc("msanread") ir.Syms.Msanwrite = typecheck.LookupRuntimeFunc("msanwrite") ir.Syms.Msanmove = typecheck.LookupRuntimeFunc("msanmove") + ir.Syms.Asanread = typecheck.LookupRuntimeFunc("asanread") + ir.Syms.Asanwrite = typecheck.LookupRuntimeFunc("asanwrite") ir.Syms.Newobject = typecheck.LookupRuntimeFunc("newobject") ir.Syms.Newproc = typecheck.LookupRuntimeFunc("newproc") ir.Syms.Panicdivide = typecheck.LookupRuntimeFunc("panicdivide") @@ -1245,10 +1247,10 @@ func (s *state) instrument(t *types.Type, addr *ssa.Value, kind instrumentKind) } // instrumentFields instruments a read/write operation on addr. -// If it is instrumenting for MSAN and t is a struct type, it instruments +// If it is instrumenting for MSAN or ASAN and t is a struct type, it instruments // operation for each field, instead of for the whole struct. func (s *state) instrumentFields(t *types.Type, addr *ssa.Value, kind instrumentKind) { - if !base.Flag.MSan || !t.IsStruct() { + if !(base.Flag.MSan || base.Flag.ASan) || !t.IsStruct() { s.instrument(t, addr, kind) return } @@ -1327,6 +1329,16 @@ func (s *state) instrument2(t *types.Type, addr, addr2 *ssa.Value, kind instrume default: panic("unreachable") } + } else if base.Flag.ASan { + switch kind { + case instrumentRead: + fn = ir.Syms.Asanread + case instrumentWrite: + fn = ir.Syms.Asanwrite + default: + panic("unreachable") + } + needWidth = true } else { panic("unreachable") } @@ -3002,7 +3014,7 @@ func (s *state) exprCheckPtr(n ir.Node, checkPtrOK bool) *ssa.Value { } // If n is addressable and can't be represented in // SSA, then load just the selected field. This - // prevents false memory dependencies in race/msan + // prevents false memory dependencies in race/msan/asan // instrumentation. if ir.IsAddressable(n) && !s.canSSA(n) { p := s.addr(n) diff --git a/src/cmd/compile/internal/typecheck/builtin.go b/src/cmd/compile/internal/typecheck/builtin.go index 524360e8df..67597cebb4 100644 --- a/src/cmd/compile/internal/typecheck/builtin.go +++ b/src/cmd/compile/internal/typecheck/builtin.go @@ -192,6 +192,8 @@ var runtimeDecls = [...]struct { {"msanread", funcTag, 140}, {"msanwrite", funcTag, 140}, {"msanmove", funcTag, 141}, + {"asanread", funcTag, 140}, + {"asanwrite", funcTag, 140}, {"checkptrAlignment", funcTag, 142}, {"checkptrArithmetic", funcTag, 144}, {"libfuzzerTraceCmp1", funcTag, 145}, diff --git a/src/cmd/compile/internal/typecheck/builtin/runtime.go b/src/cmd/compile/internal/typecheck/builtin/runtime.go index 66641fb5aa..04ae4f23a3 100644 --- a/src/cmd/compile/internal/typecheck/builtin/runtime.go +++ b/src/cmd/compile/internal/typecheck/builtin/runtime.go @@ -250,6 +250,10 @@ func msanread(addr, size uintptr) func msanwrite(addr, size uintptr) func msanmove(dst, src, size uintptr) +// address sanitizer +func asanread(addr, size uintptr) +func asanwrite(addr, size uintptr) + func checkptrAlignment(unsafe.Pointer, *byte, uintptr) func checkptrArithmetic(unsafe.Pointer, []unsafe.Pointer) diff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go index 0d2bad9612..e6c56fbc56 100644 --- a/src/cmd/internal/sys/supported.go +++ b/src/cmd/internal/sys/supported.go @@ -34,6 +34,17 @@ func MSanSupported(goos, goarch string) bool { } } +// ASanSupported reports whether goos/goarch supports the address +// sanitizer option. +func ASanSupported(goos, goarch string) bool { + switch goos { + case "linux": + return goarch == "arm64" || goarch == "amd64" + default: + return false + } +} + // MustLinkExternal reports whether goos/goarch requires external linking. // (This is the opposite of internal/testenv.CanInternalLink. Keep them in sync.) func MustLinkExternal(goos, goarch string) bool { From fd2f4b58b34effdbdacba41e0c36fa701c6dfa27 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Tue, 19 Oct 2021 13:28:54 -0700 Subject: [PATCH 152/406] cmd/compile: update the export version for generics Bump the export version to a new value iexportVersionGo1_18 (2). This will give a better error message when old compilers/tools encounter the new export format (that includes parameterized types and functions). We are also making a breaking change in the format: - a 'kind' byte is added to constant values Also updated tinter() to pass the implicit bit through during type substitution. Tested that all tests still pass if the iexportVersionCurrent is changed back to 1 in typecheck/iexport.go, iimporter/iimport.go, and gcimporter/iimport.go Updates #47654 Change-Id: I1dbeb167a97f6c7e0b7e0c011d6bada5db312b36 Reviewed-on: https://go-review.googlesource.com/c/go/+/357049 Run-TryBot: Dan Scales TryBot-Result: Go Bot Reviewed-by: Robert Findley Trust: Dan Scales --- src/cmd/compile/internal/importer/iimport.go | 36 ++++++++++++------ src/cmd/compile/internal/typecheck/iexport.go | 38 ++++++++++++------- src/cmd/compile/internal/typecheck/iimport.go | 32 ++++++++++------ src/cmd/compile/internal/typecheck/subr.go | 2 +- src/cmd/compile/internal/types/type.go | 6 +++ src/go/internal/gcimporter/iimport.go | 36 ++++++++++++------ 6 files changed, 101 insertions(+), 49 deletions(-) diff --git a/src/cmd/compile/internal/importer/iimport.go b/src/cmd/compile/internal/importer/iimport.go index cbc78539fd..d04ef5c34d 100644 --- a/src/cmd/compile/internal/importer/iimport.go +++ b/src/cmd/compile/internal/importer/iimport.go @@ -43,12 +43,12 @@ func (r *intReader) uint64() uint64 { // Keep this in sync with constants in iexport.go. const ( - iexportVersionGo1_11 = 0 - iexportVersionPosCol = 1 - // TODO: before release, change this back to 2. - iexportVersionGenerics = iexportVersionPosCol + iexportVersionGo1_11 = 0 + iexportVersionPosCol = 1 + iexportVersionGenerics = 1 // probably change to 2 before release + iexportVersionGo1_18 = 2 - iexportVersionCurrent = iexportVersionGenerics + iexportVersionCurrent = 2 ) type ident struct { @@ -99,13 +99,9 @@ func ImportData(imports map[string]*types2.Package, data, path string) (pkg *typ version = int64(r.uint64()) switch version { - case /* iexportVersionGenerics, */ iexportVersionPosCol, iexportVersionGo1_11: + case iexportVersionGo1_18, iexportVersionPosCol, iexportVersionGo1_11: default: - if version > iexportVersionGenerics { - errorf("unstable iexport format version %d, just rebuild compiler and std library", version) - } else { - errorf("unknown iexport format version %d", version) - } + errorf("unknown iexport format version %d", version) } sLen := int64(r.uint64()) @@ -374,7 +370,19 @@ func (r *importReader) obj(name string) { id := ident{r.currPkg.Name(), name} r.p.tparamIndex[id] = t - t.SetConstraint(r.typ()) + var implicit bool + if r.p.exportVersion >= iexportVersionGo1_18 { + implicit = r.bool() + } + constraint := r.typ() + if implicit { + iface, _ := constraint.(*types2.Interface) + if iface == nil { + errorf("non-interface constraint marked implicit") + } + iface.MarkImplicit() + } + t.SetConstraint(constraint) case 'V': typ := r.typ() @@ -392,6 +400,10 @@ func (r *importReader) declare(obj types2.Object) { func (r *importReader) value() (typ types2.Type, val constant.Value) { typ = r.typ() + if r.p.exportVersion >= iexportVersionGo1_18 { + // TODO: add support for using the kind + _ = constant.Kind(r.int64()) + } switch b := typ.Underlying().(*types2.Basic); b.Info() & types2.IsConstType { case types2.IsBoolean: diff --git a/src/cmd/compile/internal/typecheck/iexport.go b/src/cmd/compile/internal/typecheck/iexport.go index 46865ba3fa..6057000a5d 100644 --- a/src/cmd/compile/internal/typecheck/iexport.go +++ b/src/cmd/compile/internal/typecheck/iexport.go @@ -254,15 +254,16 @@ import ( // Current indexed export format version. Increase with each format change. // 0: Go1.11 encoding // 1: added column details to Pos -// 2: added information for generic function/types (currently unstable) +// 2: added information for generic function/types. The export of non-generic +// functions/types remains largely backward-compatible. Breaking changes include: +// - a 'kind' byte is added to constant values const ( - iexportVersionGo1_11 = 0 - iexportVersionPosCol = 1 - // TODO: before release, change this back to 2. Kept at previous version - // for now (for testing). - iexportVersionGenerics = iexportVersionPosCol + iexportVersionGo1_11 = 0 + iexportVersionPosCol = 1 + iexportVersionGenerics = 1 // probably change to 2 before release + iexportVersionGo1_18 = 2 - iexportVersionCurrent = iexportVersionGenerics + iexportVersionCurrent = 2 ) // predeclReserved is the number of type offsets reserved for types @@ -561,6 +562,10 @@ func (p *iexporter) doDecl(n *ir.Name) { // A typeparam has a name, and has a type bound rather // than an underlying type. w.pos(n.Pos()) + if iexportVersionCurrent >= iexportVersionGo1_18 { + implicit := n.Type().Bound().IsImplicit() + w.bool(implicit) + } w.typ(n.Type().Bound()) break } @@ -1137,17 +1142,24 @@ func constTypeOf(typ *types.Type) constant.Kind { func (w *exportWriter) value(typ *types.Type, v constant.Value) { w.typ(typ) + + if iexportVersionCurrent >= iexportVersionGo1_18 { + w.int64(int64(v.Kind())) + } + var kind constant.Kind var valType *types.Type if typ.IsTypeParam() { - // A constant will have a TYPEPARAM type if it appears in a place - // where it must match that typeparam type (e.g. in a binary - // operation with a variable of that typeparam type). If so, then - // we must write out its actual constant kind as well, so its - // constant val can be read in properly during import. kind = v.Kind() - w.int64(int64(kind)) + if iexportVersionCurrent < iexportVersionGo1_18 { + // A constant will have a TYPEPARAM type if it appears in a place + // where it must match that typeparam type (e.g. in a binary + // operation with a variable of that typeparam type). If so, then + // we must write out its actual constant kind as well, so its + // constant val can be read in properly during import. + w.int64(int64(kind)) + } switch kind { case constant.Int: diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index fcfadc146c..7c6c23e737 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -118,13 +118,9 @@ func ReadImports(pkg *types.Pkg, data string) { version := ird.uint64() switch version { - case /* iexportVersionGenerics, */ iexportVersionPosCol, iexportVersionGo1_11: + case iexportVersionGo1_18, iexportVersionPosCol, iexportVersionGo1_11: default: - if version > iexportVersionGenerics { - base.Errorf("import %q: unstable export format version %d, just recompile", pkg.Path, version) - } else { - base.Errorf("import %q: unknown export format version %d", pkg.Path, version) - } + base.Errorf("import %q: unknown export format version %d", pkg.Path, version) base.ErrorExit() } @@ -408,8 +404,15 @@ func (r *importReader) doDecl(sym *types.Sym) *ir.Name { sym.Def = nname nname.SetType(t) t.SetNod(nname) - - t.SetBound(r.typ()) + implicit := false + if r.p.exportVersion >= iexportVersionGo1_18 { + implicit = r.bool() + } + bound := r.typ() + if implicit { + bound.MarkImplicit() + } + t.SetBound(bound) return nname case 'V': @@ -429,10 +432,17 @@ func (r *importReader) value(typ *types.Type) constant.Value { var kind constant.Kind var valType *types.Type - if typ.IsTypeParam() { - // If a constant had a typeparam type, then we wrote out its - // actual constant kind as well. + if r.p.exportVersion >= iexportVersionGo1_18 { + // TODO: add support for using the kind in the non-typeparam case. kind = constant.Kind(r.int64()) + } + + if typ.IsTypeParam() { + if r.p.exportVersion < iexportVersionGo1_18 { + // If a constant had a typeparam type, then we wrote out its + // actual constant kind as well. + kind = constant.Kind(r.int64()) + } switch kind { case constant.Int: valType = types.Types[types.TINT64] diff --git a/src/cmd/compile/internal/typecheck/subr.go b/src/cmd/compile/internal/typecheck/subr.go index 9ebd8f1423..96e120fe03 100644 --- a/src/cmd/compile/internal/typecheck/subr.go +++ b/src/cmd/compile/internal/typecheck/subr.go @@ -1390,7 +1390,7 @@ func (ts *Tsubster) tinter(t *types.Type, force bool) *types.Type { } } if newfields != nil { - return types.NewInterface(t.Pkg(), newfields, false) + return types.NewInterface(t.Pkg(), newfields, t.IsImplicit()) } return t } diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go index ec17fe8704..c3efbc9f07 100644 --- a/src/cmd/compile/internal/types/type.go +++ b/src/cmd/compile/internal/types/type.go @@ -1884,6 +1884,12 @@ func (t *Type) IsImplicit() bool { return t.extra.(*Interface).implicit } +// MarkImplicit marks the interface as implicit. +func (t *Type) MarkImplicit() { + t.wantEtype(TINTER) + t.extra.(*Interface).implicit = true +} + // NewUnion returns a new union with the specified set of terms (types). If // tildes[i] is true, then terms[i] represents ~T, rather than just T. func NewUnion(terms []*Type, tildes []bool) *Type { diff --git a/src/go/internal/gcimporter/iimport.go b/src/go/internal/gcimporter/iimport.go index 0771fa3c26..49ea64392a 100644 --- a/src/go/internal/gcimporter/iimport.go +++ b/src/go/internal/gcimporter/iimport.go @@ -44,12 +44,12 @@ func (r *intReader) uint64() uint64 { // Keep this in sync with constants in iexport.go. const ( - iexportVersionGo1_11 = 0 - iexportVersionPosCol = 1 - // TODO: before release, change this back to 2. - iexportVersionGenerics = iexportVersionPosCol + iexportVersionGo1_11 = 0 + iexportVersionPosCol = 1 + iexportVersionGenerics = 1 // probably change to 2 before release + iexportVersionGo1_18 = 2 - iexportVersionCurrent = iexportVersionGenerics + iexportVersionCurrent = 2 ) type ident struct { @@ -98,13 +98,9 @@ func iImportData(fset *token.FileSet, imports map[string]*types.Package, dataRea version = int64(r.uint64()) switch version { - case /* iexportVersionGenerics, */ iexportVersionPosCol, iexportVersionGo1_11: + case iexportVersionGo1_18, iexportVersionPosCol, iexportVersionGo1_11: default: - if version > iexportVersionGenerics { - errorf("unstable iexport format version %d, just rebuild compiler and std library", version) - } else { - errorf("unknown iexport format version %d", version) - } + errorf("unknown iexport format version %d", version) } sLen := int64(r.uint64()) @@ -367,7 +363,19 @@ func (r *importReader) obj(name string) { id := ident{r.currPkg.Name(), name} r.p.tparamIndex[id] = t - t.SetConstraint(r.typ()) + var implicit bool + if r.p.exportVersion >= iexportVersionGo1_18 { + implicit = r.bool() + } + constraint := r.typ() + if implicit { + iface, _ := constraint.(*types.Interface) + if iface == nil { + errorf("non-interface constraint marked implicit") + } + iface.MarkImplicit() + } + t.SetConstraint(constraint) case 'V': typ := r.typ() @@ -385,6 +393,10 @@ func (r *importReader) declare(obj types.Object) { func (r *importReader) value() (typ types.Type, val constant.Value) { typ = r.typ() + if r.p.exportVersion >= iexportVersionGo1_18 { + // TODO: add support for using the kind + _ = constant.Kind(r.int64()) + } switch b := typ.Underlying().(*types.Basic); b.Info() & types.IsConstType { case types.IsBoolean: From e9eb66da307ec2da922a05b890b13363ea4e830e Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Mon, 25 Oct 2021 12:18:40 -0400 Subject: [PATCH 153/406] cmd/internal/obj/riscv: don't split ADD to SP to two adds When adding a large constant to a register we generate two adds, we may generate two ADD instructions if the constant does not fit in one ADD but does fit in two. This is generally fine except that if the target register is SP (such as in function prologues or epilogues for functions with large frames), this creates an intermediate state that the SP is not 0 nor the full frame size. For signal safety (preemption signal and profiling signal) we require that the frame is either not created at all or fully created, meaning that the SP must be written in a single instruction. Splitting to two adds breaks the requirement. So not splitting it. (We could mark such instructions not async-preemptible. But profiling signal can still cause problems.) (We could generate "ADD $c1, SP, Rtmp; ADD $c2; Rtmp; SP" to save an instruction if that is desired, while still ensuring that SP is written in a single instruction.) May fix flaky failures like https://build.golang.org/log/11537ec020a902b0ec0fc065f61161b729eb9880 Change-Id: I5cf38a6a028afe01aa3b6eeb163487bbd504b64f Reviewed-on: https://go-review.googlesource.com/c/go/+/358436 Trust: Cherry Mui Run-TryBot: Cherry Mui Reviewed-by: Joel Sing TryBot-Result: Go Bot --- src/cmd/internal/obj/riscv/obj.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go index d98806edb5..c27ad99b2d 100644 --- a/src/cmd/internal/obj/riscv/obj.go +++ b/src/cmd/internal/obj/riscv/obj.go @@ -1610,7 +1610,8 @@ func instructionsForOpImmediate(p *obj.Prog, as obj.As, rs int16) []*instruction } // Split into two additions, if possible. - if ins.as == AADDI && ins.imm >= -(1<<12) && ins.imm < 1<<12-1 { + // Do not split SP-writing instructions, as otherwise the recorded SP delta may be wrong. + if p.Spadj == 0 && ins.as == AADDI && ins.imm >= -(1<<12) && ins.imm < 1<<12-1 { imm0 := ins.imm / 2 imm1 := ins.imm - imm0 From b36b001ff13768fd1f9664b34c6d2b7948f66d4d Mon Sep 17 00:00:00 2001 From: Gusted Date: Tue, 26 Oct 2021 01:45:44 +0200 Subject: [PATCH 154/406] container/list: remove unnecessary code Remove a unnecessary statement in the test function, the variables aren't checked afterwards. Also remove return statements in helper functions and remove the declaration that a the helper function return a value. The return value isn't used in the current state of code Change-Id: I5bc384104c1002c4138e0894938778ae9710ce4d Reviewed-on: https://go-review.googlesource.com/c/go/+/358714 Run-TryBot: Robert Griesemer TryBot-Result: Go Bot Reviewed-by: Robert Griesemer Trust: Ian Lance Taylor --- src/container/list/list.go | 13 +++++-------- src/container/list/list_test.go | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/container/list/list.go b/src/container/list/list.go index 210424ceed..aa89b7f599 100644 --- a/src/container/list/list.go +++ b/src/container/list/list.go @@ -104,21 +104,20 @@ func (l *List) insertValue(v interface{}, at *Element) *Element { return l.insert(&Element{Value: v}, at) } -// remove removes e from its list, decrements l.len, and returns e. -func (l *List) remove(e *Element) *Element { +// remove removes e from its list, decrements l.len +func (l *List) remove(e *Element) { e.prev.next = e.next e.next.prev = e.prev e.next = nil // avoid memory leaks e.prev = nil // avoid memory leaks e.list = nil l.len-- - return e } -// move moves e to next to at and returns e. -func (l *List) move(e, at *Element) *Element { +// move moves e to next to at. +func (l *List) move(e, at *Element) { if e == at { - return e + return } e.prev.next = e.next e.next.prev = e.prev @@ -127,8 +126,6 @@ func (l *List) move(e, at *Element) *Element { e.next = at.next e.prev.next = e e.next.prev = e - - return e } // Remove removes e from l if e is an element of list l. diff --git a/src/container/list/list_test.go b/src/container/list/list_test.go index 99e006f39f..c74724b398 100644 --- a/src/container/list/list_test.go +++ b/src/container/list/list_test.go @@ -283,7 +283,6 @@ func TestMove(t *testing.T) { l.MoveAfter(e2, e3) checkListPointers(t, l, []*Element{e1, e3, e2, e4}) - e2, e3 = e3, e2 } // Test PushFront, PushBack, PushFrontList, PushBackList with uninitialized List From 0ec1b62ee28c633265036664c21a5cb22086f231 Mon Sep 17 00:00:00 2001 From: gosoon Date: Wed, 20 Oct 2021 11:13:29 +0000 Subject: [PATCH 155/406] doc/go1.18.html: fix a typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gofmt -> gofmt Change-Id: Idc01b01d8eb185f5e378000d11d622935b14db6e GitHub-Last-Rev: 8d55dc7b86ce0f7dfbdbd57c349b4c472eccf907 GitHub-Pull-Request: golang/go#49084 Reviewed-on: https://go-review.googlesource.com/c/go/+/357251 Reviewed-by: Daniel Martí Reviewed-by: Ian Lance Taylor Trust: Daniel Martí --- doc/go1.18.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/go1.18.html b/doc/go1.18.html index 087a06c280..985689cf31 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -98,7 +98,7 @@ Do not send CLs removing the interior tags from such phrases.

gofmt now reads and formats input files concurrently, with a memory limit proportional to GOMAXPROCS. On a machine with - multiple CPUs, gofmt should now be significantly faster. + multiple CPUs, gofmt should now be significantly faster.

From 41f74079a982dae05da1860a5f195ac08d067bdd Mon Sep 17 00:00:00 2001 From: fanzha02 Date: Wed, 17 Mar 2021 14:52:27 +0800 Subject: [PATCH 156/406] cmd/internal/obj/arm64: add a restriction on move constant instructions For MOVK/MOVN/MOVZ instructions, the assembler does not accept zero shifts, and the CL 275812 added the error check. This CL adds this restriction to the document. Change-Id: I8818d76ca2f11dade2307f3678ca521f4e64d164 Reviewed-on: https://go-review.googlesource.com/c/go/+/312210 Trust: fannie zhang Run-TryBot: fannie zhang TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- src/cmd/internal/obj/arm64/doc.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cmd/internal/obj/arm64/doc.go b/src/cmd/internal/obj/arm64/doc.go index efd4577f56..14f0f4c616 100644 --- a/src/cmd/internal/obj/arm64/doc.go +++ b/src/cmd/internal/obj/arm64/doc.go @@ -96,6 +96,19 @@ And for a 128-bit interger, it take two 64-bit operands, for the high and low pa VMOVD $0x1122334455667788, V1 VMOVQ $0x1122334455667788, $8877665544332211, V2 // V2=0x11223344556677888877665544332211 +8. Move an optionally-shifted 16-bit immediate value to a register. + +The instructions are MOVK(W), MOVZ(W) and MOVN(W), the assembly syntax is "op $(uimm16<". The +is the 16-bit unsigned immediate, in the range 0 to 65535; For the 32-bit variant, the is 0 or 16, for the +64-bit variant, the is 0, 16, 32 or 48. + +The current Go assembler does not accept zero shifts, such as "op $0, Rd" and "op $(0<<(16|32|48)), Rd" instructions. + + Examples: + MOVK $(10<<32), R20 <=> movk x20, #10, lsl #32 + MOVZW $(20<<16), R8 <=> movz w8, #20, lsl #16 + MOVK $(0<<16), R10 will be reported as an error by the assembler. + Special Cases. (1) umov is written as VMOV. From 49fda9e4f5cd3a05fd5fa0b3a2047a9d24873bd6 Mon Sep 17 00:00:00 2001 From: Fannie Zhang Date: Wed, 6 Jan 2021 08:57:44 +0000 Subject: [PATCH 157/406] cmd/go: add -asan option The -asan option compiles Go code to use the address sanitizer. This is intended for use when linking with C/C++ code compiled with -fsanitize=address. When memory blocks are passed back and forth between C/C++ and Go, code in both languages will agree as to whether the memory is validly allocated or not, and will report errors for any use of invalid memory. Updates #44853. Change-Id: I0209002ef795cc1c823daae557fb80c906158db3 Reviewed-on: https://go-review.googlesource.com/c/go/+/298612 Trust: fannie zhang Reviewed-by: Bryan C. Mills --- src/cmd/go/alldocs.go | 7 +++-- src/cmd/go/go_test.go | 2 ++ src/cmd/go/internal/cfg/cfg.go | 1 + src/cmd/go/internal/load/pkg.go | 5 ++++ src/cmd/go/internal/work/build.go | 8 +++-- src/cmd/go/internal/work/exec.go | 6 +++- src/cmd/go/internal/work/init.go | 30 ++++++++++++++----- src/cmd/go/script_test.go | 2 ++ src/cmd/go/testdata/script/README | 2 +- src/cmd/go/testdata/script/goflags.txt | 2 +- .../install_msan_and_race_require_cgo.txt | 6 ++-- 11 files changed, 55 insertions(+), 16 deletions(-) diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index d04ba04a53..8178073103 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -121,6 +121,9 @@ // Supported only on linux/amd64, linux/arm64 // and only with Clang/LLVM as the host C compiler. // On linux/arm64, pie build mode will be used. +// -asan +// enable interoperation with address sanitizer. +// Supported only on linux/arm64, linux/amd64. // -v // print the names of packages as they are compiled. // -work @@ -155,8 +158,8 @@ // in order to keep output separate from default builds. // If using the -race flag, the install suffix is automatically set to race // or, if set explicitly, has _race appended to it. Likewise for the -msan -// flag. Using a -buildmode option that requires non-default compile flags -// has a similar effect. +// and -asan flags. Using a -buildmode option that requires non-default compile +// flags has a similar effect. // -ldflags '[pattern=]arg list' // arguments to pass on each go tool link invocation. // -linkshared diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index d67d01aa1e..339014e94e 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -46,6 +46,7 @@ var ( canRace = false // whether we can run the race detector canCgo = false // whether we can use cgo canMSan = false // whether we can run the memory sanitizer + canASan = false // whether we can run the address sanitizer ) var exeSuffix string = func() string { @@ -197,6 +198,7 @@ func TestMain(m *testing.M) { testGOCACHE = strings.TrimSpace(string(out)) canMSan = canCgo && sys.MSanSupported(runtime.GOOS, runtime.GOARCH) + canASan = canCgo && sys.ASanSupported(runtime.GOOS, runtime.GOARCH) canRace = canCgo && sys.RaceDetectorSupported(runtime.GOOS, runtime.GOARCH) // The race detector doesn't work on Alpine Linux: // golang.org/issue/14481 diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go index 37e9b2666e..351c3ee6a5 100644 --- a/src/cmd/go/internal/cfg/cfg.go +++ b/src/cmd/go/internal/cfg/cfg.go @@ -35,6 +35,7 @@ var ( BuildI bool // -i flag BuildLinkshared bool // -linkshared flag BuildMSan bool // -msan flag + BuildASan bool // -asan flag BuildN bool // -n flag BuildO string // -o flag BuildP = runtime.GOMAXPROCS(0) // -p flag diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 99c4a9c62e..a5be48a49b 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -1625,6 +1625,7 @@ var cgoSyscallExclude = map[string]bool{ "runtime/cgo": true, "runtime/race": true, "runtime/msan": true, + "runtime/asan": true, } var foldPath = make(map[string]string) @@ -2415,6 +2416,10 @@ func LinkerDeps(p *Package) []string { if cfg.BuildMSan { deps = append(deps, "runtime/msan") } + // Using address sanitizer forces an import of runtime/asan. + if cfg.BuildASan { + deps = append(deps, "runtime/asan") + } return deps } diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index e10f647a6d..ffe33bfa4d 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -75,6 +75,9 @@ and test commands: Supported only on linux/amd64, linux/arm64 and only with Clang/LLVM as the host C compiler. On linux/arm64, pie build mode will be used. + -asan + enable interoperation with address sanitizer. + Supported only on linux/arm64, linux/amd64. -v print the names of packages as they are compiled. -work @@ -109,8 +112,8 @@ and test commands: in order to keep output separate from default builds. If using the -race flag, the install suffix is automatically set to race or, if set explicitly, has _race appended to it. Likewise for the -msan - flag. Using a -buildmode option that requires non-default compile flags - has a similar effect. + and -asan flags. Using a -buildmode option that requires non-default compile + flags has a similar effect. -ldflags '[pattern=]arg list' arguments to pass on each go tool link invocation. -linkshared @@ -309,6 +312,7 @@ func AddBuildFlags(cmd *base.Command, mask BuildFlagMask) { cmd.Flag.StringVar(&cfg.BuildPkgdir, "pkgdir", "", "") cmd.Flag.BoolVar(&cfg.BuildRace, "race", false, "") cmd.Flag.BoolVar(&cfg.BuildMSan, "msan", false, "") + cmd.Flag.BoolVar(&cfg.BuildASan, "asan", false, "") cmd.Flag.Var((*tagsFlag)(&cfg.BuildContext.BuildTags), "tags", "") cmd.Flag.Var((*base.StringsFlag)(&cfg.BuildToolexec), "toolexec", "") cmd.Flag.BoolVar(&cfg.BuildTrimpath, "trimpath", false, "") diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index d4e24d4cd1..62d8143828 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -2736,6 +2736,10 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo cgoCFLAGS = append([]string{"-fsanitize=memory"}, cgoCFLAGS...) cgoLDFLAGS = append([]string{"-fsanitize=memory"}, cgoLDFLAGS...) } + if cfg.BuildASan { + cgoCFLAGS = append([]string{"-fsanitize=address"}, cgoCFLAGS...) + cgoLDFLAGS = append([]string{"-fsanitize=address"}, cgoLDFLAGS...) + } // Allows including _cgo_export.h, as well as the user's .h files, // from .[ch] files in the package. @@ -2757,7 +2761,7 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo if p.Standard && p.ImportPath == "runtime/cgo" { cgoflags = append(cgoflags, "-import_runtime_cgo=false") } - if p.Standard && (p.ImportPath == "runtime/race" || p.ImportPath == "runtime/msan" || p.ImportPath == "runtime/cgo") { + if p.Standard && (p.ImportPath == "runtime/race" || p.ImportPath == "runtime/msan" || p.ImportPath == "runtime/cgo" || p.ImportPath == "runtime/asan") { cgoflags = append(cgoflags, "-import_syscall=false") } diff --git a/src/cmd/go/internal/work/init.go b/src/cmd/go/internal/work/init.go index 6a29abb03b..56e39f8c52 100644 --- a/src/cmd/go/internal/work/init.go +++ b/src/cmd/go/internal/work/init.go @@ -87,7 +87,7 @@ func fuzzInstrumentFlags() []string { } func instrumentInit() { - if !cfg.BuildRace && !cfg.BuildMSan { + if !cfg.BuildRace && !cfg.BuildMSan && !cfg.BuildASan { return } if cfg.BuildRace && cfg.BuildMSan { @@ -95,17 +95,30 @@ func instrumentInit() { base.SetExitStatus(2) base.Exit() } + if cfg.BuildRace && cfg.BuildASan { + fmt.Fprintf(os.Stderr, "go: may not use -race and -asan simultaneously\n") + base.SetExitStatus(2) + base.Exit() + } + if cfg.BuildMSan && cfg.BuildASan { + fmt.Fprintf(os.Stderr, "go: may not use -msan and -asan simultaneously\n") + base.SetExitStatus(2) + base.Exit() + } if cfg.BuildMSan && !sys.MSanSupported(cfg.Goos, cfg.Goarch) { fmt.Fprintf(os.Stderr, "-msan is not supported on %s/%s\n", cfg.Goos, cfg.Goarch) base.SetExitStatus(2) base.Exit() } - if cfg.BuildRace { - if !sys.RaceDetectorSupported(cfg.Goos, cfg.Goarch) { - fmt.Fprintf(os.Stderr, "go: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64, darwin/arm64, and windows/amd64\n") - base.SetExitStatus(2) - base.Exit() - } + if cfg.BuildRace && !sys.RaceDetectorSupported(cfg.Goos, cfg.Goarch) { + fmt.Fprintf(os.Stderr, "-race is not supported on %s/%s\n", cfg.Goos, cfg.Goarch) + base.SetExitStatus(2) + base.Exit() + } + if cfg.BuildASan && !sys.ASanSupported(cfg.Goos, cfg.Goarch) { + fmt.Fprintf(os.Stderr, "-asan is not supported on %s/%s\n", cfg.Goos, cfg.Goarch) + base.SetExitStatus(2) + base.Exit() } mode := "race" if cfg.BuildMSan { @@ -116,6 +129,9 @@ func instrumentInit() { cfg.BuildBuildmode = "pie" } } + if cfg.BuildASan { + mode = "asan" + } modeFlag := "-" + mode if !cfg.BuildContext.CgoEnabled { diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go index ac9764db94..acb1f91b44 100644 --- a/src/cmd/go/script_test.go +++ b/src/cmd/go/script_test.go @@ -353,6 +353,8 @@ Script: ok = canCgo case "msan": ok = canMSan + case "asan": + ok = canASan case "race": ok = canRace case "net": diff --git a/src/cmd/go/testdata/script/README b/src/cmd/go/testdata/script/README index 48e4055b0b..2b88e880c9 100644 --- a/src/cmd/go/testdata/script/README +++ b/src/cmd/go/testdata/script/README @@ -79,7 +79,7 @@ should only run when the condition is satisfied. The available conditions are: - Compiler names, like [gccgo], [gc]. - Test environment details: - [short] for testing.Short() - - [cgo], [msan], [race] for whether cgo, msan, and the race detector can be used + - [cgo], [msan], [asan], [race] for whether cgo, msan, asan, and the race detector can be used - [net] for whether the external network can be used - [link] for testenv.HasLink() - [root] for os.Geteuid() == 0 diff --git a/src/cmd/go/testdata/script/goflags.txt b/src/cmd/go/testdata/script/goflags.txt index 686d1138b8..f4872ffd35 100644 --- a/src/cmd/go/testdata/script/goflags.txt +++ b/src/cmd/go/testdata/script/goflags.txt @@ -9,7 +9,7 @@ stdout '[\\/]runtime$' env GOFLAGS=-race OLDGOARCH=$GOARCH OLDGOOS=$GOOS GOARCH=386 GOOS=linux ! go list runtime -stderr 'race is only supported on' +stderr 'race is not supported on linux/386' env GOARCH=$OLDGOARCH GOOS=$OLDGOOS diff --git a/src/cmd/go/testdata/script/install_msan_and_race_require_cgo.txt b/src/cmd/go/testdata/script/install_msan_and_race_require_cgo.txt index 7985cd2ab2..5e88f7b8db 100644 --- a/src/cmd/go/testdata/script/install_msan_and_race_require_cgo.txt +++ b/src/cmd/go/testdata/script/install_msan_and_race_require_cgo.txt @@ -1,7 +1,5 @@ # Tests Issue #21895 -[!msan] [!race] skip 'skipping because both msan and the race detector are not supported' - env CGO_ENABLED=0 [race] ! go install -race triv.go @@ -12,6 +10,10 @@ env CGO_ENABLED=0 [msan] stderr '-msan requires cgo' [msan] ! stderr '-race' +[asan] ! go install -asan triv.go +[asan] stderr '-asan requires cgo' +[asan] ! stderr '-msan' + -- triv.go -- package main From adfb85b3150d5ebe36440f82d83be88403951319 Mon Sep 17 00:00:00 2001 From: fanzha02 Date: Mon, 4 Jan 2021 17:53:37 +0800 Subject: [PATCH 158/406] runtime, runtime/asan: add asan runtime support These are the runtime support functions for letting Go code interoperate with the C/C++ address sanitizer. Calls to asanread/asanwrite are now inserted by the compiler with the -asan option. Calls to asanunpoison/asanpoison will be from other runtime functions in a subsequent CL. Updates #44853. Change-Id: I9e8fc0ce937828bc7f4a8b6637453ddc3862c47b Reviewed-on: https://go-review.googlesource.com/c/go/+/298613 Trust: fannie zhang Run-TryBot: fannie zhang TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/go/build/deps_test.go | 2 +- src/runtime/asan.go | 43 ++++++++++++++++++++++ src/runtime/asan/asan.go | 52 +++++++++++++++++++++++++++ src/runtime/asan0.go | 23 ++++++++++++ src/runtime/asan_amd64.s | 76 +++++++++++++++++++++++++++++++++++++++ src/runtime/asan_arm64.s | 63 ++++++++++++++++++++++++++++++++ 6 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 src/runtime/asan.go create mode 100644 src/runtime/asan/asan.go create mode 100644 src/runtime/asan0.go create mode 100644 src/runtime/asan_amd64.s create mode 100644 src/runtime/asan_arm64.s diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go index a92bb3893b..64f084152a 100644 --- a/src/go/build/deps_test.go +++ b/src/go/build/deps_test.go @@ -331,7 +331,7 @@ var depsRules = ` < C < runtime/cgo < CGO - < runtime/race, runtime/msan; + < runtime/race, runtime/msan, runtime/asan; # Bulk of the standard library must not use cgo. # The prohibition stops at net and os/user. diff --git a/src/runtime/asan.go b/src/runtime/asan.go new file mode 100644 index 0000000000..7ff5f26bfb --- /dev/null +++ b/src/runtime/asan.go @@ -0,0 +1,43 @@ +// Copyright 2021 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. + +//go:build asan +// +build asan + +package runtime + +import ( + "unsafe" +) + +// Public address sanitizer API. + +func ASanRead(addr unsafe.Pointer, len int) { + asanread(addr, uintptr(len)) +} + +func ASanWrite(addr unsafe.Pointer, len int) { + asanwrite(addr, uintptr(len)) +} + +// Private interface for the runtime. +const asanenabled = true + +//go:noescape +func asanread(addr unsafe.Pointer, sz uintptr) + +//go:noescape +func asanwrite(addr unsafe.Pointer, sz uintptr) + +//go:noescape +func asanunpoison(addr unsafe.Pointer, sz uintptr) + +//go:noescape +func asanpoison(addr unsafe.Pointer, sz uintptr) + +// These are called from asan_GOARCH.s +//go:cgo_import_static __asan_read_go +//go:cgo_import_static __asan_write_go +//go:cgo_import_static __asan_unpoison_go +//go:cgo_import_static __asan_poison_go diff --git a/src/runtime/asan/asan.go b/src/runtime/asan/asan.go new file mode 100644 index 0000000000..40ebf96824 --- /dev/null +++ b/src/runtime/asan/asan.go @@ -0,0 +1,52 @@ +// Copyright 2021 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. + +//go:build asan && linux && (arm64 || amd64) +// +build asan +// +build linux +// +build arm64 amd64 + +package asan + +/* +#cgo CFLAGS: -fsanitize=address +#cgo LDFLAGS: -fsanitize=address + +#include +#include + +void __asan_read_go(void *addr, uintptr_t sz) { + if (__asan_region_is_poisoned(addr, sz)) { + switch (sz) { + case 1: __asan_report_load1(addr); break; + case 2: __asan_report_load2(addr); break; + case 4: __asan_report_load4(addr); break; + case 8: __asan_report_load8(addr); break; + default: __asan_report_load_n(addr, sz); break; + } + } +} + +void __asan_write_go(void *addr, uintptr_t sz) { + if (__asan_region_is_poisoned(addr, sz)) { + switch (sz) { + case 1: __asan_report_store1(addr); break; + case 2: __asan_report_store2(addr); break; + case 4: __asan_report_store4(addr); break; + case 8: __asan_report_store8(addr); break; + default: __asan_report_store_n(addr, sz); break; + } + } +} + +void __asan_unpoison_go(void *addr, uintptr_t sz) { + __asan_unpoison_memory_region(addr, sz); +} + +void __asan_poison_go(void *addr, uintptr_t sz) { + __asan_poison_memory_region(addr, sz); +} + +*/ +import "C" diff --git a/src/runtime/asan0.go b/src/runtime/asan0.go new file mode 100644 index 0000000000..dad069bbe6 --- /dev/null +++ b/src/runtime/asan0.go @@ -0,0 +1,23 @@ +// Copyright 2021 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. + +//go:build !asan +// +build !asan + +// Dummy ASan support API, used when not built with -asan. + +package runtime + +import ( + "unsafe" +) + +const asanenabled = false + +// Because asanenabled is false, none of these functions should be called. + +func asanread(addr unsafe.Pointer, sz uintptr) { throw("asan") } +func asanwrite(addr unsafe.Pointer, sz uintptr) { throw("asan") } +func asanunpoison(addr unsafe.Pointer, sz uintptr) { throw("asan") } +func asanpoison(addr unsafe.Pointer, sz uintptr) { throw("asan") } diff --git a/src/runtime/asan_amd64.s b/src/runtime/asan_amd64.s new file mode 100644 index 0000000000..01bd612dc3 --- /dev/null +++ b/src/runtime/asan_amd64.s @@ -0,0 +1,76 @@ +// Copyright 2021 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. + +//go:build asan +// +build asan + +#include "go_asm.h" +#include "go_tls.h" +#include "funcdata.h" +#include "textflag.h" + +// This is like race_amd64.s, but for the asan calls. +// See race_amd64.s for detailed comments. + +#ifdef GOOS_windows +#define RARG0 CX +#define RARG1 DX +#else +#define RARG0 DI +#define RARG1 SI +#endif + +// Called from intrumented code. +// func runtime·asanread(addr unsafe.Pointer, sz uintptr) +TEXT runtime·asanread(SB), NOSPLIT, $0-16 + MOVQ addr+0(FP), RARG0 + MOVQ size+8(FP), RARG1 + // void __asan_read_go(void *addr, uintptr_t sz); + MOVQ $__asan_read_go(SB), AX + JMP asancall<>(SB) + +// func runtime·asanwrite(addr unsafe.Pointer, sz uintptr) +TEXT runtime·asanwrite(SB), NOSPLIT, $0-16 + MOVQ addr+0(FP), RARG0 + MOVQ size+8(FP), RARG1 + // void __asan_write_go(void *addr, uintptr_t sz); + MOVQ $__asan_write_go(SB), AX + JMP asancall<>(SB) + +// func runtime·asanunpoison(addr unsafe.Pointer, sz uintptr) +TEXT runtime·asanunpoison(SB), NOSPLIT, $0-16 + MOVQ addr+0(FP), RARG0 + MOVQ size+8(FP), RARG1 + // void __asan_unpoison_go(void *addr, uintptr_t sz); + MOVQ $__asan_unpoison_go(SB), AX + JMP asancall<>(SB) + +// func runtime·asanpoison(addr unsafe.Pointer, sz uintptr) +TEXT runtime·asanpoison(SB), NOSPLIT, $0-16 + MOVQ addr+0(FP), RARG0 + MOVQ size+8(FP), RARG1 + // void __asan_poison_go(void *addr, uintptr_t sz); + MOVQ $__asan_poison_go(SB), AX + JMP asancall<>(SB) + +// Switches SP to g0 stack and calls (AX). Arguments already set. +TEXT asancall<>(SB), NOSPLIT, $0-0 + get_tls(R12) + MOVQ g(R12), R14 + MOVQ SP, R12 // callee-saved, preserved across the CALL + CMPQ R14, $0 + JE call // no g; still on a system stack + + MOVQ g_m(R14), R13 + // Switch to g0 stack. + MOVQ m_g0(R13), R10 + CMPQ R10, R14 + JE call // already on g0 + + MOVQ (g_sched+gobuf_sp)(R10), SP +call: + ANDQ $~15, SP // alignment for gcc ABI + CALL AX + MOVQ R12, SP + RET diff --git a/src/runtime/asan_arm64.s b/src/runtime/asan_arm64.s new file mode 100644 index 0000000000..eb0f9bd71e --- /dev/null +++ b/src/runtime/asan_arm64.s @@ -0,0 +1,63 @@ +// Copyright 2021 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. + +//go:build asan +// +build asan + +#include "go_asm.h" +#include "textflag.h" + +#define RARG0 R0 +#define RARG1 R1 +#define FARG R3 + +// Called from instrumented code. +// func runtime·asanread(addr unsafe.Pointer, sz uintptr) +TEXT runtime·asanread(SB), NOSPLIT, $0-16 + MOVD addr+0(FP), RARG0 + MOVD size+8(FP), RARG1 + // void __asan_read_go(void *addr, uintptr_t sz); + MOVD $__asan_read_go(SB), FARG + JMP asancall<>(SB) + +// func runtime·asanwrite(addr unsafe.Pointer, sz uintptr) +TEXT runtime·asanwrite(SB), NOSPLIT, $0-16 + MOVD addr+0(FP), RARG0 + MOVD size+8(FP), RARG1 + // void __asan_write_go(void *addr, uintptr_t sz); + MOVD $__asan_write_go(SB), FARG + JMP asancall<>(SB) + +// func runtime·asanunpoison(addr unsafe.Pointer, sz uintptr) +TEXT runtime·asanunpoison(SB), NOSPLIT, $0-16 + MOVD addr+0(FP), RARG0 + MOVD size+8(FP), RARG1 + // void __asan_unpoison_go(void *addr, uintptr_t sz); + MOVD $__asan_unpoison_go(SB), FARG + JMP asancall<>(SB) + +// func runtime·asanpoison(addr unsafe.Pointer, sz uintptr) +TEXT runtime·asanpoison(SB), NOSPLIT, $0-16 + MOVD addr+0(FP), RARG0 + MOVD size+8(FP), RARG1 + // void __asan_poison_go(void *addr, uintptr_t sz); + MOVD $__asan_poison_go(SB), FARG + JMP asancall<>(SB) + +// Switches SP to g0 stack and calls (FARG). Arguments already set. +TEXT asancall<>(SB), NOSPLIT, $0-0 + MOVD RSP, R19 // callee-saved + CBZ g, g0stack // no g, still on a system stack + MOVD g_m(g), R10 + MOVD m_g0(R10), R11 + CMP R11, g + BEQ g0stack + + MOVD (g_sched+gobuf_sp)(R11), R4 + MOVD R4, RSP + +g0stack: + BL (FARG) + MOVD R19, RSP + RET From ec6c00418c83aa4f68a5afc9803831f43f8d794f Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 25 Oct 2021 13:37:29 +0200 Subject: [PATCH 159/406] syscall: use fcntl F_DUP2FD_CLOEXEC in forkAndExecInChild on illumos Use fcntl(oldfd, F_DUP2FD_CLOEXEC, newfd) to duplicate the file descriptor and mark is as close-on-exec instead of dup2 & fcntl. Illumos implements dup3 like this in libc. Change-Id: I9782bce553ffb832e9b1a12bbf3c0a40c821f56e Reviewed-on: https://go-review.googlesource.com/c/go/+/358374 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/syscall/exec_libc.go | 26 ++++++++++++++++++++------ src/syscall/syscall_aix.go | 2 ++ src/syscall/syscall_solaris.go | 2 ++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/syscall/exec_libc.go b/src/syscall/exec_libc.go index 8a84954051..b14abd4e63 100644 --- a/src/syscall/exec_libc.go +++ b/src/syscall/exec_libc.go @@ -10,6 +10,7 @@ package syscall import ( + "runtime" "unsafe" ) @@ -197,11 +198,19 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr // Pass 1: look for fd[i] < i and move those up above len(fd) // so that pass 2 won't stomp on an fd it needs later. if pipe < nextfd { - _, err1 = dup2child(uintptr(pipe), uintptr(nextfd)) + switch runtime.GOOS { + case "illumos": + _, err1 = fcntl1(uintptr(pipe), _F_DUP2FD_CLOEXEC, uintptr(nextfd)) + default: + _, err1 = dup2child(uintptr(pipe), uintptr(nextfd)) + if err1 != 0 { + goto childerror + } + _, err1 = fcntl1(uintptr(nextfd), F_SETFD, FD_CLOEXEC) + } if err1 != 0 { goto childerror } - fcntl1(uintptr(nextfd), F_SETFD, FD_CLOEXEC) pipe = nextfd nextfd++ } @@ -210,11 +219,16 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr if nextfd == pipe { // don't stomp on pipe nextfd++ } - _, err1 = dup2child(uintptr(fd[i]), uintptr(nextfd)) - if err1 != 0 { - goto childerror + switch runtime.GOOS { + case "illumos": + _, err1 = fcntl1(uintptr(fd[i]), _F_DUP2FD_CLOEXEC, uintptr(nextfd)) + default: + _, err1 = dup2child(uintptr(fd[i]), uintptr(nextfd)) + if err1 != 0 { + goto childerror + } + _, err1 = fcntl1(uintptr(nextfd), F_SETFD, FD_CLOEXEC) } - _, err1 = fcntl1(uintptr(nextfd), F_SETFD, FD_CLOEXEC) if err1 != 0 { goto childerror } diff --git a/src/syscall/syscall_aix.go b/src/syscall/syscall_aix.go index 9c6afba442..20e77ac875 100644 --- a/src/syscall/syscall_aix.go +++ b/src/syscall/syscall_aix.go @@ -31,6 +31,8 @@ const ( F_DUPFD_CLOEXEC = 0 // AF_LOCAL doesn't exist on AIX AF_LOCAL = AF_UNIX + + _F_DUP2FD_CLOEXEC = 0 ) func (ts *StTimespec_t) Unix() (sec int64, nsec int64) { diff --git a/src/syscall/syscall_solaris.go b/src/syscall/syscall_solaris.go index daa4b88a71..dedfbd03c0 100644 --- a/src/syscall/syscall_solaris.go +++ b/src/syscall/syscall_solaris.go @@ -14,6 +14,8 @@ package syscall import "unsafe" +const _F_DUP2FD_CLOEXEC = F_DUP2FD_CLOEXEC + // Implemented in asm_solaris_amd64.s. func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) From 23fdd7f0f75bca03a092faeeef60d8b0b804bf8d Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 25 Oct 2021 07:48:12 +0200 Subject: [PATCH 160/406] syscall: add utimensat libc wrapper on darwin Add utimensat as a wrapper around the libc function of the same name. utimensat was added in macOS 10.13 which is the minimum supported release since Go 1.17 dropped support for macOS 10.12. This also allows to drop the fallback to setattrlistTimes which was used to set timestamps with nanosecond resolution before utimensat could be used, see #22528 and CL 74952. Updates #22528 Change-Id: I87b6a76acf1d642ceede9254f7d9d06dddc3fd71 Reviewed-on: https://go-review.googlesource.com/c/go/+/358274 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/syscall/syscall_bsd.go | 7 +--- src/syscall/syscall_darwin.go | 53 +--------------------------- src/syscall/syscall_dragonfly.go | 5 --- src/syscall/syscall_freebsd.go | 5 --- src/syscall/syscall_netbsd.go | 5 --- src/syscall/syscall_openbsd.go | 5 --- src/syscall/zsyscall_darwin_amd64.go | 19 ++++++++++ src/syscall/zsyscall_darwin_amd64.s | 4 +-- src/syscall/zsyscall_darwin_arm64.go | 19 ++++++++++ src/syscall/zsyscall_darwin_arm64.s | 4 +-- 10 files changed, 44 insertions(+), 82 deletions(-) diff --git a/src/syscall/syscall_bsd.go b/src/syscall/syscall_bsd.go index 595e705856..40b1c07a90 100644 --- a/src/syscall/syscall_bsd.go +++ b/src/syscall/syscall_bsd.go @@ -524,12 +524,7 @@ func UtimesNano(path string, ts []Timespec) error { if len(ts) != 2 { return EINVAL } - // Darwin setattrlist can set nanosecond timestamps - err := setattrlistTimes(path, ts) - if err != ENOSYS { - return err - } - err = utimensat(_AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) + err := utimensat(_AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) if err != ENOSYS { return err } diff --git a/src/syscall/syscall_darwin.go b/src/syscall/syscall_darwin.go index a4fe4f1962..5bb34e300c 100644 --- a/src/syscall/syscall_darwin.go +++ b/src/syscall/syscall_darwin.go @@ -72,22 +72,6 @@ func direntNamlen(buf []byte) (uint64, bool) { func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) } func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) } -const ( - attrBitMapCount = 5 - attrCmnModtime = 0x00000400 - attrCmnAcctime = 0x00001000 -) - -type attrList struct { - bitmapCount uint16 - _ uint16 - CommonAttr uint32 - VolAttr uint32 - DirAttr uint32 - FileAttr uint32 - Forkattr uint32 -} - //sysnb pipe(p *[2]int32) (err error) func Pipe(p []int) (err error) { @@ -120,42 +104,7 @@ func libc_getfsstat_trampoline() //go:cgo_import_dynamic libc_getfsstat getfsstat "/usr/lib/libSystem.B.dylib" -func setattrlistTimes(path string, times []Timespec) error { - _p0, err := BytePtrFromString(path) - if err != nil { - return err - } - - var attrList attrList - attrList.bitmapCount = attrBitMapCount - attrList.CommonAttr = attrCmnModtime | attrCmnAcctime - - // order is mtime, atime: the opposite of Chtimes - attributes := [2]Timespec{times[1], times[0]} - const options = 0 - _, _, e1 := syscall6( - abi.FuncPCABI0(libc_setattrlist_trampoline), - uintptr(unsafe.Pointer(_p0)), - uintptr(unsafe.Pointer(&attrList)), - uintptr(unsafe.Pointer(&attributes)), - uintptr(unsafe.Sizeof(attributes)), - uintptr(options), - 0, - ) - if e1 != 0 { - return e1 - } - return nil -} - -func libc_setattrlist_trampoline() - -//go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib" - -func utimensat(dirfd int, path string, times *[2]Timespec, flag int) error { - // Darwin doesn't support SYS_UTIMENSAT - return ENOSYS -} +//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) /* * Wrapped diff --git a/src/syscall/syscall_dragonfly.go b/src/syscall/syscall_dragonfly.go index b01a4ada67..16adf306d5 100644 --- a/src/syscall/syscall_dragonfly.go +++ b/src/syscall/syscall_dragonfly.go @@ -156,11 +156,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { return } -func setattrlistTimes(path string, times []Timespec) error { - // used on Darwin for UtimesNano - return ENOSYS -} - /* * Exposed directly */ diff --git a/src/syscall/syscall_freebsd.go b/src/syscall/syscall_freebsd.go index 7c7b89aab9..6f44b25cb9 100644 --- a/src/syscall/syscall_freebsd.go +++ b/src/syscall/syscall_freebsd.go @@ -176,11 +176,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { return } -func setattrlistTimes(path string, times []Timespec) error { - // used on Darwin for UtimesNano - return ENOSYS -} - func Stat(path string, st *Stat_t) (err error) { var oldStat stat_freebsd11_t if supportsABI(_ino64First) { diff --git a/src/syscall/syscall_netbsd.go b/src/syscall/syscall_netbsd.go index fc13b706b5..6f05b0d43d 100644 --- a/src/syscall/syscall_netbsd.go +++ b/src/syscall/syscall_netbsd.go @@ -146,11 +146,6 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e return -1, ENOSYS } -func setattrlistTimes(path string, times []Timespec) error { - // used on Darwin for UtimesNano - return ENOSYS -} - /* * Exposed directly */ diff --git a/src/syscall/syscall_openbsd.go b/src/syscall/syscall_openbsd.go index 5a5ba5a51b..195cf8617c 100644 --- a/src/syscall/syscall_openbsd.go +++ b/src/syscall/syscall_openbsd.go @@ -121,11 +121,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { return } -func setattrlistTimes(path string, times []Timespec) error { - // used on Darwin for UtimesNano - return ENOSYS -} - /* * Exposed directly */ diff --git a/src/syscall/zsyscall_darwin_amd64.go b/src/syscall/zsyscall_darwin_amd64.go index 07a519d7d6..ff88fef74e 100644 --- a/src/syscall/zsyscall_darwin_amd64.go +++ b/src/syscall/zsyscall_darwin_amd64.go @@ -345,6 +345,25 @@ func libc_pipe_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall6(abi.FuncPCABI0(libc_utimensat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +func libc_utimensat_trampoline() + +//go:cgo_import_dynamic libc_utimensat utimensat "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func kill(pid int, signum int, posix int) (err error) { _, _, e1 := syscall(abi.FuncPCABI0(libc_kill_trampoline), uintptr(pid), uintptr(signum), uintptr(posix)) if e1 != 0 { diff --git a/src/syscall/zsyscall_darwin_amd64.s b/src/syscall/zsyscall_darwin_amd64.s index 492f947855..563083d441 100644 --- a/src/syscall/zsyscall_darwin_amd64.s +++ b/src/syscall/zsyscall_darwin_amd64.s @@ -3,8 +3,6 @@ #include "textflag.h" TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0 JMP libc_getfsstat(SB) -TEXT ·libc_setattrlist_trampoline(SB),NOSPLIT,$0-0 - JMP libc_setattrlist(SB) TEXT ·libc_fdopendir_trampoline(SB),NOSPLIT,$0-0 JMP libc_fdopendir(SB) TEXT ·libc_sendfile_trampoline(SB),NOSPLIT,$0-0 @@ -53,6 +51,8 @@ TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0 JMP libc_fcntl(SB) TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0 JMP libc_pipe(SB) +TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0 + JMP libc_utimensat(SB) TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0 JMP libc_kill(SB) TEXT ·libc_access_trampoline(SB),NOSPLIT,$0-0 diff --git a/src/syscall/zsyscall_darwin_arm64.go b/src/syscall/zsyscall_darwin_arm64.go index 5ae096730e..b096b5e662 100644 --- a/src/syscall/zsyscall_darwin_arm64.go +++ b/src/syscall/zsyscall_darwin_arm64.go @@ -345,6 +345,25 @@ func libc_pipe_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall6(abi.FuncPCABI0(libc_utimensat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +func libc_utimensat_trampoline() + +//go:cgo_import_dynamic libc_utimensat utimensat "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func kill(pid int, signum int, posix int) (err error) { _, _, e1 := syscall(abi.FuncPCABI0(libc_kill_trampoline), uintptr(pid), uintptr(signum), uintptr(posix)) if e1 != 0 { diff --git a/src/syscall/zsyscall_darwin_arm64.s b/src/syscall/zsyscall_darwin_arm64.s index b606c6e49e..0567a42fa3 100644 --- a/src/syscall/zsyscall_darwin_arm64.s +++ b/src/syscall/zsyscall_darwin_arm64.s @@ -3,8 +3,6 @@ #include "textflag.h" TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0 JMP libc_getfsstat(SB) -TEXT ·libc_setattrlist_trampoline(SB),NOSPLIT,$0-0 - JMP libc_setattrlist(SB) TEXT ·libc_fdopendir_trampoline(SB),NOSPLIT,$0-0 JMP libc_fdopendir(SB) TEXT ·libc_sendfile_trampoline(SB),NOSPLIT,$0-0 @@ -53,6 +51,8 @@ TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0 JMP libc_fcntl(SB) TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0 JMP libc_pipe(SB) +TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0 + JMP libc_utimensat(SB) TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0 JMP libc_kill(SB) TEXT ·libc_access_trampoline(SB),NOSPLIT,$0-0 From 1e2820a6d72b606eb4070eda6cc626bde122f9c8 Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Tue, 10 Aug 2021 09:50:56 -0500 Subject: [PATCH 161/406] cmd/internal/obj/ppc64: fix usage of CR bit arguments CR bits and CR fields should be treated separately. Some instructions modify an entire CR, a CR field, or a single CR bit. Add a new argument class for CR bits, and teach the assembler the recognize them as names like CR0LT or CR2SO, and update the CR bit logic instructions to use them. They will no longer accept register field (CRn) type arguments. Fixes #46422 Change-Id: Iaba127d88abada0c2a49b8d3b07a976180565ae4 Reviewed-on: https://go-review.googlesource.com/c/go/+/357774 Run-TryBot: Paul Murphy Trust: Lynn Boger TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- src/cmd/asm/internal/arch/arch.go | 3 ++ src/cmd/asm/internal/asm/testdata/ppc64.s | 16 +++++----- src/cmd/internal/obj/ppc64/a.out.go | 39 +++++++++++++++++++++-- src/cmd/internal/obj/ppc64/anames9.go | 1 + src/cmd/internal/obj/ppc64/asm9.go | 5 ++- src/cmd/internal/obj/ppc64/asm_test.go | 2 ++ src/cmd/internal/obj/ppc64/doc.go | 6 ++++ src/cmd/internal/obj/ppc64/list9.go | 5 +++ 8 files changed, 66 insertions(+), 11 deletions(-) diff --git a/src/cmd/asm/internal/arch/arch.go b/src/cmd/asm/internal/arch/arch.go index cffa9a26a4..8c71b79965 100644 --- a/src/cmd/asm/internal/arch/arch.go +++ b/src/cmd/asm/internal/arch/arch.go @@ -378,6 +378,9 @@ func archPPC64(linkArch *obj.LinkArch) *Arch { for i := ppc64.REG_MSR; i <= ppc64.REG_CR; i++ { register[obj.Rconv(i)] = int16(i) } + for i := ppc64.REG_CR0LT; i <= ppc64.REG_CR7SO; i++ { + register[obj.Rconv(i)] = int16(i) + } register["CR"] = ppc64.REG_CR register["XER"] = ppc64.REG_XER register["LR"] = ppc64.REG_LR diff --git a/src/cmd/asm/internal/asm/testdata/ppc64.s b/src/cmd/asm/internal/asm/testdata/ppc64.s index b9da48acdd..c140fd025a 100644 --- a/src/cmd/asm/internal/asm/testdata/ppc64.s +++ b/src/cmd/asm/internal/asm/testdata/ppc64.s @@ -342,14 +342,14 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0 NOP F2 NOP $4 - CRAND CR1, CR2, CR3 // 4c620a02 - CRANDN CR1, CR2, CR3 // 4c620902 - CREQV CR1, CR2, CR3 // 4c620a42 - CRNAND CR1, CR2, CR3 // 4c6209c2 - CRNOR CR1, CR2, CR3 // 4c620842 - CROR CR1, CR2, CR3 // 4c620b82 - CRORN CR1, CR2, CR3 // 4c620b42 - CRXOR CR1, CR2, CR3 // 4c620982 + CRAND CR0GT, CR0EQ, CR0SO // 4c620a02 + CRANDN CR0GT, CR0EQ, CR0SO // 4c620902 + CREQV CR0GT, CR0EQ, CR0SO // 4c620a42 + CRNAND CR0GT, CR0EQ, CR0SO // 4c6209c2 + CRNOR CR0GT, CR0EQ, CR0SO // 4c620842 + CROR CR0GT, CR0EQ, CR0SO // 4c620b82 + CRORN CR0GT, CR0EQ, CR0SO // 4c620b42 + CRXOR CR0GT, CR0EQ, CR0SO // 4c620982 ISEL $1, R3, R4, R5 // 7ca3205e ISEL $0, R3, R4, R5 // 7ca3201e diff --git a/src/cmd/internal/obj/ppc64/a.out.go b/src/cmd/internal/obj/ppc64/a.out.go index fe18296034..1e74e64a29 100644 --- a/src/cmd/internal/obj/ppc64/a.out.go +++ b/src/cmd/internal/obj/ppc64/a.out.go @@ -79,10 +79,44 @@ const ( REG_R30 REG_R31 + // CR bits. Use Book 1, chapter 2 naming for bits. Keep aligned to 32 + REG_CR0LT + REG_CR0GT + REG_CR0EQ + REG_CR0SO + REG_CR1LT + REG_CR1GT + REG_CR1EQ + REG_CR1SO + REG_CR2LT + REG_CR2GT + REG_CR2EQ + REG_CR2SO + REG_CR3LT + REG_CR3GT + REG_CR3EQ + REG_CR3SO + REG_CR4LT + REG_CR4GT + REG_CR4EQ + REG_CR4SO + REG_CR5LT + REG_CR5GT + REG_CR5EQ + REG_CR5SO + REG_CR6LT + REG_CR6GT + REG_CR6EQ + REG_CR6SO + REG_CR7LT + REG_CR7GT + REG_CR7EQ + REG_CR7SO + /* Align FPR and VSR vectors such that when masked with 0x3F they produce an equivalent VSX register. */ /* F0=4160 ... F31=4191 */ - REG_F0 = obj.RBasePPC64 + iota + 32 + REG_F0 REG_F1 REG_F2 REG_F3 @@ -358,7 +392,8 @@ const ( C_VREG /* Any vector register */ C_VSREGP /* An even numbered vsx register which can be used as a vsx register pair argument */ C_VSREG /* Any vector-scalar register */ - C_CREG /* The condition registor (CR) or a condition register field (CRx) */ + C_CREG /* The condition registor (CR) */ + C_CRBIT /* A single bit of the CR register (0-31) */ C_SPR /* special processor register */ C_ZCON /* The constant zero */ C_U1CON /* 1 bit unsigned constant */ diff --git a/src/cmd/internal/obj/ppc64/anames9.go b/src/cmd/internal/obj/ppc64/anames9.go index 3b2aba77ab..05bfd944d1 100644 --- a/src/cmd/internal/obj/ppc64/anames9.go +++ b/src/cmd/internal/obj/ppc64/anames9.go @@ -14,6 +14,7 @@ var cnames9 = []string{ "VSREGP", "VSREG", "CREG", + "CRBIT", "SPR", "ZCON", "U1CON", diff --git a/src/cmd/internal/obj/ppc64/asm9.go b/src/cmd/internal/obj/ppc64/asm9.go index 08fb5118f0..31fbb7f7bf 100644 --- a/src/cmd/internal/obj/ppc64/asm9.go +++ b/src/cmd/internal/obj/ppc64/asm9.go @@ -335,7 +335,7 @@ var optab = []Optab{ {as: ALDMX, a1: C_SOREG, a6: C_REG, type_: 45, size: 4}, /* load doubleword monitored, x-form */ {as: AMADDHD, a1: C_REG, a2: C_REG, a3: C_REG, a6: C_REG, type_: 83, size: 4}, /* multiply-add high/low doubleword, va-form */ {as: AADDEX, a1: C_REG, a2: C_REG, a3: C_SCON, a6: C_REG, type_: 94, size: 4}, /* add extended using alternate carry, z23-form */ - {as: ACRAND, a1: C_CREG, a2: C_CREG, a6: C_CREG, type_: 2, size: 4}, /* logical ops for condition register bits xl-form */ + {as: ACRAND, a1: C_CRBIT, a2: C_CRBIT, a6: C_CRBIT, type_: 2, size: 4}, /* logical ops for condition register bits xl-form */ /* Vector instructions */ @@ -856,6 +856,9 @@ func (c *ctxt9) aclassreg(reg int16) int { if REG_CR0 <= reg && reg <= REG_CR7 || reg == REG_CR { return C_CREG } + if REG_CR0LT <= reg && reg <= REG_CR7SO { + return C_CRBIT + } if REG_SPR0 <= reg && reg <= REG_SPR0+1023 { switch reg { case REG_LR: diff --git a/src/cmd/internal/obj/ppc64/asm_test.go b/src/cmd/internal/obj/ppc64/asm_test.go index 3a9b87363c..ee2e5962f7 100644 --- a/src/cmd/internal/obj/ppc64/asm_test.go +++ b/src/cmd/internal/obj/ppc64/asm_test.go @@ -435,6 +435,7 @@ func TestRegValueAlignment(t *testing.T) { {REG_F0, REG_F31, 63, 0}, {REG_SPR0, REG_SPR0 + 1023, 1023, 0}, {REG_CR0, REG_CR7, 7, 0}, + {REG_CR0LT, REG_CR7SO, 31, 0}, } for _, t := range testType { tstFunc(t.rstart, t.rend, t.msk, t.rout) @@ -463,6 +464,7 @@ func TestAddrClassifier(t *testing.T) { {obj.Addr{Type: obj.TYPE_REG, Reg: REG_VS2}, C_VSREGP}, {obj.Addr{Type: obj.TYPE_REG, Reg: REG_CR}, C_CREG}, {obj.Addr{Type: obj.TYPE_REG, Reg: REG_CR1}, C_CREG}, + {obj.Addr{Type: obj.TYPE_REG, Reg: REG_CR1SO}, C_CRBIT}, {obj.Addr{Type: obj.TYPE_REG, Reg: REG_SPR0}, C_SPR}, {obj.Addr{Type: obj.TYPE_REG, Reg: REG_SPR0 + 1}, C_XER}, {obj.Addr{Type: obj.TYPE_REG, Reg: REG_SPR0 + 8}, C_LR}, diff --git a/src/cmd/internal/obj/ppc64/doc.go b/src/cmd/internal/obj/ppc64/doc.go index 6e601df82e..a9d89c93b4 100644 --- a/src/cmd/internal/obj/ppc64/doc.go +++ b/src/cmd/internal/obj/ppc64/doc.go @@ -239,6 +239,12 @@ Register naming VSn is used for vector-scalar registers. V0-V31 overlap with VS32-VS63. (0-63) CTR represents the count register. LR represents the link register. + CR represents the condition register + CRn represents a condition register field. (0-7) + CRnLT represents CR bit 0 of CR field n. (0-7) + CRnGT represents CR bit 1 of CR field n. (0-7) + CRnEQ represents CR bit 2 of CR field n. (0-7) + CRnSO represents CR bit 3 of CR field n. (0-7) */ package ppc64 diff --git a/src/cmd/internal/obj/ppc64/list9.go b/src/cmd/internal/obj/ppc64/list9.go index 8b0b36f375..ea0dae9e02 100644 --- a/src/cmd/internal/obj/ppc64/list9.go +++ b/src/cmd/internal/obj/ppc64/list9.go @@ -62,6 +62,11 @@ func rconv(r int) string { if REG_CR0 <= r && r <= REG_CR7 { return fmt.Sprintf("CR%d", r-REG_CR0) } + if REG_CR0LT <= r && r <= REG_CR7SO { + bits := [4]string{"LT", "GT", "EQ", "SO"} + crf := (r - REG_CR0LT) / 4 + return fmt.Sprintf("CR%d%s", crf, bits[r%4]) + } if r == REG_CR { return "CR" } From a2b8c186f616db92f9812e09fb2c44b0e753f8a7 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Tue, 26 Oct 2021 00:27:27 -0400 Subject: [PATCH 162/406] all: update vendored golang.org/x/tools Pull in CL 358034 (and some more changes with passing tests) with: go get -d golang.org/x/tools@f916b54 go mod tidy go mod vendor This teaches x/tools/cmd/bundle and the package loader it uses about the new export data version. Fixes #49159. Change-Id: Icc36e77e602b1cd2da03708f20d05a66fcf693cd Reviewed-on: https://go-review.googlesource.com/c/go/+/358620 Trust: Dmitri Shuralyov Run-TryBot: Dmitri Shuralyov TryBot-Result: Go Bot Reviewed-by: Robert Findley --- src/cmd/go.mod | 2 +- src/cmd/go.sum | 4 +- .../go/analysis/passes/composite/composite.go | 68 +++--- .../tools/go/analysis/passes/printf/printf.go | 3 +- .../go/analysis/unitchecker/unitchecker.go | 3 + .../x/tools/internal/typeparams/normalize.go | 212 ++++++++++++++++++ .../x/tools/internal/typeparams/termlist.go | 172 ++++++++++++++ .../internal/typeparams/typeparams_go117.go | 46 +++- .../internal/typeparams/typeparams_go118.go | 25 ++- .../x/tools/internal/typeparams/typeterm.go | 170 ++++++++++++++ src/cmd/vendor/modules.txt | 2 +- 11 files changed, 654 insertions(+), 53 deletions(-) create mode 100644 src/cmd/vendor/golang.org/x/tools/internal/typeparams/normalize.go create mode 100644 src/cmd/vendor/golang.org/x/tools/internal/typeparams/termlist.go create mode 100644 src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeterm.go diff --git a/src/cmd/go.mod b/src/cmd/go.mod index b2ec091292..e6fdc902dd 100644 --- a/src/cmd/go.mod +++ b/src/cmd/go.mod @@ -8,7 +8,7 @@ require ( golang.org/x/mod v0.5.1-0.20210913215816-37dd6891021a golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b - golang.org/x/tools v0.1.8-0.20211011152358-18fa84021695 + golang.org/x/tools v0.1.8-0.20211025211149-f916b54a1784 ) require ( diff --git a/src/cmd/go.sum b/src/cmd/go.sum index ff8df7b749..4993128d1a 100644 --- a/src/cmd/go.sum +++ b/src/cmd/go.sum @@ -18,7 +18,7 @@ golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e h1:XMgFehsDnnLGtjvjOfqWSUzt0 golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/tools v0.1.8-0.20211011152358-18fa84021695 h1:H+g8CC6T05IOoW6fXaWvb5N3XBYQElWwgDS/7Yxg8dU= -golang.org/x/tools v0.1.8-0.20211011152358-18fa84021695/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/tools v0.1.8-0.20211025211149-f916b54a1784 h1:+xP+QoP2SEPgbn+07I/yJTzP+gavj0XKGS6+JU5tlck= +golang.org/x/tools v0.1.8-0.20211025211149-f916b54a1784/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go index 4c3ac6647f..025952ed50 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go @@ -14,6 +14,7 @@ import ( "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/inspect" "golang.org/x/tools/go/ast/inspector" + "golang.org/x/tools/internal/typeparams" ) const Doc = `check for unkeyed composite literals @@ -67,41 +68,52 @@ func run(pass *analysis.Pass) (interface{}, error) { // skip whitelisted types return } - under := typ.Underlying() - for { - ptr, ok := under.(*types.Pointer) - if !ok { - break + terms, err := typeparams.StructuralTerms(typ) + if err != nil { + return // invalid type + } + for _, term := range terms { + under := deref(term.Type().Underlying()) + if _, ok := under.(*types.Struct); !ok { + // skip non-struct composite literals + continue } - under = ptr.Elem().Underlying() - } - if _, ok := under.(*types.Struct); !ok { - // skip non-struct composite literals - return - } - if isLocalType(pass, typ) { - // allow unkeyed locally defined composite literal - return - } - - // check if the CompositeLit contains an unkeyed field - allKeyValue := true - for _, e := range cl.Elts { - if _, ok := e.(*ast.KeyValueExpr); !ok { - allKeyValue = false - break + if isLocalType(pass, term.Type()) { + // allow unkeyed locally defined composite literal + continue } - } - if allKeyValue { - // all the composite literal fields are keyed + + // check if the CompositeLit contains an unkeyed field + allKeyValue := true + for _, e := range cl.Elts { + if _, ok := e.(*ast.KeyValueExpr); !ok { + allKeyValue = false + break + } + } + if allKeyValue { + // all the composite literal fields are keyed + continue + } + + pass.ReportRangef(cl, "%s composite literal uses unkeyed fields", typeName) return } - - pass.ReportRangef(cl, "%s composite literal uses unkeyed fields", typeName) }) return nil, nil } +func deref(typ types.Type) types.Type { + for { + ptr, ok := typ.(*types.Pointer) + if !ok { + break + } + typ = ptr.Elem().Underlying() + } + return typ +} + func isLocalType(pass *analysis.Pass, typ types.Type) bool { switch x := typ.(type) { case *types.Struct: @@ -112,6 +124,8 @@ func isLocalType(pass *analysis.Pass, typ types.Type) bool { case *types.Named: // names in package foo are local to foo_test too return strings.TrimSuffix(x.Obj().Pkg().Path(), "_test") == strings.TrimSuffix(pass.Pkg.Path(), "_test") + case *typeparams.TypeParam: + return strings.TrimSuffix(x.Obj().Pkg().Path(), "_test") == strings.TrimSuffix(pass.Pkg.Path(), "_test") } return false } diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go index de0369a428..4169d30e4f 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go @@ -834,8 +834,9 @@ func okPrintfArg(pass *analysis.Pass, call *ast.CallExpr, state *formatState) (o } // Could current arg implement fmt.Formatter? + // Skip check for the %w verb, which requires an error. formatter := false - if state.argNum < len(call.Args) { + if v.typ != argError && state.argNum < len(call.Args) { if tv, ok := pass.TypesInfo.Types[call.Args[state.argNum]]; ok { formatter = isFormatter(tv.Type) } diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go index 5424489f8b..b539866ddd 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go @@ -51,6 +51,7 @@ import ( "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/internal/analysisflags" "golang.org/x/tools/go/analysis/internal/facts" + "golang.org/x/tools/internal/typeparams" ) // A Config describes a compilation unit to be analyzed. @@ -233,6 +234,8 @@ func run(fset *token.FileSet, cfg *Config, analyzers []*analysis.Analyzer) ([]re Scopes: make(map[ast.Node]*types.Scope), Selections: make(map[*ast.SelectorExpr]*types.Selection), } + typeparams.InitInstanceInfo(info) + pkg, err := tc.Check(cfg.ImportPath, fset, files, info) if err != nil { if cfg.SucceedOnTypecheckFailure { diff --git a/src/cmd/vendor/golang.org/x/tools/internal/typeparams/normalize.go b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/normalize.go new file mode 100644 index 0000000000..29373508e9 --- /dev/null +++ b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/normalize.go @@ -0,0 +1,212 @@ +// Copyright 2021 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 typeparams + +import ( + "errors" + "fmt" + "go/types" + "os" + "strings" +) + +//go:generate go run copytermlist.go + +const debug = false + +// NormalizeInterface returns the normal form of the interface iface, or nil if iface +// has an empty type set (i.e. there are no types that satisfy iface). If the +// resulting interface is non-nil, it will be identical to iface. +// +// An error is returned if the interface type is invalid, or too complicated to +// reasonably normalize (for example, contains unions with more than a hundred +// terms). +// +// An interface is in normal form if and only if: +// - it has 0 or 1 embedded types. +// - its embedded type is either a types.Union or has a concrete +// (non-interface) underlying type +// - if the embedded type is a union, each term of the union has a concrete +// underlying type, and no terms may be removed without changing the type set +// of the interface +func NormalizeInterface(iface *types.Interface) (*types.Interface, error) { + var methods []*types.Func + for i := 0; i < iface.NumMethods(); i++ { + methods = append(methods, iface.Method(i)) + } + var embeddeds []types.Type + tset, err := computeTermSet(iface, make(map[types.Type]*termSet), 0) + if err != nil { + return nil, err + } + switch { + case tset.terms.isEmpty(): + // Special case: as documented + return nil, nil + + case tset.terms.isAll(): + // No embeddeds. + + case len(tset.terms) == 1: + if !tset.terms[0].tilde { + embeddeds = append(embeddeds, tset.terms[0].typ) + break + } + fallthrough + default: + var terms []*Term + for _, term := range tset.terms { + terms = append(terms, NewTerm(term.tilde, term.typ)) + } + embeddeds = append(embeddeds, NewUnion(terms)) + } + + return types.NewInterfaceType(methods, embeddeds), nil +} + +var ErrEmptyTypeSet = errors.New("empty type set") + +// StructuralTerms returns the normalized structural type restrictions of a +// type, if any. For types that are not type parameters, it returns term slice +// containing a single non-tilde term holding the given type. For type +// parameters, it returns the normalized term list of the type parameter's +// constraint. See NormalizeInterface for more information on the normal form +// of a constraint interface. +// +// StructuralTerms returns an error if the structural term list cannot be +// computed. If the type set of typ is empty, it returns ErrEmptyTypeSet. +func StructuralTerms(typ types.Type) ([]*Term, error) { + switch typ := typ.(type) { + case *TypeParam: + iface, _ := typ.Constraint().(*types.Interface) + if iface == nil { + return nil, fmt.Errorf("constraint is %T, not *types.Interface", typ) + } + tset, err := computeTermSet(iface, make(map[types.Type]*termSet), 0) + if err != nil { + return nil, err + } + if tset.terms.isEmpty() { + return nil, ErrEmptyTypeSet + } + if tset.terms.isAll() { + return nil, nil + } + var terms []*Term + for _, term := range tset.terms { + terms = append(terms, NewTerm(term.tilde, term.typ)) + } + return terms, nil + default: + return []*Term{NewTerm(false, typ)}, nil + } +} + +// A termSet holds the normalized set of terms for a given type. +// +// The name termSet is intentionally distinct from 'type set': a type set is +// all types that implement a type (and includes method restrictions), whereas +// a term set just represents the structural restrictions on a type. +type termSet struct { + complete bool + terms termlist +} + +func indentf(depth int, format string, args ...interface{}) { + fmt.Fprintf(os.Stderr, strings.Repeat(".", depth)+format+"\n", args...) +} + +func computeTermSet(t types.Type, seen map[types.Type]*termSet, depth int) (res *termSet, err error) { + if t == nil { + panic("nil type") + } + + if debug { + indentf(depth, "%s", t.String()) + defer func() { + if err != nil { + indentf(depth, "=> %s", err) + } else { + indentf(depth, "=> %s", res.terms.String()) + } + }() + } + + const maxTermCount = 100 + if tset, ok := seen[t]; ok { + if !tset.complete { + return nil, fmt.Errorf("cycle detected in the declaration of %s", t) + } + return tset, nil + } + + // Mark the current type as seen to avoid infinite recursion. + tset := new(termSet) + defer func() { + tset.complete = true + }() + seen[t] = tset + + switch u := t.Underlying().(type) { + case *types.Interface: + // The term set of an interface is the intersection of the term sets of its + // embedded types. + tset.terms = allTermlist + for i := 0; i < u.NumEmbeddeds(); i++ { + embedded := u.EmbeddedType(i) + if _, ok := embedded.Underlying().(*TypeParam); ok { + return nil, fmt.Errorf("invalid embedded type %T", embedded) + } + tset2, err := computeTermSet(embedded, seen, depth+1) + if err != nil { + return nil, err + } + tset.terms = tset.terms.intersect(tset2.terms) + } + case *Union: + // The term set of a union is the union of term sets of its terms. + tset.terms = nil + for i := 0; i < u.Len(); i++ { + t := u.Term(i) + var terms termlist + switch t.Type().Underlying().(type) { + case *types.Interface: + tset2, err := computeTermSet(t.Type(), seen, depth+1) + if err != nil { + return nil, err + } + terms = tset2.terms + case *TypeParam, *Union: + // A stand-alone type parameter or union is not permitted as union + // term. + return nil, fmt.Errorf("invalid union term %T", t) + default: + if t.Type() == types.Typ[types.Invalid] { + continue + } + terms = termlist{{t.Tilde(), t.Type()}} + } + tset.terms = tset.terms.union(terms) + if len(tset.terms) > maxTermCount { + return nil, fmt.Errorf("exceeded max term count %d", maxTermCount) + } + } + case *TypeParam: + panic("unreachable") + default: + // For all other types, the term set is just a single non-tilde term + // holding the type itself. + if u != types.Typ[types.Invalid] { + tset.terms = termlist{{false, t}} + } + } + return tset, nil +} + +// under is a facade for the go/types internal function of the same name. It is +// used by typeterm.go. +func under(t types.Type) types.Type { + return t.Underlying() +} diff --git a/src/cmd/vendor/golang.org/x/tools/internal/typeparams/termlist.go b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/termlist.go new file mode 100644 index 0000000000..10857d504c --- /dev/null +++ b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/termlist.go @@ -0,0 +1,172 @@ +// Copyright 2021 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. + +// Code generated by copytermlist.go DO NOT EDIT. + +package typeparams + +import ( + "bytes" + "go/types" +) + +// A termlist represents the type set represented by the union +// t1 ∪ y2 ∪ ... tn of the type sets of the terms t1 to tn. +// A termlist is in normal form if all terms are disjoint. +// termlist operations don't require the operands to be in +// normal form. +type termlist []*term + +// allTermlist represents the set of all types. +// It is in normal form. +var allTermlist = termlist{new(term)} + +// String prints the termlist exactly (without normalization). +func (xl termlist) String() string { + if len(xl) == 0 { + return "∅" + } + var buf bytes.Buffer + for i, x := range xl { + if i > 0 { + buf.WriteString(" ∪ ") + } + buf.WriteString(x.String()) + } + return buf.String() +} + +// isEmpty reports whether the termlist xl represents the empty set of types. +func (xl termlist) isEmpty() bool { + // If there's a non-nil term, the entire list is not empty. + // If the termlist is in normal form, this requires at most + // one iteration. + for _, x := range xl { + if x != nil { + return false + } + } + return true +} + +// isAll reports whether the termlist xl represents the set of all types. +func (xl termlist) isAll() bool { + // If there's a 𝓤 term, the entire list is 𝓤. + // If the termlist is in normal form, this requires at most + // one iteration. + for _, x := range xl { + if x != nil && x.typ == nil { + return true + } + } + return false +} + +// norm returns the normal form of xl. +func (xl termlist) norm() termlist { + // Quadratic algorithm, but good enough for now. + // TODO(gri) fix asymptotic performance + used := make([]bool, len(xl)) + var rl termlist + for i, xi := range xl { + if xi == nil || used[i] { + continue + } + for j := i + 1; j < len(xl); j++ { + xj := xl[j] + if xj == nil || used[j] { + continue + } + if u1, u2 := xi.union(xj); u2 == nil { + // If we encounter a 𝓤 term, the entire list is 𝓤. + // Exit early. + // (Note that this is not just an optimization; + // if we continue, we may end up with a 𝓤 term + // and other terms and the result would not be + // in normal form.) + if u1.typ == nil { + return allTermlist + } + xi = u1 + used[j] = true // xj is now unioned into xi - ignore it in future iterations + } + } + rl = append(rl, xi) + } + return rl +} + +// If the type set represented by xl is specified by a single (non-𝓤) term, +// structuralType returns that type. Otherwise it returns nil. +func (xl termlist) structuralType() types.Type { + if nl := xl.norm(); len(nl) == 1 { + return nl[0].typ // if nl.isAll() then typ is nil, which is ok + } + return nil +} + +// union returns the union xl ∪ yl. +func (xl termlist) union(yl termlist) termlist { + return append(xl, yl...).norm() +} + +// intersect returns the intersection xl ∩ yl. +func (xl termlist) intersect(yl termlist) termlist { + if xl.isEmpty() || yl.isEmpty() { + return nil + } + + // Quadratic algorithm, but good enough for now. + // TODO(gri) fix asymptotic performance + var rl termlist + for _, x := range xl { + for _, y := range yl { + if r := x.intersect(y); r != nil { + rl = append(rl, r) + } + } + } + return rl.norm() +} + +// equal reports whether xl and yl represent the same type set. +func (xl termlist) equal(yl termlist) bool { + // TODO(gri) this should be more efficient + return xl.subsetOf(yl) && yl.subsetOf(xl) +} + +// includes reports whether t ∈ xl. +func (xl termlist) includes(t types.Type) bool { + for _, x := range xl { + if x.includes(t) { + return true + } + } + return false +} + +// supersetOf reports whether y ⊆ xl. +func (xl termlist) supersetOf(y *term) bool { + for _, x := range xl { + if y.subsetOf(x) { + return true + } + } + return false +} + +// subsetOf reports whether xl ⊆ yl. +func (xl termlist) subsetOf(yl termlist) bool { + if yl.isEmpty() { + return xl.isEmpty() + } + + // each term x of xl must be a subset of yl + for _, x := range xl { + if !yl.supersetOf(x) { + return false // x is not a subset yl + } + } + return true +} diff --git a/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeparams_go117.go b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeparams_go117.go index d22899d29e..6ad3a43a2c 100644 --- a/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeparams_go117.go +++ b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeparams_go117.go @@ -132,6 +132,15 @@ func IsMethodSet(*types.Interface) bool { return true } +// IsImplicit returns false, as no interfaces are implicit at this Go version. +func IsImplicit(*types.Interface) bool { + return false +} + +// MarkImplicit does nothing, because this Go version does not have implicit +// interfaces. +func MarkImplicit(*types.Interface) {} + // ForNamed returns an empty type parameter list, as type parameters are not // supported at this Go version. func ForNamed(*types.Named) *TypeParamList { @@ -155,19 +164,25 @@ func NamedTypeOrigin(named *types.Named) types.Type { return named } -// Term is a placeholder type, as type parameters are not supported at this Go -// version. Its methods panic on use. -type Term struct{} +// Term holds information about a structural type restriction. +type Term struct { + tilde bool + typ types.Type +} -func (*Term) Tilde() bool { unsupported(); return false } -func (*Term) Type() types.Type { unsupported(); return nil } -func (*Term) String() string { unsupported(); return "" } -func (*Term) Underlying() types.Type { unsupported(); return nil } +func (m *Term) Tilde() bool { return m.tilde } +func (m *Term) Type() types.Type { return m.typ } +func (m *Term) String() string { + pre := "" + if m.tilde { + pre = "~" + } + return pre + m.typ.String() +} // NewTerm is unsupported at this Go version, and panics. func NewTerm(tilde bool, typ types.Type) *Term { - unsupported() - return nil + return &Term{tilde, typ} } // Union is a placeholder type, as type parameters are not supported at this Go @@ -186,9 +201,16 @@ func NewUnion(terms []*Term) *Union { // InitInstanceInfo is a noop at this Go version. func InitInstanceInfo(*types.Info) {} -// GetInstance returns nothing, as type parameters are not supported at this Go -// version. -func GetInstance(*types.Info, *ast.Ident) (*TypeList, types.Type) { return nil, nil } +// Instance is a placeholder type, as type parameters are not supported at this +// Go version. +type Instance struct { + TypeArgs *TypeList + Type types.Type +} + +// GetInstances returns a nil map, as type parameters are not supported at this +// Go version. +func GetInstances(info *types.Info) map[*ast.Ident]Instance { return nil } // Context is a placeholder type, as type parameters are not supported at // this Go version. diff --git a/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeparams_go118.go b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeparams_go118.go index a252183411..e45896fb02 100644 --- a/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeparams_go118.go +++ b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeparams_go118.go @@ -125,6 +125,16 @@ func IsMethodSet(iface *types.Interface) bool { return iface.IsMethodSet() } +// IsImplicit calls iface.IsImplicit(). +func IsImplicit(iface *types.Interface) bool { + return iface.IsImplicit() +} + +// MarkImplicit calls iface.MarkImplicit(). +func MarkImplicit(iface *types.Interface) { + iface.MarkImplicit() +} + // ForNamed extracts the (possibly empty) type parameter object list from // named. func ForNamed(named *types.Named) *TypeParamList { @@ -169,15 +179,12 @@ func InitInstanceInfo(info *types.Info) { info.Instances = make(map[*ast.Ident]types.Instance) } -// GetInstance extracts information about the instantiation occurring at the -// identifier id. id should be the identifier denoting a parameterized type or -// function in an instantiation expression or function call. -func GetInstance(info *types.Info, id *ast.Ident) (*TypeList, types.Type) { - if info.Instances != nil { - inf := info.Instances[id] - return inf.TypeArgs, inf.Type - } - return nil, nil +// Instance is an alias for types.Instance. +type Instance = types.Instance + +// GetInstances returns info.Instances. +func GetInstances(info *types.Info) map[*ast.Ident]Instance { + return info.Instances } // Context is an alias for types.Context. diff --git a/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeterm.go b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeterm.go new file mode 100644 index 0000000000..7ddee28d98 --- /dev/null +++ b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeterm.go @@ -0,0 +1,170 @@ +// Copyright 2021 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. + +// Code generated by copytermlist.go DO NOT EDIT. + +package typeparams + +import "go/types" + +// A term describes elementary type sets: +// +// ∅: (*term)(nil) == ∅ // set of no types (empty set) +// 𝓤: &term{} == 𝓤 // set of all types (𝓤niverse) +// T: &term{false, T} == {T} // set of type T +// ~t: &term{true, t} == {t' | under(t') == t} // set of types with underlying type t +// +type term struct { + tilde bool // valid if typ != nil + typ types.Type +} + +func (x *term) String() string { + switch { + case x == nil: + return "∅" + case x.typ == nil: + return "𝓤" + case x.tilde: + return "~" + x.typ.String() + default: + return x.typ.String() + } +} + +// equal reports whether x and y represent the same type set. +func (x *term) equal(y *term) bool { + // easy cases + switch { + case x == nil || y == nil: + return x == y + case x.typ == nil || y.typ == nil: + return x.typ == y.typ + } + // ∅ ⊂ x, y ⊂ 𝓤 + + return x.tilde == y.tilde && types.Identical(x.typ, y.typ) +} + +// union returns the union x ∪ y: zero, one, or two non-nil terms. +func (x *term) union(y *term) (_, _ *term) { + // easy cases + switch { + case x == nil && y == nil: + return nil, nil // ∅ ∪ ∅ == ∅ + case x == nil: + return y, nil // ∅ ∪ y == y + case y == nil: + return x, nil // x ∪ ∅ == x + case x.typ == nil: + return x, nil // 𝓤 ∪ y == 𝓤 + case y.typ == nil: + return y, nil // x ∪ 𝓤 == 𝓤 + } + // ∅ ⊂ x, y ⊂ 𝓤 + + if x.disjoint(y) { + return x, y // x ∪ y == (x, y) if x ∩ y == ∅ + } + // x.typ == y.typ + + // ~t ∪ ~t == ~t + // ~t ∪ T == ~t + // T ∪ ~t == ~t + // T ∪ T == T + if x.tilde || !y.tilde { + return x, nil + } + return y, nil +} + +// intersect returns the intersection x ∩ y. +func (x *term) intersect(y *term) *term { + // easy cases + switch { + case x == nil || y == nil: + return nil // ∅ ∩ y == ∅ and ∩ ∅ == ∅ + case x.typ == nil: + return y // 𝓤 ∩ y == y + case y.typ == nil: + return x // x ∩ 𝓤 == x + } + // ∅ ⊂ x, y ⊂ 𝓤 + + if x.disjoint(y) { + return nil // x ∩ y == ∅ if x ∩ y == ∅ + } + // x.typ == y.typ + + // ~t ∩ ~t == ~t + // ~t ∩ T == T + // T ∩ ~t == T + // T ∩ T == T + if !x.tilde || y.tilde { + return x + } + return y +} + +// includes reports whether t ∈ x. +func (x *term) includes(t types.Type) bool { + // easy cases + switch { + case x == nil: + return false // t ∈ ∅ == false + case x.typ == nil: + return true // t ∈ 𝓤 == true + } + // ∅ ⊂ x ⊂ 𝓤 + + u := t + if x.tilde { + u = under(u) + } + return types.Identical(x.typ, u) +} + +// subsetOf reports whether x ⊆ y. +func (x *term) subsetOf(y *term) bool { + // easy cases + switch { + case x == nil: + return true // ∅ ⊆ y == true + case y == nil: + return false // x ⊆ ∅ == false since x != ∅ + case y.typ == nil: + return true // x ⊆ 𝓤 == true + case x.typ == nil: + return false // 𝓤 ⊆ y == false since y != 𝓤 + } + // ∅ ⊂ x, y ⊂ 𝓤 + + if x.disjoint(y) { + return false // x ⊆ y == false if x ∩ y == ∅ + } + // x.typ == y.typ + + // ~t ⊆ ~t == true + // ~t ⊆ T == false + // T ⊆ ~t == true + // T ⊆ T == true + return !x.tilde || y.tilde +} + +// disjoint reports whether x ∩ y == ∅. +// x.typ and y.typ must not be nil. +func (x *term) disjoint(y *term) bool { + if debug && (x.typ == nil || y.typ == nil) { + panic("invalid argument(s)") + } + ux := x.typ + if y.tilde { + ux = under(ux) + } + uy := y.typ + if x.tilde { + uy = under(uy) + } + return !types.Identical(ux, uy) +} diff --git a/src/cmd/vendor/modules.txt b/src/cmd/vendor/modules.txt index e0e116a634..ecb170d290 100644 --- a/src/cmd/vendor/modules.txt +++ b/src/cmd/vendor/modules.txt @@ -51,7 +51,7 @@ golang.org/x/sys/windows # golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b ## explicit; go 1.17 golang.org/x/term -# golang.org/x/tools v0.1.8-0.20211011152358-18fa84021695 +# golang.org/x/tools v0.1.8-0.20211025211149-f916b54a1784 ## explicit; go 1.17 golang.org/x/tools/cover golang.org/x/tools/go/analysis From 283d8a3d53ac1c7e1d7e297497480bf0071b6300 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Mon, 25 Oct 2021 23:00:56 +0700 Subject: [PATCH 163/406] all: use reflect.{Pointer,PointerTo} Updates #47651 Updates #48665 Change-Id: I69a87b45a5cad7a07fbd855040cd9935cf874554 Reviewed-on: https://go-review.googlesource.com/c/go/+/358454 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- src/cmd/fix/cftype.go | 2 +- src/cmd/fix/typecheck.go | 2 +- src/cmd/gofmt/rewrite.go | 2 +- src/database/sql/convert.go | 6 ++-- src/database/sql/driver/types.go | 4 +-- src/encoding/asn1/asn1.go | 4 +-- src/encoding/binary/binary.go | 2 +- src/encoding/gob/decode.go | 14 ++++---- src/encoding/gob/decoder.go | 4 +-- src/encoding/gob/encode.go | 8 ++--- src/encoding/gob/encoder.go | 2 +- src/encoding/gob/type.go | 12 +++---- src/encoding/gob/type_test.go | 2 +- src/encoding/json/decode.go | 18 +++++----- src/encoding/json/decode_test.go | 2 +- src/encoding/json/encode.go | 24 ++++++------- src/encoding/xml/marshal.go | 10 +++--- src/encoding/xml/read.go | 10 +++--- src/encoding/xml/typeinfo.go | 6 ++-- src/flag/flag.go | 2 +- src/fmt/print.go | 6 ++-- src/fmt/scan.go | 2 +- src/fmt/scan_test.go | 4 +-- src/go/ast/print.go | 4 +-- src/html/template/content.go | 6 ++-- src/html/template/js.go | 2 +- src/internal/fmtsort/sort.go | 2 +- src/internal/reflectlite/tostring_test.go | 2 +- src/net/rpc/server.go | 8 ++--- src/reflect/abi.go | 2 +- src/reflect/all_test.go | 32 ++++++++--------- src/reflect/deepequal.go | 8 ++--- src/reflect/tostring_test.go | 2 +- src/reflect/type.go | 2 +- src/reflect/value.go | 44 +++++++++++------------ src/reflect/visiblefields.go | 2 +- src/runtime/gc_test.go | 2 +- src/testing/quick/quick.go | 2 +- src/text/template/exec.go | 18 +++++----- test/fixedbugs/issue32901.dir/main.go | 9 +++-- test/reflectmethod7.go | 2 +- 41 files changed, 150 insertions(+), 147 deletions(-) diff --git a/src/cmd/fix/cftype.go b/src/cmd/fix/cftype.go index b47b06682a..3d292bdeba 100644 --- a/src/cmd/fix/cftype.go +++ b/src/cmd/fix/cftype.go @@ -63,7 +63,7 @@ func typefix(f *ast.File, badType func(string) bool) bool { return } v := reflect.ValueOf(n) - if v.Type().Kind() != reflect.Ptr { + if v.Type().Kind() != reflect.Pointer { return } if v.IsNil() { diff --git a/src/cmd/fix/typecheck.go b/src/cmd/fix/typecheck.go index 8c4beb4b65..b7ec72e116 100644 --- a/src/cmd/fix/typecheck.go +++ b/src/cmd/fix/typecheck.go @@ -383,7 +383,7 @@ func typecheck1(cfg *TypeConfig, f interface{}, typeof map[interface{}]string, a if n == nil { return } - if false && reflect.TypeOf(n).Kind() == reflect.Ptr { // debugging trace + if false && reflect.TypeOf(n).Kind() == reflect.Pointer { // debugging trace defer func() { if t := typeof[n]; t != "" { pos := fset.Position(n.(ast.Node).Pos()) diff --git a/src/cmd/gofmt/rewrite.go b/src/cmd/gofmt/rewrite.go index 0e736e6132..a98c6a0cd9 100644 --- a/src/cmd/gofmt/rewrite.go +++ b/src/cmd/gofmt/rewrite.go @@ -292,7 +292,7 @@ func subst(m map[string]reflect.Value, pattern reflect.Value, pos reflect.Value) } return v - case reflect.Ptr: + case reflect.Pointer: v := reflect.New(p.Type()).Elem() if elem := p.Elem(); elem.IsValid() { v.Set(subst(m, elem, pos).Addr()) diff --git a/src/database/sql/convert.go b/src/database/sql/convert.go index b966ef970c..c0997b7fc5 100644 --- a/src/database/sql/convert.go +++ b/src/database/sql/convert.go @@ -386,7 +386,7 @@ func convertAssignRows(dest, src interface{}, rows *Rows) error { } dpv := reflect.ValueOf(dest) - if dpv.Kind() != reflect.Ptr { + if dpv.Kind() != reflect.Pointer { return errors.New("destination not a pointer") } if dpv.IsNil() { @@ -419,7 +419,7 @@ func convertAssignRows(dest, src interface{}, rows *Rows) error { // This also allows scanning into user defined types such as "type Int int64". // For symmetry, also check for string destination types. switch dv.Kind() { - case reflect.Ptr: + case reflect.Pointer: if src == nil { dv.Set(reflect.Zero(dv.Type())) return nil @@ -551,7 +551,7 @@ var valuerReflectType = reflect.TypeOf((*driver.Valuer)(nil)).Elem() // // This function is mirrored in the database/sql/driver package. func callValuerValue(vr driver.Valuer) (v driver.Value, err error) { - if rv := reflect.ValueOf(vr); rv.Kind() == reflect.Ptr && + if rv := reflect.ValueOf(vr); rv.Kind() == reflect.Pointer && rv.IsNil() && rv.Type().Elem().Implements(valuerReflectType) { return nil, nil diff --git a/src/database/sql/driver/types.go b/src/database/sql/driver/types.go index 24c3a45483..3337c2e0bc 100644 --- a/src/database/sql/driver/types.go +++ b/src/database/sql/driver/types.go @@ -225,7 +225,7 @@ var valuerReflectType = reflect.TypeOf((*Valuer)(nil)).Elem() // // This function is mirrored in the database/sql package. func callValuerValue(vr Valuer) (v Value, err error) { - if rv := reflect.ValueOf(vr); rv.Kind() == reflect.Ptr && + if rv := reflect.ValueOf(vr); rv.Kind() == reflect.Pointer && rv.IsNil() && rv.Type().Elem().Implements(valuerReflectType) { return nil, nil @@ -256,7 +256,7 @@ func (defaultConverter) ConvertValue(v interface{}) (Value, error) { rv := reflect.ValueOf(v) switch rv.Kind() { - case reflect.Ptr: + case reflect.Pointer: // indirect pointers if rv.IsNil() { return nil, nil diff --git a/src/encoding/asn1/asn1.go b/src/encoding/asn1/asn1.go index cffc06dc9c..d0e1c6b176 100644 --- a/src/encoding/asn1/asn1.go +++ b/src/encoding/asn1/asn1.go @@ -1101,7 +1101,7 @@ func (e *invalidUnmarshalError) Error() string { return "asn1: Unmarshal recipient value is nil" } - if e.Type.Kind() != reflect.Ptr { + if e.Type.Kind() != reflect.Pointer { return "asn1: Unmarshal recipient value is non-pointer " + e.Type.String() } return "asn1: Unmarshal recipient value is nil " + e.Type.String() @@ -1111,7 +1111,7 @@ func (e *invalidUnmarshalError) Error() string { // top-level element. The form of the params is the same as the field tags. func UnmarshalWithParams(b []byte, val interface{}, params string) (rest []byte, err error) { v := reflect.ValueOf(val) - if v.Kind() != reflect.Ptr || v.IsNil() { + if v.Kind() != reflect.Pointer || v.IsNil() { return nil, &invalidUnmarshalError{reflect.TypeOf(val)} } offset, err := parseField(v.Elem(), b, 0, parseFieldParameters(params)) diff --git a/src/encoding/binary/binary.go b/src/encoding/binary/binary.go index a31149979d..52417a7933 100644 --- a/src/encoding/binary/binary.go +++ b/src/encoding/binary/binary.go @@ -243,7 +243,7 @@ func Read(r io.Reader, order ByteOrder, data interface{}) error { v := reflect.ValueOf(data) size := -1 switch v.Kind() { - case reflect.Ptr: + case reflect.Pointer: v = v.Elem() size = dataSize(v) case reflect.Slice: diff --git a/src/encoding/gob/decode.go b/src/encoding/gob/decode.go index f92556f8ab..34f302a5cf 100644 --- a/src/encoding/gob/decode.go +++ b/src/encoding/gob/decode.go @@ -228,7 +228,7 @@ func ignoreTwoUints(i *decInstr, state *decoderState, v reflect.Value) { // The callers to the individual decoders are expected to have used decAlloc. // The individual decoders don't need to it. func decAlloc(v reflect.Value) reflect.Value { - for v.Kind() == reflect.Ptr { + for v.Kind() == reflect.Pointer { if v.IsNil() { v.Set(reflect.New(v.Type().Elem())) } @@ -464,7 +464,7 @@ func (dec *Decoder) decodeStruct(engine *decEngine, value reflect.Value) { if instr.index != nil { // Otherwise the field is unknown to us and instr.op is an ignore op. field = value.FieldByIndex(instr.index) - if field.Kind() == reflect.Ptr { + if field.Kind() == reflect.Pointer { field = decAlloc(field) } } @@ -518,7 +518,7 @@ func (dec *Decoder) decodeArrayHelper(state *decoderState, value reflect.Value, return } instr := &decInstr{elemOp, 0, nil, ovfl} - isPtr := value.Type().Elem().Kind() == reflect.Ptr + isPtr := value.Type().Elem().Kind() == reflect.Pointer for i := 0; i < length; i++ { if state.b.Len() == 0 { errorf("decoding array or slice: length exceeds input size (%d elements)", length) @@ -561,8 +561,8 @@ func (dec *Decoder) decodeMap(mtyp reflect.Type, state *decoderState, value refl if value.IsNil() { value.Set(reflect.MakeMapWithSize(mtyp, n)) } - keyIsPtr := mtyp.Key().Kind() == reflect.Ptr - elemIsPtr := mtyp.Elem().Kind() == reflect.Ptr + keyIsPtr := mtyp.Key().Kind() == reflect.Pointer + elemIsPtr := mtyp.Elem().Kind() == reflect.Pointer keyInstr := &decInstr{keyOp, 0, nil, ovfl} elemInstr := &decInstr{elemOp, 0, nil, ovfl} keyP := reflect.New(mtyp.Key()) @@ -945,7 +945,7 @@ func (dec *Decoder) decIgnoreOpFor(wireId typeId, inProgress map[typeId]*decOp) func (dec *Decoder) gobDecodeOpFor(ut *userTypeInfo) *decOp { rcvrType := ut.user if ut.decIndir == -1 { - rcvrType = reflect.PtrTo(rcvrType) + rcvrType = reflect.PointerTo(rcvrType) } else if ut.decIndir > 0 { for i := int8(0); i < ut.decIndir; i++ { rcvrType = rcvrType.Elem() @@ -954,7 +954,7 @@ func (dec *Decoder) gobDecodeOpFor(ut *userTypeInfo) *decOp { var op decOp op = func(i *decInstr, state *decoderState, value reflect.Value) { // We now have the base type. We need its address if the receiver is a pointer. - if value.Kind() != reflect.Ptr && rcvrType.Kind() == reflect.Ptr { + if value.Kind() != reflect.Pointer && rcvrType.Kind() == reflect.Pointer { value = value.Addr() } state.dec.decodeGobDecoder(ut, state, value) diff --git a/src/encoding/gob/decoder.go b/src/encoding/gob/decoder.go index 5e4ed5a7d7..96e215eb8c 100644 --- a/src/encoding/gob/decoder.go +++ b/src/encoding/gob/decoder.go @@ -193,7 +193,7 @@ func (dec *Decoder) Decode(e interface{}) error { value := reflect.ValueOf(e) // If e represents a value as opposed to a pointer, the answer won't // get back to the caller. Make sure it's a pointer. - if value.Type().Kind() != reflect.Ptr { + if value.Type().Kind() != reflect.Pointer { dec.err = errors.New("gob: attempt to decode into a non-pointer") return dec.err } @@ -208,7 +208,7 @@ func (dec *Decoder) Decode(e interface{}) error { // does not modify v. func (dec *Decoder) DecodeValue(v reflect.Value) error { if v.IsValid() { - if v.Kind() == reflect.Ptr && !v.IsNil() { + if v.Kind() == reflect.Pointer && !v.IsNil() { // That's okay, we'll store through the pointer. } else if !v.CanSet() { return errors.New("gob: DecodeValue of unassignable value") diff --git a/src/encoding/gob/encode.go b/src/encoding/gob/encode.go index f1f5f3862d..e49b452f6c 100644 --- a/src/encoding/gob/encode.go +++ b/src/encoding/gob/encode.go @@ -279,7 +279,7 @@ func valid(v reflect.Value) bool { switch v.Kind() { case reflect.Invalid: return false - case reflect.Ptr: + case reflect.Pointer: return !v.IsNil() } return true @@ -386,7 +386,7 @@ func (enc *Encoder) encodeInterface(b *encBuffer, iv reflect.Value) { // Gobs can encode nil interface values but not typed interface // values holding nil pointers, since nil pointers point to no value. elem := iv.Elem() - if elem.Kind() == reflect.Ptr && elem.IsNil() { + if elem.Kind() == reflect.Pointer && elem.IsNil() { errorf("gob: cannot encode nil pointer of type %s inside interface", iv.Elem().Type()) } state := enc.newEncoderState(b) @@ -446,7 +446,7 @@ func isZero(val reflect.Value) bool { return !val.Bool() case reflect.Complex64, reflect.Complex128: return val.Complex() == 0 - case reflect.Chan, reflect.Func, reflect.Interface, reflect.Ptr: + case reflect.Chan, reflect.Func, reflect.Interface, reflect.Pointer: return val.IsNil() case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return val.Int() == 0 @@ -600,7 +600,7 @@ func encOpFor(rt reflect.Type, inProgress map[reflect.Type]*encOp, building map[ func gobEncodeOpFor(ut *userTypeInfo) (*encOp, int) { rt := ut.user if ut.encIndir == -1 { - rt = reflect.PtrTo(rt) + rt = reflect.PointerTo(rt) } else if ut.encIndir > 0 { for i := int8(0); i < ut.encIndir; i++ { rt = rt.Elem() diff --git a/src/encoding/gob/encoder.go b/src/encoding/gob/encoder.go index 53e2cace16..32865a7ede 100644 --- a/src/encoding/gob/encoder.go +++ b/src/encoding/gob/encoder.go @@ -219,7 +219,7 @@ func (enc *Encoder) EncodeValue(value reflect.Value) error { if value.Kind() == reflect.Invalid { return errors.New("gob: cannot encode nil value") } - if value.Kind() == reflect.Ptr && value.IsNil() { + if value.Kind() == reflect.Pointer && value.IsNil() { panic("gob: cannot encode nil pointer of type " + value.Type().String()) } diff --git a/src/encoding/gob/type.go b/src/encoding/gob/type.go index 31c0ef7af1..412a348137 100644 --- a/src/encoding/gob/type.go +++ b/src/encoding/gob/type.go @@ -61,7 +61,7 @@ func validUserType(rt reflect.Type) (*userTypeInfo, error) { slowpoke := ut.base // walks half as fast as ut.base for { pt := ut.base - if pt.Kind() != reflect.Ptr { + if pt.Kind() != reflect.Pointer { break } ut.base = pt.Elem() @@ -126,7 +126,7 @@ func implementsInterface(typ, gobEncDecType reflect.Type) (success bool, indir i if rt.Implements(gobEncDecType) { return true, indir } - if p := rt; p.Kind() == reflect.Ptr { + if p := rt; p.Kind() == reflect.Pointer { indir++ if indir > 100 { // insane number of indirections return false, 0 @@ -137,9 +137,9 @@ func implementsInterface(typ, gobEncDecType reflect.Type) (success bool, indir i break } // No luck yet, but if this is a base type (non-pointer), the pointer might satisfy. - if typ.Kind() != reflect.Ptr { + if typ.Kind() != reflect.Pointer { // Not a pointer, but does the pointer work? - if reflect.PtrTo(typ).Implements(gobEncDecType) { + if reflect.PointerTo(typ).Implements(gobEncDecType) { return true, -1 } } @@ -569,7 +569,7 @@ func isSent(field *reflect.StructField) bool { // If the field is a chan or func or pointer thereto, don't send it. // That is, treat it like an unexported field. typ := field.Type - for typ.Kind() == reflect.Ptr { + for typ.Kind() == reflect.Pointer { typ = typ.Elem() } if typ.Kind() == reflect.Chan || typ.Kind() == reflect.Func { @@ -842,7 +842,7 @@ func Register(value interface{}) { // Dereference one pointer looking for a named type. star := "" if rt.Name() == "" { - if pt := rt; pt.Kind() == reflect.Ptr { + if pt := rt; pt.Kind() == reflect.Pointer { star = "*" // NOTE: The following line should be rt = pt.Elem() to implement // what the comment above claims, but fixing it would break compatibility diff --git a/src/encoding/gob/type_test.go b/src/encoding/gob/type_test.go index 934270eedd..fa3e802d4e 100644 --- a/src/encoding/gob/type_test.go +++ b/src/encoding/gob/type_test.go @@ -184,7 +184,7 @@ func TestRegistrationNaming(t *testing.T) { t.Errorf("nameToConcreteType[%q] = %v, want %v", tc.name, ct, tct) } // concreteTypeToName is keyed off the base type. - if tct.Kind() == reflect.Ptr { + if tct.Kind() == reflect.Pointer { tct = tct.Elem() } if n, _ := concreteTypeToName.Load(tct); n != tc.name { diff --git a/src/encoding/json/decode.go b/src/encoding/json/decode.go index a9917e72c7..df4c5e1a16 100644 --- a/src/encoding/json/decode.go +++ b/src/encoding/json/decode.go @@ -161,7 +161,7 @@ func (e *InvalidUnmarshalError) Error() string { return "json: Unmarshal(nil)" } - if e.Type.Kind() != reflect.Ptr { + if e.Type.Kind() != reflect.Pointer { return "json: Unmarshal(non-pointer " + e.Type.String() + ")" } return "json: Unmarshal(nil " + e.Type.String() + ")" @@ -169,7 +169,7 @@ func (e *InvalidUnmarshalError) Error() string { func (d *decodeState) unmarshal(v interface{}) error { rv := reflect.ValueOf(v) - if rv.Kind() != reflect.Ptr || rv.IsNil() { + if rv.Kind() != reflect.Pointer || rv.IsNil() { return &InvalidUnmarshalError{reflect.TypeOf(v)} } @@ -440,7 +440,7 @@ func indirect(v reflect.Value, decodingNull bool) (Unmarshaler, encoding.TextUnm // If v is a named type and is addressable, // start with its address, so that if the type has pointer methods, // we find them. - if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() { + if v.Kind() != reflect.Pointer && v.Type().Name() != "" && v.CanAddr() { haveAddr = true v = v.Addr() } @@ -449,14 +449,14 @@ func indirect(v reflect.Value, decodingNull bool) (Unmarshaler, encoding.TextUnm // usefully addressable. if v.Kind() == reflect.Interface && !v.IsNil() { e := v.Elem() - if e.Kind() == reflect.Ptr && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Ptr) { + if e.Kind() == reflect.Pointer && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Pointer) { haveAddr = false v = e continue } } - if v.Kind() != reflect.Ptr { + if v.Kind() != reflect.Pointer { break } @@ -641,7 +641,7 @@ func (d *decodeState) object(v reflect.Value) error { reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: default: - if !reflect.PtrTo(t.Key()).Implements(textUnmarshalerType) { + if !reflect.PointerTo(t.Key()).Implements(textUnmarshalerType) { d.saveError(&UnmarshalTypeError{Value: "object", Type: t, Offset: int64(d.off)}) d.skip() return nil @@ -717,7 +717,7 @@ func (d *decodeState) object(v reflect.Value) error { subv = v destring = f.quoted for _, i := range f.index { - if subv.Kind() == reflect.Ptr { + if subv.Kind() == reflect.Pointer { if subv.IsNil() { // If a struct embeds a pointer to an unexported type, // it is not possible to set a newly allocated value @@ -782,7 +782,7 @@ func (d *decodeState) object(v reflect.Value) error { kt := t.Key() var kv reflect.Value switch { - case reflect.PtrTo(kt).Implements(textUnmarshalerType): + case reflect.PointerTo(kt).Implements(textUnmarshalerType): kv = reflect.New(kt) if err := d.literalStore(item, kv, true); err != nil { return err @@ -907,7 +907,7 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool break } switch v.Kind() { - case reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice: + case reflect.Interface, reflect.Pointer, reflect.Map, reflect.Slice: v.Set(reflect.Zero(v.Type())) // otherwise, ignore null for primitives/string } diff --git a/src/encoding/json/decode_test.go b/src/encoding/json/decode_test.go index 219e845c7b..96bf9fb5ff 100644 --- a/src/encoding/json/decode_test.go +++ b/src/encoding/json/decode_test.go @@ -1103,7 +1103,7 @@ func TestUnmarshal(t *testing.T) { } typ := reflect.TypeOf(tt.ptr) - if typ.Kind() != reflect.Ptr { + if typ.Kind() != reflect.Pointer { t.Errorf("#%d: unmarshalTest.ptr %T is not a pointer type", i, tt.ptr) continue } diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go index e473e615a9..4f40197797 100644 --- a/src/encoding/json/encode.go +++ b/src/encoding/json/encode.go @@ -350,7 +350,7 @@ func isEmptyValue(v reflect.Value) bool { return v.Uint() == 0 case reflect.Float32, reflect.Float64: return v.Float() == 0 - case reflect.Interface, reflect.Ptr: + case reflect.Interface, reflect.Pointer: return v.IsNil() } return false @@ -419,13 +419,13 @@ func newTypeEncoder(t reflect.Type, allowAddr bool) encoderFunc { // Marshaler with a value receiver, then we're better off taking // the address of the value - otherwise we end up with an // allocation as we cast the value to an interface. - if t.Kind() != reflect.Ptr && allowAddr && reflect.PtrTo(t).Implements(marshalerType) { + if t.Kind() != reflect.Pointer && allowAddr && reflect.PointerTo(t).Implements(marshalerType) { return newCondAddrEncoder(addrMarshalerEncoder, newTypeEncoder(t, false)) } if t.Implements(marshalerType) { return marshalerEncoder } - if t.Kind() != reflect.Ptr && allowAddr && reflect.PtrTo(t).Implements(textMarshalerType) { + if t.Kind() != reflect.Pointer && allowAddr && reflect.PointerTo(t).Implements(textMarshalerType) { return newCondAddrEncoder(addrTextMarshalerEncoder, newTypeEncoder(t, false)) } if t.Implements(textMarshalerType) { @@ -455,7 +455,7 @@ func newTypeEncoder(t reflect.Type, allowAddr bool) encoderFunc { return newSliceEncoder(t) case reflect.Array: return newArrayEncoder(t) - case reflect.Ptr: + case reflect.Pointer: return newPtrEncoder(t) default: return unsupportedTypeEncoder @@ -467,7 +467,7 @@ func invalidValueEncoder(e *encodeState, v reflect.Value, _ encOpts) { } func marshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) { - if v.Kind() == reflect.Ptr && v.IsNil() { + if v.Kind() == reflect.Pointer && v.IsNil() { e.WriteString("null") return } @@ -504,7 +504,7 @@ func addrMarshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) { } func textMarshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) { - if v.Kind() == reflect.Ptr && v.IsNil() { + if v.Kind() == reflect.Pointer && v.IsNil() { e.WriteString("null") return } @@ -738,7 +738,7 @@ FieldLoop: // Find the nested struct field by following f.index. fv := v for _, i := range f.index { - if fv.Kind() == reflect.Ptr { + if fv.Kind() == reflect.Pointer { if fv.IsNil() { continue FieldLoop } @@ -893,7 +893,7 @@ func (se sliceEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { func newSliceEncoder(t reflect.Type) encoderFunc { // Byte slices get special treatment; arrays don't. if t.Elem().Kind() == reflect.Uint8 { - p := reflect.PtrTo(t.Elem()) + p := reflect.PointerTo(t.Elem()) if !p.Implements(marshalerType) && !p.Implements(textMarshalerType) { return encodeByteSlice } @@ -989,7 +989,7 @@ func isValidTag(s string) bool { func typeByIndex(t reflect.Type, index []int) reflect.Type { for _, i := range index { - if t.Kind() == reflect.Ptr { + if t.Kind() == reflect.Pointer { t = t.Elem() } t = t.Field(i).Type @@ -1009,7 +1009,7 @@ func (w *reflectWithString) resolve() error { return nil } if tm, ok := w.k.Interface().(encoding.TextMarshaler); ok { - if w.k.Kind() == reflect.Ptr && w.k.IsNil() { + if w.k.Kind() == reflect.Pointer && w.k.IsNil() { return nil } buf, err := tm.MarshalText() @@ -1243,7 +1243,7 @@ func typeFields(t reflect.Type) structFields { sf := f.typ.Field(i) if sf.Anonymous { t := sf.Type - if t.Kind() == reflect.Ptr { + if t.Kind() == reflect.Pointer { t = t.Elem() } if !sf.IsExported() && t.Kind() != reflect.Struct { @@ -1269,7 +1269,7 @@ func typeFields(t reflect.Type) structFields { index[len(f.index)] = i ft := sf.Type - if ft.Name() == "" && ft.Kind() == reflect.Ptr { + if ft.Name() == "" && ft.Kind() == reflect.Pointer { // Follow pointer. ft = ft.Elem() } diff --git a/src/encoding/xml/marshal.go b/src/encoding/xml/marshal.go index a8c8f659ca..1f0eb76341 100644 --- a/src/encoding/xml/marshal.go +++ b/src/encoding/xml/marshal.go @@ -420,7 +420,7 @@ func (p *printer) marshalValue(val reflect.Value, finfo *fieldInfo, startTemplat // Drill into interfaces and pointers. // This can turn into an infinite loop given a cyclic chain, // but it matches the Go 1 behavior. - for val.Kind() == reflect.Interface || val.Kind() == reflect.Ptr { + for val.Kind() == reflect.Interface || val.Kind() == reflect.Pointer { if val.IsNil() { return nil } @@ -603,7 +603,7 @@ func (p *printer) marshalAttr(start *StartElement, name Name, val reflect.Value) // Dereference or skip nil pointer, interface values. switch val.Kind() { - case reflect.Ptr, reflect.Interface: + case reflect.Pointer, reflect.Interface: if val.IsNil() { return nil } @@ -797,7 +797,7 @@ var ddBytes = []byte("--") // This can turn into an infinite loop given a cyclic chain, // but it matches the Go 1 behavior. func indirect(vf reflect.Value) reflect.Value { - for vf.Kind() == reflect.Interface || vf.Kind() == reflect.Ptr { + for vf.Kind() == reflect.Interface || vf.Kind() == reflect.Pointer { if vf.IsNil() { return vf } @@ -946,7 +946,7 @@ func (p *printer) marshalStruct(tinfo *typeInfo, val reflect.Value) error { return err } if len(finfo.parents) > len(s.stack) { - if vf.Kind() != reflect.Ptr && vf.Kind() != reflect.Interface || !vf.IsNil() { + if vf.Kind() != reflect.Pointer && vf.Kind() != reflect.Interface || !vf.IsNil() { if err := s.push(finfo.parents[len(s.stack):]); err != nil { return err } @@ -1055,7 +1055,7 @@ func isEmptyValue(v reflect.Value) bool { return v.Uint() == 0 case reflect.Float32, reflect.Float64: return v.Float() == 0 - case reflect.Interface, reflect.Ptr: + case reflect.Interface, reflect.Pointer: return v.IsNil() } return false diff --git a/src/encoding/xml/read.go b/src/encoding/xml/read.go index ef5df3f7f6..48b0ec055c 100644 --- a/src/encoding/xml/read.go +++ b/src/encoding/xml/read.go @@ -145,7 +145,7 @@ func (d *Decoder) Decode(v interface{}) error { // but also wants to defer to Unmarshal for some elements. func (d *Decoder) DecodeElement(v interface{}, start *StartElement) error { val := reflect.ValueOf(v) - if val.Kind() != reflect.Ptr { + if val.Kind() != reflect.Pointer { return errors.New("non-pointer passed to Unmarshal") } return d.unmarshal(val.Elem(), start) @@ -244,7 +244,7 @@ func (d *Decoder) unmarshalTextInterface(val encoding.TextUnmarshaler) error { // unmarshalAttr unmarshals a single XML attribute into val. func (d *Decoder) unmarshalAttr(val reflect.Value, attr Attr) error { - if val.Kind() == reflect.Ptr { + if val.Kind() == reflect.Pointer { if val.IsNil() { val.Set(reflect.New(val.Type().Elem())) } @@ -324,12 +324,12 @@ func (d *Decoder) unmarshal(val reflect.Value, start *StartElement) error { // usefully addressable. if val.Kind() == reflect.Interface && !val.IsNil() { e := val.Elem() - if e.Kind() == reflect.Ptr && !e.IsNil() { + if e.Kind() == reflect.Pointer && !e.IsNil() { val = e } } - if val.Kind() == reflect.Ptr { + if val.Kind() == reflect.Pointer { if val.IsNil() { val.Set(reflect.New(val.Type().Elem())) } @@ -602,7 +602,7 @@ Loop: func copyValue(dst reflect.Value, src []byte) (err error) { dst0 := dst - if dst.Kind() == reflect.Ptr { + if dst.Kind() == reflect.Pointer { if dst.IsNil() { dst.Set(reflect.New(dst.Type().Elem())) } diff --git a/src/encoding/xml/typeinfo.go b/src/encoding/xml/typeinfo.go index 51e976cf01..6b399b9a0e 100644 --- a/src/encoding/xml/typeinfo.go +++ b/src/encoding/xml/typeinfo.go @@ -67,7 +67,7 @@ func getTypeInfo(typ reflect.Type) (*typeInfo, error) { // For embedded structs, embed its fields. if f.Anonymous { t := f.Type - if t.Kind() == reflect.Ptr { + if t.Kind() == reflect.Pointer { t = t.Elem() } if t.Kind() == reflect.Struct { @@ -229,7 +229,7 @@ func structFieldInfo(typ reflect.Type, f *reflect.StructField) (*fieldInfo, erro // in case it exists and has a valid xml field tag, otherwise // it returns nil. func lookupXMLName(typ reflect.Type) (xmlname *fieldInfo) { - for typ.Kind() == reflect.Ptr { + for typ.Kind() == reflect.Pointer { typ = typ.Elem() } if typ.Kind() != reflect.Struct { @@ -358,7 +358,7 @@ func (finfo *fieldInfo) value(v reflect.Value, shouldInitNilPointers bool) refle for i, x := range finfo.idx { if i > 0 { t := v.Type() - if t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Struct { + if t.Kind() == reflect.Pointer && t.Elem().Kind() == reflect.Struct { if v.IsNil() { if !shouldInitNilPointers { return reflect.Value{} diff --git a/src/flag/flag.go b/src/flag/flag.go index 885a4c8369..86e16e5a61 100644 --- a/src/flag/flag.go +++ b/src/flag/flag.go @@ -456,7 +456,7 @@ func isZeroValue(flag *Flag, value string) bool { // This works unless the Value type is itself an interface type. typ := reflect.TypeOf(flag.Value) var z reflect.Value - if typ.Kind() == reflect.Ptr { + if typ.Kind() == reflect.Pointer { z = reflect.New(typ.Elem()) } else { z = reflect.Zero(typ) diff --git a/src/fmt/print.go b/src/fmt/print.go index 8bc225f548..698ab557a4 100644 --- a/src/fmt/print.go +++ b/src/fmt/print.go @@ -498,7 +498,7 @@ func (p *pp) fmtBytes(v []byte, verb rune, typeString string) { func (p *pp) fmtPointer(value reflect.Value, verb rune) { var u uintptr switch value.Kind() { - case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer: + case reflect.Chan, reflect.Func, reflect.Map, reflect.Pointer, reflect.Slice, reflect.UnsafePointer: u = value.Pointer() default: p.badVerb(verb) @@ -538,7 +538,7 @@ func (p *pp) catchPanic(arg interface{}, verb rune, method string) { // If it's a nil pointer, just say "". The likeliest causes are a // Stringer that fails to guard against nil or a nil pointer for a // value receiver, and in either case, "" is a nice result. - if v := reflect.ValueOf(arg); v.Kind() == reflect.Ptr && v.IsNil() { + if v := reflect.ValueOf(arg); v.Kind() == reflect.Pointer && v.IsNil() { p.buf.writeString(nilAngleString) return } @@ -866,7 +866,7 @@ func (p *pp) printValue(value reflect.Value, verb rune, depth int) { } p.buf.writeByte(']') } - case reflect.Ptr: + case reflect.Pointer: // pointer to array or slice or struct? ok at top level // but not embedded (avoid loops) if depth == 0 && f.Pointer() != 0 { diff --git a/src/fmt/scan.go b/src/fmt/scan.go index 381577049c..18cb608f43 100644 --- a/src/fmt/scan.go +++ b/src/fmt/scan.go @@ -1017,7 +1017,7 @@ func (s *ss) scanOne(verb rune, arg interface{}) { default: val := reflect.ValueOf(v) ptr := val - if ptr.Kind() != reflect.Ptr { + if ptr.Kind() != reflect.Pointer { s.errorString("type not a pointer: " + val.Type().String()) return } diff --git a/src/fmt/scan_test.go b/src/fmt/scan_test.go index 1cc469ce36..6b71b792ed 100644 --- a/src/fmt/scan_test.go +++ b/src/fmt/scan_test.go @@ -516,7 +516,7 @@ func testScan(t *testing.T, f func(string) io.Reader, scan func(r io.Reader, a . } // The incoming value may be a pointer v := reflect.ValueOf(test.in) - if p := v; p.Kind() == reflect.Ptr { + if p := v; p.Kind() == reflect.Pointer { v = p.Elem() } val := v.Interface() @@ -561,7 +561,7 @@ func TestScanf(t *testing.T) { } // The incoming value may be a pointer v := reflect.ValueOf(test.in) - if p := v; p.Kind() == reflect.Ptr { + if p := v; p.Kind() == reflect.Pointer { v = p.Elem() } val := v.Interface() diff --git a/src/go/ast/print.go b/src/go/ast/print.go index d86d9ba64b..b58683075c 100644 --- a/src/go/ast/print.go +++ b/src/go/ast/print.go @@ -21,7 +21,7 @@ type FieldFilter func(name string, value reflect.Value) bool // it returns false otherwise. func NotNilFilter(_ string, v reflect.Value) bool { switch v.Kind() { - case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Slice: return !v.IsNil() } return true @@ -165,7 +165,7 @@ func (p *printer) print(x reflect.Value) { } p.printf("}") - case reflect.Ptr: + case reflect.Pointer: p.printf("*") // type-checked ASTs may contain cycles - use ptrmap // to keep track of objects that have been printed diff --git a/src/html/template/content.go b/src/html/template/content.go index 6ba87a9550..232ba199f3 100644 --- a/src/html/template/content.go +++ b/src/html/template/content.go @@ -116,12 +116,12 @@ func indirect(a interface{}) interface{} { if a == nil { return nil } - if t := reflect.TypeOf(a); t.Kind() != reflect.Ptr { + if t := reflect.TypeOf(a); t.Kind() != reflect.Pointer { // Avoid creating a reflect.Value if it's not a pointer. return a } v := reflect.ValueOf(a) - for v.Kind() == reflect.Ptr && !v.IsNil() { + for v.Kind() == reflect.Pointer && !v.IsNil() { v = v.Elem() } return v.Interface() @@ -140,7 +140,7 @@ func indirectToStringerOrError(a interface{}) interface{} { return nil } v := reflect.ValueOf(a) - for !v.Type().Implements(fmtStringerType) && !v.Type().Implements(errorType) && v.Kind() == reflect.Ptr && !v.IsNil() { + for !v.Type().Implements(fmtStringerType) && !v.Type().Implements(errorType) && v.Kind() == reflect.Pointer && !v.IsNil() { v = v.Elem() } return v.Interface() diff --git a/src/html/template/js.go b/src/html/template/js.go index 32a4fbd30a..7e919c48e6 100644 --- a/src/html/template/js.go +++ b/src/html/template/js.go @@ -132,7 +132,7 @@ func indirectToJSONMarshaler(a interface{}) interface{} { } v := reflect.ValueOf(a) - for !v.Type().Implements(jsonMarshalType) && v.Kind() == reflect.Ptr && !v.IsNil() { + for !v.Type().Implements(jsonMarshalType) && v.Kind() == reflect.Pointer && !v.IsNil() { v = v.Elem() } return v.Interface() diff --git a/src/internal/fmtsort/sort.go b/src/internal/fmtsort/sort.go index 7127ba6ac3..34c1f477f0 100644 --- a/src/internal/fmtsort/sort.go +++ b/src/internal/fmtsort/sort.go @@ -130,7 +130,7 @@ func compare(aVal, bVal reflect.Value) int { default: return -1 } - case reflect.Ptr, reflect.UnsafePointer: + case reflect.Pointer, reflect.UnsafePointer: a, b := aVal.Pointer(), bVal.Pointer() switch { case a < b: diff --git a/src/internal/reflectlite/tostring_test.go b/src/internal/reflectlite/tostring_test.go index a1e5dae09d..966b0bd849 100644 --- a/src/internal/reflectlite/tostring_test.go +++ b/src/internal/reflectlite/tostring_test.go @@ -44,7 +44,7 @@ func valueToStringImpl(val reflect.Value) string { } else { return "false" } - case reflect.Ptr: + case reflect.Pointer: v := val str = typ.String() + "(" if v.IsNil() { diff --git a/src/net/rpc/server.go b/src/net/rpc/server.go index bfc19ac97c..223a53cfa7 100644 --- a/src/net/rpc/server.go +++ b/src/net/rpc/server.go @@ -203,7 +203,7 @@ var DefaultServer = NewServer() // Is this type exported or a builtin? func isExportedOrBuiltinType(t reflect.Type) bool { - for t.Kind() == reflect.Ptr { + for t.Kind() == reflect.Pointer { t = t.Elem() } // PkgPath will be non-empty even for an exported type, @@ -262,7 +262,7 @@ func (server *Server) register(rcvr interface{}, name string, useName bool) erro str := "" // To help the user, see if a pointer receiver would work. - method := suitableMethods(reflect.PtrTo(s.typ), false) + method := suitableMethods(reflect.PointerTo(s.typ), false) if len(method) != 0 { str = "rpc.Register: type " + sname + " has no exported methods of suitable type (hint: pass a pointer to value of that type)" } else { @@ -307,7 +307,7 @@ func suitableMethods(typ reflect.Type, logErr bool) map[string]*methodType { } // Second arg must be a pointer. replyType := mtype.In(2) - if replyType.Kind() != reflect.Ptr { + if replyType.Kind() != reflect.Pointer { if logErr { log.Printf("rpc.Register: reply type of method %q is not a pointer: %q\n", mname, replyType) } @@ -556,7 +556,7 @@ func (server *Server) readRequest(codec ServerCodec) (service *service, mtype *m // Decode the argument value. argIsValue := false // if true, need to indirect before calling. - if mtype.ArgType.Kind() == reflect.Ptr { + if mtype.ArgType.Kind() == reflect.Pointer { argv = reflect.New(mtype.ArgType.Elem()) } else { argv = reflect.New(mtype.ArgType) diff --git a/src/reflect/abi.go b/src/reflect/abi.go index 2ce7ca2615..28204b8193 100644 --- a/src/reflect/abi.go +++ b/src/reflect/abi.go @@ -198,7 +198,7 @@ func (a *abiSeq) addRcvr(rcvr *rtype) (*abiStep, bool) { // complete register-assignment algorithm for the Go ABI. func (a *abiSeq) regAssign(t *rtype, offset uintptr) bool { switch t.Kind() { - case UnsafePointer, Ptr, Chan, Map, Func: + case UnsafePointer, Pointer, Chan, Map, Func: return a.assignIntN(offset, t.size, 1, 0b1) case Bool, Int, Uint, Int8, Uint8, Int16, Uint16, Int32, Uint32, Uintptr: return a.assignIntN(offset, t.size, 1, 0b0) diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 922998125b..725be28bf0 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -546,7 +546,7 @@ func TestCanSetField(t *testing.T) { for _, tc := range tt.cases { f := tt.val for _, i := range tc.index { - if f.Kind() == Ptr { + if f.Kind() == Pointer { f = f.Elem() } if i == -1 { @@ -1373,7 +1373,7 @@ func TestIsZero(t *testing.T) { {(map[string]string)(nil), true}, {map[string]string{}, false}, {make(map[string]string), false}, - // Ptr + // Pointer {(*func())(nil), true}, {(*int)(nil), true}, {new(int), false}, @@ -3313,20 +3313,20 @@ func TestPtrTo(t *testing.T) { typ := TypeOf(z) for i = 0; i < 100; i++ { - typ = PtrTo(typ) + typ = PointerTo(typ) } for i = 0; i < 100; i++ { typ = typ.Elem() } if typ != TypeOf(z) { - t.Errorf("after 100 PtrTo and Elem, have %s, want %s", typ, TypeOf(z)) + t.Errorf("after 100 PointerTo and Elem, have %s, want %s", typ, TypeOf(z)) } } func TestPtrToGC(t *testing.T) { type T *uintptr tt := TypeOf(T(nil)) - pt := PtrTo(tt) + pt := PointerTo(tt) const n = 100 var x []interface{} for i := 0; i < n; i++ { @@ -3360,11 +3360,11 @@ func BenchmarkPtrTo(b *testing.B) { } b.ResetTimer() - // Now benchmark calling PtrTo on it: we'll have to hit the ptrMap cache on + // Now benchmark calling PointerTo on it: we'll have to hit the ptrMap cache on // every call. b.RunParallel(func(pb *testing.PB) { for pb.Next() { - PtrTo(t) + PointerTo(t) } }) } @@ -4896,7 +4896,7 @@ func TestArrayOfDirectIface(t *testing.T) { v1 := ValueOf(&i1).Elem() p1 := v1.InterfaceData()[1] - i2 := Zero(ArrayOf(1, PtrTo(TypeOf(int8(0))))).Interface() + i2 := Zero(ArrayOf(1, PointerTo(TypeOf(int8(0))))).Interface() v2 := ValueOf(&i2).Elem() p2 := v2.InterfaceData()[1] @@ -4914,7 +4914,7 @@ func TestArrayOfDirectIface(t *testing.T) { v1 := ValueOf(&i1).Elem() p1 := v1.InterfaceData()[1] - i2 := Zero(ArrayOf(0, PtrTo(TypeOf(int8(0))))).Interface() + i2 := Zero(ArrayOf(0, PointerTo(TypeOf(int8(0))))).Interface() v2 := ValueOf(&i2).Elem() p2 := v2.InterfaceData()[1] @@ -5615,7 +5615,7 @@ func TestStructOfWithInterface(t *testing.T) { }, { name: "StructI", - typ: PtrTo(TypeOf(StructI(want))), + typ: PointerTo(TypeOf(StructI(want))), val: ValueOf(func() interface{} { v := StructI(want) return &v @@ -5624,7 +5624,7 @@ func TestStructOfWithInterface(t *testing.T) { }, { name: "StructIPtr", - typ: PtrTo(TypeOf(StructIPtr(want))), + typ: PointerTo(TypeOf(StructIPtr(want))), val: ValueOf(func() interface{} { v := StructIPtr(want) return &v @@ -5713,7 +5713,7 @@ func TestStructOfWithInterface(t *testing.T) { fields := []StructField{{ Name: "StructIPtr", Anonymous: true, - Type: PtrTo(TypeOf(StructIPtr(want))), + Type: PointerTo(TypeOf(StructIPtr(want))), }} rt := StructOf(fields) rv := New(rt).Elem() @@ -5727,7 +5727,7 @@ func TestStructOfWithInterface(t *testing.T) { fields = []StructField{{ Name: "SettableStruct", Anonymous: true, - Type: PtrTo(TypeOf(SettableStruct{})), + Type: PointerTo(TypeOf(SettableStruct{})), }} rt = StructOf(fields) rv = New(rt).Elem() @@ -5743,7 +5743,7 @@ func TestStructOfWithInterface(t *testing.T) { { Name: "SettableStruct", Anonymous: true, - Type: PtrTo(TypeOf(SettableStruct{})), + Type: PointerTo(TypeOf(SettableStruct{})), }, { Name: "EmptyStruct", @@ -6959,7 +6959,7 @@ func TestGCBits(t *testing.T) { verifyGCBits(t, MapOf(ArrayOf(10000, Tscalarptr), Tscalar), lit(1)) verifyGCBits(t, TypeOf((*[10000]Xscalar)(nil)), lit(1)) - verifyGCBits(t, PtrTo(ArrayOf(10000, Tscalar)), lit(1)) + verifyGCBits(t, PointerTo(ArrayOf(10000, Tscalar)), lit(1)) verifyGCBits(t, TypeOf(([][10000]Xscalar)(nil)), lit(1)) verifyGCBits(t, SliceOf(ArrayOf(10000, Tscalar)), lit(1)) @@ -7028,7 +7028,7 @@ func TestTypeOfTypeOf(t *testing.T) { check("ChanOf", ChanOf(BothDir, TypeOf(T{}))) check("FuncOf", FuncOf([]Type{TypeOf(T{})}, nil, false)) check("MapOf", MapOf(TypeOf(T{}), TypeOf(T{}))) - check("PtrTo", PtrTo(TypeOf(T{}))) + check("PtrTo", PointerTo(TypeOf(T{}))) check("SliceOf", SliceOf(TypeOf(T{}))) } diff --git a/src/reflect/deepequal.go b/src/reflect/deepequal.go index 7f1ecb2809..b71504fa21 100644 --- a/src/reflect/deepequal.go +++ b/src/reflect/deepequal.go @@ -38,7 +38,7 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool) bool { // and it's safe and valid to get Value's internal pointer. hard := func(v1, v2 Value) bool { switch v1.Kind() { - case Ptr: + case Pointer: if v1.typ.ptrdata == 0 { // go:notinheap pointers can't be cyclic. // At least, all of our current uses of go:notinheap have @@ -56,13 +56,13 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool) bool { } if hard(v1, v2) { - // For a Ptr or Map value, we need to check flagIndir, + // For a Pointer or Map value, we need to check flagIndir, // which we do by calling the pointer method. // For Slice or Interface, flagIndir is always set, // and using v.ptr suffices. ptrval := func(v Value) unsafe.Pointer { switch v.Kind() { - case Ptr, Map: + case Pointer, Map: return v.pointer() default: return v.ptr @@ -120,7 +120,7 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool) bool { return v1.IsNil() == v2.IsNil() } return deepValueEqual(v1.Elem(), v2.Elem(), visited) - case Ptr: + case Pointer: if v1.UnsafePointer() == v2.UnsafePointer() { return true } diff --git a/src/reflect/tostring_test.go b/src/reflect/tostring_test.go index e416fd84da..193484a01b 100644 --- a/src/reflect/tostring_test.go +++ b/src/reflect/tostring_test.go @@ -39,7 +39,7 @@ func valueToString(val Value) string { } else { return "false" } - case Ptr: + case Pointer: v := val str = typ.String() + "(" if v.IsNil() { diff --git a/src/reflect/type.go b/src/reflect/type.go index 96f589ca9c..2bb2438381 100644 --- a/src/reflect/type.go +++ b/src/reflect/type.go @@ -1425,7 +1425,7 @@ func TypeOf(i interface{}) Type { var ptrMap sync.Map // map[*rtype]*ptrType // PtrTo returns the pointer type with element t. -// For example, if t represents type Foo, PtrTo(t) represents *Foo. +// For example, if t represents type Foo, PointerTo(t) represents *Foo. // // Deprecated: use PointerTo. PtrTo is the old spelling. // The two functions behave identically. diff --git a/src/reflect/value.go b/src/reflect/value.go index 3e723e82a4..5d9964eb9d 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -90,8 +90,8 @@ func (f flag) ro() flag { } // pointer returns the underlying pointer represented by v. -// v.Kind() must be Ptr, Map, Chan, Func, or UnsafePointer -// if v.Kind() == Ptr, the base type must not be go:notinheap. +// v.Kind() must be Pointer, Map, Chan, Func, or UnsafePointer +// if v.Kind() == Pointer, the base type must not be go:notinheap. func (v Value) pointer() unsafe.Pointer { if v.typ.size != goarch.PtrSize || !v.typ.pointers() { panic("can't call pointer on a non-pointer Value") @@ -274,7 +274,7 @@ func (v Value) Addr() Value { // Preserve flagRO instead of using v.flag.ro() so that // v.Addr().Elem() is equivalent to v (#32772) fl := v.flag & flagRO - return Value{v.typ.ptrTo(), v.ptr, fl | flag(Ptr)} + return Value{v.typ.ptrTo(), v.ptr, fl | flag(Pointer)} } // Bool returns v's underlying value. @@ -1147,7 +1147,7 @@ func (v Value) Complex() complex128 { // Elem returns the value that the interface v contains // or that the pointer v points to. -// It panics if v's Kind is not Interface or Ptr. +// It panics if v's Kind is not Interface or Pointer. // It returns the zero Value if v is nil. func (v Value) Elem() Value { k := v.kind() @@ -1166,7 +1166,7 @@ func (v Value) Elem() Value { x.flag |= v.flag.ro() } return x - case Ptr: + case Pointer: ptr := v.ptr if v.flag&flagIndir != 0 { if ifaceIndir(v.typ) { @@ -1240,7 +1240,7 @@ func (v Value) FieldByIndex(index []int) Value { v.mustBe(Struct) for i, x := range index { if i > 0 { - if v.Kind() == Ptr && v.typ.Elem().Kind() == Struct { + if v.Kind() == Pointer && v.typ.Elem().Kind() == Struct { if v.IsNil() { panic("reflect: indirection through nil pointer to embedded struct") } @@ -1321,7 +1321,7 @@ func (v Value) Index(i int) Value { return Value{typ, val, fl} case Slice: - // Element flag same as Elem of Ptr. + // Element flag same as Elem of Pointer. // Addressable, indirect, possibly read-only. s := (*unsafeheader.Slice)(v.ptr) if uint(i) >= uint(s.Len) { @@ -1451,7 +1451,7 @@ func (v Value) InterfaceData() [2]uintptr { func (v Value) IsNil() bool { k := v.kind() switch k { - case Chan, Func, Map, Ptr, UnsafePointer: + case Chan, Func, Map, Pointer, UnsafePointer: if v.flag&flagMethod != 0 { return false } @@ -1499,7 +1499,7 @@ func (v Value) IsZero() bool { } } return true - case Chan, Func, Interface, Map, Ptr, Slice, UnsafePointer: + case Chan, Func, Interface, Map, Pointer, Slice, UnsafePointer: return v.IsNil() case String: return v.Len() == 0 @@ -1923,7 +1923,7 @@ func (v Value) OverflowUint(x uint64) bool { // It returns uintptr instead of unsafe.Pointer so that // code using reflect cannot obtain unsafe.Pointers // without importing the unsafe package explicitly. -// It panics if v's Kind is not Chan, Func, Map, Ptr, Slice, or UnsafePointer. +// It panics if v's Kind is not Chan, Func, Map, Pointer, Slice, or UnsafePointer. // // If v's Kind is Func, the returned pointer is an underlying // code pointer, but not necessarily enough to identify a @@ -1938,7 +1938,7 @@ func (v Value) OverflowUint(x uint64) bool { func (v Value) Pointer() uintptr { k := v.kind() switch k { - case Ptr: + case Pointer: if v.typ.ptrdata == 0 { val := *(*uintptr)(v.ptr) // Since it is a not-in-heap pointer, all pointers to the heap are @@ -2491,7 +2491,7 @@ func (v Value) UnsafeAddr() uintptr { } // UnsafePointer returns v's value as a unsafe.Pointer. -// It panics if v's Kind is not Chan, Func, Map, Ptr, Slice, or UnsafePointer. +// It panics if v's Kind is not Chan, Func, Map, Pointer, Slice, or UnsafePointer. // // If v's Kind is Func, the returned pointer is an underlying // code pointer, but not necessarily enough to identify a @@ -2504,7 +2504,7 @@ func (v Value) UnsafeAddr() uintptr { func (v Value) UnsafePointer() unsafe.Pointer { k := v.kind() switch k { - case Ptr: + case Pointer: if v.typ.ptrdata == 0 { // Since it is a not-in-heap pointer, all pointers to the heap are // forbidden! See comment in Value.Elem and issue #48399. @@ -2908,7 +2908,7 @@ func MakeMapWithSize(typ Type, n int) Value { // If v is a nil pointer, Indirect returns a zero Value. // If v is not a pointer, Indirect returns v. func Indirect(v Value) Value { - if v.Kind() != Ptr { + if v.Kind() != Pointer { return v } return v.Elem() @@ -2960,7 +2960,7 @@ const maxZero = 1024 var zeroVal [maxZero]byte // New returns a Value representing a pointer to a new zero value -// for the specified type. That is, the returned Value's Type is PtrTo(typ). +// for the specified type. That is, the returned Value's Type is PointerTo(typ). func New(typ Type) Value { if typ == nil { panic("reflect: New(nil)") @@ -2972,14 +2972,14 @@ func New(typ Type) Value { panic("reflect: New of type that may not be allocated in heap (possibly undefined cgo C type)") } ptr := unsafe_New(t) - fl := flag(Ptr) + fl := flag(Pointer) return Value{pt, ptr, fl} } // NewAt returns a Value representing a pointer to a value of the // specified type, using p as that pointer. func NewAt(typ Type, p unsafe.Pointer) Value { - fl := flag(Ptr) + fl := flag(Pointer) t := typ.(*rtype) return Value{t.ptrTo(), p, fl} } @@ -3048,7 +3048,7 @@ func (v Value) CanConvert(t Type) bool { // Currently the only conversion that is OK in terms of type // but that can panic depending on the value is converting // from slice to pointer-to-array. - if vt.Kind() == Slice && t.Kind() == Ptr && t.Elem().Kind() == Array { + if vt.Kind() == Slice && t.Kind() == Pointer && t.Elem().Kind() == Array { n := t.Elem().Len() if n > v.Len() { return false @@ -3118,7 +3118,7 @@ func convertOp(dst, src *rtype) func(Value, Type) Value { } // "x is a slice, T is a pointer-to-array type, // and the slice and array types have identical element types." - if dst.Kind() == Ptr && dst.Elem().Kind() == Array && src.Elem() == dst.Elem().Elem() { + if dst.Kind() == Pointer && dst.Elem().Kind() == Array && src.Elem() == dst.Elem().Elem() { return cvtSliceArrayPtr } @@ -3134,8 +3134,8 @@ func convertOp(dst, src *rtype) func(Value, Type) Value { } // dst and src are non-defined pointer types with same underlying base type. - if dst.Kind() == Ptr && dst.Name() == "" && - src.Kind() == Ptr && src.Name() == "" && + if dst.Kind() == Pointer && dst.Name() == "" && + src.Kind() == Pointer && src.Name() == "" && haveIdenticalUnderlyingType(dst.Elem().common(), src.Elem().common(), false) { return cvtDirect } @@ -3321,7 +3321,7 @@ func cvtSliceArrayPtr(v Value, t Type) Value { panic("reflect: cannot convert slice with length " + itoa.Itoa(v.Len()) + " to pointer to array with length " + itoa.Itoa(n)) } h := (*unsafeheader.Slice)(v.ptr) - return Value{t.common(), h.Data, v.flag&^(flagIndir|flagAddr|flagKindMask) | flag(Ptr)} + return Value{t.common(), h.Data, v.flag&^(flagIndir|flagAddr|flagKindMask) | flag(Pointer)} } // convertOp: direct copy diff --git a/src/reflect/visiblefields.go b/src/reflect/visiblefields.go index 1a2b53570b..9375faa110 100644 --- a/src/reflect/visiblefields.go +++ b/src/reflect/visiblefields.go @@ -92,7 +92,7 @@ func (w *visibleFieldsWalker) walk(t Type) { w.fields = append(w.fields, f) } if f.Anonymous { - if f.Type.Kind() == Ptr { + if f.Type.Kind() == Pointer { f.Type = f.Type.Elem() } if f.Type.Kind() == Struct { diff --git a/src/runtime/gc_test.go b/src/runtime/gc_test.go index 0ec5331534..7b979afd55 100644 --- a/src/runtime/gc_test.go +++ b/src/runtime/gc_test.go @@ -458,7 +458,7 @@ func benchSetType(b *testing.B, x interface{}) { v := reflect.ValueOf(x) t := v.Type() switch t.Kind() { - case reflect.Ptr: + case reflect.Pointer: b.SetBytes(int64(t.Elem().Size())) case reflect.Slice: b.SetBytes(int64(t.Elem().Size()) * int64(v.Len())) diff --git a/src/testing/quick/quick.go b/src/testing/quick/quick.go index c01647ecf0..777338bb37 100644 --- a/src/testing/quick/quick.go +++ b/src/testing/quick/quick.go @@ -113,7 +113,7 @@ func sizedValue(t reflect.Type, rand *rand.Rand, size int) (value reflect.Value, } v.SetMapIndex(key, value) } - case reflect.Ptr: + case reflect.Pointer: if rand.Intn(size) == 0 { v.Set(reflect.Zero(concrete)) // Generate nil pointer. } else { diff --git a/src/text/template/exec.go b/src/text/template/exec.go index 9ae6fdc3cc..7e44497530 100644 --- a/src/text/template/exec.go +++ b/src/text/template/exec.go @@ -327,7 +327,7 @@ func isTrue(val reflect.Value) (truth, ok bool) { truth = val.Bool() case reflect.Complex64, reflect.Complex128: truth = val.Complex() != 0 - case reflect.Chan, reflect.Func, reflect.Ptr, reflect.Interface: + case reflect.Chan, reflect.Func, reflect.Pointer, reflect.Interface: truth = !val.IsNil() case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: truth = val.Int() != 0 @@ -623,7 +623,7 @@ func (s *state) evalField(dot reflect.Value, fieldName string, node parse.Node, // Unless it's an interface, need to get to a value of type *T to guarantee // we see all methods of T and *T. ptr := receiver - if ptr.Kind() != reflect.Interface && ptr.Kind() != reflect.Ptr && ptr.CanAddr() { + if ptr.Kind() != reflect.Interface && ptr.Kind() != reflect.Pointer && ptr.CanAddr() { ptr = ptr.Addr() } if method := ptr.MethodByName(fieldName); method.IsValid() { @@ -665,7 +665,7 @@ func (s *state) evalField(dot reflect.Value, fieldName string, node parse.Node, } return result } - case reflect.Ptr: + case reflect.Pointer: etyp := receiver.Type().Elem() if etyp.Kind() == reflect.Struct { if _, ok := etyp.FieldByName(fieldName); !ok { @@ -788,7 +788,7 @@ func (s *state) evalCall(dot, fun reflect.Value, isBuiltin bool, node parse.Node // canBeNil reports whether an untyped nil can be assigned to the type. See reflect.Zero. func canBeNil(typ reflect.Type) bool { switch typ.Kind() { - case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Slice: return true case reflect.Struct: return typ == reflectValueType @@ -825,12 +825,12 @@ func (s *state) validateType(value reflect.Value, typ reflect.Type) reflect.Valu // are much more constrained, so it makes more sense there than here. // Besides, one is almost always all you need. switch { - case value.Kind() == reflect.Ptr && value.Type().Elem().AssignableTo(typ): + case value.Kind() == reflect.Pointer && value.Type().Elem().AssignableTo(typ): value = value.Elem() if !value.IsValid() { s.errorf("dereference of nil pointer of type %s", typ) } - case reflect.PtrTo(value.Type()).AssignableTo(typ) && value.CanAddr(): + case reflect.PointerTo(value.Type()).AssignableTo(typ) && value.CanAddr(): value = value.Addr() default: s.errorf("wrong type for value; expected %s; got %s", typ, value.Type()) @@ -982,7 +982,7 @@ func (s *state) evalEmptyInterface(dot reflect.Value, n parse.Node) reflect.Valu // if it's nil. If the returned bool is true, the returned value's kind will be // either a pointer or interface. func indirect(v reflect.Value) (rv reflect.Value, isNil bool) { - for ; v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface; v = v.Elem() { + for ; v.Kind() == reflect.Pointer || v.Kind() == reflect.Interface; v = v.Elem() { if v.IsNil() { return v, true } @@ -1021,7 +1021,7 @@ func (s *state) printValue(n parse.Node, v reflect.Value) { // printableValue returns the, possibly indirected, interface value inside v that // is best for a call to formatted printer. func printableValue(v reflect.Value) (interface{}, bool) { - if v.Kind() == reflect.Ptr { + if v.Kind() == reflect.Pointer { v, _ = indirect(v) // fmt.Fprint handles nil. } if !v.IsValid() { @@ -1029,7 +1029,7 @@ func printableValue(v reflect.Value) (interface{}, bool) { } if !v.Type().Implements(errorType) && !v.Type().Implements(fmtStringerType) { - if v.CanAddr() && (reflect.PtrTo(v.Type()).Implements(errorType) || reflect.PtrTo(v.Type()).Implements(fmtStringerType)) { + if v.CanAddr() && (reflect.PointerTo(v.Type()).Implements(errorType) || reflect.PointerTo(v.Type()).Implements(fmtStringerType)) { v = v.Addr() } else { switch v.Kind() { diff --git a/test/fixedbugs/issue32901.dir/main.go b/test/fixedbugs/issue32901.dir/main.go index 28bb8cde28..673c6ab3e0 100644 --- a/test/fixedbugs/issue32901.dir/main.go +++ b/test/fixedbugs/issue32901.dir/main.go @@ -4,13 +4,16 @@ package main -import "./c" -import "reflect" +import ( + "reflect" + + "./c" +) func main() { x := c.F() p := c.P() - t := reflect.PtrTo(reflect.TypeOf(x)) + t := reflect.PointerTo(reflect.TypeOf(x)) tp := reflect.TypeOf(p) if t != tp { panic("FAIL") diff --git a/test/reflectmethod7.go b/test/reflectmethod7.go index 42429978b4..688238c511 100644 --- a/test/reflectmethod7.go +++ b/test/reflectmethod7.go @@ -16,7 +16,7 @@ func (s S) M() {} func main() { t := reflect.TypeOf(S(0)) - fn, ok := reflect.PtrTo(t).MethodByName("M") + fn, ok := reflect.PointerTo(t).MethodByName("M") if !ok { panic("FAIL") } From 1b2362bb83de47188e7c60a69f46950de542f017 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 26 Oct 2021 09:47:18 -0400 Subject: [PATCH 164/406] cmd/compile/internal/typecheck: update doc for the 1.18 export format Update the documentation in iexport.go to use the word 'Constraint' rather than 'Bound', and to account for recent changes to the export format. Change-Id: I83fbcd336d5f865af804bc8bef4f5d997cd9f325 Reviewed-on: https://go-review.googlesource.com/c/go/+/358547 Trust: Robert Findley Trust: Dan Scales Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/typecheck/iexport.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cmd/compile/internal/typecheck/iexport.go b/src/cmd/compile/internal/typecheck/iexport.go index 6057000a5d..f685851e40 100644 --- a/src/cmd/compile/internal/typecheck/iexport.go +++ b/src/cmd/compile/internal/typecheck/iexport.go @@ -97,9 +97,10 @@ // // // "Automatic" declaration of each typeparam // type TypeParam struct { -// Tag byte // 'P' -// Pos Pos -// Bound typeOff +// Tag byte // 'P' +// Pos Pos +// Implicit bool +// Constraint typeOff // } // // typeOff means a uvarint that either indicates a predeclared type, @@ -108,7 +109,7 @@ // types list (see predeclared in bexport.go for order). Otherwise, // subtracting predeclReserved yields the offset of a type descriptor. // -// Value means a type and type-specific value. See +// Value means a type, kind, and type-specific value. See // (*exportWriter).value for details. // // From 76cef81bcff371c88d277f17c712ecf22b8c83e7 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Sat, 16 Oct 2021 17:53:31 +1100 Subject: [PATCH 165/406] cmd/go: stamp VCS commit time into binaries Only Git and Mercurial are supported for now. This CL also: - Skips tagging "revision" and "committime" for empty repositories. - Stores the full Mercurial changeset ID instead of the short form. Fixes #37475 Change-Id: I62ab7a986d1ddb2a0e7166a6404b5aa80c2ee387 Reviewed-on: https://go-review.googlesource.com/c/go/+/356251 Reviewed-by: Bryan C. Mills Trust: Bryan C. Mills Trust: Michael Matloob Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot --- src/cmd/go/internal/load/pkg.go | 13 ++- src/cmd/go/internal/vcs/vcs.go | 86 ++++++++++++++----- .../testdata/script/version_buildvcs_git.txt | 15 +++- .../testdata/script/version_buildvcs_hg.txt | 12 ++- 4 files changed, 98 insertions(+), 28 deletions(-) diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index a5be48a49b..dfe7849516 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -25,6 +25,7 @@ import ( "sort" "strconv" "strings" + "time" "unicode" "unicode/utf8" @@ -2364,10 +2365,14 @@ func (p *Package) setBuildInfo() { setVCSError(err) return } - info.Settings = append(info.Settings, []debug.BuildSetting{ - {Key: vcsCmd.Cmd + "revision", Value: st.Revision}, - {Key: vcsCmd.Cmd + "uncommitted", Value: strconv.FormatBool(st.Uncommitted)}, - }...) + if st.Revision != "" { + appendSetting(vcsCmd.Cmd+"revision", st.Revision) + } + if !st.CommitTime.IsZero() { + stamp := st.CommitTime.UTC().Format(time.RFC3339Nano) + appendSetting(vcsCmd.Cmd+"committime", stamp) + } + appendSetting(vcsCmd.Cmd+"uncommitted", strconv.FormatBool(st.Uncommitted)) } text, err := info.MarshalText() diff --git a/src/cmd/go/internal/vcs/vcs.go b/src/cmd/go/internal/vcs/vcs.go index d1272b66e9..941bd57147 100644 --- a/src/cmd/go/internal/vcs/vcs.go +++ b/src/cmd/go/internal/vcs/vcs.go @@ -18,8 +18,10 @@ import ( "os" "path/filepath" "regexp" + "strconv" "strings" "sync" + "time" "cmd/go/internal/base" "cmd/go/internal/cfg" @@ -54,8 +56,9 @@ type Cmd struct { // Status is the current state of a local repository. type Status struct { - Revision string - Uncommitted bool + Revision string // Optional. + CommitTime time.Time // Optional. + Uncommitted bool // Required. } var defaultSecureScheme = map[string]bool{ @@ -159,24 +162,52 @@ func hgRemoteRepo(vcsHg *Cmd, rootDir string) (remoteRepo string, err error) { } func hgStatus(vcsHg *Cmd, rootDir string) (Status, error) { - out, err := vcsHg.runOutputVerboseOnly(rootDir, "identify -i") + // Output changeset ID and seconds since epoch. + out, err := vcsHg.runOutputVerboseOnly(rootDir, `log -l1 -T {node}:{date(date,"%s")}`) if err != nil { return Status{}, err } - rev := strings.TrimSpace(string(out)) - uncommitted := strings.HasSuffix(rev, "+") - if uncommitted { - // "+" means a tracked file is edited. - rev = rev[:len(rev)-len("+")] - } else { - // Also look for untracked files. - out, err = vcsHg.runOutputVerboseOnly(rootDir, "status -u") + + // Successful execution without output indicates an empty repo (no commits). + var rev string + var commitTime time.Time + if len(out) > 0 { + rev, commitTime, err = parseRevTime(out) if err != nil { return Status{}, err } - uncommitted = len(out) > 0 } - return Status{Revision: rev, Uncommitted: uncommitted}, nil + + // Also look for untracked files. + out, err = vcsHg.runOutputVerboseOnly(rootDir, "status") + if err != nil { + return Status{}, err + } + uncommitted := len(out) > 0 + + return Status{ + Revision: rev, + CommitTime: commitTime, + Uncommitted: uncommitted, + }, nil +} + +// parseRevTime parses commit details in "revision:seconds" format. +func parseRevTime(out []byte) (string, time.Time, error) { + buf := string(bytes.TrimSpace(out)) + + i := strings.IndexByte(buf, ':') + if i < 1 { + return "", time.Time{}, errors.New("unrecognized VCS tool output") + } + rev := buf[:i] + + secs, err := strconv.ParseInt(string(buf[i+1:]), 10, 64) + if err != nil { + return "", time.Time{}, fmt.Errorf("unrecognized VCS tool output: %v", err) + } + + return rev, time.Unix(secs, 0), nil } // vcsGit describes how to use Git. @@ -263,18 +294,33 @@ func gitRemoteRepo(vcsGit *Cmd, rootDir string) (remoteRepo string, err error) { return "", errParse } -func gitStatus(cmd *Cmd, repoDir string) (Status, error) { - out, err := cmd.runOutputVerboseOnly(repoDir, "rev-parse HEAD") +func gitStatus(vcsGit *Cmd, rootDir string) (Status, error) { + out, err := vcsGit.runOutputVerboseOnly(rootDir, "status --porcelain") if err != nil { return Status{}, err } - rev := string(bytes.TrimSpace(out)) - out, err = cmd.runOutputVerboseOnly(repoDir, "status --porcelain") - if err != nil { + uncommitted := len(out) > 0 + + // "git status" works for empty repositories, but "git show" does not. + // Assume there are no commits in the repo when "git show" fails with + // uncommitted files and skip tagging revision / committime. + var rev string + var commitTime time.Time + out, err = vcsGit.runOutputVerboseOnly(rootDir, "show -s --format=%H:%ct") + if err != nil && !uncommitted { return Status{}, err + } else if err == nil { + rev, commitTime, err = parseRevTime(out) + if err != nil { + return Status{}, err + } } - uncommitted := len(out) != 0 - return Status{Revision: rev, Uncommitted: uncommitted}, nil + + return Status{ + Revision: rev, + CommitTime: commitTime, + Uncommitted: uncommitted, + }, nil } // vcsBzr describes how to use Bazaar. diff --git a/src/cmd/go/testdata/script/version_buildvcs_git.txt b/src/cmd/go/testdata/script/version_buildvcs_git.txt index 78ce2e835e..3d56c6d8b4 100644 --- a/src/cmd/go/testdata/script/version_buildvcs_git.txt +++ b/src/cmd/go/testdata/script/version_buildvcs_git.txt @@ -28,16 +28,25 @@ cd .. env PATH=$oldpath rm .git -# If there is a repository in a parent directory, there should be VCS info. +# If there is an empty repository in a parent directory, only "uncommitted" is tagged. exec git init exec git config user.email gopher@golang.org exec git config user.name 'J.R. Gopher' -exec git add -A -exec git commit -m 'initial commit' cd a go install go version -m $GOBIN/a$GOEXE +! stdout gitrevision +! stdout gitcommittime +stdout '^\tbuild\tgituncommitted\ttrue$' +rm $GOBIN/a$GOEXE + +# Revision and commit time are tagged for repositories with commits. +exec git add -A +exec git commit -m 'initial commit' +go install +go version -m $GOBIN/a$GOEXE stdout '^\tbuild\tgitrevision\t' +stdout '^\tbuild\tgitcommittime\t' stdout '^\tbuild\tgituncommitted\tfalse$' rm $GOBIN/a$GOEXE diff --git a/src/cmd/go/testdata/script/version_buildvcs_hg.txt b/src/cmd/go/testdata/script/version_buildvcs_hg.txt index 9dcb8dd950..df4938742d 100644 --- a/src/cmd/go/testdata/script/version_buildvcs_hg.txt +++ b/src/cmd/go/testdata/script/version_buildvcs_hg.txt @@ -29,14 +29,24 @@ cd .. env PATH=$oldpath rm .hg -# If there is a repository in a parent directory, there should be VCS info. +# If there is an empty repository in a parent directory, only "uncommitted" is tagged. exec hg init +cd a +go install +go version -m $GOBIN/a$GOEXE +! stdout hgrevision +! stdout hgcommittime +stdout '^\tbuild\thguncommitted\ttrue$' +cd .. + +# Revision and commit time are tagged for repositories with commits. exec hg add a README exec hg commit -m 'initial commit' cd a go install go version -m $GOBIN/a$GOEXE stdout '^\tbuild\thgrevision\t' +stdout '^\tbuild\thgcommittime\t' stdout '^\tbuild\thguncommitted\tfalse$' rm $GOBIN/a$GOEXE From 1dc77a38d293763b9de50110dd72edd755ce72b7 Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Fri, 22 Oct 2021 11:37:28 -0400 Subject: [PATCH 166/406] internal/fuzz: tiny refactor+fix Change-Id: I8db9c31ead3e5905b7f9d1faed36555e8aaa00cd Reviewed-on: https://go-review.googlesource.com/c/go/+/358054 Trust: Katie Hockman Run-TryBot: Katie Hockman Reviewed-by: Julie Qiu TryBot-Result: Go Bot --- src/internal/fuzz/fuzz.go | 2 +- src/internal/fuzz/worker.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internal/fuzz/fuzz.go b/src/internal/fuzz/fuzz.go index 5b3819be75..5008927f0e 100644 --- a/src/internal/fuzz/fuzz.go +++ b/src/internal/fuzz/fuzz.go @@ -702,7 +702,7 @@ func (c *coordinator) logStats() { interestingTotalCount := int64(c.warmupInputCount-len(c.opts.Seed)) + c.interestingCount fmt.Fprintf(c.opts.Log, "fuzz: elapsed: %s, execs: %d (%.0f/sec), new interesting: %d (total: %d)\n", c.elapsed(), c.count, rate, c.interestingCount, interestingTotalCount) } else { - fmt.Fprintf(c.opts.Log, "fuzz: elapsed: %s, execs: %d (%.0f/sec)", c.elapsed(), c.count, rate) + fmt.Fprintf(c.opts.Log, "fuzz: elapsed: %s, execs: %d (%.0f/sec)\n", c.elapsed(), c.count, rate) } } c.countLastLog = c.count diff --git a/src/internal/fuzz/worker.go b/src/internal/fuzz/worker.go index e3827b112a..b36ebe2a7e 100644 --- a/src/internal/fuzz/worker.go +++ b/src/internal/fuzz/worker.go @@ -1088,7 +1088,7 @@ func (wc *workerClient) fuzz(ctx context.Context, entryIn CorpusEntry, args fuzz wc.m.r.restore(mem.header().randState, mem.header().randInc) if !args.Warmup { // Only mutate the valuesOut if fuzzing actually occurred. - for i := int64(0); i < mem.header().count; i++ { + for i := int64(0); i < resp.Count; i++ { wc.m.mutate(valuesOut, cap(mem.valueRef())) } } From b54bdd281e62a4658ea4edb5e0a6139006938c9a Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Mon, 18 Oct 2021 18:11:48 -0700 Subject: [PATCH 167/406] cmd/compile: clean up the switch statements in (*genInst).node() There were two main outer switch statements in node() that can just be combined. Also, for simplicity, changed an IsCmp() conditional into just another case in the switch statement. Also, the inner OCALL switch statement had a bunch of fairly duplicate cases. Combined the cases that all had no special semantics, into a single default case calling transformCall(). In the OCALL case in dictPass(), got rid of a check for OFUNCINST (which will always have been removed by this point). Also, eliminated an assert that could cause unneded failures. transformCall() should always be called if the node op is still OCALL, so no need to assert on the ops of call.X. Added an extra test in issue47078.go, to explicitly check for case where the X argument of a call is a DOTTYPE. Change-Id: Ifb3f812ce12820a4ce08afe2887f00f7fc00cd2f Reviewed-on: https://go-review.googlesource.com/c/go/+/358596 Trust: Dan Scales Run-TryBot: Dan Scales TryBot-Result: Go Bot Reviewed-by: Keith Randall --- src/cmd/compile/internal/noder/stencil.go | 175 ++++++++++------------ test/typeparam/issue47878.go | 10 ++ 2 files changed, 92 insertions(+), 93 deletions(-) diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 68032e7082..56010a356e 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -928,8 +928,9 @@ func getDictionaryType(info *instInfo, dictParam *ir.Name, pos src.XPos, i int) } // node is like DeepCopy(), but substitutes ONAME nodes based on subst.ts.vars, and -// also descends into closures. It substitutes type arguments for type parameters -// in all the new nodes. +// also descends into closures. It substitutes type arguments for type parameters in +// all the new nodes and does the transformations that were delayed on the generic +// function. func (subst *subster) node(n ir.Node) ir.Node { // Use closure to capture all state needed by the ir.EditChildren argument. var edit func(ir.Node) ir.Node @@ -973,15 +974,15 @@ func (subst *subster) node(n ir.Node) ir.Node { if _, isExpr := m.(ir.Expr); isExpr { t := x.Type() if t == nil { - // t can be nil only if this is a call that has no - // return values, so allow that and otherwise give - // an error. + // Check for known cases where t can be nil (call + // that has no return values, and key expressions) + // and otherwise cause a fatal error. _, isCallExpr := m.(*ir.CallExpr) _, isStructKeyExpr := m.(*ir.StructKeyExpr) _, isKeyExpr := m.(*ir.KeyExpr) if !isCallExpr && !isStructKeyExpr && !isKeyExpr && x.Op() != ir.OPANIC && x.Op() != ir.OCLOSE { - base.Fatalf(fmt.Sprintf("Nil type for %v", x)) + base.FatalfAt(m.Pos(), "Nil type for %v", x) } } else if x.Op() != ir.OCLOSURE { m.SetType(subst.ts.Typ(x.Type())) @@ -991,56 +992,55 @@ func (subst *subster) node(n ir.Node) ir.Node { ir.EditChildren(m, edit) m.SetTypecheck(1) - if x.Op().IsCmp() { - transformCompare(m.(*ir.BinaryExpr)) - } else { - switch x.Op() { - case ir.OSLICE, ir.OSLICE3: - transformSlice(m.(*ir.SliceExpr)) - - case ir.OADD: - m = transformAdd(m.(*ir.BinaryExpr)) - - case ir.OINDEX: - transformIndex(m.(*ir.IndexExpr)) - - case ir.OAS2: - as2 := m.(*ir.AssignListStmt) - transformAssign(as2, as2.Lhs, as2.Rhs) - - case ir.OAS: - as := m.(*ir.AssignStmt) - if as.Y != nil { - // transformAssign doesn't handle the case - // of zeroing assignment of a dcl (rhs[0] is nil). - lhs, rhs := []ir.Node{as.X}, []ir.Node{as.Y} - transformAssign(as, lhs, rhs) - as.X, as.Y = lhs[0], rhs[0] - } - - case ir.OASOP: - as := m.(*ir.AssignOpStmt) - transformCheckAssign(as, as.X) - - case ir.ORETURN: - transformReturn(m.(*ir.ReturnStmt)) - - case ir.OSEND: - transformSend(m.(*ir.SendStmt)) - - case ir.OSELECT: - transformSelect(m.(*ir.SelectStmt)) - - case ir.OCOMPLIT: - transformCompLit(m.(*ir.CompLitExpr)) - - case ir.OADDR: - transformAddr(m.(*ir.AddrExpr)) - - } - } + // Do the transformations that we delayed on the generic function + // node, now that we have substituted in the type args. switch x.Op() { + case ir.OEQ, ir.ONE, ir.OLT, ir.OLE, ir.OGT, ir.OGE: + transformCompare(m.(*ir.BinaryExpr)) + + case ir.OSLICE, ir.OSLICE3: + transformSlice(m.(*ir.SliceExpr)) + + case ir.OADD: + m = transformAdd(m.(*ir.BinaryExpr)) + + case ir.OINDEX: + transformIndex(m.(*ir.IndexExpr)) + + case ir.OAS2: + as2 := m.(*ir.AssignListStmt) + transformAssign(as2, as2.Lhs, as2.Rhs) + + case ir.OAS: + as := m.(*ir.AssignStmt) + if as.Y != nil { + // transformAssign doesn't handle the case + // of zeroing assignment of a dcl (rhs[0] is nil). + lhs, rhs := []ir.Node{as.X}, []ir.Node{as.Y} + transformAssign(as, lhs, rhs) + as.X, as.Y = lhs[0], rhs[0] + } + + case ir.OASOP: + as := m.(*ir.AssignOpStmt) + transformCheckAssign(as, as.X) + + case ir.ORETURN: + transformReturn(m.(*ir.ReturnStmt)) + + case ir.OSEND: + transformSend(m.(*ir.SendStmt)) + + case ir.OSELECT: + transformSelect(m.(*ir.SelectStmt)) + + case ir.OCOMPLIT: + transformCompLit(m.(*ir.CompLitExpr)) + + case ir.OADDR: + transformAddr(m.(*ir.AddrExpr)) + case ir.OLITERAL: t := m.Type() if t != x.Type() { @@ -1058,16 +1058,13 @@ func (subst *subster) node(n ir.Node) ir.Node { } case ir.OXDOT: - // A method value/call via a type param will have been - // left as an OXDOT. When we see this during stenciling, - // finish the transformation, now that we have the - // instantiated receiver type. We need to do this now, - // since the access/selection to the method for the real - // type is very different from the selection for the type - // param. m will be transformed to an OMETHVALUE node. It - // will be transformed to an ODOTMETH or ODOTINTER node if - // we find in the OCALL case below that the method value - // is actually called. + // Finish the transformation of an OXDOT, unless this was a + // bound call (a direct call on a type param). A bound call + // will be transformed during the dictPass. Otherwise, m + // will be transformed to an OMETHVALUE node. It will be + // transformed to an ODOTMETH or ODOTINTER node if we find in + // the OCALL case below that the method value is actually + // called. mse := m.(*ir.SelectorExpr) if src := mse.X.Type(); !src.IsShape() { transformDot(mse, false) @@ -1080,7 +1077,7 @@ func (subst *subster) node(n ir.Node) ir.Node { // Transform the conversion, now that we know the // type argument. m = transformConvCall(call) - // CONVIFACE transformation was already done in node2 + // CONVIFACE transformation was already done in noder2 assert(m.Op() != ir.OCONVIFACE) case ir.OMETHVALUE, ir.OMETHEXPR: @@ -1116,34 +1113,29 @@ func (subst *subster) node(n ir.Node) ir.Node { transformCall(call) } - case ir.OCLOSURE: - transformCall(call) - - case ir.ODEREF, ir.OINDEX, ir.OINDEXMAP, ir.ORECV: - // Transform a call that was delayed because of the - // use of typeparam inside an expression that required - // a pointer dereference, array indexing, map indexing, - // or channel receive to compute function value. - transformCall(call) - - case ir.OCALL, ir.OCALLFUNC, ir.OCALLMETH, ir.OCALLINTER: - transformCall(call) - - case ir.OCONVNOP: - transformCall(call) - case ir.OFUNCINST: // A call with an OFUNCINST will get transformed // in stencil() once we have created & attached the // instantiation to be called. // We must transform the arguments of the call now, though, // so that any needed CONVIFACE nodes are exposed, - // so the dictionary format is correct + // so the dictionary format is correct. transformEarlyCall(call) - case ir.OXDOT, ir.ODOTTYPE, ir.ODOTTYPE2: + case ir.OXDOT: + // This is the case of a bound call on a typeparam, + // which will be handled in the dictPass. + + case ir.ODOTTYPE, ir.ODOTTYPE2: + // These are DOTTYPEs that could get transformed into + // ODYNAMIC DOTTYPEs by the dict pass. + default: - base.FatalfAt(call.Pos(), fmt.Sprintf("Unexpected op with CALL during stenciling: %v", call.X.Op())) + // Transform a call for all other values of + // call.X.Op() that don't require any special + // handling. + transformCall(call) + } case ir.OCLOSURE: @@ -1268,16 +1260,13 @@ func (g *genInst) dictPass(info *instInfo) { } case ir.OCALL: op := m.(*ir.CallExpr).X.Op() - if op != ir.OFUNCINST { - assert(op == ir.OMETHVALUE || op == ir.OCLOSURE || op == ir.ODYNAMICDOTTYPE || op == ir.ODYNAMICDOTTYPE2) - if op == ir.OMETHVALUE { - // Redo the transformation of OXDOT, now that we - // know the method value is being called. - m.(*ir.CallExpr).X.(*ir.SelectorExpr).SetOp(ir.OXDOT) - transformDot(m.(*ir.CallExpr).X.(*ir.SelectorExpr), true) - } - transformCall(m.(*ir.CallExpr)) + if op == ir.OMETHVALUE { + // Redo the transformation of OXDOT, now that we + // know the method value is being called. + m.(*ir.CallExpr).X.(*ir.SelectorExpr).SetOp(ir.OXDOT) + transformDot(m.(*ir.CallExpr).X.(*ir.SelectorExpr), true) } + transformCall(m.(*ir.CallExpr)) case ir.OCONVIFACE: if m.Type().IsEmptyInterface() && m.(*ir.ConvExpr).X.Type().IsEmptyInterface() { diff --git a/test/typeparam/issue47878.go b/test/typeparam/issue47878.go index cb1043a440..6ad183d221 100644 --- a/test/typeparam/issue47878.go +++ b/test/typeparam/issue47878.go @@ -31,6 +31,13 @@ func (s Src4[T]) Next() { _ = (<-s)() } +type Src5[T any] func() Src5[T] + +func (s Src5[T]) Next() { + var x interface{} = s + _ = (x.(Src5[T]))() +} + func main() { var src1 Src1[int] src1.Next() @@ -43,4 +50,7 @@ func main() { var src4 Src4[int] src4.Next() + + var src5 Src5[int] + src5.Next() } From f8779b9e757e38810bec2284e06fea20bbf09bf4 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 1 Apr 2021 17:01:51 -0400 Subject: [PATCH 168/406] runtime: rename _m_ to mp [generated] _g_, _p_, and _m_ are primarily vestiges of the C version of the runtime, while today we prefer Go-style variable names (generally gp, pp, and mp). This change replaces all remaining uses of _m_ with mp. There are very few remaining and all replacements are trivial. [git-generate] cd src/runtime rf 'mv canpanic._m_ canpanic.mp' GOOS=solaris \ rf 'mv semasleep._m_ semasleep.mp' GOOS=aix GOARCH=ppc64 \ rf 'mv semasleep._m_ semasleep.mp' Change-Id: I83690f7b4d4dc57557963100e9a2560ff343f3e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/307813 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Michael Knyszek --- src/runtime/os3_solaris.go | 40 +++++++++++++++++++------------------- src/runtime/os_aix.go | 8 ++++---- src/runtime/panic.go | 8 ++++---- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/runtime/os3_solaris.go b/src/runtime/os3_solaris.go index 3149d13869..2e946656d0 100644 --- a/src/runtime/os3_solaris.go +++ b/src/runtime/os3_solaris.go @@ -329,20 +329,20 @@ func semacreate(mp *m) { //go:nosplit func semasleep(ns int64) int32 { - _m_ := getg().m + mp := getg().m if ns >= 0 { - _m_.ts.tv_sec = ns / 1000000000 - _m_.ts.tv_nsec = ns % 1000000000 + mp.ts.tv_sec = ns / 1000000000 + mp.ts.tv_nsec = ns % 1000000000 - _m_.libcall.fn = uintptr(unsafe.Pointer(&libc_sem_reltimedwait_np)) - _m_.libcall.n = 2 - _m_.scratch = mscratch{} - _m_.scratch.v[0] = _m_.waitsema - _m_.scratch.v[1] = uintptr(unsafe.Pointer(&_m_.ts)) - _m_.libcall.args = uintptr(unsafe.Pointer(&_m_.scratch)) - asmcgocall(unsafe.Pointer(&asmsysvicall6x), unsafe.Pointer(&_m_.libcall)) - if *_m_.perrno != 0 { - if *_m_.perrno == _ETIMEDOUT || *_m_.perrno == _EAGAIN || *_m_.perrno == _EINTR { + mp.libcall.fn = uintptr(unsafe.Pointer(&libc_sem_reltimedwait_np)) + mp.libcall.n = 2 + mp.scratch = mscratch{} + mp.scratch.v[0] = mp.waitsema + mp.scratch.v[1] = uintptr(unsafe.Pointer(&mp.ts)) + mp.libcall.args = uintptr(unsafe.Pointer(&mp.scratch)) + asmcgocall(unsafe.Pointer(&asmsysvicall6x), unsafe.Pointer(&mp.libcall)) + if *mp.perrno != 0 { + if *mp.perrno == _ETIMEDOUT || *mp.perrno == _EAGAIN || *mp.perrno == _EINTR { return -1 } throw("sem_reltimedwait_np") @@ -350,16 +350,16 @@ func semasleep(ns int64) int32 { return 0 } for { - _m_.libcall.fn = uintptr(unsafe.Pointer(&libc_sem_wait)) - _m_.libcall.n = 1 - _m_.scratch = mscratch{} - _m_.scratch.v[0] = _m_.waitsema - _m_.libcall.args = uintptr(unsafe.Pointer(&_m_.scratch)) - asmcgocall(unsafe.Pointer(&asmsysvicall6x), unsafe.Pointer(&_m_.libcall)) - if _m_.libcall.r1 == 0 { + mp.libcall.fn = uintptr(unsafe.Pointer(&libc_sem_wait)) + mp.libcall.n = 1 + mp.scratch = mscratch{} + mp.scratch.v[0] = mp.waitsema + mp.libcall.args = uintptr(unsafe.Pointer(&mp.scratch)) + asmcgocall(unsafe.Pointer(&asmsysvicall6x), unsafe.Pointer(&mp.libcall)) + if mp.libcall.r1 == 0 { break } - if *_m_.perrno == _EINTR { + if *mp.perrno == _EINTR { continue } throw("sem_wait") diff --git a/src/runtime/os_aix.go b/src/runtime/os_aix.go index 54e0cfbb8d..c21da4ddaa 100644 --- a/src/runtime/os_aix.go +++ b/src/runtime/os_aix.go @@ -49,7 +49,7 @@ func semacreate(mp *m) { //go:nosplit func semasleep(ns int64) int32 { - _m_ := getg().m + mp := getg().m if ns >= 0 { var ts timespec @@ -63,17 +63,17 @@ func semasleep(ns int64) int32 { ts.tv_nsec -= 1e9 } - if r, err := sem_timedwait((*semt)(unsafe.Pointer(_m_.waitsema)), &ts); r != 0 { + if r, err := sem_timedwait((*semt)(unsafe.Pointer(mp.waitsema)), &ts); r != 0 { if err == _ETIMEDOUT || err == _EAGAIN || err == _EINTR { return -1 } - println("sem_timedwait err ", err, " ts.tv_sec ", ts.tv_sec, " ts.tv_nsec ", ts.tv_nsec, " ns ", ns, " id ", _m_.id) + println("sem_timedwait err ", err, " ts.tv_sec ", ts.tv_sec, " ts.tv_nsec ", ts.tv_nsec, " ns ", ns, " id ", mp.id) throw("sem_timedwait") } return 0 } for { - r1, err := sem_wait((*semt)(unsafe.Pointer(_m_.waitsema))) + r1, err := sem_wait((*semt)(unsafe.Pointer(mp.waitsema))) if r1 == 0 { break } diff --git a/src/runtime/panic.go b/src/runtime/panic.go index 942898716e..c4f3f41ff5 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -1190,22 +1190,22 @@ func canpanic(gp *g) bool { // Note also that g->m can change at preemption, so m can go stale // if this function ever makes a function call. _g_ := getg() - _m_ := _g_.m + mp := _g_.m // Is it okay for gp to panic instead of crashing the program? // Yes, as long as it is running Go code, not runtime code, // and not stuck in a system call. - if gp == nil || gp != _m_.curg { + if gp == nil || gp != mp.curg { return false } - if _m_.locks != 0 || _m_.mallocing != 0 || _m_.throwing != 0 || _m_.preemptoff != "" || _m_.dying != 0 { + if mp.locks != 0 || mp.mallocing != 0 || mp.throwing != 0 || mp.preemptoff != "" || mp.dying != 0 { return false } status := readgstatus(gp) if status&^_Gscan != _Grunning || gp.syscallsp != 0 { return false } - if GOOS == "windows" && _m_.libcallsp != 0 { + if GOOS == "windows" && mp.libcallsp != 0 { return false } return true From 3a0cd1121413ad02172784114318ac6b0c2801c1 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 9 Jul 2020 09:13:34 -0700 Subject: [PATCH 169/406] sync/atomic: use a better first-store-in-progress marker Unlike what the comment says, the GC can see this pointer. Might as well make it a real pointer, even though ^uintptr(0) isn't currently causing problems. Removed the comment about GC not seeing the pointer. Change-Id: I04bc1fd4848698bec6afb79bd5fda671dfc9a073 Reviewed-on: https://go-review.googlesource.com/c/go/+/241661 Run-TryBot: Keith Randall Reviewed-by: Colin Arnott Reviewed-by: Dmitry Vyukov TryBot-Result: Go Bot Trust: Keith Randall --- src/sync/atomic/value.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/sync/atomic/value.go b/src/sync/atomic/value.go index 3500cd22f4..af6295de91 100644 --- a/src/sync/atomic/value.go +++ b/src/sync/atomic/value.go @@ -28,7 +28,7 @@ type ifaceWords struct { func (v *Value) Load() (val interface{}) { vp := (*ifaceWords)(unsafe.Pointer(v)) typ := LoadPointer(&vp.typ) - if typ == nil || uintptr(typ) == ^uintptr(0) { + if typ == nil || typ == unsafe.Pointer(&firstStoreInProgress) { // First store not yet completed. return nil } @@ -39,6 +39,8 @@ func (v *Value) Load() (val interface{}) { return } +var firstStoreInProgress byte + // Store sets the value of the Value to x. // All calls to Store for a given Value must use values of the same concrete type. // Store of an inconsistent type panics, as does Store(nil). @@ -53,10 +55,9 @@ func (v *Value) Store(val interface{}) { if typ == nil { // Attempt to start first store. // Disable preemption so that other goroutines can use - // active spin wait to wait for completion; and so that - // GC does not see the fake type accidentally. + // active spin wait to wait for completion. runtime_procPin() - if !CompareAndSwapPointer(&vp.typ, nil, unsafe.Pointer(^uintptr(0))) { + if !CompareAndSwapPointer(&vp.typ, nil, unsafe.Pointer(&firstStoreInProgress)) { runtime_procUnpin() continue } @@ -66,7 +67,7 @@ func (v *Value) Store(val interface{}) { runtime_procUnpin() return } - if uintptr(typ) == ^uintptr(0) { + if typ == unsafe.Pointer(&firstStoreInProgress) { // First store in progress. Wait. // Since we disable preemption around the first store, // we can wait with active spinning. From 091db6392da5913e4bd4806215102e461dc5649c Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 4 Aug 2021 11:24:28 -0400 Subject: [PATCH 170/406] runtime: fix cgo signals detection CL 64070 removed lockOSThread from the cgocall path, but didn't update the signal-in-cgo detection in sighandler. As a result, signals that arrive during a cgo call are treated like they arrived during Go execution, breaking the traceback. Update the cgo detection to fix the backtrace. Fixes #47522 Change-Id: I61d77ba6465f55e3e6187246d79675ba8467ec23 Reviewed-on: https://go-review.googlesource.com/c/go/+/339989 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Cherry Mui Reviewed-by: Ian Lance Taylor Reviewed-by: Austin Clements --- src/runtime/crash_cgo_test.go | 45 ++++++++++++++++++++ src/runtime/signal_unix.go | 6 ++- src/runtime/signal_windows.go | 4 +- src/runtime/testdata/testprogcgo/panic.go | 29 +++++++++++++ src/runtime/testdata/testprogcgo/sigthrow.go | 20 +++++++++ 5 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 src/runtime/testdata/testprogcgo/panic.go create mode 100644 src/runtime/testdata/testprogcgo/sigthrow.go diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go index ce7bed920f..9df6fcd48b 100644 --- a/src/runtime/crash_cgo_test.go +++ b/src/runtime/crash_cgo_test.go @@ -536,6 +536,29 @@ func TestCgoTracebackSigpanic(t *testing.T) { } } +func TestCgoPanicCallback(t *testing.T) { + t.Parallel() + got := runTestProg(t, "testprogcgo", "PanicCallback") + t.Log(got) + want := "panic: runtime error: invalid memory address or nil pointer dereference" + if !strings.Contains(got, want) { + t.Errorf("did not see %q in output", want) + } + want = "panic_callback" + if !strings.Contains(got, want) { + t.Errorf("did not see %q in output", want) + } + want = "PanicCallback" + if !strings.Contains(got, want) { + t.Errorf("did not see %q in output", want) + } + // No runtime errors like "runtime: unexpected return pc". + nowant := "runtime: " + if strings.Contains(got, nowant) { + t.Errorf("did not see %q in output", want) + } +} + // Test that C code called via cgo can use large Windows thread stacks // and call back in to Go without crashing. See issue #20975. // @@ -603,6 +626,28 @@ func TestSegv(t *testing.T) { } } +func TestAbortInCgo(t *testing.T) { + switch runtime.GOOS { + case "plan9", "windows": + // N.B. On Windows, C abort() causes the program to exit + // without going through the runtime at all. + t.Skipf("no signals on %s", runtime.GOOS) + } + + t.Parallel() + got := runTestProg(t, "testprogcgo", "Abort") + t.Log(got) + want := "SIGABRT" + if !strings.Contains(got, want) { + t.Errorf("did not see %q in output", want) + } + // No runtime errors like "runtime: unknown pc". + nowant := "runtime: " + if strings.Contains(got, nowant) { + t.Errorf("did not see %q in output", want) + } +} + // TestEINTR tests that we handle EINTR correctly. // See issue #20400 and friends. func TestEINTR(t *testing.T) { diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go index 07f371cefe..8854629224 100644 --- a/src/runtime/signal_unix.go +++ b/src/runtime/signal_unix.go @@ -688,9 +688,11 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) { } print("PC=", hex(c.sigpc()), " m=", _g_.m.id, " sigcode=", c.sigcode(), "\n") - if _g_.m.lockedg != 0 && _g_.m.ncgo > 0 && gp == _g_.m.g0 { + if _g_.m.incgo && gp == _g_.m.g0 && _g_.m.curg != nil { print("signal arrived during cgo execution\n") - gp = _g_.m.lockedg.ptr() + // Switch to curg so that we get a traceback of the Go code + // leading up to the cgocall, which switched from curg to g0. + gp = _g_.m.curg } if sig == _SIGILL || sig == _SIGFPE { // It would be nice to know how long the instruction is. diff --git a/src/runtime/signal_windows.go b/src/runtime/signal_windows.go index 3fe352ef57..16c36d07f1 100644 --- a/src/runtime/signal_windows.go +++ b/src/runtime/signal_windows.go @@ -218,11 +218,11 @@ func winthrow(info *exceptionrecord, r *context, gp *g) { print("Exception ", hex(info.exceptioncode), " ", hex(info.exceptioninformation[0]), " ", hex(info.exceptioninformation[1]), " ", hex(r.ip()), "\n") print("PC=", hex(r.ip()), "\n") - if _g_.m.lockedg != 0 && _g_.m.ncgo > 0 && gp == _g_.m.g0 { + if _g_.m.incgo && gp == _g_.m.g0 && _g_.m.curg != nil { if iscgo { print("signal arrived during external code execution\n") } - gp = _g_.m.lockedg.ptr() + gp = _g_.m.curg } print("\n") diff --git a/src/runtime/testdata/testprogcgo/panic.go b/src/runtime/testdata/testprogcgo/panic.go new file mode 100644 index 0000000000..4ddef3abcd --- /dev/null +++ b/src/runtime/testdata/testprogcgo/panic.go @@ -0,0 +1,29 @@ +package main + +import "C" + +// This program will crash. +// We want to test unwinding from a cgo callback. + +/* +void panic_callback(); + +static void call_callback(void) { + panic_callback(); +} +*/ +import "C" + +func init() { + register("PanicCallback", PanicCallback) +} + +//export panic_callback +func panic_callback() { + var i *int + *i = 42 +} + +func PanicCallback() { + C.call_callback() +} diff --git a/src/runtime/testdata/testprogcgo/sigthrow.go b/src/runtime/testdata/testprogcgo/sigthrow.go new file mode 100644 index 0000000000..665e3b02df --- /dev/null +++ b/src/runtime/testdata/testprogcgo/sigthrow.go @@ -0,0 +1,20 @@ +// Copyright 2021 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 main + +// This program will abort. + +/* +#include +*/ +import "C" + +func init() { + register("Abort", Abort) +} + +func Abort() { + C.abort() +} From 86f6bf18b013d570e89f57c2decaddca5ce2a847 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 4 Aug 2021 17:33:50 -0400 Subject: [PATCH 171/406] runtime: handle async fatal signals in VDSO If we receive an async signal while running in the VDSO, such as a SIGABRT or SIGSEGV sent from another process, we fail to print the stacktrace with "runtime: unknown pc ". We already have machinery to handle SIGPROF in the VDSO, but it isn't hooked up for other signals. Add it to the general signal traceback path. This case is covered by TestSegv by making the test more strict w.r.t. accepted output. Fixes #47537 Change-Id: I755585f70e0c23e207e135bc6bd2aa68298e5d24 Reviewed-on: https://go-review.googlesource.com/c/go/+/339990 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- src/runtime/crash_cgo_test.go | 18 +++++++++++++----- src/runtime/traceback.go | 11 +++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go index 9df6fcd48b..0ccfe8580a 100644 --- a/src/runtime/crash_cgo_test.go +++ b/src/runtime/crash_cgo_test.go @@ -526,13 +526,15 @@ func TestCgoTracebackSigpanic(t *testing.T) { } t.Parallel() got := runTestProg(t, "testprogcgo", "TracebackSigpanic") + t.Log(got) want := "runtime.sigpanic" if !strings.Contains(got, want) { - t.Fatalf("want failure containing %q. output:\n%s\n", want, got) + t.Errorf("did not see %q in output", want) } - nowant := "unexpected return pc" + // No runtime errors like "runtime: unexpected return pc". + nowant := "runtime: " if strings.Contains(got, nowant) { - t.Fatalf("failure incorrectly contains %q. output:\n%s\n", nowant, got) + t.Errorf("unexpectedly saw %q in output", want) } } @@ -619,8 +621,14 @@ func TestSegv(t *testing.T) { t.Parallel() got := runTestProg(t, "testprogcgo", test) t.Log(got) - if !strings.Contains(got, "SIGSEGV") { - t.Errorf("expected crash from signal") + want := "SIGSEGV" + if !strings.Contains(got, want) { + t.Errorf("did not see %q in output", want) + } + // No runtime errors like "runtime: unknown pc". + nowant := "runtime: " + if strings.Contains(got, nowant) { + t.Errorf("unexpectedly saw %q in output", want) } }) } diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 530d572095..7e1b14ccf2 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -777,16 +777,23 @@ func traceback1(pc, sp, lr uintptr, gp *g, flags uint) { printCgoTraceback(&cgoCallers) } - var n int if readgstatus(gp)&^_Gscan == _Gsyscall { // Override registers if blocked in system call. pc = gp.syscallpc sp = gp.syscallsp flags &^= _TraceTrap } + if gp.m != nil && gp.m.vdsoSP != 0 { + // Override registers if running in VDSO. This comes after the + // _Gsyscall check to cover VDSO calls after entersyscall. + pc = gp.m.vdsoPC + sp = gp.m.vdsoSP + flags &^= _TraceTrap + } + // Print traceback. By default, omits runtime frames. // If that means we print nothing at all, repeat forcing all frames printed. - n = gentraceback(pc, sp, lr, gp, 0, nil, _TracebackMaxFrames, nil, nil, flags) + n := gentraceback(pc, sp, lr, gp, 0, nil, _TracebackMaxFrames, nil, nil, flags) if n == 0 && (flags&_TraceRuntimeFrames) == 0 { n = gentraceback(pc, sp, lr, gp, 0, nil, _TracebackMaxFrames, nil, nil, flags|_TraceRuntimeFrames) } From 80be4a4f90836a33ab5b3d09c6f529de8ee628ea Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 26 Oct 2021 14:47:07 -0700 Subject: [PATCH 172/406] crypto/x509: generate new-style build tags for iOS Make the input match gofmt's output, to make our lives easier as we phase out old style build tags. Change-Id: I95dc5a77058bf17cb02e289703f60784616db006 Reviewed-on: https://go-review.googlesource.com/c/go/+/358934 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder Reviewed-by: Brad Fitzpatrick TryBot-Result: Go Bot --- src/crypto/x509/root_ios_gen.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crypto/x509/root_ios_gen.go b/src/crypto/x509/root_ios_gen.go index 05bd672d5d..3c98de5bb6 100644 --- a/src/crypto/x509/root_ios_gen.go +++ b/src/crypto/x509/root_ios_gen.go @@ -164,8 +164,8 @@ func main() { const header = `// Code generated by root_ios_gen.go -version %s; DO NOT EDIT. // Update the version in root.go and regenerate with "go generate". -// +build ios -// +build !x509omitbundledroots +//go:build ios && !x509omitbundledroots +// +build ios,!x509omitbundledroots package x509 From e5c512520bd0a51d59b39556795a47db888d69b5 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 28 Jul 2021 11:59:01 -0700 Subject: [PATCH 173/406] crypto/elliptic: use a const string for precomputed P256 table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Const strings can be marked readonly. This is particularly important for this relatively large table (88kb). This is a follow-up to CL 315189. The generation script is a bit awkward. It needs access to crypto/elliptic internals, but also needs to be package main. Work around this by exporting those internals with the "tablegen" build tag. This requires changing the function signature at the Go-asm bridge. As long as we're here, shrink the point argument type as well; the net result is three fewer words of params. Performance impact is probably noise. name old time/op new time/op delta ScalarBaseMult/P256-8 11.4µs ± 2% 11.3µs ± 1% -1.32% (p=0.000 n=19+16) ScalarBaseMult/P224-8 579µs ± 1% 577µs ± 0% -0.30% (p=0.024 n=19+20) ScalarBaseMult/P384-8 2.31ms ± 4% 2.34ms ± 4% +1.25% (p=0.033 n=20+20) ScalarBaseMult/P521-8 1.33ms ± 0% 1.33ms ± 1% ~ (p=0.173 n=18+17) ScalarMult/P256-8 42.7µs ± 0% 42.7µs ± 2% ~ (p=0.989 n=20+20) ScalarMult/P224-8 579µs ± 0% 579µs ± 0% ~ (p=0.538 n=19+18) ScalarMult/P384-8 2.32ms ± 3% 2.34ms ± 5% ~ (p=0.235 n=19+20) ScalarMult/P521-8 1.33ms ± 1% 1.34ms ± 2% ~ (p=0.141 n=17+20) Change-Id: I3bee56df34ae61ca8829791d2e67e058ecc8ddbe Reviewed-on: https://go-review.googlesource.com/c/go/+/339591 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder Reviewed-by: Roland Shoemaker Reviewed-by: Brad Fitzpatrick Reviewed-by: Filippo Valsorda TryBot-Result: Go Bot --- src/crypto/elliptic/export_generate.go | 17 + src/crypto/elliptic/gen_p256_table.go | 112 + src/crypto/elliptic/p256_asm.go | 8 +- src/crypto/elliptic/p256_asm_amd64.s | 6 +- src/crypto/elliptic/p256_asm_arm64.s | 6 +- src/crypto/elliptic/p256_asm_table.go | 2886 ++++++++++---------- src/crypto/elliptic/p256_asm_table_test.go | 8 +- 7 files changed, 1569 insertions(+), 1474 deletions(-) create mode 100644 src/crypto/elliptic/export_generate.go create mode 100644 src/crypto/elliptic/gen_p256_table.go diff --git a/src/crypto/elliptic/export_generate.go b/src/crypto/elliptic/export_generate.go new file mode 100644 index 0000000000..5fe3025cf8 --- /dev/null +++ b/src/crypto/elliptic/export_generate.go @@ -0,0 +1,17 @@ +// Copyright 2021 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. + +//go:build tablegen +// +build tablegen + +package elliptic + +// This block exports p256-related internals for the p256 table generator in internal/gen. +var ( + P256PointDoubleAsm = p256PointDoubleAsm + P256PointAddAsm = p256PointAddAsm + P256Inverse = p256Inverse + P256Sqr = p256Sqr + P256Mul = p256Mul +) diff --git a/src/crypto/elliptic/gen_p256_table.go b/src/crypto/elliptic/gen_p256_table.go new file mode 100644 index 0000000000..cdcddcb736 --- /dev/null +++ b/src/crypto/elliptic/gen_p256_table.go @@ -0,0 +1,112 @@ +// Copyright 2021 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. + +//go:build ignore +// +build ignore + +package main + +import ( + "bytes" + "crypto/elliptic" + "encoding/binary" + "fmt" + "go/format" + "log" + "os" +) + +func main() { + buf := new(bytes.Buffer) + fmt.Fprint(buf, ` +// Copyright 2021 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. + +// Generated by gen_p256_table.go. DO NOT EDIT. + +//go:build amd64 || arm64 +// +build amd64 arm64 + +package elliptic + +`[1:]) + + // Generate precomputed p256 tables. + var pre [43][32 * 8]uint64 + basePoint := []uint64{ + 0x79e730d418a9143c, 0x75ba95fc5fedb601, 0x79fb732b77622510, 0x18905f76a53755c6, + 0xddf25357ce95560a, 0x8b4ab8e4ba19e45c, 0xd2e88688dd21f325, 0x8571ff1825885d85, + 0x0000000000000001, 0xffffffff00000000, 0xffffffffffffffff, 0x00000000fffffffe, + } + t1 := make([]uint64, 12) + t2 := make([]uint64, 12) + copy(t2, basePoint) + zInv := make([]uint64, 4) + zInvSq := make([]uint64, 4) + for j := 0; j < 32; j++ { + copy(t1, t2) + for i := 0; i < 43; i++ { + // The window size is 6 so we need to double 6 times. + if i != 0 { + for k := 0; k < 6; k++ { + elliptic.P256PointDoubleAsm(t1, t1) + } + } + // Convert the point to affine form. (Its values are + // still in Montgomery form however.) + elliptic.P256Inverse(zInv, t1[8:12]) + elliptic.P256Sqr(zInvSq, zInv, 1) + elliptic.P256Mul(zInv, zInv, zInvSq) + elliptic.P256Mul(t1[:4], t1[:4], zInvSq) + elliptic.P256Mul(t1[4:8], t1[4:8], zInv) + copy(t1[8:12], basePoint[8:12]) + // Update the table entry + copy(pre[i][j*8:], t1[:8]) + } + if j == 0 { + elliptic.P256PointDoubleAsm(t2, basePoint) + } else { + elliptic.P256PointAddAsm(t2, t2, basePoint) + } + } + + fmt.Fprint(buf, "const p256Precomputed = \"\" +\n\n") + + // Dump the precomputed tables, flattened, little-endian. + // These tables are used directly by assembly on little-endian platforms. + // Putting the data in a const string lets it be stored readonly. + for i := range &pre { + for j, v := range &pre[i] { + fmt.Fprintf(buf, "\"") + var u8 [8]byte + binary.LittleEndian.PutUint64(u8[:], v) + for _, b := range &u8 { + fmt.Fprintf(buf, "\\x%02x", b) + } + fmt.Fprintf(buf, "\"") + if i < len(pre)-1 || j < len(pre[i])-1 { + fmt.Fprint(buf, "+") + } + if j%8 == 7 { + fmt.Fprint(buf, "\n") + } + } + fmt.Fprint(buf, "\n") + } + + src := buf.Bytes() + fmtsrc, fmterr := format.Source(src) + // If formatting failed, keep the original source for debugging. + if fmterr == nil { + src = fmtsrc + } + err := os.WriteFile("p256_asm_table.go", src, 0644) + if err != nil { + log.Fatal(err) + } + if fmterr != nil { + log.Fatal(fmterr) + } +} diff --git a/src/crypto/elliptic/p256_asm.go b/src/crypto/elliptic/p256_asm.go index 9a808f260a..d46b809125 100644 --- a/src/crypto/elliptic/p256_asm.go +++ b/src/crypto/elliptic/p256_asm.go @@ -19,6 +19,8 @@ import ( "math/big" ) +//go:generate go run -tags=tablegen gen_p256_table.go + type ( p256Curve struct { *CurveParams @@ -79,7 +81,7 @@ func p256LittleToBig(res []byte, in []uint64) func p256Select(point, table []uint64, idx int) //go:noescape -func p256SelectBase(point, table []uint64, idx int) +func p256SelectBase(point *[12]uint64, table string, idx int) // Montgomery multiplication modulo Ord(G) //go:noescape @@ -410,7 +412,7 @@ func boothW6(in uint) (int, int) { func (p *p256Point) p256BaseMult(scalar []uint64) { wvalue := (scalar[0] << 1) & 0x7f sel, sign := boothW6(uint(wvalue)) - p256SelectBase(p.xyz[0:8], p256Precomputed[0][0:], sel) + p256SelectBase(&p.xyz, p256Precomputed, sel) p256NegCond(p.xyz[4:8], sign) // (This is one, in the Montgomery domain.) @@ -437,7 +439,7 @@ func (p *p256Point) p256BaseMult(scalar []uint64) { } index += 6 sel, sign = boothW6(uint(wvalue)) - p256SelectBase(t0.xyz[0:8], p256Precomputed[i][0:], sel) + p256SelectBase(&t0.xyz, p256Precomputed[i*32*8*8:], sel) p256PointAddAffineAsm(p.xyz[0:12], p.xyz[0:12], t0.xyz[0:8], sign, sel, zero) zero |= sel } diff --git a/src/crypto/elliptic/p256_asm_amd64.s b/src/crypto/elliptic/p256_asm_amd64.s index c77b11bcf2..bd16add241 100644 --- a/src/crypto/elliptic/p256_asm_amd64.s +++ b/src/crypto/elliptic/p256_asm_amd64.s @@ -668,10 +668,10 @@ loop_select: RET /* ---------------------------------------*/ // Constant time point access to base point table. -// func p256SelectBase(point, table []uint64, idx int) +// func p256SelectBase(point *[12]uint64, table string, idx int) TEXT ·p256SelectBase(SB),NOSPLIT,$0 - MOVQ idx+48(FP),AX - MOVQ table+24(FP),DI + MOVQ idx+24(FP),AX + MOVQ table+8(FP),DI MOVQ point+0(FP),DX PXOR X15, X15 // X15 = 0 diff --git a/src/crypto/elliptic/p256_asm_arm64.s b/src/crypto/elliptic/p256_asm_arm64.s index f571c50342..2b2355d57c 100644 --- a/src/crypto/elliptic/p256_asm_arm64.s +++ b/src/crypto/elliptic/p256_asm_arm64.s @@ -324,10 +324,10 @@ loop_select: RET /* ---------------------------------------*/ // Constant time point access to base point table. -// func p256SelectBase(point, table []uint64, idx int) +// func p256SelectBase(point *[12]uint64, table string, idx int) TEXT ·p256SelectBase(SB),NOSPLIT,$0 - MOVD idx+48(FP), t0 - MOVD table+24(FP), t1 + MOVD idx+24(FP), t0 + MOVD table_base+8(FP), t1 MOVD point+0(FP), res_ptr EOR x0, x0, x0 diff --git a/src/crypto/elliptic/p256_asm_table.go b/src/crypto/elliptic/p256_asm_table.go index 16a4b4f224..7f81cb6b3f 100644 --- a/src/crypto/elliptic/p256_asm_table.go +++ b/src/crypto/elliptic/p256_asm_table.go @@ -2,1472 +2,1430 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// Generated by gen_p256_table.go. DO NOT EDIT. + //go:build amd64 || arm64 // +build amd64 arm64 package elliptic -var p256Precomputed = &[43][32 * 8]uint64{ - { - 8784043285714375740, 8483257759279461889, 8789745728267363600, 1770019616739251654, 15992936863339206154, 10037038012062884956, 15197544864945402661, 9615747158586711429, - 9583737883674400333, 12279877754802111101, 8296198976379850969, 17778859909846088251, 3401986641240187301, 1525831644595056632, 1849003687033449918, 8702493044913179195, - 18423170064697770279, 12693387071620743675, 7398701556189346968, 2779682216903406718, 12703629940499916779, 6358598532389273114, 8683512038509439374, 15415938252666293255, - 8408419572923862476, 5066733120953500019, 926242532005776114, 6301489109130024811, 3285079390283344806, 1685054835664548935, 7740622190510199342, 9561507292862134371, - 13698695174800826869, 10442832251048252285, 10672604962207744524, 14485711676978308040, 16947216143812808464, 8342189264337602603, 3837253281927274344, 8331789856935110934, - 4627808394696681034, 6174000022702321214, 15351247319787348909, 1371147458593240691, 10651965436787680331, 2998319090323362997, 17592419471314886417, 11874181791118522207, - 524165018444839759, 3157588572894920951, 17599692088379947784, 1421537803477597699, 2902517390503550285, 7440776657136679901, 17263207614729765269, 16928425260420958311, - 2878166099891431311, 5056053391262430293, 10345032411278802027, 13214556496570163981, 17698482058276194679, 2441850938900527637, 1314061001345252336, 6263402014353842038, - 8487436533858443496, 12386798851261442113, 3224748875345095424, 16166568617729909099, 2213369110503306004, 6246347469485852131, 3129440554298978074, 605269941184323483, - 3177531230451277512, 11022989490494865721, 8321856985295555401, 14727273563873821327, 876865438755954294, 14139765236890058248, 6880705719513638354, 8678887646434118325, - 16896703203004244996, 11377226897030111200, 2302364246994590389, 4499255394192625779, 1906858144627445384, 2670515414718439880, 868537809054295101, 7535366755622172814, - 339769604981749608, 12384581172556225075, 2596838235904096350, 5684069910326796630, 913125548148611907, 1661497269948077623, 2892028918424825190, 9220412792897768138, - 14754959387565938441, 1023838193204581133, 13599978343236540433, 8323909593307920217, 3852032956982813055, 7526785533690696419, 8993798556223495105, 18140648187477079959, - 11692087196810962506, 1328079167955601379, 1664008958165329504, 18063501818261063470, 2861243404839114859, 13702578580056324034, 16781565866279299035, 1524194541633674171, - 8267721299596412251, 273633183929630283, 17164190306640434032, 16332882679719778825, 4663567915067622493, 15521151801790569253, 7273215397645141911, 2324445691280731636, - 9262509587234749312, 6377906816499461739, 15415592259881792841, 6113140067088447267, 17505803833889144731, 3922849788840338823, 6180172597177093790, 7272741317181956640, - 10883262735810583709, 17399134577381480315, 12750035195491397119, 13953097270363313998, 2485196748577282439, 393430759246706702, 3408702096065201083, 16993508724217005008, - 6863012803048745338, 5403358912802668606, 12029756355518540153, 7447472859343023066, 7395681837001497117, 5416243410959797052, 2749045697176435642, 7813683613416962381, - 18350218749545913064, 7509253999860752750, 13295789896366834092, 18326374111226872828, 3258048562491844971, 6342797029666289605, 9612474478300039361, 17807494771134060923, - 9986610307523639857, 6419466267862117340, 324428332031706042, 16344106992423140174, 9434790811884847197, 11733262517030341550, 10475871084940451430, 6836751077061091536, - 6209985515928007176, 8422208926220809341, 7866188125456775984, 17071696982741312252, 17482363193291892153, 1949968206030126177, 8823961512355572132, 13873010936602132387, - 1136614876084383862, 14528605954969250458, 7641208364604111421, 18286716654189762724, 10711679476846124804, 7209187038097309348, 11378652158954714549, 8736575389915992180, - 17651988839102959720, 4019365809979531118, 15024676458991206505, 12622721674297982786, 243375780477240745, 16572583194372185930, 5189991834753707889, 9498206494038386287, - 7870185149723322393, 7858065912377481781, 7050328012468471455, 17977001023138181397, 11912539230960339911, 1290924823368819542, 8532615064753763585, 6439520053123840906, - 11863354073576605599, 8052916203396229040, 16399182063316628399, 10837704607074036270, 5444229620349428264, 10866168931038804304, 1298875461760659950, 8904898233335519592, - 7053953350607273992, 16629865408105641272, 1929728580699289339, 11046110151029488400, 9569890690274721816, 6501378768832742664, 1512621765961532661, 17084264658609527495, - 300662505135603380, 15234062183651308307, 5319536121171934679, 11496182741145732970, 10520610739189276272, 4310163027157056344, 3285324287508696251, 3261468597637865009, - 5427469457023618335, 8296698312021944466, 10882999905197052907, 16825284839961451415, 2106903142647479713, 12008841566652934760, 5361688498494289694, 12228623597691228792, - 6799789383171367218, 17419525584795621504, 10685476378747845090, 16314000862057872712, 11014509959317588121, 10396318154903722147, 9986284919279346079, 4005974039875805723, - 12980531573372269379, 11790791377897350561, 14264262096731994829, 14999393269362129980, 15405842559289002684, 13147503876582120266, 15449556979080143937, 5047767509783027570, - 16354606995222167433, 15941889353688553446, 10301254747221876749, 10704428461746587572, 15702361407127630489, 3283718562982354984, 18081088275079496700, 17549094608770385733, - 15620168851912893400, 13762314693487747007, 13577625382054330775, 4116976667540664996, 712200332640207605, 9098568002202933512, 8905476951567380032, 7075673514150314660, - }, - { - 15811459837282651008, 4038049993244767161, 9054218236388056577, 10807376403937048775, 11113869110590438959, 10336442539492421506, 9228056645601479672, 2983388754829658480, - 7189376137127712298, 9147574701720272724, 3983921661449444789, 12479790317447783959, 13221020976679959405, 13001868979553711359, 17918176319017234744, 18030393246529651080, - 13903368497828271814, 8050546449078305498, 6932373216915935575, 16010012759059004304, 15451708272653450375, 211711129247219149, 10435723642185827585, 17790507800712341232, - 5218985848865375996, 5835476376320976237, 9096499658845542933, 8952489298840360492, 16605895184424459659, 505731104315931813, 17784248872812610986, 4151555707609374291, - 2650786429127545939, 15186825834659456704, 6983758297535957561, 1268007525252235269, 11433489869282443481, 12352824209154665189, 14555720778982121964, 3578659908492218328, - 4038120750249579469, 8304001815287976437, 251700810512667658, 17170873737273596918, 12809642145843734737, 5765073376623244019, 7923401246629348462, 5401634486288115286, - 12830329023522940651, 1302336131164509751, 7011936976469244509, 8446680306499168806, 1386043952588989461, 9057741950701319559, 6719607413978812889, 17371065020414280890, - 4963953120977916566, 6585250545846301109, 4490972754776862709, 10674499592300479120, 17494988318349821345, 1814042777264686189, 8938395423478059768, 9062966010283426056, - 4683683785459765575, 8782133909400988812, 7201726172249963453, 16855412996123591560, 12016536526053703526, 6004686128951599125, 4323130180079993082, 7578596978943754924, - 13272384473390546409, 15052793429857194942, 3597944793474963009, 5659515835454510338, 18013102402609680655, 15096936721974473248, 9096406212198787674, 948405832772983882, - 7533214627823316056, 8009521942734148665, 15370181949218639901, 17395801240657257383, 13217990616373936619, 16323510521919428293, 10737557422966235859, 11113837024463125316, - 3879469818714011415, 11493820457829716643, 10091807027724827301, 5032134849078736052, 18015749204009276046, 9667758283246223357, 4629693773460610802, 3807196436109718946, - 3214144211600931504, 9454007581819416365, 15275469051811991033, 18196204074031746058, 14853793468372596948, 7707818604949749658, 3266782539036976530, 12810995382868348472, - 17461133192060813135, 16870745208936545685, 5903437034120721004, 9683544852742219696, 7903581348090948266, 13461951083275541722, 2454715926022970060, 11781268272016425522, - 3026443193966185195, 8027125782547146632, 17998666917527163386, 17214321347454260227, 10230244243647560419, 8728893474426972780, 16205038544687771303, 13771356055080873468, - 5724217930909760221, 15420221591912350415, 9910465013739250802, 12511683773790779491, 2841532862707547306, 16614426471009646589, 407574220261191228, 17422057170120224031, - 17151505459068312604, 2041124098660595410, 3221606782120899146, 1382742171848704850, 17222534050501711510, 3195635935311449393, 17295393886051199723, 6296241746423654238, - 16510537668852450348, 15650518534057329304, 475704671950317376, 782416820485820540, 10970369699990900408, 16601298147057372792, 1599283701215392453, 8464446359559369186, - 602848212987973622, 9275953159572178443, 15133444738457385545, 7264639569553811785, 14831517002293569763, 4277078717758211028, 12880437544322007232, 16339691585101354857, - 3725101809714764432, 2995111022132376824, 9338883729618021504, 8824923738291347476, 3745497072215538317, 3576446898425965872, 2350077748663612773, 15793255155885543355, - 8020669822852194733, 5865488997462325879, 13508617967776537887, 12934930135071898613, 11708185641249600577, 14265801329217514207, 10451671488560352734, 13251349632343744236, - 10155392082337432799, 16725751190167983672, 17791070776350679280, 6653785531179322348, 10087876256887835780, 8422365820961469204, 13614411778251983480, 11687935452237305960, - 6094298050768263419, 13949448434836272414, 14194554169090099223, 2625524360834828424, 2823844915913169919, 14077211807091283985, 15592587505996634401, 6562949920171518305, - 12904339001067417585, 1972265247859388742, 8908590936681392405, 10320719400504224158, 8298368064038407143, 2105745729886511647, 16509751074757847095, 15156289751671616565, - 13922601558154971179, 10541544592627074316, 9996345160543671471, 2956094548427827774, 3384122842786043431, 7003441038438960180, 11945730502649377204, 14797331669618433927, - 533287349958250211, 13929395807878461602, 10036169742264959424, 18402398814900480008, 8793706913568807269, 4438954128288889267, 13996827050589647592, 6637236830429213437, - 4308464751705576538, 12193581114161194913, 7322672375339219540, 329737085274484939, 15312435499764491079, 1530264129038944128, 1545025965426980152, 14559433923601957161, - 885617946245226760, 17871561572095909264, 16413308527330544768, 2938750343525834336, 6332736376778563648, 16772687696658236231, 9760470695949399178, 17420556823805232882, - 15040671962589188567, 5841393164221253498, 8923415548773111750, 17449640982747951473, 541686588805328549, 9579487672246868564, 12793813917570150236, 5744918442591934533, - 12406806484060734474, 4655292039647906135, 5745141229449178147, 12923621608907306732, 1329768221522217568, 16293616079741201891, 16309603918079351385, 8282635243638078478, - 10842935462043546322, 9397166878596340773, 5807145729199489911, 17083242467628861919, 11473470924584853882, 15220945465200609206, 10470712526179658906, 8129601297261864071, - 4407657041250297528, 13832960959347315977, 15056546959967740939, 4350443362134191429, 8013419913016572733, 8888684099801298477, 15401479253620745715, 18279947201669400847, - }, - { - 7454214833719424418, 2128900810399984335, 8254953962723841408, 5341529923812819418, 11486532916552139238, 4528331821405917357, 5048485034448492541, 4189495710753944825, - 9223539587116638677, 879142711399260546, 2878829560233905572, 13081522393987952773, 3067261963348061547, 16008150780594711643, 5466468631453287640, 16659147898971349582, - 8047766502132608624, 8715815570878148809, 9093649079884580138, 3437267783531715968, 17562225708466062266, 3512667182749067601, 9223059995161026858, 1366690634827047376, - 17929132376737482163, 5565926714491294456, 5252303555134107501, 8169975563698132305, 1829326230943509100, 13780918661853274468, 17736665596871232627, 4246797342334307384, - 5113556452592134569, 7304867793218750141, 6016631926489320290, 16471860203547627727, 3444471410714850041, 16571738096215232488, 2003912224952639024, 4203884000388032492, - 16858425223672505353, 3192567884201479579, 1688923188642613263, 4159042130811153987, 14900413503869744297, 7521485042788722327, 14038093805562042641, 14713051866364662650, - 3738774192924465076, 14037618828827556145, 12882915396530927286, 10882862194263941815, 13115222579444494605, 18244214260845794346, 17217867059738274194, 2458870331386500577, - 8768788172344064509, 2761897497254272960, 1400167175024837359, 2591319596670212133, 1499652044223484974, 6820326453941021707, 9701009499879906773, 6897435972338565418, - 8314355711464256163, 8435944020779763783, 1814803522962187872, 1875253356755380905, 8214588085484192137, 18062045700553127821, 6649947905482043494, 3119726140944397531, - 11881571666857493523, 6300786026612414187, 4928573492087752294, 18343550313462089203, 6770642120472453960, 11296815027803718740, 17312916793783562794, 13028515123652649961, - 583508939637547757, 3195115082527873085, 8497784022800549923, 15135719419829981016, 1180291993378114150, 5447281494912347899, 4710517655176242215, 606503081693490000, - 17732293765863716052, 853971165248416821, 2022886284923413326, 7522564752651732633, 1417954193520965954, 5046659528429172066, 11426939225844711305, 17687206690616539318, - 6518552374736169438, 7940416740434530770, 15228615103587329007, 10662504584317997513, 18370800756791469891, 5564085264882124489, 51043856061444814, 11996026931884728651, - 7009195269496826002, 18330778751427846129, 7903886241001925539, 8198930484643879628, 5453546027419466587, 10378692433982210944, 2242412603379120569, 14762161396393277464, - 6146718865488327808, 8559779132928137805, 14001994895150170346, 9915701789711858841, 17119408219089522083, 4345363585985782988, 7559492126634131602, 17074565022279033371, - 1081257522368061155, 16144982029632101790, 2280210790959566458, 5000326950136078873, 10441086845859171982, 5717080014740953823, 16816253740467637151, 5185838557034755093, - 5835900675852976641, 14850646160621635240, 7784412869482958370, 2550282385659033114, 5102457400165153071, 16480738116286616710, 10726825595752219296, 3297564208881065856, - 1801069609044825811, 12940364451588241698, 11725236374887225564, 4731241880784054295, 8874695411069669852, 10719836334830130110, 12983549127094653526, 3498884940869443564, - 5044718241380586525, 9152928988998314956, 13274353997717834972, 5731942246653336838, 9453579625340936273, 6013700107129234092, 8535405089994224035, 12024982282827680252, - 8296339816955798913, 17352704937535250450, 11768204246645005024, 263391795317009517, 6622964609352808474, 14563414288208376628, 17887389278697258458, 1552357122641071119, - 13193447428787140357, 6701071088186218635, 17090465712567125397, 13844922841372559745, 4526664599449630663, 11321311100342816810, 2490532976442445147, 12506579957986846905, - 15880983134955361922, 12396434033732989105, 16113831675045409693, 2288598422068078002, 2992425583703267972, 5056435264545116829, 12961420259857080621, 3600697676136115398, - 12817090821406743193, 18109694174173693756, 17050997692981853333, 15796663317536421728, 15462568940214327094, 15151767385082666402, 17711108405932879054, 4030072071760424157, - 15725012875727498089, 7622633481063722008, 2241559275264867670, 4018985714167034871, 6507661741395512701, 13435865773135624096, 9564553262368888543, 2283482276790194513, - 2968718708369505078, 5001470555537559034, 985353756026354700, 3145435598301843880, 16410370922030326027, 13981261173663429189, 12565590835494971812, 222252377400865123, - 3096505383227168071, 9129898186148780825, 13266305466206099845, 16135309871416543685, 17993464782237414425, 8124413037611692960, 8497190057115012501, 16568064870411415344, - 7703394153241465824, 2740794419858297964, 4228931976096177316, 11207299659959318490, 3319492324515199082, 15611937984154016609, 3431896575019701337, 10686234123352138088, - 9979039962499030832, 11759414020433216431, 15164411293105859178, 2834464820255498467, 10716371968480406389, 2722055037405581557, 9240657586762413776, 267811388229104916, - 8385388272348876655, 16035999427286017211, 11255427708348651444, 18402964994101916340, 17964277099260928049, 16377129731672778885, 12034488763192562427, 15854195461740399790, - 14134352329607480415, 2406779189916280288, 1148342927890148438, 15859735140823564382, 12055096645840568482, 16044304241162505738, 7466809979198503617, 4519925955244504432, - 576546655711744206, 7729660311499709518, 16864252562359023573, 10537888397995064025, 11828992107618549830, 875843272290362538, 5328675038336932433, 3162100370899364658, - 3897734650128449985, 3892478283047854402, 153850176068596076, 4448963435449755938, 9911011406822436713, 6379744721342779297, 360324666931028426, 8002086405015565067, - }, - { - 18068291112584812890, 10288580446655316879, 16866690514199445805, 15458664010538199871, 17175925202246173890, 12208778610361755998, 927739404697616036, 10330183209424493139, - 17095781462759061506, 13984950766342782369, 7038608479806172868, 7073471193601880894, 9212126909381119712, 15865851343492198107, 3874039137971369196, 15366505242302572319, - 3235058267792568155, 8030551941244615429, 12851363585510555514, 9786973022560471711, 4901414898060251968, 13240438628487941170, 4707852389766057435, 6503805666511566831, - 12081034000518110752, 2773740877021737013, 6429475399936543899, 6804412599792308979, 16082860502313571182, 10013838454082912732, 7176778953927883654, 8065751639278576331, - 2577328127707636877, 17299987330349518428, 15104751346159263209, 15422444943335124822, 7934601464470854115, 2803659700354182364, 186161376356596699, 10049927908892587253, - 14226302346438044875, 11259466681405724608, 3945860952925292329, 3287876564263331089, 9461394118536996000, 12404803552046013762, 16569223065554335449, 15881973563254196893, - 6665552777203645232, 5302850683863152336, 7778922028047389493, 14212904863357452615, 15966527672828304861, 3802704091320278344, 10517530714917238300, 3742971938824724276, - 17741525051518363144, 1374267330336191942, 4677891169679898540, 9639823611685431337, 5482431056894095950, 6629146695374718376, 3884574854221819712, 13266790928096813258, - 16028684877412556061, 13405436055762225966, 12268280467958284214, 17956874998292211440, 8610745336676661311, 2945210828327041653, 7889492068658434371, 8032335517518163423, - 17096678157067198548, 11751872841896846778, 14951591239724148110, 14946797103632354342, 15001812923533485850, 1354666869219009884, 15934246013528228877, 17674533676709494379, - 5120889077991995845, 1349360562851394781, 7965752316528770369, 16276575673105864366, 16613052983770261287, 11454051240568463780, 16146905806612132291, 15806571503343623359, - 17505459029376928465, 14087658194607915364, 12240552390931686885, 1809009366037859941, 9468395484396723291, 9446052656478984520, 3720796795453397330, 18035355127900871187, - 10937782812576841853, 2203021845094443505, 9622750764486021477, 5518948515641487288, 8021555402800950130, 8884074473434139094, 3925095588129480413, 6199533424090268508, - 3824657730049729815, 4646911366274335188, 5283751816651713473, 16396970607630079440, 9102362834410101425, 3641728106404110497, 5923630184251416230, 13179374259571264822, - 656781601862662976, 13284523818709348938, 14255949685810234815, 17662122984572331094, 14005272187244763785, 2769973460677437621, 9745740172208222044, 4399769039990314590, - 18221138344920380175, 16761112742545021198, 14421639991115588619, 9419167563943683547, 6237248361283446238, 889754338720059891, 2289880386545166424, 4280148734121099084, - 8456687949810928719, 6224977199672540221, 9826855484829367341, 10345583292656523462, 715642447678891171, 10791247680314230673, 4390153264475025171, 6710036254773432312, - 11434352627810350015, 2720291857616706675, 15035363195148805272, 2358906741960696657, 9439888337759970778, 9654563570832962181, 6013570511081660799, 12742404245236356978, - 16538557679183724426, 6137267799072203525, 13879005145532324670, 14569289845201353615, 13784903266526414562, 1051135786146476033, 9343275973150690259, 18338317230916899584, - 5259165122317589354, 6306061166879114159, 2622163270351284906, 15212813592118086979, 11497359168652342849, 7085380391293263482, 11799059272489792659, 4912160901181298022, - 10956239956289671191, 12649697329483184719, 17174497942073298839, 16454040570484021598, 1964314354536023134, 15533681501854792750, 11384243972598433754, 14387731385073008825, - 1627256545355657442, 9010013556811110994, 14616120598404631231, 8391972858400276155, 244817907132802237, 1484397967210729699, 2663560284299448875, 4820353472962713985, - 6567121006858416952, 17119959301239619281, 3965303761563489817, 10211688306206007722, 724618943950031080, 16749575186941231354, 9181397347361086360, 470616631211702666, - 10512473611770099290, 11735037909076331019, 2922606398008539984, 2599799834378751770, 10226702495047936424, 6109026252412854338, 15572556822827169237, 11993701786788749663, - 12951512375864063487, 9270845327881823041, 13198171264747338719, 9240466821667660686, 14918848310897324032, 10111918274408213257, 9869937817792431868, 11316967879062014936, - 5691364106926740802, 2782311978438620206, 13067832493996441150, 12682941211395745221, 10515041347274706648, 9910726429809603026, 10540072260993990483, 15078586909891471233, - 10892036011159420575, 9833543566604313963, 15176473361412960115, 14504845496732895720, 15845034940445278100, 5364672156984348678, 308167090528488415, 12390239901799634313, - 5106897453764491321, 10540479232768400094, 3938246597140945859, 13156157265138481529, 4932443191001849637, 11374218582626530502, 2907557293167002437, 6807344711257391317, - 5413712686694380670, 13147753106081951274, 2960292187746417883, 13977097845105551070, 17642067093469099040, 7699556298723812469, 11597002672863564976, 12392265705126521509, - 4607947077536257852, 17763906282816835996, 11288463953418287893, 18299911648497821660, 3194698850612319839, 13371221457376435780, 10047718724723936081, 4488868185988157408, - 13742985513958274859, 14201726926009534105, 2183997556320958457, 2564950343266657518, 8846625471673389624, 10147673280504740463, 186524308060896613, 16409126738088317791, - 3993197157612782947, 14810882170056329119, 3476738916713041107, 1512933700383846542, 17820889751141311776, 9132720567660500233, 17598924894608972696, 9704537908665702455, - }, - { - 15695265447782578013, 15506558718447241194, 12341861439298989232, 18400958156300100845, 13704811286967591150, 5802260047239067846, 3266013253411255445, 9892957742319181954, - 6053458788987550519, 3243549259991905443, 17990025476026266205, 3918149716414968130, 562225565996136148, 12175287017902713154, 16317970834262634990, 5431198806775607012, - 15123186170178367264, 3054913246068400920, 8130663466272395280, 2852812622149318730, 6747630551931917110, 18302049774259156971, 3663865061939346221, 12340091610704678811, - 17453312277789785069, 1148609799196055657, 5931758962926317381, 5297597381576544508, 9136842287749269744, 3007653173299649609, 12364677607049679091, 3656932227466449489, - 17732801126130995365, 16093023291975796560, 17028512234142609413, 6293028118993952199, 4019599708379609715, 3557632583507755601, 16737140015288442165, 7041678499288317736, - 5187842645752673199, 14914432544387315508, 4944360914161982641, 4177329533692612281, 18423887817846407126, 11935898134550505219, 9191754399457615042, 962223885189306707, - 5467152559317256227, 13407023128339380091, 656806207084558176, 10823228592509573890, 282802378108427873, 13003319652664166176, 11501612671901244594, 8595770155487539951, - 1805255869285898834, 11676967700876044626, 3486630203654875772, 8366336693945605431, 17874084888474647879, 8803709150655606891, 680993178667234696, 1603785777136148315, - 3637712241808318043, 1673622542455477465, 14468899013751477571, 6607241816357171779, 2332200248940843815, 14077155355848738174, 17298155509321457563, 13624623885136011130, - 12550073596584561722, 13898852145577133829, 31360866049197404, 12629522544897401454, 4563446134761510332, 7272813487383198495, 16767195814334178362, 13600498026689482359, - 5170414136067325373, 10875290278133558518, 7331268231382198947, 4082234313337835514, 11725295114019619895, 6488017511603508543, 11399466652931338200, 2898113599278666684, - 7553418756944942759, 2324485560009697358, 16004009784734101843, 8345371056076551939, 7377284629098981027, 11049718262343754276, 8021605820736410979, 8175349759714152494, - 805625092558946929, 11996029844853502332, 1725029464967101849, 8189609560660709539, 10396089572662865065, 1756007811373736605, 7645529329516777410, 2608132938055260111, - 17014595621244604813, 1574499958190108567, 8684546755761322906, 9997538531915911005, 5652402150243592363, 6315865356369667235, 8687115108443972047, 12369176255146729475, - 5117004045853299762, 2238407612548002914, 12392667457861900490, 10614312910576266709, 6446577503758597410, 3767883614425995197, 17954966454260719539, 5233322901463099, - 9194523390605857831, 2335161171394626054, 12290490336543843159, 12464172604156286188, 15842196578033029974, 9081285134201585379, 6123406461662038242, 5504260508195082396, - 5345718195770885739, 10397124463462860788, 13439280718993427040, 15556816356929214653, 17286785976489019906, 13891416634083443852, 16346644312573564447, 917629419222512011, - 7892626957952656865, 11229871638807701267, 5249460237065799805, 9529842808650392581, 11803106868201977918, 4600784567377577444, 7178870186583927975, 13829108773971861655, - 1289703927368007546, 16175369390684210381, 2195306032582966573, 11284704298115036296, 4385727852306374408, 6915138269030006111, 13440775052829788601, 7742359656861485339, - 1418252737937945274, 10664598666472920539, 5146625453081549320, 7716408631061669307, 15481216546649435253, 9087869057854823101, 8438781502742166926, 16066665509570633845, - 13091912700111633391, 15443255616678375884, 11338466119311799740, 9641919445273031117, 12359044485240987114, 7665168466660756789, 13845183791692700257, 10700410793152785934, - 8528578803314347534, 18126789418189181716, 6819229450418907940, 10542951903574211724, 10335954505229790439, 773396809431100386, 763679854573261611, 7782804492252573047, - 14102889564247144327, 15479515297699126743, 6400257822506917934, 12400211936189844586, 8190162441518233318, 16489757979266243333, 11074854544980782334, 5650848136444824725, - 49299995316533601, 1658812626798186796, 14321322055030354, 1062750633396640947, 11458188738562323084, 10319462683954522885, 15398455357851813321, 9473384090828584828, - 17723857482947114516, 17563952877363564604, 3160294749187111891, 15485369139883303866, 7487527166185553604, 9661144290316674030, 16387431126208996705, 7499766964252214921, - 18331281993562501191, 16034836629143884193, 11149238385567891503, 1413880911197321245, 513884082842080653, 462183409527465946, 404977499728878854, 1459875951423441439, - 17249202826373649180, 11151860661862313351, 13606113651347187963, 13653298062695357606, 12346841931589648448, 10659825520992339734, 17857177794617595021, 12846976930859175746, - 7421386827645898229, 4567141110780940726, 9022716764262477732, 7287282267953917487, 12950322172330872807, 2675202024861592519, 18339036521791481203, 7003909904344391740, - 13539440097944399044, 7108271818419613260, 13229113021954558930, 14920952138366964142, 11082363944167072746, 16156446445495173622, 15515349862819133984, 12359827931233605745, - 17013104138257181849, 6982996767213561282, 16259302607976830987, 1579942890487532721, 8635464047344487404, 10435012080572068738, 2976844365866972753, 9471858478345924179, - 2347775782107812070, 311367032040459687, 10852128873404113998, 1338612296059509077, 1599132038614432432, 11533828746166635650, 14264087792956755961, 13004615331499537807, - 9599159247384506427, 13011559959971256245, 6331802547989957841, 2642320882309956905, 9140255367820630480, 6883541786494880896, 9560822438260750771, 9273862677291701694, - }, - { - 6185067974942684922, 6452325785873503452, 15247257292915812252, 3689324664200339196, 3264129576054154137, 14977721630214750038, 10720913377937894256, 15914487080763816378, - 5498621600689515064, 11498885804037952971, 12697073118321478539, 13999008478737234463, 4324885099420360642, 14021182496192299466, 10763088992583373843, 12898585157666243299, - 11622402383521841588, 18271726976204770291, 4805501248621435402, 13483122453682180759, 9288143526654965614, 4688427612851085031, 3280806057528512375, 2249349779106893174, - 2317249352525369754, 15030797481081533168, 12237590576308284360, 15660076992611440873, 11341015819700735887, 8280257602754365719, 9212501234696283343, 9673375202141178099, - 1576552382781604867, 14644873134348781157, 9860879950368557094, 12941927431704225849, 11959666739052502184, 16171152369226594315, 18364294470656574060, 15172859394935215584, - 7521577570681641021, 410124023045579310, 13806534589183327176, 2731801491329207875, 9959087943014269549, 16205635445474657221, 12069145915768935630, 14906463509471682144, - 13803661539609326912, 3233094883493439444, 13409742688319755923, 4298169788674760921, 12847636671560067434, 6702365884489797170, 5650404576647289813, 7380374625644226212, - 9762534010701623728, 15349113802811029024, 8305297169667044246, 18013018210154476198, 18414050009163335761, 2190126859433916996, 5444481274452218807, 13415988647365667724, - 12538763466834894269, 1385338113050483955, 17489001033590767373, 12734464941837886525, 5762578105750980174, 1466528690684075875, 4231060025049573530, 11218444849081704286, - 13520439252664960951, 3770430920651384098, 18274623217805904547, 11545267616883260257, 4084783424859113779, 13863968977657663867, 10237835480648574698, 7395611844854084274, - 12891185742908997266, 2889148203703402614, 663579373261619221, 7616112456816883701, 9002890885722034437, 10753730807791931375, 3553894671829778441, 4368240432504457389, - 11641532224340210206, 71261001011952801, 2321745415903209397, 6595984444855093239, 10341299657770272718, 11529878689049370930, 14381510695605158203, 6869272773579747365, - 18407769999912340511, 13801873415230385184, 8080153703167941484, 14143463895182697871, 5248006623352376562, 9271982788122934275, 11225161179021692620, 5076519449784098178, - 2388868518767189674, 381125256886459269, 11316805024982236485, 11671355336111917711, 3564177948445768908, 5245093046097324328, 16144139891410041039, 1201010948447708436, - 16591032462856670656, 533850935988668408, 2263232738784171066, 5572124915367282948, 12583782854491678471, 15015562207264407653, 1167486851113549964, 2987176661273439670, - 1073778278665127828, 301289653767944933, 11482324780950168317, 10626716202328004967, 7258024014655363102, 12597648090458567878, 2617914106162603499, 12324652644266476584, - 3803745429517922765, 1699256829990081513, 2179986933466617785, 4330084096014112280, 10403896221616386733, 11682369673591069651, 3879392495596713886, 17249085256521020624, - 13938687445393525296, 13822790166673492712, 13216892716897321740, 2165870280409061482, 9147830602451471293, 16339144108911449834, 17837507766320968023, 15340710005345158245, - 4485838034764604283, 8426970493386126530, 7709201418726935942, 13468796449943783583, 16441091014185628843, 2374269830239737237, 13423059086148485716, 17132218391020520330, - 13957732574177025801, 1100344278733481546, 12156946932617203965, 2007756425747006287, 16454508610548016441, 18058668363064769203, 15619001054652658323, 1201476243910931863, - 1292412381963708933, 10908631677673353277, 15138649576688192753, 10741579086621436813, 16534963566169304684, 10228646729525192055, 4256608246548223655, 16176814322718522963, - 3012125536603284881, 5466178753014623970, 16598422155702380175, 9902071731736699653, 13861556771123036741, 9534711573278556274, 9805898455743897538, 14683694395093520838, - 9125214754744730198, 143353181770418225, 8976042597473555858, 13405481215779362056, 2863125481657826330, 12333764090388731260, 15250359513836914002, 5086706595778559056, - 16341334571424533804, 4657494880554316004, 18092783076286521475, 19832895869027143, 8667365497283429486, 11501953273367138162, 5832487631687776985, 664754160781757174, - 13604774408440609080, 12660956565879820101, 4535452877362385626, 8063311919592303330, 4591511734775484245, 5164119991271568303, 5282209033000495913, 15181017218549722334, - 5070228782679699429, 277881850788922387, 17424210585510719837, 13586569401109299583, 16661809787463692974, 11543434536078774133, 2062889565117549061, 14261113517104795690, - 17683343658262519228, 13727986689138309987, 9352982220536939533, 7578301410191413286, 7970586266869249410, 14357824150096386968, 4381700479561442130, 13217807763329274501, - 13524719886605363170, 11553593166914861649, 12034020205580665813, 985175984881624722, 11040631342644137311, 12107496606245418129, 7328748654066365904, 14741972847454326011, - 9790251609380109406, 2449588380962781369, 4694893010228180943, 5172145489692928848, 5411277023198532852, 12752098113265127406, 4559500999103209672, 14921033543082064351, - 2248082728820243864, 8720404853152831367, 12431505213690884811, 14883031570121462817, 2278273022936639560, 14988529405400451352, 16732922988142595529, 1071232319627396164, - 8793441611217807824, 13198147137434605751, 8167936709747999601, 7685928882032231744, 8779182451658438210, 8059106577297479923, 18394590909567718507, 15508315617300242773, - 12828567388121500364, 2264959796189127526, 6222205589523394088, 8827682270015065013, 2619170858745203321, 14835030117099398518, 5960028394532808010, 2233397097850889639, - }, - { - 16319476863352440541, 10283930715856640343, 17675054544532098447, 11261132162985242084, 13712716897981761400, 2681907143459288706, 6930256922080133347, 1445069157579547822, - 16928574868467385886, 166417019993787654, 5882811520342817815, 14106304179344008065, 3747123724781081800, 197109533566874475, 14303280595714789450, 15457633026018307066, - 10773597511592584859, 12552868588431074640, 13500771767160426835, 8002499270056378440, 13792839099998553174, 12949371255843262119, 1713974340992291550, 16150173130483658061, - 14745984256428057001, 9333707338036985191, 15365925315303462, 11789129028059619744, 7873100217437235208, 5289763977161829145, 17731215200358323788, 8876377479309635703, - 265950821974454804, 5047467530470542278, 17523044368516619801, 10054436503372765176, 10321185867287373431, 1212061937729015591, 15311258419138633926, 11236518538207084768, - 10904693956407098222, 9013418755007070130, 15510005599846320670, 995378633446250700, 12234095025518917836, 6689106237771514188, 2809193993744369126, 548124799387888260, - 267350765778774337, 2853877351938464055, 3677119082593358544, 7685335121077514739, 6491980094762370981, 1384870316654548002, 10568872345228996498, 241629538659623878, - 5839400175629113441, 5238299193248381245, 16787876416022887315, 6051613843621920008, 9219569873668974552, 5916753090530931032, 13390630214643423749, 3265335490455191268, - 1507475744849985303, 2597075068965622770, 14968669113917266926, 597606442423659891, 44293923912414886, 3832651144752540816, 17438860065613195810, 782112340603343331, - 9050896199196733903, 6427608033444590004, 13787696679536621857, 9682087046920409188, 4519093754155995429, 13564098392055667371, 10512507082236058799, 5289934424008191746, - 3477191607403300916, 18283244229745029067, 8462159792484018099, 3056576498976014760, 7259283167233712785, 12530251965039903998, 10232104933720625111, 14190745998092156987, - 15759362035410895911, 16075598437961371531, 4651513528876405575, 7694151626503869614, 14468862724637972284, 1838601521755586245, 4168957446435305706, 8694905613027663664, - 14825552838983151434, 8639609968952840931, 15547914584352392016, 2313507499500708287, 6902543375698033684, 9987468886016348918, 9068175779860656258, 6899641689193116297, - 7449110402827616954, 5689206471789540768, 12722069021950813669, 16017131401246233663, 2240977975275954837, 4794705713606614946, 5734937900461809607, 118285984764445639, - 13917685647531721740, 2432096911145792817, 17733637484624159521, 3848601825403209903, 8192433211051054683, 17388066421914150767, 14336306308847565282, 7501625553608785022, - 9844707592410952215, 8167497709587672711, 18115463401502884199, 8471563375691441535, 17525405040226359165, 2460181803833371342, 3375780580907171205, 3024376384135966552, - 15446204978718816914, 10131769697256428720, 10937168660849553757, 12174257400309926241, 4774490771219074715, 13764876998736771340, 14299051476546774038, 11409551629093945893, - 5471366060803425265, 5927845172343647238, 13321967429805195545, 1981489848211999240, 3657997933879283852, 1341488083977381854, 11001000434984172675, 12666440712128450303, - 2127920575549495889, 8861781778185702064, 10501256952986753134, 8967441017586595593, 12224364761159418844, 11856305587178745520, 8176487286367052930, 4988165299911239066, - 12279712962388998309, 7552494563001503282, 7388800608466198128, 15704167671257743517, 17781278773093632973, 6688613358271814698, 12261263098366698895, 2585757657252460656, - 17064077609211627595, 14437064866605257652, 14386408901468621215, 14935685266532365200, 16350265985491822570, 5195856143474093260, 4623415440658404410, 2936315929072503688, - 18399447684263070219, 11294713679768342649, 1600242588657342501, 2841752419388937826, 15111313732750279467, 8179471361906256467, 10611923788752807866, 10823997080784081293, - 15607034385960553579, 6934034624930683639, 13318618594774430459, 7552865293216027192, 13692640408995992185, 11143313220936824014, 16721999332340829387, 6993089466645938014, - 1749509641415861857, 8597876492914031095, 17942224190138398306, 1760222146515426983, 1030117883582412628, 6655464189981098460, 14222900139576809037, 13041171493967200019, - 12415333505074758067, 16988669193263876033, 10482573641416551070, 368049292090348794, 16109255925523895167, 4949934055388640387, 12038479532506656790, 10829864449693781036, - 8355401100656399994, 16963696462538033761, 10131652431024537917, 4166156454906166144, 12888240412190236596, 8396312458335953166, 445297814986468978, 10512295830234020744, - 14405236772348157690, 6950094157338825845, 13379457125020057613, 11396720859761560260, 14063367153572826959, 4476298515903789197, 12708437873915498860, 8163633089770520638, - 6432708226771955694, 7524978005081948959, 6442046223716866789, 4082077252385606982, 13626979819841658005, 4264573835620574342, 14788317690584235128, 4710414518172449402, - 9592766374657389840, 3206081438027351157, 16013702689312533501, 15788528722601567812, 18314198451066123850, 13236688692074994659, 3229858297074852748, 2968037605940641303, - 148470760067500612, 10319937899190593880, 7185467485673911733, 13041030391924988650, 17119842693824847662, 10989053172849710331, 16048294708726813099, 6612710923681979611, - 17408606709137505005, 4263600430695220256, 8941719936291239640, 6115030817534063286, 838024703679813150, 9772071103323550178, 14394690179107421621, 8621372196164819917, - 18138724984190926809, 4154767406604950048, 5209478936276366634, 15469512148904762872, 3613429290324777670, 12631812917445459751, 10280179062385049041, 19656860716268566, - }, - { - 12030193727051241373, 13981191132445467472, 18205169646206905593, 12162181194046583886, 10929925499200074058, 15291772758590352491, 8452344520852919320, 8199821440451878776, - 9876482463501409337, 17331045017548147052, 17542726936580732548, 8299195336372136083, 12891767721269002608, 14062358772374813347, 4165127680073507756, 16350672737379495431, - 7595271959296927018, 15286771623821390629, 980612661413312852, 5738158184597378995, 6972117550390447038, 6246497134979772260, 2935831443692029059, 12837371529160496660, - 10228366644420455452, 12084265406352277347, 10265869676493821892, 3560143954870272139, 14368775225608592689, 13173522067191372913, 3592475039513249949, 11243554718624931135, - 15959892157814064696, 1882528744932347842, 3354709518288681174, 14147909176429982637, 12969888425264095514, 12509610747258602648, 10437226619684632037, 7605683691113295811, - 5697384515599291245, 14896081221061315030, 4329502046122948975, 16301954510440819492, 5191621061031169335, 12944691824816066027, 8080452646904372453, 793075614214301908, - 2662373477940179766, 8950125653339535995, 15717799081080898304, 7088593450282143511, 11723351531494404904, 38673945663198753, 5289769381065195334, 1742280067441486108, - 6543255501112359319, 6063422531520498671, 17228726254778244409, 7570754775709645369, 18222396492501523182, 14903937974816691813, 1216646642383641441, 7602781158453005929, - 3007861146695764376, 8267227185027440857, 3177625538211272080, 3144345182124760000, 9215753228267875296, 1342253891473772992, 8185239004636232247, 14951188427081280984, - 10569785547248986188, 3109435167722572449, 13661123218513357442, 4646373703143839998, 9712828426076586682, 11389514152975496268, 9796826623781200498, 234067627740956181, - 2188380882990542468, 9914251329861595119, 13616219875099353594, 16135919125023820218, 10732193797566088293, 7172996278550642736, 8531638916719074975, 14749121691457005349, - 14568782576170814716, 17582848432122737506, 1079387064102681806, 17278567874821675408, 3094302191119669899, 3730448048895347901, 3508894590334961422, 14091660942919228106, - 8414395549498864629, 370884714015114625, 9859130251236103342, 17120282094084970181, 15213286581037020029, 2737545283554254673, 12422648607044275574, 10601123825482591606, - 7332173975514924017, 6689389428877729175, 15162654177270425320, 17333672210015736765, 10717615330136876266, 15245080807947386155, 9830331968044142933, 16156512094344185621, - 9151817936103586393, 3495709317444898385, 10881665308947458223, 7087755261386867019, 18372828768905212167, 12873774245490293443, 12750361906770763255, 17688389897350887716, - 13329033749048978810, 4765695903433858377, 4452680451529163940, 5638854187414651620, 7897503022043776206, 17187635538005569019, 17766753195497526986, 13201529234556380285, - 3638940913491383692, 16533217388164981609, 4668956005988168087, 14053696531704823982, 12029006663244142834, 12043309283447175601, 7840964186868745782, 5691369519440953069, - 8500871974974230561, 6371833132372813539, 4002756625312698938, 7281624589760047276, 8813214993155334737, 7738842112797657395, 12616064385239668311, 11875709199633531753, - 13080663957403320059, 7305658810888170771, 12002632153917673214, 14713338572031413494, 11629178662016777533, 11669230410217642326, 6563025945717173284, 15889630204666511658, - 8934119620399766972, 4226481091885914732, 16000709195004445297, 14687868180928846933, 16269913392757896907, 18294005838441325342, 17625669613551023126, 10864307042201644469, - 1539179629859629979, 3357767843775461146, 2101360073251832751, 17234081431682678130, 10847284171622250162, 2314478515498414576, 17530153382031867644, 16210890762511619844, - 16932765725476234252, 17974885539458965712, 40892050255466590, 13934027942808790590, 6621543269907021363, 11796852321134174354, 16673775773384613137, 3370296079966463186, - 16962514259432373133, 4639769064050336100, 16965148588326727680, 2922022742538957808, 16752379982369550296, 12896050752492664079, 2708685629936199207, 17894058559833424187, - 14722530431277419104, 12333728409662476827, 4162946257347548625, 7052045338975163666, 16435875989376103923, 527141841571514699, 8480360258792897962, 4322786951393806781, - 17366230017999184054, 3121469063237497918, 16903979375392804254, 8204447732627807538, 10469007462907301028, 1938243801077680483, 10156223751968769092, 14290141776757271674, - 2576841693080637380, 17952976066680364360, 4927209893946473523, 12406446420948698970, 18104668447274679200, 11321546081935789882, 11763004760954725540, 7488613143173641394, - 7566233859107262691, 14065899052643539237, 17156645465457086529, 11936850757897686493, 17529993825395532749, 17145245039398670236, 17597009579379584432, 3472628483897995694, - 14380803034817149259, 11042134597430846555, 9992762805140200547, 9895143575678511242, 3228768306004664915, 16153114680219541243, 12036181641761325912, 491369524302296324, - 6378343037075212083, 4634622317247307316, 3415247351446435530, 5939760313513758783, 9540802244218497398, 2134082884335789009, 15623633842188443713, 6824600547587227473, - 2021901489047050575, 4365578779519871721, 8603845379677060773, 8929020214929242215, 13010370953605249273, 8071113541575997356, 10681914788594101574, 13369522272664029829, - 4241327321249984516, 12810477007632864750, 16880581634097860698, 3630333431846970294, 3439918565119627078, 6613942714960548236, 8647431674406387604, 13352599355545805355, - 12320933424684960076, 8906954611339502145, 16931708732547376267, 6446897311644431583, 13749563256713530203, 11522599770043814384, 14455556215959342791, 9022955938835504923, - }, - { - 14734199666349771791, 4159865781008764547, 4413963548436270853, 4489431649937855880, 2824856157476907519, 5111945927271461159, 9825486821405155220, 7657332565522279292, - 8798422177670065832, 1250388939918922012, 5145324733132743026, 3716299737175574168, 14387202892738514375, 10255681359895407489, 8563822744122397080, 18430417713920116013, - 7857399215288147901, 2593284350589299949, 10086687882410147351, 14407837835956327624, 4469878646287387405, 6845712208092605310, 3019047164798827279, 2760591274816994522, - 10930605176025081830, 5850835312463207607, 9603163404664606781, 15623771803942139684, 4096748595672894276, 13060617166821837740, 11222939712741281346, 18445178894593253710, - 7976335583419810431, 16568954524837045521, 5581116346602990350, 18369129318179031997, 1930478946186473631, 14255806344323769850, 5302512325798050097, 10008570767203424472, - 929118050943456183, 445163760697913504, 7208246135487165437, 13565354217377841149, 3835063466770003968, 8214155842021576753, 2078717035803259674, 12502657820500987763, - 17741004372977419914, 16320851348541958575, 11853008901690968430, 9954777341381304447, 14274892887030297417, 10721339848307167540, 8731332510371325649, 13676383433520290197, - 6251805914672095769, 1063060143452094078, 16647397170554915088, 15454955736319919321, 11509235104607349098, 8441647766544589978, 956121464218389431, 10752793912033728149, - 14879603883666664508, 11158422912437249402, 8667988090392051507, 12702057193823135575, 13234479167199208223, 13752955092077643608, 1117550756888145931, 1184967682872965330, - 7004802666964716824, 395433501626287206, 16674151908279399004, 2279551165611331131, 18032555740803644790, 3573953642384243989, 9892480504006025100, 2397759375236735831, - 15032723931727013905, 4176673226777913017, 7270920367565154969, 8867675920919464620, 8174119413251699506, 15030539680120439131, 12325981936900309518, 2932283844656871802, - 3227890727136855788, 10772277744280338071, 10065219931092397730, 17233706446636791341, 1372997838851103811, 14430098741859995846, 3290287064497023581, 13054133915521430696, - 3404625123065318735, 11884832674715736469, 16513753127836546671, 2355202492840722899, 2182039060332057784, 17942518439766613327, 16731345075928062112, 5501869092504492134, - 15704211025163561149, 14596679078416770266, 10262177146233936833, 12443005669252298316, 1541294166390346144, 2952804996209068760, 15358481016273272880, 1321729586231860999, - 6862865331233391228, 15106279167311639122, 3283008666555627541, 13405610967904725343, 9845239597399801983, 10764942720093673542, 6506992344666983370, 2483131164245259278, - 9508384588323002196, 4786531415304518048, 2690306308552249535, 12208815515689370850, 5145548243685871201, 1536915039528215765, 709289946127949333, 7152734178531880864, - 1555309551759198315, 13156609441579560529, 3264147002083956017, 13629162110016732793, 10295903344220946201, 13835148808782379287, 15646840234722388037, 5850505683234532491, - 13348528763144385986, 8174978337870000956, 261860806345683810, 4561309263594732686, 973813267913726588, 5812176512716041479, 14361848397565071235, 9009461390894364897, - 4179825720483458009, 3146850391122074949, 16612045757277946305, 5253713786583408340, 5426943015912173764, 17275032103121420023, 8467860410750483621, 18150546576917688519, - 12762630566060098764, 9762645120146998728, 3635705124656800121, 3295681695622364165, 1764654124266477879, 16610065552429288987, 12182970194869512424, 1144643512390613083, - 10286763540130161498, 3400614528650953395, 16801086752981339314, 5746334081386875705, 4489937467701177898, 9249554406360134002, 8258038249111147700, 1922443676251769427, - 5981893063992017591, 11780456280008557800, 6865399120670384939, 6192294124015342683, 12388377965276278882, 754882660516751393, 13476094069874573591, 1000347292494612314, - 12753947115797128456, 1864834899756446490, 12873792436322150068, 15420857687427067065, 6214698061215951246, 11174167031334850459, 16378107708672199269, 13073812080094584194, - 3531275996684891316, 11764951512033875164, 12239314899306115751, 12701224435273087197, 152051042384837402, 47099568832954431, 766394328496626388, 666084094458729910, - 145223485883456390, 2445564470200462527, 6482144922631612251, 2316071592874761856, 16548688346252111305, 342430477320199814, 17819268336019413198, 9112976726726029531, - 8272548370610798443, 13910434751574602849, 4252192981011400377, 9590519351704710983, 4172183866405471444, 5567646223402949380, 6059725713353637560, 7169982539312028092, - 8422701298619809502, 5749403137850675219, 16696307763582818287, 7683947097864552851, 8685161999810728314, 15931494353777534155, 21629333141204286, 14374464903502564030, - 2354260355218724624, 2822702976206523812, 15817484232297668127, 8389777239766813455, 7962301702220496539, 8489354871723216960, 6637394823950686331, 5853452396705295777, - 5949957329602421631, 18059540496274524007, 301304345046470155, 15775279105880040289, 15979581939040500554, 7142046514802237176, 9965619645220287167, 14369754349691428035, - 8777708254369249245, 17882304730732025188, 3127583543205765491, 17274466425160820249, 12870181470212293464, 5881181695848312122, 15338161852429951632, 7245877162563127935, - 2634466441339054819, 13057158409330115380, 7410310056430957860, 16362149248469660371, 1435827663585128427, 8005375008235415486, 10865470829924734253, 3177600727860863968, - 9627905753364576437, 12776456422166281355, 2851899644189834214, 16998174196920379994, 9001602524188761177, 8960294999163663712, 6580949973363012183, 7568306074815116797, - }, - { - 13345381996769253014, 6278048669175242345, 15990349685835870151, 16358261962292186792, 8505261070637963021, 9396725065098564446, 15331953351049782155, 16194796339208321205, - 7076257175157660597, 13221730879315432464, 4499548735964119085, 7559253754663705944, 10196808438730350168, 2391718471837563931, 914409564589897387, 6649744842278078706, - 5502356275170104522, 12750322860129485966, 9581277511584938955, 3872282844937972630, 13668854758739140874, 15020438121087800965, 4581631138384430657, 13296613956093963588, - 14380343880230315251, 6834909096379668102, 15975839936772635678, 7738230945027714388, 7971648870467745046, 8320128435052726628, 10820026056424631461, 7058118462476293754, - 7264036154081699231, 1304060579978677195, 18166928140052040308, 12593450560996175288, 16027666629366472835, 3677101504316839585, 1477956412235870359, 11566116495906585190, - 5990066097615398579, 2092999434824845091, 774626818169813708, 12815491981614523669, 6993666706115136402, 17707947501239782961, 4907798919001453899, 8644498548438963907, - 10893744790193607860, 5425031394266373727, 7829758685118664025, 11448863214220512751, 12538690882574195219, 5021176303769859871, 5820297470465439264, 5119144562842414323, - 11165438517321289842, 8661037418831619311, 4401480924846865713, 9355650368902126256, 14352422544185763829, 12268031594529744663, 17607497268577344783, 12698954426769962214, - 5383780168621648368, 3613813760948797485, 5757643543708300439, 11434310585555684688, 2345981080034027974, 17817292757133028083, 18327982597027759229, 3812144950722314021, - 8792386854586041066, 18039588893139878329, 5501406599000558473, 17117814302557684702, 7341401626090786647, 13233670006052290433, 2192568639640447778, 8946253989965365943, - 16557600339807647183, 3024845786116641335, 415867109882960964, 5024769423994345740, 6707880221250244075, 1889203596997453159, 2063004021323938442, 15149146696320496954, - 5091534986326281709, 8005812102849517353, 17366496686564185717, 3658878980438307796, 8455810244524637026, 7649393961871195909, 8629386422022530934, 507133797409068858, - 8757568869745664865, 18237318628906764926, 3340648953867756474, 561136277959994100, 7271097445297070958, 2011054670254573698, 5452809131990689118, 13469888024447314143, - 609640447772904263, 18299734743899574512, 9082773418653747144, 17312950936823165983, 8565594704932296493, 366163155689429929, 12596423288683198842, 6787120926470876217, - 18404298100226778075, 8425329164435445437, 7431919288426595458, 10680902470574406179, 7944931189168061880, 9822761000408762356, 794258562727155839, 14627123549563592012, - 10098955144981013765, 4095621933458866623, 313357785962326778, 14880249056209398407, 10605627454111004262, 7841561005378789988, 5015399193497762029, 5818383539901203899, - 486788682374900660, 17535646661984222270, 10786441143551223569, 9744277172896797168, 3600223448942144865, 8847805713765285452, 15255336563751266306, 14792236445425212896, - 1569380763811592357, 16850350231819425451, 14974316825768144065, 2974893813338477794, 16726324408135381195, 15000665607479486464, 886632233152598796, 3783793991897659851, - 17267037371866619240, 16498595171305365582, 6453906744948258368, 17267405673163971478, 1676214913570622682, 5051819157163581842, 4315279707026326708, 15525840981760267164, - 829322392873083372, 3459913121476606612, 4547714508342797986, 5801286056105229312, 11591136160675314269, 17965845487226778560, 7022309609363885527, 5990586084398664157, - 17415594387520595717, 1453256163777911406, 8242859112004661961, 17561205531134219898, 4881570838375824387, 8392772608437744175, 8797957464506597080, 3142154188155936579, - 6248409301753564092, 912147011448492506, 10413108318416902948, 3349445377400918439, 15887909530347096066, 5138859116738406557, 10990929831134698266, 5911273060564729281, - 5197581879950405305, 3001975514736631403, 1919678782193534342, 16811100109848336275, 13086769249238533805, 4351245282425706500, 18281601243717625371, 16799537683941038764, - 6288277991521986035, 12231480617236286340, 8633990423689180869, 13535190275290488690, 13419223868164389899, 17622732596713666209, 10071779220640400024, 9451660464882303005, - 14029940454474238624, 4957972603307996503, 6311878080193524221, 7485203809274562760, 14450074580092843779, 16845073066403496624, 15870387052570816676, 15700883809468229388, - 6623653867803819118, 1037643671564549885, 1236506073247459642, 2997396263933967582, 6182371056378366305, 9773995232878719062, 3356495419149379609, 10710833980055523526, - 9965766500412107699, 16895652751136174589, 7310937934566947318, 17649841370865305295, 5052693369483848536, 8093060855248113928, 15777336335257114359, 4642979535698186085, - 11761084765182152401, 9226969173242076459, 5445719591917489914, 9371133174853825566, 18381867235964583187, 17262888224001222346, 1934253649802391267, 3574888052111089863, - 7862401495691359736, 674970329153306547, 14447324101549742216, 15408908436196428001, 5339840774639473099, 15542473999923245378, 17353380999887736706, 17787369898686553525, - 2301964326759931592, 17775852221342579469, 345763078096690431, 5079606662887837532, 14863722102334084051, 8905941255852264870, 3806200576416892831, 6668327519801544161, - 3672519063263749482, 11898207454593385701, 2364050348970898536, 3761861796987022528, 8159458273489411574, 3231262679605967088, 17179214124164291006, 8770284079122589350, - 15270079546607712667, 8471883658965202468, 10333206241569264742, 7414741159725097798, 7709713706668701850, 4461310100162632915, 10099194304024685274, 4760203118683828795, - }, - { - 7237168574323016859, 17908810107504968137, 16225708127838178121, 11127095986977103648, 9346291308317410251, 7381283458277047010, 15168602815371846943, 9193719743691734294, - 9607254959726458411, 16837156817186931862, 16178143308706847393, 10970721795101931539, 10840376278605273092, 8298765077094727469, 15520543037910966843, 11484620381947762562, - 17395070963094117711, 7608132718922490881, 6531178971071758016, 1302814667007331361, 4002629363862769670, 14649492495298089937, 6868174210142585697, 15456170652716048683, - 3688308493559609536, 5123828159813683938, 6245436817220183971, 13062234263274605325, 1313395302496832996, 4961840797708687855, 4990192311341859196, 5283131006216350959, - 16952735659396950704, 1249482796824289329, 17859504101404809981, 13260403650830168625, 1583343855370236084, 11389120333403185826, 13676599385745755008, 5066667130137739346, - 4799264864906918301, 18347145714884655971, 17034125441088681346, 11828378178487279470, 1759038296522081901, 9582407833575609381, 4195817009050503354, 12618256395967210055, - 6486755100213398364, 5270923715575268322, 9268255346880651103, 3147724493117082267, 16710318779269985633, 1240462642985509644, 2400811796254219369, 13670743068809614358, - 11437779990773246594, 13609113239383378152, 31268927496646090, 11618772705165035208, 3078024460365036167, 12138983306908962712, 4779157919015181380, 11901698850260672002, - 14642787507945832432, 16258081639927585935, 2560321462542164242, 16286882196975458174, 4328159372518768969, 14313553865397841147, 13769372656320240568, 8950675126435331579, - 1309709344837422378, 18403288028608342631, 17102350491414677993, 1133523394849437315, 12526496222782003755, 5447309058259018864, 17311120581405946631, 3760058661125144368, - 17891474172606596407, 320094264574086461, 93927075222964142, 14355817838636249140, 1777882427773785068, 8237021421587560510, 11520559469641852991, 10567910693910023157, - 9164300764173563614, 12322279811717869943, 2768902015676238485, 7761799112151133995, 5740162933856370894, 8043946608495226840, 8923704438836381869, 15189322655373943849, - 12046275966378825708, 5909386969214935556, 1201990704907881028, 12128549009950617306, 10773478878317625320, 4554854625564648958, 14029736945871573056, 1353247251064221090, - 11909123603272307101, 5517949035179831783, 3295386484950432959, 5605137795524476293, 10718654547602473221, 4984952409581272095, 883267724006996723, 17328431094026829348, - 13671210467347025770, 9980617617519781731, 8339868735163579231, 2150724314757661915, 8571153021065445899, 9146903697769397191, 9122246102814640373, 7744779513085605450, - 5733697799130763963, 962857090393715865, 10538932452511329419, 3413281437172590207, 6635428480179771287, 4404718679994229138, 329074170931436370, 17746708206910902139, - 465623292609655544, 12740391094094156750, 15600221933467635716, 10712500242632508096, 4760789577759901270, 408323003115848014, 464706673403009712, 11801112998381624421, - 5545681129476190458, 8725689673989867696, 2143812364199804063, 12133065347666807143, 14072918710585286097, 9027361966934517640, 12608281386782336413, 2053972384317260152, - 11862793362110657447, 2615766363986534825, 5065170482898519596, 2878903691735623036, 5204682974850023849, 3382494556217615091, 15421437169807703253, 14936317525837021790, - 12363228588136583724, 15035239525394825264, 16312817933687103988, 5294641777817034798, 1197907056067071148, 13084871057903003628, 5240492218216802394, 13798739245031559476, - 16167519903361647970, 13106036157861122437, 2112866661358918425, 941609107359251234, 7240286582201258992, 17783018133711208779, 10433192833270769862, 4303514224506582113, - 1549168540255262874, 7958641388293572779, 17867057222043259063, 1752211085999288773, 11828273580240483781, 11712913016012991853, 2373360154803731890, 6779610934665321824, - 6633997178003959408, 145323909693817907, 2198452664824754574, 2920221908918689777, 11047294234593305837, 16840329825128198329, 5479733463453508239, 14054694221361300990, - 7908792292118068471, 2703859967221946473, 6268006869726038724, 9406994672213611166, 12424098071734234719, 11900750387777467409, 10724482893673149484, 3191937460539390989, - 7635348735946750413, 15019610708452651937, 107671898858364780, 16808612119435524257, 6120109999123152232, 2251481693156523545, 10792076820325151003, 12924551065805570215, - 11225852067204798645, 7665324911993544151, 10402215331683389905, 2856131542917118235, 14152013119539822346, 12731746180172488022, 16402457225039188820, 11129045951416314666, - 13009066459618795885, 9636541685854928780, 4783713672495759319, 13224924194053497016, 8044695420996588716, 4054951559323242873, 8718047667110955699, 13479622910466265834, - 4333570709684826136, 3188483692974505359, 17976757824852085147, 12585927226835238762, 16665346689006249776, 14033419552450595393, 12216049696243171604, 447536030797427204, - 14100792221456700414, 11757964686555543320, 3971513799111193530, 224065891283865758, 1282520657830780512, 9120233956471705454, 13711191981326748211, 3725543277190035504, - 12094220323799678341, 16876894723130932646, 14806566188177921577, 2283878370700345373, 12254260799985999571, 12764268124075139223, 2425316412794046071, 2088679341162220742, - 172600248248909168, 4338060849169481673, 12046085844143054569, 16220699277291497444, 10358794035289405365, 6739081270984238196, 16079387007561085178, 13471688054064884318, - 179238781994802586, 9017860544212172426, 16179187983079961859, 1380105261896053495, 6187003332254463653, 9896593306091975718, 17181949235068293496, 6820143159816507763, - }, - { - 11156900805411912784, 1737275748212365168, 16993486692205800040, 12538938066475152524, 13167476167764338790, 17373319366642541595, 6054831428930905282, 7118452124011953000, - 743288751022377974, 9226164090128370715, 17669221687181604232, 1117842260351396541, 17697784451833850722, 14382209306891991103, 16951372733687268016, 188390802712613066, - 13268209255833199938, 16633146482265079265, 6044233937395578074, 1733872861371247406, 14239198956565602758, 4036306057099495106, 1778912298053970082, 6174082695927204648, - 6390361653475754940, 1093882175267357438, 3784079074949811167, 17343872969822169769, 3359715652121662979, 16808529787251986583, 5169730697018536870, 52766949850965558, - 1403521870654810721, 11668153767441183906, 12890534559297323775, 13255750643204945388, 8838011266491753399, 8488733891344199335, 7468199299966346977, 10645543722243906719, - 17019046551094178629, 3055711824867115856, 10841870683594132444, 382072777978364200, 725450988418371589, 12501774248954630111, 10130164067258601487, 7823254091037946722, - 1866199290196467180, 554488389245696218, 15654194385091454776, 6131785419830586829, 17856850737824439617, 17602611196814472081, 18244498160243832872, 5819736122106091373, - 13147212495082910072, 5628914243538540648, 439989514095330941, 7620472329041817834, 4272251824771633288, 16564977601507013119, 5441117136715882317, 5622571730905974389, - 8706277077547369587, 4848592786700984858, 11350018329458740004, 143688324288835298, 16536982722430328270, 6522962371020150117, 9511378862712142567, 18221873727623821967, - 3985496688414455558, 11118602672015528143, 5383196298446424580, 6116994806363767576, 4051800833472889243, 12236802048340231756, 2619572929682123355, 6008593592518397571, - 18159379849046931840, 11283007389905902377, 7465803490016928282, 7730454089227756796, 3569936088077890000, 2804205711716327520, 14107136042131448408, 12050401455009236937, - 4207421531032215145, 7924589143024019458, 5496622772676523695, 7061817399179278712, 7371689806847905735, 8282663810521090335, 11422487361383982601, 6397294642072086677, - 15924576759579234055, 9923512276109397968, 6142441356128988365, 11189756906743802872, 17790684027455851021, 14143953977451478354, 4002828116425422775, 7521923183240026608, - 8349314793194266723, 8850246337652136896, 16635419760398709839, 12466509089914036008, 2686508850003621675, 15822032015692543407, 2211302095278204426, 12550915236378020964, - 3844358527917324404, 15045102416646491178, 558560187822263769, 119801275176287297, 15593003307431898979, 12817356186703401527, 531419248069516921, 7957931139148417935, - 960381383357168877, 16774709963697143275, 17896181076874992240, 1150415168189819777, 5498481130530161530, 6895900060791069290, 2079514944189747822, 3428689507902936354, - 8525743843643076774, 6014251588524085384, 16423924202355808346, 2605496565158241796, 16676209604549923678, 4870342652354143869, 8337072895802905281, 2478197702680510974, - 17076629945963768258, 7647523525256473652, 3999707005939039144, 9578933944626939348, 10469359763046002307, 17515033080264359276, 14272203721184987484, 9979666177276073145, - 3896303254672567310, 17167309259158926479, 13231865857998180315, 2260217573257466310, 15465674863730076330, 4460025914284098438, 718707264700157542, 7215235109325196153, - 12056920178557394302, 5131253251712581899, 16251877995882633963, 10883064494054484051, 9473274815269607947, 8874308005470196739, 4412709653190846630, 16469366225886156991, - 13309932065155297376, 11504232979548718747, 14366229841750030472, 12797870458094162590, 12894694064456675527, 16977997035748966590, 15080606548583635864, 9292471759789693596, - 1226107676031264801, 2683510924831720521, 4344623677417870872, 6581244316153602113, 12516966236091151915, 6758725397469564403, 3190083750600883646, 13018714111448482165, - 877612159223846777, 1550479938877814973, 11850498481046386377, 18144061425551419288, 6811504328538189985, 16351446194603329949, 14495016749549056145, 15394017693349630053, - 3547198835521135552, 9940690805769919242, 15170549880149605690, 10701681269101530298, 5914809102954412895, 15790219349994701461, 13664049285300230863, 5735249081148743651, - 12395092509541605535, 2320592554345067500, 14213227630916688382, 12847883717490005600, 10192971941898238362, 18392117086623245662, 14369915478097042954, 9636190568462370402, - 13308009076055104849, 9679299541833059768, 1512845037409468381, 18211703514703978816, 8337549295001075127, 15882458005321062689, 1212364284844818969, 13856780176955551126, - 7602636613718406141, 2678224565451628558, 6976331354727208830, 7414684104929828967, 13536889690553324858, 13086024708711030952, 3748455179863046304, 1853373561223967487, - 14753645881295168970, 9410794713982813264, 13485977523338061503, 14267793994973767571, 15813187206361118954, 16449603969001878152, 17705410933007144731, 10960511750491378082, - 42380674434071200, 10068881872338405083, 14327149378182272744, 18264050153181932597, 8600790433943161385, 2952021171158508784, 13461070885471956301, 9633226987835715039, - 10360728550079953555, 8471248683929284652, 6673003382103023756, 8972723925695500528, 5941683993959582947, 13500073059240140624, 17856131583218769324, 16799784995825923732, - 7292102941225494742, 4807816512907139693, 11271815982004383122, 1065441269547643077, 5279915279332961503, 12100441009657772185, 10448964764090871372, 2944169874578456259, - 4669722990542640772, 10017368027073540045, 13392819319228640800, 1070815632453829996, 7274130058405640448, 4460835865761538026, 15283885107956150892, 5815884817303156137, - }, - { - 987127652983079722, 6872208513691823695, 10110578719299008714, 16457381243184327116, 10779072738879347999, 5965282398006505989, 18251577267494363268, 9321323379108563422, - 6119049170407437179, 12938407708038792521, 10105420405825346383, 3416306788177016826, 330648587825212481, 125568991290568141, 13857127346570918649, 4376080986981308805, - 5930434126597036589, 11240994623469578584, 839346533006694594, 10015087329724081709, 6285097815938761787, 17244606485954860090, 11523249727882012981, 7178451948850151803, - 16733615335426327004, 14833564736134873977, 15736159435317472941, 17560193966711884894, 4670172300306758374, 9477713670983496835, 14243955354032737980, 6459864769649694970, - 16053517698989562256, 2069464650596796670, 18305730134729303993, 1090863611964008044, 10595928817546105363, 11743183506441120484, 8584767248013363683, 9187452830514379903, - 6938579711827578880, 16268282168771714072, 4567473305742437221, 754548046014059669, 7773636946295303572, 8132380485366854656, 5054542590195827722, 6074347500754248128, - 3955857908381474930, 11852678900999621852, 13783017203403417097, 13616745777931267488, 13189924588414196918, 14519927295809952876, 9334100965942760501, 15172548734242885286, - 4869852132020793901, 14921212823114724347, 14342559113353033349, 13336827701782657309, 11168346789878684452, 9790480725902426052, 9171116079841529936, 9268902731763220711, - 4417372365016540659, 17280138652899703220, 6650972319709075180, 11252221422799491438, 6825784270383052414, 18308562203755695191, 4237445205082731447, 8485872406483449772, - 11718726714045105993, 2624508790343569765, 5794111482300008213, 12819216567095091385, 285329842793152354, 17257707863943097374, 16912487373614458842, 9501952033607497057, - 13074643344738491288, 8505193022029238118, 9932652098552590323, 267408114280737600, 14802861246220332716, 17506028737327736269, 15929083591675282371, 10937680132245212187, - 16688733766460131050, 12777635326299184071, 7769405825716531061, 12435979606514844725, 2767987141420672349, 6723940414217341603, 16114182069580717377, 4541113259200434040, - 8506371389960537559, 18031198550689409305, 11510251852995503442, 1923472385053944821, 6189904387119195613, 345664413118550356, 6439003191582953600, 18344385760549575361, - 5320548958745018096, 8341561189829530680, 3327828110998403156, 17981346269177513223, 14254804273025688074, 11111147827704077234, 9093333670517437191, 7272552282364063165, - 7587268797387514088, 4402481408866840263, 11260815389095334885, 14391444701764948710, 4224880318604689771, 2472148458660279030, 961218007313548745, 13826356220879831691, - 4477325369345373420, 299141931133875776, 6787652129916359301, 2498016036564260464, 13342319943892943548, 11124287719737492205, 2456333599771808442, 5084719026388755304, - 11208298545009109072, 9361672558653085726, 11597473974277116433, 9123409098329262113, 2315750487079392743, 14788891796020803799, 16477373474431052867, 6394267218565388055, - 15099803091969065643, 7815556206466442264, 10304177785190927723, 6493522556494567776, 14386173575053274652, 4399768637448990408, 2996083572119906777, 9762267038999270167, - 204205141115459509, 15145142808374731170, 1678672167166598389, 12032976094920574395, 7472791648310888425, 3687068899306742850, 2661021646792225638, 13705804163602287184, - 9320611303424530507, 7295004960403065170, 15749376924513664173, 11543669941217924178, 3710258597217352196, 11371260298937340150, 3902566672028686120, 17983841473999282668, - 11814188798674654097, 13017429106091059634, 11079902218909650978, 9064898043690914606, 12023954026861289442, 3592879256613061321, 9997625973577562433, 16073808232708438680, - 15365030910001289574, 8789654976305207659, 3460532362538090307, 12992239135084766157, 11449242863169591803, 5418502644558230048, 7981056000757137731, 13021725301900406539, - 7782773734814780443, 9390379677704432300, 7130223982341575476, 6496906770393189740, 5095392170846288421, 11058865093605824851, 11021902438459302094, 6088242418938968652, - 5966014717657529537, 5136588784988696205, 6360472729290909457, 4447169061266082500, 12506934948427595318, 16433395045878253504, 5116318868244944213, 6640832565780621049, - 4132920736998081103, 11827975663170283136, 379030309731223785, 3149051804072184938, 12035317616979166548, 9642536337674500310, 15531497803043399747, 14399049832547796531, - 5493097462539196248, 1629980144571354138, 13641173578972112594, 11096917099468924214, 10934169048860132281, 11269991112518485434, 11206050457519414207, 7939067479736521906, - 3806755078949823895, 15988975666336042818, 8246267395645554105, 9703363749164024623, 7795606269507901456, 451102251659512683, 5865831186929065346, 81064915983990550, - 5810137226573964106, 8424253088401255706, 4543883508937971494, 7386148745257823512, 1348150366217548727, 2103092839740150931, 8353010273955146981, 16831854467863536537, - 5095778754322493440, 16577416628492146129, 12288076721910512064, 10563487622054214075, 14620553808255752273, 8159958565993701874, 6712100880095874267, 13203797993773281759, - 9640010815039549413, 17460773950401928956, 18229977265837445092, 9252634318278265623, 16798979334068219458, 11731856767337519419, 1551975378671663669, 14320102155496153821, - 10528988339881191052, 3808685834232068820, 1064376960475785008, 6466670187430364599, 16860839938395945578, 8876458447995837267, 7897541112736965607, 10283235741250763328, - 12246932755942887931, 10842213418139067847, 1827392608284960926, 6961756951208563550, 14626966634382828071, 12653808277900379805, 3359368990539585596, 1190255644328095727, - }, - { - 10836955050615624183, 6228108794259714192, 3769609579318360527, 1481673673659326756, 301329772189110029, 3574710782304999603, 3037244905687722509, 14442941761397229485, - 7739110373965523311, 11019153332996240080, 7346010155518751797, 14853737521111213548, 2542883237207113209, 11015136828834421504, 1998601666328316353, 1540417751495800469, - 599034134015360884, 11263317530774995092, 6667501365379084069, 9844276013103312691, 7566306886180438990, 13702768345615509363, 12525031963170717968, 8463786212988210464, - 16430555432520738762, 11225321696360643709, 11777973654353154098, 13133115227828884393, 17678738157022850345, 1586660156856830642, 840647763693221003, 8645742354464326466, - 8067725618510810414, 6229041032854057836, 8025364837156161898, 1290443646630661359, 10991323655842003728, 9346782840170054789, 8939059450584871902, 4772347025802041241, - 8187379062828795656, 14744366698824202673, 17014663804743197103, 7704635785366672415, 17162645929628468457, 12942442527592695216, 13291710923558633295, 5800071247768119960, - 3552067877931717181, 590108493628737243, 497390871097272557, 12785795808441396281, 5561451613221796230, 14263823913216836845, 10481729699001112354, 7818094022046194698, - 3598736754916501501, 4827022662021197854, 8203180748141933720, 10283251600632599041, 16186680658340956808, 15183393398087319142, 8714402370450665212, 13217902016653171217, - 13766344083396522552, 3843491774288631026, 1174164282483810421, 6398024882371290634, 5459580537585379131, 5871096222069618377, 9611875286525007701, 1940221124144536452, - 11598781954647517543, 15695098933552070478, 14976427118847622464, 7147358677856872160, 17135524627354123951, 8338407198954935663, 18099467407613897492, 9025371359994313919, - 11451018285787631498, 11710749546511767589, 12969419493657624536, 2338911230088800542, 17492614411321910750, 15274296072504110502, 1258801445108685875, 15178229640559232741, - 11743016372336018414, 6125536020759642301, 16563280170798047733, 14529052521060111789, 15253502329174644388, 1556763737841306861, 3041940064290508531, 18020881359462953336, - 3035547704692483898, 462291414338050452, 4209186193642705826, 929930084709639338, 5246348806539841852, 16407585218848843770, 6076996892610687611, 16547395936238439809, - 7781914900266335582, 17967080065814694611, 14677062197599091614, 6667353926398988267, 5658765839564756939, 15807817354312473921, 7476371642206655552, 1194561222317134506, - 10645607622061780068, 11583886495890779582, 6879987349345299140, 5119348262235800038, 6546217876212430196, 5534845503308945424, 2003680599532879233, 2824480091030475274, - 2297585344913389180, 13965959247788377604, 11341378863608387800, 9890953382689640379, 10443523266835246852, 9631856696811288063, 6944503116553031744, 10030824122780966395, - 2699238910420203023, 13176131497943324759, 2961070701879546988, 1511208990650977146, 13153451530298458944, 254163587562261430, 6668642257003911712, 9040693998431169077, - 5596789796292416136, 10505785820531892681, 3803057245175025164, 13601446877323203658, 7939638174866660891, 14141848241206986005, 13782885912650943563, 6287188921995938212, - 12999700407775352603, 2664314004284450753, 7085329252118415126, 17472483363754271126, 15550759073378819069, 7572177503239633527, 15705617684783232308, 8586972133880335199, - 6636244234467769744, 18284390012667441869, 722929822219329257, 3274166388651987221, 13177791837760949480, 2568122970128111127, 3477167651270374316, 11371867850093288299, - 4065583279544717744, 15575999213135020408, 1319417044854511604, 14713082471342741360, 9399053450949627084, 8900637792268080986, 13511414538589410393, 601556817111475086, - 9243142430859561073, 14638657859832212223, 15324499241122936340, 14477761753578941934, 14699832840191454785, 5114873517253108658, 7427057898915535537, 12536800031182849473, - 11775949216482616439, 9736654184925478086, 2941126957776086651, 11331303510371804917, 3535865528819665754, 2488682969529955908, 922100556888217739, 17904958255578472855, - 12876460969864886954, 4692925517843901006, 17390372170975588763, 14692578774429957295, 1759864963511373267, 12016553435172103063, 13015881292003590351, 16187569590073958370, - 15154092100094191059, 8103665941237580228, 3265383210728928809, 8341136973870067643, 17281635732314163959, 16433737305161442677, 9130496888060417111, 7070932927684908859, - 2129695226164849659, 15163429615374108928, 2225893409909150746, 7870945454511315288, 11525457118388411301, 10519485231888976311, 17601979933176863246, 5257431126828903605, - 8898009465920717074, 9418463821940622934, 3166596280515383312, 14529914354665032916, 17743784337460844568, 15964972678726654742, 17116339264937332927, 17098426671353029801, - 5868176722765418764, 8429364877332796959, 7785756492654137899, 14975349488807886278, 3272010964035218775, 8946396491617515063, 3774503492701710541, 2113917870331282160, - 8185651664029868180, 7343199417670698200, 16586532029502206227, 1531724981369431299, 5596507566645246686, 1033673521199123313, 6075312368002387319, 6988496924054716781, - 4604669688530289732, 1867259042549585024, 16180237500272383882, 3296394050993129267, 4326520583229998770, 6557569103657179065, 4126356691591689646, 8674328613473447843, - 18057076842177382833, 13020419432300857029, 13646402493577420410, 16962268104464192344, 5358581430340252761, 16443104373870300795, 10099216829282619724, 14890543634568831960, - 13276631120161396750, 16968574704982977753, 2376454925072971568, 9477134218094425043, 13784622991820528988, 2074505569780291922, 14294803056569335889, 8759684036994631222, - }, - { - 16549155412115374305, 75977962737081600, 8870825488941031605, 7403557657089993256, 5825394234709429518, 11978746413791918409, 1876293130790608838, 9416631623519692610, - 12346821858361333862, 6352722970730511156, 9920942104315084988, 10492373916708072181, 11163323626947992791, 17035282992056675772, 835685192553490421, 12792459312570503983, - 10447922451077327640, 1515090998837129975, 13498807582085718212, 1212623301098019779, 11573518650162536086, 4823461685803772444, 7289704908733783271, 13167881392748327839, - 16959954449957105311, 11051594981465026138, 16062472412226411858, 1976004115345602080, 3630495248560019222, 12698191555196404138, 10107923614229901155, 1597725222698864118, - 3416019089997140849, 3011417601086561495, 6275242351124667286, 14197557183081060761, 5633711018871057458, 9723496411345030748, 13910057756335530832, 7285051335492395815, - 16774605620279328247, 10223834398868957807, 15781733027568799739, 2607095622729296315, 16499590296954181006, 7576646116121533069, 16638313875339315529, 14296194207652471696, - 12874411821611501068, 1998417862388106640, 13882642435422318946, 5791129521978463837, 7512934139125398199, 6966283273373526248, 5475728301311080129, 13542211842758381589, - 7798993150530415596, 3288770257171840452, 13373286069558329631, 9784279046496345014, 15725032660238528813, 16038931923358478835, 6921788930154218900, 6093507035435214187, - 12194839527972802101, 8376199250979271449, 9055995864116790217, 8125030124567662718, 1070812422878398727, 3950906148308170707, 10121516919638719072, 813471384549762068, - 7610605259962047827, 14617655900985224117, 16089669078196617440, 10594009761533811214, 3425971360520359121, 1245021768718221594, 16690372892586114152, 9933179766195044175, - 15142732720676276463, 17435583143726694663, 6030257647680338377, 243683009289621849, 3064238900429394982, 7655019927497549159, 4484400084400458429, 11650860345018651068, - 16203650576183697977, 17614744533772112337, 1119292890050870301, 4574885263986729787, 8108207498737924504, 9708434439316056191, 10676823369888368482, 1078311554675991883, - 6876202174636220158, 18057502510666060150, 7821730895845187783, 8882321799602877790, 16220624224336230256, 15562800387021280583, 3043825293109091520, 697130162105054983, - 5394549491776704087, 14795348078061113966, 14206080764200897220, 4623073019242398493, 5850602047109930316, 13783531993760979209, 14764346975698048641, 8951680172224205890, - 7302725075484262769, 12572584665857403749, 6499691362933905099, 14476353114356185371, 7381716148644532401, 1573798302334388880, 8128390307766282880, 14547454176248589604, - 12109367644744157376, 18037756988516427980, 814572839386760074, 913616818805172815, 12974490864633240943, 5228203788953366069, 11458421156905635350, 14534725545904442520, - 7717994192616957513, 12204841747568567286, 3911093871228418198, 11236736110419819217, 3283907124458179474, 11742518530965881218, 15033771683298452989, 5201173013910789542, - 13950307561490203211, 2109530041534182225, 16966608361725322273, 17050013487213560977, 6582524050666171954, 8348662591649610062, 18257068567217206885, 12084557407109908164, - 18134052713971906645, 13522834551049471624, 11796035797088472898, 4408384297249203940, 13184035659663315829, 10318594606381671372, 43784547091343099, 5864759723778872652, - 273751009786971880, 17433500308695913052, 14095169299451888252, 9384697581863180516, 3670310635026975567, 7512955195757960238, 1061441390592395566, 8687976820410979119, - 5847434943730572861, 6139588162124989313, 16640425042872222986, 2868461478718351559, 4582082172412426839, 15999623457772192080, 3911979819012561187, 2157661418664981538, - 1679437503202036379, 3357369754420384657, 14227038694942012893, 10849243658636382261, 14698996273665673323, 15473144682787301630, 12886363027445513063, 4218522843946321369, - 4305571301049736163, 7569433164869749160, 9286896219015408706, 3061813620853218759, 13836461093317197944, 12893856993043908140, 17368798334120212403, 3507360881370918016, - 17887381848254057882, 5080557806347717197, 10977337278063191668, 13725230338861893934, 12618602415751234016, 7913767807930932665, 7119689779124353718, 14253582440914432409, - 16180079775228731323, 7952167928403988663, 17529082815577219791, 14568667835887326401, 80331144542697157, 16190739578357987369, 8688615216852085496, 16668129019590270615, - 7430615013050690552, 16490141830322172211, 9793941851666815428, 12678643730925993658, 248986629347794843, 14250412400606998841, 7671639316274744213, 198890803142183275, - 14099347485199617889, 10490379547566026579, 2979540189595374423, 1947868558918413664, 14807112327541983728, 2275659819146309375, 14464189275380358394, 11448352451702208893, - 6508543885912264241, 11768683250765503158, 10952591955476802447, 13816638967602836229, 15422608700909569544, 2270147616630940233, 11179267547770249728, 10448962907285827304, - 16734703714440778657, 5221611440144584595, 14517195248502569256, 17256223341936104100, 13260411672715241049, 15406026631864099983, 13737383554048659263, 15455560302156741675, - 1751310744149771156, 13066379976997527874, 3353407191478085130, 1488844206746128853, 5630044290904406795, 14205180196532348798, 10021323252656730909, 4177092513333669169, - 16120743770319899284, 12307096057555293266, 15459231763664176764, 889710173957193674, 4419259815443372538, 17256024223837463177, 6105822529166486288, 14459703836399905847, - 13918155529832261002, 12953608416498491778, 4285102780598248527, 15853935066983430239, 2610351403194505517, 14905969693015035277, 12043976761492019990, 3883507340167876094, - }, - { - 10994470105201067642, 16033352651464686189, 15774427704233149170, 4596106024708523955, 8854068685612048031, 13529126595187822090, 11509928293490788309, 11620850709434334690, - 2068337952936280662, 6856444059219131741, 17213926210819196459, 513413453513211652, 5520465604253824995, 12970886588014924605, 12296275668437451137, 16808287251356954962, - 3413637388791433603, 16937929882486384885, 11215805046681294327, 11559398419268924015, 11697258172757450737, 6137795229387768085, 3190984692021653574, 15347236891154706739, - 17955247196574331290, 285928599571507431, 11902987704297070981, 2841167725097799100, 9281167410796848363, 16444340476026142274, 3423202423051178709, 9101021305726472246, - 7129792976024548817, 11116052691850916690, 13765136177550464799, 15815419857669199536, 3490265904262366633, 3075105190264147815, 13090337405102529529, 3772589223509323910, - 1865569627339845981, 14405510401062639678, 16548248891153314376, 18134729633170718083, 7342289204282809135, 13678804825671892797, 11309594694670555920, 6482941613725556691, - 15861081392207208208, 8373665453512079014, 1489270058265748447, 3594001972161344915, 1115942979837741628, 11080512787291988167, 8129036993725083225, 3358115086982889477, - 8869273893561412239, 10349812081309865197, 8913824872487209090, 3148808685596180274, 530908416884501807, 10284103744075805979, 13606889938905754722, 2418062398586758364, - 12413212040240282991, 7478703750955930147, 1623142090654002287, 3800351594986125089, 483782039790230646, 7823394007049468275, 7643246613581822171, 15001087565682987468, - 4027740097060141621, 11299467443664320327, 11151439614540606708, 866223440636939151, 3440384894029167420, 3873155505711856537, 5954029035616033594, 15381861683078360474, - 536906646315848696, 4762701494256722953, 3244970900590282998, 13809219136128336072, 6259009038800226590, 15448401588227595780, 5228638796256712654, 52817644221507266, - 2298603653884322501, 601221199968240092, 1285112712738261659, 13882709760355308533, 13563254433762438170, 13447718334658435053, 13493687958886238103, 11032778298151679283, - 17130548285854289846, 13389656739579236890, 11825243553071488462, 3295650559395515332, 5681593832990094932, 1986112566735995333, 6900923912677810734, 12885634718618182763, - 5991348986251844787, 10652959958005297329, 4727138097613835700, 11665606181484659859, 17818486388489237050, 17381457056943650121, 11483713831771420728, 14346336385265122549, - 6806904066777263417, 13464056321884738018, 6982639430167685380, 7669355554060154277, 5859444273628884163, 13073052226541367148, 9082949662405155834, 12390918296713433257, - 8626760324117733843, 16403951745962159364, 5837394731212322914, 6847167719031297053, 2888142337636247281, 3409818743436360750, 1677113113408664401, 1222157560539217476, - 2099068961815044779, 12562181036171628906, 16101890713848274666, 6017764396716978009, 13064414845499489050, 8419967306079989759, 18212218073753486044, 1008986649080828268, - 14883940931343463293, 12319376897638542821, 12367185247284838739, 5861252096374912155, 10018798299303262817, 6422772579819453330, 2070123940915480886, 12141302052520620302, - 7347211048650261526, 4324486111460763452, 1238262417801832007, 7620393213816116173, 13629115925647807355, 17975185632155863015, 6751253893269214002, 3530207280414557051, - 2294668553308381923, 17165287249067859297, 9897724011823072967, 17409851874231284314, 13888575318617508639, 12092766090379658603, 8412268183255186961, 8046572777745318483, - 4493498909328627892, 14652253245762410953, 5345262207345951514, 3970988687199074488, 2208768899312608620, 1510839623981662369, 642580537527653605, 14940785106713466054, - 12480576687390709541, 11249304546887636239, 6075047530003410694, 6121669232248820705, 10309256543424460776, 101796817907499847, 2110451750984093184, 10778335615512351243, - 2885395260584376454, 612553588199732392, 17978615338185945515, 10414937982597482385, 6078565000469652304, 11381998957121196965, 1536418226678270090, 15114446343888525079, - 13178439025428734594, 16388038968589028071, 16165750006742628176, 17903639397633243161, 9560319088110737392, 7888974492854359310, 16116323630343158496, 10177829649622711030, - 12866004572891901059, 10190228418101288877, 4717913135317392922, 13460871068228811018, 4756401774767581561, 7711771325649205249, 13695132008344052711, 13361851345229950778, - 938191787235564236, 14328703178349042628, 10217257468952800498, 10415924210674864240, 7171739159943819214, 6502538915112206091, 3300616451202954689, 9576887970605726107, - 17259872866446195810, 3694244894150718459, 3214322135693408389, 15571503654130046642, 2332159362399220208, 14087696453363417437, 14318693886833071484, 6131092646618026480, - 2378363646789710539, 494954399989334038, 6915496914984330558, 757197055392642378, 9097171378505823650, 12104288338329241488, 1905673690814481722, 13011078677095066032, - 8123217305309052526, 2527408826476194625, 10072980201182378784, 15489255866670747761, 12978131276673936002, 8312787524887306087, 13561211528259491689, 6311660759462081662, - 16247831307849916845, 8654394682758927217, 1180998443932568506, 3847327552938166714, 17658215545137701161, 11975413369861829206, 10679985684889599173, 14928266362876119222, - 7605162785889302718, 5718899840342120733, 6057249397801266401, 9486440247354542717, 10618370743126190918, 16153494357430969850, 16785070420314699787, 11277000340020413902, - 12712274459771886808, 15748114764509451764, 1994630377849062253, 564390855806287868, 135493276425567450, 4305883520257541088, 4842008929542073044, 7035106970720249617, - }, - { - 5757832545805155636, 17609080533053427627, 13855662030602089892, 9622498683452213297, 12281586442064581946, 610529441714948581, 14740357477019436626, 16983190111725558863, - 8470173855499872166, 15915210069852758660, 12368087246231545517, 3867174158581293223, 9082358201271846042, 16663463402757176964, 13740908859955866819, 7748969412274962298, - 13375424826931892789, 8508645806391261552, 18359272328758476903, 16433208398005282080, 13071423254987294580, 7999383023651164492, 14514701556577587750, 4848295889377673720, - 1020519568493754982, 10467781020270669620, 17607771250627508499, 6620300538436640218, 3858527175523168333, 13798129597334232823, 12495322651937391008, 3926713306087152023, - 5116038770086590715, 9943789276328255827, 13715439407309914230, 4887040860130243503, 18288477612078228131, 7640050573721350378, 14537362862524718973, 1658575506924200900, - 18400486168653423966, 18026904540891591040, 2037921821724043966, 18010956304511658647, 3751340308708032971, 16275459031633957091, 17177866831427164840, 1635431811339422016, - 3897330996014812355, 14347736534650088376, 16862404119462964612, 12216005411754788835, 11561909516001453735, 6261639657930189859, 9101978764314050064, 12280333151331067982, - 910276569977357717, 2872810615152156462, 1942106118995935911, 8734004121981822024, 13862118436432879698, 1912639548162720505, 13060137938875924732, 10642216911059510120, - 5132232031613377471, 3053931945527415993, 2695169719602504430, 11855046366025891084, 16462491222215366712, 16664416596202206835, 3077124688577987843, 7109495326459366311, - 3858762384693274897, 7520194928987242278, 4496744297661574884, 16159343214247089321, 6441167128044578145, 3604951495694157848, 3072075325567814428, 1964798869371174506, - 13689578474000942304, 8998724267038772595, 3350174507425430811, 15015413657749135511, 4848907595494161497, 7935644131326131098, 385849363817229511, 10087353746314516691, - 6067717601858189468, 10438404859927821308, 9991403870358837471, 17728358586134467771, 13476949968946830198, 7311235997042381570, 4429835371823736972, 17463216455983091974, - 3446799583712077997, 6763499387263152328, 9231082163128267527, 7733182914440272884, 17225092062157610409, 8163842076250628108, 14230171836718858439, 8195740716303697476, - 57759226194841354, 14962480748390190557, 2047254208877381876, 2830450574091058648, 14905486147404440754, 15792397930637469157, 16383409053580142957, 8686506861607761226, - 11120178572139812895, 11534611317577597022, 10437856602660752754, 13925966850017814278, 16776862023867799947, 17362554889424346260, 3408825299914455645, 2606150045870067742, - 1119490156854665483, 16772836556735128526, 8607715508817325509, 9931017263385440911, 8799481055779587022, 11740562709785257943, 1956849872282864970, 595288629437737005, - 2281206023740505682, 9926719762453358166, 4061056930877891291, 15576657447058286418, 2614863633636977404, 2206334532799385250, 3474210873232711865, 8477734925846980028, - 3340305349427486363, 5188523629566097463, 6160790887356413747, 9863988255192204305, 14066826366866912046, 11932779567129411871, 12863116515340321220, 15222969978942513045, - 12758642615291604404, 3209096496454847183, 11182564090025111575, 1931382908005123647, 15151007707308352245, 5954868822601995640, 15742433078711209582, 3347972315985628205, - 16490337555999239547, 8990885971520264447, 10360258506616249745, 6630482203535351500, 16999397485942558889, 6788531264412870316, 7229988042452941955, 9856917486277085502, - 10734804718395003162, 14385908274213668346, 6022876926209575383, 371182857232839872, 7412466195447558077, 7961511694540082231, 8030758761844457080, 8046696009323575767, - 6399666206029163609, 17663811097734928631, 11470778017516778751, 17702646621253134508, 14876192013866833082, 12935280981291312476, 1467399042175927183, 8848908916563618579, - 14359906986235888744, 4587839368531771442, 10497105860390751463, 14244616431904836676, 14906421794748569105, 7955760173743833219, 17152550002849021490, 138081467951201370, - 2349932829525749283, 14749355610935637731, 14751838563606808702, 18058355029195133983, 8461199524627795693, 4219910612621001507, 12776964042319070094, 15905069451612157329, - 1355498131832429384, 15975585519420207244, 15757549940022310945, 11357394570768845273, 8197697208897202922, 1901621009956576265, 4290101364365692172, 11947148614241269523, - 5840762872471677309, 7514977007446174348, 1527060545570586419, 16609099121469101859, 9320342325870097548, 13965331598495025936, 9683433385601741715, 8845290689278472178, - 14119395813630029665, 8634138112335652518, 4658233985292819043, 9622846971166516113, 996353694479629398, 7404001202059682426, 18145845493517798921, 6449664057746980028, - 16521775738375440178, 14142357232938693849, 10990147202113110230, 9959066954415780230, 13034621383041722634, 5025797339352139456, 10322111864643366459, 2614961497496501105, - 12557910439954509999, 12230084394391362713, 8427020226737465235, 12518021396913122088, 7134271418642259845, 3905501389650646356, 15707807001177039585, 2909191175572717037, - 769225015796913609, 8753059944613840368, 1611869096690868003, 11449828005116201197, 11517191665323762104, 2697717476879599241, 11188965056705006770, 6249359019890699508, - 15594613737645580981, 3037156291483237329, 5604071908229825169, 1604475019228431078, 7766918222574600204, 9339455406279970318, 16266564745812517195, 4799424886612563329, - 11601570184515356415, 11247678357869162156, 8415095559389686315, 9625816053586466047, 11807876143163335372, 15690209134241397733, 8684637224468015605, 15974968144193406020, - }, - { - 11275984449259340674, 14922638629881602958, 17186426309348732477, 2094500549052461127, 1245672419927595636, 7529921141299797945, 3181089597449057707, 7749529014968942143, - 12842581296013847382, 7845624487558348664, 8747439372999364825, 849305823897878133, 2217292264321907974, 8173534404179332054, 3588643190593022889, 12047811416592660080, - 6959527445237219799, 17170778245769606301, 807762173031474321, 9151445233487017286, 15103411489939446333, 7976669669591851659, 14824323986579638641, 1535817133122800221, - 2365455792963674834, 2249234228455309648, 5237136544555745182, 8814246419234451463, 13017813702607013347, 2241193992640629733, 17982226236989862510, 9800528153239873634, - 14106286229675768856, 13210380707737857536, 8049798856134302097, 9734560649539497957, 1623205786926824588, 14287958304696241706, 1800854015662052826, 1212925137572581937, - 3026947385483276729, 13169758424754896088, 6834174387382969128, 7206544572805916922, 6934064062491731757, 10620406409375153308, 5194048681860016706, 1469688754160716493, - 12993558037376222988, 4669474265806332952, 4832324179281001408, 4413085485243863075, 5405837906169635761, 10091776239975644239, 5290719555562061144, 4213669820858776415, - 17271890190678399664, 284117971978206043, 14999643475704678808, 6264699496666119083, 8859934981351804429, 8300880062060532031, 3667839168820458685, 17133003164910522197, - 2997449698566957466, 7884833253198684528, 12498695470674374226, 3115564300965505022, 13376506794876055601, 17895331353362057251, 16990581103090492269, 4674862843410794096, - 5006430925084708381, 16053115139414023422, 7049813739763202517, 6676629839394309180, 2410666182773729148, 8945309185393628712, 17674821778351929167, 2683163960153153804, - 14505459891908974624, 1849503921080779239, 13990490450160111440, 5181610498614712941, 8653117877167770474, 8814499350344722617, 5343755460620184433, 243401361005198353, - 17791633957402883820, 5938849497629314459, 8356801465373786047, 3163889445599730677, 9723709910898285412, 2841967670768995554, 10896757438566636700, 7434996874241771203, - 7372440365321345784, 2862880403174214663, 8420116322934238724, 2818552325655576635, 111342786192022359, 74705672003306783, 6591511741514218962, 13124391319573921957, - 9931074113040228488, 15362193958291437280, 6613002366394890474, 5258448208225327677, 5126245224005997831, 8755434042915330962, 4405830479557957055, 13343591337768921462, - 9242810916685205316, 2838356272544913798, 10099476622515682546, 15551100165305852662, 737838832976059770, 11188026425234857295, 10166119013055947704, 8628233674684143419, - 14086272070125896854, 12009239107306499026, 6592816798466831203, 11371087141421707743, 16277593907837607793, 16449564916599232060, 17471042072158213549, 11953382410698485455, - 823047236880870350, 7830286704456953572, 6464058012664717582, 15521380082330968365, 10182202815901986450, 18143527955004661429, 3207725716803325445, 3193887560605396493, - 15569872930692175382, 5346306686087630019, 6632365629111827330, 15865883909120927399, 7200040798106687333, 5723169387900917854, 15027071603483375844, 11018037359110138454, - 741009114382240162, 13879961246490269823, 4790141947869766711, 4479737908710468090, 4979904969974036721, 634413885118778288, 101727670723732801, 3160663692354720401, - 14613304240735929191, 7658770973133328064, 3028731168325633068, 1486737152001467114, 16715835021406106944, 15214200823642287507, 18441898204110447697, 5669963154424393607, - 4313074171267006471, 16217697149498819074, 2027993870023154350, 18018610229517524263, 117205923522590215, 1784380715025232199, 307956084870608716, 4140912860495129528, - 3938313265660748839, 13018885466029447230, 12461354215832959401, 14495299413345669177, 16234805331742830462, 1578184208291171741, 17168468892394781152, 12575003872292801090, - 10424668870965277693, 8952352824982702795, 18017430252932614600, 14101949308713937413, 16342352613992153502, 6862842966642668923, 7238655696295295374, 11216037980129705353, - 8381651800836461905, 275661552864412688, 5548629401959193001, 7174991431295718071, 7441251258233899268, 14052832476485122412, 301250917807487282, 17797202428295526090, - 5173263645506172639, 7621852612520351243, 4670271322283433581, 8663786927624336026, 14433502423455668413, 6926265712671351075, 9776903322968672826, 542207238644018218, - 9588056942118198784, 14024040464098859998, 17712446698584877455, 17945455593410056285, 18104078100936060946, 9565731894604896153, 13213845893767817606, 16043575675737450101, - 3436179376183792489, 8124476612946977721, 2169106928994773725, 8589833084708985039, 15137137534993478994, 12789920909097626916, 6767184505234754407, 8369097443031908183, - 16448089571044203401, 1396460397790470601, 9796571033221459545, 8162511506983092708, 13893406727199803081, 16188892369453405032, 16023105002157964343, 7061289566170423383, - 10448117565485426152, 8145533940921335838, 1579413779055052019, 14761309857236492983, 9815666466018583851, 15131106965446764630, 16986514923298225288, 3751380281663155649, - 2224143503200162255, 9410177163066991107, 7157489123570995878, 13420515130397093319, 2675717750075873421, 6702938999067232257, 394050047437199204, 11922372120263518221, - 9930837889018815244, 11397955329795684905, 6931891256005909739, 516538601500853702, 923444815286512108, 16665363217941733257, 1377231042965759902, 8439923996651310778, - 8743817608749172620, 7804846024944300667, 507107926259802795, 5258061329638283805, 15071070675288472598, 1848743106176521296, 16295570828486620412, 7409462376590083349, - }, - { - 10223936123327786454, 2321887803300626936, 13607747528117965743, 10456421630388400123, 3266519591187534953, 1053691207967834494, 7151443045753788549, 18124688636664828399, - 6946488664257064464, 9775328903143754150, 58700362449753229, 7901817271072273406, 5074738678159003249, 18397239731906005785, 15911102965988125888, 9277654580204145348, - 1874700306906525099, 7337351570334852732, 7954195906114335343, 17230226427261850070, 5181329498860909261, 107167242193237170, 4364856176182710332, 14611171841443342914, - 10990327814895720476, 16588412771027628390, 2850177278998422188, 11569813740328484871, 3922148781422941186, 3581659216490446242, 3646872304052351376, 10887870617200051198, - 8175121141368087217, 15079393830876652065, 16766987879267543828, 10582796406546815217, 16832256009371376870, 10042650470778064892, 17867163453935683780, 7123418345572641116, - 1782651072016504775, 11033882508408412333, 11105300284232190625, 3276372405089292929, 6399472468041061588, 15319690780388315076, 4928530863063375966, 11596222198340277418, - 5452424185619067445, 12050433097586021281, 15018766900844679217, 273234254926088220, 15426383635547379531, 5213762666043737626, 2829185842069118470, 3230799283770935127, - 280030342772428106, 17354882606189694746, 17455445295460080284, 18076709382926018941, 9895982528034548913, 13681172423928175330, 1656433131309057012, 11935757350437721114, - 14437472586336929440, 17387041914242263390, 14861577074379746687, 5146556788377906297, 13036814755814090195, 15108836859245573802, 1667563994642521213, 14722845469958372258, - 7781061995240980266, 2066078418484154391, 4089376589847114892, 2434843609506038666, 18376509832460312721, 7187709121160627756, 2455436656049651823, 14419116837518875372, - 1270185079976403265, 9214436628411717184, 15450450827683432913, 2880014804806096082, 15448799931519826757, 10080240282127928735, 10673974088219619287, 12998944469117087518, - 18028691745165748687, 8931519595829275195, 18379893031942930865, 12120980098075498008, 9596371470855895261, 4133427878071274570, 13159312399982591699, 1639865074052258019, - 1661696187746428348, 2656198437014978712, 13769477291975851694, 12512848714492869444, 5980926616932344693, 15821983893144953005, 5816015630031200526, 15887565799959254415, - 16463929919291729278, 14920112063826664828, 10056471508435050704, 10696267144984026763, 12049530292963090991, 11926086636123189182, 9464890378472966538, 9719194510330239601, - 18110249193861022779, 5612784685592189906, 11360454032996393150, 6795401682138043705, 1961398978248902107, 8999847457729547905, 8941741619641401180, 6086938661427918241, - 10153847769616409178, 16591913677701651064, 11369151065084080884, 9493662847124813178, 14299126668179023903, 2451525064998641745, 16055696673728703463, 7600736037142850105, - 3331094657189179723, 8579232659787725167, 11007434086335446933, 7488529659250917009, 17217317841029490639, 7202184784979805220, 10955913831459448069, 9000508720500651545, - 12966352809478736412, 9643078159289928329, 1577471789984999485, 3065864601417367655, 13683627106599504109, 12782093364215596525, 12883456287502344466, 384144415368165580, - 2010495664660209855, 15520744321638216967, 5385447087428594566, 12897496516555487055, 7343279016502952747, 11323820480524965410, 3414484402519450292, 2497721392671865580, - 16065061175628739123, 13981641072236579791, 6942197664821630380, 1667302033233547783, 11254994815452647404, 5265777633437443003, 1242523090981771320, 11333562630675377559, - 13967113064180443992, 10679621597408504672, 16223869620849920309, 8813286726524283182, 2000697484240530777, 5417120625530117302, 12109041278382745291, 13257693171778388584, - 11737174095432286870, 13459661128718998448, 4655386724404378836, 3119616752887818891, 13324285182058113375, 1078137740985006431, 1610820303976884986, 10433300853468291587, - 13552049979590080822, 4379357932546858489, 7594644709024650108, 7268811721525297059, 6728671136192921869, 8183021491392757516, 6569378188404015319, 6481294988812800823, - 6071501855022377789, 3805172128285889052, 6802689634429908933, 11713310861536728752, 18291420299754708339, 7582277238191809023, 6183429490206797252, 10452668103640934631, - 16083971675285095468, 2965035896159234764, 9379493912871845724, 13109394112987303523, 231416620515766991, 630445729708227114, 10015412267172773636, 18104521419340860951, - 13169770634232644390, 12462964563528956096, 2689434882719314440, 5936289129999384022, 17773436345927091892, 2631892834965929605, 8167719122803587721, 2458223071457452931, - 10744932251818515465, 13367480890778627284, 15909410072235544918, 9252559547875570290, 16355895225285344183, 5115003811789024567, 7369371640924666845, 4586532908333332092, - 15999516281080615520, 10972478396135936147, 9002100275598932738, 9043399249857967875, 4975188939801806064, 14240375126510021504, 4497218436093285729, 899858725260616391, - 4788026362409273347, 8940774760122210910, 66616358927988247, 13054723206705508289, 6256911511259454580, 589353691478007084, 17831732841616807303, 10847300659030294141, - 3016120727980669767, 340560476433708073, 10516500208515875331, 14933811541787518485, 9941997565508314935, 9752941942651093949, 1928238223054143159, 16147782066840428568, - 8953947187833770878, 6627103431982157573, 1279114735725952920, 5378128106441279737, 15447712974588571571, 10552843735673449739, 14956126644414569830, 1994513099978508850, - 3339871688614476269, 2937156932445032796, 2071344655111136329, 509603454456841298, 10929109734329673813, 4531629375826317764, 1802431569220697099, 7971315018970882891, - }, - { - 4307546666223047416, 13914498777427309061, 6812156124789414732, 1680174913762530491, 6756325174405757110, 2535144759174364990, 11263393915003278429, 14767595249676286403, - 6981289090623415465, 8930069945493884157, 8223216504978132408, 796477795300774057, 3120155459209743472, 14825603392456550470, 3711879425019804830, 11041054473536223927, - 14135544350792474553, 6171419888118563156, 12495035851387242130, 2843310747449412555, 5668766087526340552, 10117858698838396246, 5181027414039980750, 13247490124270426, - 10847249691051757241, 13332329214721571156, 12457628412284474075, 17044657510482764070, 5218221397478351943, 6922630493693541156, 6207927102810766143, 5644846665334649748, - 3169200533952511826, 13123046990387029463, 10303462306703730135, 3315008874027436174, 12427067008037332041, 13190195608614554888, 11930408619792340463, 12881268563913740396, - 6700154625941523096, 796110091507466427, 5388163944686450548, 3113104467109529928, 12930558649635882086, 7536049463980825715, 11851825635055645132, 2654888532632283214, - 17530163750522835336, 9722612350417778827, 13244522480616169491, 13740964907388846002, 793235549667461791, 1998252773625399730, 9697911491069876538, 3365596945186794622, - 6506371904134856034, 9541373683805144018, 3149037850125132851, 7111810601994573897, 16732445693192247884, 4994069681898274622, 7223719243730104348, 5649174084086150712, - 4640203560336739679, 9900565149463137003, 1093715346388527458, 17169722430093991108, 14911871124664548213, 8091096017016862097, 2911569128494944136, 10192934055727569503, - 13251895658744991883, 18083873142202267221, 8241707078409323349, 5240943892375002838, 7329419846032881810, 17784005510850539551, 14034072243705748841, 10459194866755836024, - 16396304393792022741, 510358226971662693, 2002127643935690257, 14681425695950046262, 481902649451190280, 1717807040845239061, 3358903321435525144, 12361252150277163759, - 16562962997045986629, 1977585352264948582, 15588655103333244279, 253344970359156714, 12939363813291366775, 12548224526376199974, 14450582788883748364, 5869541533939881460, - 15346378007864735078, 9904337403373774864, 17933855382993937953, 9391248304932723816, 2250334275383247202, 5978804056136420670, 1528238852592364099, 6491566547950141733, - 8439860020828526478, 8674532462170555517, 13889716766953024111, 1166696901054897271, 3599113965286446905, 3276801695553601157, 6631284861504552600, 757022358659145685, - 1117291222568805017, 7148845117809308441, 4044258438241699262, 16593433123496068718, 13992202310165134218, 2998204381658279116, 11137382784909083266, 11972581616612094469, - 13970586842647892965, 3680317572634289692, 3416494470839852757, 8341497967750607131, 5522860734580749818, 6847292760525096386, 9317394708872196559, 8522252330730808934, - 7951036477225560362, 3718789111033607646, 11667291286820266731, 6927579620295878614, 6796746225018555970, 2070061401518338268, 2452626412419851405, 6130352643925327785, - 128317967134069640, 18241952544586374251, 10689311587315723515, 16537482248073764435, 15914436258832414511, 15518344078557945167, 15883120902045970449, 16251109112716994957, - 11957637677355945602, 8965882791601648704, 9390723380463051523, 15025038333096274711, 14983844148312808973, 14488574793452236487, 15795526425513195718, 11651978879566144360, - 6838341670149165895, 12326189699069923388, 9258908232339348843, 17297038041466207989, 5242182985453021593, 9648294165629935142, 9715128265517308395, 2662662536493743894, - 11289660454922592938, 470300170724369955, 4571871646010841181, 8724229358245178735, 10173959190953118810, 3611286966550223594, 10810806064515103403, 13571898391208639897, - 6782514579206442308, 893150666351200058, 2099535232722538223, 300696716419619813, 4778737709473194628, 16786610674618434170, 1751624209281870237, 1677055321500839173, - 8950755642341912951, 1974922263791844623, 5333377426024439800, 13909803085973342843, 7639604505882407937, 16195074617613125552, 8954461446680048430, 6823359994465290754, - 6790869670806738567, 4499989093713728199, 17496748050437205626, 7194829324969293638, 18432532588985091708, 12041300075343806904, 7788543067151959941, 13703334460383638224, - 15088053026772564466, 18172984562199594382, 3119317310593433742, 13835498717175822656, 10015747176747842576, 11008571041665092033, 9377877781626879674, 10465443099481589185, - 8933481722931715231, 10811948483433850165, 16314247813274714890, 503147444786527544, 2533443680646505069, 7617720894972668760, 12477410920355308950, 422423516920457876, - 1501843276089632258, 18180777013307233967, 2535426997299341256, 5318958493284100856, 16758265544916918856, 8118598628492446123, 2511013049335776232, 11181447982017705826, - 5996381448168274884, 8108757135223610234, 8067369725584584297, 7184925262427750366, 8199341143188441284, 13031376443169557016, 16036606349050125404, 11958720833222295864, - 15336831835795822898, 6806921200736832713, 5959923980569572002, 16835674225684329982, 9985579070716031367, 6517360043741716503, 16609518082836868591, 15878184747124924573, - 4786224758360153905, 10283234398763800487, 13695837902615591472, 7260571034197533442, 9225062953237806971, 5969706575516748564, 6537573986766117532, 15754484267739133126, - 5004791824134844360, 4971286291135250424, 1811371968353107289, 15772458387007519716, 17381493577383518445, 14326903440006940586, 14237922492359728234, 6234116464684325431, - 9293668142017263584, 17134656749295164870, 5879480323258506465, 4788695233340705697, 17809277710857366810, 15157733645094688870, 14143869691462709080, 3162286338158090229, - }, - { - 4471613312912718060, 13601785177495103328, 8083849806888905297, 9053545412554844461, 1876605639999952155, 6124537911475118673, 16877891074567085688, 16541720065079132344, - 18138305348849897995, 11498878557125400853, 14125346336359365201, 11991638807788804369, 13935355764550912568, 16209147067155729660, 11086190285777019292, 16727288863943596410, - 8873152377611229668, 6260821826956744083, 11489383533808918262, 6585112195310961861, 7365821041919648819, 1936165695028211587, 16164747634991415711, 17957320776652490392, - 13065030057172289846, 7278765836407486850, 383827150208081081, 7832055893191054601, 5249323286889945617, 1631661912887095912, 4431088469837785451, 2866263172993336891, - 6140213328062333551, 16704025329777067037, 5839832043209342792, 9196354634862869885, 2735762290983671190, 5323501742548818139, 3199127466610501482, 6719610946615763192, - 4032564124345275293, 240208626666701335, 10264845378648897042, 15608289126091352415, 17866864241918154829, 6207477318890336372, 491708931325462670, 7002400618323099260, - 11507747783030541234, 13683043390668171754, 9924966309328785763, 5549516466627385909, 3724001483041449858, 2408778220985427590, 10510707601023430105, 12862520912519186496, - 5012372868660694231, 12033652755433827667, 5960732801180177919, 6089487525155575261, 18400192045204062277, 12754175136438960528, 6170965736016609163, 10141374482047067946, - 11781193922347227447, 16937876011211881637, 2982972111293427964, 1728244726890919596, 3327997232304084768, 4754833121145407334, 5871027825507908591, 15772493911709624273, - 5862944033912881884, 11132730978666088350, 12167180155548291888, 16449838286695349787, 14399676610730016345, 17071083123672650337, 13727728787831175379, 7507765123422748291, - 4883057314704644529, 6606742732149784343, 16070555141087563722, 8408294891669305261, 4298316003054547788, 1573237855902568238, 5357176885445018289, 5855732582172939202, - 11721126538980357625, 7216004194033429913, 12765889884935948315, 6003399149613653734, 4571046290325663920, 15023470461830485075, 11463513436288928362, 16135217522406374542, - 14300855104129153291, 11491527690078786162, 5674183453812271017, 5044682546652747711, 9153978680942338831, 400454762074409409, 12351470849648616331, 10559229320903248832, - 11839166519633311143, 16489041153719856002, 4820713204385149226, 13768001962143023630, 13107713406478328396, 15471245828032402460, 6733652296473831544, 7665657127090105428, - 6114372925011600760, 13061069979571997963, 12156991017966837826, 12403009591138383583, 5761958709898299258, 1907771304051897263, 3007439379929412593, 18410854883912163962, - 14408045416865494124, 2442199381796557002, 10475326303775862953, 13637445125954159957, 3778313603630758744, 9247460369874272772, 17572237597883145087, 11338350096360776602, - 16486104352829691584, 11856560607954368882, 7574789609701925021, 12240083183242127118, 9872957337376856275, 11508929285199799229, 12084460294902152451, 5537978390111837838, - 17987471707896681874, 13038244305326284081, 6130570860032709721, 13697749322780057427, 15250226813583295859, 11214437899623632196, 11227424166765094355, 16073863048822462466, - 12399110995748365941, 8259021120978314016, 13249466772279340115, 11201772702582865107, 6680428295197296613, 14825065014187212998, 11638499193934854444, 13944483483619391536, - 12792956896156056673, 17521293339475028823, 5738513258925006248, 7070317930523546296, 11175557000762820214, 15356683721815441509, 3038847573301969409, 3712495274059632476, - 9703339902904468931, 6903532388259237787, 6598718994389707957, 3524767540333384210, 17230409287786477986, 398508689507908728, 12956323124513250470, 3050411724956364887, - 9936181795041159997, 16502578966693139346, 12331385558134766329, 16368402633574222539, 17549179704234998175, 16732353056786161257, 7018642409136068141, 13907639522324102590, - 3202436334590923936, 10521323531132496064, 17087322194145514933, 2557934785422493682, 1054672647095378624, 13197226692868722325, 1089249862965154915, 6479925079582112772, - 3880905381896902231, 16702686708922296685, 9815623322445801304, 3275100382267252573, 6882533095211022198, 11000715667767797665, 17615808190378608947, 7418883369171949489, - 15109802007060416273, 6172716471862133951, 10675428021956965140, 5719399515177959211, 13414568332401128475, 15437234656470291881, 15174397947571718085, 15093134682110367825, - 12767354263003560893, 9423701226679222965, 15980976879563466685, 16370172902785037004, 8843543841582241065, 16817827501960591898, 1524531339915785994, 11624580276885598157, - 17147068462804570503, 413038056092618151, 5178874804057490245, 6267545065511948977, 17573054445714024932, 7120476833739422223, 5707115123830922617, 10971108972695387841, - 12546478152711337402, 3213958910433616233, 1066524299473173792, 6276669942370566610, 14816818963020520773, 7372806616674468946, 12220278123497641030, 4953625488417522128, - 9443607421568920607, 2583030461169574647, 9900905053299561307, 15892418329702922907, 1184158607153919924, 17842123060489837980, 2681791639846598155, 14394984710894548047, - 17363678829105605076, 3907856148144141388, 7535915338133892356, 4354053943074081189, 9644954727645503986, 6816908226661921388, 15867806610099035654, 13874346146744695721, - 2654416582410062512, 9232324386948815478, 13864516581612906345, 17132638924861000235, 16875312639179645137, 11536057026563830119, 1090137303802556590, 15667188983774010898, - 4336697789732072031, 16054848662858822197, 17934449813415035557, 14518380622432694666, 14100582434152190048, 6262866632984449325, 18069160441815400774, 9798342103009260692, - }, - { - 687104890149081183, 1938816743979859301, 11342071981175913904, 4270322127259097184, 4964776270155503160, 17849333582861534767, 15814479527332819692, 8083943565773123408, - 3986890035154628803, 15316660330065019741, 11560940574529263780, 12576851520091035878, 10883944418224886092, 9908329441525486205, 11238684990962507809, 12900626758810151662, - 4077800412543228484, 7173833470188867493, 4604439809988262876, 8090706047559948234, 6117166546062912279, 15748537214854486946, 16719594636199001564, 563850925691991999, - 7109145612337154341, 10502845970727626855, 6527587047878193251, 7049690136888681718, 16750703006415156202, 2559311261501721445, 1222802194566919230, 18019462938525560766, - 322982839910423931, 2590270731903609206, 14012397059804449007, 4254569016772908483, 8508420263334539908, 9175848619353159735, 9777676085150569067, 51565612432741329, - 10233009747926770582, 4858065366607044068, 17837971428933010861, 10016544790726166742, 15260359301638740999, 5101999662344938158, 8809855615759524306, 15369468763003019252, - 4549989329927399868, 4866130696079291940, 2784467031729859937, 12617898982021887868, 2721301974598150044, 1014232218549205942, 5446756626431953863, 7315134179045561903, - 2592184418896595488, 1723751460114310463, 11198512454461769811, 6203707848404803677, 2601731234271436477, 18186700975610533226, 4757569424831899615, 13359873383138312209, - 7339520839328992093, 3349084091338116256, 16532710170417471614, 4425958052714174548, 16833748535746803845, 12665172019028452441, 11274971974705134171, 6504206221872290467, - 17921256304121537300, 16573867650874642543, 18439217559900658467, 2917797231317530012, 2415475159165597656, 2027542924210178369, 13542535558170959524, 9428931592662127870, - 17821420552135083528, 332847653840014838, 11832506312426064436, 8314663852639826188, 5744960486691350299, 8069724388577179929, 7949740770152910898, 7431049632429535950, - 13904640252203718708, 10747313134117021792, 14667070697514384141, 2600977347774743546, 15498986940124021079, 14740645313274577011, 17403811028932224808, 8060102076475954685, - 3517334016249952489, 10826317205305313746, 9664766330892822745, 4145357045596983962, 123566849370572650, 6452080295201963409, 15558941970553263818, 1191650177320171029, - 13303794914626036653, 12135860919529132656, 3620217653879289461, 5443663950311568399, 9020744500355505374, 11953955628401776228, 2101814526784564259, 18218598416910848525, - 306945432061418036, 3150552227215797902, 12928374347433953916, 13299101042862573370, 13702883318367407795, 4879985767563062391, 17591048490944890593, 5088664549487213106, - 12990649636107730851, 13002224935892458030, 4380799638612122791, 7935443787987894924, 10438069978940053126, 302419699431148366, 551508078777729872, 366155636877501719, - 1657628676376133571, 11398060401420699070, 15376723048512638551, 9875623386041366116, 9978954704196888739, 13768323245406799962, 3568095027938899541, 11120740210192996096, - 15561317952331530901, 10479759083279078649, 16536004935523752634, 2928518661531554130, 736056663469575928, 6131440330717529370, 11275149343392851570, 9601030074480228347, - 2397968519718544666, 7793046606567840651, 8971792946996316712, 16581860514259510747, 9067804351225143661, 12322425857061932421, 10680196669251962457, 7226521395530060461, - 14734735764746786753, 1378251478826083755, 13509550209468602124, 14458158239096821346, 5681313138148713219, 9054039627425609375, 4235536482830620712, 1502753755874778370, - 10053374816829223121, 5956370573575798562, 6842782625116195714, 6646143553705917790, 10487617951080656190, 3930886288654953669, 13141858447548326172, 6966039733711006320, - 3565931266726110263, 10142260659118036168, 18315406451571961983, 16857333990691080595, 6889519058362658033, 11812045051361479600, 12503117299646153207, 7223531498406875484, - 15243128568488310595, 13798032762330794140, 4456440673105474920, 17896260893739107970, 5519537045179649847, 11908888770632658821, 5444504459295913107, 5588728973482930155, - 8914021876030553161, 9071747156187788379, 14974736924255494885, 17070198435868341999, 3643991391224035758, 260637732328275649, 17609644917816078225, 2302996326941944665, - 1293835161492069734, 5795029109259991590, 6978986253519330084, 10360755458408067486, 9467742127861782141, 9197981630801498774, 6297600026339958279, 1375635441408481019, - 16875086338187280639, 18188722331528885957, 2047282716697647836, 17808297209051779725, 4756860180475663362, 16103863616340614471, 4416311024167936572, 6340715229216403079, - 14261984008515151673, 8778722476581699445, 1624620854396291363, 8490568310899028272, 6147263592092458803, 3717414274397202281, 3449154725620836174, 13526832985450537957, - 5888744936142942064, 17277140802638358763, 10290028650289820825, 1940657436863195045, 10796401239257150661, 7788083050548605852, 13474393003015663489, 8961936186303685357, - 81364364291228199, 11636155122637141142, 927710893705810893, 1403208391464987879, 4332234662194589819, 7913319387647351094, 2589089673930123808, 5387282875974124558, - 10611669207938469024, 4491327257859270050, 14129391883837344111, 13924810848449766461, 8792187899775727862, 15048142623570073200, 3933861866144269656, 1162055633060412126, - 6883724061714130987, 10416279294253729103, 12247033224345499651, 10291073256885105234, 4480789666471481188, 6022169887991948086, 3778647272347441051, 9527380466585130391, - 16407225233842256953, 13423683834633513951, 17454464203550700633, 6033758555290610449, 5063673994339442907, 12250392784929419939, 5954485814444410119, 10099095370725442279, - }, - { - 7669790431656261769, 2776517632462593286, 11694025667665633506, 9533794089008895277, 2895611631120558023, 11551410655448788956, 10026541900772270925, 6243136875017000843, - 9434484992529186384, 16435748047660609525, 16190660694150989986, 7083965852434071085, 4216306437741910756, 2698742177539497614, 5199793642504009017, 17298424769819019160, - 4041169394784902550, 5699517344009382913, 5306272267462320559, 15846674482556330025, 2606351264228884283, 4162585980422107281, 3715151019132039005, 6607223447043258693, - 8168579295855409503, 16727569921530031841, 6182114460261837773, 8940603165471931374, 6081572078077526926, 5890840443923124563, 11215305828294759727, 2875117534361804712, - 9045974983664041829, 905036705033699463, 6962033946652121779, 3027264198782618401, 13786415307358010100, 3643342525745067473, 13641958783381681886, 15675065537779359584, - 7507377696839752642, 1061259379811757443, 10276590160392917813, 6889137095037822679, 16373913505782725550, 12287733095803524526, 5695917172259210496, 6360958736925918808, - 7459854586357006968, 702429387211615855, 8231296036461604410, 628323703857882004, 1059802628602873385, 12517208225099517507, 2368172548334856593, 4792344750094708709, - 18352334786472886037, 7096021570596476676, 17045407505128867173, 2467670847537319400, 2225663888244226889, 1876713214939672742, 5329943993157142620, 12168650975912182188, - 6639850268372381409, 2284514769224558945, 15390110317831975716, 13933785559694229008, 12787641603764341997, 793886210532292741, 3222136169196008839, 11104892506868626444, - 12660547967989039787, 2109392063597767300, 9889743271997754037, 11803327596624324036, 6940409327849314286, 1466399127363116843, 2572333022681966275, 4216097356402537802, - 16858757460581672909, 5838407119753001493, 4453405435911954669, 2828665451507432751, 13657966632733241760, 6875986784381874300, 2390233934255482553, 17386653779125555159, - 2976756344404126744, 17032556609402836559, 16348907464011574182, 2196781021202618892, 8270822867494340805, 4738372358350764889, 6088256422707334932, 17121369334507507505, - 2081729301541563384, 5577186154173396778, 1865152567701500436, 1422284589642218069, 2489023909725140903, 276494395149046869, 17420927169263487236, 8292343688801608074, - 7819174654675104600, 12778055482430336726, 14615848543490171611, 17498415175263742825, 4785899184222234034, 5227136636239697699, 1570704808469050246, 2858953380860123257, - 4323577007857413306, 10524228743339400397, 5418808897687027557, 5939367271366264075, 3569359126353670574, 12961495213964770607, 8906990808988099905, 261084295374207271, - 13937553904380032591, 9165760362893872288, 14159606902675650669, 7794101517494576908, 11994596892880464164, 16211278212275417034, 1568324133241165712, 6579463633356173526, - 3784436423124943604, 14504130598322564217, 13343318845201913758, 2617267381187565844, 10063945174501910869, 8584806992850354016, 17494557973113338328, 16987450461117846543, - 3191556545349441897, 4780077336463115599, 102121356289129288, 18353108394754479957, 10099934050411322327, 10323433488737585897, 1480832277301232858, 8304664509429164326, - 16494820005379860880, 1719281141269927630, 2983529566257876158, 15928721259545722550, 3714203000118655889, 15922105900709017310, 17662263539397115758, 1577461381995722723, - 3426958921435818822, 395886748655323570, 280632942609884625, 4361473570148050146, 6600885194277340683, 16668323952296831943, 10057749804882861513, 5701592287343868424, - 6951585494335471689, 15680855848517030170, 9776921814538436791, 17640230976984644473, 5777838393869379647, 2176689364164694052, 10884627395386092313, 17656310368333301757, - 215205608065278414, 15361057989137229644, 6756215047166430628, 12215084297877052825, 7185815532109454500, 3394755837885079236, 1778980761557523977, 1861969072415300655, - 1535235777601157298, 8875662482214652105, 15404846185148709157, 6538418983879634448, 8341745508628160868, 7582603669233291629, 13003716464169800826, 13309194956036155778, - 4791947847339351337, 15204996809755844932, 11672964318683763318, 13067259871945801803, 2139419248113049376, 18195694858089271989, 7208559250123396675, 4671149208567820584, - 7276586425415793787, 14549539461274532692, 7381249250982432115, 3215735370879771405, 9197833835152018601, 17236122023193655371, 5029275100388702506, 10829687080866991082, - 15533362570521057331, 6942829144635570952, 9572990445468151820, 6294042535380467396, 9052929167426522790, 18293430694900525497, 9076155092724374912, 6410242671697688127, - 16930844972313552415, 9009509357611549679, 10722442939705348974, 4686888495512108749, 6326319203058274828, 2590592779822711917, 12876493112068819735, 12372064322375408146, - 11938822647496400962, 15333527667419199710, 2385985954862343680, 14776415112244140169, 12817753724474105460, 5129368568396757194, 607898027127847045, 3917240453172744497, - 47211231428738650, 9333275559955619158, 7534434473427098199, 8557232404317963052, 11597011861056629671, 15926835677212702441, 17943276685960195536, 2513989430679125485, - 2903417389682946131, 15905578940823611094, 4910425097773753648, 10817415382143821768, 16356392378927186116, 1174713154793914656, 9176413825070952738, 17779105524945038711, - 18302140065591767046, 6334261306636966429, 4203057092695998640, 2740754645452686340, 10020911575632378009, 5906713384548665207, 13902791548718280892, 2505591245136304093, - 369660229032730089, 11851915833529805698, 13485269529443969890, 1270120511649175022, 9128783725626301238, 6173048611666804214, 14151404531169195672, 18241008099921643437, - }, - { - 16226789363155700046, 13734705589524056856, 9629995513492843231, 2636144377026081617, 1233405076007260313, 2119672919365858964, 4932766292290315579, 4185117177904214366, - 16996170392430604056, 2476294162951949891, 6677439492116109133, 1649550562276235959, 7307278264575968221, 17128676264244010843, 9768062299436691373, 3825325732056225433, - 5861627228365499618, 5011684805137210454, 1579621475012951778, 11535371650014354624, 12847902922833318241, 4997014846790385136, 9875988184618650628, 13094082946822736823, - 17224650011872599657, 11430188086182976152, 12892063618843720029, 5912993124689510433, 7069617917494051681, 1298012103142698333, 7943359430865057535, 9329776843721719539, - 9091412025380293893, 8622355764644651307, 8718353412518918238, 12338548766610785709, 5241721208413391572, 6315749100915178625, 17919741546105181107, 13677847475856526539, - 17388254638056933809, 5422523708003180288, 16851423629233109043, 5504298365310420423, 15145549220326540137, 5184279399795985462, 2201159255780420815, 12506121988996036804, - 4460258780042860751, 1816027820333214126, 7778555198679811350, 8155451943744426012, 18392325810806023014, 3955295139981696248, 17141295608995204052, 14206938573418983337, - 9464085603669036454, 7848014338005901108, 2368914226155404065, 11578416111848517850, 6323647866244499941, 14399589996703947996, 2824522520842155768, 391310842153371124, - 17489550078249576530, 13418700716683405568, 8265132837103985034, 8386855948619700037, 4642739669076635265, 1941217860224507563, 7402267177254210690, 9863923110146355168, - 6176679707488254741, 4307819088229734202, 7082712522654871200, 14603822721598353371, 4115674343542702663, 4132348830250348245, 5992042367418590636, 15937819366199058986, - 11008669567537833607, 14841150752801539889, 5253470025479549456, 5665837575328478629, 4601810548582757669, 6173003636576141170, 6899193615399367692, 968231402917393055, - 9948650801233133770, 5836115460383443197, 11404170696974449207, 4791020823967734476, 423024247809958592, 11251668387880260801, 5562546584223492723, 578572156618131794, - 13456676488167240303, 17121749146829956377, 17370555398500311209, 5041791432274350681, 4009412063225388868, 2407629981571159579, 13052555280728877038, 11483117063845312302, - 13421089948800544371, 5001604265596626568, 15312985179876036482, 16032805766802337150, 12508684642650694186, 10422897636519090240, 3970071218688010847, 17419166239676042564, - 400453640980208069, 15220637399286523210, 17321057148174216619, 14860227640908306879, 8047994708253288483, 10174040071518845057, 3280567772472213687, 5651529697807929627, - 13988854693674964723, 10817154032069031941, 3171651998645961547, 5518712225783687705, 14706905091132091970, 13960758460934966876, 12141035142079693145, 3149939820435101269, - 17047631647660916802, 11327141967045825261, 6773994317182166280, 5064726840218426586, 11921340002806613391, 9067034595359929709, 16499225867422892436, 9333282251383805811, - 16851791401266483516, 3629537449474963381, 9616439067014312078, 17691280261538133313, 13915291913519800282, 4229243823856128517, 5998682815524220834, 18293451622818510596, - 13740317056016164038, 15410121987858832401, 12080671504470100936, 11635316325777860129, 2584464163154495637, 9849046399519426256, 7991103215010751716, 2109987257001640948, - 2505301881938098126, 9962323478923652140, 9312199523950444342, 12957822502673689705, 8060810607849163143, 737408553843844193, 8143568733429881786, 18003168270780769476, - 18361695650419575705, 15964191128341330249, 14834821085064012697, 12512940671502931238, 11592194993753547188, 14358438239394059598, 2876909840522954216, 13154864917311376528, - 1919485747906370662, 5250174270363591951, 6270889482486194520, 726576673961648732, 5067680336545953003, 3152041783219682891, 15674051618916413369, 12438966377512424334, - 7755405178378312585, 2001220826274540277, 13276328134279740680, 5464764824709243977, 5374818714652367118, 7988129049563289676, 13996688354532099099, 14091540329663446637, - 4460927228453411137, 16058422703785787527, 8016770980039986075, 11450941100964860520, 2742597710491507274, 16940752978671801273, 5897441526901650840, 5926672707007682446, - 11513132526446047688, 2371334524276946445, 2461552185903242316, 2195417192784351355, 8821293936856062699, 17392142102281287994, 4066797133115509650, 10704373174879556404, - 15778536817306082589, 5755579035239870289, 2105368957367433938, 16043807797277162048, 14990960263520315004, 15618512283659189876, 1020703273079622517, 9735594589053383212, - 11529096471626785524, 13217557548494128192, 6973227637542883184, 17901194406865837244, 2414269359614891938, 9165268075797348071, 1013041849562373861, 17525420894350269712, - 5772778048593061508, 15424756817708323928, 11842041259277183807, 17669952685051160523, 5405007811515938363, 4415223809135251038, 2223192286456742546, 15742105795795272774, - 2844957165101842208, 5188198001787563362, 17071130520794983821, 6691797472842348899, 4294126956896299534, 5788827614077663481, 16267876196920424765, 10795461545625002360, - 4405006158507706423, 8343317561528812223, 7851955346465616798, 14568481075913348758, 4391527082463073614, 13997921112025001396, 15259963045788570485, 6787776208020191083, - 4002627348223514978, 16231148554725644698, 9578235186329928114, 14741034641204805809, 14651073646349829984, 1797163177099497214, 982043220105120238, 9027434646723092211, - 11809342655313500273, 16822704101813284237, 13097372075606737923, 5463281428453250615, 11967866991673525562, 6828790575157689223, 12568831962097805646, 8385980093725157349, - }, - { - 9246769514475702626, 5788284997389507365, 15857897362850327403, 13864676801095094218, 12881526722328523267, 2620841421323221200, 12599981775316397124, 12820989846844560040, - 13066648645100247757, 16727492115601921665, 15749471761440498106, 937594351871983779, 8381111811209734349, 10884357918725639691, 781591570669492079, 12778743765298428266, - 1797915488494232282, 17274756142259274463, 14207994319179101777, 9405903752538915237, 9001743317941152797, 15048752608061590843, 4925745663463425863, 17143694017177138485, - 11613437975225156304, 8619196433402562266, 11907033287998837424, 5056904365610561965, 7637552956459333558, 2827449950719061527, 9998507085256853501, 9238562885525900325, - 13246436769495027717, 5445015753017977819, 16266739009580878036, 15566606095998238977, 12196078605380432771, 4854324313875295137, 10974170498288217052, 6425550765546527417, - 14574824159194628650, 16992289415800830701, 3499062703303067574, 11220872042664151226, 18135860701984580530, 13630928571014923388, 2913126838766947469, 15869180955632349704, - 10621010745328025245, 14637275395423748577, 12928463178963493980, 3270672471462681194, 11765440832075775157, 8138439106739837848, 10004644076263261924, 12582897670868871780, - 9605391611675301152, 14014632424042523224, 4638465078692570733, 3013469722048440965, 10972600060210514686, 4497572559400894366, 2652629676209366276, 15827846806499715082, - 216774559418075105, 7056732230404238374, 4342481467357759950, 16143194646968227790, 12304857685680249595, 5021239809847286634, 745754913624924064, 1603290801266214539, - 2784418922013631805, 3554650219010546629, 8896448905401216908, 13445015286698819482, 6508982623352460996, 3322529327934132311, 18417788670080975365, 17554108945303789353, - 17620122226715347133, 9738429733440215024, 15577771434516492888, 12422193389576942718, 18383756008252443605, 12736926759685644351, 16981429110294392086, 11999528928951986433, - 14489177617081844909, 15995916840320959685, 6361381313838994395, 11146176143708648759, 17190512001934479207, 8406914945663974955, 18073221191428103088, 14075266763636071788, - 11493260321718935244, 7134447477334726345, 10489281872281557152, 6145540581503915475, 4002857892747271740, 5167943945955725680, 2892864850826359384, 16887114279977647596, - 16493058314197913501, 14642843949567816202, 8421201635021034279, 3645913604138483317, 6127272877310948153, 3660286308390076870, 14343325047340052700, 5355450922054278073, - 8426383571761073988, 17627146217941553397, 7396223609641674418, 2402241526082789613, 4067059813672963823, 10306840429023537942, 18342506396531908477, 7249869764848707701, - 17055119974261943875, 6266720893662254540, 13102139953381148874, 5249314164321788611, 7157525732140787612, 15381277459195914226, 17265025258266710353, 17573500432599548120, - 11703325491493519624, 6756922948215553472, 10849241105791329449, 4442124988071574400, 13193138084274485850, 11408181130174894537, 16602978650637017500, 4282478513876287613, - 15849352004835856215, 7022332658299393045, 2753527422472509447, 2508636546397160815, 18156018186852519542, 13445036260276495365, 6279372959444826452, 4487789154840943220, - 6912674041294744283, 18177825269025993506, 2129493844567951509, 6833453501368177831, 1878514166200306112, 12873954541639117785, 7984716702294892278, 1590286870058148425, - 13310953099825480439, 942949035351116482, 7073926138905956784, 7700580694019269362, 3135382872993338421, 14860196563555722941, 10662854588851556233, 5736680857908686906, - 3285730769783013255, 5648284582450022694, 16712547815126338303, 16508335566005209527, 12272617736405465053, 6690178916455692547, 3481505327914964440, 9148348679521508925, - 5445751308732564169, 15671537507319596886, 17721221564106627243, 379590599139121791, 11923849517192812255, 11794879354344258105, 4802202540817083733, 9502952511912834734, - 10387170863530151921, 5325952605083195756, 9255511257002170523, 413412942592261158, 2693041233704004652, 14135620291598275670, 11595337134421837671, 1965085859594934829, - 10567751951694288416, 10466024270444644770, 17138727632883910786, 12652567654757797118, 13864111438265559205, 2552332838857882141, 3739570066357761968, 1439381288436968019, - 14926469836092482784, 1974273958550553776, 10770915481273902280, 4033929759715842024, 15461883773070197251, 5631323369668498153, 13319268013678629907, 16483196656661792008, - 5825598074470439590, 15514383036808278765, 836600073173284669, 17006029483641514808, 2253041172677940136, 10109282146738215012, 2050330973627959134, 13783991480192211446, - 7361422649689322835, 16012782899552425604, 10324124765039044621, 12319908523309013390, 17065808121376215422, 14844145564675640794, 2754581529304803758, 1149534055082731343, - 5371192675994106473, 15892724499541682278, 3862864290653799361, 15759456296270265029, 12018492462347307225, 11503979417352537931, 1894695486127847219, 15184833349947874986, - 14711143160318482298, 15515618319260581947, 10015362293284733112, 1169298538214120845, 14481541537099551545, 10304547737174682912, 9351439436434829996, 15807708290724844107, - 16946643895530263911, 6110142153011856496, 6857516759047242219, 2026267735072107620, 10338469980804248611, 8224240981205716101, 12739986350836865860, 6828408496869642385, - 18199296108774357398, 10154672256889745380, 1190269705881674139, 2317654455984851716, 6948704988682993246, 7864433505284017226, 12371653445644439372, 16432795124971446509, - 940679263188661008, 14653357165718140350, 15439920797347843673, 9415587255510557494, 18115037054677722678, 8165849408798239027, 17369387099667572407, 17619066457126678815, - }, - { - 11047138821675365077, 8918121441180891972, 26692501222219426, 15248413052700323978, 7305399157133896461, 7065644238942265367, 3949166834387057064, 14178248206708015607, - 69860179712677448, 15464996655458230480, 15095351218136595554, 3792171085643513009, 3187131848664503636, 12713332789590787064, 6278731049699775392, 1597379696359884724, - 3952205381894147962, 11371446109407143937, 7231851263356642380, 11612512368538303138, 5227214975837085115, 10737565048439707166, 6333629542995218640, 12386725921557807638, - 3631886121917081375, 14286411187847401959, 1546298555066841633, 4790996540037176549, 9541492152219486842, 12304868498960755609, 11426775785781090329, 10793898029125361155, - 16970032026045908366, 4739834790205788500, 11604777595337607879, 7222013010088766249, 5472916641327283117, 4172262758310864960, 5724466588558015820, 1116300519629843659, - 15795014995613238211, 14290583239597353888, 2490895887909073495, 11130992987297321872, 17554999787604367088, 3420129662095546057, 11472786435923282727, 16869713476687852227, - 15035061229930585935, 453017670704522761, 13269498238801130975, 9381945743239523058, 2560842189862328725, 6461599464735341542, 12067824007347016987, 254830492191366350, - 10932352970046201499, 5875690226460998551, 3699681560657289718, 8665743594825198441, 10232089728487302472, 15664572298733091969, 7267222702489958195, 10552093353886118696, - 15492342672675114391, 415437554733257587, 12890781990283079094, 13204935186176658494, 16394061615709463286, 5115734945762570776, 10421418042968619739, 5523853293632283162, - 11813086056645720947, 8830149648607040713, 12579056778157665738, 8379445845509747387, 11968812374998926933, 7579079245215672446, 18392522237039663466, 14209436550919930092, - 10567400467353853420, 12039111362360014956, 9752698954159464580, 974455144078370581, 16749750902684349652, 7431880327875076520, 16572811640260132367, 197121614392940749, - 4008236965647744142, 8547116629188387980, 13874587567755370880, 12696453513706541959, 10752386832421030566, 365775083075323708, 14295272684753058141, 11024897725724291722, - 9389823976782902582, 12987864137510618346, 14351996708263571593, 9397276818616280108, 8943695845699072910, 16761881794918812428, 14395546039428720745, 9608138420173912436, - 1876375509629583057, 3290820252719995988, 488255726920613097, 12524692306565281959, 1588481057230489293, 2737168321842385117, 3787136521155591587, 2297952115270241626, - 14002797112021507101, 15941913959379016886, 13373428680779564378, 905956693320605119, 14911807685762669378, 13046351903511292109, 5010776430112230246, 13569296078340893444, - 2399232949134869057, 16408469118941953277, 17229778225562184411, 15990256768949242309, 10694906341686584836, 2816242351659628719, 10794163145486835660, 15601904974333104002, - 11025280186920123511, 2638544612389113264, 14138782464677956897, 8182901095979048555, 11304014986311338849, 5418181013691186545, 4702887342992202530, 10901371551431733592, - 7470028071605003558, 15552389775050890646, 8285175978626575302, 11755261053723122966, 10951094485216236078, 5507384267235142469, 13239757172982680465, 16153920989213321821, - 18058993449364903238, 13898361855323379776, 4830208064835445821, 2108287244297002782, 403367259355957679, 5208097191763320114, 5105753392567780820, 6874403921011777407, - 1158521281204350113, 6232098057848694897, 12517518152351190341, 17852831094628421272, 11653774695260269881, 4420518556213490728, 13835371272800239099, 12119809446886544909, - 13202632776652821767, 12444449950521044637, 11128589812117041029, 13640351754206364654, 12210309609173025143, 2998033188714623978, 2790558847086549679, 1412882974937756344, - 8872627396983903111, 13010748252899511409, 9503554222158928531, 17266043773425260257, 14299273669130129568, 8206060595465248374, 2391269797717981426, 11490348680137544215, - 5625434013536513462, 11006046905736534335, 12974260386406529669, 9092861657954444193, 9064784322822166467, 388172762639483312, 7975459140038679785, 16519143691087724914, - 5143546864201185527, 6400878864024957342, 15513803558106064076, 6712861984922181478, 15623960351786428150, 3094277713920675576, 6184647748693682810, 7857605928718754519, - 17306606255667524897, 5112741148301782470, 12807238528895999857, 15137864759480529337, 14604908573844046691, 17945466774813936069, 8840495514948749443, 11197321446299638637, - 17220811598578674405, 4438480777123093236, 3563461541688367236, 3111403934731489046, 16319666149508644048, 11775149819643332554, 6467838040542164752, 1567553021477840718, - 5384669083154912160, 17619132083131362037, 8938889855576647487, 9107335704092137106, 10077424566800668390, 15550874273916351174, 15171215175982142697, 15277375103802490853, - 2219152199405421709, 5367881810186787185, 9606063680551349934, 18233690822105957780, 9941441403610160291, 14996958158691873775, 4936282940888570414, 16608409936766385729, - 3344228690528365773, 14741103791830625697, 12105806333035047780, 4814603778329751458, 15692542571489717296, 4074467482166609769, 11583878004635312071, 15057041878895842153, - 12046059187840675577, 1106267261822046486, 4800396230944794513, 6983782857932290361, 12630891077786998995, 18331269049237387531, 8843236455524152484, 8233277245902259517, - 4072376012468301087, 15956856707868364136, 6651399164294705117, 9169559249495366525, 8774931051408681195, 7328702764302633441, 3821510551720221090, 13559321821383641691, - 13270099407878039596, 11569032926557804346, 7759575992876193458, 8239088820951102451, 9633607727685959064, 9775909232917811341, 12297921731498614906, 14756100221590046549, - }, - { - 5228416958727036186, 12534300056259911378, 6859045937063682340, 16561718753727911412, 9427589074776024847, 4167904055656501509, 10156691045253563236, 17557096561606923049, - 12847261474293104380, 15935635664155479706, 11956861064550631146, 11743590506948225647, 15973092866215748716, 8269726904881958353, 15639962392523441528, 15171417818360069012, - 2605212343977737441, 18393471024186189813, 2302707671753008158, 8606549841034095192, 3842822953634987820, 3094721493917442423, 6408313759447502937, 13486364200254727287, - 2191808101092881088, 128992526124656216, 738676021426139131, 10157323147642681558, 11221959943853120586, 18255489816550713347, 10885231659068427649, 12104397395119665023, - 7707807226411417919, 16609863548699265350, 17639371636697428128, 8755472387723764172, 164779854477783265, 9714199241756765614, 3491355372893948450, 17683742455036967163, - 13595758632462338296, 14515163666150177917, 6720823780841221770, 15071435664343609336, 9016075014492765983, 16881277609836316886, 6969993988115170067, 15419704786434737070, - 14933348768149415725, 8499210770493553168, 6778840616148281272, 13282837866452012488, 12007326272174861053, 11172739862019218274, 15202495365302649711, 8797477675597086120, - 17862558746132168231, 4941846130090682869, 17131557654945008226, 5312800819142473968, 5818269467205924209, 13458582047859447022, 2683428091382447153, 12956887954464730664, - 11820752998821943867, 5623379642132478491, 11666807493120740820, 7241997274572162616, 17165010508995490690, 1769225877906480182, 3814296306467163522, 1913823003062817434, - 11936813336110488997, 3878433838529606580, 6540053284493149566, 10610279324743393563, 14079852809920102066, 9176732841330794388, 14287311909822853963, 7146204303626670196, - 1222343790928490335, 2199405396044383670, 14080919887213592148, 7341303626667347624, 11784881532696657518, 17307742911086150556, 6036132721599132043, 12167106497065306941, - 13817073203406999359, 7220729284169210756, 14908407498603601482, 13536224989620701632, 1615171540711527931, 2063856048260214664, 10622581435417474559, 16378505765730768032, - 6855676470217754770, 9517149712286624325, 11080380031068971680, 667425509348698033, 6136243307299269825, 5326577850303193160, 16120190278345757447, 1982981965726975383, - 15399454106099176868, 3988744407816581672, 3596277710300384050, 15129113714633923498, 1554582462382333698, 3164553872715651710, 12729140363982748426, 16366728035709811784, - 11647936211409428873, 14704462653811533865, 10005129575282387925, 1526194796943187368, 10906326807488904308, 18256878690674435807, 13093574545395154003, 12352810226542367406, - 15290817014272444879, 8012864091692295774, 7591940515496590516, 9299619125326026848, 7297256232167521068, 17861204372399797627, 3100022958796565106, 15313770879200204613, - 10190931844127971311, 4449277895844944513, 18060903840299422620, 5786504870079014862, 13877878835839147302, 17536010013969819055, 12266576574650233794, 3344384108564085445, - 10406231172694378191, 12785551100938284935, 12210880209800471137, 16615829503150405150, 11718424737227538631, 2245674303359461903, 9283401225508960391, 7699506693893764319, - 2278745583218618906, 10638058115573097116, 5685140621618740987, 7758115175926730915, 9043786871908073988, 11442680114439652875, 15805407285446479015, 17615595308217319903, - 17127838629068819444, 14692086977823146619, 2491742894643214379, 3238012827598604955, 4066194902402629617, 3613111175737094005, 3296022969960608152, 4860674720288543209, - 3753308721541654311, 13160824061458819791, 11298768140351857216, 14042645015841972579, 10518697187157549363, 9641851844202952198, 9254393371864075771, 11429987449073904258, - 2566815986599406395, 7824829323439900657, 14465315986665451243, 2957504741164666523, 2280672126115151165, 14999624386740200468, 6090063205272921919, 3478652904863279960, - 18131467168461028363, 16471039226156513736, 14133684792391617163, 7137732710914086892, 17299189471163637576, 17270681183882183871, 9046519354210103502, 16091721986926209161, - 6572875037492082093, 18318192911446580882, 18107990043035854610, 13573958681720538720, 2821064027974708708, 13000417359062035623, 18286430707379660800, 13070676610179458046, - 8521670721910745896, 7440450230382417926, 13794050882540606099, 3657777690979179248, 15466400576048586018, 7802926536345945651, 11932698778931413693, 4291944108972289013, - 16729016738422946915, 4082443597391481873, 2238453914102498318, 1806710580451019071, 18305396377745213463, 2262209146853870557, 17240603302299977012, 1540474707615687112, - 16013022710115947086, 8748688582020024424, 10921431579160628425, 2228053349060750948, 7024441100951863599, 15816203310189470753, 9078141084316010447, 9841344410499582933, - 13377311905703150010, 6352753896568161822, 11086576920416079356, 7629848369702522073, 5472036379742160857, 6535781794177956975, 7671272114437903042, 5056286897725243410, - 14579350500102276494, 5882738271691348624, 7188200631561491668, 3605286077046581049, 8957701412704914688, 10347270272487533128, 5995825272041784807, 18321189862831103872, - 2376178340116743056, 2263593380938083722, 1990228394694589285, 13477447633165073333, 9023956677421314778, 7820910817739139038, 5288765314200405868, 13070699273589738968, - 6765952613794178887, 347733275422001747, 7640026333627494061, 12925707101320796635, 5670472934143686904, 15041817307271371058, 18176041895529109656, 6838891343875575060, - 9902363248877274636, 15776195244792726061, 1935342462634574355, 16572507349421626602, 7503944294807242065, 7454248748618678609, 2837392985175901475, 16494567631149775512, - }, - { - 12299242278498309265, 117303082144788574, 18382936515565701803, 7941141688858846015, 14923823358299367958, 15681089039073030752, 16878721085421212785, 3933697483394042011, - 2878536922988449879, 8819365314325664735, 2696760638950720974, 11357179421800829605, 14730809809256560583, 16277258726425730599, 13189689275745970592, 13769784951430309444, - 10292669945637125918, 13595563061674492799, 18301330068714272653, 16981073598172019270, 4022713583718555211, 847970754090163894, 12867993617169467387, 10021141621864633865, - 15254713655124736464, 6283719686609422435, 5417864180357938798, 14010638809605797246, 10873690600705871523, 15014239467130590294, 15765460219545280655, 6048061577845125750, - 13465802402879986040, 12777495579796377113, 11251142258511736751, 8312965145580158560, 223338793373356823, 813747086573652373, 534790745256052224, 3658554932030960904, - 223170064814687698, 12938716002978051117, 3848816111228150666, 17463649319617382466, 12886402189488467296, 9605942357133455486, 12272689261734151433, 9916808458308982839, - 2879267873712146919, 1770061136847768757, 3497337219301780129, 17065005588401306579, 7675751531915094916, 4337540836976665798, 12505868586426061855, 16929961945120117126, - 12012729503226546642, 4811951115754240681, 2652621264600062520, 1108958391967017223, 2508980100759035797, 9023233544151778447, 11183557587641545146, 10726727280840759519, - 7189877122763725514, 14656082750550993666, 13508306914749420120, 4564443784575285318, 15450566991657647015, 14019683331552104148, 7751003035652012225, 960642801291306739, - 4621870789074053275, 2699296606556701282, 17510056683561737074, 14554735156054608866, 9556940770704438829, 10801168482998872433, 2280142648958056556, 4982572404720159279, - 14621729774738200671, 16850208728798178903, 2650832773786164628, 8325244333065591089, 17692120343646193143, 2242845836784335580, 9386711085286369304, 517979059098779699, - 396296174223428093, 16763788748988621834, 10606803701784640909, 2399987183687936561, 3641562114746393614, 8536687357022564742, 14532545286961725758, 14658331097531946901, - 13237433907493396869, 4990918623816750268, 17673032790739307275, 15907935024302716062, 8613470231259845273, 9346326052910147032, 17747177708802561938, 4490130127498754807, - 13867405496809412712, 7002613759387491643, 13033935552806967378, 67437088702121131, 1528641041740753990, 7001198041125832592, 6102137699349551632, 11527483925092226802, - 5535652777947676324, 1216916140919282417, 343617165825197489, 10806931059627863289, 3212291315152120591, 3351900116486367965, 8595828725191802110, 15621077401736893558, - 2386026063595321071, 9144724461940169335, 13121187420621518554, 17351696676224980491, 143495028693925520, 4590642171152119027, 8655406817079059692, 10005507077955932112, - 6982427644490593208, 5211219672384700779, 14348546115682624722, 5876199850746516331, 18396840586595761484, 1465795856184232635, 9374516147960853174, 11803025633575966436, - 16374709377982692229, 2545295070586009694, 17366393861359867323, 18067336234259281315, 9181658491221440805, 16188192004088261717, 13669686513572099673, 2044092029751770484, - 7308293641399229883, 9813539775451467496, 4837144575100457648, 14073521030008335794, 12371724228966966456, 9185074727660313894, 7387427551441329556, 1866580457929037678, - 2047964090310465728, 14133690277069748515, 8287749071957055844, 16821270580974431218, 10324684883587585565, 9652498187344172497, 2461802306013063247, 15048850312040680643, - 9659170831875656345, 4251587871822599596, 12391279033133774782, 7346556824831912968, 2133114137534468833, 8694105814921565301, 1000087733076615381, 3478818915231998954, - 15832320183998834886, 898251865651859288, 16874504161383651033, 18425166917936355349, 13387271833996394553, 808054572728974308, 2281828182196149100, 14620221246129351423, - 2755242181069093228, 16155597320469161129, 17375128328249992589, 13376690667170223367, 12825454052191060221, 13625129606409283552, 5627148592782580041, 3092789333954796605, - 105705035058376953, 7541598459498134635, 6627685529861836787, 5724525771392188178, 13865897118300842617, 627652561624109853, 167084371112939132, 14192831153344015422, - 15618434900514973465, 14267977447705810206, 8823759714826430108, 7918740515193061263, 1664424041430494212, 9076733744947861202, 12010737794701759719, 13920688631446302868, - 14823160144680924028, 15690572793903331709, 1101762466949115887, 19462496059060771, 6099422315003219574, 4300077459158116870, 1282001407902323746, 5792772971400374848, - 11488321122368726901, 14632273370344181937, 12984850848826263218, 1857014998357880446, 13897135914532207935, 15925630222053677390, 11992050787349110965, 10072349923584966035, - 12837696619944805389, 13470316523008526719, 3074966674353053986, 2630814767089382743, 13353767941686870870, 11405513520090968568, 3071969598389884693, 8212421686942839224, - 7866179127856055582, 11874624506147226333, 5793384221044709375, 4411967221310302622, 3004913667339358722, 12230878672003882045, 7395980261120250376, 5188846147165419817, - 16160221386626609076, 2876994290210606255, 6065036384672004173, 14696333348949573335, 2667009584785381424, 12100192661844794919, 12401945669155059163, 12847772853650923808, - 2286437117905535902, 3130250324287833414, 3662253455746154641, 13229041365675585947, 3663813013822489770, 3093300797589723687, 11507645566517710232, 3715061633580408995, - 3464453985305889088, 7486900500389940957, 8944303108517222303, 18319933556403836918, 6782476025105836770, 12822840946923377510, 2799592944286097404, 8737598030273298051, - }, - { - 2754563581284692865, 11257360722362829387, 8254261291934606879, 10023569920325096229, 7980898855627864603, 17162063449612285703, 9275759455936104363, 15936804738099638644, - 303387668469489035, 7978391052264888020, 15413722057350324494, 508608987485166058, 5585753287556892522, 1344134516582665443, 15144279405777509214, 17014353449841567149, - 12518577022215294774, 11347384788122950558, 17122718824958020364, 5431993665805279177, 1445831254446028321, 9845654210244803480, 18315778529692612284, 930563922336183289, - 4894710987714215219, 15704993603878996107, 1606204036324478223, 14308635149530198932, 5026736228773269251, 2911689442372084137, 9004077539360196849, 7770049130277452000, - 2745120518194234905, 17255944807561408883, 7371907591838942770, 11781525288383871227, 7814952754785494862, 15022715213812536212, 4112388658963418656, 13703771908397991335, - 17455440140812341569, 16738670164475421762, 13259904130186215994, 2168106064304872507, 1969289843772256992, 9025317999701057831, 5835661391798891929, 3826587698101558069, - 9149648374608464235, 7248346993716635643, 17283919168525322365, 10107681064815728795, 12176813938029507719, 15110337574289033068, 2436453685316043712, 5876967059744625564, - 6197919059881189313, 3300993078638782623, 9357667752372201437, 17688129755135009447, 5477090746558113696, 12602024521188880300, 15889961935507293355, 7135039746373941272, - 12561063426893244305, 3079971284510744316, 15695857190375815873, 16730673956207425338, 12065477821845465116, 13846158368121919228, 2126156187526559500, 3005167441915916768, - 3858987859895327040, 17043903959888117395, 5861237635520080595, 3292646198413575902, 14286644557048422360, 14346409530388980974, 12583555046601155161, 4665981927428063991, - 7657686120974201842, 2388299767028319466, 17934808017791217639, 16708640707026372313, 14122341266134976486, 9547124998857374491, 11194069918436025923, 14657538980930727877, - 18115789712912297420, 6543740714573413570, 1955886376702349613, 14736853369719086334, 3914330395250768396, 7607848156418885173, 18220633528980056514, 11930952850158858930, - 17010681753474701341, 6961088634819162945, 18395881317121515295, 11611411242007267179, 7996717433149311639, 2687736005475404867, 15340214362731923149, 7116441414289074727, - 14302198697220662403, 11915041511943922518, 12363437164440173650, 4047410026894059083, 11439743031696133447, 8776097395071907030, 6851061783357383945, 16484733576581941012, - 2861660066704264713, 16453202148771053225, 10039035813504063627, 6275446616881871868, 7150609984920482782, 11100941755544354363, 6219760433202580646, 2875377482232912143, - 16477698187919702699, 2757160833848759781, 5976267476122243443, 7375951277779829055, 6525111513935493528, 9969722922172879681, 12582700753056539952, 3861958159147836631, - 4207324524057007052, 13478421263392765917, 13318275642734768006, 8504333045658265535, 3960720256367501697, 1601661680373853468, 7704205542213854353, 1552780884856863914, - 11788483659211580527, 8739274750400900816, 17562450707643849072, 2113004873311762141, 8542099133996522813, 5273956141012313478, 15661081976505113338, 2290009483289921559, - 7730337285529332076, 910421998453976119, 1242962796308775978, 15931313183507922513, 296811920445331257, 5821874870466240960, 3843405649348506130, 9007082448812181532, - 7200777231000974420, 15816416455380831370, 12932038056359512011, 16422801186386616731, 489979647738684819, 8269568123908387407, 11617965045895762979, 10069799398667455631, - 8245819835927284113, 5237630684564909794, 16572245571184457585, 13396211619915630497, 9177789877937729597, 7598297211302983411, 3133511073496333246, 16553020037702090576, - 13441991323065749602, 15441570013111011986, 291172418860690999, 765089869758770890, 15943751395897588683, 1887511823199710563, 15452188663399676440, 15028027691170546376, - 11009923302693800320, 5465227554242327455, 6511134004216481185, 2187999546010819375, 8387421071023131689, 174295266381833460, 6010935117399493668, 3340537243300033200, - 270646782953286316, 6635640130829923909, 12717598479778596267, 3198506535831522029, 2605714695474737827, 14548588937126505914, 10448279824323025574, 16008560590494788290, - 11460241048816176102, 6557818897531989327, 6948658872009630691, 12506263743501199667, 1813031030961999507, 18320107449706503757, 16783076453582799039, 10113937529079967843, - 3096618551325580575, 16427990761832670936, 11792441105446619028, 682188988823121368, 15606025696371121549, 15395362449248397023, 10158149307437310549, 4442375503593769727, - 5486499432056098253, 3811951715772590831, 3856863699598204250, 559724736042732093, 13251752681229681959, 3173330346541355882, 3597530263899943500, 11567248716558420280, - 12822024566847931229, 14487146762942136806, 1361688279016339671, 2776885758026394514, 13616222293131162973, 4629388276054227930, 8304132204812769256, 15188275451670510949, - 3676452641243730693, 10839008248003066479, 7676518604603740317, 18384275325050378660, 7827069556104560937, 14335741841451672783, 1145975213382205474, 13691620069378415495, - 2513451633312793643, 17331457978938147928, 11588204658848186728, 8824497684232939293, 5956154520546906549, 14434958079241686709, 11798870987920360447, 5875117843056165993, - 11313908033360767461, 14678575871510948417, 8479250768537158849, 13854183783158898926, 9413525381201650053, 10077438283140087199, 11413783222317729281, 4418417663988371635, - 6001837395299394988, 7545846298204709215, 6662102781970969966, 12696054550672669874, 7436995610194789060, 9042605089262227561, 11621508125069628605, 7289479057360149973, - }, - { - 15555649500689005370, 7857014165815014600, 4664069234996337119, 8058230521837307501, 18090421626009183450, 9278179697462444898, 17138879353097908770, 18285223269807746171, - 12741225973381753432, 5461579923265799106, 4348015554411389960, 14970536173310927872, 11568371199139699619, 11748662751675667230, 15495664823061891700, 670495577617908409, - 9865772269601493999, 7325690007062740244, 18437964667185475354, 9546360111100619473, 6266116854923135821, 295905071295541234, 16037468634731642095, 16602609756229843150, - 13266892287530449189, 2232961926857263527, 5934654989155432442, 5415975493246016158, 17117784386882463158, 3875398271691758986, 15755743581177209843, 11380746535012415659, - 2047267291755864302, 5637045342080349843, 15779859211873634959, 2415175423642772217, 8664113127182901077, 3032959071705433205, 4250761979529656864, 8729259992491925346, - 16559648310139278090, 4796731467175572814, 9267555165184254828, 1400425639375650333, 5199035239208036114, 7994153995816640929, 15677746297407711038, 16338895562326287438, - 1740700879164022194, 8442598604870387302, 14969965175291161450, 3086786406508018865, 12097766404705693713, 3199218739761578935, 1744290654371906763, 3672816528005113908, - 10162459499000477259, 7534168794800651527, 6320985751131807192, 9263840233901040421, 12178625283764017250, 13143797113231152006, 13089053551699608219, 13480464010111258056, - 6572275813002629593, 15328678880838895837, 4281489161088939969, 17996597009627631572, 10405019085582914256, 4773602940383417103, 1455403777441353089, 14766164051850429812, - 3886207141264898075, 4215113531127552656, 14283840761174092490, 11161507022796293343, 11235510295695006534, 2260082644337974884, 3781681413610409735, 5577127823856153222, - 15609337727165147542, 5725010295752332028, 10091444858515990726, 16162855978360002823, 2478705273652882251, 11394669968372227148, 512641267828429208, 581410050368207889, - 11426681347395118622, 17135867298562042628, 10870734720453621112, 13803364322975322217, 9740527283062276630, 13765238480893165263, 4792349632705804116, 18359029140065847048, - 15215482935039834459, 3553551735757600990, 2471323651039083728, 11355669733892999598, 15830640053604899661, 1625382463038435804, 11969247519895019474, 14372668755409420943, - 11113773299077372683, 16618589175113863833, 12580653821785550146, 8264195478884998326, 13569468260761711850, 16539804400793525042, 14464540796871846551, 7710175783216723569, - 17565888320840294282, 12018783137972195797, 12159604578082686310, 3210316551614996638, 7700243787046971168, 8307491254792612954, 18022719331150542511, 15890872243361196004, - 1420251412241033168, 6449255753238336368, 7468624722117319576, 5716072259994197219, 8165015263320602150, 4757529151848960259, 2040364517493350115, 11069642333484542749, - 6861520668253090597, 14998859189233167760, 4851545815068976365, 594940747993801912, 8473464707442482665, 2316305389548210767, 3995416902578245152, 15770229481630179441, - 7316766449463697051, 1410976281384361962, 2878678490331118371, 17638505404208445694, 1130528985192221086, 7544558337870473835, 12071909234624857373, 436426448500115731, - 17436263074416557505, 4339627812592344328, 1076653379358004720, 4996950998108333398, 8528954985898069924, 8259369611572362613, 7869239207308554342, 3592003501289265534, - 9434687670958330812, 4808705744496679962, 13910334628239183613, 2628594509406050235, 10055911465166862298, 8069256921143792190, 11886968715847498191, 6351594160398684406, - 9865961381837093259, 9590584894285774485, 10674927452501376239, 13861388033657872936, 808108663597281834, 16581187679405825998, 490312642991375167, 11352102610468872412, - 12888468148530619065, 542846015600866106, 2086677842713697080, 2758534484095407635, 15767123419143795297, 7077908316515201321, 10297306681753168866, 4641656730233236179, - 104445550853777927, 3829969899624802332, 4713997522991885393, 677661257782477991, 12383280183673921457, 4373178143111769979, 6375181113677777933, 18335077047046332699, - 5472832021993175857, 6120966193470238758, 13156950075464061259, 14833372202848630444, 5760885723102571027, 18022572190906170343, 9870918995920897221, 9546055667466056471, - 9516299398994303577, 11139435630263588724, 7364473923787049608, 15378275072059759415, 7378721410182635028, 2461490895435109307, 2579531356642691202, 11061693189962996686, - 17380308085259417126, 12584808641030185141, 15485460243194852460, 16172215807782473427, 690761937231979275, 17570908286361380250, 3347059970688467328, 10404397759606846636, - 1302709369035452282, 7149637102192386111, 11659118804203241786, 13909758997057192683, 4361167997834561257, 2300569874961985919, 1609719848856066643, 9866395233709297503, - 17124591880405051324, 3379747334483646957, 2084957978131092947, 2413497199486596627, 2867893699156486423, 1357836849049583382, 13607307985344221035, 18039194570940763745, - 831259058391834318, 12782538711785697535, 12640197944141330321, 11004378265133697847, 13622812183191119169, 5878590957416415562, 4810392157669422629, 11128662835376944411, - 2248775486830407244, 1550340755758127506, 8399436463450785695, 11063895076440303538, 2168511054719571959, 12238498894267955838, 10824266376477587807, 1073243669335517712, - 13568560319245254019, 17615770913976878569, 13214159705850440913, 7542574047209989510, 7392331519546111377, 2685908847786414772, 14835825677444128105, 11347648758435372538, - 13230815692170010235, 10662664037814374845, 10120384214921531334, 8892863196093018212, 4443096401408136417, 1896901619181196514, 739574867683694091, 11233952771600927581, - }, - { - 10708602749843635238, 8046488591192123621, 11391158257016334553, 2512908912806916201, 14760224624269838038, 2631910198880826809, 2387247811669872033, 2048193899742148806, - 17392983665205025720, 12603331233691760840, 3752711326309791976, 8281544857330094164, 17004651346561270106, 10399322540256775923, 9721299450284863176, 3725182263994944884, - 13643198694788276032, 8127425924819487897, 14165945065582850538, 16520977003164405917, 1941948502806705647, 12390949208067741787, 17112117376594486408, 10232906951259490042, - 74190110112564319, 11227229657066745164, 10151080599595091944, 16591051376074591375, 8256332495682655293, 7127985739945537626, 5708687346183367016, 18310921046455023281, - 10040565835468209502, 3986586816478505371, 7957179672896506016, 13347112914739722590, 14099734293320932556, 13921950344400895005, 17478414833301838037, 961445463330402797, - 10553899634420153414, 4215979268474142438, 3643081140297634139, 11620906704125380460, 17733628678553828301, 137473878710304143, 6211837577294956591, 13926110616399428016, - 15203257341351417031, 11597829209697937782, 17317571979811895272, 15929491640570317745, 5731227916276913121, 17093153916149088230, 3908757069480556294, 18211818355208735794, - 6887629766078662088, 15330755394432598442, 14144608177273202986, 13258654996547018856, 8975611270007504091, 16869834856279102361, 12707970875852047823, 8520055680055874514, - 1643407997152867899, 5400650551136488814, 14663391437159245064, 4743209938058826866, 1728998201888511561, 11238331920657195520, 11617984741897247805, 13858029141809651878, - 14003691155137683825, 14641672309228817657, 4031783205073356111, 7414359968614421153, 8166814052414482491, 5209260157266028169, 17555696996149558694, 9780166780476833956, - 16029688335186691281, 4244772808651443261, 6450459413414527821, 695875191412722741, 11104054226249884864, 146461617619843327, 17480214580411209436, 11285418463967817315, - 4922928863857449168, 7226901725606965824, 7568276305032368752, 6253457805758596797, 14345040877576203078, 1718759302498746946, 3544444746772280646, 17880302727399449566, - 10693864548794383214, 736148233485985101, 5241869061152863453, 7166954323782542739, 16861482585847848251, 11483636939866570861, 5950529069765100144, 700887039653157350, - 3906969739692830848, 5546431121705298614, 10491799900914853406, 5871175286230239238, 2851574662174517162, 5511397532379144624, 17409985391224790540, 319012646822749823, - 15269778527761027251, 16471737837294177924, 8830398856035267114, 8206807757132984992, 1421214226977370752, 14233751335943482739, 9668238787333455452, 8700964319357541954, - 17561670470565298976, 9524122142014309347, 12619871254022879995, 4098610542031538614, 8338691110372464881, 4378598564044777665, 16435680634249352743, 12067828180476756532, - 17102475410743425567, 16244272017711449252, 17598420420289880464, 17858587557620312875, 7275673248698358659, 13952444068457447282, 14004356855576602555, 15776401868125266614, - 9848210305813205280, 13777844361911806961, 874096498600831552, 6286216140019341540, 1229781121487503670, 1221366673976886811, 4534525466071627057, 12966848050780717673, - 14890015174575641658, 7082696407720868596, 14546372439063914434, 18306301153433516531, 14360952638570231274, 5387283652784509262, 7246876761413034655, 4917620254108676720, - 16572428185201836512, 15535161956998457706, 3118508753345802652, 1036719175817464914, 9929541174185476740, 17658764424885337186, 3038747611544544975, 9299826573437432057, - 4068144934809412921, 10422353259330469599, 10820596685747357573, 18174251490011716747, 14838047097904304200, 6494279871501263445, 10908514990777375627, 2395220126873880030, - 8963350163641627638, 7331858013030906816, 15047142507680204097, 6113080618647404016, 7520779807516814683, 10255234845683676901, 12010823325949652354, 4005195924244758895, - 14455661618497189876, 980858168361168621, 5057114595071838088, 9447128440518577562, 17115933446433165191, 2063106073840638313, 5944852338857186064, 14601740796836275216, - 12750698494453238590, 822220438401342753, 12735466470750534773, 15168985403101776640, 17837672477921333079, 5413174218886573483, 8340507718774735027, 3796235681866322764, - 3366536195244539993, 13901131415620358879, 9146606194544531067, 7568835872371146677, 7101767951356426039, 1958938171972212156, 3871412404872561111, 6437054924013233533, - 12849284342518738377, 6061751293342567452, 15168528907847693260, 2071752334274992986, 338461453751559028, 17270401493472349305, 14152214298057413781, 14074152302209367061, - 3814267663972523036, 16047424572869508620, 328411057776532579, 2321721854548154476, 14950895796162035951, 2381867458906113095, 3121132178592915484, 11019696935452271225, - 17929201703034060485, 15478512769360046037, 11652099424221007544, 8436785170867890275, 16340404489137765730, 13705192502407972039, 9464924753010269658, 17372624212933856135, - 11237648987477338397, 850109691127167972, 6566350160877169296, 8028073340740368222, 4445151747345891893, 7753144690511205475, 7551118086710031441, 16785474804106433438, - 3919851124685189663, 16028223238454025712, 9008783533564802058, 15647028843636411071, 2029953422298604024, 361326896057539567, 7653333452646403127, 9211397293968688243, - 1817762546790624760, 15025271080704836746, 5761603182050280401, 10355268146728370750, 12900583599325924868, 1488036927944469046, 3405173852255315327, 5600132277974719103, - 12574920924242276218, 18146097977073890534, 18281543194137545725, 4432773597060264867, 797962164984225968, 13432184750641235201, 12394976215803938078, 3054137600383896411, - }, - { - 18270562314314829224, 17574550722906577917, 15522987576586641271, 4200899284963891561, 15719788437321868967, 18390235318178988753, 17371818886753265385, 4583380351670429228, - 10102001197913431240, 6211688443233768420, 1986665099237206297, 9248907879269017005, 3081890249882755206, 7828527646248386813, 12676034092230326487, 14655968027461080131, - 11464797300361906821, 1444449385286554508, 12433005157477847389, 964895564896662942, 8457290958728547067, 7044433897330872257, 12292673928275053405, 13679355097865192207, - 5841260956815214452, 9461234662498869948, 4761949640006529525, 18229823346336752572, 16055957459773168413, 4272222475092786627, 18249888117586812770, 4531982814021269346, - 6528332072572425694, 15678657170585498065, 14462305190193144746, 10159286562616704237, 8919172138248087686, 13247073064443362933, 3056992278576665488, 8216417459286092432, - 15095644792163717355, 9931529712396800935, 8608932369590222253, 17019087735655287783, 17120516184457264144, 16412592485673181957, 11221555966650765276, 6815162077372858604, - 2239262553722461896, 16518231021003046485, 12875479040073845800, 5243141733462514317, 12216971859495819530, 8917663622006068692, 2606734295032613674, 11237688605489138628, - 7270238601276019194, 7318279377964882079, 5226788506940171017, 16838449902078450273, 3375184937745100689, 16320655850583231520, 2173229791272659780, 9816381971766204380, - 11061652864259684005, 3625039563689831268, 4435107405432574197, 17570841169180914890, 13981724030179216670, 4992487505540472327, 12893808204753555435, 12899171569920731024, - 12002788024483301555, 629439982201171214, 13749214763651595011, 7164215996082938159, 63895081825959000, 7006379700570403491, 11929054672290963822, 14290981753366049931, - 13554823979828564217, 15627748053816803157, 12924111102804720301, 3165135223777020148, 16345805559363705538, 17656153856991335888, 5211305829410935273, 17846236012427517420, - 17113448198982970082, 8879656883528014268, 15215762680430094206, 15232212751792759071, 13699137317730183483, 11815206710130297569, 12298409691055054593, 2192455093917691024, - 6973243752017383665, 15334919534387330350, 12203459507012560294, 1880762698376948842, 13008085926447766632, 11695961991328184563, 1311309249708428072, 11981691262998313807, - 9209757463013140118, 6782250604095077195, 7896297860376631775, 11500117438976638113, 9099678680126826621, 11908588510950302487, 16863479726536938776, 6368086884375751995, - 6220904427249143299, 4501361418756965744, 13907877383736656540, 4499586229279778873, 7233050316216252450, 2775027076708404645, 5669561106187108564, 13951461080947060780, - 9742819322069712752, 8779224519997661749, 2591205872359340025, 9144644967919881415, 10495832103710459914, 4557264342687723360, 935865282128150338, 7120324256648044882, - 10780007491891304021, 14382731247791652187, 3296810302419712004, 12567831906993651128, 13933396378746555124, 9754754796778422405, 2905077741505886450, 1522919492210831578, - 7282056954663740402, 4915867300034445627, 234865561845141598, 8874426225092097899, 196269165389812019, 8951904020835594063, 6908903359164319029, 14062039535595890356, - 17922518107542393156, 17388335427727081004, 9077910363057082196, 15157438705071651749, 5615196861086779767, 17404239261681991687, 9772161835068093639, 8380484042808490346, - 4683169301229531061, 14940390399739549639, 13128742567354398401, 15222231511210090535, 7352694898928671332, 1221555526903686446, 8697118143614336514, 14515400523185205597, - 1119145169329993209, 3453487026721044641, 13723232966162256192, 15282444658208236515, 17806849942057939434, 158876409507122147, 11954364486113732203, 17566268785944006600, - 1443798830844295330, 5744920153630226551, 15739845606128975055, 10458513157123726949, 14711103578835123416, 13886988522344422595, 4454455988362290346, 3507977514728491242, - 15328194945269186082, 16398971046683442289, 16293780909421539295, 14488637138080135219, 1108438550767062231, 16291467684905586857, 11891067917592351245, 10459212739896579624, - 10239864229747754958, 12477284975467600510, 14054830413782031834, 17752968481181892755, 16082713391521411762, 17191329716867535304, 11245514405315337909, 15159733745232554536, - 4102022129275956496, 9361580273813141387, 13824110615577377618, 17115977884930866990, 15058705994968389537, 8039281695081359531, 7179945727911625126, 17628825480910826356, - 2477336341361304271, 18030759410783456479, 1164757311756325043, 14195508307731677040, 9794350654156795137, 1135232100348022155, 16693007636113380448, 17770308235375345497, - 7064407865619227176, 13284912648471743270, 9099541805618279168, 7383718461788433067, 3311987567268438113, 10943963018398042859, 8038765968977300792, 11039205462473399718, - 15444441705629456398, 12030687282161152512, 16500102437404896225, 11467410246278043769, 14031300093087427598, 14458597378298191386, 9434445586505481169, 18221119130471329822, - 2269899977501467759, 9674818903084386596, 11781166634280447465, 11752600152694102168, 14011747753002945247, 1084585411243442928, 15614695372212325691, 17196679090968022414, - 5062812993852092949, 13193601915773858975, 12910718608861476282, 447390754333146274, 18393090736120037653, 13231946117349235609, 13365030203093499221, 9724404925244523782, - 18064151108813428175, 3928735035534454387, 186686833744587171, 18406101378699384605, 16477405641027895528, 697258480673566897, 8958117283476321666, 6970167016227017231, - 12694666558858009121, 10992313774737315187, 6046508760845509477, 16818819584649823054, 10464090160691032219, 1221502600750419478, 8658907655588546849, 16110628890984509877, - }, - { - 6266830413981331818, 10890859480409122410, 738708598357264321, 9241173142142102299, 9152169484987657321, 12122430118903337055, 14270062735458703743, 13877635605034675649, - 4572419849863661964, 16330741525817240677, 5456771007607263420, 8798510164381810403, 16547183593064549865, 11355135595370359779, 17581910791451710925, 11684604415749005488, - 2766130068233451740, 15909689412657372214, 3272828023364980896, 12907534005596438003, 7065629942275705493, 10609982651084321649, 17330343421617897811, 1746246157222856918, - 13168953859078137190, 9072500190247791267, 11090199374278127099, 3503847851309060744, 14395788825673846582, 15073993563711333791, 12879874391706003251, 15417028700542288171, - 2686132933630431595, 334448852204016400, 5636563341880055087, 3897420469445246068, 10569177829735084588, 8244586887721364305, 17973493209847502315, 18083956436923498083, - 15514509130323617046, 9833490355170899102, 12028021566105512521, 6349458533674010018, 13470024118569549588, 7867188201997717819, 6110792121234766402, 9917858515766574695, - 8273062939911446888, 1936638151089648185, 44602505720759914, 7839132833110815763, 13045756168264521992, 5375972549477973022, 16964151563535745964, 2871770426902555432, - 14164643693563803212, 6386904235704679249, 931435629437735510, 4496152555914735639, 820099532545743339, 13419988718062417698, 8948965620484833159, 7238410427920554862, - 4387941928212462673, 8023190031094282215, 12322462122895470016, 17311901330042910195, 16445894183838823370, 690424095855074674, 12820742226551488738, 227935274674223825, - 17437729542205914525, 8439533239207225162, 2862942422640746698, 7340866642549630610, 6770451500989398335, 17262212260581413381, 2156505157624055602, 12195119268846383898, - 13685370053507732180, 8304030489296890211, 7042719123662732989, 12115154796394040286, 10496877583013829980, 8909625177349683785, 5268451666475070682, 8910488385056259560, - 8874918984373509240, 6652428549855789281, 14866714872885601270, 12093494664302554643, 10149999253136441007, 1611873554177023520, 10271627298853910516, 15171882630355491729, - 17085353800722834618, 3271271583189511718, 9338466116389304614, 4685545953421459012, 5059702655119414343, 201476627889215522, 6388612869673101372, 8357217932305360896, - 1836621694151238424, 11438765101326043062, 5537182303007083642, 2657011195641217678, 15370176245454161308, 1478361893117141052, 8729368992402422055, 4807782542738120272, - 5084555197036037383, 500829604818691390, 8128181767026348964, 17895639808733462562, 4138748420878083709, 267892430674902987, 8954358455330696651, 1946224964877667668, - 9440495138081785154, 17328162383695942099, 1870751290505230781, 17987066187778049275, 9952223038481207705, 10126409487298126876, 1181369784146909444, 8158422380540037915, - 13005094963168549814, 7254364757817833162, 3708127625424981603, 13214729399033107803, 14306349749849146051, 6983270854272831328, 14340019638575491596, 704963281855585401, - 14561080905697443279, 7640393429462623622, 15685656608213407004, 6317405842945074950, 4586197269496115618, 4352991463721324184, 18421865732314202847, 13679296167045126011, - 5024751682397066348, 16464187416447039066, 17561916915150311869, 1553872229528720506, 3971081625989469183, 16363381852589102144, 270446294712200212, 4668332646727035585, - 4623922898967168175, 14927682190770218553, 18082407698612059245, 8156136453512346914, 17256761355350416250, 16185397881787027880, 15277309552707416345, 5991448876439153037, - 1334994484802978518, 6876293985013000163, 4439518198423905531, 18287119869714109760, 10942138263490204506, 13981840082343935999, 186527448590996253, 11759869552919496944, - 12652601656062843187, 3947181446273381189, 6235196886760030384, 10531746495897900463, 13249616872107073217, 7937663398525899211, 8701780810784627798, 5901496026068341468, - 1059285256835989485, 18284969105568513488, 8222225088165109003, 1178299600673068913, 16068875143685216551, 17849596766342630525, 1648308197824141718, 6344465813776674352, - 13850247359965870279, 17391106451201459411, 9882112511974412840, 9027485913083134379, 2654737707750698953, 2829872619210764000, 10765067664204983675, 6008367494734883394, - 3596754664049660092, 4049565277418079196, 14294713401434678004, 682517403208603499, 13234861305501540306, 2878761138137340816, 7563571058666806838, 10752984583868770507, - 16399575624290910947, 4698193514990054887, 16222170007882213172, 6300376482027477465, 11587700570984519002, 4408509191665524069, 8909599698892352923, 15110169407475815879, - 13814725956725513903, 11675366986709837701, 8008867936756292473, 9627238521208818281, 500674066787171963, 7307892989752288627, 16701476208533897826, 13745712031279374379, - 14988991093658383268, 6586109441484875615, 1456715231981080716, 10587865765103526958, 7439504550868615754, 430398141621608230, 17710495017725824018, 1267747579289674850, - 7939033276966801601, 2952159422351169438, 10439776924885737877, 13630489377585028212, 1779349587540144503, 17209739673050012100, 4174716919431642272, 4986592555205663040, - 7110204405213656469, 5225260473696365908, 13544564684169074596, 10807318789744351361, 16301252682064971136, 5046748520130689465, 7049174921499294642, 433785658536711265, - 14622798677938552282, 10254953149954221954, 2609148400899865119, 8197897294400569748, 11784700166516996756, 18107483989994737564, 5332550435198791193, 13389061302706010047, - 10892870009313407934, 5709686117526627488, 16343828906887149047, 16063790174205876315, 9076070192754075075, 4639156357669822592, 4904064385440242264, 5942264027390072320, - }, - { - 17271984572727555145, 2097715321690717305, 5328035183708920909, 13206781766168781008, 5915693606819932446, 3870849056297265622, 18070792155150730518, 7786839743829304936, - 7939886940063870939, 3597929036186322512, 12732772396498766041, 13300425267730247515, 2345112231224079293, 12327614629296314761, 17106102937162407683, 1702694317559034053, - 8821632341545057929, 16708916351043551467, 9171560460858577216, 5711973041149612575, 15808302665077457285, 8412173943543358851, 12602476370021215716, 4778674887660148537, - 2707032230021934480, 14943945588296447659, 13333962501998857701, 10603744732015256400, 3386903941135274495, 8507451908469049716, 9231176235773710950, 995464562185179329, - 1251633503842168929, 8646405730060859011, 7525758827556699239, 12781503299321323139, 3762059070509735358, 12904588764985510882, 518456268741331092, 2752400776174997580, - 2965193395248314453, 17005383961540689211, 2510904953800463288, 14582093408745785683, 14930278391247460535, 15319775861672772086, 7915822626743762260, 10481055458185028303, - 750419144665626202, 4009275022270511551, 4810013488865977907, 13090697535304919393, 17408171061427940566, 13469810562978287715, 3952372983235223818, 12596642250700034956, - 1497127512412966214, 11292269970549257426, 13920714718237672232, 1363993524078475237, 3687544717271789391, 14097532154250414203, 8367320351336033564, 11089672460564007700, - 3927746316404254574, 9973240942982210953, 14122301504960485144, 13249357693517290445, 4259646940372475995, 13156585130751616020, 424701295260668232, 13006066175253059189, - 10308406270137410351, 18444509448482991837, 12509509048086126555, 8343613342319774737, 7902938427788958534, 9924925722974851885, 3762983399809982874, 3397026083592781307, - 2116063253535766674, 12792173758770945620, 11357854367169339661, 4502375174987631263, 11374536277081101446, 718846097450449491, 6555869089578359747, 8571702699293548804, - 16993953276024768829, 12025590727803527383, 2672535181364381995, 2183111709986676538, 14822521615475063339, 10618745739454592027, 9957515072444869664, 4797521918890127374, - 4582720743315312164, 18280419827142252016, 13380629421749133990, 16786942173448683921, 5929601960379909803, 6715621236552343797, 11192523517069751956, 228125323996215945, - 11861176681909235996, 830114321507110720, 13132205092670772295, 15318287322892364044, 9027539547229346224, 17629383881225964174, 17167841317952050345, 2169650970520181403, - 11366374573920831312, 81590945660392134, 3339836125719372590, 6176339191258224503, 13498384602634172923, 17380518646558253069, 6505222573402454298, 3404196177841425416, - 18097777493026370528, 398882723487597643, 10462164796529820357, 7704526739683689547, 12438059168025171393, 8163001730991802064, 3319372757738711275, 11518015261707325261, - 11235814273447729629, 17827792960634604769, 10951458440780869321, 13957342734404907932, 7344502969085321880, 15052563297577817908, 9276707332138855229, 16077312904856138176, - 10945312442787809330, 8353703025227023259, 2523779015225839136, 5997809042199398051, 5595238423081509301, 1901941038793828090, 983256298544496123, 929860142706986099, - 1859865867925261002, 7171610585558961405, 1708769301690637951, 1669524125723022855, 1126574755172968332, 2284167219201068318, 14925928881489847288, 4349400324295146347, - 7809927122217534998, 6003738786706135597, 16541272992243715653, 11352602417510156921, 6070703545889058045, 3742828100079104877, 9416263310824977145, 1406892456840131842, - 15907861713154660116, 1789008941779432664, 1086909323248385272, 5337878342158043460, 16405416607888113885, 8262005873603178297, 12775015438669465500, 18394022127507526579, - 9832954710628449545, 14612341389215489179, 8860090710725054989, 501948203387806263, 9969784653624607958, 8524029089859194791, 18028069685553315869, 7863046312587606086, - 940114737935470576, 15661699274328042324, 2496303902262203344, 17900779334646110602, 10928989106385540880, 11160326060698033088, 6591628982832414200, 12860480197090465356, - 4005088727670892586, 10215872293486093012, 7634075494800881158, 7707144163086802537, 7085702388211248163, 12168208652772836726, 16347414703478252736, 9386623607672009940, - 10720163442173876242, 185901255673735804, 189524655270248212, 17937598483325200462, 9672767027914841820, 10911520298114954717, 17238190140596785520, 12302850034563751398, - 1819872496749425461, 5856173707582412777, 8519855762092470428, 16315722646681962500, 11554620938156340375, 11822224388003836169, 8221825485736638318, 8413608007099273503, - 16265754830488408124, 13716061973016396515, 6050948709307262401, 7654402024031530787, 149712175032162058, 8319305312043679388, 6115793437696694706, 9669523344165801010, - 16530167766100505402, 14672843572926881623, 10752276706209340624, 6888427606311779724, 9060900993058482991, 10439396339124215720, 17640982730425880863, 12916411341252677116, - 13182242421100666863, 5267519287044706312, 1780278156705475292, 12839545421803851420, 9724873776343820617, 11742602593528879231, 7598735248774560112, 4512374343657017031, - 15080601286098047668, 6570749562833033851, 17494147260115946401, 4878559727303047850, 2259644365338981526, 4232993783633913284, 3035566741498855042, 4306414296080197928, - 3878740698199360708, 1631626027682263021, 10479957065093850273, 1678395573475248815, 9964111965340163993, 8992208313996775841, 8147773940555378986, 6205594793300838098, - 11776245660806714247, 18129100488268011560, 15389929343761297429, 14544292652959164154, 18063319363114104433, 13433144948667100183, 462314076175867487, 1862686058702915115, - }, - { - 17596113920958619489, 11920824479658301378, 3786905428099710821, 11112764289322906111, 8817260450068629272, 6518847791514184438, 14593687325057339783, 18018581321332807475, - 2056254186648603335, 12143016575009965669, 3290271983033386616, 4338404082685850854, 12660444972475266123, 6345409453044955404, 13278869140778657354, 10063005167581762786, - 5303950317664091150, 17409642188139937758, 12135894348302287058, 16444741243419918751, 13935885817311324323, 8496908197501732703, 12163317723288843510, 16891353436915314685, - 4168420842704770545, 338440394515115377, 2102734009665481092, 9772725684473416465, 1247616337419130000, 4222072446972129729, 4836898447189504007, 9154346000276664999, - 14649401370738987318, 10044081678892811795, 1306517740393103656, 16586067283450489622, 8211832777731897494, 12849393859171286949, 17327526552807783018, 14171704619529498238, - 12849053390245557890, 12693731077061619694, 5891211584023409476, 1008960642219209210, 15593393872187214387, 7381248773473326001, 16559656086795428559, 2106025108820858934, - 4347667984894353308, 2129883711661222690, 1076488804494872856, 15059968377755299195, 12380937310378496242, 16425480883270944108, 4769192332535557551, 10388305045430499744, - 8553482596123775980, 12627020622203381515, 10774788686070344669, 6271789114731522097, 6270586844349642345, 5584690155569770537, 9478526526319537174, 3405597782572827563, - 10255408065071335198, 2384996481315588922, 10679447117297819075, 3734157461055440416, 1635042286365643780, 11321809677772938996, 2373960964139986040, 4869129159740273704, - 16681657814739017038, 2045405432090866328, 9473434018957974472, 5549808619751464269, 3650191693776946828, 15805634549736708741, 16764187297356548667, 6849534466635874363, - 15295973549776084894, 8150873746601283651, 8017271980921908229, 4899654767305073834, 15257501950484641691, 17365331272978440066, 14582514748324426172, 14727798284858071666, - 3180828552573045472, 17698570278585440462, 8986722854533057232, 4518665117523514004, 1718699978312382231, 16973074530347269964, 5684175730451960274, 17228649521631238473, - 2897180423141326703, 13691273076814343144, 2967066815351306232, 1032540647518716635, 16365716239989474776, 9503666134295232767, 4599017511227366879, 14475021161770955579, - 4512626226592149712, 13575110216387069176, 13488662643497927183, 9673147324484250604, 143936220816719815, 2307325398241477161, 468315224038772027, 17743582630124600591, - 1476494936296433813, 3408612621327299295, 11632756669813257564, 14296719897220703576, 2241234207239321749, 12237974399755684219, 16253635131573079566, 11892871179872526079, - 8492025373682814159, 9341562763134230960, 10104358220305514878, 17545404790574939459, 15737064134098795026, 3880597485411313924, 388663918823974597, 15032915458906101183, - 965170717686924337, 17890763357610871180, 17588999527212997589, 13975763809893342952, 5109669798963414493, 7891916061794044612, 4789971769354067287, 13049661741280223048, - 13047125712251887103, 6463859133854403980, 12163714608926575519, 1018022589444930561, 1736262463418943433, 15665908585957261569, 8814123147308650486, 4798595000205497714, - 7506024921976923590, 5624217973379693717, 1727881279508834884, 6843292805721229768, 14721392495779901462, 15739256886195814859, 4955780690636679890, 7941019297099640360, - 1679075860853192334, 11512607379850785303, 8606478479964129549, 11355506676698290554, 8638706560448426692, 11314948425220125007, 192055228531777598, 1407009579456262795, - 13286048494307428802, 9003344338654830342, 14153483128501604993, 18443414499226619410, 1307798988667786279, 4422280407538765508, 1295189585361403916, 13026087054487841568, - 2784400402546744378, 15890015749743051151, 2721137876244951114, 5096506081391833837, 7797931926335359630, 11689452583898581132, 14104784079353186010, 3188967683935096888, - 11330231400343362000, 12540174755074499088, 10360616188128925049, 3458938550662172118, 9983547038346979353, 14986318734459319551, 6345635939240236679, 6320686366534231970, - 14746231842102190633, 3622710091833101572, 12626649920759262265, 7005023704205322451, 8825692535315999015, 4515463777365688013, 9604411949030284505, 440641657645532650, - 15551627195111259367, 17849357920181562395, 12870839822102241674, 13056924324197787476, 15109676201265834798, 12974964680406025093, 12841612415554457877, 2986633967268013902, - 16172780290314506283, 6024364507532794579, 11981052290745212925, 14235100278052078327, 12912505872017936022, 4228821405313065812, 2097279962856941481, 5542690235350104224, - 6815123236701278368, 6160442936745831892, 8260371745376005388, 715614132817606668, 7741929556783214361, 6266561134278568728, 13996537792746468394, 13116379830815883328, - 2212637711439965528, 14217650183061928416, 540869510933311267, 6195450915592159668, 14904187357299823445, 5215400274033728644, 6907285779833076435, 15804222685871187391, - 11124404141552478131, 15318338152189072517, 4067893425297764249, 1697503410612817642, 219476584157335935, 13106826093753036522, 13049745208482785760, 11832231199490391669, - 10493328169052594634, 10627081887813813659, 11388663495964140754, 1823051796271862577, 12476400584366298768, 13709148086980681224, 4023418280354022922, 7805776130903851852, - 11989040498741265687, 10985482710426001838, 598034896692782488, 12230542700168560619, 1496676485546951232, 6833695919100964828, 527254545105454187, 6276811762216173921, - 9452334891928331309, 15207477416486363718, 8081596400773698461, 7528187414539292243, 4773782664413845594, 9435822414884353799, 2722451711480791323, 13642248100035410269, - }, - { - 16570512961992288509, 15784840936011612960, 17797638261217375128, 10589124475671334830, 16848440972121709899, 697679021479737566, 1456738239410270672, 7214966028857473701, - 11434157439953722433, 9090860151661100670, 8407869262026581159, 17882547383849407986, 5277257988019769029, 11463853580825342183, 13607489835500075467, 16878800997498950751, - 16059297404709367406, 8426877510924536482, 15269952608796785555, 6256768900860981984, 13142655793714702073, 14566340391957173918, 17147065283704191109, 879106195264399, - 1169887957113173798, 4936710663791789838, 8029349457377894665, 3317691225106441967, 3622769674498678594, 1954144360900150482, 1432045977341997899, 934737636789214593, - 3519438486034584001, 16935008858078961013, 11197550931955434437, 14100007087636813411, 11096181469792598416, 1355325916242161182, 3003143504356161310, 5855778258533244174, - 3469569649879539425, 2734409579230557820, 11243101718460963222, 14449395552625174865, 2832531264658408884, 12736053595733579053, 8514265014627300817, 4646556172848350801, - 1035318057221356651, 16671259128991069733, 933190532640544326, 10073090919720429370, 16298191828003546946, 89465711115503243, 1726024123088964037, 6293688775358665990, - 9646181593082190523, 16068017411165381498, 13319927590045936565, 6113055520205251774, 5576373032696512038, 13880344501714804196, 12022206929479211261, 7387979357081975315, - 14353322331225872624, 14137906560696321406, 9597841809127146330, 14479164716385450316, 18390885446667453601, 13789601367024187697, 10599569472420906075, 2183893278236533867, - 17984045804937170919, 3008713646989855019, 11485907798025297413, 14380740919052976941, 3447658178143557676, 9095585806057103587, 698302327819557146, 7922185712178340950, - 12592522203651044465, 1491459000495558958, 16988036704095888812, 4620491143241098446, 3378886739158384486, 4601357523445825298, 7994566595487207192, 4507705687201434902, - 13553890993911526641, 1237937561304731611, 11053651340854998814, 8737874920379363783, 15414508226001886918, 9311523317130687807, 12080742822716708234, 4715194040021784977, - 11413808093931937231, 8917864246709968658, 13554307490245863526, 2827250138133094370, 7637229863299622584, 6947884496333162143, 4815638417787805223, 10291803792760846879, - 12634048591085853546, 14321728045924893987, 12328747445286182403, 436433860116637979, 5910966881246245784, 11478152401127002379, 15956760875311888867, 9580341487614973173, - 5405380974793160831, 17240616607222875763, 18407061562244315632, 1777973921117407170, 6264824459040652928, 18267228171835175724, 1278124974392461846, 16099414790431742315, - 17182132836049601530, 1486820395924546410, 14089047182364760490, 5375431386740917568, 2352352269256972682, 6220398075470064021, 11444733678216077372, 8173002234516562536, - 2862732059898640615, 16485439906762588046, 8431038226899400253, 8931540904642954995, 792388953489761723, 9296018986570869365, 406447163304028453, 13270392174836298982, - 7772216409762031099, 334915652033124323, 9705063888720244418, 9829080877134570370, 13800256788887079067, 6121678265481939341, 11747955988727867922, 15561904257519022219, - 11919247213871390231, 15058232650937578711, 16509435050946309716, 4585646383560577121, 7109079914182671169, 11070600764446172401, 13212464399509938674, 18057628120939602025, - 7896339057146013415, 17613745684396593735, 4238258305077796259, 15438639564771394288, 1482402451684594916, 3104492350488980260, 5195487229736262641, 1361150797580203482, - 16473144777827648385, 1226441665397311636, 11587851779002173636, 5723433682141598491, 3818559725806959172, 9177247615754603193, 9531025756553277601, 1716800965379459594, - 10276432666086031385, 14627452075834666747, 18000674623336885291, 15328386422432799237, 18139556051577750412, 2213209867616444127, 9597214736611625280, 2458176131336755868, - 17117806110792423322, 15887422186644000204, 18208397717053970445, 7361598408210891485, 13818554723430207838, 12816010025806087198, 17883064936092688211, 1716893191215908273, - 15949855327936545010, 15892613064802301412, 7776232754624386979, 2193423430757249310, 10751855334513902678, 13772090376350944100, 5644047706587449960, 370992037484721524, - 10797607675141630710, 16625594903133516890, 4419277245854893028, 2258389314023537326, 16758443963306613299, 15289730903996513589, 17124263661185245991, 15862017582286958991, - 12272869926038995590, 4569089761627301260, 6495211060884501138, 11124576322292919277, 18314798224925096163, 13232331582712038213, 4402693571738173484, 9384301049965683996, - 9611026793910805538, 11152002731283498747, 12528844591327054806, 1485961507414531975, 12820893906402770618, 16248407567081091370, 15794078730898691457, 18231302945982292403, - 16329953561108738383, 14553061366216182492, 5112198484879130320, 1893048255589705004, 11469678860036344015, 8992526488267920066, 18208245559304821518, 8980963391041920447, - 17694621707784163170, 16317870945177246022, 9173265111786762052, 761657177655159269, 4876597178189658673, 8185879737091523833, 7520213092991049248, 6827963030155074898, - 4104149897263226969, 1008830393844825523, 1692548451180187046, 10984924503299463085, 3526468436911084942, 18012043951628458646, 15181223987778535698, 18016160796635284569, - 1524865955503524054, 7479709667052337482, 1064851658558537015, 14404181438374010311, 192685278892740648, 38546070651855709, 17006752915941498851, 7120034574635007914, - 5783711159088718530, 3503029393593618754, 10736192136662142256, 15443859608128978668, 271805305647187927, 8244170003029416464, 17017071503038388446, 2536084345379259313, - }, - { - 11535283160083833975, 15102917952496589829, 12909095696891909745, 4611119212602854744, 4195756524232932570, 3754603965149529000, 11539276962358607816, 4401424391553230481, - 6842993463058627120, 2708745114617181146, 3832382691810282630, 10333834458057320812, 15028197197004077388, 7681293343255119354, 16227537691626587485, 6703363869832495607, - 17567108285065737529, 8693245930330183070, 4025672038042952121, 3491067119247522844, 2100799837993193702, 9579542950705774054, 5091525285265581997, 1806757015709820088, - 7757354840118131559, 16227348978414023262, 5800861674805516343, 16486235803248700961, 15646700163023677309, 504258765210816549, 13724147899924699697, 13588899538317277096, - 15895596198730294923, 12513494396374459899, 13552575153453342654, 11312160635199213507, 12446618129881485796, 11286186116805515445, 1584191291800429567, 10188741008566636830, - 10157626021970320469, 6580688164585715207, 17158416694471177787, 2873484006255074946, 14852216457444863041, 7463041347566136496, 2190030775722958628, 1116223035803602728, - 8598875756176012541, 2146658618778432566, 17575736667490551813, 3602654209723135985, 7223347129734689099, 7256921024940026570, 12249118963297692963, 18168532365040819099, - 7585174044375463988, 2491923406404093282, 9355733262044036112, 11484079611349577325, 13145030009254943291, 1234932884591406048, 479845670619308618, 87735010308690865, - 17307641427543377277, 5862898330718319545, 485176909118483750, 9845223919324484076, 4293549583740204024, 12765124043303931186, 17870894781132657382, 6508172378961793849, - 14234156373312856400, 16210939788814051708, 6478880037923038392, 10435512103812909561, 18142844321802359753, 3243996803126554757, 395603619159523019, 10213589535656704607, - 13256075137060741204, 991285459654295161, 7857174835799942102, 16201105040554625727, 18398612085349994216, 4512860776717176840, 3521452275695011919, 10622137733045360311, - 14993897771652736376, 3320388672992783302, 18421556740970114213, 7438967127794745135, 15048397725789819354, 12721899159423777001, 1135125102123667189, 6637485660805148630, - 205606553319362431, 15484041062449893984, 12896720585684759529, 16675624014916513672, 7579112430564108390, 4602460356900251082, 2677787525524280838, 16723483619407414479, - 17981939084373319995, 3989926231875116241, 15342509934701840045, 12999252495311233519, 15389919024942778009, 6136335679373143315, 4117381415379544275, 13342256463740646775, - 7622769999043907199, 15227992053145045634, 2719412067263856950, 17811161335980566241, 15036003689029442301, 4919601685231030712, 6756893600905532338, 18029567067112075531, - 15804957839814547154, 7924193945337173678, 1080401129055171214, 10816444561878528576, 13171610473229361771, 8099842733764406841, 9284741070210451667, 9245195215372025289, - 7352706423771400643, 11698139248518535945, 12836997796963939813, 5747451345763534394, 7572033904536738295, 17752330422795919668, 16404760947165813434, 13477251724246705199, - 13700661979310397040, 11172816633936827025, 7087232997755437759, 601317374152115944, 16028751590837491967, 2749566595186093629, 4445248645671399873, 14714182958477634997, - 9630153311383545953, 6436885924177487891, 2150319761793765423, 3799049242167098053, 13902640603080497957, 13121685068446422901, 10099985117244683905, 10692630753099650856, - 15680946025356791729, 10935239212262708062, 15255596602338430716, 15502989798538458360, 906862139952472300, 16128362872146694687, 9038121313842477036, 18304772087255114926, - 16961332967315316395, 2872796507989583018, 18145413156795763341, 6377517922859730669, 3543621377523624979, 10701607653242580646, 17747200374013876449, 15987594633077120628, - 3487728992359467218, 11271201736509774853, 5968332690756574092, 3519182420015237550, 17144214368301394415, 1805926423542721773, 13696269518209159134, 942126126861202483, - 16211326119697754410, 9043490763746629445, 13119640043033532883, 9720862297941999125, 12662669665140843415, 2188499520755532048, 2671631563874698813, 621164898587943254, - 4804461736506692241, 10698651491947798952, 3524135800884470917, 11451653751986650957, 10424912129082359813, 6912080226482239953, 10357808719970986526, 11757540241185558439, - 1841157911016607198, 17522398974331009019, 17392843956059453556, 10510758656389762948, 7666344868273530034, 10739409534839380580, 18010518965344703872, 14478457810678500914, - 1617286442811984718, 4008909641875477702, 9328654790542709745, 12015676532404599710, 1763241944305573436, 9348325841675336084, 4072126498552363080, 17245688939115723821, - 17277555838655940279, 16604852268187595492, 11674181070138727191, 9847423407697994070, 13562477602392929772, 8181792789545038731, 6999326623175714057, 1227784795779857129, - 14923095901189736698, 90760593075377861, 11732533481504731510, 6000651333412910877, 7847865090059184838, 16859539404919901595, 2709105957383645337, 10263820965340474390, - 3161036642361826348, 5744405044938832483, 8939741099437920817, 9766097724147073614, 12117283480449144394, 14632688836103128438, 9491651214417380913, 13676064073123352224, - 4673738700738845848, 2758750364605631228, 16596306154038523740, 4124917668203310922, 2170509910405778957, 4178077301639210933, 5109055439238993109, 9627760120514410208, - 7259236533647228872, 9608619771663043870, 4148523959415435806, 8831501534166306825, 7919036824652396994, 13625969543100731176, 2546426055029800579, 14852443398434563210, - 7185947197544988797, 13306809398790059447, 11440959253278285287, 15084384140482244570, 5059824327869316332, 7585354587200615362, 6801884469610571467, 6427162399794357267, - }, - { - 1453348772281274490, 13028088570940491471, 16100623112750251840, 5210244400259879874, 9443916155735416174, 16869520919318450506, 7479400208826706574, 14374970913352602458, - 10149597276931117465, 5778043705364022356, 13888443605241209218, 6889225091714429810, 16209363638493043975, 8516350006446457646, 9214830076046105138, 8894115046323798175, - 13026208197163596446, 1935567165776196957, 17296090833026336866, 8461284827078097590, 14545382879887213077, 3302103559307506085, 16026840048628844803, 4599071908983273604, - 16375505785562641226, 4903074653735993511, 10355787845763031761, 3188849033041803587, 3145147452182864049, 13878747873108378466, 2798650520315922121, 2325962694441538199, - 3587824003578414733, 14942115314012282784, 5312737955169054323, 12478174640832111702, 7866537714619856949, 1076672758151595875, 12163513815501875048, 8343003998956997868, - 1392855790923554429, 928317148609633070, 18064469091536763974, 13446092366984636072, 1975222540660444795, 15443703204026028192, 4016450768356916736, 16656367700821047808, - 11505659892372808762, 10322665279031813234, 16948868760451861492, 13706671779256832515, 1968671033447691229, 2446599110590827903, 13721045634744350023, 11053432744256776013, - 11530583608023224967, 15979155166527001287, 592931868138800645, 5361781029549479856, 11246418752830406096, 11882251984248471436, 12026389461944629423, 12289077922798223820, - 7685868633977346753, 12528120620943035447, 18394735788313062922, 8523101916703102094, 14261596878655792929, 6364753027040158382, 6433482955677830548, 11538026548937002170, - 16221339092185577802, 2285289075757313223, 1151823739515800834, 1010537560193450047, 10651328720714490261, 426599792903611671, 7181136719074122463, 15350479907287263858, - 7559201271967630136, 3561344874280275357, 16379496429080959327, 9662226613694502966, 10995850494788192620, 14875349277152338391, 730989400822814422, 14352408679782573731, - 1328339467113622233, 13374824154992864223, 12057132015324007824, 8507647484414695512, 9286016370798146986, 9083798709648036612, 4312959727577073260, 3732271624824420608, - 13007262390446754395, 5631627784562092966, 2644488352265945851, 15340614364643014664, 6692152810984634488, 3903120388658969320, 2513009101887784188, 11999681442010831364, - 8301343575202991577, 7108394080005777057, 3477086484634015274, 8772644795325835021, 14747670046873500269, 11068536909552811695, 12349879357573378133, 8898863927320049679, - 5231654281125841638, 5181061730027800171, 10657176101406080919, 2548241936122768256, 17140253194139059526, 17961047717804458883, 12407260567549658707, 1464243167234637194, - 14129872794455315922, 16354810591314135702, 3177417010197743958, 16494351130927698692, 16557765056328447818, 3139394196704738651, 16891813998271303650, 7374470997276173905, - 18244279644122204437, 10097660526910786400, 9270181538098732492, 362243376823712218, 12369863141977485111, 2550957813014523686, 7768963959853738595, 470330801228165919, - 14632133560934390222, 13844843545192224059, 12232948338847787315, 18223343336729121487, 5219716370019749202, 2729037467284418866, 4546118556621109595, 12191675540034649671, - 15868991745937371466, 12686820201922367283, 14799186526268126508, 1241626948050017911, 7080072468753824165, 10793537086099229143, 7855065677501047369, 9747396305344084667, - 1547814412223404746, 14194709348405912167, 15771028929623393801, 10945048172868684389, 11234483878611528405, 9542605377580701681, 4555391547268120796, 14916872217451960022, - 398873176015355134, 17609838001051405497, 3752252377312468061, 10441993652683449973, 5218696730429184844, 6514361533063264268, 16024112124035725701, 13453525984055386124, - 3452753233449684767, 8937677805622461008, 15346651759545553711, 17055791435062851045, 7025089132368408239, 7345356702153522862, 17760529714295220737, 10772604293313163303, - 9940223451501501487, 13671810088603813912, 1432075826781639138, 8145669182511487125, 852664959675237493, 11640273224943853609, 16220508798123490173, 12787926729706993802, - 15490131882364039637, 5140304620645573547, 9403655757498826823, 9824850954989176893, 6366139388903157264, 1981838834216345294, 14659870286877979556, 12091578124492612524, - 9672198938588933438, 1848525214318852627, 6500329435429402369, 8547555101599185897, 4282139019453982058, 13391782461875853462, 956960429753408730, 1865393350316759140, - 9155847368519787501, 17397005067762861574, 9943535970799289809, 16365250691105460494, 13595148040475375224, 8300668237654861875, 7149654787413440141, 9226755501324961219, - 9359301870380673800, 9344500253098672841, 282669288080771734, 1996492472861301505, 4777949892950526502, 1374151996531969836, 1529729047243522545, 3371309923165192567, - 6832171775190531128, 7903951882621813138, 13717573220828409267, 15400575122727850054, 6101307565293576434, 17226772767105983314, 3485283905347036760, 18439321272895583847, - 5095761409418784463, 15484673138064200869, 7743962634971666154, 9119597914470879266, 17978461537972396088, 11490423388734028778, 6537551181013090408, 11706370534703673937, - 6635008658379780815, 11428304571924124070, 392068559161657302, 16314310970878215293, 13769492864572584674, 16880907685897496637, 2877983831559338706, 10391660973242662710, - 16861266984653213659, 1968749328591656132, 13301499995824894911, 14523175695360471336, 15130688872832023531, 1794208537894703529, 10525607764904270704, 14288604199111912452, - 6289130721434350290, 16129337673129720846, 6648351866142453445, 7705983837166554199, 8120136556582544814, 7924417299222764443, 7821995671300500892, 17697662726179084739, - }, - { - 14086745261650819748, 17953107869776717888, 1777725846494438428, 2765314406831814212, 2603997194371852991, 2223517025105045134, 15579901335531749634, 6571733615332171148, - 5478465698516556930, 287443454357750768, 12201204663663129285, 782849770204658255, 11270045035009204251, 18152683972363144337, 10463300037926642739, 14363641589598863851, - 3790592075869665284, 5120320091554329756, 15361581282394028709, 14360464660911164915, 15249656958991931940, 2563751872827049233, 13745792006936646733, 14572943674933168173, - 3167679014977537749, 3417445004776702290, 1709246158507866266, 5861367897285174360, 8437429877561342262, 17231607446243478748, 16047596399306766948, 17656438585829685897, - 12977336347094692192, 13723871955002954132, 17399919575273038847, 16163973860244779675, 14997921584659740746, 6543247361992425067, 4675926398794487109, 17580512382853194054, - 10778828023580771765, 9812611440536367405, 14168149065325522570, 6692229110872358750, 11010962724400581057, 13055203605065073902, 11396463140731730116, 16969789651736772232, - 3285258013801327520, 14114268241282882888, 5367399533198476395, 17277410244918727028, 2751895479568588421, 751309667192066167, 13038472116718581917, 16013586354334596135, - 12364168614988940500, 13194367252463423118, 12223406606527741280, 5014139294736037086, 11244699482831816093, 5336498572491451990, 14268404582568856142, 14502318820969599316, - 13295673091232554814, 313981772853781347, 11829785736449464030, 13341198421333360997, 16787450350663111566, 6525407229623764159, 2012189087039636323, 2110887590404698758, - 16984895766311549717, 1057465499230843916, 13565444352859773343, 1019268943988786852, 2190009140530404855, 10045598732295352970, 4789803496780829836, 10700158388954091321, - 14840255112988420500, 10066628133368048408, 6527354835873855384, 16106607076894419125, 3989024604987083046, 10713316697020150694, 16811389107269552264, 11294596059797019619, - 622403023838932676, 11423409007234191765, 17086830255702454786, 1213655124481948199, 3976593910085142945, 6315875935390432543, 17947502153968859628, 18031540937011531543, - 342675887578148289, 18366454547938469828, 3853530442390999217, 7499455395579634652, 768597405171336502, 1636271570683567151, 16786205337983572309, 13056241332863199715, - 15991153618414855143, 803325462494472241, 5709347424437559249, 10138502962472290727, 4675124205115228106, 9599016746550345197, 2769443894695609085, 12311020551315051087, - 11470964304318784059, 17313372553735202469, 10686997186364536871, 9228453594798060121, 57933324335302024, 8931389936300346353, 17823596478938529898, 1126996688113949835, - 10457697409306668434, 7830477435299250296, 7772379952622394912, 6109610138112185532, 4382803614711332911, 286231563340803504, 14408860285425706036, 9445290615796219321, - 17536503470234411585, 10755841521760916925, 15905055604395954066, 10842889504280336728, 10780689817551616331, 12490302644719656914, 14399349211478895553, 6458867531104408547, - 18263696007238300109, 14344529985676987842, 12351733186419515951, 14648750128188787544, 3817061805140294292, 13460439592176294955, 2651602395003150964, 17613970291099197676, - 1107162420032075035, 14270134754120385897, 4090584027509443635, 16066949131129832709, 10961641187652236678, 5480069976143996625, 8549185711954755645, 3125346629140152790, - 18337941236561689695, 2899707239319273137, 10519944305927777790, 6913088845356962577, 13796383125935684169, 2756403850320695444, 10018647980137529204, 15185795467001072323, - 678732289042224133, 4682655677430115166, 4806112367076139288, 7101473987708012826, 9907594813802528406, 5572757906434657546, 17819688309930892783, 8734990255058630746, - 4831187103439262344, 8323117365987697459, 10690753367486223100, 8744079000061869982, 12737295198832254982, 8667406752954112119, 7942221205780634447, 12612313636795726189, - 16544756691464009983, 3413196415113664237, 18442955254149959801, 10193439941306925215, 15178607176290875326, 10962146035584651400, 11757614026658646304, 16241528460556234026, - 9593194029396792148, 6376573619820601945, 14694667798662125868, 473733746941891591, 662607401339043361, 12105576520816361855, 16629740468317868384, 12416206001206121129, - 6655696780366945398, 12313066500177107654, 15308290012322636383, 2159880960357061128, 12374858353753840133, 11331956329091160239, 11794840094276473821, 14170553661155653327, - 3336445037682266403, 3746885541049520962, 12688476435907418892, 7399089272376853858, 4625608774712059624, 1535040330210000507, 6878676093546636363, 14533846142831376645, - 6250279356724130049, 3901672557903829499, 4884397030724371499, 17385695093365573379, 1240675257703364805, 9703149291204612490, 10295741452056015824, 7249917314998921510, - 3336800790505577062, 319907795530586958, 15852045830964927276, 5538471989976998401, 16558766045222360422, 3135574045680866961, 7590873965560972285, 17191236425969884848, - 542161999237385999, 11197034618748267807, 9595673564043235773, 16351524685431643264, 17127456926935032059, 15448416181819692483, 2035065584045934249, 10976830957530152324, - 3230012351101746458, 1662948417350421518, 16062645290454019168, 6021730506322388306, 9903225699788133023, 8549278993611431648, 16267339446315716903, 9759051179942016620, - 14281696762614162345, 14970002486407845832, 14940104843292093805, 7021313216295048550, 18131586729996841512, 13957742754718859034, 14322894803959804982, 12861731196696133597, - 8838210194055479741, 16190279688839291456, 16520121358582757556, 16768959728701970634, 17279896910204983538, 3582816187015369256, 372137484481226748, 12972230207718993241, - }, - { - 11480031272463364121, 2525856087688686375, 5875255653057452580, 5606696614467440464, 12094715534218447962, 6173479337351577758, 18244015404482482803, 13199349349511499695, - 6097225965006328457, 2630336000831717722, 7049638698786526134, 4203465038263485233, 4677974565964393904, 16044036678123636261, 7266049959100300634, 11339674070148504929, - 1979992348876614621, 7494083465935166973, 16035723662722831744, 6820849908885211777, 16740735239901023053, 2017530162004533409, 3087262288875984227, 9072904925376793991, - 1830819081327272165, 11951292080860646547, 18002500803418629938, 13317986695217403840, 5005574200470766330, 10138179785738652504, 1610518863105278224, 13309443265578956954, - 8383241685301818332, 6629521234420338478, 8997316634951392497, 9976633096395028594, 5171570735720385772, 8129153749198218776, 10596302915145665067, 3726383961188926740, - 14494271933981109919, 9056473564311980628, 10557807473422306929, 1549747977888697589, 4534184223615087698, 12977118933167042558, 11930457930026683843, 8346041661496792064, - 7756665146227128459, 15140824521273386708, 693427108108819556, 14819189462601222526, 4507393341357475468, 8710020646873218244, 4535796033535410044, 11884504632761707946, - 14192194428653714479, 11578618567931657764, 6032668189933768881, 15981535562386193924, 8925792218631314923, 9408714146004183681, 8859017894477140398, 1675606340537058506, - 13447287279335601133, 7792625320709870803, 5347956615552953057, 335662974452886013, 892825083599137885, 1017154417323307505, 11923254597349925339, 13818364932306372202, - 15945578153358602744, 6304522416189552358, 2545503746231186920, 14563857419242252397, 9711931929315762229, 7949505077082864287, 8780199792032437102, 10109661610848827442, - 1628958128919487289, 9818701341087940523, 16480240737841185501, 12633108361335093100, 7982147509828265471, 17959437456356197928, 14370416793872407673, 3577532534573396628, - 3265119697568866078, 13753322853248061974, 15435163376825672274, 13646180516491714938, 15620545622955090250, 18241486585498394565, 459566729126467878, 9728217493753855944, - 3187267754295885454, 7928049460349917700, 737484733736740002, 16459695106656291329, 13000947522838718027, 11933371771659873912, 4720706464557996274, 7997020276574823784, - 12655797542121172150, 16574741514838026101, 13532097913031715162, 13578832971779600350, 18171552525916232035, 1516234640889581592, 13625693062693291889, 3869929504544890755, - 5134589228918179333, 5186584327613952853, 4114726195152833642, 578924708883784650, 9128473117392713984, 17390547319520768186, 15077700332150016764, 8707446714183162237, - 9883406233903270985, 17184231210468300584, 5498903678702785900, 6903833261382863389, 11489138095102981636, 9021901931786177471, 3227433089132150317, 16639455550797627042, - 2873811051246262545, 12759149028054319339, 17920917684786397179, 2576455203420292139, 3181713670456310447, 1109589489775958300, 8920119044838278090, 16056330702164227666, - 14277712977137303378, 3896132440952049994, 13252040000848248790, 7844779060499908154, 8651912177362107995, 5527615699397299219, 17688189207278018869, 14560189235973121390, - 10861951673021959044, 16820848382034483641, 6761027571816469843, 3555385088072119757, 9363319138244920099, 14172742116400795253, 9535965929584057049, 15628517769546199992, - 839045372102318861, 2032615141683118500, 1921816835840256924, 504869150737570005, 15932184001422473505, 7849475855313305697, 1189994394722618598, 9874798350548229684, - 11973862230325381876, 7670835358390713178, 2113918814334481709, 2289514490388170400, 4570586695077036349, 9449360682811675838, 16506880875578470116, 13723444740920888736, - 14210428465641691143, 15330786835024186142, 14173742373807858721, 15041216914246450688, 6027140311333696225, 17929849776014561356, 3955935517651718925, 12080548003455651805, - 1974142217308765297, 2347591555456293560, 9029256828390326937, 15561672734848339972, 4719329765359230610, 1924866103348851009, 4950258359754995181, 3245952633715281425, - 4636201671610663345, 16662311204732135584, 12398897461787695675, 1355753199357412657, 14695655628527768564, 1692838776852698754, 7346906782826540912, 14869028424564984700, - 7242751356102425321, 7770223857340282376, 14976092066160539655, 389604327668352376, 3472336298605227213, 11456496863560248128, 14597769228654187922, 17838672631901123288, - 10997764239928568735, 16648935573721932916, 13735964592293716412, 1364388817619955667, 2511134998006929958, 811167458534120344, 9371523327214092569, 9359553283016173792, - 15311627918891973770, 17170652974122329165, 12620036374776436604, 17439165699070911984, 18124482726761033947, 18390083820175794165, 5492125340791896125, 16506113603670143446, - 14240080119980315297, 4751983902385717684, 7941412103662252178, 4796803816695225123, 9327986654018000413, 15111345676387005726, 3582558555283734415, 11913156735178831102, - 2000999613038609412, 1070613390669459171, 595743672188217500, 9169968884291187666, 17960105939867090032, 13927107353795575459, 17872593051171658925, 11087013461789649235, - 2280207936513065312, 11704149285124951522, 2138093032627822381, 6816805886026674440, 12141709925796155041, 12164596600353477920, 5711177504477877148, 17211856235678509153, - 6061025098309340877, 4060747063380827182, 15186975689243681841, 18380882388949786706, 927262408801716090, 7447789770541113239, 14074172896745727729, 15372475239996145400, - 12915868875134296756, 3071143582305760275, 10848717856747030010, 10973183887638314967, 5983269487036236823, 9885184706933333413, 14509493669845681951, 9669608065801379977, - }, - { - 1190044221726873109, 732025666411072563, 7781096808432277694, 13079879637655900365, 9048680577986693793, 12528346194104542124, 10575369576322629835, 14068913038053465964, - 3297775431071502652, 7947266993949467566, 6161673381820779563, 10604626734847205996, 17669018066064502925, 2386071939136502354, 1076023928806956187, 16075459682742916440, - 12387028018538599950, 5791681577936683396, 7536922194386052138, 15377770247350254336, 6564316170002440575, 10629371267149545956, 16125760269901494382, 16051398044897962024, - 6237354803374899565, 1782400080026955610, 16115027077529639342, 17907259814836219524, 13179234383592426160, 7302978467158243198, 13607720993463749225, 6693531817169120736, - 9659467198848065929, 13765104107473534739, 820057324758632016, 16604163594878267405, 15321524555426147294, 14524167419333362957, 157291234996957911, 3689488130722730671, - 13896531645245568605, 13598412639648980920, 3875086557856143664, 9242105512956135595, 17410265178284161091, 14904754836127450463, 2354327747158525902, 3858493849578874654, - 17288438225198818690, 15275190140700748774, 14532856272428522409, 2192294551011758591, 4275966798014984695, 13252812474545742114, 8604705074440591847, 504054699541924162, - 3623027910997185067, 15957466839356832933, 3504133700071704955, 4135728439139397021, 1160600455691338871, 4431928072859292239, 1542956305318065546, 14109181184369694855, - 9135041378474229537, 15626265487594878380, 2645257479784082878, 8105679948445763432, 8579715781576202730, 13437359533149316300, 4344754720520585005, 13326372852934103673, - 11341622086474305983, 17104958945811183278, 8154944722722765678, 6696975609844549775, 10895966360082878017, 2277686037575837054, 12236842881540344526, 2086470279064067791, - 2942668817124399651, 11439025398519255779, 17477264434671471242, 9606507094132585461, 1771475584689465869, 10791261379080046759, 12901998265727968789, 16423426725595035468, - 555419805011031621, 13715683285513290290, 15526654591995532751, 7023761423093873354, 15093366433178982304, 8625749648874372840, 6412297471587129206, 12161114204724955762, - 9362623422820895267, 6491356159483508885, 8543224082493101588, 17290929683278258587, 17348088672546490894, 3323350644823701753, 398525379151271104, 17794417664139368677, - 5880914635028486784, 2898124605786107494, 7953506026198179840, 2189477357380899574, 11207122442953694293, 9288539232660208671, 13527697625010979453, 448462453367651162, - 11262205719433170585, 7539606872920196479, 492385789142086954, 16036594120332851267, 8084547797138041354, 10063336189771527714, 2484395715469739911, 4879298610504146231, - 194633990068625151, 1028128699653523895, 7436102537486268753, 1855520454959348468, 5098690958966904466, 3342676718901330604, 6942212660412942406, 16510188838209674083, - 8847926418142642416, 13342814936333556870, 7082971165114489981, 9307541560233171550, 3013250253632606412, 289291445038948658, 2146586262066552853, 17331519863134074479, - 13747350589043267381, 6342477793304440894, 10087817302474912962, 18076409030930122816, 240893790090129194, 16364025156922886538, 13518167316464590136, 8034023137744309866, - 14013962864860194917, 5900268096329749317, 578665371390927342, 1407477069341362927, 15142181569643383319, 5217173950329651840, 7999234477517614232, 14722759409199120103, - 857809728583972424, 12785911478120621636, 11351522624307635957, 6288237507210579634, 15030282678317951238, 5521516375915920991, 1243458350248005764, 3567973108073272461, - 2834660673354035229, 10728451420162645120, 13396052377701115268, 5730788601228223475, 1616452754395208882, 18236419625072278846, 1179103743668306981, 9179882267624091153, - 14087439523312437665, 7814060325531094731, 16777382811045908592, 16916500419494378884, 16312259370378381991, 15848836870251345077, 16352246673954213424, 5228629139249919486, - 16889782864065172884, 4486233301301317202, 12424854171669138635, 12490430652425390015, 17335301435940798099, 9685877269515541824, 8728054940414220990, 12781228698496150916, - 15949574575791239459, 10394047428873141717, 15915386168603191086, 11400139144838475744, 17198578050070482368, 10505386377385262682, 11269920026804647377, 6796664536515856824, - 3285292208372623455, 3132524240856145976, 9712372580979649457, 10523781046601368064, 4797168047433466290, 11748687702182632788, 4177442610271848350, 8549047039673741703, - 6897143822689085584, 12727238507037725105, 12692443686524496083, 1187606781546544862, 11016254758711515442, 15622643445771261724, 16669571628491989170, 7099030384210775042, - 3541342827520921014, 12596176563952906070, 5209816272233406534, 17158219989390045881, 9096207539532607151, 12291463442559161708, 5188945441827912424, 12721126884401346746, - 8137171114112655022, 6980210601071561830, 10156197453074241467, 4481350962546197264, 1902625885079226055, 18310954340184922140, 10624840172920793227, 121304340390125189, - 5261036238619130144, 1418912875050883205, 4741122621962383610, 17995804738511375239, 15493968366750472633, 8417505178158780382, 14685111207483504618, 9729483826733360559, - 13434828863770210135, 2940287993177646896, 18241509923298296610, 7613631401252601295, 16815829390381900683, 8566309323681786413, 11094402941539790077, 8442864581771174862, - 17650059733379916650, 4260524072883785227, 8351659371377110706, 710338300032970720, 5512358883882849029, 15533759462039713914, 14352344066268876816, 16708588250954382269, - 7963995066277321795, 14986230345162551366, 10616366460602472778, 16186943329215681149, 9522855644164647723, 9858336437877021178, 16344942402271072884, 18027353494090590022, - }, - { - 13175608910844763921, 11168387468381338510, 5555873864224342205, 17780559602571640345, 1582669533588472814, 8145133762789622706, 1625372887980692455, 4576809104068554285, - 2900978533555060931, 1749946807863203576, 11705734511931072459, 4446980691693419424, 14437524160594907241, 12795912566640000773, 10400036254697939154, 8356113088668925361, - 8900726473285671992, 890209742292473781, 16059468388719373167, 16577940938542233221, 17381766864962227733, 231915274132518769, 16477817024012878700, 15646021286310268545, - 17511864284462479051, 4391315454785363822, 16633389246499252566, 4290325975494843430, 15912670649662225191, 14172733821603328367, 12709802627494541709, 9648238681838878635, - 4196883387800999444, 11261069840079702254, 7135968036494594517, 14537849011631244070, 1930221875891546479, 3029378442249928630, 6219774718328347890, 5922417028077454069, - 12470404961188516783, 10420863874252801995, 1369334550763670666, 4781925915058005676, 13086538845357988031, 11031029468188842766, 15252022305121561855, 10497770692868889659, - 8808726441417268278, 8201526072266158452, 1136378216494101481, 15014143365043073153, 9752793532008788265, 18423606089906807282, 12708377698545978413, 13697405528655748691, - 12840624483048662115, 13614226123606379619, 15087571995173849344, 1395488309690794621, 7173958427217959878, 1198561064176820332, 16821886260165681626, 10019479169661217935, - 8089335244564816024, 4652396396372834438, 8473523796721514770, 4493469844513366216, 5448577418901909194, 13487502520341193870, 17978888920023381084, 13125222810420128122, - 11369140159803973135, 8391820975236191093, 4865145203995472561, 14899728882581231165, 11169032718524058736, 14532440521453562763, 7464998467530340358, 14981246381757614771, - 1242992129726403300, 2014928170416925311, 6341058783517690890, 11690291498253019630, 15951586247597589423, 14033993236702971559, 16963725291567059464, 15075124616754319226, - 9901328250515532535, 12796305315632203942, 10819069447660403847, 12542238242508661240, 17077777737462854238, 4364294351375777648, 8335244153165894685, 8863541604979427311, - 12648774127830238318, 5576880401343711606, 11786867566889606858, 7421038047404952574, 1037620897405863409, 16680872357246325645, 10443290127564886223, 9718182896013830581, - 15199007294286606824, 10225517367964809030, 12827778649823141649, 16046039393887815140, 284741135347255597, 4015036609703147909, 3902771329647468314, 5128707935422024078, - 16953148044626345363, 5101833106541998042, 7655361325113312133, 15948906743291877728, 11619404274756349415, 7521254459857915559, 14978040810149334918, 18392994517091959591, - 11029520456752683158, 2297291237551781454, 7934683676555855479, 1563954733146546128, 2252805128528536255, 10523375695822939112, 4598652721256818062, 17493379105069761435, - 1717382065475436420, 12444276194160330384, 3605273785657402256, 17503422605669121015, 12066457002913396306, 18109827202111882684, 11555238022219952400, 1993655497207863497, - 14852223665677610379, 4743851404709775958, 8525514757892437524, 10402777181498591725, 17096034999928466604, 4289543339828736175, 4306145672261807290, 15366124999227707930, - 9159996652502914864, 10301349423202296392, 13530090903323000632, 4082840779249202050, 8824726775176314063, 16033767772359951785, 9181204573557660412, 7582747879080399183, - 2747551692916263132, 3151123035150683281, 13938314333309683791, 11970864255483579560, 7894236725861110998, 10515613623232567716, 10445557830757066839, 11155097727742050955, - 511773909731247800, 2463012923954369656, 15859141716591041471, 4940781664379556792, 12435624343534748284, 10278084527750129328, 13178135781125832492, 5930328346313533490, - 9122100956633732655, 4007876149211873275, 8339438668849688737, 7791075492023424820, 1771434463088769532, 17441254147665904787, 9470298561063283873, 16552350513326886351, - 2842235074681099572, 6045955093828210410, 12534027406207583719, 9023829328537353058, 1661393615224515538, 3265308219651631507, 14825441620546235307, 6190486519065164472, - 9569762631377921701, 10341967309273270300, 4697570564829842013, 16684762125903667303, 5281929071085172097, 13027961546412671127, 18398764602992176314, 3872796039504642974, - 3625046733403850478, 18072436321985678348, 12926724831909767455, 17260889391923475120, 2205546675974800411, 4823605748727161314, 11756378320036258430, 12725625915588142865, - 3620769638269480452, 531680461898170, 10213227252513668871, 15446816035938502695, 15189868868814686765, 8689079054027125562, 10767300823767661010, 12185259819280811201, - 2954211398425891878, 887045055614004603, 17024961552904496644, 11183183814128062689, 2275500228939836642, 8454621353771976628, 13706050871317440521, 13152782683288296426, - 5035609627965208105, 6338722048255995169, 11594969687968475335, 5639340633771742838, 6928934109570365590, 11589609913085167707, 18353534295019770247, 6879412911232288750, - 13223374340976842384, 5803903047180226505, 10382392856292138950, 6807712794865416975, 7273350714698980002, 16071615116869102753, 11130104866208195846, 17099222713467268806, - 4288395624114587260, 10186593737807119648, 5970871638851383523, 17274628153010076591, 11083355019391773968, 15571651381840416650, 7269503864920933911, 34314525388851272, - 13518907013113787435, 13799188114963266222, 10949327997049617616, 12851874981220611149, 14245323937486085594, 18324803746062213911, 13224741762315864830, 15910543010675195930, - 10042008593756684008, 6713471518385846030, 10961845838926538977, 855334359173719954, 7598642325962297361, 18006511265377032901, 6844179774752820363, 248341098560552116, - }, - { - 9259451175701532574, 15597985540941612547, 4541553034987877619, 8927802479718285609, 14672230714928802576, 14284617950605306700, 13339970812390782046, 787078889494395850, - 18165439414433063919, 14693282888419586094, 14992616289789993230, 13232208150801553912, 16850347485914337693, 223364064845089224, 7302899015436300563, 4391216311540396088, - 12558388403188680537, 10687978569513354810, 9373570856564649772, 4079327722512691465, 5372437374337150740, 3297421622932790851, 9326853593823854687, 8305371884938201251, - 13121472331750731303, 323745485980480220, 15110308702528119977, 4696302365805118372, 9859094500834571602, 5315656270700787939, 4187063204400651801, 1695695129564818327, - 12817586844019849804, 15425488216915741929, 15293562913126043054, 11770898970765978555, 6806103820345670787, 17789094149138630459, 3807781571713999192, 5823254011289457198, - 10112524230916015604, 13571143908656270599, 6031089010487808103, 5774558171390644848, 1808959243244841573, 14071312530426692155, 9241399242704553402, 9836150050655369231, - 14083007972403535491, 16009534514129505275, 12481249112231139039, 10309390659262581143, 5782517315325366794, 16717384553294759530, 4578392002424884134, 239005024949492645, - 1836857790164349346, 11263074778654917115, 4786985732596838094, 10525445084936097674, 1484357665966453236, 3110871407036679558, 1668700683093601768, 2736269131339849752, - 9249362594190920246, 8088172462140746331, 4080107866285682736, 16205599538438551353, 18312943145606312277, 9100632964181080418, 3969991115337154345, 5340098959750368315, - 12122448407048035645, 2891250339380982359, 12794212052932523400, 7166035112141500392, 15777441312724841162, 4552528682229856831, 2210391301762911476, 16410254680957321386, - 6910044784455706429, 11951245774670922855, 207795885948948810, 3884359690300962405, 4578772752480772344, 2948797025787714138, 16774444535658202808, 1388183483009000463, - 16561979129019905420, 1881862411760441386, 15441950514711322010, 12933020223458438856, 5570341451312029630, 18172638959728259059, 9074261777549091198, 6171200053222754816, - 10126435102176037237, 1545112930055760251, 11563139991870561593, 10766754172364938834, 5116781688621052838, 14471715119500781375, 4724882615229687192, 10031687030722046325, - 15016829467434780812, 6777508689306592732, 3811682306063049290, 11475361222871876387, 6080948654298953274, 11612742274762615033, 5268311600240325047, 9147351973710519861, - 12130203770930472759, 3880998309361490881, 8807462332494735511, 9291388074337055133, 18165312304248982432, 12733144434841535979, 18090195697688236271, 5825342884125782172, - 13034385644450400616, 16498936039876211302, 13019014556329727588, 17911110193068084415, 2034190024798401134, 1526884555531436223, 8108814142164064795, 4075908755148182733, - 6404489603451030675, 16601749455344583377, 12907740667428956072, 8446383351289364752, 698035388979141580, 3593914367189873571, 6744392605914028800, 18168078953147292456, - 14484703498492722699, 6030798911934842161, 15931002029256202288, 13491601992324491240, 8585568434702372483, 9113555433818303018, 6375455514164501736, 1476639189214882947, - 5209683814158663472, 16895526973128357178, 10457488910391635027, 17530003042232440701, 4030542539553991812, 9445656287872984963, 4212489101708176016, 837886727556721620, - 2983790309644332360, 11276772732994425347, 1310621139116895737, 3131558545024164284, 3529698629777893989, 13271773334458143370, 8171825923423406479, 305718858162497191, - 12347543988562572522, 4315642616923374215, 17586477762860427847, 1037334149869395772, 18311071546005132724, 1489505092175764848, 8926409949339059078, 10260307609945070716, - 1253128470325829265, 917180526219408600, 10471425074479693158, 12658678264459355332, 8502334428811982364, 3789675096428271759, 4531393894096863308, 12176495757901795513, - 15081766794595471636, 3944913291385975654, 14507832069904091484, 3624606168811123851, 11476968507677098110, 1056328247986567681, 15246608002200052960, 6566558379177875405, - 652315099041528631, 4287214618428297946, 11730560225433863449, 7935915607867430686, 15979159466809939008, 9209839549459543141, 9501045239358734673, 15490773728258884277, - 14281001444503113096, 9253803478538227873, 3842669056581745692, 18399990656305827164, 11841387504710944221, 16052361836589007383, 831115622826254867, 8219898649601530197, - 2339128600785774471, 1426373723429876004, 3299581455481810683, 16966544600853047157, 8419320331267538738, 8376963013864643226, 1996128805959565963, 2376766970819731241, - 10963611841695254911, 2914831079289063424, 15884256460390936367, 8724520571578171796, 329402220949313078, 8905943304651682982, 1280899166177109409, 6980213851983339340, - 5524321102331478758, 2149164875175284006, 10897639484514200325, 14605181792035620644, 316829907946955098, 13776780818927038502, 18167912441745301047, 16845612593885106452, - 15817940025107036888, 14405005201957074368, 11647077937228007305, 13795438792777593442, 9813339145840642083, 13196196205982926907, 5981408724994946624, 12303812818084690125, - 11821409230485627325, 1934768678832528678, 15798397330147151183, 2089418311766868031, 16206123311846842647, 10276976147555604745, 14858750786699873336, 2500482310681473276, - 9502861285700748804, 12163827978530279544, 9383068907817479934, 5717811606328725851, 12416198015020836733, 15689586164720677894, 14337921697724349521, 9392403465642971279, - 6696074876763293236, 10302972695440286968, 16647054763285662245, 7841147641486000427, 10612636854719975349, 3592516733641215266, 14172459823963607855, 1290213042793222575, - }, -} +const p256Precomputed = "" + + + "\x3c\x14\xa9\x18\xd4\x30\xe7\x79" + "\x01\xb6\xed\x5f\xfc\x95\xba\x75" + "\x10\x25\x62\x77\x2b\x73\xfb\x79" + "\xc6\x55\x37\xa5\x76\x5f\x90\x18" + "\x0a\x56\x95\xce\x57\x53\xf2\xdd" + "\x5c\xe4\x19\xba\xe4\xb8\x4a\x8b" + "\x25\xf3\x21\xdd\x88\x86\xe8\xd2" + "\x85\x5d\x88\x25\x18\xff\x71\x85" + + "\x4d\xd6\xdd\x10\xd4\x46\x00\x85" + "\x7d\x82\x33\xa4\xc1\xe3\x6a\xaa" + "\xd9\x90\x14\x8d\x03\x05\x22\x73" + "\x3b\x3a\xcf\x3d\xe4\x32\xbb\xf6" + "\xa5\xe1\xbe\x61\xd3\x48\x36\x2f" + "\xf8\x6f\x23\xeb\xcb\xd7\x2c\x15" + "\xbe\x2d\x04\x92\x0e\xfb\xa8\x19" + "\x3b\x8a\x5b\x0a\x51\x77\xc5\x78" + + "\x27\xc1\xeb\x4e\x90\x3f\xac\xff" + "\xfb\x81\x7d\x08\x4a\xf8\x27\xb0" + "\x98\xbc\xcb\x87\xdd\x77\xad\x66" + "\x7e\x74\xff\xb6\x3f\x6a\x93\x26" + "\xeb\xa7\x83\xc9\x1f\x5c\x4c\xb0" + "\x1a\xfe\x61\x08\xad\x47\x3e\x58" + "\x8e\xe9\x2e\x1a\x31\x08\x82\x78" + "\x07\xcc\x87\xe5\x29\x6a\xf0\xd5" + + "\xcc\x8d\x91\x46\x0d\xb5\xb0\x74" + "\x73\xc1\x23\xc6\xed\xa6\x50\x46" + "\xf2\x0a\x10\xe8\xac\xac\xda\x0c" + "\x6b\x17\xb0\x41\xf5\x62\x73\x57" + "\xa6\xab\xcb\xe4\x4c\xf2\x96\x2d" + "\x47\xf4\xd6\xfa\x71\x84\x62\x17" + "\x2e\xd2\xdd\xe5\xde\x36\x6c\x6b" + "\x63\xb8\x5a\x4c\x39\x4c\xb1\x84" + + "\xf5\x61\x5c\xc4\xae\x8a\x1b\xbe" + "\x7d\x53\xb9\x94\x9a\x64\xec\x90" + "\x0c\xc2\x76\xd0\xaa\xb5\x1c\x94" + "\xc8\x23\x05\x89\x05\x96\x07\xc9" + "\x10\x4f\xba\xe7\x4a\x9b\x30\xeb" + "\x2b\x88\xeb\xe5\xef\x68\xc5\x73" + "\x68\x1f\x7a\x7e\x87\xa9\x40\x35" + "\x16\xe9\xd1\x2d\xbb\x76\xa0\x73" + + "\x4a\x66\x77\x3e\x37\x47\x39\x40" + "\x3e\xee\x6c\x34\x4f\x74\xae\x55" + "\xad\xa3\x17\x5b\x1a\x96\x0a\xd5" + "\x73\x36\x21\x54\x59\x4b\x07\x13" + "\x4b\xe4\x77\xd3\x20\x62\xd3\x93" + "\xb5\x14\xff\xad\x53\x2b\x9c\x29" + "\x11\x9f\x63\xef\x4c\xd4\x24\xf4" + "\x5f\xf7\x07\x4a\x6d\x91\xc9\xa4" + + "\x4f\x3b\x17\xa0\x4e\x35\x46\x07" + "\xf7\x00\x3c\xd2\x13\x02\xd2\x2b" + "\x08\xbb\x23\x0c\xb5\xaa\x3e\xf4" + "\x03\x3e\x12\xc3\x19\x51\xba\x13" + "\x4d\x9d\x5b\x3f\x30\xd0\x47\x28" + "\xdd\x7b\xa6\x5d\xf2\xf2\x42\x67" + "\x95\x41\xc9\x77\xdc\x3b\x93\xef" + "\x67\x08\x24\x6e\x15\xd9\xed\xea" + + "\x8f\xa7\x99\x94\xd1\x4c\xf1\x27" + "\x55\x34\x9b\x6f\xc5\xb5\x2a\x46" + "\x6b\xfc\x2c\xf0\x2a\xf0\x90\x8f" + "\x0d\x23\x65\xb2\x1e\x89\x63\xb7" + "\x77\x49\x2d\x53\xa9\xa3\x9d\xf5" + "\x15\xba\x9e\xcf\x7d\x32\xe3\x21" + "\xf0\xbb\x60\xbe\x84\x7b\x3c\x12" + "\x76\xdf\x06\x77\xf2\x12\xec\x56" + + "\xe8\x20\x4e\x26\x8f\x6e\xc9\x75" + "\x41\xa8\xa7\x59\xed\xbf\xe6\xab" + "\x00\xeb\xc8\x44\x04\x9c\xc0\x2c" + "\x6b\xe1\xc4\xf0\x80\x30\x5b\xe0" + "\x14\x33\x5f\xa4\x7a\x77\xb7\x1e" + "\xe3\x45\x5d\xce\xed\x7b\xaf\x56" + "\x1a\x2f\xb1\x88\x9a\x01\x6e\x2b" + "\x9b\x5f\x83\xfd\xcd\x59\x66\x08" + + "\xc8\x1e\xc2\x9d\xd1\xdb\x18\x2c" + "\x39\x81\xcf\x0f\x8a\x86\xf9\x98" + "\x49\x0b\x25\x48\xd6\x2c\x7d\x73" + "\x8f\x42\xb3\x24\x47\xc9\x61\xcc" + "\x76\x9e\xdd\x80\x78\x40\x2b\x0c" + "\x08\xbe\x3f\x38\x91\x89\x3a\xc4" + "\xd2\xe5\x9b\x77\x65\x2d\x7d\x5f" + "\xb5\x4a\x3b\xeb\x54\x9a\x71\x78" + + "\x04\xe4\x45\x62\x0a\x26\x7d\xea" + "\xe0\xdf\x7f\x6e\x95\x07\xe4\x9d" + "\xb5\x1a\xac\x8d\x15\xa4\xf3\x1f" + "\x73\x90\x9c\x64\xf1\x90\x70\x3e" + "\x88\x4e\x94\x2b\x61\x85\x76\x1a" + "\xc8\x61\x7f\xe5\x9e\x93\x0f\x25" + "\x3d\x64\xad\x1e\x89\xaa\x0d\x0c" + "\x8e\xb8\x25\xe1\x23\x00\x93\x68" + + "\x68\x77\x69\xd2\xa7\x1a\xb7\x04" + "\x33\x5a\x34\xca\xf5\xde\xde\xab" + "\x5e\x38\x37\xee\x9d\xd2\x09\x24" + "\x56\xe1\x83\xcb\x77\xdf\xe1\x4e" + "\x43\x5b\xbb\x1c\xd9\x12\xac\x0c" + "\x37\x56\x89\xca\xf6\xd2\x0e\x17" + "\x66\x6d\xde\x8a\xfa\x8c\x22\x28" + "\xca\x8a\x23\x53\x95\x7c\xf5\x7f" + + "\x09\xd7\x2e\x4b\x63\x25\xc4\xcc" + "\x0d\xd3\x6f\x85\x69\x67\x35\x0e" + "\x11\x98\x9e\x55\x3f\xd4\xbc\xbc" + "\x59\xb7\x95\x53\xac\x77\x84\x73" + "\x7f\xe1\x0e\xc0\x90\x2b\x75\x35" + "\xe3\xd2\x2e\x74\x90\x83\x74\x68" + "\xc1\x5b\x1f\xbd\x22\x64\xd0\x7c" + "\x97\xb7\xe7\xc9\x69\x87\xc0\xfb" + + "\x4a\x66\xcf\xb0\x5b\xa3\x42\xa2" + "\xe3\x07\x97\x7f\xf7\x48\x6e\x12" + "\x60\x26\x83\xc6\x54\xbf\x17\x17" + "\x2e\xc7\x12\xfd\x32\x73\xae\xfa" + "\x6b\x58\x5d\x99\xb7\x2d\xb5\x27" + "\xc2\x37\x22\x83\x9e\x56\x29\xbe" + "\xdb\xe7\x65\x2a\x3e\x19\xe4\xe8" + "\xbb\x1b\xaa\x2e\xdc\x06\x27\x15" + + "\x5b\x05\x60\xbc\xb7\xd8\xbc\x72" + "\x4b\x7e\xe2\x56\xee\x23\xcc\x03" + "\x70\x93\x81\xe4\x24\x74\x33\xee" + "\x09\xda\xd3\x0a\x43\x0e\xaa\xe2" + "\x5d\xc4\x83\x63\x4f\x52\xb8\x40" + "\x25\x1b\xa4\x42\x54\x35\x66\xd7" + "\x97\x47\x8a\x77\xde\xa6\xef\x64" + "\xf4\xad\x79\x70\x0a\x17\x42\x20" + + "\x80\xfb\xc6\x0b\x65\x0b\x8b\x80" + "\x6b\x2e\xfe\x3f\x75\xe0\x82\x58" + "\x49\xf5\x83\x2c\x7c\x2f\xef\xd5" + "\x23\xb7\x03\x91\x80\x3c\xd6\x54" + "\x9b\x3f\xa2\x52\xd6\x1b\xf1\xf2" + "\x87\x65\x0b\x4b\x19\xc3\x70\x36" + "\x9e\x0e\x58\xb1\x3b\x62\xc4\x55" + "\x20\xe2\xef\x01\xb2\xf7\xed\x64" + + "\x9d\x5c\x3c\xd5\xcb\x1d\x09\x97" + "\x7b\x17\x0a\xac\xb6\x24\x76\xf1" + "\xff\x2d\xfe\x2c\x75\x39\xf1\xb0" + "\x4e\x57\x7a\x6c\x0a\x5c\xa3\xc1" + "\x87\x99\xe7\x93\x46\x31\x7d\x22" + "\x0e\xb8\x9c\xe8\x30\xbf\x75\x05" + "\xbb\x83\x18\x0d\x7f\x24\x4e\x2f" + "\xd0\xc3\x74\x32\x26\x12\xd5\xeb" + + "\x7a\xa9\xad\x56\xc8\x51\x3e\x5f" + "\x3e\x40\x8b\x8f\x4d\x96\xfc\x4a" + "\x79\x29\x2e\x41\xab\x47\xf2\xa6" + "\xda\xeb\x80\x6f\x1b\xbd\x5a\x67" + "\x1d\x5a\x48\x5e\x72\xbd\xa2\x66" + "\x3c\x0b\x4f\x8f\xaf\x5c\x2a\x4b" + "\xba\x7b\x84\x1b\x7f\x92\x26\x26" + "\x4d\x39\x02\x05\xd9\xc7\x6f\x6c" + + "\xe8\x9a\x65\xa5\xba\x12\xa9\xfe" + "\x6e\xa1\xe1\x25\xba\x3a\x36\x68" + "\xac\x41\x2c\x75\x77\x22\x84\xb8" + "\xfc\xc3\x97\x28\x28\x5c\x54\xfe" + "\x6b\x69\x4c\xdc\xe7\xe9\x36\x2d" + "\xc5\x77\xa9\xfb\x4a\x24\x06\x58" + "\xc1\x08\x95\xe3\x9b\x5e\x66\x85" + "\x7b\x59\x12\x6d\x25\xee\x20\xf7" + + "\x31\x7a\x33\xd2\x29\x91\x97\x8a" + "\xdc\x2b\x86\x0f\x8f\x86\x16\x59" + "\xba\x83\xd2\x5d\xd9\x99\x80\x04" + "\x4e\xfb\x5b\xfe\xb6\xee\xd1\xe2" + "\x5d\x00\x84\x78\x41\x1c\xef\x82" + "\xae\xcb\xff\xff\x17\xec\xd4\xa2" + "\x66\x5e\xa9\x8a\x3f\xc5\x61\x91" + "\xd0\xe0\xfe\xc5\xe1\x04\xe1\x5e" + + "\x08\xb2\x35\xc1\xec\x4c\x2e\x56" + "\x7d\xf4\x83\x47\x65\xb2\xe1\x74" + "\x30\x3b\x3f\x5a\x6c\x50\x2a\x6d" + "\xfc\x62\x67\xc1\xf4\xd9\xea\xec" + "\xb9\xe5\x86\xe2\xb2\xd4\x9d\xf2" + "\x61\x3c\xbb\x83\xc0\xad\x0f\x1b" + "\xa4\x29\xac\x7f\x3e\x02\x75\x7a" + "\xa3\x7f\x47\xc9\xf1\xd5\x86\xc0" + + "\x76\x30\x6f\x2f\x35\x11\xc6\x0f" + "\x9a\x2a\x91\xe3\x23\xfa\x9f\xc9" + "\x3d\xba\xf8\xd2\x85\x06\x0b\x6a" + "\xa4\x58\x33\xe9\xe8\x77\xc7\xfd" + "\x04\x5f\x41\x35\xbb\x87\xa7\x94" + "\xa4\xfe\x23\x4d\x6a\x2d\x0c\x64" + "\xb5\x35\x3a\x15\xda\x17\xe9\x9d" + "\x74\xd0\x5c\x5d\x07\x8d\x3e\x79" + + "\x68\x50\xe4\x2d\x53\x76\xf8\xf4" + "\x6e\x1f\x2e\x9e\xe8\xa7\xc7\x37" + "\x69\x40\x58\xa3\xa2\x5f\x82\xd0" + "\x42\xbf\x27\x17\x7c\xea\x2c\xaf" + "\xa9\x85\x47\x9e\xfb\xa4\x60\x03" + "\x4a\x9f\x29\x27\x9c\xa4\xfd\xe5" + "\x71\x2f\xac\x71\x13\x8e\x06\x48" + "\x6f\x66\x77\x90\x7b\x68\xd0\x83" + + "\x19\x28\xd0\x15\xb2\x83\x38\x6d" + "\x35\x9a\xdd\x40\x50\x75\x0d\x6d" + "\x9f\x46\x2b\x1d\xf9\xcb\xd7\x61" + "\x15\x31\xfc\x2e\x2f\x23\x7b\xf9" + "\xc7\xcb\x4b\xb2\x50\xd7\x51\xa5" + "\x56\xe3\xa1\x88\x49\x49\xea\x11" + "\x01\x75\xcb\x93\x31\xf0\x69\x76" + "\x8a\x7b\x73\xca\x5e\xc5\x5d\x59" + + "\x9f\x87\x37\xd8\xac\x19\xa3\xa4" + "\xb0\x67\x6b\xed\x9e\xb4\xc1\x6f" + "\xaf\xf3\xf1\x32\x33\x99\x95\xe3" + "\x2e\x2a\x43\x65\xeb\x42\x67\x96" + "\x28\x62\x96\xb4\xfe\xc9\x8d\x4b" + "\x50\x39\xf4\x43\x12\x63\xcc\x96" + "\xee\x31\xb7\xc9\x59\x88\x06\x12" + "\x68\x99\xf7\x56\xc3\x8d\x94\x7b" + + "\x08\x80\x1f\xed\x32\xad\xe4\x61" + "\x38\x75\xb1\xd8\x7a\x26\xc9\xe6" + "\xfb\xf6\x7f\x85\xeb\xc5\xc7\x1a" + "\x10\xfb\xf2\x55\xa8\xaa\x4b\x99" + "\x18\x80\x24\x1d\xe1\x14\xcf\x84" + "\x08\xc5\x8a\x62\x8b\x89\x39\x5a" + "\xf5\x44\xa9\x5f\x7b\xe9\xfd\x14" + "\xc7\x5a\x2e\xd1\x30\x80\x17\xed" + + "\xb4\xfe\xe2\x97\xf4\x2a\x2c\x04" + "\x13\x73\xbf\xae\xd7\x42\x6a\xd3" + "\xd7\xfd\x4f\x08\xeb\xc9\xd2\x49" + "\x6a\xc7\xf7\x2e\x4b\xa5\x8a\x9f" + "\x70\x5e\x89\x09\xba\xb7\x00\x92" + "\x58\xfb\xb7\xdd\x6f\xc6\xd0\x3b" + "\xbb\x4c\xeb\x78\x08\xd1\x97\x2d" + "\x31\xde\x4b\xd8\x68\x10\x43\x2d" + + "\x1f\xcd\x2c\x17\xb7\x3e\x52\x4b" + "\x92\xa8\xa6\x30\x28\xcb\x23\x73" + "\xeb\x53\xe1\xcf\xc0\x2e\x08\x97" + "\x97\xdb\xaa\xf2\x6a\x6b\x7f\xe9" + "\xa1\x3d\xa8\xd1\x3e\x39\x3d\x1d" + "\x68\x2a\x4b\x80\xc7\xf9\xa7\xa6" + "\x1e\xb7\x0c\x2d\x48\x8b\x68\x4a" + "\x78\x52\x58\x40\x5f\xcc\xb4\xa9" + + "\x32\xe1\x66\xcb\x6a\xb4\x5d\x5e" + "\x80\x58\x92\x0d\x3a\x96\xbe\xf1" + "\xe2\xb9\x17\x03\x27\x70\x4a\x94" + "\x48\x3d\x60\x48\x59\xf9\x66\xe2" + "\x99\x88\x20\x5c\x73\x66\xdb\x98" + "\xa3\x18\xfb\xa2\x47\x24\x47\x90" + "\x9f\x61\x7c\x77\x39\x69\x96\x8a" + "\x1b\xe2\x3b\x2a\x2a\x14\x98\x37" + + "\x43\xb3\x98\x32\xb1\x1c\x24\xb4" + "\xa1\x65\x4f\xb4\x49\x4e\xa1\xa3" + "\xcd\x7a\xc7\x3a\xcd\xd6\xf4\xc5" + "\x3c\xfc\xb6\x52\xb5\x8c\x28\xd0" + "\xbc\x0a\x04\x1c\x2f\x8c\xcc\xd5" + "\x4a\x9b\xbf\x06\x1e\x51\x75\xb6" + "\x41\xa4\x3a\x9b\x37\xda\x67\xd6" + "\x72\x1f\x60\x51\xce\x45\x0d\x46" + + "\x89\xff\x55\x67\x69\x3c\xf7\xe2" + "\xe6\x17\x30\x47\xe7\xf7\x3c\xdd" + "\x0d\x60\xf7\x3c\x9d\x68\xf5\x8e" + "\xb4\x87\xfc\xb1\xf8\xc4\x8d\x94" + "\x99\x32\xa5\x4e\x81\xfe\xe9\xd9" + "\x28\x60\xeb\x98\xa2\x1c\x92\x2d" + "\xfc\x03\x98\x0c\xfd\xed\xec\xfa" + "\x45\x47\x7b\x4d\x91\xe8\x8a\xf3" + + "\xd8\xa3\xe3\xc5\xcf\xfc\xc5\xd8" + "\xbf\xdf\x79\x40\x4c\x90\xfd\xbe" + "\x97\x01\xad\xfe\x58\x6a\x6d\xbc" + "\xa4\x32\x55\x69\x77\x70\x22\x39" + "\xf5\x42\xef\xdb\x6d\x3e\xe2\x09" + "\x08\x99\x0a\x48\x64\x9b\x44\x7e" + "\x40\x2e\x9a\xad\x1a\x9c\x96\x7b" + "\xa4\xc2\x91\x95\x92\xd7\x31\x62" + + + "\x80\x8b\x96\x05\xf3\x96\x6d\xdb" + "\xb9\x73\x9f\x08\x13\x09\x0a\x38" + "\x01\x1e\xc6\xc2\x83\x0b\xa7\x7d" + "\xc7\x38\x9b\x56\x94\x83\xfb\x95" + "\x2f\xfe\xed\x80\x12\x65\x3c\x9a" + "\x82\xaf\xae\x8f\xb9\x6b\x72\x8f" + "\xf8\x4b\x42\x78\xa0\xa4\x10\x80" + "\x70\x49\x84\x0e\x44\x20\x67\x29" + + "\x2a\xd6\x2a\x7a\x81\xcb\xc5\x63" + "\x54\xff\x62\xac\xb9\xb6\xf2\x7e" + "\xb5\x9d\xad\xb3\xa4\xbb\x49\x37" + "\x17\xa6\xd5\x46\x2c\x1f\x31\xad" + "\x6d\x3b\xff\xc2\x87\x80\x7a\xb7" + "\xff\x34\x78\x36\xf3\xea\x6f\xb4" + "\x38\xb1\xd6\x75\x6d\x26\xaa\xf8" + "\x88\x81\x00\xec\x20\xd3\x38\xfa" + + "\xc6\x16\x69\x4e\xfc\xaf\xf2\xc0" + "\xda\x42\x18\x81\x57\x49\xb9\x6f" + "\x57\xd1\xb4\x24\xb6\xbc\x34\x60" + "\x90\xfb\x2e\x99\xc7\xfd\x2e\xde" + "\x87\x3c\x79\xac\xce\x7e\x6f\xd6" + "\xcd\xfd\xc6\x7d\x26\x26\xf0\x02" + "\x01\xc5\xa1\x9a\x5c\x23\xd3\x90" + "\xf0\x66\x46\x2b\x96\x94\xe4\xf6" + + "\xfc\x46\x69\x69\xfa\x8f\x6d\x48" + "\x6d\xa5\xcb\xb9\xd8\xc6\xfb\x50" + "\x15\x5a\xf3\x90\x3e\x42\x3d\x7e" + "\x2c\x96\xdd\xc0\x95\xa1\x3d\x7c" + "\x8b\x5d\xfd\x3c\xb0\xfd\x73\xe6" + "\xa5\xfc\x9d\x88\xc2\xb7\x04\x07" + "\xaa\x05\x23\xf5\x1f\x58\xce\xf6" + "\x53\x5e\x4d\x91\xeb\x49\x9d\x39" + + "\x53\xd4\x92\x7b\x36\x7c\xc9\x24" + "\xc0\x26\x9a\x24\xa2\x71\xc2\xd2" + "\x39\x4a\xd1\x89\x2b\x4b\xeb\x60" + "\x05\x80\x2e\x43\x20\xde\x98\x11" + "\xd9\x80\x9b\x79\x75\xea\xab\x9e" + "\xe5\x6a\x82\x8f\x2b\x0c\x6e\xab" + "\xec\x61\x00\xd1\xed\x4e\x00\xca" + "\xd8\x4f\x9c\xe9\x39\xf4\xa9\x31" + + "\xcd\x93\xc2\x6e\x6d\x49\x0a\x38" + "\xf5\x51\x70\x8e\xa7\xbd\x3d\x73" + "\x0a\x14\x49\xb8\x8d\x38\x7e\x03" + "\xf6\xdb\x46\x59\xb0\x32\x4b\xee" + "\xd1\x68\xe3\xca\xa9\xfd\xc4\xb1" + "\xf3\xb2\xb0\xfd\xb0\xa7\x01\x50" + "\x6e\xc4\x3a\x2e\x74\x93\xf5\x6d" + "\x56\xe6\xb3\x39\xf2\x75\xf6\x4a" + + "\xeb\x26\x78\xd6\x44\x7c\x0e\xb2" + "\x37\x96\x37\xac\xcf\xd3\x12\x12" + "\x5d\x3a\xe0\x7d\x87\x67\x4f\x61" + "\x26\xaa\x2b\x80\xfc\xa2\x38\x75" + "\x15\x24\x25\x9d\xa1\x37\x3c\x13" + "\x87\xb5\xb4\x6e\x50\x90\xb3\x7d" + "\xd9\xd1\x49\x4c\x57\xd7\x40\x5d" + "\xba\xc4\x01\xa8\x99\x6b\x12\xf1" + + "\x96\x92\x94\x39\x10\x81\xe3\x44" + "\xb5\xb1\x1d\x36\x7b\x82\x63\x5b" + "\xf5\xaf\x6e\x20\xed\x23\x53\x3e" + "\x90\x42\x1f\xc2\xd2\x70\x23\x94" + "\xa1\x85\xd9\xe0\x2e\xaf\xca\xf2" + "\x6d\x84\x39\x72\x4b\xc6\x2c\x19" + "\xf8\x12\x63\xae\x47\x8f\x0b\x7c" + "\x08\x01\x62\x96\x91\x1f\xc6\x7d" + + "\x47\x11\x96\x70\x96\xc9\xff\x40" + "\x8c\x2c\xc2\xc7\x42\x68\xe0\x79" + "\xbd\xbb\x97\x1a\xcc\xab\xf1\x63" + "\x88\x03\x73\xf0\xd0\x74\xea\xe9" + "\x66\xff\xef\xd9\x4d\x50\xc3\xa6" + "\x15\x20\xe0\x57\x38\xee\x54\x53" + "\xfa\x40\x70\x6d\xfe\xd7\xfe\x3b" + "\xac\x82\xca\x99\xcc\x95\x2c\x69" + + "\xe9\x7d\xda\xc2\x5b\xfb\x30\xb8" + "\xbe\xd3\xf8\x0f\xdf\x43\xe6\xd0" + "\x41\x96\x8a\x18\xba\x77\xee\x31" + "\x02\xd5\xf6\xbc\xaa\xa3\x8a\x4e" + "\x0f\x11\x49\x9a\x32\x65\xfb\xf9" + "\x20\xb2\xd6\x2d\xf6\x17\x83\xd1" + "\x5a\xea\xc3\x52\x41\xed\x3c\x7e" + "\x4a\x9c\x57\x7d\x14\x6a\x29\x0d" + + "\x58\x6c\x2f\x94\xca\x5a\x8b\x68" + "\x39\x94\x5d\x49\xc5\x89\x27\x6f" + "\x1d\x50\x4c\x50\x0c\xdb\x4d\xd5" + "\xa7\xe3\xac\xbc\x0f\x4d\x6a\xf1" + "\xeb\x41\x6a\x05\x6f\xbc\x6f\xb7" + "\xc5\xd6\x5b\x82\x55\xc2\x88\xe2" + "\xd3\xe2\x42\x0f\x96\x77\x03\x95" + "\x44\x7b\xb5\xde\xe3\x47\x3c\x9a" + + "\x17\x37\x4c\xed\x3e\xa5\xd6\x35" + "\xa3\xd2\x0e\x3d\xcf\x40\x82\x9f" + "\xa5\x3a\x54\xe5\x05\x4d\x0d\x8c" + "\xb4\xb4\x33\xdd\xfb\xbb\xd5\x45" + "\x8e\xd2\x7f\x13\x73\xcc\x04\xfa" + "\xfd\x3f\x3b\xc7\xef\xc6\x2a\x86" + "\xf2\x1e\xf5\x31\xf5\xf9\x3f\x40" + "\xa2\xf5\x73\xbc\xfc\xe0\xd5\x34" + + "\xb0\xfa\x59\x95\x21\xef\x9a\x2c" + "\x2d\x2f\x32\x62\xce\x61\x33\x83" + "\xf9\x0d\xba\x72\x2b\x5e\xfd\xd3" + "\x0a\x8c\x2d\x9d\x32\xe7\x85\xfc" + "\xd4\xb8\x5d\xf1\x75\x46\x23\xce" + "\x9a\x3f\x2d\xf5\x2e\xac\xf7\x6a" + "\x92\x65\xbf\x3d\x69\xf1\x55\x2d" + "\x38\x8e\x09\xd7\x6c\xcc\xc9\xb1" + + "\x4f\x3f\x91\x08\x20\x68\x52\xf2" + "\x95\x3d\xc9\xea\x61\xed\x20\xea" + "\x6c\xb2\xa6\x6c\xb4\x38\xed\x51" + "\xb0\x27\x43\xea\xbc\xdc\x62\x86" + "\xaa\x2a\x5d\x72\x5c\x29\xaf\x6d" + "\xda\xdc\x52\x8e\x2f\x75\xd2\xba" + "\xcc\xda\x17\x0b\x21\xe7\x10\x22" + "\x32\x82\x1e\xd5\x12\x79\x7f\xa3" + + "\xeb\xca\x40\xd5\x0c\x16\x00\x2a" + "\x88\x27\x1a\xa4\x5e\x14\x66\x6f" + "\xfa\x11\xc8\x51\x33\x1c\xc8\xf9" + "\x03\x54\x6f\x64\x0f\x8e\xe5\xee" + "\xe3\xfa\x18\xfc\xef\x20\xf9\x8d" + "\x6c\xea\x71\x09\x5e\x42\x23\x79" + "\xa7\xae\xa0\xcb\xb2\xdc\xe3\xe0" + "\xfc\x2d\x85\x4a\x5e\xaf\x1d\xbf" + + "\xdd\x3a\xcc\x44\xe1\x81\x70\x4f" + "\xcf\x82\xbe\x87\xd6\xa1\xff\xd5" + "\x72\x64\xdd\x0e\x6c\x0b\x89\x89" + "\x63\x78\xd1\x3e\x1a\x6e\xa2\xad" + "\xaa\x3c\x48\x63\x15\x27\x6f\x27" + "\xfd\x77\x60\x2f\xd9\x4c\x92\xe6" + "\x3c\x6e\x46\x0a\x98\xfe\xa7\x05" + "\x1f\x2d\x90\xb1\xb0\x94\xc7\xf1" + + "\x1c\x9c\xf0\xaa\x57\x63\x06\xee" + "\xd2\x76\x27\xab\x8d\x87\x53\x1c" + "\x4a\x32\x4e\xae\x4c\x72\xb5\x2c" + "\x52\x83\xfe\xe0\xad\x7c\x30\x13" + "\x96\x56\x39\x54\x78\xbb\x02\xef" + "\x31\x4d\xb6\xb3\xf3\x2d\x59\x2c" + "\xeb\x6a\x8b\xbc\x1a\x95\x05\xf0" + "\x5e\x27\x91\x6b\x82\xbe\x60\x57" + + "\x2c\x04\xa8\x82\x88\x36\x21\xe5" + "\x98\x82\x27\xcd\xaf\xcf\x31\xd9" + "\x40\xa7\x97\xf5\xe0\x0a\x9a\x06" + "\x7c\x10\x59\xeb\xf3\xb3\xdb\x0a" + "\xb8\x8e\xaa\x5e\x1e\x95\x3e\x98" + "\x78\x8e\xb4\x11\xb5\xa8\x63\xe6" + "\xc5\xf2\x03\x8a\x0d\xcc\x31\x16" + "\xe2\x71\xe2\x11\x1e\xc1\x77\x75" + + "\xf6\x8f\xa0\x74\x41\xbf\x5d\x08" + "\x0b\x46\x76\xa5\x40\xce\xba\x80" + "\x49\xba\xc1\x27\xcf\xcb\x04\xd2" + "\x49\x69\x80\xe4\x32\x2f\xd1\x64" + "\xe3\xe8\xdf\x01\x22\x22\xd4\xcd" + "\xd4\x83\x5c\xd0\x6e\x3c\x5b\x3b" + "\xc0\x00\xeb\xfc\xb3\x81\xc0\xb2" + "\x69\xd7\x67\xdd\xec\x3e\xc2\xe2" + + "\x90\x9a\x36\x08\x5c\x38\xb2\x33" + "\xf8\xb4\x0e\x19\x9b\xc5\x90\x29" + "\x80\xac\x8e\xc6\x45\x61\x9a\x81" + "\x14\xa0\xc4\x2e\x62\x6d\x78\x7a" + "\x8d\x3a\xac\x20\xbe\xad\xfa\x33" + "\x30\x2d\xba\x5a\x81\x17\xa2\x31" + "\x65\xf5\xa4\xdb\x42\x27\x9d\x20" + "\xbb\x0f\xaa\x55\xe3\xe9\x2c\xdb" + + "\xad\xe1\xcc\x63\xb5\x24\x4f\x6f" + "\x77\x3a\xb4\x9f\x2a\x67\x66\x51" + "\x1f\x9d\xc7\x4f\x78\x40\x78\xbb" + "\xf5\xbb\x74\xf7\x6c\x1a\x82\xb3" + "\x41\xf4\x02\xdf\xce\xd4\x7b\xa2" + "\xdf\x2a\x4e\xb8\xb9\x4e\xfa\xc5" + "\xde\xcd\xb7\xf0\xd7\xcb\x0b\x91" + "\xec\x1e\x5a\x2e\x48\x40\xe6\xb7" + + "\xdf\x84\x89\x16\x4b\x33\xef\x8c" + "\x38\x96\x87\x33\x17\xce\x1d\xe8" + "\xf0\x20\x37\x26\x9c\x94\xe6\xf6" + "\xec\xcb\x93\xf5\xaf\xfe\x56\x5c" + "\x84\x8c\xe5\xfd\x01\x56\xff\x8b" + "\x14\xb3\xcc\x2e\x17\x41\xe2\x74" + "\x78\x8a\x9a\x4c\x61\x1b\xf0\xbc" + "\x68\x98\x4c\x54\x5e\xe3\x33\xa2" + + "\xfb\xd8\x65\xc7\xc9\x4b\x93\x54" + "\x1e\x75\x0b\xb3\x71\x65\x96\xc1" + "\x17\xc8\xa7\x91\xcf\x2f\xfd\xc4" + "\x88\xc8\xb1\xdc\x7e\xbc\x6f\x24" + "\xff\x1b\xcc\x59\xfd\x4f\x30\x27" + "\x11\x58\x9c\xe5\x8d\x4d\x5c\xc3" + "\x21\x99\x1f\x40\xb9\xff\x63\xd8" + "\x61\x69\x80\x2e\x2e\x48\x14\x5b" + + "\xf1\xaf\xd7\x8b\xf3\x6b\x15\xb3" + "\x46\xb1\x81\x1d\xcb\xe4\x5e\x1b" + "\x15\xa9\x28\xd6\x41\xac\xa1\x7b" + "\x9e\x69\x89\xfd\x9c\x8f\x3a\x8f" + "\xe7\x8b\x74\xa0\xc9\xb9\x29\x73" + "\x1f\x62\x2e\xa9\x95\x1c\x39\x1d" + "\x37\xa8\x10\x4d\x21\x6b\x1e\xe5" + "\x35\xb4\x47\x49\x3a\xf5\x55\xd2" + + "\x2b\x88\x20\x1f\x5a\x04\x37\xc1" + "\x0c\x05\x7a\x9b\xf4\x16\x4b\x92" + "\xaf\x94\x66\xea\xf5\x26\xba\x8a" + "\x3e\x6a\x82\x69\x54\x28\x06\x29" + "\x27\x16\x8c\xb0\xcb\xd1\xf6\x2e" + "\x34\x0c\x8c\xc5\x84\x38\x31\x61" + "\xb4\xf1\xf6\xd8\x99\xc2\xc7\xa5" + "\x87\x9f\x3e\xff\xc0\xae\x5a\xcd" + + "\xe3\x8e\x78\xf1\x04\x9e\x66\x07" + "\xa2\x38\x69\xa8\xaf\x27\x4f\xc1" + "\xc0\x01\x3a\xe9\x34\xa3\x47\x8b" + "\x08\x68\x36\xd9\x38\x74\x62\xff" + "\x65\x59\x2a\xca\xd8\x85\x09\x7a" + "\xb3\xb9\xe9\xd6\x42\x55\x9a\x3d" + "\xe8\x72\xf9\x4c\x0b\xb8\x3e\xc2" + "\xfd\x72\xdf\x4f\xbb\x33\x1c\x5c" + + "\x5a\xd4\xb3\x4c\xdd\xbd\xca\x3b" + "\xa1\x67\x7d\x41\x6b\x4d\x38\xa9" + "\x54\xfa\xa8\x6a\xba\x5b\x9f\x65" + "\xcb\xf0\x0e\xcd\x21\x76\x93\x04" + "\x47\x23\x8b\x51\xf5\xb2\x80\xd4" + "\x80\x87\xe3\x1f\x1e\x97\x3c\x15" + "\x38\xb5\x07\xfe\xed\x08\x71\x15" + "\x29\x01\x11\xab\x03\x80\x0d\xca" + + "\x08\x61\xa8\x74\xd4\x58\x4a\x0c" + "\x90\x5d\x4c\xee\x8f\x8a\x04\xf8" + "\x80\x4c\x6d\xe8\x24\xc9\xc7\xe3" + "\x60\x1e\x6a\x05\xde\x89\xc8\x28" + "\x40\xa0\x14\xb2\x2e\x66\xe2\x57" + "\x47\x03\xe1\x37\x98\x8e\xc4\xe8" + "\x8a\x74\xac\x80\x62\x28\x74\x87" + "\xf2\x06\x6b\x18\x22\x40\xc2\xf1" + + "\xd7\x51\x4e\x09\x76\x33\xbb\xd0" + "\x7a\x87\xcd\x42\x22\xcc\x10\x51" + "\xc6\x97\xd1\xcf\x29\x57\xd6\x7b" + "\x71\x31\xca\x8a\x05\x94\x29\xf2" + "\xa5\xae\x55\x21\x15\x75\x84\x07" + "\x54\x1a\x82\x9a\x48\x2d\xf1\x84" + "\x5c\xaf\x37\x37\xf9\xc1\x8c\xb1" + "\x45\x58\x48\xba\xe2\x0c\xba\x4f" + + "\x0a\x04\x74\x5f\xc3\xd4\x2d\xac" + "\x57\xc9\xea\xfc\x71\xeb\x9a\x40" + "\x23\xec\xc4\x55\x82\xd7\xba\x4f" + "\xec\x76\x7b\x8a\x61\xed\x59\xb3" + "\x60\x4a\x6f\xed\x26\x49\x74\x12" + "\xe3\x2d\x91\x4b\x7f\x8d\x1e\xe2" + "\x59\x5a\x70\xfc\x59\x5a\x57\xe2" + "\x0e\xbc\x2d\xed\xde\xd4\xf1\x72" + + "\xd2\x72\x97\xb9\x5a\xd8\x79\x96" + "\x25\x1c\xcd\xdd\x7c\x71\x69\x82" + "\x77\xc3\xdc\xeb\x45\x20\x97\x50" + "\xdf\xc9\xe2\x6e\x83\xde\x13\xed" + "\x7a\x21\xa7\x50\x04\xf5\x39\x9f" + "\xb6\x07\xe0\xae\x41\xa9\x3b\xd3" + "\x9a\xec\x2b\xfc\x90\x71\x4f\x91" + "\x87\x24\xd9\xb0\x4e\x25\xd2\x70" + + "\xb8\x26\x79\xeb\xb9\x24\x2b\x3d" + "\x09\x55\xbe\xcd\xb3\x8c\xf8\xbf" + "\x0b\x64\xdd\xe4\xaf\x99\xf3\xd0" + "\x45\xed\x76\x2f\x30\xe1\x5f\x3c" + "\x3d\xfb\x64\x37\xf4\x62\x35\x6f" + "\x2d\xb6\x51\x31\x18\xf3\x5a\x7b" + "\xf3\xe5\x9c\xd7\xc7\x0b\xbd\xd5" + "\x0f\x89\x66\xec\x20\x6b\xaf\xfd" + + + "\xa2\x35\x4b\xab\xe5\xb0\x72\x67" + "\xcf\xaa\xee\xf5\x01\x60\x8b\x1d" + "\x80\x95\x5b\x79\xe4\x7c\x8f\x72" + "\xda\x81\xfb\x41\x2a\xed\x20\x4a" + "\xe6\x01\xec\x4f\xd4\x5c\x68\x9f" + "\xad\x50\xff\xa7\xcc\xdd\xd7\x3e" + "\xfd\x97\x2d\x0c\x64\xd2\x0f\x46" + "\xf9\xf4\x82\xeb\x26\x14\x24\x3a" + + "\xd5\x21\xd7\xd5\x62\x98\x00\x80" + "\x82\xa1\xd3\x5b\xa3\x57\x33\x0c" + "\xa4\xcd\xa2\x7a\x3b\xa8\xf3\x27" + "\x85\x30\xf8\xf6\x4e\xe7\x8a\xb5" + "\x6b\xad\x6d\x2e\x81\x1a\x91\x2a" + "\x5b\x6c\x3d\xf4\x51\x60\x28\xde" + "\xd8\xc4\x96\xf9\x41\xcc\xdc\x4b" + "\x4e\xe2\xe1\x0a\xc0\x2e\x31\xe7" + + "\x70\xee\xe6\xaa\xfe\x68\xaf\x6f" + "\xc9\xb0\x02\x56\x15\xcc\xf4\x78" + "\x2a\x05\x94\x6e\xa8\x21\x33\x7e" + "\x80\x5d\x4d\x73\xd6\xa0\xb3\x2f" + "\xba\x43\x5a\xb2\x3b\x8f\xb9\xf3" + "\x51\x29\xee\x19\x31\x80\xbf\x30" + "\x2a\x61\xb0\x21\x33\xe4\xfe\x7f" + "\xd0\x21\xb8\x2e\xe4\x75\xf7\x12" + + "\xb3\x85\x64\x6e\xe7\x12\xd1\xf8" + "\xf8\x52\x1c\x77\xdb\x24\x3e\x4d" + "\x6d\x2f\x4a\x68\x41\xee\xe3\x48" + "\x51\x55\xd9\x21\x7d\x95\x61\x71" + "\x6c\x2a\xb1\xcd\x83\x12\x63\x19" + "\x64\xe1\x50\x2e\x82\xa8\x3f\xbf" + "\x73\xcc\x66\x31\x63\x4b\x25\xf6" + "\x38\xcc\xe8\xae\xae\xa7\xef\x3a" + + "\xa9\x29\xa9\x37\x80\x00\xf7\x46" + "\xbd\xc6\xfe\x19\x8e\x1a\x60\x65" + "\x62\x8b\xab\x12\xdc\x5e\x7f\x53" + "\xcf\x90\x59\x5e\x95\xcd\x97\xe4" + "\xf9\xb2\xa5\x9a\x7f\x38\xcd\x2f" + "\xe8\x8f\xb7\x67\xff\xa3\xfa\xe5" + "\x30\x5e\x5d\x29\x8d\x53\xcf\x1b" + "\xec\xa7\x13\xa8\x39\x32\x57\x3a" + + "\x09\x24\x7c\xd1\x6b\x28\xf5\xe9" + "\x9b\x4d\x26\x63\x93\x47\x4e\x2c" + "\x0f\x88\xf6\x17\xb1\x42\x70\x17" + "\x43\xee\xe1\x4c\xc8\xe2\xb7\x39" + "\xa9\xf4\x96\xd0\x22\xe7\xc8\xce" + "\x97\xe6\xd5\xbe\xcb\xae\x61\x68" + "\x11\x19\x23\x6c\xf0\x53\xd1\xc2" + "\x7a\x53\x90\x28\xb8\x42\x2f\xcc" + + "\xb4\x17\xa9\xd0\x51\xcb\xe2\x33" + "\x31\xf9\x99\x48\xf3\xa3\xcf\xc2" + "\xb6\xf6\xa2\xe9\x4b\x4f\xc9\xb2" + "\xb7\x62\xa1\x7c\x81\xb1\x07\x97" + "\x0d\xb1\xf8\xd5\x72\xa1\x02\xb6" + "\x2a\x54\xd4\x4f\x35\x78\x30\xfd" + "\x92\x69\x99\xdd\xdd\x26\xf2\xee" + "\xe1\x15\x0a\xeb\x89\xa9\x1f\x22" + + "\xfd\xf9\x36\x3b\x62\xfe\xb0\x79" + "\xc0\x9f\xe1\xfd\x23\x3b\x54\x26" + "\xef\x82\x84\x95\xa0\x64\x6e\x13" + "\x25\x58\x09\x9b\x71\x37\xf6\x23" + "\x2e\x14\xa1\xb6\x96\xd5\xcf\x14" + "\x0b\xac\x5a\x33\xc6\xaa\xa6\x5e" + "\xd5\x1d\x08\xf3\xbd\xe8\xa0\x86" + "\x2a\xc1\x3d\x00\x79\x9d\xb8\x5f" + + "\xa3\x32\x11\xde\x77\x86\x62\x73" + "\x47\x88\xa8\x2f\x64\x7e\x12\x75" + "\x60\xe6\x49\x5b\x30\x7a\x2f\x19" + "\xa9\x6a\x43\x11\xfe\x3c\x06\x1a" + "\x89\x01\x71\x4b\x57\x14\x00\x72" + "\x8d\x37\x57\x2a\xde\x46\xa9\xfa" + "\x66\x30\x1c\x19\x63\x5c\x49\x5c" + "\xdb\xb4\x7d\x6b\x65\x7e\x4b\x2b" + + "\x13\x04\x63\xd0\x7a\xd2\xe3\xa4" + "\xeb\x56\xfa\x19\x82\xe3\x70\x57" + "\x66\x06\x4c\x75\x7a\xcf\x65\x44" + "\xf3\xc5\x69\x61\xd2\x61\x91\xfe" + "\x48\xe3\x0e\xdc\x22\x27\xf6\x5d" + "\x54\x04\x89\x29\x6a\x59\xc6\x9c" + "\x2a\x32\x5d\x9f\x18\xd6\x43\xf0" + "\xe9\xe3\x1e\x18\x7a\x95\xce\xb4" + + "\xed\x62\x5c\xfe\x49\x0a\x19\x08" + "\x3d\x18\x91\x36\x3d\x54\x57\x2c" + "\x23\x48\x04\xa9\x8b\x31\xee\x75" + "\x58\x8f\xf2\xae\x9e\xe0\x0c\xd2" + "\x66\x4a\x8a\x84\x50\x3d\x61\x10" + "\xfb\x2e\xcf\x9f\xa8\xa1\x98\x4b" + "\x27\x64\xfc\x98\xd9\x1e\x5f\x41" + "\x50\x2b\x85\xe3\x56\xbb\x6a\x08" + + "\xd4\x34\x2e\xf7\x3a\xc3\x15\xf6" + "\x35\xec\x0e\x11\x40\xea\xd9\x0b" + "\x4e\xa3\xde\xc1\x5b\xbc\x12\x1c" + "\x99\x46\xae\x49\xc9\x84\x65\x68" + "\x42\xb9\x97\x8c\xd3\x95\xad\x13" + "\x62\x75\x5c\x4e\x1a\x56\x09\x46" + "\x89\x7f\x73\xf2\xae\xa4\x94\x9e" + "\xb6\x78\x1c\x37\xc6\x94\x75\xf5" + + "\xde\xa9\xed\x19\xd9\x8c\x76\x5a" + "\xd2\x51\x2a\x8e\xf4\x06\x32\x6e" + "\xef\xa3\x78\x86\xc0\xe8\x56\xd3" + "\xc9\x91\x3f\x54\x6d\xd3\xf8\x93" + "\x43\x67\x08\xa4\xf4\x31\xf2\xfe" + "\xc9\xc6\x48\x91\x11\x9a\x37\x4d" + "\xce\x32\x82\xdc\x1d\x58\xb5\x00" + "\x4b\x21\x02\xd7\xef\x72\x7a\xa6" + + "\x92\xe8\xb4\x17\xf6\xa9\x45\x61" + "\xf1\x9f\x22\x5f\x27\x02\x64\xfe" + "\xa3\x6b\x04\xdc\xa8\x3e\xb0\x6d" + "\xcc\xda\x51\x03\xd6\x73\xc8\x71" + "\x5b\x7b\x94\xc2\x37\xe3\xae\x4b" + "\x80\x43\x8b\xb0\xc7\x85\x08\x90" + "\xb9\x79\x45\xc8\x61\xa6\x1e\x1f" + "\x18\x78\x01\xa5\x93\xbb\xdd\xcc" + + "\x80\xb4\x9f\xcf\x3d\x88\x4d\x55" + "\x4d\x9a\xfb\x0d\xc5\x71\xca\x76" + "\xea\x40\x42\xe0\x2b\x14\x51\xc2" + "\x99\xfc\x7a\xfa\x3d\xa6\x9b\x89" + "\xa3\xcd\xbb\x9f\x12\x5b\x94\xed" + "\xcc\xa4\x99\xa2\x28\xd5\x4d\x3c" + "\x92\xc0\x63\x8a\x09\xb6\xe8\x68" + "\x1b\x62\x40\x3f\x6c\x0a\xf5\xec" + + "\xe3\x9e\x77\xe3\xfc\x65\x01\x0f" + "\x9e\x5d\x49\xbd\x9d\x7f\x0e\xe0" + "\x7a\x4e\x28\x20\xa2\xef\xa4\x1f" + "\x19\x62\xac\x47\xde\xba\x64\x45" + "\x8e\x8e\x70\xc4\x2a\x31\xe6\x90" + "\xdf\x9a\x1e\xa7\xfb\x25\x57\x4f" + "\x9f\x4b\x68\x3d\xae\x55\x5f\xe9" + "\x15\xb4\x94\x1e\xb1\xcc\xf7\x47" + + "\x01\xc2\xad\xa8\xbe\x48\xfd\x50" + "\xa8\x06\xdf\x40\x00\x18\x18\xce" + "\x22\xce\x82\xde\x42\xca\x07\x6c" + "\x1a\x76\x24\x5a\x51\x6c\x64\x23" + "\x2f\x39\x68\xb2\xf8\x91\xcf\x46" + "\x86\x14\x81\x81\xff\x57\xb7\xe4" + "\xa0\x02\x61\xd2\x0b\x57\xdd\x94" + "\x80\xdf\x65\x3e\x2d\x4d\xc3\x2d" + + "\xd3\x56\xde\x56\x44\xaf\xfe\x18" + "\x22\x79\x02\x61\xe8\x68\x95\xb3" + "\xdc\x58\xa4\x28\x5c\x68\xb8\xa2" + "\x17\xa8\x95\x62\x6c\xbf\xa8\x41" + "\xdc\xd1\x98\xca\x74\x40\x29\x7b" + "\xbe\x13\xe0\xb3\x59\x82\xc4\x94" + "\x56\x52\x4f\x2c\x24\xd5\x2e\xb4" + "\xec\x9f\x7c\xda\x50\x89\x8e\x30" + + "\x1d\x54\x6c\x31\x83\x70\x02\x46" + "\xcc\xab\x9e\xd3\x6b\xbc\x05\x7f" + "\xdc\x0c\xc2\x60\xa1\xfa\x37\xb8" + "\x06\x9d\xd3\xac\x1a\xf3\x8b\x4f" + "\x51\x20\x51\x00\x95\xdc\x31\x83" + "\xac\xa2\x2a\xaf\x62\xf4\x74\x53" + "\xa3\xb1\x2a\xf3\xb4\xd9\x73\x76" + "\xfc\x49\x4f\xd6\xac\x51\xe1\xa6" + + "\x81\x65\x94\x8d\x1b\x85\x22\x73" + "\x12\xa0\xf4\xbd\x33\x31\xd1\xf0" + "\xe0\xda\x84\x65\x69\x0f\x51\xa3" + "\x6d\x6c\x9f\x3c\x71\xc1\xa7\x03" + "\x1a\x38\x75\xe4\x38\x7f\xe9\x5b" + "\x34\x33\x82\x85\x22\xa4\x1b\xca" + "\xda\x7d\xe1\x0b\xc7\xc5\x3c\xf8" + "\x0f\x8c\x91\x0b\x94\x14\x8b\x15" + + "\x05\xf7\xa5\xdb\x88\x8a\x18\xb7" + "\x8b\xd8\xfa\xa1\xa6\xfc\xfe\x5c" + "\x95\x85\x8e\x33\x04\x88\x2d\xed" + "\x81\x09\xb4\x7e\xf8\x0b\x23\xc0" + "\xc7\xf7\x87\x4b\x78\xf1\xd1\x3e" + "\x2a\xd0\x9e\x7f\x76\x60\x1d\x9d" + "\x5b\x8d\x3f\xf2\x8b\x26\x90\x22" + "\xb9\x68\xd3\x86\x35\x4c\x90\xad" + + "\x82\xd6\xfb\x2a\x05\x96\x64\xdc" + "\xb1\xb0\x37\x16\x13\xfb\x08\xac" + "\x9d\xf3\x84\xa1\x88\xd4\x9f\xdf" + "\xb2\x25\xe3\xac\x23\xbc\xc2\x1f" + "\x84\x9a\x6c\xbd\x36\x3b\x87\x29" + "\x9d\x52\xf8\x3c\x15\x11\x2c\x46" + "\x2d\x21\x55\xc5\x0d\x37\xe0\xb3" + "\xc6\xec\xaa\x89\x75\x3f\xf8\x31" + + "\x99\x5a\xde\xb7\x31\x74\xdf\xb1" + "\x3c\x87\x95\xf2\xe6\x8e\x52\xfb" + "\x95\x3c\x30\xcc\x0f\x50\xa1\xec" + "\x60\xb7\x33\xce\x97\x05\x39\xdb" + "\x36\x97\x76\xe4\x86\x14\x96\xd6" + "\xa2\x9d\x33\xc3\x28\xe4\x45\xd2" + "\xce\x6c\x10\xfa\x41\x7f\xca\xf5" + "\xdd\xac\x80\x70\x32\xb1\xed\x37" + + "\x69\x6b\x2e\x52\xe5\x77\x3a\xda" + "\x18\x6c\xcd\xbb\xc3\x08\xc9\x69" + "\x56\xfd\x24\xd9\x48\x9e\x1b\x1f" + "\xf7\xb3\x4b\xaa\x36\x4e\xc6\x37" + "\x7d\x8d\x47\xee\xdf\xdb\x4f\x5a" + "\xa0\xf7\x93\x01\xbc\xc8\x75\xba" + "\xdf\x16\xcd\x56\x84\x1e\xbc\x84" + "\x51\xd1\xfa\x46\x08\x8f\xb0\x1f" + + "\x36\xbb\x6b\xb2\xef\x01\x33\x29" + "\xfa\x4d\x64\xa9\xf8\xca\x68\x45" + "\x0c\x3c\x0c\x3e\x05\xae\xac\x0d" + "\xa8\x51\xa6\xec\x02\xd5\xa6\x2b" + "\x0b\x61\x04\x60\x68\x59\xbd\xe3" + "\x45\x72\x2b\x28\xf6\x6a\x07\xc2" + "\xa4\xe9\x94\x1e\x4a\xf2\x61\xae" + "\x63\xf1\x76\x15\x5c\x99\x15\x03" + + "\x47\x15\x57\x74\x3d\xff\xf8\x2a" + "\x19\x9b\xe1\x2c\x07\xea\xb3\x7e" + "\x85\x99\x09\x9b\x88\x62\x1b\xb8" + "\xc5\x09\xa3\xea\xd6\x22\xec\xdf" + "\x19\x34\xc3\xcf\xe2\xa0\xb5\xf9" + "\xa0\xb3\x65\xdb\x9c\xb6\xbf\x70" + "\x95\x4d\x52\x3f\x56\x15\xec\x75" + "\x30\x2f\x80\xe0\x37\x97\xed\xe5" + + "\xe0\x53\xc7\x04\x2b\xf4\xe7\x6a" + "\x6c\xd4\x06\xe6\x00\x42\x09\x26" + "\xa4\xdc\x80\xf6\x39\x2f\xb0\x3a" + "\xda\x37\x3b\x73\xa9\x53\x88\x9b" + "\x6a\x38\x5d\x85\xae\x34\x11\x2e" + "\x61\x9b\xed\x88\xe1\xbe\xa8\xd8" + "\x59\xd4\xed\x83\xc0\x8b\xa0\x2f" + "\x68\xe1\x0f\x2d\x51\x21\x4d\x94" + + "\x30\x9f\x2e\x84\xf9\xab\x7c\x8a" + "\xaf\x83\xab\x5e\xbf\xd4\x31\xa3" + "\x6a\x2a\x7f\x01\xba\xcf\x72\xd2" + "\xe3\xa0\xab\x83\xbc\x0a\x56\x27" + "\x75\x6b\x3a\x0e\x87\x33\xb8\x94" + "\xf5\x50\x9f\x6b\xa2\xae\xc6\x25" + "\xd0\xf6\xfd\xb5\x1d\x69\x3d\x80" + "\x14\x35\x33\xe6\x09\x75\xb7\x03" + + "\x6f\xcf\x14\xbd\x34\xe2\x5e\x74" + "\xbb\x24\xc0\x49\x84\x50\x8b\xde" + "\xb4\xd7\x35\xef\xdd\x4f\x33\x9c" + "\xb4\xb2\x64\xb7\x28\x77\x64\xff" + "\x31\xe0\x21\xcc\xd7\xee\x4d\xf9" + "\x85\x28\xd8\xa0\xb8\x40\x47\xe3" + "\xfb\xd2\x85\xc7\xc4\x17\x03\xa7" + "\xae\x8c\xa5\xf8\xc5\x6a\x05\xdc" + + "\x5f\x04\x78\x88\x8e\x4e\x27\xc4" + "\xe0\x25\xc3\xeb\xeb\x98\x66\x21" + "\x56\x6c\x39\x09\xcf\xbb\xef\x0f" + "\x5e\x80\x91\x04\x15\x19\x19\xdc" + "\xa2\x80\x54\x5c\x87\x4e\x4c\xa7" + "\x0a\xce\xc8\x72\xb3\xd1\xa8\xde" + "\xc1\xfa\x77\x7f\x1d\x70\x9f\x67" + "\x70\xb5\x6a\x6d\xb5\x00\xba\x3e" + + "\xce\x50\x23\xf2\x20\x4e\x00\x08" + "\x4e\x1c\x60\x8d\x19\x45\x45\x6b" + "\xd5\x77\xe1\xd5\x5a\xdc\x09\xea" + "\xd9\xba\x34\x75\xaa\x19\x3e\x92" + "\x46\xc0\x80\x31\xa6\x05\x29\xa4" + "\xaa\x64\xc8\xd3\xd0\x9e\x27\x0c" + "\x51\x5a\x90\xff\xb6\x41\xf3\x49" + "\x32\x6b\x96\xa7\x88\x09\xe2\x2b" + + "\xc1\x41\xa3\x61\x03\x89\x17\x36" + "\x42\x61\xfd\x0c\x60\xdc\x04\x36" + "\x6c\x31\x33\x85\xeb\x95\x22\x02" + "\x22\x29\xaf\x44\xac\xe4\xbd\x3d" + "\x69\xef\x7e\x1c\x5d\xfc\x8a\x89" + "\xa1\x4f\x4f\xd1\x05\x68\x89\x58" + "\xca\x21\x3c\x20\x60\x21\x00\x05" + "\x0b\x73\xef\x40\x30\x1f\x0d\x6f" + + + "\x5a\x19\xf7\x77\x09\x77\xbf\xfa" + "\x8f\x83\xeb\xad\x67\x61\xc8\x8e" + "\x2d\x01\x4f\xbb\xa8\x85\x12\xea" + "\x3f\xab\x3e\x9a\x03\x35\x88\xd6" + "\xc2\x04\x90\x30\xf8\x24\x5d\xee" + "\x5e\xe9\xff\x13\x76\x4b\x6e\xa9" + "\xa4\x3e\x22\xbd\x12\xfe\xdf\x0c" + "\x53\x9a\x73\xb6\xe5\x2e\x5c\x8f" + + "\x02\x38\x76\xbd\xa9\x6a\x40\xed" + "\xa1\x3d\x30\x65\xa0\x86\x14\xc2" + "\xc4\x2e\xe6\xc7\x1e\x29\xae\x61" + "\x3e\x33\x99\xdf\x92\x04\x2a\x62" + "\xe0\x8e\x7a\xbb\x9d\x0c\xd8\x7f" + "\xdb\xae\x01\x6c\xbc\xd3\x2e\xdc" + "\xec\x74\xbe\x08\x12\x5a\xc3\x35" + "\x1f\x67\x9f\x46\x1a\xcb\x40\xd5" + + "\x5b\x6f\x77\xbf\x5a\x3c\xe5\x2c" + "\x05\x7b\x35\x60\x71\x40\x72\x6f" + "\x7a\x3f\xbf\x71\x17\x37\x59\xb2" + "\x9f\x4a\x0c\x44\x1c\x50\xd2\x87" + "\x40\x53\xb0\x87\xe1\x52\x05\x44" + "\x32\x4c\x62\x21\xc8\x7c\xbf\xb7" + "\xdb\xcd\xfa\x22\xce\xa6\x55\x41" + "\xef\x37\x98\x88\xcb\x28\x42\x5a" + + "\x20\x5e\x4c\x58\x6a\x74\xa8\xa7" + "\x35\x70\xdc\xb9\xa1\x4e\x7e\x26" + "\x9b\x8c\x54\xb9\xcf\x15\x3a\x59" + "\xf3\x12\xd0\x4b\x35\x21\x6e\x5e" + "\x6e\x93\x8f\x8c\x6a\xcc\x31\xdf" + "\xdc\x41\xc2\xb5\x04\x4d\xf8\x8a" + "\x86\xfb\x5e\x34\x6f\x0a\x99\x63" + "\xcb\x62\xb9\xb9\x61\x4e\xef\x6f" + + "\x8d\xe4\xa2\xe1\x46\x82\xc4\x23" + "\x5c\xce\x3d\x54\xd1\xe6\x15\xf0" + "\xe9\x1d\x6d\x28\x52\xdb\x9e\xd1" + "\x56\x6f\x82\xdf\xf6\x87\x07\xd6" + "\xe3\x59\x14\x1c\xfe\x5d\x1d\x6e" + "\xdc\x6c\xb0\x9e\xa4\x99\xe8\x26" + "\xdb\xfb\xa1\x14\xc9\x60\x95\x02" + "\xf5\xb4\xd3\xb3\x2f\x84\x78\x8b" + + "\xcb\xec\xbe\x22\x9c\xfa\x6d\xc5" + "\xc0\xd7\x88\xa1\x4a\xa9\x41\x9c" + "\x29\x47\x32\x70\xa1\x83\xc2\x36" + "\x11\x65\x3f\xb6\x50\xe2\xa0\x2d" + "\xa0\x24\x5e\x7b\xd2\x9f\x4d\x83" + "\x42\xdd\x34\x6c\x1b\xb7\x26\xac" + "\xd9\x36\x93\x32\x97\xb4\xf1\xe5" + "\x9d\x4a\xe9\x39\xcf\x1a\x68\xdc" + + "\x30\x7b\xd7\x6c\xef\xcc\x80\x5c" + "\xd0\xb6\x99\xec\x99\x82\x97\x49" + "\x35\xd3\x39\xb9\x5e\x48\xf4\x6b" + "\x47\xc1\xd7\x86\xab\x61\x3e\xc5" + "\xdd\x1d\x60\xfb\x52\x80\x94\xdd" + "\x48\xdd\x11\x35\x39\xeb\xc5\x34" + "\x1c\xf6\xe6\x00\x76\xc6\xf5\x91" + "\x34\x1f\xe7\xb1\x25\xb5\xf1\x33" + + "\x08\x26\x72\x25\x09\x8f\x36\xf6" + "\xc6\xf5\x1c\x13\xdb\x60\x12\x13" + "\xac\xf7\xb4\xfa\x3b\x35\xeb\x40" + "\x29\xe8\xee\x37\x80\x88\xc7\x85" + "\x4e\xf2\xbd\xc3\xff\x81\x15\x4c" + "\xa8\xc5\xc3\xf5\xcb\x75\xff\x5b" + "\x40\x6f\x4e\xa1\x3f\xc8\xe8\x35" + "\xca\xe0\x95\x02\x0f\x1c\x1d\xb8" + + "\x1d\xdd\xd9\xee\xf8\x53\x71\xde" + "\x2e\xcb\xeb\x52\x11\xad\x09\xba" + "\xb6\x3f\x84\xe1\x15\xb0\x41\xaa" + "\xf0\xe6\x4c\xdd\xab\xa2\x33\xf9" + "\x3f\xb8\xf6\x13\x43\x83\x7f\x77" + "\x75\x3a\x11\xdb\xa4\x7d\xdf\x28" + "\x43\xd1\xa5\x72\x3c\x1b\x7d\x6d" + "\xdf\x6d\x6c\x96\x98\x96\x78\x6f" + + "\x54\xa0\x2b\xa7\x33\x9a\x43\xed" + "\xba\x65\xd2\xea\x15\x0a\x17\xa3" + "\x8e\xa5\x99\xfe\x03\xb9\x7e\xcf" + "\x26\x0c\xd8\x33\xc6\xb0\x6d\xcf" + "\x1a\xe7\x13\xf6\x5e\x25\x31\xd0" + "\x5c\x25\xca\x18\x57\xbe\xcc\x12" + "\x0d\xc4\x08\x78\x53\xd0\x21\xdd" + "\x6b\xbe\xf2\x3a\xbc\x8e\x48\xf5" + + "\xc5\xf9\xe3\x1b\x7c\x0d\x11\x47" + "\xdd\xb4\xad\x5e\x48\xe4\xb9\x12" + "\x41\x3d\x71\x0b\x87\x09\x8c\x6e" + "\xae\x56\x3d\x73\x56\x03\xe2\xe1" + "\x27\xa7\x5e\x44\xab\x6b\x8d\xe6" + "\xa4\xa1\x34\xc9\xea\xf6\xf4\x9e" + "\xc3\xf1\xce\xf8\x47\x55\x15\xe0" + "\xbf\xdc\x9b\x15\x09\x39\x5c\xdb" + + "\xd1\x8a\x2a\x44\x3d\xe2\xef\xf2" + "\x64\xc1\xb9\x06\x7d\x6a\x81\xc3" + "\xe5\xa5\x0a\xdc\x8b\x2d\xdf\xa9" + "\x65\x8e\x0a\x12\x6f\xe4\x1a\x19" + "\x5b\x1c\x61\x00\x87\x7f\x66\x83" + "\x48\x99\x10\xff\xd7\x1e\x17\x83" + "\x52\x59\x69\xca\xf8\xec\xa2\x33" + "\x13\x1a\x8d\xf4\xee\x73\x4a\xfa" + + "\x7d\x00\x04\x66\x84\xcf\xca\x97" + "\xf1\xa9\x47\x2d\xb2\xb4\x92\x1e" + "\x65\xd1\x4e\x37\xd6\xe0\x8a\x85" + "\xb8\xef\x7a\x30\x6f\x3e\x97\x4c" + "\x72\xeb\x10\x8a\x23\x4a\x52\x6f" + "\xd6\x49\x28\xeb\xa9\x92\x4a\x7b" + "\xdd\x1e\xe9\x2f\xa4\xbd\x78\x36" + "\x5c\xc3\x0f\x7c\xcd\x2a\x09\x56" + + "\x17\xe5\x10\x0b\xf1\xe9\x13\x35" + "\xd4\xc1\x81\x69\x44\x25\x7d\x40" + "\xc1\xab\xd9\x60\x48\xa8\x53\x49" + "\xd0\xd5\x4f\x8c\xe4\xbd\x8d\xe3" + "\xb1\x5a\xbb\x81\xc5\x16\x52\x7e" + "\xa1\xe0\xc5\x06\x6b\x04\x8a\x32" + "\xa6\x5e\x16\x91\x44\xf6\x34\x52" + "\x36\x0d\xac\xcf\x0f\x8b\xe6\xb6" + + "\x40\x3b\x09\x1a\x63\x5b\x1d\x09" + "\x4a\xf2\x62\x58\x07\x1c\x5c\xb8" + "\xbf\x85\x8f\x3e\xb5\x4e\xd7\xc5" + "\x56\x24\xb2\xca\x46\x77\x1c\xf5" + "\x89\xda\x61\xe7\xd9\xb8\x5c\xc2" + "\xb5\x28\xf0\xc0\x2f\xec\x70\x26" + "\x5c\xaf\xb9\x2d\x0d\xd3\x3f\x87" + "\x5e\x56\x62\x82\xa1\x1e\x0f\x3d" + + "\x0f\x73\x3a\xf4\xc8\x7c\xde\xfc" + "\x0e\x59\xab\x33\x3c\x6f\x9b\xe8" + "\x0b\x24\x03\xad\x29\xf5\x23\xc8" + "\xdb\xa5\xbe\x98\xfe\x9a\xb7\x82" + "\xde\xe5\x2f\x96\x56\x28\x8f\x56" + "\xf3\x91\xc5\x60\xdb\x0a\x59\x0c" + "\x58\xa8\x28\x4a\x14\x4a\xc7\x1f" + "\x4c\x3f\x20\xb3\x98\x24\x66\x3b" + + "\x4f\x8c\xce\x88\xe2\x30\x5c\x75" + "\x3d\x3c\x63\x21\xc8\x8f\x63\x56" + "\x2d\x7c\x5a\xa0\xff\x00\x60\x88" + "\xc6\x18\x02\x01\x31\xe5\x92\x8f" + "\xa3\x64\x17\xb8\x03\x79\xee\x09" + "\x91\x47\x63\x3c\x97\x36\xc2\x95" + "\x13\x2f\x8e\x4e\x22\xf5\xec\x3c" + "\xf8\x4f\xc3\x23\x6c\xd6\x1e\x5d" + + "\xbf\xb3\x30\x19\x22\xfb\xae\x9e" + "\x73\x9c\xa1\x22\x08\x6b\xc0\x25" + "\x98\xa4\xd3\x4b\x2a\x57\xa8\xd0" + "\x51\x63\xd7\x0c\x2f\x85\xbc\x20" + "\xda\x25\x89\xb3\x6d\x38\x01\x83" + "\x85\xf2\xec\x64\x6a\xe6\xfb\x85" + "\x7f\x61\xc9\xc0\x84\x7e\x74\x53" + "\x72\x17\xbe\x1d\x26\x1d\xd6\xb0" + + "\x8a\xff\x0d\x8d\x95\xc2\x84\xe5" + "\x05\x63\x24\xef\x8b\xf4\x2b\x55" + "\x3e\xdb\x45\x4f\xa5\x21\x9c\xc0" + "\x8f\xbb\xee\x3c\xec\x83\x30\xca" + "\xe2\xc6\x6d\x40\x7c\xd0\x4d\xbf" + "\x01\x30\xf6\xa7\x6d\x62\x96\x0e" + "\xd3\xcb\x16\xaa\xfe\xfb\xa9\x81" + "\x00\x13\x3a\x67\x5c\xca\x7e\xfe" + + "\x6a\x1b\xdd\x82\xd0\x4e\xfc\x48" + "\xaf\x03\xb7\x67\x38\xa1\x83\x57" + "\xaa\x6a\x5d\x00\x9a\xcb\x63\x24" + "\x43\xcd\x6e\x70\x5c\xc5\x1e\xd3" + "\x41\x76\x9a\x8e\x3f\xd3\x8e\x9f" + "\x7a\x9e\x8d\x09\xed\x53\x54\x62" + "\x93\x74\x88\xec\xe4\xad\xbe\xa3" + "\x66\x55\x79\x5a\x50\x80\x2b\x44" + + "\x17\x50\x96\x0c\x31\x62\x0c\x98" + "\x4f\x7a\x0d\x40\xb3\xc0\x8c\xaf" + "\x97\xcf\xf4\x48\xe2\x12\x58\xee" + "\x5e\xd9\x90\xbb\xb8\x7e\x58\xe4" + "\x5e\x04\x52\x81\x7f\xa5\x42\x1b" + "\x2e\x7c\x1c\x64\x06\xb9\x92\xd7" + "\xda\x87\x1c\xa7\x93\xf5\xfc\x9d" + "\xb9\x00\x04\x1b\x77\x7d\xab\xc7" + + "\xe2\x70\x5a\xd8\x34\x2d\x95\x16" + "\x52\x1a\x2e\xc3\x97\xff\x09\x7d" + "\xbf\x8a\x2d\xa6\x3e\xe4\xd6\xca" + "\xbb\xfe\xaa\x25\xda\x46\x76\x74" + "\xbd\x24\x4e\xe5\x96\xc4\x65\x03" + "\xe3\x50\xe8\x24\x16\xa4\x99\x14" + "\x2b\xd2\x81\x67\xf7\xdd\xf6\x24" + "\x81\x59\xc3\xbf\xf1\x55\xe5\x42" + + "\x38\x33\xcd\xfa\xc2\x19\x23\x5b" + "\xd1\x3e\x88\x6f\x47\x50\x96\xed" + "\x19\x16\x83\x16\xc3\x96\x07\x37" + "\xaa\x61\x6b\x20\x69\x34\xb7\x8d" + "\xe8\x08\xa9\x1f\x17\x5d\x0e\x0a" + "\xfa\x40\x54\xb4\xe3\x71\x72\xe8" + "\x98\xdb\x2b\x07\x3e\xe0\x6a\x7f" + "\x8a\xb9\xc3\x28\x55\xf7\x87\x06" + + "\x5a\x76\x39\x6c\x0d\xcf\xe3\x91" + "\x0b\xca\x3c\xac\xcd\x3a\xdb\xa2" + "\x50\x3b\x95\xcb\x08\x2f\x8f\x28" + "\x1a\xcf\x43\xcf\x2c\x58\x14\x24" + "\xa8\xe9\xee\x60\xbc\x8b\xec\x8d" + "\x42\xa0\x9a\x72\x02\x9f\xc7\x54" + "\xd5\xf5\x32\x65\xec\xd5\x1c\xd8" + "\x5f\xe1\x82\xcf\x3a\x30\x72\xa6" + + "\xff\xf5\x73\xc3\xe2\x03\xbd\xb3" + "\x41\x63\xfc\xe7\xb4\xa8\xa8\x80" + "\xdf\x7b\x08\xa0\xd6\x52\x29\xb7" + "\x8e\xa3\x48\xc0\x9d\xbb\x3c\x80" + "\x00\xb0\xf8\xcc\x7e\x65\x0a\xcf" + "\x09\xeb\xe1\x67\x18\xc0\x54\x8c" + "\xfc\x46\xb6\xf0\x26\x10\xf9\x88" + "\xd8\x4b\xff\x7d\x53\xf2\x0d\x9d" + + "\x42\xd5\xc6\x48\x80\xc9\xfb\x4e" + "\x2e\xf4\x25\xc9\x00\xc2\x9c\x26" + "\x3e\xfe\xf6\xbc\x6a\x44\x5a\xb5" + "\xc5\xe5\x67\xac\xd5\xdb\x02\xb0" + "\xd8\x8e\xda\xee\x64\xee\xec\x91" + "\xd2\x71\xe0\xba\x2d\xf9\x89\x89" + "\x53\xbf\x7e\xaf\xe0\xdb\x45\x92" + "\x81\xa7\xef\x9e\xe7\xe6\x41\xd1" + + "\x9f\x7e\xeb\x2d\x0b\x49\x28\x97" + "\x6b\x25\xc7\x02\xc6\xc3\x77\x88" + "\x73\xaf\x32\x22\x1d\xaa\x9d\xd2" + "\xe8\x49\xb0\x1a\x21\x90\x4b\xc9" + "\x94\xbf\xe4\xe6\x53\xdf\xe4\xdb" + "\x06\x10\x7b\x4d\xe7\x24\x73\x4a" + "\xdf\x8b\x6a\x0a\x56\xd4\x46\x04" + "\x89\x55\xa3\x5c\x8b\xf9\xf2\xab" + + "\x39\xb8\xfa\x3b\x2d\x58\xdf\x46" + "\xde\xda\x8a\x2f\x04\x4e\x47\x92" + "\xc3\x1b\x7a\x14\x6a\x76\xa7\x36" + "\x79\xf9\xc0\x0d\x54\x0f\x94\xb6" + "\x25\x9f\x75\xf2\xf2\x8e\x73\x44" + "\xc6\xf4\x19\xa7\x89\x57\xd9\x9d" + "\x45\xc3\x50\x07\xf4\xb7\x59\x28" + "\xd5\x80\x21\xb2\xf2\x8b\x78\x5e" + + "\x7e\xb4\x71\x66\x01\x5f\x21\x4b" + "\x2a\xae\x8d\x4a\xca\x33\x76\xb6" + "\xdb\x3c\xfd\x79\x0f\x12\x15\x29" + "\xde\xe6\x64\xb0\x6f\xa0\xf8\xc1" + "\x20\x74\xd5\xc1\x8c\x36\xd5\xf4" + "\x75\xe4\x8d\xe1\xa8\x51\xda\x6a" + "\xb0\xd4\x49\xc7\x7c\xd4\xf0\xa0" + "\xa5\x6a\x52\x74\x00\x2c\xfa\xab" + + "\x3c\x17\x59\xfc\x73\xb7\xf2\x3f" + "\x9c\x91\xa0\xa2\xa5\x12\x86\xf6" + "\x15\x7b\x4c\x23\x28\xae\xa8\x9c" + "\xdc\xe7\xbe\xed\xaf\x58\xf6\xfd" + "\x5f\x96\x18\xab\xad\xd9\x55\x2c" + "\x44\xde\x00\x5c\x12\x1f\x90\xb9" + "\x51\x0b\x36\xee\xf1\xaa\x70\x8b" + "\xe0\x4f\x60\x05\xd5\xa9\x4b\x3e" + + "\x2b\x77\xd2\xf0\x82\xe4\xb8\xbe" + "\x99\x06\xe6\x2d\x65\xab\x16\xc5" + "\xf9\xf7\xd4\xc6\x34\x1e\x4f\x1e" + "\xee\xe4\xec\x5c\xbf\x88\x98\x23" + "\x38\xd2\x03\xbc\xfe\x86\xc5\x7a" + "\x6f\x3a\x35\x7d\x15\xc7\xd3\x8c" + "\x65\xfd\xf1\xb3\xde\xaa\x96\x02" + "\x5f\x53\x1e\x3a\xd4\xed\xb8\xe3" + + "\x63\x05\x9c\x71\xa8\xaf\x6a\x37" + "\x9f\xc7\x5f\xbc\xdc\xd2\x8a\xcd" + "\xd3\x0c\x75\xcb\x9f\xdb\x3f\x30" + "\x8e\xb0\x18\x44\x2f\x05\xff\x14" + "\x20\x65\x2d\x3e\xcf\x84\x50\xf7" + "\x09\xd5\x4e\x14\xf8\xf0\xbd\x7e" + "\x98\x5b\xf2\xd3\xf2\xf0\x3b\xf4" + "\x37\xd8\x54\xa3\xcf\x71\xad\x86" + + + "\x5d\xf7\x8a\x86\xc4\xc8\xd0\xd9" + "\xea\xc7\xc8\x45\xff\x5c\x32\xd7" + "\xb0\xec\x81\xcc\x96\x19\x47\xab" + "\xed\x24\x18\x61\xf3\x55\x5d\xff" + "\xee\xa0\x77\x19\x41\x45\x31\xbe" + "\xc6\x38\x20\x72\xc5\xc4\x85\x50" + "\x95\xb4\x4b\xf9\xbf\x35\x53\x2d" + "\x82\xa0\xe2\xc8\xa6\xd8\x4a\x89" + + "\x37\xbb\x11\x2c\xb2\x34\x02\x54" + "\xa3\x74\x4c\xed\xdd\x66\x03\x2d" + "\x5d\xf2\xc5\xee\xda\x68\xa9\xf9" + "\x42\x31\xb6\x67\x68\x10\x60\x36" + "\xd4\xb6\xd7\x68\x2c\x6d\xcd\x07" + "\x42\x29\x84\x0c\x09\x4f\xf7\xa8" + "\xee\xb1\x68\x77\x04\x14\x75\xe2" + "\xe4\xae\x62\xfe\x89\x7e\x5f\x4b" + + "\x20\xef\x94\x19\xb2\x59\xe0\xd1" + "\x18\xe3\x8a\x63\x69\x3b\x65\x2a" + "\x10\x90\x69\x2f\x58\xeb\xd5\x70" + "\x4a\xf8\xf5\x09\xf7\x39\x97\x27" + "\x36\x93\x79\x8b\x3c\x66\xa4\x5d" + "\xeb\x37\x3c\x20\x4d\xf1\xfd\xfd" + "\x2d\xfb\xdb\xa1\xdc\xa9\xd8\x32" + "\x9b\x8f\xd4\x77\xf0\xcf\x40\xab" + + "\xed\xbb\x9f\x87\x0b\x9f\x36\xf2" + "\x69\x18\x9d\xda\x86\xae\xf0\x0f" + "\x45\x6f\x76\x56\x59\xd7\x51\x52" + "\xfc\xd0\xe8\x2b\xc0\xd8\x84\x49" + "\xf0\x08\x10\xd2\xa6\x95\xcc\x7e" + "\x49\x1c\x1a\x3a\xa0\x54\xbd\x29" + "\xf3\x50\x6c\xd2\xc5\x28\x98\xab" + "\x51\xd2\xd0\x51\x7c\x08\xc0\x32" + + "\xa5\x50\xaf\xfb\xab\x90\x17\xf6" + "\x50\x07\x4e\x68\x6b\xe7\x55\xdf" + "\x05\xb0\x76\xf1\xa7\x6d\x51\xec" + "\xc7\xdd\x2d\x7a\xbb\x53\x55\x57" + "\x73\xfa\x3a\x55\xa3\x7c\xc8\x37" + "\x51\xc2\x55\x4d\xfc\x3f\x5f\x31" + "\x35\x5d\x3e\xaf\x2a\x44\x46\xe8" + "\x28\xff\x95\x64\x49\x11\xb9\x61" + + "\xaf\xf3\xb5\x62\x66\xeb\xfe\x47" + "\x34\x37\xbb\x0a\x61\xb5\xfa\xce" + "\xb1\x5c\xf3\x19\x0e\xe6\x9d\x44" + "\xb9\x0e\x7f\x15\x14\xdb\xf8\x39" + "\xd6\xbf\x61\x3c\x5b\xcc\xae\xff" + "\x03\x67\x21\x41\x1d\xd4\xa4\xa5" + "\xc2\x1c\x4e\x22\xed\xab\x8f\x7f" + "\x53\xd9\x1a\x87\x86\x81\x5a\x0d" + + "\x23\x08\xf9\x56\x49\x3a\xdf\x4b" + "\x7b\x77\x1d\x74\x80\x50\x0f\xba" + "\x60\xf7\x8b\xf3\xc3\x71\x1d\x09" + "\x02\x5b\x62\x9b\x0f\xd5\x33\x96" + "\x61\xde\xc9\xb8\x43\xb7\xec\x03" + "\x20\x47\xe7\x5d\x54\x12\x75\xb4" + "\xb2\x1c\xce\x74\xc9\xef\x9d\x9f" + "\xef\x32\xbd\x00\x6a\x4f\x4a\x77" + + "\x52\x9a\x79\x01\xa6\x8e\x0d\x19" + "\x52\x29\x6d\xb8\x41\xec\x0c\xa2" + "\x7c\x2a\xff\x7f\xb2\xff\x62\x30" + "\x37\x9d\xf1\x79\xe5\x32\x1b\x74" + "\x47\x7d\xb5\x4e\x81\x81\x0d\xf8" + "\x6b\xf0\xae\x16\xd4\x0e\x2d\x7a" + "\x88\xb5\xec\x1c\xb0\x5f\x73\x09" + "\x5b\x1f\x06\xc6\xaa\xca\x41\x16" + + "\x5b\x1e\x13\xb0\x02\xc0\x7b\x32" + "\xd9\x14\x25\xcb\xd5\xe6\x39\x17" + "\x43\x15\xa8\x55\xfe\xda\xcb\xc8" + "\x43\x72\x13\xe1\x6c\xa3\xb1\x5b" + "\x27\x53\x32\x17\xc5\xa3\x5d\x20" + "\x7e\x05\x5a\x51\x36\x1a\x5c\xc3" + "\x9b\x5f\x92\x42\xc9\x64\x0f\xf0" + "\x7a\x9f\xd5\xb7\x3c\x63\x14\xbd" + + "\x3a\x8c\x6e\x65\x71\xd1\x2a\xae" + "\x05\x07\xcd\x1a\x63\xa4\xe2\xc0" + "\x5c\x05\xb6\xa0\x8a\x6a\x6f\x00" + "\x6e\xa2\x65\x2b\xd7\x13\x45\xaf" + "\xbc\xd5\x16\xd6\x14\x9e\x54\x3f" + "\x1f\x3b\x25\x71\x55\x39\xee\x64" + "\x3a\x24\xce\xb8\xc1\x0b\xb1\xe8" + "\x77\x4e\x3a\x91\xe5\xac\xbe\xbc" + + "\xbd\x7d\xf3\x41\x43\x00\xc1\x47" + "\xf6\xec\x68\x61\xe3\xca\xec\x96" + "\xa3\x6a\xa4\x1c\x9d\xe5\xbd\x65" + "\xfa\x8f\x69\xb8\x7a\x02\xa7\x38" + "\x37\x44\xc3\x6d\xc8\x9d\xb8\xa2" + "\x3f\x15\xa4\x43\x8d\x11\x0a\x5a" + "\xd8\x2f\xe2\x1c\x86\x0a\x33\x9e" + "\xbc\xd3\xbb\xb3\xf6\x2a\x38\x28" + + "\xa7\xd6\x79\xf7\x56\x22\xd3\x68" + "\x4e\x28\xe7\x19\x4d\x3b\x42\x20" + "\x53\xb1\xf3\x38\x1b\xaa\x19\xde" + "\x03\xf7\x44\x84\xc2\xb6\xd0\x73" + "\xa3\xe6\x64\x9c\x48\x61\x61\x66" + "\x24\x62\x25\x37\x37\x7c\x58\x99" + "\x63\x15\x33\x61\xfe\x77\x52\x6f" + "\x2e\x50\x56\xa6\x4a\xad\x74\x71" + + "\x71\x02\x1e\xd8\xc0\x27\x2e\x0b" + "\x7c\x31\x7a\x11\x96\x75\x7a\xa6" + "\x99\x3d\x72\xa6\x28\x89\xf0\x17" + "\xa3\x10\x53\x48\x81\x56\xa7\x71" + "\xa9\x6c\xb6\xaf\x62\x54\x46\x90" + "\x9d\x22\xbe\xfb\xcc\x97\x5e\x18" + "\xc2\x8f\xad\xdd\x6a\x60\x1a\x6a" + "\xcf\x97\xc7\xb3\x16\xf3\x31\x24" + + "\x8d\x91\x33\x01\x92\xfc\x1f\xec" + "\x97\xef\xc9\xb2\x5e\xbf\xd9\x15" + "\x9a\xbb\x6c\xfc\x42\xb5\x85\x78" + "\x5d\xcf\x20\x57\x53\x64\xbe\x8a" + "\xab\x68\xec\xd4\xce\x5d\x71\x4e" + "\xa3\x24\x9c\x27\x14\x76\xa6\x57" + "\xcf\x61\xbb\x31\x2a\xd5\x8e\x78" + "\x03\xa0\x37\xf4\x44\x24\xa8\xab" + + "\x32\x94\x52\x93\x11\x40\x03\x47" + "\x62\x34\x74\x30\xdd\x6b\x10\x1f" + "\xca\xd8\x66\xcd\x64\x99\xfb\xab" + "\xd5\xad\xbd\xe9\x5a\x9d\x4d\x93" + "\x22\x3d\x8e\x90\x15\xd8\x76\x59" + "\xbd\x57\xe0\x28\x2f\x36\x4a\x34" + "\xb3\xdf\x43\x54\xdc\xda\x2c\xf9" + "\x3b\x60\x89\xf0\xad\x97\x12\x00" + + "\x27\x14\x15\x20\x4f\x82\x99\x7f" + "\x06\x02\x43\x92\xb6\x28\x68\x20" + "\x57\x23\x11\xe1\xd7\x97\x90\xaa" + "\xec\x14\xe4\x09\xf2\xa2\xf9\xac" + "\x56\x53\x91\x27\xda\xc9\xda\xdb" + "\xe3\xfe\x1e\x00\xb7\x34\x07\x7e" + "\xe2\x88\xb2\xd2\xbb\xb5\xfa\x54" + "\x9c\xd0\x2d\xf6\xc4\x0f\x63\x4c" + + "\x6b\x06\x44\x50\x60\xce\x2f\x4a" + "\xf4\x47\x3a\xfa\x9c\x01\x4a\x90" + "\x60\x0a\x5c\x0c\x9c\xea\x81\xba" + "\xbd\x98\xc0\x96\x0d\xea\xe4\xd7" + "\x02\x0a\xd5\x9c\x41\x00\xe7\xef" + "\x8c\x04\x7f\x2d\xd4\x39\xc8\xc0" + "\x1f\x56\x9b\xe0\x64\xf2\xda\xe2" + "\x8b\xb1\x34\x50\x18\x13\xbc\x0c" + + "\xe1\xa5\x70\xbd\x66\x3e\x88\x6d" + "\x13\xe7\x5d\xd0\xc1\x84\xd8\x9b" + "\x7d\x48\xd8\xd4\x45\xd4\xd9\x48" + "\x05\xe4\xea\x0e\x8b\xcd\x40\x84" + "\x3e\xf8\x26\x3d\x29\x0f\xcd\xa3" + "\xe4\xc5\xa3\x22\x30\x45\xd9\x3f" + "\xa7\x2c\xfa\x3f\x66\x78\xa0\x63" + "\x97\xa0\xd4\x00\x29\xdd\xea\xbf" + + "\x7a\x3f\x32\x88\xe3\xf2\xe5\x11" + "\xcd\x84\x75\x92\xc2\x74\x7a\xe0" + "\x2d\x3d\x61\x95\x34\x4b\x77\x1e" + "\x88\x74\x78\x2c\xc5\x52\x9b\x9c" + "\x08\x1f\x42\xbe\x3e\x3c\xdd\x3c" + "\x5f\x3d\x3e\x22\x9e\x81\xf7\x5f" + "\xb9\x09\xda\xc1\xb2\x39\x87\xba" + "\x1b\x49\x8b\x4e\x16\x63\x72\x6b" + + "\xba\x32\x84\xd6\x59\xa5\xae\x13" + "\xdb\x15\x39\xd3\xfb\x43\x00\x94" + "\x08\xda\xe8\xe2\x94\x7c\x6c\x47" + "\xbb\x65\x30\x44\xc4\x30\x16\x6b" + "\x75\x6c\xf0\x19\x6d\x54\xd8\xd6" + "\xbd\x5a\xb3\x2e\xc2\x98\x1e\x7e" + "\x8e\x7d\x15\xf0\x10\x93\x1c\x75" + "\x75\x60\xfa\xf6\x27\x43\xf8\xde" + + "\xef\x3b\x94\xa0\x3c\xd1\xaf\xb5" + "\xcc\xb1\xab\x57\x29\x77\x51\xd6" + "\xbc\xb5\x61\x9b\xdc\x52\x5a\x9d" + "\xcd\x31\x6e\x80\xa6\xfa\xce\x85" + "\xea\x1d\x0a\x72\x7a\x25\x84\xab" + "\x35\x0d\xd7\xce\x1b\x26\x60\x6a" + "\x61\xda\xd6\xb9\x4d\xf9\x23\xc0" + "\x0e\xae\xa0\x54\xec\x7e\x7f\x94" + + "\x0e\x4e\x7a\x3a\x3c\x99\x5b\x76" + "\x14\xd3\x79\x9d\xef\x4a\x8f\xfb" + "\x24\xeb\x19\x2a\x0e\xc5\xa2\x5e" + "\x8c\xbc\x91\xb8\xe5\x16\x50\x92" + "\xe7\xec\xd1\x3a\xdc\xaf\x70\x8f" + "\xe2\xab\x8f\xf0\x4c\xa8\xbb\x0a" + "\x2b\x13\xf6\x15\xc8\x22\x99\x0a" + "\x77\x6d\x07\x5d\x73\x13\x02\x6c" + + "\x87\xb7\x83\x9f\x56\x87\xb7\xc3" + "\xd7\xdd\x94\x36\x26\x49\xd2\xd6" + "\x2e\xa0\x70\x5d\x94\x48\xd2\x58" + "\x6a\x8c\x27\x8c\x0e\x67\x16\xac" + "\xe6\xb6\x70\xe3\x58\x4d\xa9\x71" + "\x05\xdb\x53\x02\x84\x63\xd7\xe4" + "\xfe\x2c\xb3\x14\x88\xc9\xb1\x99" + "\x95\xcc\x78\xcc\x70\xd8\x6b\x4e" + + "\x61\x39\x45\xa4\x15\x26\xaf\x00" + "\x2c\x11\x3d\x99\x4b\x49\x05\x17" + "\x52\xd6\xcd\xa1\x2a\xe1\x32\x00" + "\xb3\x9c\x6d\x04\x12\xa6\xbf\x0e" + "\x8c\x72\x63\x1b\xf3\xa9\x03\x9f" + "\x05\x2b\x02\xde\xa2\x18\x36\x8f" + "\xc9\xc5\x77\x3e\x90\x4d\xb2\xd5" + "\x7c\xb7\xac\x72\xa3\x38\x78\x83" + + "\x14\x36\xb6\xc8\x79\xca\xf7\xf5" + "\x3c\x90\xf4\x8a\x15\xb2\xbf\xf3" + "\xd3\x7b\xd4\x96\x54\x9f\xdb\x2b" + "\xba\x63\x8a\x0e\x30\x15\xe7\xd6" + "\xc4\xbe\x93\x7a\x49\x0a\xe9\x67" + "\xee\x63\x1e\x8c\x8b\x47\x13\x86" + "\x61\xe5\xdd\xf2\xc8\xd9\x6b\xe3" + "\x89\x86\x76\x8a\x51\x86\x14\x68" + + "\x47\xb0\xce\x8f\xd9\xcb\x65\xfe" + "\xa1\x11\x8b\x3f\xf5\x2e\x87\xde" + "\x2f\x80\xec\x8f\x3d\x0d\xba\x9a" + "\x1d\x38\x9f\x9a\x32\x1d\x9f\x13" + "\x8d\x95\x87\xc5\xd9\xae\x21\x07" + "\xda\xa7\xf6\xb9\x5c\x01\x6a\x06" + "\x06\x9d\x5d\xed\xe3\xc4\x9e\x05" + "\x1f\xca\xba\x6c\x71\x85\x42\x14" + + "\x1c\x53\xaa\x94\x94\x7a\x61\xef" + "\x87\xad\xf4\xd6\x2f\x5e\xc3\x9a" + "\xfb\x68\x24\x12\x47\xa0\xd2\xbc" + "\xa6\x5c\x7c\xef\x3f\x42\x7a\xbd" + "\x40\x80\x4c\x06\x52\xcb\x58\xab" + "\x16\x47\x64\x4a\xd5\x4e\xef\x93" + "\x8d\xd4\x2c\xc3\x97\x70\xd1\xf7" + "\x42\xcf\x7f\xd1\x73\xa1\x49\xb2" + + "\xf5\xcd\x98\xe2\xff\x0f\xfe\x66" + "\xb6\x51\x2e\x7b\xa4\xbe\x61\x3f" + "\xa4\xaf\xd3\xba\x17\x21\x37\x7d" + "\x2f\x6e\x65\xef\x9c\xa0\x21\x65" + "\xe7\x8f\xa5\xe8\x66\xc9\xb8\xb3" + "\xc7\xeb\x47\x5a\x11\x3a\x20\x25" + "\x73\xe5\x4b\x5c\x8d\x58\x81\xfe" + "\x3c\xa0\x49\x1f\xf3\xe2\x32\x61" + + "\xc4\xec\xa7\xb7\x08\xc1\xe5\xbb" + "\x4c\x2e\xd2\xbf\x8e\xa7\xa5\x62" + "\xd2\x8b\x18\xdf\x33\x40\x97\xb7" + "\xae\xd1\xf7\x4d\xea\xde\x11\xcf" + "\xea\xe3\xac\x53\x4a\x77\xcc\x99" + "\xf6\xc1\x5c\x10\x71\x3a\x37\xe0" + "\x20\x7a\x3d\x13\x7f\x98\x51\xd7" + "\x71\x58\x21\xae\x04\xee\x86\xab" + + "\x99\x2c\x8c\x0f\x13\xb0\x1a\xec" + "\xc2\x25\x77\xf1\x8f\x96\xe8\x60" + "\x0b\x98\x0a\x94\x93\xa5\xa4\xe1" + "\xb1\xcc\xe9\x20\xb0\x15\xed\x15" + "\xec\x0b\xa0\x64\xcc\x54\xd7\x77" + "\x82\x73\x68\x41\x33\x9c\xd0\x90" + "\x51\xb6\x1f\xc3\x2d\xe0\x4f\x29" + "\x53\xae\x94\x1c\x1a\xcd\x72\x83" + + "\xe6\x10\xcd\x80\xa2\xf9\x94\x20" + "\xa7\x0d\x8a\x7b\xaa\x32\x52\x04" + "\x4e\x24\x03\x9c\xb6\x81\x9a\x96" + "\x55\xd9\x98\x7e\xca\xb4\x93\x12" + "\xb0\x3a\x8f\xd6\x1d\x42\x31\x16" + "\x82\x8c\x73\xc3\x22\x64\x10\xa0" + "\xf9\x4f\x2c\xf8\x45\x38\xf4\xc5" + "\x8f\xf5\xa0\x1a\xbe\xac\x79\xb4" + + "\x3b\x70\xc2\x1a\x7a\x10\x37\x85" + "\xb5\x57\xc8\x6b\xd8\x58\x92\xb4" + "\xd1\xcc\xda\xbc\xde\x14\xdf\x57" + "\x29\x85\xae\xc4\xd7\x68\xab\x24" + "\xd0\x59\x4e\x73\xd4\xb5\xd8\x7e" + "\x80\xcc\x95\xc4\xc8\x40\x87\x5f" + "\xb3\xb9\x1d\x29\x5a\xdd\xae\x84" + "\xbe\x95\xb9\x4f\xf8\x60\xb3\x80" + + + "\xfa\x76\x1a\xa6\x8d\xc6\xd5\x55" + "\xdc\x54\x15\xca\x1d\x44\x8b\x59" + "\x9c\x27\x3b\x77\xb9\x23\x99\xd3" + "\xfc\x9e\xbf\x36\x3c\x1d\x33\x33" + "\x99\xe3\x8d\x29\x8e\x84\x4c\x2d" + "\x56\x7f\xa2\xa1\x77\x8e\xdb\xcf" + "\x70\xab\xb8\x57\xea\x55\xc8\x94" + "\xba\x79\x78\x6f\xae\x9d\xdb\xdc" + + "\x38\x6a\x63\x7f\x36\x07\x4f\x4c" + "\xcb\xd5\x76\x0e\xb7\x3f\x94\x9f" + "\x8b\x8b\xb6\xa8\xba\x10\x35\xb0" + "\x1f\x7a\xd0\x9e\x0a\x78\x46\xc2" + "\xc2\x9f\x54\x6d\x15\x14\x05\x3c" + "\xca\x81\x77\x60\x31\x3f\x95\xc2" + "\x13\x54\xd9\xd8\x69\x2c\x5e\x95" + "\xe3\x82\xd2\x7b\xdc\xfa\x00\xb3" + + "\xb4\x01\x79\xc2\x63\x11\x4b\xa1" + "\xf3\x8b\x9b\x89\xe0\x36\x92\xfd" + "\x0a\xda\xc6\xcb\xec\x91\xb0\x42" + "\x97\xd2\xd1\x5a\x6f\xac\x1d\xbb" + "\x6e\xf7\x1c\xa9\x53\x1d\xe6\x80" + "\xe7\x1e\x1f\xd3\x12\xa4\x10\x41" + "\x77\xcf\xef\x13\xba\xc3\x87\x2d" + "\x76\x0d\x45\xdf\xb4\x4b\x37\x1f" + + "\x9a\x51\x47\x41\x02\x86\x28\x20" + "\xf0\x72\xb3\x26\xac\x1e\x98\xd0" + "\xc8\xeb\x85\xa7\xca\xa7\xd4\xa9" + "\xe9\x58\xdf\xdb\x0d\xc5\x53\xd9" + "\x8f\x0f\x59\xfd\xcc\x61\x63\x9d" + "\x17\xc9\xe6\x44\x6b\x62\xe9\x72" + "\xcf\x64\xeb\x22\x10\x61\xd9\x7f" + "\xf3\x88\xb2\x9e\x7e\xbb\x3e\x86" + + "\x03\x44\x7e\x09\x0a\x0a\xe1\x15" + "\x65\x46\x85\x19\x86\x0a\x3d\xcb" + "\x26\x48\x7d\xd6\x11\xe2\xd8\x88" + "\x39\x28\x9d\x0b\x6e\xf6\x9a\xb3" + "\xa8\x5c\x47\xbd\x88\x45\xf9\xa5" + "\x0b\xb8\x77\xc0\x66\x79\x6b\xe0" + "\x6c\xc2\x27\xda\x85\x14\xdb\xfe" + "\xe0\xd5\x0f\xfe\x3a\xd3\x90\xd2" + + "\x3d\x58\x06\x13\xf3\x02\x62\x68" + "\x2e\x62\x7c\x43\xa0\x0d\xb1\x05" + "\xc8\x7b\x6a\x07\x0f\xaa\x9a\xbf" + "\x43\x4e\x8f\x8f\xfb\x4e\xe9\x25" + "\x6d\xc2\x3d\xfa\xb7\xc9\x35\x8a" + "\xc5\x03\xff\x96\x93\xfb\xe5\xe0" + "\xce\x94\xc3\xeb\x43\x38\x7e\xa7" + "\x60\xde\x61\x83\x95\x65\xde\xce" + + "\x40\xb5\x22\x0c\x09\x75\x90\xbf" + "\xd4\x67\xc2\xb7\xaa\x42\xde\x2c" + "\x93\xd6\xb0\x5a\xed\xf9\x18\xba" + "\xd9\x60\x46\x6e\xa6\x2a\xa6\x3b" + "\x6a\xa9\x9e\xab\x7b\xf9\x4b\xb2" + "\x32\x0e\xb6\xe3\x42\x96\x03\x5d" + "\xd5\x9b\x4d\x7c\x06\x45\x6a\x4e" + "\xa4\xa6\xd4\x7e\x9e\x5b\x6c\x66" + + "\xb0\x31\x8a\x67\xf5\x7c\x7b\x87" + "\x20\xb6\x98\x39\xae\x01\x03\xd5" + "\x96\xb3\x0f\xc0\xc5\x57\x42\x73" + "\xa6\x72\xe6\x04\xa0\x18\xfb\xf9" + "\x51\x88\x75\xe8\xeb\xd8\x8b\xff" + "\x44\xba\x99\x5d\xc6\xe4\x64\x1e" + "\xb7\x93\xfd\x7d\xdf\xae\x8e\x4b" + "\x8c\x6b\xe7\x04\x98\x2a\x2f\xba" + + "\xbd\xdd\x56\x9b\xf0\xa2\x02\xae" + "\xf3\x1c\x2f\x8a\xac\xb5\x39\x13" + "\x0d\xff\x9d\x83\xc7\x69\xb5\xf2" + "\x3d\xa4\xe9\xfe\x64\xe8\xb9\xb0" + "\x4e\x06\xbb\x77\x41\xca\xf8\x4f" + "\x63\x9f\x24\xfd\x12\x28\x5a\x14" + "\x9a\x68\x6f\xf8\xac\xbe\xb7\x3a" + "\x5e\x5f\xd3\x01\x27\xec\xaf\x9b" + + "\xb7\xc7\x57\xae\xdd\x3f\xa2\xbb" + "\x22\x25\x93\x1b\xf2\x42\x53\x34" + "\xa3\x4a\x6d\x55\xfe\x80\x9c\xfd" + "\x61\xbb\x25\x65\xba\x07\x39\xa0" + "\x33\x89\x21\xff\xe1\x10\xb0\x38" + "\x7b\x11\x52\xaa\x54\xb6\x66\xc0" + "\xea\xe6\xf2\x94\x20\x19\x14\x8e" + "\xb2\xf2\x32\x0d\xca\x7d\xa2\x66" + + "\x92\xbe\xab\xfb\x21\xb1\xe6\xb2" + "\x76\x00\x33\xe1\xfb\x50\x18\x28" + "\x15\x00\x89\x97\xec\x81\x35\x09" + "\xf5\x77\xff\x75\xed\xdd\xb1\x69" + "\x05\x51\x10\xab\x8f\xb1\xf0\x7c" + "\xef\xcf\x9c\xa8\x31\xed\x3c\x95" + "\x09\x40\x91\xeb\x5f\xf8\x51\x31" + "\xad\x48\xed\x88\x87\x1b\x9f\x3c" + + "\x1e\xb2\x0f\xe9\xe0\x07\x8f\xa1" + "\xa1\xfc\xa7\xbb\x80\x2b\xfd\x00" + "\xb5\x67\xcd\x95\x27\x7f\x38\x20" + "\xf7\x07\x97\xd3\xe7\xa4\x89\x5b" + "\xce\x07\x44\x89\x3f\xad\x83\x8f" + "\x32\x61\x22\x6c\x94\x5b\x02\xa0" + "\x3b\xc1\x06\xf9\xc7\x63\x95\xc7" + "\x25\xb0\x7b\x4e\x31\x8f\x54\x5f" + + "\x1f\x0c\xde\x4f\x49\x89\x75\xff" + "\x20\xec\xb6\xe5\xbe\x1a\x8a\xbf" + "\x6c\xdb\xe1\x87\xfb\x78\x22\x70" + "\x8f\x65\xed\x35\x7a\xad\x47\xc4" + "\xf2\xcc\xd0\x03\x38\xaa\xd4\x48" + "\x03\x7c\x9a\x81\x38\xb3\xac\x80" + "\xcc\xce\x17\x6e\x9e\xc8\xc7\x9b" + "\x82\x1d\xbe\x03\x8b\x6b\x73\x46" + + "\xaa\x5e\x3b\xd4\x42\xf7\x26\x21" + "\x85\x9b\xa5\xdf\x66\x07\x4a\x05" + "\x45\xfd\x6b\x12\x36\x5e\x0d\x9d" + "\x8f\x8a\x4f\x38\xd7\xfb\xf8\xa1" + "\xcc\xfc\x63\xd5\xf5\x80\x76\x31" + "\x28\xa9\x80\xf2\x55\x50\xca\x48" + "\xcf\x78\xb5\x27\xb2\x81\x0b\xe0" + "\x14\xa5\x94\x29\x18\xd9\xaa\x10" + + "\xc0\xcd\x8b\x35\x1f\x30\x3f\xe6" + "\xf8\x47\x9d\x0a\x99\x9e\x68\x07" + "\x3a\xd4\x43\x4f\x2f\x9e\x68\x1f" + "\x04\x09\x92\x90\x16\x2a\x54\x4d" + "\x07\xa7\xa0\x9c\xd5\x93\xa2\xae" + "\x65\x80\xc6\x8a\x45\xfe\x61\xd0" + "\x8c\x00\x90\x00\x1b\xbf\x33\x10" + "\xb6\x6d\x8a\xc0\x58\x95\x74\x29" + + "\x94\x87\x5d\xc3\xa7\xd3\xe6\x0e" + "\xe5\xba\x56\x03\x58\x65\x2e\x04" + "\xfd\x22\x33\x64\x8d\x69\x59\x9f" + "\x67\x19\xa6\x50\x15\xae\x79\x93" + "\x1e\x98\xc9\xfc\x62\xae\xb9\x64" + "\xc6\x34\x29\x6d\x31\xd6\xd3\xae" + "\xeb\x65\x4e\x5e\x02\xb3\x54\x24" + "\x28\x04\x95\xf9\x47\xf6\x09\xab" + + "\xcd\x71\x6e\xa6\x50\x9e\xc9\x34" + "\xe9\x13\xb7\x75\x15\xf9\x94\x17" + "\xb9\x57\x45\xe0\x90\xde\x40\x1e" + "\x18\x56\x7d\x26\x8b\x8c\x17\x3c" + "\xad\x32\x79\xc9\x7d\x10\x62\x90" + "\xd3\x1b\x31\x81\x52\x1d\x20\xa2" + "\x9e\xb7\x5b\xbc\xeb\x5e\xd6\x35" + "\xd0\xf4\x5c\xb7\xa6\x0f\x61\xef" + + "\x30\xca\xe0\x99\x61\x2a\x70\xc1" + "\xe8\x0a\x56\x99\x6b\x6a\xd4\xbf" + "\x0c\xc3\x1c\x61\xe6\xd5\x6b\xb7" + "\x6a\x98\x5b\x75\x8b\xb7\x0e\x1e" + "\xbd\x4b\x91\x34\x77\x9f\xf3\x7e" + "\xea\x56\x95\xa1\xff\x4c\xc0\xe2" + "\x57\x31\xd5\x69\xce\x8e\x8b\xf7" + "\x65\x04\xe1\xa6\x78\x26\xe5\xd4" + + "\x7b\xa3\x14\xf6\xec\xe5\x40\x3e" + "\xc2\x74\xfa\x06\x04\x9d\xf2\x74" + "\x86\x0d\x28\x61\xd8\x95\xfc\x6a" + "\x9f\x08\xf1\xae\x02\xc7\xea\xba" + "\xab\xb4\x66\x34\x2b\x7d\x2a\xe4" + "\x95\xd5\x5d\xc8\xd4\x19\xf3\x20" + "\x54\xc2\xf5\xd4\x1e\x49\x48\xba" + "\x8a\x43\x31\x33\xdb\xdd\xc1\xed" + + "\x09\x5f\xb8\x31\xd3\xd3\xb3\xc1" + "\x4a\xe6\x8a\xa8\x4a\x35\x45\x0f" + "\xfd\x50\xec\x2f\xd3\x26\xb6\xa8" + "\x4f\x83\x28\xe8\xd4\xfb\xdc\x1b" + "\x39\x25\x52\xcd\x66\x28\x5a\xe4" + "\xb3\x7a\x0f\x81\x32\x47\x9d\xfa" + "\x93\xf2\x05\xc9\xb4\xd6\xc1\xd8" + "\x97\xb5\x61\x34\x47\x80\xac\x10" + + "\x05\x6a\x43\xc2\x36\x92\xef\x11" + "\x3d\x30\x4b\xe5\xb6\x3e\x63\x97" + "\xf1\x0c\x9e\xfd\x94\x49\x17\xd2" + "\x8d\xeb\xd5\x98\x44\xc1\x11\x95" + "\x6c\x2e\x8c\xe7\xc1\xfd\x77\xe5" + "\x77\x65\x4f\xbe\x01\x74\xf3\x8d" + "\xa7\x56\x81\xd3\xa5\x82\x12\x3b" + "\x53\xbe\x16\x07\xeb\x96\x7f\xe0" + + "\x91\x25\x1f\x74\x37\x38\xcd\x29" + "\xe2\x6e\x39\x64\x9d\xc4\xdb\x4b" + "\x8f\x26\x9d\x26\x02\x71\x59\xe6" + "\x05\x63\x9a\xce\xc6\x39\x6b\x89" + "\x45\x02\xb3\x10\x71\x24\x5e\xc0" + "\x72\x00\x13\xa9\xa8\x19\x52\x84" + "\xc2\x9f\x2a\x0e\xb1\x8c\x15\x88" + "\xc6\x91\xf1\x39\x41\xf6\xc6\xcb" + + "\x56\x82\xb6\xd3\x78\x46\xa3\x7e" + "\x31\x08\xd9\x94\xf5\x4a\xfd\x01" + "\x92\x95\x2f\x6f\x2f\x4f\x91\x7c" + "\x08\x55\xb3\xf5\x23\xd6\x09\xba" + "\x1a\x7c\x95\xc1\x74\xdd\xbb\x27" + "\x7c\xd5\x16\xd7\x17\x55\x2a\xab" + "\x52\x85\x3f\x8f\x2d\x29\xa4\xd3" + "\x50\x7c\x04\xc6\xb2\x9c\x97\x46" + + "\x2c\xcd\x91\x6d\x36\x15\xc8\xe2" + "\xe4\xf0\xa3\xda\xea\xbe\xa2\x40" + "\x83\xe0\x41\x24\x59\x7a\x16\xfb" + "\x47\x03\x24\xe9\xe9\x75\x46\x00" + "\x6e\x44\x0e\x84\xff\xaa\x48\x78" + "\x72\x8f\x30\xea\x8f\x25\x9f\x9f" + "\xd9\xfa\x9b\x63\x99\x28\xf1\x50" + "\xf6\x0a\x5c\x20\x63\xae\x39\x09" + + "\x38\x79\x6d\x48\x3e\xde\xcd\xbc" + "\x45\x8f\xea\x81\xea\xc0\xb4\xaf" + "\xda\x52\xb5\xb2\x5c\x2a\xf1\x3e" + "\xe2\xea\x78\x38\x78\xa3\xe6\x6f" + "\x55\x8f\x54\x8d\x98\x53\xb8\x3f" + "\xaf\x33\x3c\x79\xc5\xa3\xaa\x47" + "\x29\xab\x5a\x11\x21\x2d\x4e\x49" + "\xde\xac\xbe\x50\xba\xce\xad\xd2" + + "\xe5\xaf\x95\xf1\x36\x12\x5d\x46" + "\x13\x44\xcd\x2d\x12\x3c\xdb\x03" + "\x5d\xb1\xf7\xc8\x35\x3b\xcf\xf1" + "\x7f\xc1\x4f\xb5\xe2\x30\x8d\xbc" + "\xae\x72\xe6\x40\xb9\xa3\x3a\xe7" + "\x75\x8f\xf3\x02\x8d\x84\x32\xa0" + "\x05\x0a\xb1\x3b\x21\xdb\xa0\x1c" + "\x2a\x90\x8d\x68\x2f\xa7\xe9\xc5" + + "\xbc\xdd\xe4\xe7\x5d\xdb\x67\xf5" + "\x63\x3b\x61\xe7\x28\x9b\x83\xbe" + "\x0d\x04\xa6\x7d\xc6\x77\xcc\x81" + "\x26\x10\x4d\x23\xfb\x88\x2b\x69" + "\x82\x35\x59\xd0\xfa\x35\x9d\x6e" + "\x98\x1b\x05\x56\xfe\x3c\x41\xc7" + "\x52\x23\x6b\xf4\x5e\xed\xce\x3c" + "\x85\x52\xa4\x3a\x21\x16\x6f\xb7" + + "\xe2\x27\xc6\x6f\x14\x75\xb1\xbb" + "\x51\x3a\x57\x91\xc5\x9b\x56\xa0" + "\xd5\x43\x82\x35\x9e\x6d\x01\xa7" + "\x92\x66\x1d\xac\x56\x0c\xac\x0d" + "\x5f\x0d\x59\xda\xb5\x33\x38\x99" + "\x91\x74\x81\xde\x03\x78\x06\xa8" + "\xd0\x75\xbf\x4d\x12\xf2\xb4\x65" + "\xfb\x0c\xf8\xcc\x32\x02\x96\xcc" + + "\x5e\x3c\xcc\xbe\xf7\xf5\xdd\x87" + "\xb9\xf8\x35\x6d\xa7\xaf\xfe\x21" + "\xcf\x77\x1d\x75\x51\x9c\x27\x41" + "\x50\x2b\xc9\x6f\xeb\x26\xc7\x47" + "\xf4\x54\xfb\x4c\xc8\xb7\x18\x4b" + "\xee\xcf\x18\xa6\xab\x8d\xf8\xb0" + "\xc8\xe0\x95\x5c\x00\x9a\x46\x3f" + "\xdf\x39\x18\xd1\xf3\x28\x12\xcf" + + "\x98\x7d\x05\xbd\x54\xcb\x32\x1f" + "\x87\x57\xc4\xe1\x02\x1a\x05\x79" + "\xcb\x32\x76\x7d\x20\x94\x85\xac" + "\x21\x94\x03\xfe\x5b\x26\x8b\xce" + "\x48\x68\x7e\x59\x3e\x0d\x9e\x1f" + "\x18\x09\x64\xe2\x14\xf4\x01\xd0" + "\xc9\x0d\x35\x8a\xcd\x48\x37\xe8" + "\x44\x04\x4f\x7b\x1e\xc8\xdd\x0e" + + "\xd0\xa9\xc6\x45\x8e\x94\x08\x7a" + "\xb7\xd8\x20\x0c\xe5\x3c\x29\xb7" + "\x71\x03\x67\x74\x29\x57\x5a\x71" + "\x40\x45\x72\xae\x98\xe7\xa9\x6a" + "\x42\xb6\x71\xf9\xec\xeb\xd5\x79" + "\xf3\x98\xd4\xaa\xbb\xb2\xd7\x6f" + "\x6b\xd4\x69\x39\xf9\xb6\x46\xff" + "\x55\xe1\xd2\x29\xe3\x9a\x38\xd7" + + "\xcc\x8a\x24\x22\x12\x3a\x08\xb2" + "\x66\xe3\x64\x32\xef\xc0\x6e\x1f" + "\x28\xee\xfd\x5a\x04\xb7\x59\x56" + "\xb5\x0b\x43\xe6\x40\x3a\x82\x7a" + "\x79\x0a\x90\xe1\x04\x2a\x59\x24" + "\x76\x65\xee\xc9\x4a\x9d\xe0\xcd" + "\x4a\xa5\x5e\x4b\x3f\x46\xb6\x52" + "\xa7\x65\xca\xd3\xd3\x9e\xfe\x1e" + + + "\xdd\x06\x54\x30\xbe\x6d\x7a\xe2" + "\x57\x19\x5d\xdd\x7f\xdc\xb7\x8e" + "\x8f\x4d\x7d\x38\x76\x68\x4a\xf5" + "\xe4\x2d\x76\xc7\x09\x94\x47\x9c" + "\x78\x07\xb3\x99\x5d\x5b\x4d\xbe" + "\x82\x36\x79\x6e\x56\x0c\x38\x25" + "\xe3\x40\xc7\xda\xf3\x37\x2d\x60" + "\xae\xe4\x66\x15\xbe\xea\x0d\x14" + + "\x1e\x86\x9a\xc4\x26\x61\xee\xea" + "\x06\x0d\x4f\xe1\x65\x3b\x4f\x02" + "\x17\xfc\x9b\xc6\xe8\xf1\xa3\x51" + "\x81\x63\x68\xa7\xe9\xa8\xc3\xc3" + "\xc8\xd4\x03\xb1\x2c\x75\x00\x34" + "\x6b\xb3\x18\x92\x13\x46\xbc\x02" + "\x4a\x50\x51\x76\xeb\x75\x7f\xc6" + "\xfa\xeb\x2a\xd0\x56\x8b\x84\xd6" + + "\x9b\x26\x82\x17\xdb\x81\x83\x95" + "\x50\xe5\x97\x25\x79\xbf\x34\xae" + "\x53\x51\x38\x5f\x64\x60\x5c\xbb" + "\x48\x80\x08\xe3\xaf\x96\x0e\x6f" + "\x56\x44\x88\x77\x15\x02\x6a\xbf" + "\xa7\x0e\x31\x69\x8c\x68\xb5\xb3" + "\xde\xd2\xfa\x04\x95\x42\xc9\x17" + "\x4d\x6d\x89\x17\xe5\xf0\x20\xe0" + + "\xa9\xa1\xe5\xbb\x8d\x42\xa4\xcc" + "\x67\xbd\x26\x31\x5f\xfd\x87\x81" + "\x26\x58\x10\x48\x3a\x97\x36\x00" + "\xa0\x61\xbd\xb8\x63\x66\x9b\xa3" + "\x08\xa8\x65\x2d\xef\xde\x42\x6d" + "\x19\x6b\x63\x94\x4f\x04\x69\x49" + "\x4c\x56\x5d\xdd\x47\xee\x11\xf6" + "\x77\x30\x87\xd2\x49\x3a\x2f\x7b" + + "\x14\xb2\x82\x0f\xdd\xd8\xb0\x03" + "\xc6\xcb\x03\xf1\xf9\x34\x0c\x46" + "\x19\x9e\xd7\x18\x03\x5c\x2e\xf3" + "\xf8\x17\x41\xa8\xba\x88\x88\x8b" + "\x77\x26\x72\xc0\xdc\x37\x3c\x8f" + "\x27\x0f\x1c\x1c\xe9\x1b\xd2\x10" + "\xc6\xa0\xf7\xe0\x68\x84\x7c\xd4" + "\xe0\xc0\xec\xad\x13\x22\xf0\x9b" + + "\x6e\x7b\xfe\xb7\x60\x41\x55\x97" + "\xb2\x3f\x0a\x40\x9a\x18\x16\x7d" + "\x1e\xca\x28\xe3\xea\x9b\x3e\xd7" + "\xcc\xd8\x93\xe7\x97\x4b\xd0\x0d" + "\xcc\xb8\x6d\x50\x9b\x3c\xc8\xa9" + "\x4c\x81\x38\xcf\xae\x7a\xd4\x5c" + "\xe6\x45\x4b\xb6\x0d\x43\xfc\x26" + "\x84\xea\x18\xd8\x99\x54\x9b\x07" + + "\x41\x29\xac\xe0\x1a\xd2\xb5\x03" + "\x37\x19\xd3\xc2\x54\x02\x9b\x27" + "\xd0\x92\xc9\xca\x52\xc0\x07\x33" + "\xf3\xb1\xa8\xef\x92\xcb\xa7\x6a" + "\xa5\xc7\x37\x0d\x80\x25\x18\x5a" + "\x22\x54\x2d\x34\x37\x0c\x38\x13" + "\x92\xef\xd2\xd5\x66\x2d\xac\x92" + "\xc6\x63\x0c\x03\xc9\x70\x5a\x03" + + "\x61\x18\xba\x71\x85\xb7\x09\x51" + "\x3d\xf9\xc8\xd0\x5c\x2d\xb2\x48" + "\x93\xbb\x33\x86\xa7\x84\xfa\xe8" + "\x08\xbd\xeb\x5a\xba\xa6\xfb\x53" + "\xd8\xa7\xee\xe5\xf3\x7d\xf2\x7f" + "\x58\x71\xca\x68\x96\x87\x1c\x52" + "\x05\x1a\x6f\xce\x3b\x13\xd5\xb9" + "\xe4\xbe\x0e\xfd\x53\xcd\x50\x2d" + + "\x17\xff\x4c\xf7\x33\xa1\xeb\x14" + "\xf2\x13\xb8\xec\x03\xaa\x0a\x24" + "\xee\x5b\x66\x6f\x40\x65\xbb\xcf" + "\x73\xad\x25\xa4\xe4\x1f\x4b\x08" + "\xa6\xf6\x81\xd0\x16\x5d\x9d\x00" + "\x90\x2c\xf8\xee\xe8\x4f\x30\x35" + "\x22\xaa\x9e\xaa\xd5\x46\x03\xf2" + "\xe3\x91\x1c\xac\x07\x9f\xda\x0a" + + "\xcf\xf1\x0d\xb4\x23\x3e\x9b\x7d" + "\xb4\x71\xe9\x94\x73\x73\x33\x59" + "\x21\xf9\x9c\x66\x14\xbd\x57\xbf" + "\x64\x10\x1a\x0c\xdf\xae\x5d\x86" + "\x25\x91\x27\x83\xd3\x0b\xb7\x3e" + "\xab\xda\xec\x34\x9f\x5b\x3d\xbc" + "\xaf\x5c\x75\x5f\x7e\xed\xe3\x91" + "\x02\x6f\x1e\xd4\x54\x9f\x69\x49" + + "\x34\x48\x3e\x0f\x58\x77\x41\x30" + "\xcb\xaf\xa9\x17\xc2\x21\xbb\xfd" + "\xb3\x67\x9a\x2f\x7f\xa1\x6f\x75" + "\xa8\xc1\x45\xa2\x21\x24\x6b\x2a" + "\x91\x22\xf0\x4a\x94\x27\xbe\x64" + "\xfe\x04\x58\x2a\xc6\x65\xe4\xad" + "\xd7\x8f\xf0\xa6\x39\xbd\xff\x8d" + "\x3b\x40\x14\xaa\x4c\xa8\xef\xc4" + + "\x27\x84\x71\x47\x46\x80\xb4\xda" + "\x8b\x0f\x83\x6e\x9b\xff\x17\xdf" + "\x47\x13\x9a\xe4\xe8\x7e\x8d\x40" + "\xae\xd4\xc1\x91\x23\x1e\xc7\x6a" + "\x3c\xd7\xef\x1d\xfd\xb9\xcb\xc8" + "\xc5\xfe\xbb\xbb\x57\x06\x84\x19" + "\xea\xf8\x7e\x9e\xb5\x1c\xdb\x39" + "\x30\x5f\x10\x64\x96\x82\xaa\x78" + + "\x4a\xef\x5f\x06\xc2\xf1\xbe\xcd" + "\xe3\x92\x5b\xfd\x7d\x0f\xe6\x77" + "\x50\x83\x70\x26\xf0\x49\xc5\xd7" + "\xbf\x21\xf1\x34\xd0\x3a\x1b\x20" + "\x14\xfc\x34\x03\xa1\xc2\xca\x5f" + "\xf6\x52\x45\x34\x09\x9e\x9a\x8a" + "\x82\x30\x65\x97\xd3\xa1\xd8\x7d" + "\x89\xf2\xd4\x79\x8f\x73\xc0\x5f" + + "\xba\x02\x35\xbd\x71\x8e\x60\x67" + "\xa0\x75\xde\xb4\x24\x1f\xf4\x4e" + "\xe5\x25\x61\xfd\x5e\xde\x8d\xb0" + "\x3f\x54\x09\xa4\x25\x48\x48\xde" + "\x95\x22\xcc\x65\x98\x8d\x19\x1f" + "\xa2\xdf\x0e\x6e\x71\x37\x8a\x42" + "\xc7\x5f\xf3\xad\xa2\x97\x96\x4f" + "\xc7\xc3\xca\xf7\x79\x3c\xa4\x01" + + "\x0c\x44\xae\x7c\x5b\x8d\x25\xc1" + "\x31\x75\x2b\x40\x41\x8b\xc0\x21" + "\x21\x23\x93\xde\x55\x89\x1a\xf6" + "\xaf\x08\x14\x2d\xf8\xfa\x68\x35" + "\x5b\x96\xcf\x9e\x99\x5e\xb1\x71" + "\x6f\x27\x17\xe9\x48\xd2\x4e\xf1" + "\xe2\xf9\x0c\x82\xa1\xca\xf4\xc6" + "\x7e\x3c\xd8\x18\xb2\x20\x1b\x68" + + "\x17\xf2\x3e\x53\x65\x6d\x9f\x88" + "\x87\x2e\xca\xc3\xe4\xc7\x58\x71" + "\x67\x41\x2b\xdc\xfb\x0d\x67\xfb" + "\x7f\x25\x4c\x84\x01\x0a\x91\x75" + "\x7d\x57\x88\xcf\x07\xbf\x36\xf3" + "\xce\x2a\x5e\xe4\x50\x52\x24\x22" + "\x85\x3d\xa2\x7c\x8d\x2e\xd9\x2e" + "\x58\x2f\x81\x2b\x4c\xbe\xf8\x29" + + "\x92\xba\x67\x34\x97\xf1\x5b\xd6" + "\xb0\x54\x09\xf7\xdb\x46\x9b\x8c" + "\x5d\xf1\x78\x0e\xf3\xa0\xc8\x97" + "\x61\xc9\xa4\x85\x9a\xa6\xf3\xa8" + "\x9b\xce\xe4\x61\x0f\x66\x42\x42" + "\x0c\x79\xa6\x6e\xb3\xaa\x06\xbf" + "\x16\x64\x98\xec\x8e\x6f\x70\xc6" + "\x25\xc2\x9f\x9a\xc1\xde\x56\x9e" + + "\xf1\x03\x51\x9a\x71\x32\xee\x4b" + "\x06\xac\x0e\xf5\xc6\xef\x43\x52" + "\x19\xc1\xdc\x6a\xcb\x22\xe1\xb8" + "\x08\x0a\xb8\xc0\x84\xaa\x7f\x1b" + "\x8c\xd0\xfc\x6d\xbd\xd1\xc3\x32" + "\xde\x27\xe4\x0b\x4e\xec\x9d\x12" + "\x83\x3c\x26\x1d\x9c\x67\xab\x98" + "\xff\x4e\xf6\xce\xb7\x3c\xc8\xaf" + + "\x51\x5a\xdf\x3f\x7d\xe4\x87\x1d" + "\xb0\xca\xc9\x55\x93\x5f\xfb\x7a" + "\x6e\x58\xe0\x89\x8f\xf5\xbb\x91" + "\x09\x37\x84\x0d\x18\xc0\x72\x7c" + "\xdc\xc3\xb5\x99\xfb\xaa\xa5\xa9" + "\xb0\xae\x44\x38\x1d\x0f\x8a\xa4" + "\x82\xe4\x67\xb6\xdd\xb7\x78\x71" + "\x9a\xa5\x23\x6e\xe9\x85\x39\x45" + + "\xa5\xb8\xf4\xea\xe0\x4d\x6a\xaa" + "\x32\x0e\xc6\x4b\xca\xd9\xcf\x68" + "\x70\x5e\xd1\x7f\x01\x4b\x8a\x66" + "\x9d\xc0\x7d\xf2\x4a\x69\xf0\xd9" + "\xcd\x8b\x70\xba\xd5\xca\xc3\xf6" + "\x2a\x5c\xb9\x5b\x69\xba\xd2\x5c" + "\x8f\xa5\xc0\x33\xd3\xc1\x28\xaa" + "\x70\x78\xc7\xab\xe3\x74\xe2\x23" + + "\x4b\x88\xc1\x1c\x2d\xc8\xcf\xec" + "\xb4\x53\x47\x5d\x01\xc2\x5a\xc8" + "\x9f\x09\x8e\x65\xac\xca\xa6\xc7" + "\x90\x73\xb2\x04\x9e\x36\x46\xcf" + "\xea\x67\x64\x50\x49\xd0\xe7\xe2" + "\xcc\xec\xcd\x37\xa2\x63\x1b\x48" + "\x3a\x14\x80\xed\xd8\xab\x29\x40" + "\x88\x0b\xb0\xbc\xc7\xe3\xbf\x28" + + "\x0b\x4a\xe2\x33\x2f\xf8\x57\xff" + "\x79\x50\x56\xf2\x3f\xe2\xbe\x9c" + "\x25\x58\x5f\xeb\x27\x34\x35\x16" + "\x62\xd6\x48\xe9\xc4\xee\x6f\x27" + "\x2b\x03\x10\xda\xc6\x2b\xb6\xd1" + "\x53\x2a\xe7\xf0\xdd\x51\x83\x71" + "\xba\xe7\x20\x24\x76\x20\x45\x93" + "\x8d\x11\x00\x3a\xff\x8f\x36\x96" + + "\x6b\x4c\x7c\x9c\x15\x53\x97\xd8" + "\xf7\x9a\x40\xd7\xc0\xa3\x3a\x60" + "\xfb\x32\x71\x00\x0c\x3d\xd5\xb8" + "\x38\x92\x84\xa6\xf7\x2a\xd1\x68" + "\x79\x92\x5d\xbf\xe7\x07\x06\xbe" + "\xce\x74\xda\xaa\x55\x00\xa5\x9a" + "\xcb\x8c\x7e\xba\xcb\x79\x10\xe8" + "\x5e\xff\xf4\xa5\xd1\x71\x0c\x61" + + "\x61\xa6\xb6\xe3\xbf\x81\x47\x18" + "\xf7\x79\xd2\xe6\x1d\xcb\x51\x77" + "\x62\xb6\x9e\xc5\xd6\x95\xff\xf8" + "\xa7\xde\xd3\x58\xb7\x90\x6d\x18" + "\x54\xf7\xb4\xdf\xc1\xb6\x4b\x0e" + "\xdc\x01\x28\x2b\x6b\xf5\x5c\x5c" + "\x4d\x56\x54\x1f\x52\xe4\x61\xc5" + "\x13\x7f\xdd\xf0\x60\x8c\xfb\xb4" + + "\xb3\x81\xfc\x29\x0b\x20\x4c\xac" + "\xc1\x87\x1d\x17\x9f\xe0\xc3\xeb" + "\x9e\xaa\x81\x14\x30\x95\x79\x91" + "\xfa\x14\xe1\x92\xe1\x92\x1b\x05" + "\x7f\x53\xb5\xec\xe9\x92\x8f\xdf" + "\x83\x74\x0c\x29\xcc\xb2\xb1\x44" + "\x16\xb0\xde\x2a\x5a\x45\x11\xa7" + "\x2c\x0c\xa1\x81\x56\x68\x4b\x96" + + "\x7a\x56\x88\x40\x08\x59\xf4\x73" + "\x61\x4a\x21\x1f\x0e\x28\x6b\xeb" + "\x3d\xc1\xf0\xca\x34\xdc\x9a\x8c" + "\x80\xfb\x61\xf5\x38\x29\xd1\x39" + "\xb4\xdf\x6e\xbc\x5e\x3a\xdc\xb2" + "\x0e\x21\x4d\xfe\xb1\xb1\x85\x74" + "\x72\xae\x86\xe1\x00\x04\x2e\x06" + "\x88\x3b\xeb\x6e\x5c\x2d\xe3\x91" + + "\xfa\xde\x34\xb1\x85\xae\xe9\xc7" + "\x75\xd4\xb2\x1b\xd0\xb1\x73\x60" + "\x0d\xc0\x63\x28\x5e\x61\xad\xb9" + "\xc4\x4a\x5f\x52\x3d\x49\x29\x9e" + "\x4f\xcf\x9a\x4e\xea\x1d\x2b\xc3" + "\x8d\xb8\x0d\xa5\xc8\x01\x1f\x3e" + "\x6c\x91\xda\x04\xea\x70\x5d\xb0" + "\x3e\x80\x65\xd8\x0a\x0d\x4b\x71" + + "\xee\xaf\x79\xe0\x0c\x92\x45\x59" + "\x1f\x83\x89\x67\xa0\x17\x6e\x68" + "\xe5\x5a\x4a\xb7\xe8\xbe\x66\x59" + "\x46\x8d\x25\x1e\xa2\x73\xa6\x38" + "\x95\x1c\x14\x83\xf2\xc1\x1c\xbd" + "\x86\xe4\x96\x0e\x4f\xcf\x2e\x3b" + "\x78\xfc\xe5\x74\x96\xa8\x3a\xcd" + "\x7a\xfa\x82\x24\x0c\xc1\x5e\x41" + + "\x10\xf5\xc3\x6e\x31\x5a\x20\x85" + "\x75\x04\x98\xd2\x14\x4a\x7e\x2c" + "\xfd\xeb\x30\x6f\xc0\x19\x3c\xde" + "\x44\xe6\xb7\xd4\x38\x1f\x1c\xdb" + "\x4a\x36\xce\x5d\x75\x1a\x29\xfe" + "\xe3\x5b\x8f\x05\x3c\x2a\xb2\xb7" + "\x8c\xa3\xfe\x37\x02\xc3\xd2\x2c" + "\x17\xbe\x17\x2e\x7a\x96\x30\x29" + + "\x44\x0a\x5b\xa1\x5e\x79\x0f\x02" + "\x58\xa9\x58\x89\xd7\xc8\x37\x8f" + "\xb5\x75\xb6\xa4\x9b\xe8\xb7\x63" + "\xea\x1a\xc3\x0f\x0c\x0c\xfb\xb4" + "\x2e\x1f\xff\xa7\x39\xe6\x95\xed" + "\xfb\x14\x96\x61\xa3\xf5\x80\x98" + "\xab\x51\x71\x94\x02\xff\xb6\xde" + "\xdb\xdc\x68\xa8\x8c\x11\xc5\x5b" + + "\xed\x7a\x9f\x34\x91\xcb\x97\xf1" + "\x20\x84\xca\x8f\x00\x5a\x2b\x3b" + "\xd8\xf6\xaa\x23\xe8\x5e\x17\x7c" + "\xb6\x32\xaf\x35\x21\xf4\xdc\x54" + "\x1e\x56\xd6\x27\x07\x43\xa1\x0b" + "\xe2\xb1\x75\xd1\xe4\x5e\x9d\x87" + "\xb5\x7d\x80\x99\x73\x36\xc4\xc7" + "\xcd\x5b\xd5\x9c\x55\x44\xa5\x77" + + "\xd9\xff\x33\x21\x45\xb2\xb9\xfb" + "\x20\x1a\x0f\x83\xf1\xb2\xa8\x39" + "\x2a\xf5\xa1\xd5\x7d\xc9\x4b\x48" + "\xf8\xdd\x0e\xa4\x56\xbf\xae\xd6" + "\xc6\xda\xcc\x76\xcb\x7a\x25\x32" + "\x27\xff\x86\x15\xec\x36\x4d\xaf" + "\xd1\x7d\xde\xf8\x63\x88\xaa\x8e" + "\x16\x7c\x64\x88\xcf\xd5\x45\x00" + + + "\x9d\x97\x05\xc0\x74\xd5\xf3\xa6" + "\x50\xe3\x40\x6a\x42\x2b\x07\xc2" + "\xf9\xec\xe2\x8d\x56\xc1\xa5\xfc" + "\x4e\x34\x15\xa5\x5b\xbf\xc8\xa8" + "\x4a\xf1\x4d\x11\x55\xe5\xae\x97" + "\x6b\xec\xc5\xfd\x4d\x4a\x37\xd4" + "\x18\x54\xa8\x2c\x8f\xc2\x4c\x75" + "\x78\x1f\xc4\xd3\x27\x9e\xcb\x71" + + "\x39\x5c\x60\x03\x79\x50\x10\x89" + "\x6c\xc9\x42\xa1\x9e\x3d\x84\xf0" + "\x84\x36\x92\x16\x34\x49\x74\xf3" + "\x93\x28\x0a\xfa\x2f\xaa\x2c\x73" + "\x70\x01\x16\x61\x70\xc2\xe8\xb2" + "\xa3\xba\x7f\x43\xcc\x88\x27\xc3" + "\xac\xa3\xed\xa6\x8e\x81\xcd\x39" + "\x07\x2e\x2b\x9e\x39\x42\xe9\xe2" + + "\x2a\xe5\x60\x02\x9b\xd3\x67\x69" + "\x25\x33\x65\x90\xcc\x85\x25\xd4" + "\x54\x79\xca\x21\x05\xd6\x9b\x0d" + "\xb3\x57\xed\x81\x77\x08\xa2\x4f" + "\xbe\x0b\x4a\xe3\xf8\xef\xc1\x60" + "\x64\xef\xf6\x84\x0c\x04\xb0\x56" + "\x83\x84\xaf\xb1\x24\x2b\xbe\x28" + "\x14\x16\x53\xf5\x63\x81\x27\xb2" + + "\x1c\xac\x22\x59\x45\x75\xf2\x8d" + "\x63\x3f\x2b\xa5\x5c\xef\xb3\xa7" + "\xc4\x57\xde\x71\x14\xb2\x77\x8e" + "\x8b\x00\x4c\x83\x10\x2c\x68\x31" + "\x31\x5d\xd5\x4b\xf0\x24\x68\xc7" + "\x71\x1c\xb6\x17\x86\xc0\xd1\xb6" + "\x9d\x08\xa5\xc2\x03\x09\xdb\x31" + "\x3f\x5d\x4e\x18\x72\x21\x09\x9c" + + "\x38\xc6\x0c\xc0\x5b\xed\x7c\xdd" + "\xc2\x8f\x27\x61\xeb\x15\x20\x1a" + "\xd6\xf8\x37\x6a\x88\x52\x8e\x2e" + "\xad\x33\x99\xe7\x6f\x78\x57\xc4" + "\x1a\x21\x51\x2c\xce\x4c\xfe\xb3" + "\x98\x04\xc2\x24\xb2\x10\x9b\xad" + "\xe5\xb5\x8d\xd2\x4f\x7a\xd8\x90" + "\xc3\x2f\xca\x3a\x05\xd1\x8c\x69" + + "\x6d\x53\x1b\xe9\x07\x2d\x11\x4f" + "\xd6\x09\xba\x9e\xf2\x82\xb9\xce" + "\x6f\x39\x7c\x19\x2c\x7b\x15\x3c" + "\x24\xeb\x66\x7b\x41\x2d\x3c\xe2" + "\x37\x0d\x33\x3f\xd9\x57\x0c\x48" + "\xeb\x8d\x10\x79\xa1\xc8\xa4\xb3" + "\xe5\x9c\x19\xcb\xde\x88\x23\x70" + "\xd4\xa8\x44\xb9\x11\x92\x01\x0b" + + "\x36\xb3\x0b\x84\x92\xa6\xf2\x24" + "\x7b\xfa\x69\xa6\xdc\x3b\x35\x7c" + "\x00\xc3\xc9\xde\xfc\xd6\x20\xda" + "\x17\x4f\x3a\xa1\x2f\xbe\x5f\x62" + "\x28\x73\xc1\xdb\x1a\xb6\xb1\xa2" + "\x21\x56\x51\xa9\xbf\x65\x89\x00" + "\x46\xff\x20\xc6\x39\x09\x69\x49" + "\x1c\xe9\x17\x87\x7d\xd2\x2d\x18" + + "\x97\x39\x6c\xea\x35\x50\xce\x5a" + "\xef\x0b\x61\xc2\xaa\x9a\x25\x54" + "\x39\xdd\x80\x3c\x3f\xbb\x18\xef" + "\x39\xfa\xc3\x5f\x5b\xb9\x10\x69" + "\xee\x9a\xe0\x43\x10\xf5\xe2\xfc" + "\x65\x56\x67\xa7\x9f\x6c\xd5\xce" + "\x61\xdb\x72\xd8\xac\x65\xe2\x10" + "\x69\xce\x9f\xae\x2e\x81\x82\x69" + + "\x98\x09\x80\xce\xc6\x11\xbe\x29" + "\xd9\x60\x03\xb9\x52\x17\xbb\x72" + "\x90\xd5\x4a\x5a\x97\x31\x19\x2c" + "\xc0\xdb\xc1\x9f\x48\xf5\xa2\x2b" + "\xe0\xeb\x90\xe4\xbb\xee\xe4\x7f" + "\xc0\x11\xae\x7f\xcd\xa4\xa0\x12" + "\x37\xba\x03\xe9\x81\xcf\x97\x71" + "\xd8\x6d\x1c\xde\xa8\x4a\x7d\xcf" + + "\x4c\x68\xd5\x3f\xf4\x6b\xaf\x92" + "\xa1\x0a\x36\x80\xcf\xee\x26\x2b" + "\x82\x6a\x54\x00\x30\x0f\x96\xbd" + "\xfe\xd8\x9a\xf5\x43\x3c\x7b\x40" + "\xba\x82\x9c\x24\xfe\xe5\xca\x86" + "\x4c\x74\x63\x24\xc7\xae\x0f\x9e" + "\x72\x62\x91\x94\xe8\x51\xf5\x87" + "\x15\x06\xeb\x6c\x44\x93\x3f\x03" + + "\x84\x2e\xe8\x8b\xd1\xb0\x5e\x1e" + "\xef\x2f\x58\x7a\x0e\x7f\x96\x89" + "\xfa\x21\xe9\xa6\xd5\x87\xf6\xbc" + "\xba\x09\x7a\xd3\xf3\x4c\xee\xdf" + "\x65\xc4\x93\xb4\x65\x69\xf0\x94" + "\x30\xc0\x35\x76\x1c\x9a\x8b\x63" + "\x9f\x5e\xf0\x66\x64\x78\x66\x76" + "\x25\xa7\x4d\xc0\x08\x68\xaf\xcc" + + "\xfc\xcc\x8f\x76\x90\xb6\x2e\xca" + "\x62\xb3\x35\xb8\x7d\xd3\x02\xf4" + "\xce\xfc\xfd\xe2\xd0\xc0\xfa\x0e" + "\x90\xd9\x38\xb6\xef\xcd\xc9\xef" + "\x8b\x9a\x66\xd1\x72\x2b\xf1\x2a" + "\xbd\xcc\x74\x57\xbc\x36\xc5\x33" + "\x0e\x87\x34\xfb\x09\x19\xb2\x30" + "\xca\x5a\xf2\x7d\xf7\xa2\x8f\xc3" + + "\xf5\xf3\x81\xbf\x2b\xf0\xc5\x74" + "\x81\x45\x7e\xaf\xae\xa5\x25\x05" + "\xae\x54\x3c\x43\xba\xaa\xd2\x88" + "\xc5\x56\x6a\x80\xdb\x75\x97\xed" + "\x7d\xb3\xed\xc0\x8a\x73\x20\xd3" + "\x51\x1f\xcc\x66\xee\xb6\xfd\x25" + "\x76\x0d\x60\x10\x17\x1d\x66\xac" + "\x76\xed\xd1\xbd\xf3\xc1\x1e\x93" + + "\xf1\x43\xee\x19\x62\x1d\xc1\x65" + "\x97\x9d\x82\x60\x3e\x7c\xd5\x5c" + "\xe8\xe6\x4b\x98\xa3\x91\x6c\xd2" + "\xbd\x53\x0c\x8b\x09\x93\x8d\xf0" + "\xea\xe4\x16\xc0\x5b\x9e\xbc\x94" + "\x2b\x3d\xd4\x11\x39\x68\x91\xd3" + "\x55\x11\x70\x73\xd7\x5a\x6c\x88" + "\x15\x07\xb0\x20\x26\x76\x37\xe0" + + "\x59\xba\x80\xaa\xec\xc9\x01\x7f" + "\x51\x8e\x53\x68\x1a\x41\x83\x30" + "\xaf\x28\x81\xe8\xf1\x70\x03\x97" + "\x4b\xc1\xde\x91\xdb\xc3\x5c\x62" + "\x07\x31\xac\x01\x6c\x66\xf9\xfe" + "\xc3\x7a\x05\xd5\x77\xd5\xa8\xb2" + "\xf7\x5d\xbe\x92\x99\x62\xf2\xb0" + "\x24\x39\x35\x00\xe5\xc8\x79\xf5" + + "\x7a\xed\x41\x13\x93\x3d\xfa\xb8" + "\x49\x9d\xb5\xa7\x2c\x27\x23\x42" + "\xa4\xc4\xb8\x83\x47\x19\xcb\x3d" + "\xe4\x02\x13\xed\x01\x3c\x41\x4e" + "\xce\x44\x7e\xe1\x27\x91\x99\x6d" + "\xfb\xad\xb3\x33\x75\xbf\x86\xee" + "\xca\x96\xaa\x25\xe6\x2f\x90\xf6" + "\x7d\xe4\xaa\xe5\xe4\x40\x35\xb7" + + "\x8c\x15\x4a\x1b\x7b\x1d\x80\x32" + "\x69\xa3\xe2\x27\x9e\xc9\x71\xe5" + "\x97\xf1\xd9\x10\xc0\x76\xcb\x40" + "\xae\xc0\x67\x31\x89\xc2\x08\xc3" + "\xf2\x58\x79\xeb\xd3\x9d\xef\xa6" + "\xb1\x79\x08\x30\xfc\x6d\x22\xa7" + "\x36\x06\xdf\x7e\x62\xb3\xd0\x6c" + "\xed\x7e\xc3\x7b\x6c\xce\xfb\x4e" + + "\x21\x90\x69\x8d\x05\x2a\xf9\x75" + "\xe3\x66\x25\x77\x79\x4c\x6d\x58" + "\x3a\xd2\x1a\x76\xf1\xa5\x8c\x37" + "\xac\xa8\x65\x14\xfc\x86\x0d\x65" + "\x51\xa2\x2b\x84\x57\xd4\x4e\x7a" + "\x33\x49\x23\x42\xe6\xe3\x65\x6b" + "\x57\xd6\xaa\x31\xb7\x43\x15\xaf" + "\x69\xc3\xfe\xcb\x98\xfe\xce\xa4" + + "\xfb\xbe\x47\x9f\x90\xda\x87\xb5" + "\x13\x2d\x31\x41\xfb\xe9\x62\x65" + "\xfe\xce\xf1\xef\x59\xea\x91\xa6" + "\xf6\x4c\xfc\x05\x7a\x47\x30\xcc" + "\x3d\xfd\x0f\x0b\x61\x24\x63\xa1" + "\x56\x59\x35\x5b\x3b\x6f\xf1\xa1" + "\x24\xec\x24\x42\x53\x8d\x14\x5b" + "\x2a\x01\x77\xf9\x7b\x4e\x83\xdc" + + "\xbc\x9d\xc6\xb2\x75\x5e\xfc\x7b" + "\x6c\xda\xc3\x03\x29\x7a\xa7\x3a" + "\x71\x02\x91\xca\x3c\xf0\x0d\xde" + "\x55\xdc\x06\x78\x4a\xca\xd5\xcb" + "\xcb\x76\xb4\x6d\x07\x58\xca\xe1" + "\x1e\xa3\x37\x5f\x62\x5d\xe1\xfd" + "\x16\xf4\x1a\xf4\x20\xf5\x9a\xf4" + "\xb5\x2d\x34\x7d\xb1\xc5\xc5\x96" + + "\x9b\xeb\x4c\xeb\xb7\x43\x5c\x15" + "\x1a\x37\x77\x4e\x10\x30\x99\x2e" + "\xaf\x43\x5d\x67\xda\x87\x29\x1d" + "\x72\xfd\x99\x85\xc0\xc1\x2b\xef" + "\xb2\xf6\x42\x93\x7b\x4b\x89\x96" + "\xf0\x71\x8e\x7c\xf2\xad\x1e\x20" + "\xfc\x3e\x1f\x4a\x9f\x9d\x47\xf3" + "\x04\x97\x2a\x70\x42\xa7\xf8\xe0" + + "\x0c\xa4\xeb\xb3\xb6\x44\xfd\xea" + "\xd0\xe0\xc1\xc1\x29\x9f\x73\xf9" + "\x5e\x50\x9d\x61\x1a\x47\x91\x00" + "\x3e\x26\x7c\x9d\x96\x9c\x5f\xc1" + "\x33\xbe\xaf\x83\x85\x72\xe4\x5b" + "\x92\xe0\xf1\x04\xaf\xd6\xb6\xa3" + "\x11\x9d\x1a\x75\xb9\x26\x65\xe7" + "\xd2\xe4\x4a\x9a\x6d\xb2\xc5\x2e" + + "\x8d\xfb\xf6\x02\xd9\xf4\x66\xeb" + "\x64\x21\x91\x96\x61\xc5\x63\x40" + "\x00\x30\xef\x80\xc1\x50\x70\xeb" + "\xf0\xb3\xa5\xea\x33\x1c\x8d\x28" + "\xd8\x6f\x80\x07\xd6\x68\x7c\xe8" + "\x0f\xf5\xbb\x4b\xd5\xf9\xf7\xb2" + "\x27\x66\x8d\xac\x3a\x2f\x97\x25" + "\x3b\xc1\xe8\x10\x74\x77\x54\xf8" + + "\x60\x4a\x2b\x87\x6c\xef\x50\xcc" + "\x1b\x52\x13\x46\xa4\x34\x2a\xab" + "\xd1\x15\x3e\x98\x90\xc1\xc5\x39" + "\x12\x55\x90\x59\xdf\xe5\xdd\x61" + "\xf3\x75\x22\x9f\x21\xf6\x17\xe4" + "\x4b\x89\x1d\x45\xb6\xc8\x50\x07" + "\xaa\xbd\xb0\x78\xb9\x4a\xb0\x75" + "\xbd\x89\x85\x45\xd4\x9f\xfd\x3b" + + "\xb6\x20\x91\xee\x30\x3e\x01\xf1" + "\x3e\x74\xa4\x23\x93\xaf\x51\x2b" + "\x9e\x4d\xd1\x48\xae\xff\x96\xea" + "\x32\x1d\x8a\x69\xbe\x0d\xdc\x71" + "\xa4\xcc\x80\x01\xd2\x62\x49\x91" + "\x63\x89\x56\xc3\x77\x06\xe6\x1a" + "\x44\xc4\x7b\x43\xb1\x27\xf2\x8c" + "\x7a\x2c\x96\xc9\x3b\xc8\x50\xc6" + + "\xc4\xcf\x7c\xfe\xdd\xc7\xc2\x23" + "\x48\x9d\x92\x1b\x9d\xc8\x25\xf9" + "\x33\x3c\x78\x06\x4b\xf7\x60\x44" + "\x5a\x47\x90\xa5\x49\x8d\x2c\xac" + "\xa0\xbb\x07\xb8\x07\xb4\x40\xfb" + "\x3a\x8f\xff\x69\x2d\x36\x1e\x9d" + "\xa4\x64\xef\xcb\x81\x96\x3e\xa3" + "\xb2\xb4\x2f\x33\xfa\xe5\xec\x67" + + "\xe3\x10\x9f\x73\x9b\xa9\x00\x69" + "\x25\x59\x52\xff\xa9\x1c\x34\xc3" + "\x41\xd0\xe2\xa9\x26\xa6\x18\xee" + "\xdd\x0d\x58\x29\x85\x36\xa8\xa5" + "\xcd\xe3\x7d\x9d\x81\x0c\x47\xf3" + "\x9c\xcf\x62\x20\x86\x25\xf0\xed" + "\xb0\xed\x10\xc0\xfa\x22\x35\xf4" + "\xae\xb1\xa4\x13\x35\x41\x31\x30" + + "\x4b\xb9\x22\xdb\x2a\xe0\x92\xc7" + "\x5b\xa4\xea\xa1\xe9\x8a\x3d\x99" + "\x63\x1c\x1e\xcd\xd3\x6c\xad\x8a" + "\x8a\x68\xce\xc5\xa7\x9c\x52\x89" + "\x53\xa2\x72\xe5\xaa\xe3\xce\x2c" + "\xfb\x1e\xa2\x02\x38\x64\x2b\xe0" + "\x58\x03\x43\xc9\x6e\x1b\x09\xa7" + "\x04\xb5\x7d\x9d\xfa\xb1\xd1\x06" + + "\x33\x47\x74\xc4\x32\x6d\x84\x58" + "\x34\x9e\x9f\x37\x71\x7c\x51\x40" + "\xca\xf6\x0e\x13\x5f\x65\x65\x2f" + "\x3f\x50\xf3\xf1\x88\x44\x6e\x52" + "\x76\xa9\xe4\x7e\x17\xbd\x67\x84" + "\xd1\x63\x13\x92\x13\xc9\x9d\x1d" + "\x41\xe0\x69\xb0\x33\x4c\xd2\xd8" + "\x51\x7f\xdf\x2c\x0a\xda\xb5\x5e" + + "\x4f\x99\x7b\x19\xb1\x3c\x0f\x1c" + "\xe9\xea\x43\x28\xc5\xa6\x95\x3c" + "\xa5\x7e\x09\xa6\xc9\xff\x66\x77" + "\x67\xb8\x23\xd7\x93\x40\xea\x7b" + "\xf9\x78\xb3\x4d\x73\x1f\x8e\xb4" + "\xac\x77\x7b\xe3\x00\x5b\x02\x70" + "\x46\xad\x24\xaf\xe7\xc8\x3d\x94" + "\x85\x0a\xd0\x16\xac\x15\x8a\xb9" + + "\x04\xb0\x43\x27\xba\x38\xdc\x3a" + "\xee\x15\x44\x33\xf7\xf4\xc7\xb1" + "\x5a\xd0\x62\x1e\x8f\xdf\x43\xea" + "\xb6\xa3\x76\x9d\x05\x89\x61\x32" + "\x46\x0f\x3a\xa2\xb5\x0b\xbd\x2f" + "\x8c\x91\x01\x6a\xdb\x71\xc9\x5b" + "\x94\x3f\x74\xb4\x4a\xd9\x01\x78" + "\x2b\xe2\x6a\x67\x5e\xf6\x4d\xb9" + + "\x4c\x89\x95\xaf\xab\xbf\xfc\xaa" + "\x41\x22\x6b\x27\x07\xdc\x9b\x7b" + "\x8b\xa4\xdd\x5b\x62\x83\xf9\xea" + "\xdf\xb4\xfc\xa3\xf2\xfa\x77\x59" + "\x5b\x4b\x2c\x05\xef\x42\xd0\xbe" + "\xf0\x91\x75\x06\x71\x7f\xe8\x9f" + "\xc7\x4e\xf2\x22\xca\x73\x9c\xc8" + "\x1b\x9f\x4a\xe6\x9e\xfa\x37\x7d" + + + "\x0f\x0c\x75\x0a\x88\x64\x7a\xcc" + "\x83\x8e\x54\x4e\xe3\xcf\xba\x39" + "\x05\x0f\x11\x0c\x76\x8c\x41\x3d" + "\x88\x15\xf1\xb1\x4c\xaa\x4d\x3e" + "\xff\x69\xfc\x5f\xb5\xe7\x33\x27" + "\x27\x31\x05\x92\xbc\x47\xf1\x46" + "\x94\xdf\x22\xd7\x34\x24\x5b\x88" + "\x7c\x6b\xfc\xe6\x65\x4f\x44\x6a" + + "\xa8\x6e\xf1\xc3\x5a\x46\x1a\x7a" + "\x1c\xd1\xf1\xb2\x1d\x46\x5a\x11" + "\x72\xa1\x68\x6c\x95\xdd\x67\x47" + "\x98\x46\x3a\xd1\xeb\xf2\x92\x33" + "\xc7\xcd\x26\xe5\xcd\x9c\xa9\xc7" + "\x81\x2b\x29\x22\xdc\x7f\x53\x8e" + "\x98\x91\xd3\xa6\x69\xcf\xd8\x76" + "\x2d\x85\x46\x24\x43\xff\xc5\xff" + + "\xbd\xdf\xae\xbd\xf4\x16\x0b\x6d" + "\xed\x6c\x74\x86\x60\x32\xfd\x23" + "\x17\x3e\x4b\xff\x2f\x1d\xfb\x8b" + "\xc8\x14\x9c\x01\x2d\xec\xf2\xc7" + "\x0d\x4b\x10\x45\xf2\x32\x08\x3e" + "\x7e\x2b\xea\xad\xfb\xda\x00\x5f" + "\x0f\xfb\xfb\x99\x66\xcf\xe5\x29" + "\xda\x7c\x82\x61\x23\x97\x4f\x26" + + "\xe6\x67\x05\xa9\x7e\x4f\xb1\x97" + "\xb7\x5c\xae\xb6\xb7\x57\x32\x51" + "\x3d\x90\x10\x9f\x3c\x4a\x45\x85" + "\x24\x37\xbc\x69\xad\xc9\xd2\xd8" + "\x44\xcb\x29\x6b\x24\x93\xda\x38" + "\xac\xcb\xc8\x77\x1d\xa2\x40\xb5" + "\x42\x8e\x91\x01\x35\xe4\xbf\x9b" + "\x4e\x61\xc3\x56\x7a\x70\xfa\xff" + + "\x7f\xc2\x0b\xe3\xf3\xa2\xb1\x6e" + "\x11\x65\x83\xb0\x5a\xc0\xf0\xe5" + "\x0e\xab\x65\x49\xbf\x1b\x74\x4d" + "\xbd\x4b\x46\x83\xca\x41\xec\xfe" + "\x9f\xb0\xd0\x99\x5f\x70\xca\x1a" + "\xfa\xa5\x2d\xf4\x56\xcc\xd6\xc5" + "\x31\xb9\x52\xcc\xdd\x4e\x96\x49" + "\xd8\xd8\x84\xc8\x15\x96\xe5\x8a" + + "\xb7\x53\xe3\xd4\xf1\xe3\xe4\x0c" + "\xa0\xb0\x46\xef\x14\x8a\x2d\x06" + "\xfd\x73\x4b\x57\xab\xd5\x08\x64" + "\xfd\x3f\x27\xd3\xc9\xd1\x41\xbc" + "\x00\x78\xe7\x6b\xe7\xe1\x38\x35" + "\x31\x50\x65\xc5\x37\x8b\xfe\x71" + "\x1a\x33\x9b\x6b\x21\x16\xd9\x1c" + "\x73\x8f\x38\xbb\x0b\x5d\x82\xad" + + "\x8a\x86\xf8\x39\x7b\xb5\x34\xf6" + "\xaf\x69\xcc\x75\xd4\x4f\x7f\xe2" + "\x6e\x49\xd5\xd0\xcb\x58\x7e\xa4" + "\x7f\xe0\x23\xd3\x3f\x79\x26\x8a" + "\x49\xf3\x30\xfa\x72\x9b\x1a\xc6" + "\x34\xd1\x96\xb6\xc9\xd9\xc9\x94" + "\xd1\xa6\x80\x58\xa8\xec\x2b\x79" + "\x95\x99\x03\xaf\x45\x46\xcc\xbd" + + "\x19\x62\xb7\x1c\x5b\xe0\xc2\x56" + "\x7e\x7e\x56\x71\x91\xbf\xc0\x0e" + "\x10\xc9\xc4\x61\x86\x6f\x07\xe7" + "\xd9\x04\xbc\xba\x5b\x08\x7b\xd6" + "\x6a\xa9\x93\x5e\x59\x04\xb9\x9f" + "\x9a\x24\xdc\xfb\xea\xc1\x26\x75" + "\xb7\x0b\xdd\xec\x67\xd3\x44\x0d" + "\x95\xd6\xc0\x9d\x17\x99\x39\x95" + + "\x3c\x6c\x79\x8c\xe5\xf8\x7e\xce" + "\x7a\xe5\x66\xdd\x84\xae\xda\x9a" + "\x33\x7f\x22\x45\x3e\xe1\x4a\x78" + "\x57\xe7\x85\x2a\xb8\xc5\x46\xb0" + "\x1f\x63\x37\xec\xae\x50\xaa\xb7" + "\x58\x07\x30\x3b\xca\x4f\xdc\xbe" + "\x0b\x70\xc9\x0a\x7e\x56\x82\x0f" + "\xd2\xf8\xf5\x4f\xd4\xd9\x71\x10" + + "\x18\x0d\x24\x9e\xe9\x0e\x36\x61" + "\x66\x44\xb9\xb4\xac\xdc\x7c\x05" + "\x5c\x32\xe5\x2f\xd1\x7c\x66\xe7" + "\x3b\x4e\x97\x21\xb5\x97\xa2\x1f" + "\x76\x3d\x08\xdb\xe7\x81\x40\xfa" + "\x15\xbd\x06\xf2\xe6\x3b\x99\x31" + "\x8c\x9f\xc1\x14\x9b\x26\x49\x89" + "\x57\x23\xd9\xa9\x72\x8d\x46\x21" + + "\x11\x28\x1a\xe5\xc4\xf6\x9e\xd0" + "\xb9\x66\xfb\xb8\x2b\x86\xf6\x39" + "\x99\xaa\xdf\x22\x8d\x7f\xe7\x64" + "\xac\x8a\xb0\x61\x44\x50\x10\x7b" + "\x32\xf3\x7d\x4a\x4c\x4e\x70\x71" + "\x5b\x01\xfe\x2f\x34\x34\x97\xd0" + "\x0e\x02\xd3\x08\x44\xaf\x0e\xab" + "\x7a\xb9\x63\xed\x9e\x90\xb1\x28" + + "\xec\x06\xc5\xa4\x83\xc5\xcb\x2c" + "\x97\xfe\xac\xd1\x88\xd1\x7e\x95" + "\xa2\xae\xf1\x12\x33\xd8\xae\x8b" + "\x2d\x36\x25\x83\xb4\x6c\x2a\xef" + "\x43\x5c\x19\x8e\x42\xde\x0d\x13" + "\xc6\x50\x60\x0e\x5a\x02\x42\xc8" + "\x5d\x6a\x68\x08\xa7\x72\xa9\x2d" + "\xa8\xb4\x08\xe5\xa1\x99\x29\xb5" + + "\x4f\xcd\xad\xcd\x82\xa8\x3f\x2f" + "\x95\x19\x63\x5f\x59\x68\xef\xa4" + "\x6f\x76\x31\xe5\xf9\xa2\x2c\xe5" + "\xd3\xc1\xe2\x57\x30\x5c\xaf\x20" + "\xb8\x94\x1e\xe5\xf6\x28\x48\x1e" + "\x4f\x5d\x2f\x1a\x75\xa1\x00\xf9" + "\xa0\x58\x2c\x39\xb3\xad\x31\xe8" + "\x66\x58\x6e\x1b\xca\x90\x5a\x4c" + + "\xbd\xa8\xa5\x10\xb9\x90\xf0\xd9" + "\xda\x64\x68\x09\x49\xd2\x91\xca" + "\xc1\xdb\x67\x3f\xbe\x93\x6a\x8e" + "\x4c\x76\xf4\xf5\xba\x6f\xae\xac" + "\xa0\x11\x14\xd2\xe0\xc6\x63\x15" + "\xd8\x4a\x0a\xda\x7f\x78\xfa\x28" + "\x30\x80\x8c\x90\x1c\x49\x24\xd5" + "\x07\x5f\x79\x4c\x0e\xba\x57\x12" + + "\x7c\x82\x82\x61\xa8\xcb\x3d\x5f" + "\x52\x72\x7e\xbd\xdd\x48\xa4\xd1" + "\x15\xb8\x93\xf4\xfc\x96\x8f\x2d" + "\x5f\xa9\x0a\x3b\x26\x4c\x0a\xba" + "\x7f\x00\xa0\x63\x40\x51\xa1\x88" + "\x46\x58\x9c\x6a\x5e\xc2\x64\x95" + "\xca\xcb\x0f\xdc\x0f\x7b\x4d\x5a" + "\x0e\x74\x8a\x3f\xa3\xda\x75\x22" + + "\x54\x97\xca\xce\x67\x91\xf4\x83" + "\xa0\x39\x79\x4b\xf6\x2c\x6d\x42" + "\xbf\xd0\x3f\x72\x55\xe3\x55\x25" + "\xe2\x44\xf1\xc4\x06\x6d\x6e\xa9" + "\x61\x0e\x88\x87\xdd\xa8\x68\x47" + "\xd5\xe4\x08\xe5\x15\x38\x54\x15" + "\x15\x5e\xb6\xb1\x72\xe7\xd7\x09" + "\xa0\x2f\x30\xac\xd6\x9d\x43\x63" + + "\x6b\x08\x61\x04\xcc\x91\x95\x15" + "\x51\x6e\xe6\x95\x94\xaa\x95\xb6" + "\x31\xd5\xde\x79\x67\x94\x4c\x2d" + "\x79\xbe\xc2\x89\xba\x82\x24\xbd" + "\x19\xbf\x0b\xa2\x8a\x65\xe2\x8e" + "\x17\x79\x24\x32\x8a\x52\x00\xc0" + "\x45\xe8\xea\xff\x4a\xbe\x24\xd9" + "\x8b\x2c\x99\xed\xeb\x2b\x31\x51" + + "\xc2\x35\x4e\xc1\x2f\x80\x3f\xb9" + "\x3c\x33\x41\x43\x7c\x5b\x73\x71" + "\x62\xf3\xd4\x16\x04\x51\xa2\x03" + "\x8e\x3c\x43\xbf\x9b\x06\x4d\x3f" + "\x7c\x5a\x8f\xf7\x01\xae\x83\x0d" + "\x07\xed\x4e\x7c\xbe\xff\xa8\x50" + "\x83\x0f\xe1\x76\x06\x89\x4f\xc7" + "\xe1\xf8\xda\x9d\x66\x09\x08\x7d" + + "\xd9\x2b\x75\xdc\x58\xb9\x01\x3a" + "\x45\x5d\x21\x0c\xc2\xdb\xab\x2b" + "\xc1\x41\x16\x13\x9a\xd7\x89\xe6" + "\xd4\x5e\xe0\x80\xda\xf0\xe8\x48" + "\xc4\x70\xbb\x77\xeb\x5f\x50\x4b" + "\xf7\x7e\x05\xb6\x2b\x3e\xbd\xef" + "\xa5\x3c\x60\xce\x2d\xe2\x83\x75" + "\xc7\x70\x5c\x2c\xf2\xb1\xe3\xfb" + + "\xcc\x04\x8e\x69\xe1\xf8\x1d\xb1" + "\xc8\x05\x90\x16\x03\xe2\x7b\x87" + "\x79\x61\x3c\x4f\x8c\x9e\x74\x32" + "\x05\xfc\x53\x78\x0a\x9d\xbc\x2d" + "\x37\xd9\x54\x94\x93\x4f\x7d\x18" + "\x1b\x0e\x80\xb4\x9d\xce\x82\xe6" + "\xe8\x68\x5e\x16\xd8\x9a\x12\xa9" + "\x5b\x78\x7f\xbe\x35\x97\xe2\x0f" + + "\x5a\xe3\xe5\x29\xf0\xec\xc1\x8e" + "\xb3\xc2\x45\x86\xe5\x68\x31\x2f" + "\xb2\x4c\xf9\xc7\x62\x73\x29\xe9" + "\x39\x0b\xc9\xd1\x66\x14\xbf\x4f" + "\x2a\xae\x0b\x92\x56\x76\x4f\x3e" + "\x72\xb1\xbe\xf1\xb9\x04\x5d\x80" + "\xb4\xd4\xdb\xdb\x08\x72\x9a\x72" + "\x53\xca\xae\x87\x56\xe4\xad\x1a" + + "\xb7\x02\x9e\x5b\x0c\xf4\x03\x53" + "\xe8\x04\xee\x35\x92\x96\x7c\xa3" + "\x2b\x63\xd6\x34\x20\xcc\x46\x5f" + "\x5b\x54\xac\x96\xb2\x72\xef\x55" + "\x62\xb0\x91\x7b\x1f\x5c\xec\xab" + "\x21\xe8\x33\xbb\xc7\xe1\x79\x0a" + "\x17\x41\x9f\x3a\x28\xb4\x04\xbb" + "\x5a\x47\x2a\xfd\x8f\xf2\xe1\x0d" + + "\x08\xa5\x34\x19\x54\x1f\xff\xb0" + "\x1a\xf3\xbb\x04\x76\x39\xe1\x19" + "\xb4\xa6\x17\x37\x03\xe6\xa8\xb2" + "\xb9\x2c\xf1\x0e\x5d\xe4\x01\xd6" + "\x8e\xe9\x15\xb5\xf5\x0a\x3f\x56" + "\x9b\x4f\x98\x33\xb6\x9d\x12\x9b" + "\x65\x4a\x7e\xa4\x2f\xba\x4a\xe3" + "\x82\x9d\x3f\x9e\xd1\x82\x6f\xb5" + + "\xb4\x34\x44\x3a\xcf\x9c\x01\x31" + "\xdc\x54\x79\x1a\x11\x81\x45\xa3" + "\xa7\x72\x49\xe3\x0d\xc8\xda\xa9" + "\xdd\xb8\xf6\x74\x54\xd0\x43\xb0" + "\x1a\x7b\x13\x11\x9e\x31\x1c\x02" + "\x3f\xc0\x5c\xed\xce\x54\xa7\x00" + "\xd4\x5a\xea\xcb\x94\xc7\xa2\x0a" + "\xb6\x15\xc0\x70\xf4\x67\x3e\x09" + + "\x86\x9b\x20\xb1\xfd\xef\x03\x02" + "\xbf\x6c\x9d\xb1\xed\x63\xf0\x21" + "\x5b\x27\x0f\x98\x76\x34\xf5\x59" + "\x80\x5e\xac\xb7\xd7\x56\x24\x20" + "\xc9\xed\x00\x49\x5f\xc0\xa8\xe5" + "\x86\x1e\xf0\x70\xb4\x8e\xc0\x04" + "\xce\x98\xcd\x1d\x24\xc2\x4a\xf7" + "\xdb\x30\xe8\xe2\x0c\xcc\x77\x7e" + + "\x6b\x3f\x7e\xc9\xe9\xfe\xcd\x72" + "\x61\x74\xda\xb6\xb4\xca\x0b\xc1" + "\xb9\x06\x98\xb5\xfc\xd2\x02\x3b" + "\x47\x6f\xde\xa1\x89\x5e\x18\x85" + "\xd4\xc4\xb6\x0e\x1f\x93\xe6\x39" + "\x04\x5b\xfa\xd4\xbd\x40\x44\x4d" + "\xb8\x7e\xbe\x34\x6e\x78\x18\x54" + "\xbc\x59\x72\x9d\x21\xe5\x80\x63" + + "\xde\x7e\x74\xa9\x34\x72\xe3\x74" + "\x13\x10\x1b\x36\xb1\xfb\xc9\x4f" + "\xef\x57\xf3\x3c\x73\x33\xb5\xe7" + "\x93\x41\x1c\x99\x2c\xdd\xa2\x6a" + "\x7a\x91\x70\xa7\xd2\xe4\x87\x78" + "\xcb\x24\x0d\xc2\xb4\x09\x18\xdd" + "\x3e\x2d\x9c\x8e\xc3\xd7\x4c\x00" + "\xbe\x0a\x97\xa9\xab\x5b\x7c\xc7" + + "\x10\xd7\x98\xd5\x51\x03\xac\x20" + "\xa4\x4d\x3a\xcb\x66\x41\x2c\x27" + "\x1f\xde\x71\xca\x1a\xfe\x82\xdb" + "\x0f\x4b\xf5\xd8\xf2\x79\x6e\x74" + "\x9b\x3e\x57\x4b\x36\xc7\x7f\x6e" + "\x40\x50\x4b\xfd\x46\x3f\xd0\x75" + "\x7b\xd8\x98\x0b\x6d\xc3\x1c\x5c" + "\xa1\x2d\x47\x1f\xf1\xa3\x3b\x51" + + "\x7f\x23\xaf\xc3\xaa\x7e\x92\x52" + "\x67\x87\x39\xd7\x65\x60\xa0\xfa" + "\x0b\xce\xc6\x97\xb4\x72\x2e\x04" + "\x61\x23\x9f\x0a\xc4\x0c\xed\xda" + "\x4a\xbb\xc1\x2f\x1c\xe1\xc2\xdd" + "\xf8\x9e\x1a\x0c\x77\xa5\x1d\x63" + "\xbf\x72\x02\x68\x44\xfe\x4c\x8a" + "\xc3\x5c\xfb\x62\x72\x9f\x6b\xc7" + + "\xdd\x77\xb1\xab\x26\xaf\xd0\x79" + "\x64\xd5\x91\x78\x68\xb5\x2a\xf8" + "\x73\x21\x23\x72\xa9\x68\x67\x2b" + "\x19\x66\x1f\x8c\xb0\x3b\xbb\xef" + "\x58\x83\xd1\xa6\xdb\x11\x9c\xb2" + "\x3a\x6d\x91\xb0\x97\x27\x9e\x51" + "\x90\xe2\x88\x91\xf0\x18\xdc\xd4" + "\x7f\xca\xb0\x98\xe3\x86\x8e\x64" + + "\xe3\xaa\xb3\x38\x45\x81\x8f\x24" + "\x34\x43\x20\xbc\x64\x58\x34\xb5" + "\x24\x75\x12\x1d\xbc\xb5\xd6\x66" + "\xd3\x72\xf5\x14\x0d\x08\x12\xe3" + "\xeb\xaf\xab\x16\xa7\x15\xed\x13" + "\xbe\x67\xa9\xdb\x27\xce\x18\x6f" + "\x2d\x55\x08\xef\x26\xe8\xc9\x96" + "\xe0\x63\x2b\xbe\x06\x1b\x19\x2c" + + "\xb5\x38\x3c\x98\x45\x31\x9d\x85" + "\x8b\xbc\x7a\x63\x6c\x17\x4f\xb1" + "\xe6\x7b\xff\xca\x9d\xfb\x93\x27" + "\x5a\x6a\xa6\x35\x5f\xa5\xe5\xeb" + "\x59\xdc\x87\x9f\xcd\x1d\xec\x7c" + "\x60\xf5\xdb\xfb\xd3\x5c\x59\x7c" + "\x57\x32\xeb\x26\x22\x3b\x54\x5b" + "\xfd\x35\xc9\xc4\x46\x06\x08\x69" + + + "\x96\x16\x53\x1d\x38\x52\x34\xb9" + "\x69\xde\xcd\x88\x00\x1c\x20\x57" + "\xc7\xaf\x86\x9a\x51\x22\xe9\xdd" + "\xa8\xce\x35\xbd\x95\x38\x04\xe3" + "\x0d\x97\x55\x85\xe1\xc1\x08\x76" + "\x5e\x93\x35\x25\xa9\xdf\x67\x82" + "\x8b\xa3\x2e\x32\x57\x0a\xc6\xd4" + "\xb5\xf8\x4e\x80\x77\x79\xbf\xe0" + + "\xb5\xdb\x94\xc0\x68\xea\x33\x62" + "\x10\xd4\x68\xd9\x2e\x06\x7d\xb7" + "\x2d\x00\xb3\x58\xbc\x9b\x71\x3e" + "\x58\x9d\xc4\x3d\x3d\xdd\xe7\x68" + "\x58\x5e\x3a\x01\x40\x57\x82\x8d" + "\x1b\x3c\x9e\x3c\x47\x17\x31\x21" + "\xab\xb6\x99\x7c\xa7\xa2\xb0\x0c" + "\xf2\x88\xf8\xc2\xb3\xa3\x48\x5c" + + "\xca\xd4\x27\x29\xe1\x4b\x5c\x4c" + "\x8e\x84\x8f\x51\x16\x3f\xf2\xb0" + "\xcb\x7b\x75\x0c\x22\x89\xf7\x84" + "\x96\xeb\x5d\x32\xbb\x1c\xbd\x35" + "\x0a\xe1\x0d\x7d\xfb\x86\xb1\xbd" + "\x85\x96\x2c\xb2\xe3\x50\x73\xd0" + "\x41\xc6\x45\xef\x3e\x39\x95\x3f" + "\x44\x6d\x7b\xd0\xf1\x0f\x87\xb8" + + "\xf3\x24\x17\x99\x91\x3e\x91\xc7" + "\x86\xd6\xcb\x39\x9c\x79\xda\x5e" + "\x1e\xfc\xd4\x63\xc7\x95\xb5\xdd" + "\x54\xed\x4f\xac\x0b\xb8\x63\x6b" + "\x16\xb5\x5f\x7e\x69\xfc\xa0\x6e" + "\x64\xc9\xf1\xd0\xba\x08\x77\x73" + "\xa5\x2c\xa9\x11\x5f\x74\x28\x96" + "\x7a\x96\x86\x9a\x58\x79\xf3\x61" + + "\x9f\x65\xa2\x47\x65\x0a\xcf\x64" + "\xcb\x0b\x38\x33\x30\xf4\x18\x12" + "\x74\x8a\xd9\x0f\xe4\xe4\x1d\xfc" + "\xb8\xed\x9e\xf0\x8f\xec\xc4\xae" + "\x83\x60\xc5\x95\xe1\xb5\x6d\xde" + "\xa1\x16\xdc\x07\x56\xb0\x07\x33" + "\x97\x70\xd4\xc0\x86\xc1\x82\x14" + "\x66\x3a\x4c\x51\xac\x19\x83\xa0" + + "\xb3\xe6\x79\x09\x61\xfd\x20\x53" + "\x23\x07\xd4\x93\xe5\xd3\x0b\x1d" + "\xcc\xba\x80\xaa\xfc\x06\xc0\x0a" + "\x15\x25\x00\xd2\x0e\xc6\xd9\xb1" + "\x92\x0b\x78\xaf\xd0\x7e\x0e\x61" + "\x31\xce\xa9\x80\x6e\x44\xbf\xf5" + "\x4b\xb5\x20\x3c\x1d\x01\x1c\x44" + "\xc3\x96\x15\x19\xa1\x6d\xf7\x77" + + "\xb4\x94\x40\x4d\x2b\x5b\x2e\x97" + "\x5f\xde\x96\x5e\x4f\x95\x49\x4b" + "\x59\x0d\x87\x4f\x0a\xe4\xa8\x6c" + "\xef\x8d\xa6\x45\x6f\x88\xe2\x9e" + "\x13\x9a\x43\xc4\xec\x60\x02\xae" + "\x1f\xb7\xcf\xb4\x3e\xcd\xae\x45" + "\x20\x76\x32\x4e\xb6\xd9\xc5\x50" + "\xf3\x2c\x18\x86\xdb\xda\x0a\x47" + + "\x72\x50\x66\xaa\x2c\x9b\xf3\x9a" + "\xef\x24\xd3\xef\xa4\x2f\x32\x78" + "\x31\xbd\x27\xc3\x94\x33\x15\x3d" + "\xb0\xda\x29\x31\x71\xf2\xd5\x81" + "\xf5\x27\x80\xf4\x42\x0c\x2e\xc7" + "\x17\xe7\x36\x85\xbc\xcd\x40\xaa" + "\x0f\x9d\x36\x2d\x7a\x65\x5a\xf4" + "\xe6\x74\x7f\xea\xc4\xbf\x3b\xb0" + + "\xf0\x69\x7c\xf3\x89\x07\xb7\x4a" + "\x2d\x80\xc5\x01\x78\xd8\x26\x32" + "\x97\xf4\x0d\x36\x4c\x42\xe7\x4f" + "\x50\x0d\x89\x5f\xe5\xd4\xae\x9e" + "\xc6\x29\x37\xdd\x5c\x99\x8e\x20" + "\xf3\xea\x0d\xd0\x5c\xbd\x43\xf7" + "\x7d\x84\x61\xf1\x10\x13\x5a\xfe" + "\x25\x3f\x1a\x94\xa2\x75\xe7\x34" + + "\xea\x42\x6a\x9b\x42\xd5\x04\x7a" + "\xb9\x41\xaf\x3d\x85\x7e\x59\xfa" + "\x89\x0b\x6b\x72\x27\xec\x58\x4c" + "\xde\x43\x0d\x03\x6a\xb1\x8e\xed" + "\x57\xcf\x9d\xec\xe1\xe5\xe1\x65" + "\x81\xff\x7c\x69\xc1\x70\xa7\xb7" + "\x22\x2b\x6e\x9f\x8f\x91\x6d\x1e" + "\xb7\x82\x4e\xc6\x9a\x7a\x27\x7c" + + "\xcf\x35\x1f\x7b\xc8\x69\xc8\xe5" + "\x37\xd2\xd1\x55\x37\x69\xfa\x29" + "\x44\x9c\x57\xde\xee\x74\xc5\x05" + "\x0c\x59\x6d\x33\x2b\x91\xbb\x45" + "\xeb\x4d\x7d\x77\x85\x2d\x17\x5d" + "\x67\x65\x6c\x7b\xa9\xcc\x37\x1a" + "\x8a\x3a\x37\x25\x3a\x43\xa1\x1c" + "\x3a\x35\x77\x1c\xa8\x94\x3c\xd2" + + "\xed\x8d\x73\x0d\x18\xc4\xa8\x46" + "\x29\x57\xde\xe0\xb0\x5b\x1a\x6f" + "\x75\x16\xa8\x8b\xb9\x30\x02\xf1" + "\xd4\x33\x2b\x11\x0c\xf3\xc6\x32" + "\x62\xfb\xff\xd8\x9d\x12\x59\x75" + "\x05\xbf\x59\xb4\x47\x1b\x28\x6a" + "\x76\x67\x3b\xfa\x3a\xbd\xc1\x77" + "\x3a\x97\x29\x78\x80\xb3\x09\x07" + + "\x61\xa3\x35\xc9\x7c\x22\x89\x79" + "\x7e\x0a\x9a\xe3\xaa\xf8\x17\xfd" + "\xba\x63\x91\x26\x86\x5e\x5c\x2e" + "\xf4\xea\x63\xc6\x78\x8e\xc9\x07" + "\x6e\xa3\x2e\x42\x9a\x20\xe8\x64" + "\x82\x08\x6a\x4c\x91\xb3\xe8\x1b" + "\x5e\xa5\x4f\xec\x03\x45\xac\x4b" + "\xdf\x68\x78\xad\xca\xa7\xee\xba" + + "\x47\xcb\x36\xda\xc1\xe0\x75\x08" + "\xf0\x10\x02\x1e\xcb\xb7\xf5\xfd" + "\xc8\x87\x37\x3a\x4d\x7e\x0c\x7e" + "\x1f\x74\x1c\x2b\x26\xf5\x43\xf0" + "\x2d\xd7\x74\x6d\x00\x1b\xdf\x76" + "\xa9\x5b\xb4\x38\x73\xdf\x14\x05" + "\x7a\x79\x6b\x0a\x3e\x7c\xcf\xae" + "\x39\xac\xea\xdd\x85\xb2\x30\x5e" + + "\xdb\xe3\x69\xac\x9c\x33\x69\xff" + "\xbd\xd6\xe9\x59\x3c\xc8\xec\x74" + "\x82\x84\x0a\x82\x37\x7b\x23\x67" + "\x23\xfa\x2d\x07\x35\x30\x3a\x94" + "\xb8\xbd\x48\x8f\xd2\x10\x42\x6e" + "\xf4\xc7\xec\x2e\x16\x75\x51\x88" + "\x7f\x18\x2a\x63\xf4\xc5\x05\x0b" + "\x4c\x1d\x7d\xd9\x5e\xfb\xfd\xca" + + "\x05\x65\x32\xa3\x32\xb2\x26\x8c" + "\xbf\x41\x1d\xee\x72\x92\xd6\x38" + "\xfa\x2a\xe3\xff\x3e\x45\x59\x04" + "\x87\xea\xb3\x7c\xad\x43\x81\xce" + "\x66\xb6\x6a\x7e\xfa\xc1\x2e\x93" + "\x64\x62\x28\x22\x30\xd2\xd2\x6c" + "\xed\xf8\x36\x67\xfe\x46\x9a\x45" + "\xbb\x85\xca\x9e\x00\x0d\xbf\x50" + + "\xb4\xeb\xa2\x3d\xba\x6b\xc1\x06" + "\x3e\x7c\x55\x32\xbb\x21\x5b\xf3" + "\x11\x67\x07\x30\x12\x23\xb1\x95" + "\xf0\x11\x76\x1b\x76\xa0\x3a\x87" + "\x61\x6d\x3a\xea\x26\x90\xf6\x31" + "\x4c\xbe\xa6\x42\x6b\xb8\xc9\x7a" + "\x02\x28\x6c\x4b\xc7\xd7\xb5\xd3" + "\xe0\x1d\x28\xab\xac\x94\x48\xcd" + + "\xa5\x38\x52\x60\x7d\x8f\xc7\x15" + "\xab\x96\x84\x44\x42\x78\xd8\xe9" + "\xc1\xac\x10\xd2\xd0\x75\xcf\xcf" + "\xe2\x14\x8c\x5c\x29\xf2\x48\x29" + "\xcb\xf0\xda\xe8\x6d\xd7\x1f\xe8" + "\x00\xe8\x3b\xa0\xe4\x11\x2d\xd0" + "\x0c\xd3\x78\x87\x51\xf3\x4d\x0c" + "\xcb\x39\x51\x96\x96\xbc\x82\x34" + + "\x68\x1d\x81\x49\x01\xd7\xa0\xef" + "\x4e\xa0\xa1\x1e\xe5\xc8\xf6\xe4" + "\x40\x76\x23\x82\xfd\xe1\x90\x59" + "\x96\xdb\x80\x1d\xf9\x25\xa2\xef" + "\xda\xcc\x96\x3a\x95\x1c\x43\x17" + "\x92\xa1\x3f\xfc\xc1\xaa\x1b\x46" + "\xb4\x84\xc1\xbb\x07\xf4\xe2\x3b" + "\x9c\xd3\x05\x0d\x1d\xde\x76\xd7" + + "\xec\x21\x7a\x87\x52\x58\x82\x0b" + "\x94\x7a\x53\x0f\xa7\x14\x04\x30" + "\xa2\xa6\xa9\x21\x40\xba\x1c\x3f" + "\x00\x3c\x94\x76\xee\x4e\x82\x50" + "\x5d\xba\x3c\xf8\xec\xfc\xdb\xa0" + "\xc0\xf3\xb4\x93\x48\x81\x53\xf9" + "\xd7\x4d\xf2\x48\x62\x41\x74\x61" + "\xdd\x09\xfb\xe4\x4d\xd6\x22\x53" + + "\x05\xa7\x73\xdc\xd2\x9e\xb0\xf1" + "\x6e\x1a\xa1\x01\xc8\x00\x2b\x14" + "\xc9\x32\xa1\x98\xb0\x84\x64\x72" + "\x7a\x56\xe1\x26\x63\xef\xb5\xf3" + "\x03\xfc\x4b\x57\xd0\xd2\xbe\x43" + "\x2f\x72\x8f\x76\x38\x1e\x79\x74" + "\xd8\x7e\xe9\x4c\xb3\x9f\x18\x7a" + "\x43\x5f\x8a\x16\x96\x2c\x9b\x2b" + + "\xbc\x8b\x44\x8a\x27\xcf\xb6\x56" + "\xda\x51\x52\xc8\xdf\x98\xa8\x0c" + "\x24\x9b\xe7\x36\xd8\xca\x82\x90" + "\xa7\x51\x8e\x1a\xd3\x9e\x7b\x2e" + "\x02\xc8\xe1\x43\x8a\x31\x7d\xdc" + "\x9d\x68\xf8\xcb\x23\xe5\x50\x47" + "\x1a\x1b\x07\xf0\x72\xa0\x87\x98" + "\xc1\xfd\x4b\x81\x87\x0f\x09\x52" + + "\xb9\x6e\x73\x8d\x2e\x85\x21\x48" + "\x6b\x1e\x4c\x54\xd3\x28\xa9\x29" + "\x86\x05\x80\x77\xae\x11\xa4\x1a" + "\x93\x57\x0a\x1b\x7b\x06\x4d\xe9" + "\xad\x46\x5e\xa6\x4b\x8b\x9d\xb5" + "\x04\x18\x94\xcd\x87\xba\x62\x3c" + "\x1b\xe6\x20\x99\x78\x4b\xb5\xfd" + "\xac\x1a\x18\x0a\x84\xf2\x23\xe9" + + "\xf3\x25\x93\x3d\x84\x73\x44\x57" + "\x84\xcb\x71\xf3\xd0\xf2\xbe\xa9" + "\xc5\x36\x1e\xa6\x8b\x18\xd2\x77" + "\x72\xdf\x02\xc6\xd7\xa7\xd6\xbb" + "\x0b\xbc\x61\x8f\x02\xa9\x3a\xba" + "\xa1\xb6\xd0\x6e\xed\x85\x90\xf4" + "\x98\x82\x6e\xae\xd6\x25\xc6\x8b" + "\x1d\xc0\xe9\xa2\x1d\x0b\x2b\x83" + + "\xa0\xca\xd1\x70\x82\x5c\xb4\xc2" + "\x57\xb5\x4a\x72\xd0\x41\xce\x44" + "\xfd\x71\x82\x13\xac\x4b\x98\x57" + "\xc8\x08\x36\xcb\x34\xc9\xe0\x67" + "\x03\xf7\x55\x54\x45\xfa\x88\xc8" + "\xb0\x02\x7b\x72\xb4\xb8\xc5\xe9" + "\xa4\x30\x71\x7c\xf0\xf0\x3e\xdc" + "\x0c\x27\x09\x4b\xa3\xbe\xe4\xd9" + + "\x6e\xbc\x96\x61\x19\xf2\xeb\x5b" + "\xfd\x7e\x09\xef\x6b\x73\x66\x0e" + "\x3a\x29\x87\xea\xb8\xf3\x28\x11" + "\xde\xfc\xdd\x6a\x05\xe4\x98\x29" + "\x61\xc9\x16\x5d\xb8\x31\xcc\x55" + "\x56\xf0\x18\x24\xe1\x34\xa4\x87" + "\x19\xe8\x9f\xdc\xcc\xaa\x94\x2e" + "\xc6\x90\x64\xa5\xc1\x86\xa4\x94" + + "\xb3\x2b\x8d\xcb\xd4\x83\x4d\x8a" + "\xfd\xb1\xd2\xff\xa8\x6a\x79\xea" + "\xf6\x79\xca\x04\x51\xab\x75\x65" + "\xcf\x86\x6b\xc4\x36\xd5\xf0\xf4" + "\x58\x6b\x0e\x67\xd9\xc5\x1e\x46" + "\x08\xd1\xae\x0e\xf8\x53\x50\x70" + "\xf7\x16\xdd\x14\xce\x5b\xf4\xda" + "\x65\xcf\xb2\xc4\x49\x2d\x6f\x40" + + "\xd1\xce\xf0\xf1\x47\xc4\x37\xa3" + "\x2b\xdd\x92\x94\x93\xc7\x0c\x80" + "\xfa\x8e\xa0\xbe\x1d\x15\x93\x4b" + "\x1e\x74\x0a\xde\xf8\xf3\x0c\x82" + "\x13\x7d\x0f\x1c\xdc\x82\x19\xff" + "\xca\xe6\xdd\x84\x60\x19\x92\xef" + "\xe3\x6e\xf9\x45\x72\xd9\xd7\x1a" + "\xc7\xa0\xde\x29\xbe\x8d\x9c\x31" + + "\xf8\xf5\x2e\xe8\x80\xdc\x1c\x6d" + "\xb3\x7f\x1c\x2f\xf0\xf9\x5d\x09" + "\x88\xd8\xcf\xa3\xb9\x34\x7f\xc8" + "\xe1\x08\x02\x34\x95\x70\xd7\xd5" + "\xcb\x51\x88\x91\xe4\xec\x1a\x4a" + "\x42\x71\x2b\x60\xc1\xf5\xb1\xd7" + "\x82\x4f\x52\xc6\x13\x98\xd3\xf0" + "\xb5\x1d\xb0\x6b\xae\x6e\xd9\xf6" + + "\xc8\x9e\x25\xde\x5b\x38\xf2\x1f" + "\x0d\x7b\xf6\x30\x6a\x83\xb0\xf6" + "\xff\x1c\x66\x06\xb0\x65\xcc\x04" + "\x5c\x0f\x23\xd4\x58\x63\x7e\x46" + "\xd3\xd3\xbe\x2d\x80\x8c\x46\xce" + "\xa6\x0d\x92\xf1\x62\x42\x98\x7b" + "\x9f\x47\x37\x15\x42\x57\xd2\x34" + "\xe1\x8d\xbb\x87\x8c\xa8\x8a\x5c" + + "\x6a\xa5\xaf\x54\xa1\x68\xf7\x32" + "\xe5\x84\xf1\xfa\xa3\xec\x1e\xa5" + "\x68\x74\x8c\x61\x44\xcb\xce\x20" + "\xc0\x2c\x86\x87\x5f\xd1\x34\x34" + "\xf6\x5d\xf5\xae\x11\x38\x3c\x71" + "\xf0\xf8\xe3\x81\x49\xc0\xd7\x2c" + "\xbe\x99\x2f\xff\x39\xd4\x68\xee" + "\xa6\xa6\x5d\x2b\xe7\x4e\xb6\x79" + + "\x9b\xb9\x82\x7b\x71\x38\xea\xd3" + "\x24\xb6\x0e\x47\x4d\x2d\x92\x75" + "\x66\xd4\x95\x3b\x54\xec\x66\x8f" + "\x46\xe3\xe1\xbe\xcc\x73\xe6\x66" + "\x9a\xb8\xf2\xb5\xc4\x67\xfe\x6a" + "\xd3\x5c\x0e\x29\xe6\xc1\xe9\x3d" + "\xda\x2a\x0a\x31\xb6\x8b\x27\x8c" + "\x3b\x32\xdb\x0b\x84\xa3\x0f\x42" + + + "\x9b\xc4\x24\x64\x79\x96\x6f\x64" + "\xc9\x41\xc2\x67\xe8\xdf\x88\xf8" + "\x49\x8b\xf6\x24\x93\x4b\x2d\xe1" + "\x20\xdf\x71\xa5\xd8\x62\x6b\x9a" + "\xcb\x83\x94\x17\x6d\xb2\xb4\x81" + "\xe2\xfa\x11\x95\x32\x96\x6f\x66" + "\x1f\xa5\x3a\xd5\xe4\xb3\x81\xd2" + "\x16\xbd\x3d\x7f\x65\xa7\x96\x7f" + + "\x2b\xf6\x1a\x05\x7c\xd3\x53\x85" + "\x96\x44\xf9\x0b\xeb\x98\xa9\xe9" + "\xa1\x9a\xd5\xb0\x9f\x4f\x84\xe0" + "\x13\xb8\xaf\xe6\x58\xd5\x3f\x98" + "\x04\x98\xd6\x65\xca\xc0\x70\x96" + "\x2d\xff\xa5\x6e\xde\x22\x2b\x73" + "\x3b\x62\xd8\x5f\xa9\x0b\x64\xd7" + "\x82\x17\x35\xa6\x63\x91\x61\x9f" + + "\x4f\xdd\xef\xbd\xe0\xb4\x67\xf1" + "\x01\xe4\x66\xf3\x65\x84\x95\x69" + "\xc0\xbe\x3b\xa7\xab\x68\xa3\x5a" + "\x21\x0c\x24\x7b\x09\x87\x14\x12" + "\x06\x90\x96\x18\x33\x32\x8c\x37" + "\xd1\x53\xfe\xe1\xce\x73\x4d\xcb" + "\x61\x43\x0c\x13\x0e\xa8\x50\x5f" + "\x2b\x21\xf5\x7e\x51\x59\x7f\xd6" + + "\xc0\x38\xad\x8c\x08\x81\x2f\x33" + "\xe2\x8a\xd6\x6b\x90\x7e\x1b\x47" + "\xa3\x27\x8e\x0d\xb2\x3f\xac\x56" + "\x0d\x4b\x6b\x13\xdb\x60\x46\xb5" + "\xe4\x8d\xfd\xa6\x11\x1e\x3a\x12" + "\xef\x99\x77\xa3\xea\xff\xdb\x44" + "\x7c\xc1\x6a\xce\x77\xb9\x40\x45" + "\xef\xac\x60\xaf\xa8\x73\x51\x49" + + "\xb0\xea\x73\x45\x43\x37\x44\xeb" + "\x31\x60\xac\xd1\xfb\x0d\x57\x11" + "\xfd\x9a\xdd\x44\x5b\xb4\xd9\xf7" + "\x31\x72\x06\x22\xdd\x6a\x06\xb8" + "\xb4\xf0\xa3\xf8\xd8\x2a\xf9\x15" + "\xa2\xe2\xac\xe0\x99\x48\x0e\x9e" + "\x80\x8b\xb3\xfa\xad\x0a\xcd\xbd" + "\x52\x00\x02\x17\xe9\x6a\x50\x46" + + "\x9d\x39\xca\x8f\xf7\x69\x9a\x42" + "\x63\xbb\x07\x02\xd2\x27\x9e\xfe" + "\x82\xf5\x88\x87\xd6\x5e\x65\xec" + "\x6e\x5f\xb7\xad\x48\xd7\x26\xa4" + "\x6d\xc6\x81\xca\x02\x5c\x69\x18" + "\x25\xd4\x31\xa5\x27\x8d\xfb\x84" + "\xba\x48\xff\xde\x56\x89\x3a\x3a" + "\x47\x22\x6d\x76\x56\x0d\x1d\xaf" + + "\x5c\x4b\x2c\x35\x65\x95\x05\x5a" + "\xe2\xc3\x0b\x59\x31\x15\x26\x49" + "\x5f\x9f\x6f\xf6\x21\x75\x9f\x80" + "\x9b\x4a\x0a\xc7\xbf\xf6\xae\x2b" + "\x61\x35\xed\x09\x65\xfa\xe6\xe7" + "\x0c\x23\x4b\x98\x33\x02\x37\x11" + "\x69\xdc\x4c\xd0\x9b\x65\x51\x21" + "\x16\xd4\x07\xf0\x63\x3c\xb8\xbd" + + "\x82\x2a\x1c\x39\x4d\x28\xbb\x9e" + "\xe8\x08\x83\x15\x63\x48\xdd\xbc" + "\xca\xed\xf1\x83\xec\x16\x6f\x00" + "\xc8\xc6\x5d\x69\x37\x2c\x3e\xa1" + "\x87\x7a\x05\x4a\xf0\x56\xb7\x2a" + "\x98\x8f\xb4\xa6\x00\x55\x76\xa8" + "\x44\x1c\x65\x68\xce\xfa\x52\x42" + "\x02\x5e\x76\xe1\x0b\x54\x2b\xa5" + + "\xf0\x7f\xa3\x5c\xa8\xa1\x35\xcb" + "\x8f\x1c\x2f\xcd\x1c\x4f\xa0\xe1" + "\x12\x61\xa2\x15\xce\x16\x88\x23" + "\x7e\x17\x5b\x09\x11\xa1\x06\xe2" + "\x49\x41\x42\x8a\x04\xb6\x10\x3c" + "\xfb\x2c\x75\x74\x67\xf5\xa3\xc6" + "\xb8\xdb\xf1\x47\x7a\xa3\x16\xbf" + "\xfb\x3d\x1a\xd3\x9a\x2f\x37\x7c" + + "\x2a\x4d\x0b\xc2\xb5\x05\x2d\x12" + "\x67\x2a\x66\x0c\xf5\x9c\x65\xff" + "\xe9\xc9\xff\xe8\x28\xc1\x57\xed" + "\x83\x76\x98\x9e\x85\x15\xbb\x0f" + "\x2b\x9a\x31\x47\xf2\x0d\xd7\xad" + "\x70\xe4\x4b\x37\xba\xba\x98\x4b" + "\x07\xb3\xa7\x56\x73\x74\x3d\xf0" + "\x30\xbf\xfe\x3e\x6e\x69\x2e\x34" + + "\x37\xc5\x4a\x86\xf7\x48\x4b\xf8" + "\x3d\x0d\x94\xa6\x09\x34\x71\x04" + "\xae\xc7\x74\x61\x2d\xb2\x4d\x01" + "\x34\x30\x21\x8c\x43\x1c\x3a\xc7" + "\xec\x93\xdd\xff\xa5\x4e\xac\x18" + "\x3e\x78\x02\x61\x57\xc7\x4f\x72" + "\x3f\xe8\xc3\x91\xcc\x3f\xe1\x9f" + "\xf5\x0b\x8f\xf0\xc8\xc2\xa8\x92" + + "\xde\xf6\x67\x8f\xfd\x22\x2e\x7f" + "\x77\x31\x69\xd8\x33\x88\x01\xab" + "\x95\xca\x3e\x86\xb6\x1d\x6d\x26" + "\x2b\xef\xb5\x31\x2b\x73\xb7\x6b" + "\xce\x80\x5f\x91\xc6\x27\xa9\x4f" + "\xd8\xef\x90\x5f\xd2\xd6\xa1\x6f" + "\xad\x48\x6b\x45\xe8\x5d\xd7\x7b" + "\x29\x64\x5b\x84\x7a\x50\xcb\xd2" + + "\xec\xd7\x55\xe2\x2a\xf8\x2c\xa7" + "\x04\xe2\x60\xa4\x23\x5c\x02\x52" + "\x44\x0a\x5b\x7d\x2d\x54\xae\x10" + "\xda\xae\x05\x93\x10\x43\x51\xa8" + "\xe8\xbf\x4b\xa1\xf5\x15\x83\x95" + "\xfe\x65\x53\x38\x26\x18\x36\x3f" + "\x40\x50\xd9\x66\x6b\xa3\xb3\xc2" + "\xa2\xed\xf4\x7c\x34\xb3\xc7\x12" + + "\x9d\x11\x44\xe7\xd1\xb4\x45\xa5" + "\xe7\x71\x9a\x82\x69\xb1\x93\x4c" + "\xbf\xfc\x17\x61\x8c\x90\xbb\x2d" + "\x85\x3d\x5a\xb3\x20\x73\xc9\x4d" + "\x05\x81\xf8\x6b\x85\x4f\xc0\x94" + "\x1f\xbc\x51\x1b\xce\x1b\x2e\x45" + "\xf3\x3a\x01\xb3\x50\xff\x41\x0c" + "\x24\x7e\x4d\x22\x45\xf4\x7a\xf0" + + "\x6a\x4f\xd2\xa3\x7c\xe5\xb9\xbd" + "\x63\xa7\x45\xf3\xd7\x46\x82\x8a" + "\x5f\xbb\xcf\x98\x6d\x2a\xbd\x73" + "\xdb\x04\xed\x86\x5e\xe8\xd8\x1d" + "\x0b\x42\x1f\xc0\x42\xda\xf2\x76" + "\xc7\x7b\x40\x64\x73\x54\xf0\x7e" + "\xf5\x48\xf5\xaf\x7f\xba\x98\x7e" + "\x4a\xb6\x30\xfd\xee\xfb\x7a\x6b" + + "\xbb\xd2\xa0\x16\xc5\x2f\x92\x4f" + "\x99\x34\x62\x1a\x6c\xc1\x5c\x0d" + "\x8b\x2c\xc6\x57\x3a\xcf\x41\x92" + "\x7f\x66\x1b\xfd\x61\x69\x5e\x2f" + "\x97\x17\xa0\xf5\x0b\xc7\x15\x5c" + "\x92\x61\x95\x60\x4d\xb4\x20\x3d" + "\x52\xdb\x1f\x07\x37\x1b\x91\x04" + "\x7b\x0f\x6f\x8d\x16\xf9\x48\xf6" + + "\xf8\x72\x25\xeb\xea\x39\x76\x06" + "\xce\x53\x08\xd7\x32\xf6\xce\xb0" + "\x04\x90\x98\xe9\x31\x1f\x7f\xd8" + "\xc0\x82\x65\xa2\x36\x72\xaa\x94" + "\x56\xc6\xc2\xb0\xe5\xb8\x11\x42" + "\x4e\x41\x57\xa2\x9b\xa7\xaa\x05" + "\xb0\x9a\xf0\xe0\x41\xf8\x72\x06" + "\x65\x1c\xc8\x3e\xbf\xf9\xc5\xa3" + + "\xfa\xf0\x03\xe0\x9a\x37\xf6\x4c" + "\xb0\xc8\x75\x1e\x87\xe0\x17\x79" + "\x9f\x3c\x38\xa1\xfc\x59\xc0\x1d" + "\x67\x09\x48\x64\xa6\x4e\x61\xa8" + "\xd1\x5d\x62\x79\x01\x0d\x4d\xc3" + "\x88\xe7\x00\x42\xe1\xa1\x47\x7d" + "\x9d\xa5\x54\xa7\x1e\x9d\xf9\xae" + "\x78\x41\xb1\x49\x00\x2d\x81\x1c" + + "\xa7\xb3\x77\x08\xb6\x1b\xa1\xa4" + "\xa9\x21\xd5\x2c\xa6\x11\x4d\x24" + "\x2c\xc6\xf5\xbf\xb7\x19\x4b\x46" + "\x7c\x65\x76\x90\xa7\xeb\xf3\x27" + "\xa9\x81\x75\x0c\x97\xbf\x3a\x48" + "\xf3\x22\x0b\xae\xe0\x08\xf1\x2e" + "\xd5\xbc\x64\x50\x66\xf3\x03\xd6" + "\x5e\x02\xf5\x5b\xa7\x75\x48\xcf" + + "\x2c\xd2\xd5\xd0\xe5\x02\x93\xab" + "\x30\x40\x12\x30\xb0\xe6\xa7\xd0" + "\xf4\xa1\x0a\x4f\x7b\xc5\x62\xe2" + "\x2e\x20\xba\x0b\xa5\x58\x7a\x49" + "\xac\xcc\xcf\xe6\x1e\xd2\x9f\x10" + "\xec\x27\x19\x8a\xe6\xcc\x96\xb5" + "\x5a\xe8\x02\x3b\xe8\xf7\xb9\x48" + "\x34\x11\x59\x08\x3c\xf8\x7e\xbf" + + "\x62\xc5\xed\x62\xb1\x91\x5e\xe0" + "\x85\xd1\xbc\x62\x72\xfe\xe1\xb5" + "\x19\x5b\x10\xb8\x08\x69\x52\x1d" + "\x22\xbb\x6b\x89\x7e\x44\x11\x0d" + "\xf0\x13\x22\x2c\x49\xaa\x7a\x64" + "\x4b\xc1\x2f\x2e\xc6\xf8\xc9\xf6" + "\xc6\x68\x41\xbc\x9a\x25\xca\x90" + "\x61\x34\x8e\xdd\x62\x27\xb9\x3b" + + "\x9a\x18\x20\x5b\x94\xc0\x7f\x15" + "\xab\xc8\xf5\x0b\x2d\xc6\x72\x6e" + "\xb7\x50\x77\x35\xe1\x89\xf4\xf7" + "\xc5\x31\x7d\xf8\xb2\x1a\x51\x18" + "\xc5\x35\x5f\x00\x27\x78\x26\xa4" + "\x6d\xed\x80\x94\x54\xa0\x8c\xa2" + "\xb2\x7d\x24\x77\x7c\xde\xef\x20" + "\x60\x9d\x14\xa4\x39\x04\x16\x5e" + + "\x70\xae\xde\xf3\x48\xb1\x10\x5c" + "\x33\xc4\xab\x6e\x53\x4b\x04\x02" + "\x8e\xf1\x63\xfe\x0c\x79\x82\x1e" + "\xf1\x5f\x69\xaa\x5a\xb6\x86\x28" + "\xed\xa4\x27\x46\x93\xdf\x4f\x99" + "\xb9\xb0\x2e\x87\xc0\xde\xb4\xe9" + "\x8f\xa2\xf7\x58\x8d\xec\x0b\x4c" + "\xfe\xc5\xf9\xea\xed\x4d\x0c\xc3" + + "\xf7\x7c\x0b\xe6\xaf\xac\xc1\x6d" + "\x69\xd8\xa9\x84\x50\x0a\x86\x25" + "\xc4\x8a\xba\xe7\x09\x6f\xfc\x56" + "\x9e\xd2\x48\x61\xd0\x5b\x8c\x82" + "\x5f\xae\x55\xdc\x5e\x43\x6b\xac" + "\x11\x74\x11\xc0\x6c\xf5\x27\xa5" + "\x2c\x34\x24\xfd\x5e\x04\xd5\x94" + "\x0d\x7c\xb6\x70\x35\x0a\x4c\x2c" + + "\xcd\x79\x55\xb6\x38\x35\xf6\x69" + "\xa1\x33\xf9\xad\x5c\x60\x70\xd0" + "\x6c\x9f\xbe\x83\x05\x87\x7e\x01" + "\xa1\xb8\x47\xb2\xaa\x2f\x44\xe9" + "\x68\x3d\x0d\x54\x9e\xff\xee\x54" + "\x19\xbe\xe3\xca\xab\xde\x3e\x1f" + "\x1b\x31\x35\x70\xb0\x28\xc5\x95" + "\xa7\xc0\xbc\x96\xb7\x3a\x5d\xb3" + + "\xb5\x98\xd3\x5e\xfa\x3c\xca\x9b" + "\xd7\xdd\x53\x13\x65\xb4\x60\x6a" + "\xd1\x51\x1c\x1a\xbb\x17\x5c\x90" + "\x1b\xf9\x5c\x7f\x81\x04\xa3\x27" + "\x0a\xbf\xd6\x9e\xf3\x0c\x66\xc4" + "\x56\x1d\x9e\xf7\xb1\x3f\xb0\xb0" + "\x54\x13\x00\x36\xf1\x3b\xa1\xe3" + "\x2a\x2b\x2b\x1f\x54\x50\x72\x9a" + + "\x6d\xe1\x06\x21\x05\x7d\x89\xb4" + "\x8c\x7f\xa0\x50\x9b\xdf\xbb\x85" + "\xd7\xff\x49\x6c\x3d\x2a\x63\x42" + "\xb8\x20\x07\x60\x7c\x5e\x88\xb7" + "\xac\x94\xb6\xde\xdc\x7f\xa4\x6f" + "\x79\xd1\xe0\x8a\xf5\x14\x46\x38" + "\xb3\x4a\x12\xbd\x29\xba\xfc\x78" + "\xea\x12\x8f\x74\x9e\x3d\x11\xbb" + + "\x18\x30\xcd\xa7\x99\xef\x23\x3c" + "\x8f\xfd\xde\x83\x06\xc5\x3f\x2c" + "\x9b\x49\x88\x2b\xff\x45\x7a\xf9" + "\x6a\x7f\x6e\x34\x21\x32\xaa\xae" + "\x30\x27\xf3\x50\x84\x34\x47\xe7" + "\x41\xca\xd6\x0f\xbb\xb8\xc0\xc2" + "\x14\xc1\x17\xaf\x79\x20\x88\xa9" + "\x04\x72\xde\x1b\xa6\xf7\x35\x06" + + "\xfe\x93\x84\xf3\xd0\x13\xb0\xc3" + "\x18\xf7\xba\x07\x96\xae\x2c\xa3" + "\xba\xb3\x95\x20\xc2\xa6\x1d\x37" + "\x9e\x90\x41\xb0\xbd\x0a\x1c\x03" + "\x60\x9e\x1a\x43\xbe\x6d\xcc\x11" + "\x6e\x8f\xf3\x5b\x76\x94\x91\x7e" + "\x33\x4a\x2a\x46\x76\xf0\x47\xbe" + "\x30\xb8\x41\x30\xdf\xc9\xb3\x33" + + "\x85\xbd\x63\x7b\x4e\x4d\xd7\xa7" + "\xa6\x3d\xe2\x43\x55\xc6\x36\xea" + "\x29\x96\xa7\xe5\x7f\x7d\x7b\xcd" + "\x1d\xc0\xca\x13\x47\xf7\xb1\x1f" + "\xd3\xde\x28\x90\x45\xe1\x0f\xaa" + "\x97\x20\x57\x19\x3b\xca\x23\xb1" + "\x77\x86\x83\x74\x6d\x74\xa8\x21" + "\xc6\xcc\xab\x63\xcb\x7a\xfc\x1c" + + "\x70\x3d\x05\xe5\x02\x33\x65\x02" + "\xc9\xbf\xc6\xb8\x5b\xe3\x33\x3c" + "\xe9\x1e\x02\x9a\x40\x4b\x2c\xa7" + "\xe4\x27\x65\x3f\x0d\x80\x1b\xe1" + "\xb5\x37\xdc\xb6\x4a\xd4\xc1\x8f" + "\x74\xe4\x80\xf5\xb5\x06\x86\x5d" + "\xfa\xb0\xb5\x87\x4a\x75\x25\xdf" + "\x5e\x2a\x69\xbb\xe8\x0c\xf5\xba" + + "\x9a\x1d\xc6\xfa\xb8\xc8\x7c\x02" + "\x8a\xfe\xc6\xe3\x62\xe0\x25\x7d" + "\x03\xf5\xbf\xe5\xbf\x05\x88\xe0" + "\xf7\x32\xf6\x6f\x6c\x1e\x27\x13" + "\xa5\x76\x2f\x23\xc0\xa6\xdc\x55" + "\x26\xf4\x1e\x70\x2d\xc3\x57\x89" + "\x78\x51\x0a\xa1\xcb\x8b\x72\xee" + "\x73\x51\x2c\xb6\x11\x04\xa6\x5e" + + + "\x50\xbc\xd8\xb4\x2b\x46\xd5\x9a" + "\x70\x57\x19\xa9\x16\x0b\x1c\x18" + "\x68\x2a\x41\x78\x1c\xfe\xd4\xeb" + "\x8c\xf4\xdf\xc0\xbc\x41\x03\xae" + "\x66\xe8\x03\x70\xcf\x45\xbc\xb6" + "\x1b\xa4\x24\x8a\xea\x6d\x1a\xf1" + "\xc2\x24\x4c\xd0\x1a\x15\x07\x54" + "\x68\x7b\x5b\xda\x7d\xd2\xc9\x62" + + "\xf6\x8b\x3b\x52\x2e\xb1\x50\x0a" + "\x1b\x0c\x91\x8f\x5b\xeb\x09\x80" + "\x88\x75\x16\x4a\x82\xaf\x35\xf5" + "\xbd\x2a\x2a\xfb\x9c\x5f\x83\x0f" + "\x62\xeb\xfc\x2a\x31\x29\x9b\xf5" + "\x3f\x38\x9d\x16\x2a\xdf\x97\xc7" + "\xb0\x02\xac\x66\xb0\x5f\x3f\xeb" + "\xca\xd0\xa2\xda\x6f\x4c\x9d\x02" + + "\x42\xe5\x7c\x2b\x05\x26\x22\xb8" + "\xe1\xbd\x72\x74\x99\xce\xd4\xe6" + "\xda\xf4\xd2\x09\xbe\x6e\xe1\x53" + "\x2e\x2b\xb9\x53\x2e\xf4\x0f\x18" + "\xc6\xa1\x34\x2c\x02\xcc\x9b\xc5" + "\xc2\x46\x2c\x42\xf9\xd6\x03\x38" + "\xa2\xa8\x14\x5c\x4f\xf7\xaf\x18" + "\x28\x8b\xa0\x10\x80\xbf\xae\x55" + + "\xbc\x43\xb3\xf5\x10\x20\xaf\x58" + "\xfe\x42\xf1\xf2\x0a\x40\x2e\x0f" + "\xdf\x4b\x5f\xa8\xde\xbf\x83\x34" + "\xa9\xea\xbf\x03\x93\xd0\xb1\xf0" + "\x03\x16\x08\xc7\x95\x1b\xa0\x2e" + "\x97\x10\xba\x3d\xc9\xe4\x43\xe9" + "\xa6\xf3\x38\xb4\xad\x92\xbe\x47" + "\x36\x66\xbf\xe5\x42\x77\xbb\x00" + + "\x61\x2a\xdf\x86\xb4\x4f\x7a\x13" + "\xa2\xb4\xf7\xec\x07\x9c\xed\xa1" + "\xff\x42\xd0\x7b\xe2\x60\xe4\xb2" + "\xec\xf5\x62\x5f\xfa\xe2\xf5\xb7" + "\xb7\x23\x24\xcc\x6b\xec\xa6\x7a" + "\xa7\xee\x63\xba\x7f\x0a\xce\x75" + "\xe1\xa6\x50\xf2\xb1\x5f\xa4\x67" + "\x9f\xdc\x3c\xe5\x9c\x91\xbc\x93" + + "\x45\x33\xce\xdd\xaa\xcc\x2f\xec" + "\x50\x43\x2a\x01\xb7\x11\x68\x2a" + "\xdc\x8b\x59\xac\xf1\x0f\x76\x96" + "\x28\x41\xbf\xd1\x2a\x65\x4d\x05" + "\x05\x10\xa2\x92\xd4\x51\x11\x0a" + "\xdf\x0f\x11\x33\x71\x39\x7f\xad" + "\x0f\x10\x60\x19\x8c\x92\x95\x8c" + "\x62\x33\xf0\x7b\x25\xc8\x91\x6c" + + "\xec\x1d\x3f\xec\x5d\x12\xe6\x19" + "\xda\x78\x11\x91\x40\xf0\xb1\x07" + "\x38\x67\x4a\x90\xda\xde\x3e\xd9" + "\xcd\xed\xeb\x0b\x5a\x7a\x18\x55" + "\x41\x9d\x32\xeb\x22\x47\xd0\xf7" + "\x91\xb3\x70\xf1\x9e\x09\x49\xf4" + "\x28\xf8\x99\xca\x69\x7a\x31\xfd" + "\x6d\x97\xa4\x34\x2b\xdb\xc3\x50" + + "\x78\x71\xfe\x7b\x1b\x48\x74\xb6" + "\x68\x58\x40\x65\xae\xeb\x1d\x4e" + "\x7d\x86\x8c\xc4\x21\x28\x1b\x06" + "\xea\x30\x3b\x51\x35\x5b\xc1\x69" + "\x88\x10\x87\x36\x66\x16\x4a\x3b" + "\xff\xb1\x20\x12\x5d\x9f\xe2\xe5" + "\x4d\x9f\x3d\x23\x35\xbb\x82\x4b" + "\x75\xc6\xcd\x18\x33\x63\x07\x4e" + + "\x73\x44\x56\xcb\xdf\xe8\xd2\x78" + "\x1a\x62\xd5\x57\x73\xa9\x49\x43" + "\x24\x8b\x8f\x21\x89\x5d\x83\x9d" + "\xe2\x6e\x9b\x07\xc5\x7b\xfe\x01" + "\xce\x5d\x3b\x5b\x2b\x2a\x7f\xe5" + "\x65\x55\xe5\x5f\xb7\x37\x86\x5a" + "\xe7\xba\x1d\xa4\xae\x34\xff\x83" + "\x8f\x7a\x0a\x95\x9c\x19\xe1\xfc" + + "\x06\x77\x70\x3e\x1f\x54\x4f\x37" + "\xcf\xd0\x31\xa8\x38\x36\x4d\x9a" + "\x04\xca\x18\x15\x83\xf4\xb4\x4a" + "\x18\xc3\x38\xfe\x5d\xee\xe3\x54" + "\x9b\x81\xc8\x03\x64\xe3\x3a\x38" + "\x4c\x86\x17\x2e\xa1\xda\xd1\xa9" + "\x5b\xaa\xee\x50\xb3\x97\x5a\x24" + "\x83\x4e\xbf\x99\x09\xd0\x62\x53" + + "\x80\x39\xd4\x9b\xc2\x13\x03\xfc" + "\x29\xdb\x72\xf1\x70\x4b\x95\x9c" + "\x1a\xa2\x54\xf9\xb7\xdc\x9b\x67" + "\xfc\xe4\xe2\x54\x09\x17\x48\x6b" + "\xd0\xf1\xba\x30\xf5\xf5\x8a\x31" + "\x60\x20\xf9\xcb\x3c\x8a\xea\x26" + "\x58\xe2\x5a\xcd\x7c\x9d\xc6\xc3" + "\xc9\x07\xad\x0e\x47\xa0\x3b\xa7" + + "\x69\x5e\x81\x31\x97\xc3\x63\x3a" + "\x02\x28\xdd\xdc\xd6\xcb\xf9\x6d" + "\xaf\xf6\xb4\x15\x4a\xed\x47\x4c" + "\x78\xf9\xc0\x6a\x82\x9d\x00\x62" + "\xc7\x8f\x89\x8b\xd2\x80\x4d\x66" + "\x1f\xc9\x17\x2c\xda\xee\xf1\x72" + "\x09\x66\xae\x7a\xbc\xd3\x84\x9e" + "\x95\x68\x37\x28\x95\xc1\xc7\x58" + + "\x07\x4f\x29\xd9\x30\x76\xff\xdc" + "\xd0\x8f\xba\x8d\xd6\x65\xb7\x89" + "\xcd\xac\xbc\x8d\xde\x55\x3e\x55" + "\xf8\x2b\x70\xed\x9e\x00\x4a\x9b" + "\x0d\xca\xb8\x27\xdd\x34\xe5\xf6" + "\x52\xfd\x77\x61\x34\x6b\x49\xc4" + "\xb7\xb7\x7b\xc8\xf6\xe6\x8c\x37" + "\xf0\x19\xcc\x44\x48\x3d\x63\x68" + + "\x63\x20\x42\x5e\x91\xb9\xde\x73" + "\xc0\x1b\x75\x4a\x27\x64\xd2\x7a" + "\x4f\x34\x14\x44\x22\xe2\xdc\xe6" + "\x28\x1f\x81\x85\xf7\xef\x01\xad" + "\x2b\xb7\x68\xba\x90\x65\x48\x25" + "\xaf\x35\x36\x20\x4a\x26\x93\xdb" + "\x0a\x66\x22\x28\x8a\x1f\xb0\x1e" + "\x64\x8c\x59\xee\xe8\xce\x2d\xae" + + "\x74\x78\xc1\x7d\xb6\xe7\x59\x35" + "\x2a\xcc\x95\x81\xef\xf0\xca\xd0" + "\xd9\x4d\xd2\x0c\x88\x67\xc0\x07" + "\x41\x7c\x85\x02\xa0\x9e\xa9\x01" + "\x63\x2f\xf8\x90\xe4\x79\x65\xd8" + "\x37\x92\x1c\xe4\x8a\x65\xe0\xb1" + "\x79\x1e\xfd\x93\xfd\xfa\x5f\x07" + "\x8f\x0b\xf6\x47\x35\x40\x70\x6e" + + "\xed\xfc\xe6\xa3\xc7\xf5\x53\x0d" + "\xeb\xbd\x5f\xf4\xd5\xbd\xcb\xe8" + "\x70\x9a\x33\x13\xdf\x01\x5c\xf8" + "\x81\xeb\x2c\x14\x80\x18\xf7\x0f" + "\x7a\x43\x70\xbd\x74\x87\x4e\x4c" + "\x6a\xda\x0b\xba\x91\x28\xb3\x5f" + "\x6e\xd2\x8b\xf1\xd2\xeb\xdb\x1c" + "\x22\xd5\xa9\x03\xf1\x26\x95\x2f" + + "\xa6\xb0\x51\xbe\xda\x86\x51\x76" + "\x88\x90\xce\x73\xf4\xe9\x76\x53" + "\x5a\xd8\x5b\x5b\x0b\x80\xed\xe3" + "\x04\xe6\xc1\x4d\x52\x95\x28\x24" + "\x5e\xd3\x27\xef\x47\xcc\x6d\xe7" + "\x7d\xa6\x00\x90\xd6\xee\x96\x43" + "\xc1\x92\xde\x84\xa0\x3b\xb3\x73" + "\xfe\x01\x76\x37\xae\x53\x64\x22" + + "\xc2\xe9\xf7\xc1\x75\x60\xfc\xec" + "\x34\xec\x5a\xbe\x20\x76\x21\x6a" + "\xa8\x3b\xa3\x9e\x54\xd0\x81\x37" + "\xd4\x85\x6b\xd8\xab\x35\xef\x84" + "\x83\xee\x1f\x46\x3c\xa3\x4a\x91" + "\x6c\x7d\x5f\xb2\xc9\xe5\x11\xf3" + "\x5c\x49\x3d\xc3\xaa\x0d\x11\xc6" + "\xb9\x54\x85\x81\x83\xe5\x7e\x8a" + + "\x0e\xec\xf4\xa7\x2a\x73\x12\x36" + "\x8f\x34\x71\x9d\xd0\x88\x3e\xee" + "\xdb\xcf\x99\x75\xe4\x07\xa1\xb7" + "\xc6\x51\x1b\x61\xe8\xe7\x5d\x1f" + "\xaa\xaa\x51\x10\x59\x1d\xa1\xd6" + "\x86\xc3\xf0\x55\xf0\x31\xe5\x3d" + "\x66\x0e\xf2\x09\x73\x5c\xf9\x09" + "\x79\x4b\x41\x9e\x1a\xaa\x21\x64" + + "\x7e\x1d\x27\xa8\x05\xc9\x52\xa7" + "\x0b\x81\xe5\x58\xa5\xdf\x35\x47" + "\xeb\x5a\x92\x5d\xee\x44\x8a\xe1" + "\x53\xa8\xc8\x13\x7f\x69\x08\x97" + "\x0b\x9a\xcc\xbf\x40\xd5\x77\x83" + "\x03\xd4\x74\xe5\x1c\xe0\x27\x7b" + "\xa6\xa8\x60\xcf\x0c\x18\x3d\x3d" + "\xbf\x98\xc2\xf1\x52\xf1\x8e\xe4" + + "\x60\xb0\x29\xb8\xb1\x60\xb6\xb8" + "\x9b\xc6\x55\x5f\xf1\x3e\xa7\x9f" + "\x88\x78\x20\xef\xec\x19\x5f\xc7" + "\x9e\x12\x2b\x28\x60\x2b\x9b\xb1" + "\xc7\x30\x47\xbf\xee\x27\xf3\xb2" + "\xbe\xc0\x73\xc9\x59\xf6\x9d\xeb" + "\x98\xdb\xc1\x65\xc1\x13\x49\xd1" + "\x9c\x1a\x9d\xf7\xd4\x7d\xf5\x80" + + "\x21\x28\x39\x66\x6f\x02\x04\x11" + "\x49\x84\x79\xe1\xf7\xbe\x3d\x25" + "\x18\x56\x3e\x3f\x37\x34\x4b\x3c" + "\x41\xe0\x64\x2c\xd6\x46\x55\x5b" + "\x2b\x76\xc5\x57\x79\x32\xb5\xad" + "\xf3\x8d\x95\x92\xf0\xd0\xcb\x5d" + "\xbe\xbd\x4f\xf6\x44\x74\x45\x2c" + "\x75\x81\x40\x1d\x82\xc3\xab\xb4" + + "\x79\xd7\x19\xe9\x9b\xe7\x2d\x0c" + "\xbd\x78\x2e\x24\x4a\x69\x84\x15" + "\xc9\x76\x13\xf6\x94\x6d\x75\xa4" + "\x98\x27\xdc\x34\xbc\xa7\xcc\xfb" + "\xa1\xf0\x8d\x10\x19\x53\x87\x5e" + "\x9d\x89\x3e\x29\xae\x01\xec\xe2" + "\x91\x70\x35\x92\xef\xa4\x28\xc9" + "\x65\xd0\x2e\xf6\x87\x89\xa2\xd5" + + "\xc0\xa3\xea\x0a\x8c\x2e\x3a\x31" + "\x0a\x5b\xe8\xab\x9e\x6d\xf4\x89" + "\x3a\x7d\xa9\x2d\xbd\x9e\x88\xd2" + "\xba\x8c\x3f\x10\x6a\x02\x84\x94" + "\x5f\x3b\xd8\x87\x8a\x9f\x15\x52" + "\x95\x02\xef\xb1\xd6\x20\x22\xdb" + "\xcf\x1a\xc0\x03\x6e\x74\xa0\xbd" + "\xe3\x9f\x41\x14\xa7\xb2\x97\x4f" + + "\x9f\x20\x55\x25\xf7\x36\x04\xac" + "\xec\x73\x27\x16\xa2\x66\x34\x20" + "\xfe\x59\x8e\xb4\x39\x87\x3f\xc5" + "\x60\x56\x84\x88\x2b\xda\x4c\xb2" + "\x9a\x39\x5e\xfa\xf9\xb5\x74\x8d" + "\x5e\x25\x92\x6f\x0b\xed\x3d\xff" + "\x0a\x9e\x5c\x04\xfe\x31\x6c\xc7" + "\x62\x46\x2b\x6d\x44\xa0\xba\x85" + + "\x51\x5d\xf0\xed\xbe\x8b\xaf\xb8" + "\xb8\x8d\x8f\x71\xa6\xc7\x53\x86" + "\xdd\xff\x00\xcf\x8b\xb4\xfe\x14" + "\x40\xe1\xa9\x5c\xdb\xf7\xbc\xfc" + "\xb7\xfd\xd8\xd9\xe8\xec\xb4\x73" + "\x21\x99\x38\x2f\x68\xd3\x69\xdc" + "\x19\xc2\x8b\xc8\xe4\x2e\xd3\x10" + "\x96\x2d\x1c\x92\x27\x2c\x4d\xc0" + + "\xfd\x73\x10\x3d\xb8\xfd\x81\x69" + "\x0e\x20\x78\x6c\x0d\xf7\x2a\x25" + "\x7e\x57\xef\xa9\x67\xe8\xd0\x60" + "\x67\xe0\x13\xa4\xe8\x3f\xe6\x66" + "\x3a\x15\x14\xb9\x73\xb1\xdc\xbb" + "\xa8\xa0\xb4\xcc\x23\xe6\x9a\xb5" + "\xa0\xb8\x35\x3c\x20\x30\x05\x34" + "\xff\xf2\xda\x30\x6f\x81\xb8\x19" + + "\xca\xe5\x80\xc8\xc2\x7a\xbf\xcc" + "\x50\xc4\x11\x8d\xee\xdb\x99\x82" + "\xbf\xa6\x77\x0f\x1b\xd1\x27\xbb" + "\x93\xe7\xdc\x5e\x0b\x63\x01\xc6" + "\xea\xf8\xe7\x79\xfb\xb9\x73\xdb" + "\x88\x72\x36\xf4\xa7\xbb\x48\xe4" + "\x1b\x57\x35\xb0\x6f\x41\xb6\xf5" + "\xa2\x91\x88\xa4\x5d\x8f\x1b\x98" + + "\xa0\xfa\xfb\xb4\xff\x90\x96\x00" + "\xdb\xc6\x19\x36\xb7\xda\xbb\x8b" + "\xe8\x56\x83\x72\x73\x42\xd4\xc6" + "\x35\xec\x53\xe4\xd8\xf0\x76\xfd" + "\x29\x8a\xc2\xaa\x54\x25\x5c\x77" + "\xf0\xe4\x55\x5c\x9d\xaf\xf7\x28" + "\x4d\xad\xe8\x88\xa6\x54\xcf\xba" + "\xdf\x6d\xa7\x0a\xe8\x18\xb0\x85" + + "\x93\x7a\xc3\x09\xb9\xb3\xc8\x8f" + "\x2c\xb0\x99\xa1\xcb\xeb\x8f\x75" + "\x8c\x20\x3b\x8f\x38\x45\x9b\x5c" + "\xf0\x90\xba\xf2\xde\x84\x85\x7c" + "\xe3\xcc\x95\xb3\x1c\x1a\x75\x52" + "\x50\x5f\xd4\xc1\xeb\xe4\x59\xbb" + "\xac\x5d\x63\xb0\x11\xb9\xcd\xf7" + "\x94\x36\x24\xd3\x71\xd3\x24\xe9" + + "\xd6\xa8\x53\x65\xfd\xc0\x32\x65" + "\x6d\x5a\x16\x45\xa5\xcb\xb8\x42" + "\x92\x2d\xf1\x3c\xea\x88\x6d\x9c" + "\xc5\xb0\x6d\x90\x30\x35\xc9\x0e" + "\xdf\x6c\xcc\xec\xf8\x06\x46\x49" + "\x99\x78\x38\xc6\xfc\x66\xed\xa7" + "\x4c\xae\x35\x8a\x17\x2e\x02\x91" + "\xc3\xbe\xa7\xec\xe6\xca\xdb\x28" + + "\x84\xd6\xc4\x92\x51\x30\xce\x40" + "\xcd\xef\x12\x76\x25\xd7\x04\x8b" + "\x20\xae\x9c\x6f\x36\xda\xdc\xb9" + "\x6c\x85\x58\xf0\x24\x4d\xdc\x0e" + "\x00\x79\x42\x85\xbf\xe6\xf2\x64" + "\xea\xdf\x09\xdc\x95\x12\xe8\x3d" + "\x6c\xf2\x9b\x37\x87\x44\x1b\xd4" + "\xa9\x35\xf1\x6d\x6d\x2c\xb6\x50" + + + "\x2a\x83\x05\xd0\x5e\xfb\xb2\x0d" + "\x4f\x2e\x04\x91\x3b\xfd\x5e\x5f" + "\xca\xf8\x70\xed\xc6\xfd\x4f\x8c" + "\xcc\xa9\x2d\xb5\x0b\x5d\x64\xe4" + "\x1f\x1d\x00\xc9\x8b\xf5\x96\x95" + "\x05\x72\x11\x4e\xbc\xf0\xc8\x52" + "\x84\xa0\x98\xe3\xd2\xa0\x4a\xfd" + "\xde\x49\x4f\x10\x3a\xfe\x5b\x81" + + "\x7b\xb3\x48\xe5\xcc\x3a\xeb\x54" + "\x49\x05\xd4\x84\x42\x75\x8e\xb3" + "\x4f\x1b\x34\x7b\x51\xaa\x3d\x8c" + "\xfa\xf7\x0b\x69\xec\x28\x69\x2f" + "\x41\x6c\xce\x86\x23\xb3\x96\x04" + "\xcd\xad\xad\x10\x55\x1c\xbe\x01" + "\xf9\xfa\xb5\x4b\xe7\x67\x4e\xc0" + "\x85\x99\x5c\xe1\x78\xf6\xba\x3c" + + "\x2d\x9a\xab\xd7\x6a\x22\x4d\x52" + "\x58\xe9\xfa\x7d\x0d\x09\x00\x9c" + "\xc2\xd8\x51\x87\x39\xf5\xa5\x0b" + "\x2d\x26\xb8\x3a\xdd\xbc\xfc\x8a" + "\x3b\x04\x9d\xe9\x29\x27\x39\x57" + "\x3a\x94\xbc\xae\x3b\x26\x51\xef" + "\x35\x29\x86\x20\x93\xce\xea\x9f" + "\x7b\x81\x6c\xb0\x03\xfc\x9e\x63" + + "\xdc\x81\x1d\x34\x7d\xbe\x39\xe8" + "\x79\x83\x14\x32\x89\x68\xdb\xcd" + "\xad\x6e\x02\xf7\xa1\x11\x62\xda" + "\x5e\xcc\xd1\xf4\x5f\x57\xb2\xf3" + "\xe6\x3a\xa7\xa7\xf6\xc8\xcf\x40" + "\x83\xb4\xd5\x61\x5e\x9a\x87\x83" + "\xbc\x0e\xa5\x41\xed\xb1\xac\xc5" + "\xfa\xd8\x07\x3c\xc8\x0c\xa6\x59" + + "\x90\x19\xb8\xc3\x4a\x8d\xc9\xde" + "\xfe\xc8\x0c\x9e\x22\x37\xb8\x1c" + "\xb9\x27\xb4\xd2\x91\x04\x0b\xfe" + "\x6c\xa6\x83\xe9\xac\x86\x23\x0f" + "\x13\x12\x29\xb3\x1e\x4d\x0c\x93" + "\xe4\x2a\xa6\x59\x2e\x2b\xf8\xa2" + "\xe3\x89\x3e\xf9\x53\x38\x23\x77" + "\x7f\x7c\x77\x11\xac\x63\x80\x7f" + + "\x00\x10\x37\x59\x7c\xc9\x4a\x60" + "\x18\x9c\x75\x7f\x70\x8c\xc4\xe1" + "\x65\x6b\xdb\xa5\xc5\xec\x62\x3f" + "\x95\x14\xa2\x38\x73\xb1\x78\x0a" + "\x94\xad\xc8\xbc\x9d\x81\xe1\x6b" + "\x00\x34\x9c\xd8\xf6\x04\xdc\x70" + "\x0a\x84\xb4\xa6\xb4\x57\x25\x46" + "\xc0\x21\xbd\x60\xde\x6a\x4c\x54" + + "\x72\x60\xff\x02\xcf\x07\xe6\x36" + "\xdc\x8c\xd9\x8a\xa9\x2c\x7d\xa4" + "\x09\x66\xf5\xf5\x1e\x1d\x47\xbf" + "\xa0\xad\x64\xf2\x23\x66\xf8\xbc" + "\xb6\x5c\x9e\xaa\x87\x06\x0c\xb7" + "\x6c\x1c\x40\x17\xf2\x24\x81\xc9" + "\x35\x14\xa6\xd4\x5f\x63\x89\x81" + "\xa6\x8e\xd9\xa9\xaf\xb8\x8f\xd2" + + "\x2d\x32\xc7\x65\xb6\x30\x95\x43" + "\xfb\xb3\xc1\xb3\x01\xcc\x12\xcf" + "\x85\xf6\x72\x01\x86\x01\x0b\xc7" + "\x1d\x39\x58\x1b\x22\xee\x15\xb9" + "\x24\xdb\x17\xa3\x3b\xf0\xfd\x9a" + "\xc4\xff\xb8\x17\x59\xc6\xde\x87" + "\x50\xd0\xd3\xe4\x7b\x59\x46\x7f" + "\xe7\x00\x65\x00\xed\xc1\xa1\x80" + + "\xf3\x25\x70\x01\xc3\xa8\x4d\x3d" + "\xb4\x79\x95\xfb\x8c\x62\xcf\xef" + "\xec\x16\x37\x1f\x16\x00\x4d\x5c" + "\x6e\x11\x01\x68\xc4\xeb\x27\x9c" + "\x7e\x76\xa1\x1d\xa1\x0e\xba\x5e" + "\x57\x4c\x00\x47\x52\x14\x15\xfe" + "\xb7\x73\x23\x8c\xf6\x6d\xce\x3a" + "\xac\x37\xbc\x5d\xfe\xdf\xc3\x75" + + "\x49\x07\x8a\xa2\xdb\x47\xa1\xa2" + "\x65\x91\x51\xee\xd6\x20\x6c\x24" + "\x15\x07\x81\xd3\xb1\xd1\x68\x50" + "\xb9\x60\x81\x74\x8c\x01\xe7\xb1" + "\x62\xff\x80\xf3\xfa\xb1\xf5\x03" + "\x1e\x2c\xcb\xf3\xdd\xb1\x7f\xef" + "\xda\xa7\x91\xfc\xa8\x39\xb5\xea" + "\x61\xb5\xf9\xf3\x07\xb7\xdd\x83" + + "\x98\x1b\x10\x80\xd9\x76\x72\xb5" + "\x66\x0f\x2f\xb8\xfd\x83\x08\x76" + "\xf3\xef\xc3\x4b\x75\xde\xd7\x89" + "\x40\xab\xc2\x5d\x43\x06\xb6\x03" + "\xac\xee\x5b\xe0\xdf\x53\x6e\xcd" + "\xcd\x25\x33\xbc\x62\xe8\xf1\xf2" + "\xc3\x03\x4f\x77\x21\x79\x0f\xdd" + "\x1b\xcc\x52\x45\x21\x72\xca\x97" + + "\xea\x46\xec\x9c\xf0\x4a\x9a\xe7" + "\xc7\x9b\x8b\x65\xa1\x47\x53\xb1" + "\x75\x2f\xaf\x35\x6f\x79\xd2\x6b" + "\x35\xc4\x51\x40\x90\x79\x95\xac" + "\x5d\x65\x3a\xc3\xa3\xdd\x69\x26" + "\xa3\x4a\x51\x88\x2e\x3c\x50\x5d" + "\x41\xdd\x53\x37\x37\x13\xa1\xdf" + "\x78\x4f\x75\x0b\x73\x46\x05\x3f" + + "\xd7\xc5\x24\xe2\xb5\xb3\x0c\x76" + "\x19\x69\x61\x68\x8c\xaf\x3b\xfa" + "\x52\x25\x14\x8d\x13\xa1\xbc\x9f" + "\xf5\xeb\x69\x76\xf1\x8b\xb1\x1a" + "\xdd\x25\xdf\x9b\x3e\xf5\xe6\x55" + "\x54\xd1\x6c\xcb\xf3\x0b\xcc\x04" + "\x80\x90\xe8\x95\x49\xef\x5b\x59" + "\xc1\x9a\x4a\x10\xa8\x59\x94\xfe" + + "\xf0\x3e\x12\xa8\x16\x63\xd6\x49" + "\x38\x54\xf9\xe7\xb4\x2d\xc3\x73" + "\x54\x78\x9e\x0d\x09\xd2\x2e\x2e" + "\x07\x05\x9f\x9d\x29\x93\x8a\xf9" + "\x0a\xa2\x6a\x0c\xf6\x3c\xd3\xc5" + "\xb2\x9b\x27\x75\x14\xba\x32\x9a" + "\x07\x73\x4a\x77\xcb\x02\x32\x7e" + "\xbd\x2d\xc4\xe8\xc4\x4b\xed\x64" + + "\xe8\x20\xb0\xab\xc5\x64\x4b\x69" + "\xc7\xee\xc4\x19\x84\xc1\x18\x3d" + "\xe5\x93\x47\x1c\xef\x73\x46\x9c" + "\xe6\x92\x60\x05\xb5\xae\xb8\xc7" + "\x6b\xc1\xf8\xf0\x43\xca\xa1\x3a" + "\xf6\xb2\x79\xd6\xec\xd5\x4e\x22" + "\xc9\x05\xa2\x55\xaf\xee\x56\x0d" + "\x8b\x02\x8e\x4b\xba\x15\xe1\xbf" + + "\xec\xf4\xac\x97\xb3\xa7\x22\x3e" + "\x40\xb6\xa8\x5e\x00\xc4\x26\x04" + "\x85\x92\x96\x4e\xa6\x95\x32\x5e" + "\x70\x56\xa4\xa6\x59\xbc\xaa\x22" + "\xbc\x42\x59\x5f\x4c\x71\x29\xb9" + "\xed\x82\x31\xfa\xbd\x68\x61\x9a" + "\xba\x52\x41\x10\x65\xa6\x16\x22" + "\x68\x63\x92\xb6\x03\x8d\x90\x46" + + "\x50\xa8\xcb\x7f\x24\xe0\x8b\x9b" + "\x1e\x18\x0a\x82\x97\x57\xeb\x81" + "\x11\x12\xa0\x30\x22\x81\xf2\xa0" + "\x21\x88\x7b\xae\x3c\xdc\x9c\x7e" + "\xe7\x15\xce\x72\xcc\x32\x23\x20" + "\xd7\x38\x82\xcb\xbb\xb2\x3c\xcd" + "\x43\x2c\xe8\xc6\xdf\x63\xab\xe4" + "\x17\xd7\x83\x31\x28\x00\xbd\x58" + + "\xab\x42\x29\xf3\xe8\x46\x8d\xd1" + "\x18\x24\x88\x10\xf6\x6e\x76\x6c" + "\x6b\xcd\xc6\x0c\x1a\xcb\xff\x8e" + "\x60\x59\xd8\x68\x5c\xa0\x1d\x5a" + "\x1c\x6e\x29\x32\xa5\xf4\xa5\xc7" + "\xc8\x2e\x0d\xc9\x43\x1e\x0f\x3d" + "\xd9\x29\x97\x89\x22\x3a\x94\x29" + "\x17\x53\x0e\x36\x26\x8a\x7a\x87" + + "\xb5\xd7\x7e\x71\x7e\x7b\xd5\x02" + "\xa2\xe1\xbc\x4d\x24\x5b\x2e\xd2" + "\xf5\xdc\x4c\x2a\x71\xd7\x4b\x17" + "\xbb\x05\x82\x40\x01\xb8\xfd\xa6" + "\xe9\x87\x13\x5e\x69\xb0\xb4\x67" + "\x42\xa4\x91\x05\xa1\x19\x2b\x33" + "\x66\xf3\xac\xcc\x16\xd9\xed\x24" + "\x50\x8a\x95\x34\x45\xcc\x34\xbe" + + "\x4b\x18\x1c\x06\x99\x76\x59\x81" + "\x52\x89\x89\x63\x5c\x10\x3d\x65" + "\xad\xfc\x5e\x7b\xde\x06\x91\xda" + "\x52\x14\xa6\x8a\xa6\x5a\x33\xa0" + "\x04\xba\xfa\x4f\x89\x7c\x7d\x33" + "\xf6\x90\xa9\x8e\xfe\xd4\xce\x9d" + "\x28\x57\x8c\x26\xb6\xb3\x28\x36" + "\xec\x21\xaa\xc2\x89\x70\x93\xf9" + + "\x91\xd3\x66\x3e\x1e\x6e\xf4\xa3" + "\xb2\x69\x63\x7d\xcd\x32\xa7\xb4" + "\x22\x10\x2c\x40\x5d\xb8\xc3\x99" + "\x2e\x93\x54\x2b\xbe\xfc\xcc\x7d" + "\xe2\xdf\xb1\x56\x7b\xaa\xdd\xa6" + "\xc9\x82\x4a\xe3\xa5\x78\xdc\x31" + "\x41\x39\x4f\x70\xda\xb3\xbe\x8a" + "\x98\xfa\x55\xca\x6c\xa3\x11\xdf" + + "\x66\x19\x86\x89\x34\x8e\x3b\xd5" + "\x6b\x99\xea\xa0\xa1\x20\xfb\x79" + "\x43\x7f\xd3\x5a\xd9\x47\x06\x30" + "\xcd\xe3\xa7\x53\xa8\xb4\x4d\xb4" + "\xfb\x59\x66\x2e\xb9\xe1\xe3\x9e" + "\x20\x72\x68\x5f\x72\x63\x32\x4b" + "\x43\x01\xa1\xb1\x25\x68\xc2\x6e" + "\x0b\x6f\x7d\x86\x2b\x76\xb6\xb4" + + "\x1b\x0c\xe0\x16\x7a\xf7\x01\x6c" + "\xac\xaa\x9e\x83\x90\x54\x51\x82" + "\x34\xd3\x70\x34\xef\xa4\xf3\x62" + "\x6c\xcd\x1d\x1c\x49\xa6\x29\x5a" + "\x25\x7a\x99\xce\x2e\x78\xb6\x46" + "\x53\x99\x57\xd3\x35\xfb\x78\x99" + "\xce\xe0\x60\x09\xdf\xa9\xf5\x98" + "\x4c\x7a\x52\x1f\x39\xc8\x7d\x54" + + "\xc1\xbc\xba\xc2\xc6\x8a\xcb\x52" + "\x8d\xae\x81\xfe\x48\xd4\x48\x47" + "\x11\xa7\xf1\x80\x3f\xf0\x44\x58" + "\xc4\x4a\xdf\xf8\xb2\x84\xb7\x3d" + "\x36\xfe\xf1\x2d\x12\x8f\x91\xad" + "\xc0\xc7\x3c\xf3\xb9\x25\x0f\xe4" + "\x55\x55\x5e\x3b\xe7\xd0\x00\x47" + "\xf9\x26\x33\xb0\x08\xfa\x28\x5c" + + "\x4f\xc2\x9d\x5d\x83\x15\x5b\x39" + "\x80\xe6\x3a\xc7\x32\x69\x25\xa4" + "\xe9\xc8\xa2\xfa\x0e\x96\x42\x05" + "\x6a\x8c\x06\x71\xee\xad\xb3\x2b" + "\x54\x45\x0b\x57\x9b\x09\x06\xa7" + "\xd6\x78\xe2\xf4\xb5\x2b\xd1\x85" + "\x43\x68\x29\x64\xf6\xf6\x8a\xd7" + "\x33\xc6\x28\x84\x88\xb3\xd3\xc7" + + "\x58\x97\x3f\xdb\x09\x67\x3b\x4c" + "\x1a\x8c\x1d\x34\x4e\xda\x9e\x16" + "\xd2\xa6\x13\x96\x18\x2f\x4f\xbd" + "\x36\xa5\xcd\xd7\x4e\x2b\x00\x9a" + "\xb9\x03\x61\x77\xd1\xf8\xbd\x97" + "\xba\x45\x79\xb3\x34\x0d\x67\x9c" + "\xbf\x5b\x8c\xd7\x84\xe3\x83\x9b" + "\xb2\x14\x8d\x51\xcf\x3b\x2d\x6e" + + "\x97\xe5\xb7\x43\x93\x4f\xd4\x34" + "\x42\x0f\x53\xc2\xa7\x40\xe4\xdd" + "\xb9\xbd\x56\x78\x81\xa0\x70\x72" + "\x2f\x03\x53\x53\xeb\x45\xa9\x86" + "\x10\x98\xd3\x66\x99\x8e\x2f\x6c" + "\x6b\x4b\x8b\x9b\x1b\xa3\x42\x06" + "\x82\x9d\x50\xd1\x62\x9e\x67\x51" + "\x16\xff\xf8\x90\x1c\x00\x20\x01" + + "\x4a\xe3\x36\x2e\x06\xc1\xa1\x50" + "\x1a\xed\x24\xe0\x8c\xf5\xe8\x74" + "\x26\xd7\x00\x13\xfa\x1d\x0f\x3f" + "\x18\x2d\x4a\x7b\x26\xdf\x80\x66" + "\xb7\xb3\x35\x82\x9d\x97\xb5\x12" + "\x93\x14\x61\x8a\xcb\xaf\x2f\x1d" + "\xe5\xec\x48\x88\x96\xda\xeb\x73" + "\x99\xe3\x13\xa4\x75\xc2\x96\xe9" + + "\x00\xf0\x5f\x49\xc7\xd7\xb7\x46" + "\xd1\x95\xed\xba\x97\xd0\x0e\xe6" + "\xc0\xf9\x38\x6e\xac\x04\x88\xaa" + "\xbb\xf9\xc6\x45\x06\x0c\x99\x92" + "\x51\x98\x91\xc0\x39\xa4\xe6\xca" + "\xf2\xe1\xf5\x1b\x15\xff\x3d\x71" + "\xdb\x8c\xb3\x2e\x30\x2c\x26\x5d" + "\xdf\x31\xdf\x90\x51\x50\x3d\xb7" + + "\xe5\x2f\x5b\xe5\xc2\x32\xc8\x85" + "\xfc\xde\x19\x91\x65\x21\x51\xf2" + "\xe4\x0f\xb0\x99\xbc\xe3\xfd\xfc" + "\x17\x8b\x90\xd1\xe3\xf5\x67\x80" + "\x42\xae\x43\x14\xb3\xf6\x21\xe9" + "\x3b\x59\xea\x64\x92\xed\xcf\xa2" + "\x35\x7a\xe0\x59\x62\xb9\x89\x15" + "\xdd\x62\xa7\x0d\x0a\x39\xbb\xc6" + + "\x8c\x26\xd9\x32\x1c\x7b\x1e\x92" + "\xd4\xfa\x76\x42\x96\x2b\xdb\x34" + "\x30\xe7\x44\xcc\x34\x6d\xc5\x0e" + "\xb7\x45\x65\x09\x46\x3a\xbe\x59" + "\x6a\x3a\xcf\x66\x97\xbc\xfd\xe9" + "\x53\x9b\x4e\xd0\xed\x83\x2f\x7b" + "\xe7\xe3\xba\x8f\xcc\xb3\x99\x6d" + "\x40\x3a\xda\x7a\x6c\x64\xb5\x8e" + + "\xfb\x51\x12\x5a\x74\xd8\xf5\xa9" + "\xc7\x25\x27\xc7\xa8\x47\x77\x96" + "\x9e\xe8\xff\x31\xe5\x33\x5c\x19" + "\x5e\x93\x64\xe9\x0f\x21\x9d\x60" + "\x27\x22\xe1\x2f\xa8\x6c\xfd\xca" + "\x9d\x46\x26\x04\x96\x5b\x9b\xaf" + "\x3c\x18\x93\x56\x4c\xe0\x9e\x2e" + "\xef\x6f\x14\xc8\x33\xa3\x84\x10" + + + "\xf7\xd1\xd1\xae\x33\x99\x64\x96" + "\x90\x30\x56\x50\xf3\xaf\x6e\x56" + "\xcf\x39\x2e\xad\xf0\x57\x50\x34" + "\x24\x21\x83\x1f\x5b\xf6\x8f\x14" + "\x0d\xcf\x94\xcf\xd4\x89\x2e\x04" + "\xb3\x58\x0c\x52\x84\xec\x9b\x31" + "\x0d\xaa\x61\x53\x26\x76\x26\x2a" + "\xad\x87\xbc\x8f\x02\xa3\x6f\xc8" + + "\x6f\x69\xc1\xad\xe1\xd7\x66\x6b" + "\xd0\x72\xcd\x0a\x93\xe5\xeb\x98" + "\x35\x74\x1b\xcc\x50\x45\xf2\x65" + "\xec\xa5\xb9\xb4\x93\x13\x23\xce" + "\xf9\x7d\x06\xdb\xd4\x22\x4a\x23" + "\x00\x9b\xff\xca\x95\xa0\xdd\x98" + "\xc1\xc9\x00\x61\xa0\x75\xbc\x1b" + "\x95\xf6\x9c\x93\xc8\xa9\x60\x15" + + "\x74\xbf\x51\xfe\x5e\x32\x50\x08" + "\x94\x00\x46\x5e\x9e\x57\x4f\x9c" + "\x25\x2f\xda\x76\x2a\xb9\x87\x5c" + "\x33\xef\xeb\x6f\xe0\xe4\x9d\x88" + "\xce\x83\x60\x64\x06\xec\x00\x69" + "\x73\x27\xe1\xbf\x35\x03\x2a\xbe" + "\x10\x41\x34\xc5\x35\xda\xd1\xad" + "\x20\xcd\x02\xb8\xb7\x68\x75\x75" + + "\xca\x67\xc3\xf1\x1c\x0f\x05\xe4" + "\x7d\xbc\x0f\xc9\x9b\x5a\xc8\x9b" + "\x32\x10\xa1\xe1\xa2\xc4\x73\xa3" + "\xa9\x93\x03\xad\xb7\x32\x42\xb6" + "\x29\xad\x7d\x16\xb0\x7e\x57\xf5" + "\xb2\x8a\xb7\x94\x01\xf3\x04\x16" + "\x8b\x34\x29\xe8\xaf\x94\xaa\x0b" + "\x42\x43\x65\x41\xdd\xd8\xfb\x77" + + "\x2e\xcd\xa7\x94\xb4\x51\xf6\x6f" + "\x6c\x33\x99\x06\xd1\xff\x71\x56" + "\x6a\x89\x9a\x97\xcc\xd2\x5f\x6f" + "\xef\x8c\x14\xd8\xa8\x93\xe8\x11" + "\x10\x7b\xcf\x65\xa1\x06\x89\x98" + "\x85\x84\x0d\xc5\x78\x71\xb6\x81" + "\xde\xb3\x35\x8a\x35\xeb\x0d\x7c" + "\x99\x97\xd2\xc1\x55\xc8\x3a\x42" + + "\x08\x87\x61\x09\xe1\x69\x9f\x71" + "\xb1\xf9\x83\xc1\x64\x83\x9e\xcc" + "\xaf\x21\x6a\x36\x95\x3a\x20\xec" + "\x1f\x14\x8b\x06\x6d\x5d\xec\x6a" + "\xe9\x04\x4f\x99\x8a\xf7\x2d\xee" + "\xb0\x45\x12\x27\xe8\xca\x9c\xb3" + "\x4f\x3f\xe4\x97\xa9\xa4\x75\xb8" + "\x98\xea\x2c\xdb\x11\xfe\x7d\x50" + + "\x3d\x12\x32\x52\xea\x7a\x4b\x31" + "\xdb\x86\xae\x65\x8c\x7c\x30\x08" + "\xed\x68\x46\xaa\x5c\x16\xe7\x06" + "\x39\xec\xd3\xb4\x8b\x45\x70\xb1" + "\x86\xb9\x9b\xc1\xc6\x3e\x2e\x4d" + "\xed\x04\x03\xae\x46\x48\xf3\xc5" + "\x22\x97\x9f\x6c\xa0\x95\x76\x91" + "\x0a\x1c\xab\x4c\x17\x73\x7f\x6c" + + "\xfd\xa7\xf0\xfc\x02\x48\xf1\x31" + "\x1e\xb0\x88\x54\x89\x07\xfd\x42" + "\x98\xb4\x52\x99\x6d\x8d\xd7\x71" + "\x01\x52\xac\x07\xd9\x72\xb5\x8e" + "\x88\x4a\x19\x4d\x4c\xa4\xa2\xe0" + "\x66\x7e\x01\xba\xd9\x3f\xb6\xd2" + "\xfc\xae\x88\xf8\xc8\xc6\xef\x78" + "\x11\x1a\x88\x4a\xda\x6b\x6f\xb7" + + "\x38\x72\xa6\xb2\x01\xe1\x0b\xbf" + "\xf2\x14\x9c\xaf\x67\xd3\x56\x35" + "\x75\x20\x66\xa5\x31\x78\x4b\x10" + "\x0a\xe6\xd9\x79\xbb\x59\xca\x58" + "\x3b\xa7\x69\xa5\x92\x53\xc4\x4b" + "\xc9\xf6\x98\x56\xe8\x52\x7a\x51" + "\x55\xd7\xad\xae\xa5\x3d\x64\x85" + "\x84\x1b\x58\x2a\xd5\x0c\xed\x1a" + + "\x67\xe9\xf9\x19\xbc\x26\xf7\xa0" + "\x4e\xbf\xfb\xe8\x52\x31\xd0\xd9" + "\x40\x7d\x70\xb7\x1d\xf5\xd6\xcf" + "\xe0\xe6\xf6\x63\xd9\x84\x30\x63" + "\xaf\x7e\x66\x55\xdc\x9c\xcd\xed" + "\x6f\xd5\x44\x2e\x2b\xf9\xb7\x73" + "\x14\x2b\x96\x4e\xb6\x39\x2e\xfb" + "\xbf\xfc\x71\xf6\x6e\x8f\x40\x7d" + + "\x8a\xcf\xdf\xf8\x75\x30\xea\x9e" + "\x25\x98\x66\x95\xaa\xf0\x84\xa2" + "\xd8\x3f\x7d\x86\x50\xa2\xfc\xb3" + "\x1e\x69\x9d\x26\x5f\x7b\x75\x20" + "\xde\xa5\xb8\x93\x20\x40\xc2\xf2" + "\xa6\x6d\xc0\xeb\x59\x33\xf9\xd3" + "\x33\x9c\x73\xb2\x3e\x29\x78\x11" + "\xe5\x86\xd6\xbc\x70\xe7\xa3\xd2" + + "\xee\x43\xaf\x68\x2c\x93\xf7\xa2" + "\xbd\x00\x3d\x70\x8e\x46\x02\x55" + "\xf5\x61\xb0\x2f\x8f\x97\xdc\xe5" + "\xad\x15\xc8\x28\x4a\x90\xa1\xc9" + "\xa4\x56\x0c\x47\x8d\x53\xaf\xd3" + "\xed\x8c\x3d\x19\x5f\xbc\x9a\x15" + "\xf3\x8e\x10\x20\x5f\x24\x37\x2a" + "\x78\x71\x3f\x22\x1e\x08\x17\xfa" + + "\x3a\xa7\xf2\xec\x8d\x6e\x20\x2a" + "\x94\x19\x55\x8e\x97\x63\x6a\x06" + "\xa2\x53\x8d\xb9\x8a\x08\x6a\x3a" + "\xaa\x24\x11\x2d\x7c\xc6\xe7\x0c" + "\x3c\x11\x9a\x75\x71\xc6\xce\x48" + "\xfa\x67\x6f\x4f\xd3\x73\xb3\xe3" + "\x7b\x72\x36\xfd\x79\xd4\x55\x54" + "\x81\x0d\x3c\xa1\xee\x28\xa4\xe5" + + "\x5e\xbd\xb1\x16\x5f\xea\xfe\x6b" + "\xd3\x0a\xe3\x4d\x20\xe4\x57\xf9" + "\x9e\x3b\x35\x6a\x4e\x66\xaf\xcb" + "\xeb\x4f\xd1\x26\x12\x33\x87\x5c" + "\xcb\x57\x5f\xb6\x8c\xf9\x87\x4e" + "\x41\xdd\x0c\x5e\x21\xa6\x60\xdb" + "\x40\x14\x88\xa6\x65\x68\xc1\x67" + "\xaa\x52\xab\x46\x1a\xef\x93\x10" + + "\x64\xec\x2e\xbb\xba\xcb\xbc\x93" + "\xbe\xad\x03\xda\x64\x3b\xc2\xa0" + "\xc4\x6a\xe8\xe0\x0a\xa0\x7a\x5f" + "\xe6\x01\x14\xfc\x1e\x94\x0b\x47" + "\x74\x35\xf4\x9d\x79\xd6\xd8\x5a" + "\x10\xd8\x65\x0f\xa9\xb8\xcf\x4c" + "\x81\xbd\x7f\xaa\xe3\x80\xce\x1b" + "\x0a\xd2\x08\x95\xad\x91\x32\x27" + + "\x7c\xb6\xb4\xb4\xb2\xa9\xe2\x1f" + "\x04\x06\x02\xe8\xf0\x0d\xd1\xc1" + "\xd8\x58\x80\xbc\xfc\xab\x64\x9d" + "\xbb\x0f\x2a\x71\xb2\xb9\x43\x89" + "\x04\xef\x3d\x3b\x14\xd9\xee\x90" + "\xff\x75\xe7\x4c\xa2\x3a\xab\x85" + "\x40\x90\xbc\x7b\xca\xd4\x5f\x60" + "\xfb\x5d\xc7\xe2\x64\xa5\x34\x8b" + + "\x0f\x36\x82\xe3\x7c\x9f\x75\x25" + "\x57\x58\xbf\x88\xc9\x05\xdb\xb6" + "\x6c\xd4\x58\x6c\x1d\xd6\x17\x29" + "\x7a\xcb\x20\xfd\x91\xe4\xf8\x14" + "\x40\x03\xc2\x11\x7a\x72\x8a\xb6" + "\xb6\xcb\x7c\xaf\x6f\xf8\x86\x03" + "\x20\x9a\xe0\xfe\xcc\xc6\x8b\x5c" + "\x35\xea\x7e\xbb\x4a\xff\x76\x7d" + + "\x88\x52\x8a\xaa\xaa\xca\xab\x4d" + "\xc9\xa1\x23\xaf\x8a\x0c\xcc\x91" + "\x0c\x0e\x22\x3f\x6a\x2c\xc7\x34" + "\x4a\x14\x32\x12\xdf\x0b\xc2\xbc" + "\x1b\xde\x0e\xa2\xda\x42\x2f\x6e" + "\x15\x05\xa0\x74\x0c\xf0\x41\xc4" + "\x4b\x8c\x4b\x73\xb6\xa5\x46\xbf" + "\xa4\xc9\x56\x7b\x03\x95\x40\x57" + + "\x1b\x57\xf3\x3f\xa5\x36\x68\xb4" + "\xc1\x27\x79\x83\x78\x8b\xf9\x24" + "\x16\xc7\x33\x45\x6a\x25\x54\x62" + "\x96\xe1\x7e\xd0\x0b\xbb\x7a\xf2" + "\xfd\x5b\x6d\x5c\xfc\x64\xcf\xd7" + "\x77\x7a\xcd\xf0\x51\xc7\x15\x69" + "\x34\xf5\x98\x87\x12\x90\xf5\xd9" + "\x5f\x8b\x1d\xf8\xa8\x0d\x2b\x77" + + "\x90\x7d\x2f\x8e\xf8\xac\x18\x5c" + "\xcd\x32\xbe\x77\xd7\x33\xbf\xfd" + "\xe9\x5e\xeb\xd2\xd7\x5c\x08\x0a" + "\x15\x11\x20\xb3\xfb\x2c\x70\x2d" + "\xe8\x8c\xc8\x85\xdb\xeb\xe0\xb6" + "\x17\xd6\x01\x1e\x3c\xce\xa3\x23" + "\xac\x33\x73\x56\x8e\x61\x41\x30" + "\x6b\xdb\x7e\x15\x8f\xfd\xd0\x9d" + + "\xb0\xd1\x07\xce\x73\xda\x6b\x38" + "\x78\x41\xad\x58\xc2\x10\x29\xd8" + "\xf4\x17\x26\xcd\xcf\x82\x4f\x12" + "\x70\x17\x69\xef\x8d\x5e\x2f\xcc" + "\xcc\x0c\xc3\xb8\x50\x25\x70\x82" + "\x5a\x57\x8e\x1a\xea\x6a\x85\x7b" + "\x59\x94\xab\xb1\xef\x2f\x82\xbb" + "\x8e\xe3\x24\xec\xbc\x28\x59\x08" + + "\x71\x88\xb9\x8f\x11\x3d\x46\x80" + "\xff\x6a\xc7\xbb\xc3\xf5\x26\xcb" + "\x14\x36\xe0\xfb\xdd\x8e\xab\xd4" + "\xee\x2d\xcf\xc0\x9b\x57\xeb\xc8" + "\x41\xae\x3b\xc9\x15\x4c\x00\xcc" + "\xb2\xa3\xec\x3a\x5d\xae\xfb\x46" + "\xb1\x9a\x1e\x0f\xcf\x35\x12\x67" + "\xc1\x85\xc2\x9e\x34\xa9\xfb\xad" + + "\x77\x64\x7c\xb5\x6b\x93\x6c\xa3" + "\xc6\xbc\x4d\xe9\x64\x8b\x1f\x87" + "\x7b\xa6\x91\xa5\x62\xfb\xd0\x28" + "\xf5\x26\xd9\xc1\x81\xe0\x40\x9d" + "\x5a\x4b\xd8\xf2\xf6\xea\x11\x31" + "\x44\xb6\x65\xa5\xf9\x93\x89\x22" + "\x8b\x18\x83\x2c\x92\xf5\xcb\x0c" + "\x97\xe1\xf3\x3d\xab\x30\x7b\xf8" + + "\xaa\x7a\xfa\x98\x07\x61\xb2\xb2" + "\x4e\xaa\x73\xf0\xe4\x9e\x20\x41" + "\x9b\xb1\xd6\xf2\x59\x03\x57\xf1" + "\xaf\x7c\x57\xfc\x8c\x86\xe6\xcb" + "\xd3\x4d\xc0\x32\xdc\x4b\x6c\x18" + "\x97\xe3\xee\xcf\xae\x5f\xc3\xa6" + "\xcf\xc0\x86\xf0\x12\xb3\xa1\xb4" + "\xe2\x1f\x46\xd9\xc6\xcc\xa5\xe0" + + "\xd3\xe5\xaa\xa7\x79\x26\x4e\xd2" + "\xc4\xc1\xe5\x0d\x3d\x01\x76\x70" + "\x29\xb6\x05\xbb\xba\xf8\x50\x2d" + "\xbb\xef\x66\x6e\xe2\xab\xc1\x73" + "\xf7\x8a\x48\xf2\x22\xb4\xd4\xef" + "\x75\xa5\x3b\x66\x02\x5d\x10\xe4" + "\x57\x94\xa6\x53\x8b\x0a\xb6\x7e" + "\x3b\x97\x45\xc9\x08\x00\x21\x62" + + "\xfb\xab\x66\x4b\x86\x32\x8e\x1d" + "\x00\x09\x03\x59\xe5\x52\x6f\xd2" + "\x1a\x94\x84\x55\x43\xf6\xe3\x1e" + "\x58\x59\x9f\x56\x30\x37\x3b\x6d" + "\xa5\xdb\x89\x47\x2f\xa6\xf2\x9f" + "\xb7\xc9\xb5\x72\x15\xb8\xfc\x91" + "\x0e\x9a\x8f\x6c\x7d\xcb\x46\xf4" + "\xb5\xec\xb7\x39\xc1\x25\xf6\x48" + + "\x12\x81\x44\x30\x77\x14\x7c\x7b" + "\x56\x86\xa3\xe4\xf1\x1a\xb5\x82" + "\x10\x50\x31\x2f\x8a\x02\xf2\x2b" + "\xd4\x8c\xa8\x6e\x1f\xa0\xa4\xc9" + "\x18\x58\x7e\x25\xd8\x95\x3e\xf6" + "\x16\x9b\x51\xb4\x10\xfa\x8e\xdd" + "\xbf\x10\xa9\x0d\xe0\x73\x89\xed" + "\xa9\xe4\x0f\x5c\x77\xd0\x49\xed" + + "\x0c\x11\xa6\x6f\xa3\xf3\x6f\x51" + "\x1f\x56\x93\xfb\xb1\x1e\xfb\x74" + "\x2b\x52\x57\x84\x47\x90\x0c\x6c" + "\xc6\xbd\xb8\x6b\x04\x21\xd3\xcf" + "\x57\xad\x80\xcc\xa2\x84\x68\x2d" + "\x37\xb6\xa9\x86\x35\xfc\x27\x7c" + "\xcd\xe8\xf4\xad\xed\xba\x61\x34" + "\xf0\x42\x72\x61\x1a\x25\x56\x1d" + + "\x94\xe0\x95\xa9\xd1\x46\x99\x71" + "\xd8\x04\x1e\xe5\xf6\x48\xe8\x65" + "\x13\x31\x1e\x6a\x00\x33\x2f\xe6" + "\x03\xe5\x1d\x50\xc1\xc7\x41\x15" + "\xde\xfa\xac\xf4\xfa\xc9\xaa\x4d" + "\x71\x0b\xcd\x44\x97\x58\x58\x0e" + "\x77\xcd\x51\x0a\x69\xd8\x4f\x54" + "\x6d\x01\x31\x00\xed\x20\xfc\x60" + + "\x44\x44\xdb\x64\xaf\x12\xe7\x3f" + "\x80\xd4\xcd\xbe\x34\xd6\xe9\x19" + "\x8a\x97\x30\xa9\x47\xc0\x8b\xe0" + "\x33\x07\x28\xa1\xec\x24\xbf\x2d" + "\xb2\x06\xd7\x2c\x8c\xe3\x0a\x3c" + "\xb9\x17\x90\x35\x5b\x2a\x01\x5b" + "\xae\xf5\xe0\x72\x8c\xc3\x43\x39" + "\xa3\x6f\x17\x57\xea\x67\x61\x78" + + "\xb1\x49\xea\xab\xb7\x9f\x97\xfa" + "\xc5\xc6\xe2\x10\x7d\xd2\xb1\xb4" + "\x7a\xde\xaf\x23\xc4\xc2\x61\xbd" + "\x58\xd3\x86\x97\xf8\x14\x66\xeb" + "\x59\x74\x6f\x7f\x6b\x81\x5d\x4a" + "\x7b\x0e\x36\x09\x4f\xa4\x31\xe4" + "\x4c\x91\x09\xc3\x32\xa0\x27\x8c" + "\xd8\xe3\xed\xca\x8a\xd6\xa5\xce" + + "\x0e\xd8\x1d\x43\xa9\x11\x40\xb8" + "\xd9\x6c\x30\x73\xca\x7c\x7c\xeb" + "\x30\xb7\xb3\xd1\x29\xdd\xfa\x20" + "\xd3\xb3\x37\xfe\x5b\x8b\x85\x83" + "\x5c\x1d\x25\xb6\x93\xd1\x4c\xbf" + "\x52\xd9\x52\x13\xd3\x1f\xca\x1c" + "\x51\xc0\xfb\x90\xa4\x57\x61\xc6" + "\x36\x86\xb9\x89\x38\xa6\x90\x79" + + + "\xe1\xc0\xde\x87\x2a\x69\xaa\xe5" + "\x00\x9d\xb3\xf7\x8d\xed\x0d\x01" + "\xb5\xa0\xcf\x54\xc8\x80\x1b\x7b" + "\x28\xea\xf8\xa0\x76\xb8\xbe\x66" + "\x0e\xcd\x76\x34\x31\xf5\xd7\x50" + "\x49\x39\x8d\xb0\x65\x0e\x3d\xa6" + "\xc6\x9f\x47\x53\xa9\xee\x09\x1a" + "\x42\xe7\x99\xf4\x91\x98\xae\x82" + + "\x66\xd8\xa7\x5c\x10\xb9\x58\xab" + "\x34\x3b\xdb\x3a\xe2\x67\x29\x58" + "\xbc\xc0\xea\xcc\x47\x44\xae\x89" + "\xf5\x6a\xf5\x7b\x7c\x66\x9c\x91" + "\xd7\xdc\xf5\x60\xb1\x17\xec\x9a" + "\xbc\xad\xca\xdd\x9f\x7b\x69\xec" + "\xf5\x67\x34\x46\x41\xf3\x98\x0b" + "\x2f\x13\x67\xa9\xf7\xf1\x87\xb1" + + "\x18\xeb\x4a\x21\x1d\x7a\xfe\x90" + "\xf7\x32\x14\x74\x3c\xaf\x06\x15" + "\xc4\xa0\x91\xe5\xf9\x65\x55\xbb" + "\xc3\x1b\x4f\xb4\x77\x1a\xd4\x10" + "\x96\xde\x4b\xa8\xe4\x65\x9d\xa0" + "\x1c\x6a\x0a\xf2\xd8\x60\xf0\x42" + "\xe7\x9c\x7f\xf2\xfd\x3b\x2a\x65" + "\x9f\x73\x3d\x3b\x5c\xb6\xbd\xb6" + + "\x9f\xae\x7f\xec\xb6\xdc\x5d\xeb" + "\x5a\x6e\xb6\xef\x14\x27\x5f\x99" + "\x52\x5d\x44\x69\x8e\x5d\xe9\xde" + "\x20\x76\xe2\x09\x46\x2d\x6c\x1b" + "\x16\xd7\x29\x81\x31\x1c\x62\x32" + "\xaa\xc1\x58\x09\xf1\x09\x39\xb0" + "\x63\xaf\xf4\x1a\xf9\x8e\x46\x8c" + "\xf6\xcd\xa5\xfb\x9f\x42\x2c\x16" + + "\x71\x93\x3b\x75\x43\x23\x68\x2f" + "\xd7\x9c\x1f\x5f\x5a\xb4\xca\x29" + "\x96\xdb\x45\xb2\xab\x23\x16\x57" + "\x99\x99\xd7\x3f\x09\xdb\x07\xc5" + "\x32\x6c\x03\xaf\x52\xf6\x2e\x4e" + "\x5c\x8e\x01\x05\x78\xcc\xf0\x86" + "\x50\xe3\x8b\xab\xd4\x73\x0a\xc1" + "\x27\x63\x82\x7e\x97\xb3\x19\x65" + + "\xf7\x3d\x05\x9c\xef\x5e\xcb\xe8" + "\x6f\xea\x00\xb3\x37\x5b\xe2\x8d" + "\xfb\xcf\x49\xc8\x92\xfa\x03\xdb" + "\xbb\x69\x41\xe8\xa7\x43\x2e\x24" + "\x8e\x95\x6f\xdd\xf4\x51\xfa\xe4" + "\x8d\x5a\x44\xf4\x7f\xa7\x25\x69" + "\x49\x89\x0d\xe9\x50\x2a\xe7\xe6" + "\x90\x63\x1f\x2b\xe3\x48\x66\xc6" + + "\x0c\x46\x3e\x17\x57\x19\xab\xb2" + "\x90\x45\x70\x30\x75\xce\xbb\x1b" + "\x62\x71\x1c\xdb\xbd\x0d\xa9\xc0" + "\x5d\xd6\xcd\x15\x9e\x39\x5e\x50" + "\xb7\x7a\x79\x57\xcb\x4d\x43\x68" + "\xe8\xa8\x2c\x6a\xba\x35\xad\x60" + "\xc1\x36\x33\xde\xe0\xb1\xfd\x4b" + "\x15\x90\xb3\xd8\xeb\x99\xef\xbb" + + "\xec\xeb\x11\x17\xf3\x96\x3b\x6c" + "\xc4\xfd\x98\xce\x1f\x0f\xa4\x2d" + "\x1f\x41\xb4\x57\xd3\x74\x97\xb9" + "\xb6\x5b\xb6\x15\xf4\xbd\xc8\x87" + "\x2d\xf1\xee\xc2\xe3\x89\x3a\xda" + "\xf3\x71\x74\x3c\x9b\xbb\x95\xde" + "\x94\xc5\x12\xd8\x5b\x22\x0f\x60" + "\x6b\xa5\x75\x2b\x5d\x7c\x90\x54" + + "\x35\x0e\xb6\x8d\xf0\xc5\x3c\xa9" + "\x19\x33\x83\xfa\xd6\x3c\x3e\x74" + "\xc9\x83\x16\xf8\x41\x5c\xad\x7d" + "\x7e\x10\x34\x9c\xd9\xe7\xc1\x70" + "\x07\x09\xbe\xa6\x39\x4a\xdc\x0e" + "\xd3\xb7\xd0\x86\x35\x70\xd4\x36" + "\x60\xfa\x2b\x27\x03\xda\x76\x8c" + "\x14\xa4\x08\x0f\xea\x07\x4a\x0b" + + "\x53\xdd\xc1\x45\x29\x4d\x9e\x69" + "\xb5\xeb\x1d\x23\x98\x58\xdc\xca" + "\xe0\x00\x7f\xa7\xc7\xfc\x49\xdf" + "\x0e\x5a\x3e\xa7\xbf\x7b\x05\x93" + "\xd1\x4c\x7a\x02\xcd\x7e\x8b\x2f" + "\x1a\x01\x14\xc6\xb3\x34\x47\x11" + "\x68\x7c\x67\x67\xb7\x1d\xa0\xe7" + "\x4f\x3f\x27\x7e\x5e\xbe\xd9\x89" + + "\xef\x08\x98\x08\x2e\xcb\x25\xd2" + "\x07\x41\x9e\xd5\x7d\xa2\xf7\xf1" + "\xc9\xb9\x11\x82\x61\xc7\xaf\x53" + "\x59\x91\x81\xe6\x67\xbc\x61\x03" + "\x26\x14\x07\x7f\x0b\x5d\x86\x2a" + "\x67\x25\x07\xe7\x10\x18\x3c\x6a" + "\xbd\xca\x6b\x0d\x1e\xca\x3b\x3e" + "\xbc\x91\x85\x40\xc1\x2b\xb0\xa1" + + "\x39\xa2\xfb\x31\x59\xee\xde\xe0" + "\xd1\x91\xbd\x98\xd3\x24\x74\xf4" + "\x1d\x3c\x1a\x07\xf4\x86\x88\x0f" + "\x3b\x23\x19\xa8\xe8\x41\x7d\x3f" + "\x98\xb9\x6e\xcf\xc2\x23\x86\x70" + "\x7f\x28\x9a\x60\xaf\x49\xbb\x86" + "\x62\x07\xc9\x63\x49\xb2\x2b\x94" + "\x4b\x65\xa9\x55\xa5\xee\xf6\x0e" + + "\xfe\xde\xf5\x36\x72\x2d\x6d\x5f" + "\x76\x91\xf9\x56\xdc\x22\x99\xfa" + "\xc7\xe0\x8c\xf7\xce\x5e\x8c\x6c" + "\x5e\xb5\x09\xbe\x9d\x58\x44\x7b" + "\x70\x37\xa8\x9e\xca\x3b\x1b\xe1" + "\x47\x15\xb7\x2a\x7f\x2c\xfa\xd7" + "\xc0\xdc\x1d\x2a\xfa\xd6\x3d\x2a" + "\x07\x77\x7b\x5a\x30\xb4\xac\x09" + + "\x57\x4e\x9d\x64\x2e\x4a\xdd\x4a" + "\x6e\x52\x17\x19\xb0\xa2\x53\xcd" + "\xc4\x4a\xb4\x20\x30\x23\x26\xc5" + "\x1d\xc3\xa2\xba\x6a\x74\x28\x40" + "\x4c\x1d\x29\x64\x90\x83\x31\x51" + "\x09\xd9\x5a\xee\x51\xf1\x48\xbf" + "\x81\x56\x18\x7b\x59\x7f\xe5\xcc" + "\x42\xd4\x54\x48\xb0\xc1\x3a\x7c" + + "\x71\xc1\x93\xc0\xc3\x7d\x58\x65" + "\x65\x2b\xf4\x24\x24\xcb\x7a\xae" + "\xcb\x96\x59\x95\xdb\x8a\x33\x5a" + "\x1b\xf9\x51\x60\x75\x56\xe6\xc8" + "\xb1\xd0\xb8\x28\xba\x1f\x71\x66" + "\x90\x0a\xc1\xb6\x37\x41\xd7\x15" + "\x80\x2a\x23\x3a\xeb\xd7\xcd\x70" + "\x24\xed\x91\x61\x7f\xf0\xe2\xc9" + + "\xc0\x88\x95\xf7\xb6\x1d\x0d\xa8" + "\xcc\x68\x57\xb5\x69\xfc\x52\xfa" + "\x8a\x43\x54\x7f\xae\xf1\x4d\x0b" + "\x4f\x6a\xb4\xf9\xa7\xd1\xad\x0c" + "\x6f\xdd\x03\x18\xb3\xa6\x0e\xb4" + "\x35\xae\xea\x55\xa5\x4f\x8e\x48" + "\x16\x4e\x2e\x38\x55\x7d\x04\x9f" + "\x98\x0c\x6e\x2f\xe0\xb7\xb5\xc9" + + "\x49\x26\x76\x95\xd3\xd2\x1b\x6b" + "\xf6\xa3\xae\xc7\xe7\x4e\x60\xa9" + "\x96\xf8\xc6\x6d\x27\xff\x46\x36" + "\xd1\xba\x60\x28\xf5\xe7\xf0\x9b" + "\x92\x4b\xb4\x7c\x21\xc8\x92\x2d" + "\x82\xc1\xa9\xae\x63\xce\xf5\xa2" + "\xfd\xa5\x54\x91\xb1\xaf\xa2\xd0" + "\xa6\x1d\x80\x95\x4c\x47\x2e\x48" + + "\x4b\xc2\x11\xb6\xd0\x72\x99\xc1" + "\x51\xf3\xa8\x60\x65\x8e\x46\x1d" + "\x21\x64\xcf\x7b\x69\x80\x75\xeb" + "\x91\xc4\xfb\x88\xee\xd0\x9d\xec" + "\x32\x2e\x6c\x95\xbf\xd2\x59\x5b" + "\x4e\xf9\xdd\xdc\x64\x68\xdc\x73" + "\x65\x76\xee\xbc\x21\x23\x5e\xfd" + "\xc4\x06\x9a\x5e\xef\xf8\xb4\xa7" + + "\x55\xf8\x80\x72\xdd\x18\xa9\xfb" + "\x88\xc6\xae\x8b\x60\xc2\xaa\xbb" + "\x42\x0f\x40\x33\x0f\xf0\xb3\xa3" + "\xe4\xe6\xf2\x66\x29\xba\x2d\x3d" + "\x75\x93\x50\x98\x94\x1a\xf7\xb6" + "\xcc\x23\xa4\xce\x1f\x03\x33\x8f" + "\xfb\xe6\x07\x48\xd0\x8d\x9b\x00" + "\x4c\x95\xdb\x5c\xe5\xcf\x63\x51" + + "\xe8\xc6\x41\xcf\x17\x8f\xcc\x03" + "\x5c\x92\x7b\x03\x2a\x3c\xf0\xf1" + "\x7c\x42\xd2\x66\xcc\x19\x9c\xc3" + "\xe4\x18\x6c\x7b\xba\x24\x3d\x82" + "\x4f\x0b\x1f\x90\x13\x90\xef\x32" + "\x2e\x1c\x94\xf8\xf1\x60\x43\x68" + "\x2e\x09\x28\x2c\x52\xff\xba\x0e" + "\x2f\x93\x6c\x25\xe3\xe4\x91\x78" + + "\x3d\x5e\x44\xac\x19\x43\x26\x51" + "\x81\x43\xa7\x8e\xe7\x32\x34\x55" + "\x0a\xc5\xe9\x67\x69\xaa\xee\xe6" + "\xc7\x28\xe6\x62\x84\xd2\xce\x27" + "\x57\xfa\x4a\x7a\x75\xd3\x96\x3f" + "\x50\xc1\x84\xe4\xc3\x14\x0a\xde" + "\x23\x99\xbd\x38\xeb\x24\x4a\x36" + "\x22\x74\x17\xe5\xa0\x8d\xf1\x1d" + + "\x9b\x8a\xd3\xd8\x82\x8f\x4e\x17" + "\x91\x13\xde\xe7\x00\xc6\x97\x2e" + "\xdd\x75\xc1\xa1\x50\x98\x70\xc5" + "\x35\x50\xae\x32\xa0\x41\x90\x96" + "\x6b\x08\xa2\x76\x3b\x53\xfd\xcb" + "\xfe\xe8\xc2\xd7\x1b\xa7\xbb\xd6" + "\x67\xfb\x9d\x09\xe6\x8e\xd5\xb2" + "\xd9\x85\x4a\x06\x2d\x34\x8b\x3a" + + "\xe3\x9b\x2f\x52\x49\x76\xc0\x3b" + "\xa8\x49\x1f\xdf\x5b\x07\x0c\x69" + "\x42\xec\x54\x38\xe8\xae\xe1\x80" + "\xc7\x9d\x68\x17\x44\xbf\x7d\x2a" + "\x78\x40\xaf\x3f\x0e\xfc\x04\xc0" + "\x2c\x86\x11\xdf\x9e\x2e\xf0\xb2" + "\xb3\xb7\xa1\xa0\x0f\x5e\x0a\xf1" + "\x80\xec\x36\x89\x23\xa6\xac\x30" + + "\x9a\x0d\xf4\x02\x05\xbf\x3c\xf8" + "\x4d\x8a\x31\x2c\x68\xc4\x81\x46" + "\x74\x26\x9c\x0e\x18\x56\x57\x98" + "\x2e\x09\x47\x18\x46\xd0\x79\xbe" + "\xe0\x01\xbd\x78\x0a\x48\x1e\xaf" + "\xb9\x1d\xa5\x72\xe4\x59\xd3\x6d" + "\xb6\xba\xaf\xe3\x21\x38\xce\x62" + "\x99\x31\x73\x17\xb6\xe5\xce\xc5" + + "\xbb\x9f\xfd\x6f\xd4\x30\x8b\xe0" + "\xb7\x10\xc6\x36\x99\xc6\x5b\x6e" + "\xcf\x62\xe2\x9c\xf2\xcf\x43\xf3" + "\xc1\x14\xb9\x68\x35\x4e\x2e\xca" + "\xc5\x36\xde\x16\xc0\x64\x1d\x01" + "\x29\xb8\xe2\x42\xdd\x0f\xb1\xe0" + "\xf8\xaa\x85\x66\x81\x29\x94\x78" + "\x97\xde\x0e\x23\x08\x17\x51\xe7" + + "\xf8\x2b\x92\x3b\xfc\xd8\x1e\x67" + "\x33\xb1\x29\x4c\xa0\xc0\xd8\xe4" + "\xc4\x99\x6e\x3b\x39\x12\xeb\x87" + "\xba\xbe\x93\x87\x4c\x97\xf3\xaf" + "\x9b\xdf\x18\x2c\x05\x94\x74\x03" + "\x39\x71\x00\x91\x93\xa2\xc3\xc5" + "\x95\x0b\x7a\xe3\x4f\x23\x77\x6a" + "\x6b\xc9\x61\xb6\x21\x9a\xc2\x02" + + "\x61\xcf\x1e\x14\xd6\xf1\xaa\xc3" + "\x53\x2f\xb2\x3b\x9e\x50\x95\x91" + "\x57\x13\xd5\x22\x04\x74\x59\x29" + "\x60\xed\x7b\x53\x22\x38\x08\x1b" + "\xf0\x89\x72\xe0\x35\x6e\x7d\xcd" + "\xff\x6e\xd8\x6d\x8c\xc4\x94\x1f" + "\xfa\x9c\x0f\xeb\x82\x1f\xbb\xc8" + "\x7d\xb9\x2e\x1b\xe6\xb7\xe0\x9e" + + "\x31\x4e\xd7\x34\x2e\xfe\x52\x5a" + "\xb6\x9a\xf7\x3b\x10\xc3\x52\xa3" + "\x8f\xeb\xfe\xab\x5a\x6c\xff\x97" + "\x05\x73\xc9\xf5\xef\x8f\xbe\xbf" + "\x08\x46\x90\xa7\xe6\x1c\x08\xd6" + "\x49\xa2\xfc\xc4\x3a\x2f\x81\x1f" + "\x00\xe2\xe5\xb9\x9a\xbc\x24\x9b" + "\xe8\x2e\x01\x38\x67\x2c\x02\x91" + + "\xa1\x13\xa7\x30\x5d\x9c\x3d\xe8" + "\x93\x0f\xef\x84\xf0\xe3\x76\x48" + "\x28\xf9\xfb\xc1\x29\x70\x77\xc9" + "\xa4\xd2\xe7\xbc\xb3\x6b\x7a\xef" + "\x59\xa6\xa2\xdf\x28\x72\x06\xb8" + "\x8f\xa4\x77\xd8\x98\x33\xcd\xd5" + "\x3f\x0f\x5d\x02\x8f\xfd\xa4\xbe" + "\x2b\x7c\xae\x2e\x35\x2e\x7d\xd6" + + "\x94\x43\x5f\xcc\xd7\xe7\x4d\x18" + "\x42\xe1\x36\x45\x5c\x1b\x55\xb5" + "\x0a\xa6\x4a\xd3\x12\xb2\x89\x2e" + "\xd5\x51\x00\xf5\xea\x6f\xa9\x14" + "\x0b\xbb\x12\x0d\x74\xef\x21\x4e" + "\x7e\x67\xb9\x60\x20\xf0\x22\xc5" + "\x1d\x73\xf7\x2d\x67\xe4\x12\x8b" + "\x31\x6d\x32\x7b\x82\x03\xf8\x39" + + "\x94\x4a\x02\x39\x0c\x63\xb8\xdf" + "\x52\x94\x31\x97\xa8\x96\xcb\xaa" + "\x7c\x86\xa3\xed\x61\x39\x8a\xd6" + "\xca\xff\xc4\x77\xb0\xe2\x58\x0c" + "\xfa\x19\xa9\x4d\x63\x5d\x54\x3d" + "\x89\x22\x5e\xf1\x9a\xb6\x79\xef" + "\x10\xab\x8b\x80\x3d\x3d\xbc\x54" + "\x37\x2c\xf8\x45\x07\x30\xab\xc8" + + "\x8a\x65\x4a\x7c\xb6\x38\x27\xc1" + "\x82\x21\xe7\x40\x39\x76\xc4\xb3" + "\x4f\xe4\x98\x87\x46\xbe\x77\x3b" + "\x5f\xf8\xa7\x17\xf2\x7d\x04\xdc" + "\x2d\xd9\x59\x5e\xc5\xd4\x39\x24" + "\x8d\x4d\xe6\xe8\x75\xa4\xdc\xce" + "\x16\x9b\xca\x87\x0d\xcd\x24\xa7" + "\xfe\x0d\x54\xa5\x59\xfd\xe4\x35" + + + "\x7a\x46\x29\x3a\x4f\x34\x94\x98" + "\x6d\xba\x1e\xc5\x49\xe9\x81\xde" + "\xf2\xc2\xe5\xa5\x6b\x06\xea\xda" + "\xb3\xc7\xc8\x08\x14\xa6\xc8\x3f" + "\x9f\xde\xd0\x06\x8f\xf8\xdf\x7a" + "\x0a\xce\x75\x3b\xf5\x1c\xc1\xbb" + "\xd5\x87\xbc\xfb\xcc\x7a\xbb\x9f" + "\xe2\xfd\xad\x7b\x26\x8e\x45\xa1" + + "\x56\xc2\x39\xe0\x68\x36\xb4\x1c" + "\x5d\xfd\x17\x7c\x8b\xfb\x26\x5f" + "\x2b\x06\xaa\x79\xaf\x26\xe4\xee" + "\x04\xbf\x8f\xd7\xd0\x02\x20\x07" + "\xe3\xb7\x4f\xe8\x37\xa2\x9c\x4c" + "\x3d\x13\x82\x0c\xa1\xd8\x01\xb4" + "\x81\x41\x7e\x6d\x92\x25\xa5\xaa" + "\x52\xb1\xdb\x73\x33\x08\x43\xe9" + + "\x83\xc9\xe7\x6e\x1e\xad\x5f\x2f" + "\xf5\x28\x13\xb4\x7c\x9d\x0f\xeb" + "\xf7\xd5\x78\x1d\x44\x8b\xa6\x9b" + "\x6f\x72\xbc\x35\x9e\x3b\x6b\xa0" + "\xf1\x1f\x3e\x59\x55\x02\x55\xa2" + "\x15\xc1\xbe\xdf\x3d\xd4\x2d\x55" + "\x46\xf0\xa8\xbb\xab\xa7\x48\x2c" + "\x33\xf1\x0b\xad\xa3\x56\xfc\xd4" + + "\x9a\x31\x24\xbe\x31\xda\x2d\xf9" + "\xe7\xa8\x95\xe0\x8b\xd2\xf7\x03" + "\x85\x21\x78\x98\x40\xe8\x2f\xa5" + "\xbc\x4d\xc2\x29\xfe\xda\x6d\x27" + "\xeb\x64\x7a\x1d\x96\x54\xcd\x80" + "\x42\xbe\x1d\x7f\x89\x08\x36\xe4" + "\xd5\xd2\x38\x84\x77\xa8\x81\x2f" + "\x36\x90\x16\x85\xa8\x52\x4d\x7e" + + "\xd1\xb5\x04\xba\xef\x1c\xf2\x62" + "\x52\x73\x4c\x22\x07\x27\x44\x9a" + "\x1f\x17\xc6\x33\x6c\x96\x07\xbf" + "\xb0\x16\x08\x1e\x91\xa8\x7b\xdb" + "\xa9\x45\x37\x03\x59\xea\x6f\x30" + "\x67\x8f\xa7\xc0\xe0\xf7\xac\x2a" + "\xf9\x1b\x25\xad\x83\x38\xaa\xb5" + "\x86\x70\xbd\x26\xe9\xed\x5a\x34" + + "\x5d\x71\x59\x1d\xb1\xd5\xe3\x19" + "\x3e\x98\x88\xd7\x62\xa7\xea\xc7" + "\x48\xf2\xf1\xab\xb0\x30\xa7\xe5" + "\x83\xfd\xe3\xfa\x84\x80\xab\xfb" + "\x2f\x5b\x76\x53\x21\x0d\xe5\x65" + "\x3d\x7f\x12\xfa\x83\xe0\xd4\xbd" + "\x10\x1b\x7b\x39\x74\xc0\xf3\x9c" + "\xd3\x9f\xb5\xb1\x0c\x09\xf8\x59" + + "\x10\x9f\x11\x98\x7d\xe1\x1d\xdc" + "\xa6\x36\x8c\x48\x5d\x3c\x35\x74" + "\xdf\x23\x8e\x3d\x3a\xf3\xaa\x14" + "\x93\xf5\xba\x78\xc0\x75\xe0\x31" + "\x3c\xca\xd1\x46\x3a\xa0\x7c\x0f" + "\xc7\x60\xb6\x47\xac\xe3\xc5\x99" + "\x59\x2e\xfe\x88\x13\x24\xd0\x70" + "\x05\xc0\x7e\x2a\xe1\x6b\x9a\x2e" + + "\x8f\xaa\x5f\x61\x9d\xfd\x15\x7b" + "\xed\x54\x85\x96\x40\xeb\xa1\x8f" + "\x82\x48\xa4\x7a\x7e\x44\xb4\x7b" + "\x32\xff\x9f\x02\xd1\xd0\xb2\x2b" + "\x2f\x6d\xaa\x6c\x64\x2a\x5e\x07" + "\x1b\x35\xe7\x22\xde\x79\xb8\x8e" + "\x62\x6c\x50\x9a\x4e\x62\xd5\xbc" + "\xdc\x24\x7e\xa8\xf0\xae\x8e\x21" + + "\x6f\xbd\x1f\x24\x95\x96\x44\xac" + "\x23\x12\x1c\x08\x70\xb1\xc9\x67" + "\x6f\xac\x6a\xb5\x21\x8f\x86\x16" + "\x21\xb7\xbc\xf8\xa3\x8f\xbd\x34" + "\x76\x1c\x69\xb6\x33\xbd\xb6\x06" + "\x73\x79\x1a\x38\x66\x47\x92\x6c" + "\xdb\x78\x40\xa5\x4c\x44\x12\x6a" + "\xcc\x51\x10\x6d\xa9\x91\x2e\xd0" + + "\x35\xfa\xdd\x44\x47\x68\xe5\x37" + "\x47\xf7\xb3\xda\xc5\xc5\xcf\x9c" + "\xf4\x6c\xe9\x1e\x3f\xdf\xc1\x9a" + "\x8f\x0b\x48\x3b\xa1\x71\x05\x0c" + "\x3c\x7b\x3a\x4b\xd5\xb3\xbe\x2f" + "\x99\xbb\xcd\x5d\x69\x36\xc0\x35" + "\x3a\x5b\x41\xb2\xdc\xf5\xa0\x52" + "\x9a\xed\x13\x44\xb4\x59\x77\xd5" + + "\xf8\xd3\x33\x0b\xc0\x79\x73\x07" + "\x09\xe4\x64\x70\xc6\x83\x18\x42" + "\xf6\xc8\x29\x6c\xd7\x73\x08\x2d" + "\xc8\xc0\x74\xd2\xa3\x33\xa4\xbf" + "\x1e\x89\xa5\x23\x8f\x77\xdc\x56" + "\x04\xde\xe2\x35\x65\xbf\x63\xd6" + "\xce\x17\xb5\x5d\x48\xdb\x8f\x48" + "\xc2\x26\xb2\x19\x5e\xa5\xbb\x00" + + "\xc5\xa2\x30\x3d\xd8\x47\xe6\x1f" + "\xdc\x81\x8a\xf7\x7e\xf7\x57\x08" + "\x9b\x4a\x1a\x13\x34\xa3\xd5\x11" + "\xf5\x93\xd3\x29\xf9\x4a\xa9\xc0" + "\x1a\xec\xa6\xda\x0b\x5c\x3a\xbc" + "\xed\xd7\xd2\x88\x93\xe4\x9f\xba" + "\x97\x47\x61\xbb\xb4\x35\x43\xbb" + "\x33\x35\xf8\x72\x68\x4d\x1c\x99" + + "\xb6\x8f\x05\x8a\xe7\xee\xbb\xed" + "\x1a\x12\x09\xfb\xdc\x9d\xd1\xb9" + "\xce\xdd\x4d\xd3\x5b\xb4\x1b\xa4" + "\xc4\x4b\x96\x00\xb9\x80\xbc\x2d" + "\x54\xb6\x6c\x1d\x7d\x13\xd9\x4e" + "\xc5\x01\x3d\x48\xdb\x16\x90\x1b" + "\x2e\xe2\x28\x65\xbc\x01\xc5\x5f" + "\x6b\x64\xad\x6c\x81\xf8\xd2\xb2" + + "\xb3\x1c\xf0\xd2\x28\x8c\x25\x53" + "\xb1\xb0\x5d\xd7\xa3\xea\xd6\x93" + "\xb4\x0d\x7d\xe8\x0d\x2b\x9a\x41" + "\x93\x84\xfe\xd8\x03\x8f\xe4\xa1" + "\x3a\xb2\x08\xc5\xf6\xfa\x47\xf7" + "\x49\x35\xd5\x35\x1a\x57\x37\xf1" + "\x38\xb8\xf9\xfc\xe2\x58\x5e\x9f" + "\xf5\x3c\xfd\xa7\xee\x6c\x18\xc7" + + "\x39\xad\x6b\x28\x2f\xfb\x76\x5e" + "\xe2\xd1\xca\x9d\xe3\xef\xd9\xba" + "\x04\xe9\xc7\xed\x90\x51\xe7\x60" + "\xa5\xb5\xec\x0f\x3e\x06\x6f\x6a" + "\xc3\xac\xd8\xae\x85\xed\x50\x51" + "\x6c\xaf\x20\x6d\xbc\xcf\x6c\xb5" + "\xfa\xdb\x69\x2c\x98\x1e\x0d\x7e" + "\xa9\x10\x7e\x7c\x8a\x62\xf5\xab" + + "\xd3\xa1\x78\xe9\xce\x68\xb8\x77" + "\x04\x2d\xb9\x7a\x33\x8b\xa6\xe3" + "\x62\xb8\xa5\x87\x94\x97\x02\x51" + "\x1d\xd4\x61\x3a\xc3\x06\x06\x5f" + "\xf1\x26\x93\x6f\x27\xbe\x14\x28" + "\x2e\x3c\xfe\xc6\x14\x1c\x52\x2f" + "\x51\x73\xdf\xac\x7d\x4d\x46\x17" + "\x44\x7e\x7f\x77\xd3\xf9\xf5\x10" + + "\xab\xa2\x08\x74\x19\x64\x21\x1d" + "\x6a\x91\x28\x59\x18\xd5\x55\xae" + "\xea\x5e\x16\xf3\x4a\x68\x75\xdf" + "\x59\xef\x4e\xd8\xd5\x64\x83\x53" + "\x1a\x3b\x56\x70\x15\x20\x4e\xb5" + "\xff\xef\x4c\x6b\xa7\xbb\xd9\x74" + "\xdc\x82\x06\x7a\xd8\xcb\xbe\xfc" + "\x6c\x11\x93\xf1\x02\xa4\x00\x0e" + + "\x7d\xb3\x9f\x26\x6b\x61\x8e\xce" + "\xe5\x2d\xe6\x7d\x04\x38\xf7\xaa" + "\x53\x41\xdd\x4f\x75\x11\xa1\xab" + "\x9b\xb4\x70\x37\xba\x59\x57\x51" + "\x61\x3a\x42\xaa\xf8\xeb\x09\x8b" + "\x92\xfb\x41\xcd\xa1\x45\x22\x59" + "\x36\x89\x4c\x9b\xc1\x8e\xba\x1c" + "\x0e\x71\x36\xaf\xe3\x91\x7e\xa8" + + "\x16\xc4\x9f\x84\x85\x89\xf6\x65" + "\x3c\xa7\xba\xcd\x34\xa9\x03\x3c" + "\x47\x66\xcb\xbf\x1b\x31\x2f\x11" + "\xcd\x93\x4e\xde\x40\x13\xc1\x69" + "\x7b\x53\xdb\x66\xb9\x58\x24\xbd" + "\xe7\x07\x5b\x88\x18\xb0\x74\xf9" + "\x32\xd3\xc8\x70\xa5\x45\xb1\x5d" + "\x7b\x83\x9b\x54\xd1\xd0\xfd\x30" + + "\xe3\xa2\x34\x3d\xe4\x4c\xd8\x1f" + "\x61\x5d\x3b\xb4\xce\x59\x37\xee" + "\xc7\x86\x91\x61\x8c\xc7\x5b\x89" + "\x5a\x72\xb9\xcb\x09\x38\x9c\xf1" + "\x1f\x4b\x74\xde\xaa\x21\xbe\xc0" + "\x6b\x05\xf8\x60\xb0\x22\xd2\xa7" + "\x11\xfe\x3e\xb2\x57\x61\xbe\x74" + "\x53\x82\xd6\x0c\x4f\x2b\xab\x6f" + + "\xb4\x58\x23\x51\x73\x1d\x5c\x3e" + "\xc9\x99\xbb\x30\xb2\x42\x57\xcb" + "\x1a\x03\x2d\x3c\xa8\x2f\x2e\x4a" + "\xb8\x78\x98\xfb\x2b\xc9\x1b\x37" + "\x6c\x65\x75\x82\x9c\x1f\xa7\x1e" + "\xa1\x00\x03\x1c\xa2\x94\xf7\x14" + "\xe5\x54\xea\x26\x98\xe7\xea\x08" + "\xc6\x54\x1a\x17\xe5\x54\x58\xcf" + + "\x25\xd7\xf1\x4b\x5f\xea\x33\xad" + "\x0f\x95\x6c\x4f\xe2\x8e\x1d\x9c" + "\x06\xaf\x77\xa3\x8a\xe7\x4e\x54" + "\xe1\x13\xa1\x94\xbb\x89\xf4\x54" + "\xe8\xb7\x2f\x99\x34\xd6\x11\x8f" + "\x47\x43\xa4\xa2\xaa\xa7\x69\x01" + "\x00\x0e\x02\x95\xaf\xd4\x49\x1d" + "\x0b\x12\x8e\xe0\x22\x57\x94\x95" + + "\x86\x38\xba\xb7\xb3\xfb\x0a\x28" + "\xa8\x34\x89\x36\x3e\x3a\x80\x08" + "\xab\x71\xf6\x31\x65\xdf\x80\xf9" + "\x91\x47\x72\x1a\xea\x4a\x89\x90" + "\x50\xa3\x1d\x8d\xa9\x66\x5b\x54" + "\xa5\x53\x13\x41\xbf\xfb\xf4\x9d" + "\x8a\x08\x98\xa3\x3c\x74\x52\x15" + "\x17\x57\x2d\xb8\xde\x4c\xc1\xd1" + + "\x82\x22\xd3\xa4\x78\x38\xe3\xb6" + "\xe7\x0a\x02\x48\x9d\x02\x6e\xe3" + "\x50\xb7\xa9\x37\xfb\x47\x58\xe0" + "\x19\x38\x9e\xb2\x2c\x81\x76\xf8" + "\xf0\x17\x3a\xd2\x8e\x13\xad\x84" + "\x0e\x95\xb3\xf0\x80\x44\x7b\x6d" + "\xe0\x7a\xd6\x2f\xf4\xae\xa8\xdf" + "\xf6\x3a\x33\x52\x24\xea\x3e\x8d" + + "\x83\xec\xc5\xf5\xfd\x3a\x8d\xb2" + "\xad\x9f\x04\x91\xc1\xf6\x6a\x8d" + "\x1a\x1e\xbe\xff\xff\x64\x79\x41" + "\x0a\x79\x1c\xf5\xea\x9e\xce\xba" + "\x79\x29\x0f\xb2\x36\x22\x02\x42" + "\x01\x38\x5d\x76\x29\xb7\x05\x6b" + "\xe7\xe3\x6d\x6d\x00\xe2\x0e\xbe" + "\x3a\xaf\x01\x1e\x01\xd5\x6e\xb9" + + "\xcc\x5a\x5d\xb1\x75\x20\x05\x0d" + "\xc4\x5b\x81\xbd\x9f\xc7\xd9\xc6" + "\xf2\x6c\xa3\xdf\x88\xfd\xca\x8d" + "\x70\x90\xaa\x38\xe2\xcb\x8c\x90" + "\xce\xaf\x35\xba\xc4\x22\x87\x63" + "\x0b\xbf\x6a\xfd\xb0\xa8\x3d\x5a" + "\xc1\x35\xc3\xc9\x2c\x25\xce\x2d" + "\x9b\x79\xaa\x65\xde\xf0\xe7\x84" + + "\x62\xbc\xed\xe0\xec\x62\x87\xef" + "\xfb\x73\x27\x85\x28\x98\x44\x33" + "\x85\x38\xae\xc3\xf3\x90\x9b\x2c" + "\xb2\x56\x1e\x73\x12\x18\x19\xd8" + "\xf0\x31\x68\x73\x95\x7e\x5d\x20" + "\x5d\xc1\x41\xd6\x48\x8d\x81\xc3" + "\x7c\x15\x3e\xf4\x39\x38\xb6\xc6" + "\xf0\x51\xad\x36\x47\x04\x16\x55" + + "\xcb\x72\x9a\xb9\x22\xa5\x01\x21" + "\x16\x80\x61\x87\x67\x6e\xde\x06" + "\x3e\x65\xf3\xe6\xcd\xc7\xf8\x5f" + "\x4a\x75\xa6\xc7\xb5\x1a\x82\x0a" + "\xa2\xb5\xb0\x7c\x2b\xa5\x3f\x7e" + "\x90\x87\x04\xc9\x1c\x12\xfb\xa7" + "\x3a\x05\xce\x06\x20\x50\x72\x1a" + "\xb0\x29\xe9\x04\x1f\xa3\x90\xb4" + + "\x6e\x7e\x40\xbc\x19\x77\xbb\x70" + "\x41\xeb\x4c\xd8\xef\x28\x13\x23" + "\x20\xbb\x04\xc1\x1f\x6a\xca\x8b" + "\x71\x90\x0b\x28\x25\xe4\xf4\xd6" + "\x82\x6a\x89\x92\xa2\x95\x1b\xb4" + "\x67\xdf\x34\xfa\x35\xf4\x5c\x73" + "\x69\xd7\xd6\xd9\x08\x1a\x33\xbc" + "\x7e\x74\x82\x26\x05\x86\x97\x57" + + "\xad\x61\xdd\x62\x7d\xe4\x7b\xe1" + "\x71\x13\xe0\x6b\x1c\x96\x1a\x78" + "\xba\xcb\xe3\xda\xd3\xbf\x63\x10" + "\xba\xc9\x73\x7f\x06\x74\x64\x35" + "\x29\xa1\x36\x27\x7b\x95\x0e\xf5" + "\x56\xf2\x13\xed\x02\x37\x31\xa6" + "\xc5\xfc\x19\x3a\x65\xee\x36\x94" + "\xb6\xc8\xa4\xe7\x29\xdb\x2b\xcf" + + "\xbe\xb8\xf3\x87\x42\xf7\x8a\x69" + "\x1d\x59\xa1\xd1\x1a\x9d\x5d\x4f" + "\xe1\xac\xe4\x0f\x3c\xac\x0f\x54" + "\x7d\x4a\x89\xc6\x24\x9b\xa6\x83" + "\x46\xeb\x6f\xad\xee\x07\x5c\x93" + "\xfa\x25\xf3\x7f\x88\xbd\x2c\xe0" + "\x0b\x38\xc6\xbc\x9d\x8c\xf0\xe8" + "\xce\x45\xe0\xa6\x0f\xf4\x7f\x9c" + + "\xd8\x5c\xf9\xc5\x44\x12\x6b\xb0" + "\xf4\x95\xab\xf4\xf0\x8a\x8c\xda" + "\x6d\x83\xe5\xb9\xc2\x59\xae\x1b" + "\xfc\xff\xcf\x3a\x7e\x1e\xd5\x07" + "\xda\xbc\xcc\xc2\x6a\x5e\xe1\x01" + "\xe0\xc3\x28\x85\x3f\x92\xc1\x3b" + "\xd4\xea\x9f\xa4\x77\x45\x32\x43" + "\x11\xa7\xa7\x2a\x84\xb8\xa1\x61" + + + "\x34\x3d\xe6\xb0\x31\xee\xe7\x4f" + "\xab\x4f\xe5\xa9\x72\x05\x60\xf4" + "\xa4\xb5\xe7\xd5\x34\x33\x49\xc0" + "\x31\x48\xd5\x06\x92\xfb\x89\x85" + "\x3a\x55\x83\x65\xcc\xf5\x70\xaa" + "\xe5\x49\x56\xe2\x4a\x09\x79\x08" + "\x52\x46\x04\x10\x07\x45\x90\xcc" + "\x4f\x1c\x54\x02\x6d\x69\xb0\xeb" + + "\xa6\xe7\xde\xa2\x3e\x1a\x8c\x75" + "\x84\x22\x4b\x73\x3c\x2f\xde\xdc" + "\xad\xa6\xab\x4e\xd2\x45\xa4\xab" + "\xa7\xe0\xce\x76\x68\xf6\xaa\x35" + "\x9a\x04\xaa\xe5\xa9\x04\x0b\x7e" + "\x84\x3e\x10\x91\xad\x83\x40\xe7" + "\xc3\xec\xaf\x40\xce\x83\xb1\xbe" + "\x7a\x3f\x04\xea\x9f\xde\x89\x6b" + + "\x35\x52\x37\x99\x03\x0e\x9f\xb9" + "\x70\x79\x91\xb9\x47\xc8\x14\x76" + "\x67\xc0\x4e\x52\xe9\x3c\xc9\xfe" + "\x20\x25\x12\x9b\xf8\x7b\x0e\xe4" + "\x74\x47\x4c\xee\x31\x06\x67\xb5" + "\x4c\x91\x04\x3b\x7a\x84\x03\x6f" + "\x26\xd2\x9d\xdc\x29\x94\x6e\xc9" + "\xf8\xc1\x57\x8c\x6c\x9b\x48\x43" + + "\x66\xba\x67\xfe\x23\x9d\x29\x0e" + "\x34\x2f\xcf\x93\x60\x07\x45\x91" + "\x13\xf9\xfc\x97\xa9\x5e\x5b\xf4" + "\xda\xdd\xd7\x8b\x43\x08\xe0\x5b" + "\x4d\xf0\x3f\xd5\x05\x3e\x8c\x35" + "\xf7\x1e\xe9\x5d\xc3\xcd\x7c\xbf" + "\xa0\xc1\x9e\xb6\xbf\x4d\x68\xad" + "\x97\xd9\x1f\x80\xf2\x7c\x7e\x36" + + "\xfb\x38\x23\xcc\x27\xd2\xff\x46" + "\x53\x61\xe2\x90\xa9\x6f\xff\x89" + "\x76\x00\x1a\x33\x79\x07\x57\xbe" + "\xaf\xf3\xe1\x06\xc5\x41\xd2\x43" + "\xa3\x62\x9b\xde\x7d\xb9\xcd\xfd" + "\xea\x30\xae\xa0\x84\xe9\x06\x6a" + "\x7d\xdf\xbd\x4f\x80\x16\xbf\xc9" + "\xc4\x63\x61\xd3\xa2\x71\x04\x17" + + "\x5e\x65\x13\x31\xae\xa8\x5b\xff" + "\x80\x31\xb8\x57\x2b\x6e\x2c\xfa" + "\xbe\xea\xe0\x77\x19\x27\x48\x1c" + "\x97\xea\x7f\x33\x55\xc5\xf3\xf9" + "\xcb\x81\x25\xa4\x22\x70\x0f\x34" + "\xe3\x10\xf7\x18\xc2\x0b\xde\xe1" + "\xa8\x5a\x2e\xf6\xde\x0a\x64\xee" + "\x40\x89\x42\x49\x91\x38\xb2\x16" + + "\xc3\x0c\x95\x55\xe4\x19\x16\x36" + "\xb8\x6b\xb6\x56\x5c\x66\x1d\xc7" + "\x84\x6d\xac\xaf\x34\x4b\x03\xea" + "\xe3\xc7\xe4\xe5\x32\xf8\x87\xa9" + "\xa7\xa6\x79\x7a\x72\x27\x74\xa0" + "\x23\x6c\x6d\xe2\x17\xd0\xe5\x56" + "\x10\x7e\x16\x38\x76\xb9\x50\x7e" + "\x4e\xa8\x8a\xe8\xef\x81\x6c\xaa" + + "\x95\x85\xdc\xb0\xb7\xf3\xa1\x0c" + "\x2e\x9f\x1d\x9f\x08\x46\xde\x27" + "\xa7\x82\xdd\xba\x39\xbf\xf3\x1a" + "\x48\x24\x86\x65\x79\x6a\x35\x79" + "\x52\xa0\xf9\xf5\x45\x23\x60\xc0" + "\xf9\x42\x9a\x13\x89\x0f\x8b\x1a" + "\xfc\x40\x4d\x84\x42\xee\x3e\xb5" + "\x68\x63\x5b\x4e\xe5\xbf\xb0\x93" + + "\xbf\x5b\x32\x4d\xd7\x59\x39\x47" + "\xb9\x14\x61\x8d\xec\xbe\x61\x2a" + "\xee\xe2\x4b\x92\x94\x2a\x67\x25" + "\x0c\x3d\xc2\xf2\xdb\x95\x85\xa4" + "\x38\x18\x22\x6a\x8b\x84\x76\xe4" + "\x73\xb6\xc1\x35\x9a\xe6\x43\xe7" + "\x03\x85\x46\xd8\x99\x24\xb4\x2a" + "\xa7\x0b\xe9\xe9\x54\x00\xaa\x62" + + "\x11\x29\x48\xbc\xf1\x13\x8d\x35" + "\x26\x7f\xfa\xb7\x71\x19\x5d\x68" + "\xe4\xae\xe1\x2b\x1d\xa5\x67\x3e" + "\xa9\x14\xd1\x98\x09\x85\x41\xe0" + "\x61\x25\x05\x4e\x60\x9f\x63\x59" + "\x18\x08\x5d\x15\x49\x5c\x07\x32" + "\x1c\x4b\xb6\x67\x3b\x34\xa2\x2a" + "\x6a\x3e\xf5\x67\x29\x5e\x44\x1b" + + "\xe0\x04\xa9\x73\x17\x27\xfb\xbd" + "\x73\x8d\x88\x28\x0b\xe4\xe1\x7c" + "\x1b\x7d\xa9\xea\xf6\x35\x7e\x2e" + "\x97\xa0\xaf\xa9\x2a\x77\x61\xd0" + "\x59\x7c\x1f\x7a\xc4\xc7\x4a\x43" + "\x9a\x7b\x9b\xe7\x4a\x12\x21\x6e" + "\xc7\xec\x22\xbb\xf3\xcf\x5a\x05" + "\xd3\x58\xc8\x84\xc9\x7a\xfd\x8b" + + "\x9c\x78\x24\xc0\x02\xdd\x34\x54" + "\xfc\x7b\xb5\x41\xea\xa9\xdc\x90" + "\xdf\x98\x33\x24\xe2\x98\xa8\x8a" + "\xbb\x94\x4a\x89\x34\xc8\x07\xf6" + "\x76\x9b\xc9\xc2\x97\xbe\x07\xbb" + "\x02\x93\xc2\x18\x67\xba\x76\x65" + "\x8c\xa8\x03\xe7\xcc\xef\x79\x3d" + "\x06\xd1\xa0\xb6\xd7\xce\x59\xf2" + + "\xad\x68\x1f\x9f\xf5\x7d\xd5\x2f" + "\xc8\x70\x64\xb0\xdb\xc6\xdc\x5d" + "\x07\x73\xb4\xa9\x51\x64\x1b\x80" + "\xf4\x1b\x55\x76\xe3\xc8\x51\x6b" + "\xa9\x1d\x4e\xd4\xf7\xd1\x0b\xef" + "\x0c\x60\x4e\x4d\x1d\xcb\x4b\x71" + "\xc7\x40\x65\x0c\xe4\xb9\x7b\xc5" + "\x44\xc6\x7c\x32\xc2\x1e\xbd\x71" + + "\x0a\x4f\xd8\xcf\xb5\x33\xcd\x00" + "\xdd\x0d\x6b\x4e\xf7\x68\xa5\xcf" + "\xf4\x48\x0f\x2d\xdb\x4e\x69\x1c" + "\xd8\x7d\xff\xfe\xcc\xc7\x47\x27" + "\xb2\x24\x8c\xac\xad\xec\xda\xce" + "\xe5\xa5\x42\x07\x3f\xde\x29\xdb" + "\x6d\x29\x90\x30\xbb\x8f\x5d\xe3" + "\x4a\xb5\x1f\xb1\xf7\xab\x8c\x78" + + "\x1f\xd8\x4d\x7f\x7e\xcf\x52\x9a" + "\x5e\xc0\x69\x5e\xe1\x2b\x13\xa0" + "\x72\x4d\x0f\x2a\x47\xb7\xda\x90" + "\x06\x67\x2d\x31\x11\xf9\x42\xc1" + "\x8b\x99\x61\x82\x1f\x63\xd3\xe8" + "\x94\x1c\x5c\x61\xae\x2f\xf4\xf0" + "\x5d\xfa\xc3\xae\x8c\x94\x4e\x2f" + "\x1e\x10\x74\xa3\xa8\xe7\x2a\x24" + + "\x0b\x61\xde\xc8\x5d\x3a\x89\x0f" + "\xce\x23\xe2\x67\xfb\x15\xc5\xe8" + "\xc5\x6d\xad\x4e\xa6\xbf\x74\x77" + "\x8f\x72\x5c\x92\x95\x0f\xd2\x89" + "\xce\x83\x85\x09\x66\x09\x1e\x7a" + "\xd7\xa7\xf2\x93\x94\xdb\xee\xa2" + "\x4a\x4d\x30\x4c\x97\x20\x28\x1b" + "\x2d\x28\x77\xc0\xda\xe3\x42\x08" + + "\x52\xbe\x88\xd0\xca\x78\xa8\x1f" + "\x56\xe6\xe1\xa9\x07\xcb\xc2\x89" + "\xdb\x62\x9d\x21\xc3\xc5\x5b\x38" + "\x52\x27\xda\x5f\x6b\x67\x2b\xd8" + "\xfc\xea\x04\xe3\x9e\xdc\x49\x24" + "\xa2\x4e\x2f\x63\x91\x79\x9e\x1e" + "\xb9\xe0\xd5\xcd\x61\xe0\x36\x30" + "\xbc\x25\x08\x83\xff\xf6\xa6\x75" + + "\x9b\x5e\xf6\x81\x04\x26\x5b\x2e" + "\x37\xf8\x01\x49\xc0\x56\x01\x48" + "\x33\xb7\x57\xb8\xab\x86\x7f\x55" + "\x11\x44\x5b\x73\x0e\xed\xe3\x88" + "\x2e\x73\x33\x2a\x0d\x68\x37\xc3" + "\x1f\xc1\xc9\x31\xcb\xbf\x99\xa5" + "\xc4\x01\x52\xa9\x51\xf8\x82\xb2" + "\x95\xdf\x4d\x85\x8a\xda\x42\xd3" + + "\xb4\xed\x9d\x44\xdc\xcd\x0f\xb1" + "\xcf\x4a\x24\xd1\x42\x00\x89\x2c" + "\x17\x70\xfc\xc7\xca\x72\x30\x9b" + "\x3f\x06\xe8\x9c\x85\xa6\xcd\x1a" + "\xf5\xe2\x51\x7f\x3c\x31\x43\xd2" + "\x78\x95\x3d\xd7\xa4\xf1\xa3\x52" + "\x6e\xce\xf0\x64\x7a\x5b\x78\xda" + "\x2d\x4c\x2a\x44\x15\x63\x76\x2e" + + "\x7b\x2d\x9e\x3b\xa3\x72\xd9\xe4" + "\xff\x18\x82\xc4\x27\x0b\xc6\x7c" + "\x91\x9d\x14\x84\x38\x08\xc7\x8f" + "\xcc\x1e\x46\x2f\x6f\x34\x04\x5c" + "\xa9\x50\x46\x61\xf2\xfd\xe9\xeb" + "\xac\x66\xf6\xc1\x37\xb5\x35\x5e" + "\x83\xbc\xba\x88\xd1\x13\x56\x64" + "\x3e\xc9\xe1\xc5\x3a\xce\xca\x88" + + "\x1a\x11\x1f\x15\x04\xb0\xf9\x94" + "\xfa\xc5\xdb\x07\x5b\x03\xa5\xc7" + "\xd7\x49\x9e\x60\xa7\x8e\x95\x53" + "\xc0\xf4\x13\x90\xd7\xb4\x26\x05" + "\xbd\x2f\x3e\x59\xbb\x5e\xde\x66" + "\x37\x0c\x2e\x4c\xb4\xf8\x7c\x6e" + "\x78\x3e\x98\x8c\x8b\xfc\x72\x6f" + "\xd7\xf9\x48\x23\x63\x9b\xab\x6f" + + "\x59\xac\x70\xeb\x81\x2e\xd0\x58" + "\xf7\xd8\x17\x44\x9b\x76\x22\xf5" + "\xff\x74\x72\x07\xd5\x63\x30\x9f" + "\xac\xe8\x0f\x34\x4f\x6f\xac\xf5" + "\xba\x14\x09\xb5\xd1\xd9\x72\xce" + "\x5c\x25\xbc\xb7\x84\x59\x83\xb3" + "\x8f\x03\xa5\x7c\xa7\x3f\x5d\x14" + "\x13\xab\x8f\xad\xc6\xa3\xcd\x7a" + + "\x68\x84\x3d\x6a\x52\xa3\x48\xc7" + "\x32\x80\xe3\x27\x99\x47\xab\x3f" + "\xe7\x0c\x43\xfa\x29\x36\xad\x91" + "\x44\x4c\x61\x71\x2c\x0b\xaf\xc5" + "\x11\x16\x21\x0c\xa5\x3f\xde\xce" + "\x83\x80\x33\x02\xba\x89\x68\x6e" + "\x32\xfe\xf0\x77\x59\x19\x0a\xee" + "\x5a\xbc\x4b\x0f\x5d\x90\xea\x01" + + "\x23\x2e\xe9\x3d\x75\xa3\x9c\x20" + "\xe3\xb6\xbb\x5f\xc8\x3c\xb0\xcc" + "\x7e\x48\xb1\xd7\x03\x0f\xb9\xcc" + "\x1f\x94\x10\xc7\x38\x2a\x9c\xfa" + "\xed\xce\x24\x67\x23\x38\x6c\x75" + "\x23\x03\x2d\x19\x58\x22\x90\x3a" + "\x8e\x03\x5e\xea\x19\xe5\x50\xb1" + "\x91\x75\x42\xc7\x65\x28\xba\xdc" + + "\x48\xdb\x93\x81\x5e\xb2\xcf\x12" + "\x8c\x70\xea\x3b\x63\xae\xb4\xdd" + "\x21\xf8\x81\xf1\x2e\x10\xae\xda" + "\xd9\x89\xa0\x24\x30\x92\x9d\x9d" + "\xea\x6a\x87\xa0\x2d\x12\xc4\x71" + "\x09\x9c\xe1\xbb\x3b\xea\x63\x1a" + "\x0c\x8d\x6f\x01\x76\x80\x89\x3b" + "\x13\xb7\xa6\xae\x5d\xcc\xcc\xa5" + + "\x7d\xe9\xf6\x06\xe3\x8e\x0e\x51" + "\x8c\xaa\x0e\xb0\xc5\x8f\x4a\x68" + "\x33\xbf\x3f\xb9\x79\x35\x31\x15" + "\x23\x17\x6b\xf6\xa6\x5f\x7f\xe6" + "\x8c\x74\x86\xce\xf6\x81\x58\x81" + "\x10\x8b\xd5\xea\x18\xd3\xce\xc1" + "\x93\x33\xf3\xf2\x5b\x77\x62\x86" + "\xf2\x6f\x83\x7d\x04\xc9\xc0\x7a" + + "\x61\x2f\x8e\x4a\xaf\x2b\xf2\xc3" + "\xa6\xa6\x6d\x17\xde\x9e\xd2\x77" + "\x63\xda\x07\x16\x21\x5f\xa5\x40" + "\x91\xe3\x52\x14\x56\x38\x8b\x85" + "\x56\x3c\x1b\xfe\x67\xc2\xd3\x0d" + "\x7a\x22\x55\x7d\xdd\x4b\xc0\x66" + "\x09\x4e\x40\xe6\x55\xfe\xd2\xfb" + "\xbc\xfc\x9c\xea\x49\xcf\x81\x59" + + "\x32\x07\x89\x78\x7f\x23\x49\xe5" + "\xd9\xb4\xfc\x53\xf9\xbe\x43\xc4" + "\xd6\x80\x34\xeb\xa6\xd8\x84\x98" + "\x86\xb1\x48\x30\xa1\xb6\x35\x8a" + "\x0a\xa9\xe9\x65\x16\x47\xe4\xb4" + "\xc0\x06\x30\x65\x0d\x38\xbf\x45" + "\x3b\xae\xe9\x4f\x0d\x82\x3f\x8f" + "\x71\x3b\x9a\x97\xa0\x35\x4a\x24" + + "\xaf\x70\xa8\xae\x02\xa9\x46\xae" + "\x99\xdc\xbe\x7c\xf5\xfc\xb9\xa9" + "\x93\xe7\xb7\x79\x3f\xca\xf2\x74" + "\x28\xeb\xbe\x1d\x23\xf2\xb8\xad" + "\x85\xdf\x64\x67\x0e\x06\x02\x63" + "\x54\xd5\xeb\x57\xd2\x20\x33\x36" + "\xe1\x22\x8d\x79\x3e\x57\xfd\xd9" + "\xed\x7d\xb6\xeb\xf5\x85\x5f\x28" + + "\xc9\x55\xeb\x8a\x13\xd6\xac\x0a" + "\xf0\x85\x68\xd8\xa4\x1d\x79\x79" + "\x23\x5f\xb0\x44\x67\x82\x5e\x16" + "\xed\x48\x45\x28\xe8\xf5\xe5\x9e" + "\xb8\x61\xb6\x85\xcc\x48\xd5\x9f" + "\x89\x86\xc5\x89\xc0\x37\x70\x25" + "\xb2\x0c\x29\xf9\x6f\x30\x47\x9b" + "\xf4\xec\x77\x06\xeb\x2e\xba\x56" + + "\xb5\xa2\xca\x11\x92\x32\x6b\xd8" + "\xd1\x7b\x33\x39\x8e\x25\x26\x2a" + "\x91\xc2\xc8\x79\xb5\xa9\xc5\x4d" + "\xe6\x42\x19\x74\x87\x3d\x44\x16" + "\x0c\x40\x11\xf8\xf8\xa2\xc9\x6b" + "\x0e\x4e\xeb\x9e\x35\x69\x9c\x81" + "\x4b\x21\x0c\xce\x73\x72\xbe\xe1" + "\x81\x15\xb6\x84\x81\xfb\x9a\x42" + + "\xff\x06\xcd\x74\x9d\x0e\x01\xa1" + "\xac\xee\xa3\xac\xdf\xc7\x17\x9c" + "\x2b\xaa\x63\x80\xd3\x6c\xc8\x74" + "\xff\x14\x46\x73\xb3\xc4\x95\x85" + "\xcc\x62\x0f\x99\xca\x00\xde\xa3" + "\xe5\x3b\x0c\xca\x13\xd2\xbe\xd9" + "\xf5\xe9\x8c\xdf\x8a\x07\x86\x78" + "\x44\x44\xd4\x5c\xe3\x7c\xb2\xdd" + + + "\x82\x83\xee\x26\x1d\x58\x7c\x9c" + "\x8e\x63\x9d\x35\xc5\xdc\x17\xcf" + "\x3d\xae\x28\xb7\xab\x73\x82\xee" + "\x47\xf0\x21\xf8\x26\x29\x11\x1d" + "\x74\x1a\x49\x50\x77\x84\x49\x11" + "\xb9\xdf\xe0\xfd\x61\xa7\x7f\x68" + "\xab\x35\xa4\x7e\x22\x80\x25\x2c" + "\x3f\x7e\xce\x91\x94\xdb\x8b\x6b" + + "\x56\x2b\xfb\x53\xa5\x03\x3a\xb2" + "\x78\x7f\x05\x4e\xe7\x41\xe1\x6c" + "\xd9\x90\xe4\x89\xc3\x25\x65\x79" + "\x75\x7e\x1a\xa3\x25\x57\xc9\x0b" + "\x06\xfd\x20\x12\x91\x67\xc5\x1e" + "\xd6\x0b\x8b\x40\x3c\x3a\x6e\x71" + "\xa9\xeb\xeb\xe8\xf7\x6b\xcd\x31" + "\x70\xb6\xe6\xbe\xa6\x6c\x32\xa7" + + "\xd7\x41\xf2\x99\x56\x35\x95\x60" + "\x9d\x34\x1a\x00\xd7\xdb\x4a\xee" + "\x91\xe4\x89\xaa\x6a\xbf\x35\x0b" + "\x46\x75\x6f\x13\xf4\x76\x00\x7f" + "\x3d\xda\x64\x92\xba\x18\x9a\xd1" + "\x8b\xa2\xa7\x62\xcd\xd2\xb2\x6e" + "\x71\xc9\x61\x87\x1f\x94\xba\xcd" + "\x5d\x4a\xbe\xa3\x8b\x51\x50\x15" + + "\xd2\x62\x7d\xcf\x82\xc9\xd3\x20" + "\x50\x81\xba\x23\x9d\xe2\x36\x1f" + "\x9e\x3f\x76\x92\xf0\x0b\xae\x48" + "\x07\x70\x3a\x1d\x6b\x7e\x52\x7a" + "\xe3\x85\x1a\x58\x97\x90\xa8\xb4" + "\xe5\x8b\x15\xdc\x0f\x52\x1a\x1f" + "\x6e\x72\x7d\x16\x7d\xb3\x8d\xf9" + "\x62\xe8\x13\x11\x6e\x78\x02\x88" + + "\x18\xfc\xce\x6b\x96\x98\xc3\xc3" + "\x00\x6e\x63\x18\x43\xb3\x54\xb7" + "\x91\x19\x3b\xf5\x68\xa1\xb6\x6f" + "\xe5\x2f\x4c\xb8\x55\x1b\x18\x87" + "\x8c\xbc\x21\x27\x10\xc9\x86\x16" + "\x2a\x0e\x03\x95\x60\x06\x49\xc6" + "\xda\x55\xdf\x97\x2f\xeb\xfd\x18" + "\x31\xd2\x27\x7c\xfc\x2c\xd5\x10" + + "\xb9\x31\x87\x11\x9c\xe0\x01\x2a" + "\xd8\x3c\x39\xcd\x82\x61\xc4\xb6" + "\x28\xe3\x08\x75\x65\xdd\xd7\x5e" + "\xfa\xa8\x1d\x68\x1b\xca\x02\x64" + "\x2d\x27\x9f\xce\x86\xbe\x3a\x60" + "\x9c\x7c\x16\x29\x5c\x43\x63\x93" + "\x42\x2a\x5a\xc4\xc1\xf7\x14\x48" + "\xcd\xca\x22\x9a\x22\x62\x65\x14" + + "\x0c\x47\x3b\x32\x31\x64\x52\xb4" + "\x18\xe4\x36\xd5\x1a\x4e\xcd\x40" + "\xc0\x3b\x93\x01\x3d\xdd\x0f\x43" + "\x23\x90\x64\x07\xde\x6d\x3e\x3d" + "\xb1\x23\x95\x2e\xef\x64\x05\x4b" + "\x4f\xbc\x79\x90\x05\x31\x0d\x8c" + "\x58\x3d\x7d\x83\x67\x69\x6c\x49" + "\x5f\x3b\x12\x89\x60\xf6\x79\x3a" + + "\xb0\x9a\xf0\x36\x9e\x14\xb2\xef" + "\x5b\xbb\x10\x4a\xca\x63\xf1\x03" + "\x98\x09\xe2\x06\x45\x70\x29\xd0" + "\xab\x3b\x5a\x1b\x00\xaf\xf0\x56" + "\x0d\x0e\x88\x70\xec\xcf\xf4\x7a" + "\x3f\x91\x3d\xbe\x6f\xa6\x32\x73" + "\xbd\xb4\xce\x7e\x4a\xc8\xe6\x32" + "\x55\x8f\x22\x9c\x9a\xa7\xc4\xed" + + "\x9a\x69\x2f\xa3\x9e\x14\x99\x29" + "\x70\x61\x18\x72\x11\x8e\x6c\x6d" + "\x52\x6e\x54\x45\x4f\x49\x74\xad" + "\xfe\xe7\xef\x89\x39\xb5\x3c\x2b" + "\x31\xb0\x2f\xe4\x0e\xe6\xa2\xb9" + "\x23\x48\x0e\x67\x0d\xfd\x58\xf8" + "\x6d\x63\x2c\x49\x7e\xab\xca\xeb" + "\x70\x46\x2c\xd3\xfc\x72\xe0\x40" + + "\x1d\x4e\x34\xb2\x66\x6a\x7a\x45" + "\xfe\xdc\x37\x8f\x2a\x1f\xc8\xde" + "\xd5\xf9\x40\xab\x3e\xf8\xd5\x61" + "\x3c\x04\xdf\xf1\x76\x27\xa8\x5c" + "\x7c\x67\x46\xf8\x1e\x68\x74\x21" + "\x28\x16\x6d\x51\x4f\x1f\x24\x7c" + "\x4f\x37\x01\x1f\xc3\x94\x49\xf5" + "\x0c\x21\x0f\xdf\x67\x83\x3c\x25" + + "\x20\x18\xe9\x20\xeb\xbe\x4d\xc9" + "\xe7\x41\xb6\x62\x04\xc2\xaa\x19" + "\x50\xcf\x49\x8b\xf0\x34\x28\xc2" + "\x6d\x5a\x5d\x8e\x4b\xc7\xe8\x47" + "\x6a\xcb\x2a\xf4\xdc\x0c\x16\x78" + "\xb9\x68\x35\x3a\x75\x64\x53\x7a" + "\x71\xeb\xd1\x6c\x47\xd5\x28\x4a" + "\x11\xbc\x8f\x8c\x3f\xbc\x60\x03" + + "\xec\xb6\xc6\xf4\xd1\x94\xe8\xf6" + "\x9b\xcd\xb3\x18\x27\x08\x6b\x52" + "\xbf\x7f\x11\x12\xa8\x52\xf9\x73" + "\xf5\x5b\x94\x11\xb0\x64\xe8\x2b" + "\x64\x9b\x09\x42\xa5\x8e\xf1\x86" + "\xe2\x8c\x54\x07\x8a\xb2\x70\x27" + "\x9c\x1c\x5c\x29\x28\x0f\x39\x97" + "\xc3\x06\x52\xcb\x43\x6a\x2e\x67" + + "\xf8\xda\xba\x8e\x73\x2b\x50\x66" + "\x07\x4c\xa0\xf9\x8e\xfe\xba\x27" + "\x04\xae\xf6\x1b\x2f\x43\xda\x74" + "\x3b\x40\x8d\x27\x68\x82\x1d\x27" + "\x57\x1b\x47\x93\xac\x91\x8b\x01" + "\x1f\xc5\x76\xb2\x69\x68\x09\x01" + "\xd2\x7d\xc5\x6d\x01\xc1\x79\x5b" + "\xa5\x80\x6c\x80\x5e\x34\x23\xb6" + + "\x88\x20\xd7\xe9\x49\x43\xd2\x89" + "\xe0\xf6\x9c\x3e\x03\x7a\x31\xd5" + "\xea\xf8\xc8\x73\x9d\x1a\xc6\x5b" + "\x3d\x5a\x0f\xf1\xc8\xc2\xf9\x48" + "\x07\x95\x6b\x08\xdf\x14\x24\x47" + "\x92\x9b\x54\xae\xdf\x8c\x81\x79" + "\xbf\x15\xa4\x62\x7a\xa7\x24\x3d" + "\x76\x29\xb2\xd3\x9f\xf5\x2d\xb9" + + "\x44\xcf\x1f\xe7\x8e\x0f\x45\x80" + "\x86\x99\x0a\xdb\xfd\xdd\x63\x27" + "\xf2\xbc\x68\x96\x7a\x8c\x28\x8c" + "\xf6\xe2\x92\x03\x35\x9b\xd0\xd7" + "\x7a\xdd\x06\x65\x82\x54\x3d\x0a" + "\x4f\x9d\xce\xcd\xc1\xda\x43\x9b" + "\xb8\x63\x8b\x45\x61\x4f\x15\x8d" + "\x3b\x97\x9c\x12\xd0\xa4\xbd\x77" + + "\x96\x44\x5c\xc5\xd0\x7d\x7c\xc3" + "\xd2\xab\xbb\x25\x57\x63\xa9\xa6" + "\x63\xf3\xd7\xad\xf2\x63\x7e\x5b" + "\xdf\xf1\x73\x2e\x82\x37\xce\x9d" + "\x71\x1f\xb9\xb2\x6a\xa1\xe5\xe1" + "\x3c\x16\xa0\x5b\x23\x98\x48\xe4" + "\xad\x15\xe5\xf6\x32\x9c\x75\xf2" + "\xcf\xee\x15\x86\xf8\xf1\xe2\xa5" + + "\xce\xab\xa6\xeb\x19\x0d\x6c\x0b" + "\xe4\xee\x9e\x64\x45\xc4\xaa\x6c" + "\x0e\xe1\x65\xb4\x83\xf2\xb4\x59" + "\x2d\x21\x29\xf7\xf2\x04\x67\xd7" + "\x92\xee\xd1\x70\x83\x73\x4e\x8d" + "\xb5\x1e\x6c\xea\x8b\xc2\xca\xfb" + "\x05\x8e\xf2\x4e\x8b\x21\x84\x2c" + "\x0d\x6e\x6c\x7e\xd0\xf7\x52\x2c" + + "\x16\x96\xe0\x0f\xf0\x4c\x13\xd8" + "\xc3\x8c\x8c\xe4\x9a\xe5\x31\x4a" + "\x82\x7b\xb8\x5f\x66\xe5\x0a\x5c" + "\xa7\x26\xbd\xb2\x5a\xf1\x2e\xdc" + "\x65\x17\x78\x5b\xf5\xae\xeb\x63" + "\x5e\x58\x39\x53\x3c\xc8\x6c\x4f" + "\xe4\x78\xfc\xab\x01\xe2\x8a\xd0" + "\x56\x2a\xbe\x1f\x9a\xee\xe7\x98" + + "\xa2\x89\x14\x0e\xdd\x97\x48\x0a" + "\x7f\x98\x3d\xe9\x36\x87\x9f\xc0" + "\x37\xa4\x79\xea\xb8\x00\x7a\x42" + "\xfa\xe9\x89\xaf\xe4\x39\x2b\x3e" + "\xf1\x38\x81\x7e\x2f\x2d\x1c\x45" + "\xb0\x8b\x14\x37\x11\xe4\xcd\x08" + "\x41\xe5\x50\x0d\xc7\x68\x69\x01" + "\x91\x12\x47\xdd\xe1\xee\xdc\x2b" + + "\x67\x43\xc6\x47\xc8\xe2\xcc\xca" + "\xc0\x4e\xaf\x45\x9f\x6b\x49\x6a" + "\x2c\x04\x34\x60\xf3\x36\x08\x2a" + "\xea\x62\x6c\x0b\x90\xf3\xa1\x14" + "\x40\xf5\xf1\x3e\x63\x93\xfa\xe7" + "\x93\x6d\xa7\x72\x0a\xb3\x23\xd3" + "\x51\xe4\xea\x0f\xb5\xc8\xee\xff" + "\x87\xef\x04\xbd\x72\xc1\xaf\x4e" + + "\x07\x40\x48\x6c\x1b\x1e\xdb\x3b" + "\x02\x02\xbe\xe6\xa1\xd5\x10\xe1" + "\xae\x5a\x66\x15\xae\xe1\x24\x1c" + "\x27\x9d\x9c\x7c\x89\xf6\x0e\xfa" + "\x07\xb6\x22\x9d\x2a\x66\xa0\x01" + "\x47\xf1\x22\x67\xce\x64\xc3\x18" + "\x4c\xf7\x21\x75\x6d\x14\x46\x04" + "\xb8\xab\xa8\x9f\x4e\x7a\x77\x39" + + "\x27\xe4\xea\x8d\x0c\xb3\xa7\x36" + "\x3e\x58\x2e\xb6\x5a\x5f\xac\xb4" + "\xa9\x39\x0a\xdf\xa2\x9f\xef\xac" + "\x39\x90\x65\x5d\x04\xa6\x29\xc9" + "\x7e\x2f\x26\xfc\x6e\x9d\x4d\xe1" + "\x9d\x8d\x53\x05\x2d\xd6\xe6\x15" + "\xe0\xf9\x88\xc4\x7e\xa7\x42\xee" + "\x42\x8a\x2c\x89\x65\x63\x83\xae" + + "\xfd\x33\xf5\x1a\x1b\xdd\xab\x90" + "\xcb\x0a\x0f\x75\x76\x25\x3d\x7c" + "\xc8\xc9\x6c\xc7\x5a\xc5\x0a\xfa" + "\x05\xaa\x75\x52\x2e\x30\xb4\xc3" + "\x9e\xc1\x2d\xef\x1d\xb3\xcb\xe2" + "\x7b\x35\x06\x38\x51\xb7\x3d\x5f" + "\x8e\xf9\x09\xf5\x00\xdf\x74\x64" + "\x89\xbd\xeb\x28\x1e\x5f\xa7\x9b" + + "\x51\xd5\xde\xab\xe7\x9b\x51\x74" + "\x10\x44\xb7\xc8\xb8\x58\xd3\x03" + "\xa9\xd9\x10\x0e\x0b\xb1\x00\x4d" + "\xb7\x52\xda\x28\xb1\xb0\x92\x63" + "\x04\xc9\x75\x0b\x98\xa2\x44\x67" + "\x6c\xf9\xf7\xa8\xae\xb0\x05\xc3" + "\x32\xf9\x2c\x18\x1d\x42\x2e\x04" + "\xca\x36\x46\x9e\x50\x5d\xfc\xf6" + + "\xdf\x76\xd6\x5f\xe0\x1f\xcb\x47" + "\x0b\x96\xa8\x9b\x91\x42\xc6\x69" + "\x6d\xde\x65\x01\x06\x23\xd0\x40" + "\x9a\xb2\xb8\xd6\x4e\xf4\x3b\x78" + "\xbd\x98\xd0\x6e\xfb\x19\x4e\xc8" + "\x23\x61\xbe\xff\xf7\x09\x1f\x60" + "\x3a\x4a\xe2\xa0\xc5\x89\xae\x87" + "\x2a\xac\x05\x5e\x9c\x4e\x86\x07" + + "\x00\x5e\x2c\x39\xfd\x9e\x0f\x85" + "\xde\x1b\x51\xe2\x7f\x66\x9f\xc2" + "\x8f\x29\x31\x84\x6d\x40\xcf\xf5" + "\x5d\xd0\xc0\x79\xc8\x10\x0b\xf9" + "\x12\xf0\x38\x00\x1d\x9b\x3e\xfb" + "\x99\x97\x8c\x0a\x7a\x4e\xc0\x84" + "\x86\xe9\xc8\x96\xd4\x02\x61\xb7" + "\x75\xa6\x6d\x17\x13\x3b\xa6\xde" + + "\x69\x53\xf5\xdd\xef\xc2\xaf\x2f" + "\xb9\x63\xac\x24\x6f\xf0\xbf\x70" + "\xdd\x6a\x92\x6e\x42\x37\x1a\x1e" + "\xcf\x18\xfa\xfd\xad\x37\x35\x77" + "\x52\xb5\x84\x59\x63\xea\x11\xd2" + "\x24\xed\x1a\x8c\x4d\xed\x7e\xb1" + "\x67\x8b\x0b\x14\x74\xde\xe9\x5d" + "\x57\xff\x8b\x76\xc8\x01\x25\x74" + + "\x89\x9b\xe5\xb3\x51\x5a\x43\xe4" + "\xc9\xa1\x33\x41\x55\x39\x61\x13" + "\x59\xee\x0b\x44\x73\x69\xf4\x87" + "\xe4\x01\xc4\x00\xf8\x10\x47\x71" + "\xc9\x46\xc4\xd6\xce\x4b\xcf\xc0" + "\x68\x53\x4d\x6c\xd6\x7f\xaa\xe0" + "\x37\xfc\x68\xfc\x1a\x81\x5d\xde" + "\x57\xa0\xc2\xb7\x72\xbd\xfe\x61" + + "\xe8\x25\x47\xbe\x91\x2b\xff\x90" + "\x1e\x00\x81\x5e\xf6\xbf\x0a\x71" + "\xf3\x04\xef\xc5\x76\x34\xeb\x15" + "\xb7\xa2\x0d\x3c\x1b\xb5\xda\xcc" + "\x2b\x65\xc0\x2c\xa5\x40\x38\x88" + "\x56\xa8\xe4\xf5\x9d\x7d\xfc\xd1" + "\x88\xfc\x0f\x07\x53\x39\xbc\xeb" + "\xc1\xed\xef\x91\x7d\x94\x0f\x34" + + "\xcf\x11\xbd\x6d\xbb\xbe\xdd\x1e" + "\x03\xe2\x19\xc6\x45\xaa\x97\x82" + "\xa6\xd2\x2b\x96\x6f\x82\x54\x63" + "\xc7\xed\x12\xfa\x67\x3f\x3f\xba" + "\x8d\xd8\x7a\xfc\x1d\x0f\x22\x25" + "\x01\xc8\x83\x86\x81\x9f\x05\x5d" + "\x64\x57\x38\x2d\x6e\xf2\x77\x05" + "\x0d\xe8\x53\xa4\x46\xc6\x74\xa5" + + "\x0c\xe3\xf4\xb8\x71\x6c\xd1\x89" + "\x29\xfa\x3d\xc6\xfb\xab\x2d\x9e" + "\xeb\x5c\xde\xdf\x5e\x06\x33\x60" + "\xc6\x45\x3c\x0f\x1f\x1d\x2b\x07" + "\xec\x29\xd4\xb8\x2a\xbc\xd0\x0c" + "\x89\x1f\x47\xc2\x8c\x43\x47\xe7" + "\x9e\x67\x9d\x31\x56\xe8\x1c\x13" + "\xba\x4e\xb2\x87\x28\xa2\x20\x75" + + "\x8c\xc7\x4c\xd6\xc9\x47\x58\x79" + "\x7b\xb2\x6c\x9b\x1b\x62\x50\x6c" + "\xab\x22\x80\xdf\xf8\x9b\x09\x07" + "\x1d\xda\x4e\xc0\xeb\x62\xf8\x48" + "\x16\x3c\x60\xe1\xed\x32\x27\xd1" + "\x50\x94\x9a\x5c\x0f\x0e\xa8\x19" + "\xfc\xb4\x29\xb4\x54\x7f\x25\xe2" + "\x15\x05\x46\x45\xc6\xb2\xd3\x66" + + + "\xd6\xad\x3c\x45\xbc\xb7\xe2\x8d" + "\xf8\xc1\x0b\xbc\xa7\x00\x39\x20" + "\xaf\xd3\xab\xa6\x47\x6e\xd8\xbc" + "\xfb\xef\x02\x85\x12\xac\x1c\x91" + "\x69\x54\x96\xec\x42\x02\x55\x2d" + "\x7e\x01\xe0\x29\x92\x76\x9f\x0e" + "\x85\x98\x97\x65\x8f\x07\x3f\x63" + "\xef\x51\xf7\x4c\x49\xd4\x87\xfb" + + "\x10\xee\x51\xd5\xa2\xe2\x66\x60" + "\xa6\x09\x7e\x72\xd8\xf1\xa8\x87" + "\x8d\x14\x01\x2c\xab\x8b\xd0\x00" + "\xfe\x33\x4f\x42\xf1\xe4\xa8\x6d" + "\x71\x4e\x9a\xcf\xf0\x17\x6d\x46" + "\x19\xcb\xf5\x3b\x10\x20\x50\xff" + "\xc0\xec\x62\xd0\xd8\x97\xcf\xdc" + "\xc4\x0a\xd8\x81\xaf\xd9\xc0\x80" + + "\xab\xad\x7a\x1d\xff\x45\x04\x1a" + "\x7c\xa6\xf6\xd5\x60\x82\xd3\x65" + "\x6f\xb2\xcf\x91\x08\xfb\x62\x6e" + "\xd6\x91\x7d\x5c\xa5\x0f\x1e\xef" + "\xcd\x72\xdb\x33\xba\xc7\xe7\x47" + "\xb2\x74\x7c\xfa\x09\xbc\x7c\x01" + "\x3c\x50\x0a\xf5\x90\x15\x93\x3c" + "\x42\xaa\x6b\x61\x60\x4f\xc5\xca" + + "\x1c\x58\xf4\x1b\xeb\x7c\x85\x98" + "\x66\xb1\xa7\xac\x86\xe1\x35\xe6" + "\xac\x22\x97\x65\x22\xdd\x8d\x27" + "\x07\x80\xb6\x1d\x4c\x3c\x90\xa0" + "\x02\x14\xf2\x48\x89\x45\x6e\x36" + "\xa2\xbd\x6a\xb9\x14\x9c\xb4\x31" + "\x90\x31\x40\xe0\x09\x4b\x9c\x32" + "\xfe\x43\x9f\xd2\xa3\x7c\x19\x97" + + "\xb1\xe2\x07\x4b\x5d\xdd\x73\x71" + "\x21\xa2\x9e\x8d\xcb\xc4\x44\xd1" + "\x14\xab\x05\x11\xa4\x4e\xb0\xe8" + "\xf1\xd8\x80\xfe\x42\xa5\xdd\x92" + "\xe6\xdc\x03\xcf\xa8\x2f\x98\xe9" + "\xfc\xcf\x22\x1a\x65\xa9\x5e\x8b" + "\xc4\x88\xad\x3f\x7f\xea\xf4\xf7" + "\x5c\xa9\x5b\x6a\x3e\x77\xdb\x62" + + "\xc7\x57\x03\x82\xb4\x3f\xbd\x18" + "\xad\x58\x14\x6f\xae\x39\x20\x99" + "\xa1\x4a\xb4\x25\xc5\xf3\x1d\x9a" + "\x81\x52\x3d\xed\x57\x03\x78\x2d" + "\xd4\xd4\x7a\xc7\x4d\x7e\xcf\x58" + "\xc4\x4f\xdf\xf9\x98\x79\x9a\xd4" + "\x5e\x20\x71\x1d\xb5\xa8\x65\x44" + "\xaa\x54\x92\x64\xa6\x0e\xee\xa0" + + "\x35\xb2\x92\x9c\xe8\xe6\xaa\x4b" + "\xa1\x93\x39\x6b\x0e\xbd\x3b\xa7" + "\x31\xd0\x3d\x69\xec\x60\x6d\xd0" + "\x1c\x88\x56\x71\x1b\xb9\xca\x03" + "\x4b\x57\xb3\x1d\x2f\x86\x15\xd6" + "\x1a\x06\xbb\x64\x85\x01\x5b\x48" + "\x06\x1e\x18\xa0\x88\x49\x43\x27" + "\x57\xc7\xc0\xc1\xd4\x1a\xd6\x2c" + + "\x4a\x0d\x48\xf3\x1c\xde\xe2\x03" + "\x1a\xcf\x8a\xbc\xc7\xed\xd8\xf0" + "\x9c\x5a\x29\x68\x03\x33\x3e\xf2" + "\x7d\xa9\x46\xc5\x68\x5f\xdd\xfa" + "\xb1\xac\xf8\x96\xad\x97\x55\x89" + "\xe2\xda\x1b\x67\xd5\x49\xdd\xbd" + "\xf4\x43\xdd\x21\x28\xd5\xfc\x16" + "\x1a\x14\x19\x66\x12\x54\xa4\xa5" + + "\xa0\x86\x0d\x03\xd3\x34\x5c\xc8" + "\x5e\xe9\x3c\x21\x80\x2e\x4b\xf1" + "\x7f\x6d\x7e\xf0\x9b\xed\x3e\xce" + "\x79\xec\xa3\xa3\x21\x3e\x6c\x47" + "\xd3\xa5\xde\xca\xf2\x11\xec\xb4" + "\xaa\x36\xa9\xcc\x12\x5f\xad\xd1" + "\x7d\x1c\xe6\x34\x9e\x60\x24\x17" + "\xa2\x7b\xd6\x2f\xf3\x0d\x52\xcc" + + "\x2a\x7f\xa1\xa9\xa8\xe2\xfb\x6b" + "\x17\x50\xd9\x03\x60\x2f\xac\x1c" + "\x8c\xb4\xa2\x8e\x57\x62\xc0\x38" + "\x8a\xc3\x3c\xcc\x5c\x4d\xca\x21" + "\x91\x20\x45\x67\x54\x7a\x06\xff" + "\x2c\x46\x9d\x13\x5d\xdf\xbf\x63" + "\x6f\x00\x50\x14\xa1\x76\x13\x22" + "\xec\x9a\x2a\x33\x5e\xfe\x1a\xc8" + + "\x41\xa1\xfe\xba\x99\x9a\xa0\x11" + "\x40\x16\xd4\x19\x4b\x41\xe0\x7f" + "\xd1\x09\xb6\xf3\x2a\x07\x6b\xd6" + "\xd2\x54\x55\xbc\x34\xde\xf7\x27" + "\x45\x7b\x51\xbc\xaf\x29\x65\xd6" + "\x9f\x8d\xd1\x12\x21\x35\xe4\x8b" + "\xd7\xef\x0d\x4e\xe1\x92\x21\x94" + "\x1e\xaf\xc0\x90\x1f\x87\x65\xb4" + + "\xcf\x29\x9f\x43\x9f\xc7\x32\xfa" + "\x3b\x2a\xd8\x4d\xc0\x21\xf3\x7b" + "\xb1\xc1\xa2\xea\x54\x7f\x12\xff" + "\x18\x96\x5e\xf3\x2d\x5f\x36\xa8" + "\xdd\xf8\x0e\x4d\x02\x29\x2d\x85" + "\x4a\x8c\x22\x59\xc1\xe2\x5c\x39" + "\xd3\xfe\x5a\x21\xe8\x44\x9f\xb6" + "\xe3\x58\x74\xb2\x98\xf8\xc1\x16" + + "\xbc\x25\x3f\xf3\xe0\x87\x0f\x17" + "\x98\xc0\x39\xc3\x67\xb6\xdc\x24" + "\xae\x3e\x07\xab\xa4\x02\x17\xbf" + "\x44\xfb\x8c\x23\x9c\x91\xa6\xad" + "\x75\x63\xee\xdd\x11\x85\x00\x53" + "\xad\x60\xdb\xb8\x85\xfa\x92\xdb" + "\x0e\x21\x21\xa4\x66\xa3\xb6\x50" + "\x8f\x55\x37\x4c\xeb\xf8\x7b\xdc" + + "\x7e\x25\x4f\x2e\x08\xa1\x7b\xe4" + "\x7c\x9d\x68\x35\xdf\xe2\x0e\xcf" + "\xd0\xa0\x1b\x32\x8e\xc3\x8f\x8b" + "\x8b\x5e\x74\x0f\x4c\xc6\x70\x94" + "\x2f\xa2\x5f\xd6\xf5\x87\x38\xa7" + "\xbe\xef\xa7\xc2\x9b\xf8\x81\xa5" + "\x8a\xc9\xe4\xee\xa6\x0b\x5a\x83" + "\x71\x1a\x29\xa3\xe9\x83\xe1\x86" + + "\x3b\x04\xe4\x89\xb0\x87\x54\xfb" + "\xd2\x9b\x79\x09\xef\x9d\xe4\x4d" + "\xbe\x60\xe7\xb3\xc0\x70\xa8\x9d" + "\x39\x15\xee\x89\xd3\x1d\x4e\x5e" + "\xdb\x05\x57\x91\xfa\x49\x38\x1b" + "\x81\x0e\xac\x5e\x94\xe1\xe5\x7c" + "\x5c\x3f\x0d\xb0\xa0\x72\x17\x7c" + "\xa1\xb5\x00\x6c\x76\x26\x79\x54" + + "\x5a\xe2\x60\xc3\xbf\xb6\xe9\x8c" + "\x78\x1a\x5a\x07\x95\x51\x42\xe6" + "\xf4\x32\x17\x48\xa8\x56\xc7\x9d" + "\x7a\xb5\x32\x54\x0f\x44\xc0\x83" + "\x1f\x28\x20\xd7\xf1\xb3\x70\xc6" + "\x51\xe0\x35\xd1\x0e\x91\x05\x22" + "\xe7\x2b\x05\xdb\x0e\x4b\xd1\xde" + "\x39\xea\x68\xc5\x27\x3d\x7b\x69" + + "\x4b\x71\xf6\x1a\xf1\x6c\x3a\x2e" + "\x6f\xb9\x13\x3c\xa6\x8e\x0f\x77" + "\x95\xff\x8c\x4c\xfb\x42\xc2\x98" + "\x91\xbe\xa0\x95\x0c\x9a\xec\x67" + "\xcf\xe7\x8e\xeb\x5a\x33\xf0\xee" + "\x24\xc4\x71\x33\xe7\x4c\xf3\x63" + "\x05\xe5\xed\x31\x95\x39\x0b\x98" + "\x19\x36\x3f\x9b\xfe\x3a\xe8\x7c" + + "\x1c\x4a\x5e\x79\x2e\xbd\xf1\xb3" + "\x89\xca\xcd\xa1\x7e\x18\xd3\x85" + "\x3d\x68\x41\x35\x3c\x4e\xe4\x15" + "\x67\x40\xed\x80\x9c\x23\x8c\x2a" + "\xed\x08\xc5\xbf\x5a\x02\xe6\xbd" + "\xed\xc5\xf2\x3b\x31\x1e\x63\xb1" + "\x12\xa1\xd9\xe7\x3b\x3b\xcb\xb2" + "\xcc\x38\x78\x7c\x4f\xc1\x54\x05" + + "\xbf\xe0\x88\xaa\x27\xb7\xe6\x1b" + "\x07\x35\xe8\x64\xba\xc2\x64\xd7" + "\x86\xeb\xd7\xba\x97\xf3\xbc\x4a" + "\x4f\xb7\x20\x79\xbf\x1c\xfd\xb2" + "\x2b\x03\x3d\xf1\x5b\x91\xe8\x65" + "\x22\xd6\xfb\x19\xbb\x4a\x26\x9d" + "\xb4\xa2\x48\x2f\x79\xaf\x62\x2f" + "\xec\xba\x19\x86\x5f\xb0\xa9\x22" + + "\x33\x32\x45\xdc\x05\x90\xf2\xde" + "\xcf\x4b\xac\x2f\x7a\xc4\x08\xc2" + "\xac\x55\x3d\xac\xfe\xa3\x57\x60" + "\x07\x12\x2c\x90\x5d\x72\x23\x17" + "\xec\x0f\xeb\x33\x27\xc6\x31\x9c" + "\xbb\x63\x3c\xbb\xdb\xcc\x13\x49" + "\x38\x58\x30\x07\x2b\x54\x3e\x11" + "\x97\x2d\x0c\x31\x2a\xe7\x48\x9d" + + "\x58\x6b\x31\xb8\x54\x27\xd5\xc1" + "\x60\xab\x1f\x81\x42\xa3\x35\x94" + "\x35\xc9\x02\x61\x76\xc3\x26\xe1" + "\x2e\x29\x25\x3e\x95\x15\x4f\x7a" + "\x59\xad\x2c\x03\xc3\xe7\xc3\x1b" + "\xb6\x1c\x2a\xfe\x81\x7a\x2d\x4b" + "\xcb\xa6\x8b\xe0\xe2\xf4\x0b\xa8" + "\x68\x02\xf9\x8c\xb2\xc9\xfc\xb7" + + "\x96\x82\x28\x51\xa7\xd1\xe2\xa2" + "\xb0\xdb\x6d\xf6\x7b\x52\xca\xba" + "\xd4\x3c\x31\x80\x8f\x41\x9b\x40" + "\x8b\x6a\x3c\x87\xe8\x1a\x4b\x2b" + "\x5f\x29\x93\x2a\xc7\x5e\xe9\xb8" + "\x5f\x79\x5a\x2e\x90\x50\xf6\x0e" + "\xfa\x6a\x87\x2f\x88\xc8\x5a\x16" + "\x03\xe2\xc1\x25\xd9\x87\xca\x90" + + "\x36\x79\xce\x93\xa7\x8d\x12\xbc" + "\xf9\x9d\xbe\x39\xd6\x9a\xc6\x3c" + "\x7c\xd3\xb6\xec\x1f\x99\x65\x69" + "\xa3\xff\xb5\xb8\xbf\x01\xe0\x64" + "\x0d\x01\x34\x93\xbf\x0a\x61\x5d" + "\x0c\x3f\xda\xdf\xb0\xee\x8f\x71" + "\xd7\x40\x05\x03\xa8\x1e\x2b\x5b" + "\x37\xd3\xb4\xf4\x73\x2f\xf2\x59" + + "\x3d\xeb\xbb\xd9\xc4\x4e\x42\x54" + "\x1c\x92\xb2\xd7\xe3\xaf\xce\x34" + "\xc5\x37\x6d\x29\x2e\x02\x68\x5e" + "\xb0\x16\x9f\x35\x2b\x0a\x8e\xa2" + "\x73\x9d\x3f\xbc\xd9\x2d\xd8\xfd" + "\xff\xe1\xf3\xba\xf9\xa8\x39\x69" + "\xc4\x6d\x73\x31\x5c\xf4\xcf\x55" + "\xe7\xe8\x92\x78\x42\x56\x0f\x91" + + "\x2c\x04\xd0\xaa\x05\xbf\x35\xdf" + "\xcc\x6a\xda\x28\x70\xec\x25\x29" + "\x5c\x3f\xaa\xe1\x04\xa8\x2a\x82" + "\x63\x8e\x34\x3d\x7d\xec\xed\xb5" + "\xcf\xb2\xf6\xb4\x30\x28\x36\x03" + "\x2a\xba\x6b\x09\x0d\xcb\xbf\x08" + "\x04\x3f\xec\x9f\x64\xe4\xfd\x8a" + "\x17\x4e\x43\x1c\x4f\x2e\x40\xfb" + + "\x26\xc3\xce\x8a\x9d\x6c\xc4\xb6" + "\xc0\xb8\x6c\x29\x3d\x58\xf5\xac" + "\x08\x72\x07\xcf\xc6\xca\x52\x25" + "\xd6\x3d\xa0\x0d\x83\xef\x61\x52" + "\xb4\x46\x00\x5d\x30\xee\xa7\xf6" + "\x85\x3e\x0a\xcb\x96\x5c\x86\x24" + "\x89\x7a\xdf\x8b\x44\x91\x59\x71" + "\x83\x23\xe4\xf8\xdb\x5c\x1d\x22" + + "\x09\xdc\x47\x35\xf4\xaa\x1d\x95" + "\xd4\xac\xae\xd4\x0b\xd5\x82\xb9" + "\x56\x11\x9f\x45\x2b\x94\xc9\xdc" + "\x72\xb2\x45\xfa\xe2\xb1\x67\x80" + "\xb7\xfb\xa3\xd6\x0c\xd0\xfb\xe2" + "\x37\x2d\x74\xca\xdd\x24\xfc\x46" + "\xdd\xfb\x26\x7b\x76\x44\x45\x66" + "\x7c\xf6\xd8\x2f\x61\xa3\xa6\x3f" + + "\x60\x92\xe3\xdf\x49\xb3\x09\xde" + "\x93\x90\x54\x73\xf7\x12\x46\x98" + "\x02\x3b\x85\x67\x81\xe2\xed\x7c" + "\x03\x77\xd1\x29\xb4\x9b\x80\x7d" + "\xf0\xc4\x56\x27\xfb\x6b\x0b\x45" + "\x80\x2b\xf0\x93\xba\xf9\x9f\xc5" + "\x61\x95\xad\x20\x57\x54\x69\x3e" + "\xc7\xe2\x31\x33\xbe\xf0\x7c\x0c" + + "\x03\x48\x9c\xca\x9b\x7c\x72\x42" + "\x5e\xda\xdc\x29\x46\x03\x14\x7c" + "\x17\xf6\x21\xba\x39\xab\xec\x00" + "\xc1\xef\xba\xf0\x96\xb1\x2b\xb5" + "\x74\x1c\xac\x73\xde\x03\xd5\x56" + "\x2c\x9d\x9c\x53\x0f\xce\x2d\x08" + "\x87\x95\x3c\xfa\x8a\x0a\x77\xf7" + "\x7d\x7e\x5c\x59\x7a\x5a\x89\x96" + + "\x47\xfb\xfa\x6e\xd2\x69\xdb\x29" + "\x29\x74\x5e\xee\xf2\xe9\xb9\x04" + "\x03\x02\xe9\x88\x38\x1d\xf2\x91" + "\x15\xa6\xdf\x7a\x79\x8e\x3f\xcf" + "\x37\xe7\xeb\x61\x1c\x12\xf9\x89" + "\xbd\x03\xba\x06\x06\x69\x59\x87" + "\xb7\xfe\x78\x97\x72\x7a\xc2\x1a" + "\x18\x60\x72\x34\x3c\x72\x18\xe0" + + "\x7e\x93\x70\xfc\x86\xcf\x42\x7c" + "\x05\x8f\x11\xa1\x75\x33\xf8\x5b" + "\x98\xbf\xe9\x39\x13\x54\xc0\x11" + "\xf9\x08\xfa\xac\x04\xf3\xa2\x4a" + "\xb3\x6f\x8b\xda\x1a\x4d\x61\xd6" + "\x0b\xad\x05\x5b\x77\x3b\x73\x92" + "\x66\xdd\x15\x30\xf1\xd5\x8e\xcf" + "\x32\x0a\x15\xd8\x18\xef\xad\x1b" + + "\xed\xf9\x3f\xfb\x9a\x9b\x59\x2e" + "\x5c\x51\xf6\x17\xab\xe0\xc2\x28" + "\x49\xa4\x4d\x47\xfd\xe4\xbe\x1c" + "\x52\x44\x36\x4f\xa4\x79\x12\x07" + "\x55\xe8\xfb\x01\x66\xff\xab\x97" + "\xc4\x51\xda\x5f\xe8\x94\xe3\x3e" + "\x0b\x7c\x59\x67\xf6\x85\x03\x19" + "\x4b\xe3\x7e\xa2\xc6\xcc\x9f\x6e" + + + "\xf8\x92\xa4\xdd\xde\x7a\xc7\x3b" + "\x05\x72\x29\x78\xea\x3a\x1a\xc1" + "\x4c\x1b\x93\x34\xe7\xa3\x89\x5e" + "\xbb\x94\x56\x9f\x2e\x2e\x51\x17" + "\xb6\xf8\x7b\x17\xf3\x49\xc3\x5d" + "\x3e\xff\xc7\x08\xba\xa4\x2e\x23" + "\x5d\x14\x11\xf5\x16\x9d\x4f\x9c" + "\xc3\x79\xb3\x33\xa3\x09\xf1\xcc" + + "\xa9\x24\xeb\x80\x70\x85\xe2\x60" + "\xfd\x0c\x8e\x48\x4d\xfb\xed\x7b" + "\xb8\xcd\x59\xc2\xd7\xbb\x1e\x72" + "\xa9\x90\x63\xbc\x55\xa8\x0d\x0b" + "\x70\x4c\x31\xde\xdb\x04\x4d\x2b" + "\x46\xe8\x32\x6c\xbc\x1f\xbf\xcd" + "\x9e\xfc\x62\xb1\xab\x3e\x83\x33" + "\xb7\x3a\xdd\xb0\x8b\xb4\x39\x99" + + "\xb9\xdf\xc3\x97\xb1\x8a\x2b\xc4" + "\x54\x81\x16\xcf\xb0\x49\xa5\x55" + "\x92\x06\xb5\xc1\xe7\x48\x67\xad" + "\xcb\xcb\xc5\x6f\x0f\x78\x75\x27" + "\xc8\xd7\xc9\xe1\xb8\x80\xab\x4e" + "\x56\xcd\xdb\x3f\xe1\xda\x69\x8c" + "\xce\xea\x69\x99\xfb\xb4\xe6\x47" + "\x5a\xcb\x05\xa7\x85\x10\x2f\x00" + + "\xb9\x0e\x1b\x71\x1f\x2c\x89\x96" + "\x54\xb9\x0a\x78\xc8\xf2\x05\xb9" + "\xdb\x92\x07\xa2\x09\x63\xe2\xac" + "\x26\xe1\x84\x06\xb3\xc9\x8a\xec" + "\x47\x24\x0a\xb4\xb6\xd8\x6a\x48" + "\x24\xfb\xe3\x9f\xc1\x1f\x12\x60" + "\x3f\x3b\x8e\x1a\xcf\xfc\x26\x56" + "\x94\xf3\xd1\x6a\x22\x86\x56\x4e" + + "\x52\xbf\x37\x30\x18\x43\xfb\x2b" + "\xd7\x25\xc7\x78\xb5\x6d\x1e\xb6" + "\xd7\xe5\xb3\xbb\x60\x40\xfd\x8e" + "\x8e\x48\xac\xdb\x01\x47\x01\x2e" + "\x49\xa4\x0a\x36\x9a\xcf\x75\xac" + "\x08\x4d\x63\x79\x05\xfd\x0c\xb7" + "\xef\x15\xfb\xff\x6d\x53\x91\xa5" + "\x6c\x10\x7c\xd0\x82\x75\xc3\xb2" + + "\x98\x4a\x6f\x23\x22\xbb\xfb\x5c" + "\xbb\x00\x68\x06\xe9\x59\x0c\x0b" + "\x74\x77\x9a\x5a\x8f\x9a\xc6\x4a" + "\x48\xc9\xbe\xd6\x04\xf8\x33\x2b" + "\x66\xc4\xe6\x32\x95\x92\x72\xb3" + "\x73\x9c\x59\x4e\x0f\x6d\x95\x68" + "\xcc\x31\x5c\x15\x9f\x24\x7a\xa4" + "\x4e\x28\xce\xe1\x0d\x0f\xd8\x24" + + "\x88\xd1\x57\x64\x0d\xa7\x47\xf3" + "\x8b\x38\x7a\x8b\x6b\xa8\xed\x86" + "\x13\x60\xcd\x0c\x06\xff\xcd\xb7" + "\xb2\x3f\x05\xd0\xc7\xb6\xb1\xbe" + "\x9f\x0a\x24\x99\x87\x23\x02\x0b" + "\xb2\x89\x61\x77\x4f\x38\xbb\x1b" + "\x3a\x19\x66\x90\x1e\xe7\x95\x86" + "\x7e\xac\xff\x06\x97\x00\xb5\x2e" + + "\x62\x3d\x8a\x4a\xc6\x46\x4b\x5a" + "\xd2\x43\x77\x24\xd0\xc4\x69\x84" + "\x33\xe4\xf7\x88\x3d\xa1\xb3\x2b" + "\x49\x58\xbe\x01\x10\x3a\xb2\x62" + "\x4c\x1a\x3d\xa6\xb4\x96\x35\xe8" + "\x3e\x3f\x18\x7d\xea\x7f\x4e\x45" + "\x1c\xb0\xaf\x17\x61\xce\x3f\x64" + "\x38\x36\x4c\x1c\xe6\xe5\x65\x4e" + + "\x5f\xcd\x5f\xa3\x8d\x50\x65\x40" + "\xeb\xca\x5c\x49\x8c\xdf\x65\x89" + "\x62\xa9\xe1\x12\x50\xa8\x2d\x0f" + "\xc4\x1c\xcf\xc1\x94\x1b\x47\xee" + "\x75\xfb\x08\x0a\xc8\x9b\xf1\xce" + "\x91\x35\xde\x81\xf5\x58\x49\x70" + "\x88\x4f\xef\x3a\xb2\xf8\x67\x28" + "\x5f\x9a\x9f\xea\x84\x93\x74\x8d" + + "\x8b\x50\x09\xdc\xe3\x30\xe8\xb7" + "\x55\x76\x31\x74\xcf\xd2\xf6\xfa" + "\x55\x03\x69\xdf\xeb\x6c\x60\x72" + "\xd6\xde\xc3\xd0\xb3\x92\xbb\x48" + "\x92\xf8\x7c\x5c\x84\x54\xb7\x65" + "\x1f\xf0\xd5\xd5\xc9\x7a\xcd\xf6" + "\x69\x1d\x40\x96\x59\x0a\xc3\xc2" + "\x78\x18\x92\xed\x50\x86\x26\x91" + + "\xd5\x68\x26\x8d\xf9\x5f\x8b\xe3" + "\x65\x19\xd8\x7a\x1a\x28\x15\x07" + "\x11\xce\xc6\x03\x7c\xfc\xc8\x1b" + "\x36\x04\x65\x8b\xe2\xe6\xbe\xcb" + "\x08\x98\xdb\x0c\xe8\x0f\xb0\x06" + "\x15\xd3\x3e\xfe\x66\xe0\xd6\x17" + "\x18\x50\x0b\x4d\xc6\x38\x9d\x2e" + "\xef\xca\x4d\x84\x56\xfd\x8b\xab" + + "\x45\x85\xdd\x6a\x17\x77\xdb\xe5" + "\x66\x9b\xc4\x72\x66\xcb\x71\x1b" + "\x77\x1d\x42\x68\x39\x07\x56\xd8" + "\xea\xaf\xe3\x83\xe8\x0f\x84\x03" + "\x77\x99\xc6\x1e\xd5\xda\x91\xb3" + "\x26\x67\x7f\x30\xb9\x3f\x24\xae" + "\x0c\x16\xca\xe8\x7b\xc8\x8a\xc8" + "\xf4\x55\xe3\x4c\xed\xcc\x74\x51" + + "\x66\xf5\xa4\x53\x7d\x49\xf9\xd4" + "\x10\x68\xb5\x97\x64\x46\x73\x89" + "\x21\xa6\x94\x04\x74\xda\xe1\xf8" + "\x68\x1c\x01\x8d\x93\x6a\x54\x82" + "\x62\xc1\x1a\xc6\x19\xcb\x3a\x1f" + "\x3e\x0d\xad\xab\x9c\xfa\xf8\x52" + "\x43\xea\xb7\xb4\x23\x65\x35\x15" + "\x25\x81\x60\xae\x61\xad\x16\x5a" + + "\x8e\x57\x81\xff\xf8\x67\x20\x75" + "\x7d\x44\x45\x90\x50\x21\x62\x78" + "\x6f\xaa\x05\x05\xcf\x2f\xc2\xc0" + "\x77\x1c\xed\x6b\xa6\xf0\x30\x10" + "\x39\xd7\x0b\x1f\x15\x9f\xf2\x31" + "\x85\xbe\xde\xe6\xc7\x89\x79\x2d" + "\x98\x7e\x67\x8e\x72\x0e\x07\x5c" + "\xd5\x1f\xe8\x06\xd3\x7b\x81\x0a" + + "\x99\x22\xe0\x7f\x72\x6a\x81\x0f" + "\x19\x33\x4f\x29\xc2\xcc\x35\x63" + "\xbe\xc5\x45\x47\x9f\x17\x20\x38" + "\x6e\x06\x2f\x92\x82\xb7\x47\xe6" + "\x8a\xfb\xca\x02\xde\x49\x2e\xc2" + "\xcc\xec\xc2\xfc\xff\xc2\x9b\x29" + "\x82\x82\x0e\x6e\xa2\xee\x8f\x9a" + "\x05\x32\x89\xfe\x8b\x27\x27\xa6" + + "\xe5\x13\xc6\xcb\xb6\x7e\xe1\xc1" + "\x1c\xa6\x7e\x49\x55\x1d\x13\x33" + "\xd5\xde\x7e\xaf\x9e\xd3\x69\x2f" + "\x1b\xf1\x6a\xde\x34\xf4\xc2\x73" + "\xfa\x75\xa3\xa4\x93\x24\xa5\x4c" + "\xc2\xc5\x33\xb8\x7c\x78\x06\x5f" + "\xcf\x71\x6e\x3e\x1f\x09\x4e\x81" + "\x66\x66\x74\x8b\x57\x1f\x45\x76" + + "\x2a\xe9\x33\xb5\x8c\xc1\x57\x6e" + "\xde\xb5\xbf\x55\xfe\xca\x9b\x33" + "\xeb\xa2\xee\x01\x9c\x8b\xea\xa1" + "\xd6\xa7\xf8\xf4\xf5\xb4\x23\x60" + "\x42\x4e\xb5\x52\xae\xe4\x52\x5e" + "\xdc\x70\xbf\x84\xe0\x55\xba\x1c" + "\x8d\xa4\x06\x3f\xba\x7a\x09\x22" + "\xa9\xbf\x0b\xe9\x3f\x63\x13\x55" + + "\x88\x93\x53\xe1\x82\xe0\xc7\x01" + "\x6b\x9c\x9a\x75\x30\x6f\x28\xfd" + "\xfb\xac\x6b\x17\x41\x10\x58\x94" + "\x53\xde\xc3\x3b\x7c\xf0\x80\xe5" + "\x2f\x77\x4d\x88\x75\x6f\xdb\xdc" + "\x4f\x9d\xbb\x40\xb8\x3b\x5c\xd7" + "\x11\x30\x08\xdb\x4e\x2e\x6c\xdc" + "\x8d\x29\x9c\xcd\xa2\x89\x87\xe1" + + "\x82\xce\xa0\xff\x1c\x10\xf2\xa5" + "\x40\x34\x34\x4b\xe5\x36\x6d\x7c" + "\x03\xa3\x74\x0c\x29\x8d\x52\x82" + "\x17\xab\xd4\x04\xc2\xa8\x83\xd0" + "\x0d\x1e\x00\x76\xdd\x4e\xf1\xcf" + "\xc7\x2e\x66\xc9\x02\xc2\x11\xc9" + "\xc6\x78\x02\x81\x98\xfb\x34\xdb" + "\x68\xe3\xe4\x5e\x0e\x25\xb4\xa1" + + "\x47\x13\xfe\x95\x84\xab\xe6\x5e" + "\x3c\x50\x24\x6f\x39\x6c\x0f\xab" + "\x6b\xdd\x86\x44\xfb\x3f\x7e\x80" + "\xf5\xfe\x02\x80\x74\x6c\x0b\xf0" + "\x99\x29\x86\xa7\xa6\xf9\xbf\x48" + "\x26\x9e\xd8\xbe\x6c\xa0\xe5\x85" + "\xeb\x19\x84\x3d\xaf\x11\xd3\x86" + "\x16\x3f\x73\x34\x78\xad\xf3\x24" + + "\xaa\xa2\x6f\x5a\x5e\xee\xac\x9c" + "\x23\xe6\xd4\x75\x83\xd7\x86\x06" + "\x5d\x18\x28\x0b\x0a\x8d\x72\x3f" + "\x6f\xed\x3c\xdd\x60\xb0\x12\x79" + "\x5a\xcc\x14\xf0\xfa\x29\x31\x8d" + "\xea\x5a\x39\xd7\x5c\xde\x1d\x32" + "\xab\xba\x0f\x6b\xd6\xb2\x07\x96" + "\x99\xbd\xaf\x07\xae\x11\x59\xbc" + + "\x44\x0d\x82\x11\x13\x55\x20\x5e" + "\x3a\x47\xc4\x86\xcc\x1b\x65\x0c" + "\xef\x0e\xd8\x9b\x2b\x0c\x23\x1d" + "\xe5\x5b\x51\x07\x12\x4a\x2c\x04" + "\x84\xe2\xe9\xbf\xa0\x7c\x51\x42" + "\x7a\x82\x69\x23\x78\x05\xf6\xe8" + "\x9d\x69\x38\x16\xf0\x04\x4f\x18" + "\x05\x6d\xbc\xf2\xed\x18\x46\x17" + + "\x77\xf1\x1c\x65\xd5\x78\x37\x7c" + "\x0f\xbd\x52\xd8\x55\x55\x68\x1b" + "\xf8\x1f\x46\xf3\x82\xf6\x03\x4a" + "\x7b\xca\x12\x9b\x35\x8c\x09\xc1" + "\x01\x34\x98\x5d\xd2\x53\x05\x6a" + "\xb0\x87\xc6\x3d\x8f\x76\xc0\xe0" + "\x2e\x73\x4b\x34\x3e\xa3\x44\x7c" + "\x02\x0a\xb7\x64\xc3\x71\xb1\x5e" + + "\x87\xd6\x68\x6c\xfc\x03\x3e\x5e" + "\xc7\x52\xf0\x1f\x3d\x2c\x73\x3e" + "\x7a\x6e\xd1\x6e\xa6\xef\xd0\xf2" + "\x46\xb7\x5b\xb6\x26\x2b\xd9\x63" + "\x7c\x86\x44\xdd\xba\x82\xcd\xff" + "\xb8\x81\xc0\xf8\x9e\x4a\x1b\xa7" + "\x85\x87\x6c\x73\xa7\x76\x16\x6c" + "\xd0\x32\x89\x9d\x16\x06\x2c\xbe" + + "\xf2\x39\x09\xb5\x49\x88\x63\xd1" + "\x8e\x85\x90\xba\x2c\x69\x33\xfc" + "\x8e\x00\xa6\x2f\x91\x0a\x4a\x2b" + "\x40\x39\xa3\x97\xc7\x90\x01\xc0" + "\x10\x3c\x2d\xd6\xfd\x14\xff\x8a" + "\xc1\x89\x19\x57\x09\x4d\xc6\x98" + "\xba\xfe\xe5\x00\x28\xea\x24\x82" + "\xc1\xc5\xa9\xf9\x0c\xb9\x3c\x91" + + "\x9f\x1c\xca\x9e\x4b\x1a\xfa\x7b" + "\x35\xe5\xe5\x8c\xdc\xc1\x0b\x96" + "\x0a\xc3\xee\x17\xf3\xd9\x67\xe2" + "\x38\x7d\x25\x6c\xef\x89\xfb\x06" + "\x6d\xa2\x64\xd3\x9a\x99\x28\x23" + "\x58\xab\xea\x26\xcb\x94\xb7\x69" + "\x96\xa5\x5b\xb8\x1f\xab\x28\xad" + "\x94\xaa\xd0\x56\xf3\xbf\xdc\x05" + + "\x02\xa6\xa1\xa3\x80\x9e\xd7\x14" + "\xaf\xd6\xc3\x22\x5e\x18\x4f\xfc" + "\xc8\x67\xf6\xb7\x6b\xa5\x2f\x23" + "\xf8\xea\x3e\x8f\x91\xbc\xd0\x49" + "\x48\xe2\x70\x58\xb9\x51\x91\xe8" + "\xab\x09\x44\x3d\x70\x0e\xab\x70" + "\xe8\x83\x07\x80\x10\xe9\xd8\x22" + "\x62\x77\xac\xa2\xb2\x7b\x2c\x9b" + + "\xc4\xfb\xcf\x2b\x28\x6d\x37\x53" + "\x7a\xdb\xea\x06\xa7\x17\x88\x70" + "\x69\xae\x35\xcd\x05\x0e\xf5\x6f" + "\xde\x7f\xbc\x74\x75\xfb\xb5\x63" + "\xc4\x08\xfe\xe7\x53\xe9\xc9\x71" + "\x18\xca\x83\xf5\xd4\xbf\xd8\xb4" + "\x5c\x1c\xe8\x45\x82\x78\x8d\xde" + "\x38\x41\x47\xe0\x3c\xe9\xf5\xa5" + + "\x32\x19\x83\xf0\x4b\x5f\xd7\xd4" + "\xc9\x8c\xfe\x77\xc4\x0a\x77\x5e" + "\xa2\x72\x2e\x86\x48\xe7\xb5\x52" + "\xfe\x35\x1d\x50\x82\x54\xa4\xe9" + "\x87\xb1\x9a\x4a\x42\xe7\x93\x8a" + "\x17\xa0\x8c\xe8\x6d\x50\x72\x5a" + "\xef\x2d\xeb\x01\xb2\xdc\x80\xe6" + "\x9d\x20\x68\xba\xe6\xa4\x5a\xdc" + + "\x31\x9f\x3c\x29\x0f\x16\x6c\x42" + "\xa7\xd7\x64\xe8\x33\x63\xb5\x8e" + "\x30\xba\xbb\x3e\x02\x64\x11\xbe" + "\x02\xa3\xd5\x2f\xe3\xba\xc2\x64" + "\x7b\xff\x5a\x26\xe1\x01\x06\x80" + "\x14\x4b\xfd\x66\x80\xa8\xd8\x52" + "\x9c\x5a\x07\x46\xe7\x20\xba\x5a" + "\xc6\x34\x12\x7e\xf8\x2b\xa3\xda" + + "\xc8\x2f\x56\xc4\xa5\x97\x74\x45" + "\xf8\xbf\xe2\xf3\x8a\x8e\xfd\x44" + "\x59\x7d\xc9\x49\x35\x49\x23\x19" + "\xe4\xbb\x36\x40\x56\x07\xe3\xda" + "\xed\xa0\xad\x49\x51\x78\x37\xf1" + "\xaa\x87\xef\x80\xc5\x62\xd3\xc6" + "\x6a\x5c\xa5\x30\x12\x43\x97\xc5" + "\x37\x5a\xec\x15\xe5\x07\x84\x56" + + "\xe0\xb7\x4d\x69\xef\xbd\xf9\x80" + "\xc6\xdd\xfc\xb9\x87\x87\xca\xed" + "\xe1\xdc\xb8\x03\x34\x1c\x98\x51" + "\xa1\x0b\xe1\x70\xf1\xdc\x74\x42" + "\x1a\x6d\xef\x6d\xb8\x43\x27\xf7" + "\x66\x18\xdb\xeb\x70\x16\x5b\xd2" + "\x58\x6f\x0c\x05\x8c\x1e\x49\xc4" + "\xf5\xd7\xfb\x87\xab\xb2\xe2\x2b" + + + "\xec\xf8\x11\xd1\x9d\x5c\x0e\x3e" + "\x60\xe7\xc4\xb7\x8d\x3f\xc3\xbc" + "\x51\x2a\x39\xbd\x91\x9a\x2f\x70" + "\x2d\xe9\x32\xc1\x95\xa7\xa4\x7d" + "\x1b\x15\xb1\x0b\xe3\x0a\x0b\x1a" + "\x51\x22\xe3\x02\xc8\xba\xfe\x54" + "\x78\x9e\x4e\x69\x82\x50\x3a\xea" + "\xb8\x40\xfe\xe4\xc1\xfe\x8f\xe5" + + "\x0b\x12\xc4\x29\x9d\x34\xb8\xfb" + "\x15\xd9\xd0\xc0\x1f\x39\x94\x9f" + "\x51\xba\x10\x54\xa7\x4f\x07\xc4" + "\x11\x59\x0a\x15\xf6\xdb\x6a\xa6" + "\x38\xca\xbf\x34\x3c\x54\x64\xc1" + "\xfc\xcc\xe1\xb9\x60\x75\xf2\xe0" + "\x9c\x21\x20\xe8\x53\x0f\xda\x99" + "\x7a\x99\xb4\xc6\x98\x44\x23\xe8" + + "\xe4\x19\x6e\x51\x13\xc5\x23\x7b" + "\x93\xd5\xc4\xc5\x47\xe8\xe2\x56" + "\xf6\x1e\xe7\x5c\x73\x7d\x72\x9f" + "\xc5\x44\x9a\xf7\xa6\x04\x63\x5b" + "\x33\xe4\xb7\x3a\x36\xa7\x38\x66" + "\x83\x2f\x74\xfe\x70\xa4\xde\x1a" + "\x9f\xc1\x7f\x5b\x54\xb8\x54\xe0" + "\x98\x06\x1d\xba\x1a\x38\x35\xf9" + + "\x36\x49\x8e\x91\x9d\x4f\x50\xb5" + "\x82\x39\x51\xb2\xf6\x5e\x03\x65" + "\xb9\x9c\x4d\x6f\xc2\xa0\x53\x05" + "\x09\x55\xa8\xbe\x56\x0d\xb1\x6c" + "\x11\xda\x42\xa2\xb7\x57\xd9\x48" + "\x68\x72\x2b\x67\xdd\xd3\xa4\x16" + "\x6b\xa9\x02\x85\x7c\x63\x7e\x3d" + "\x3b\x46\x0d\x73\x2b\x03\xc7\x27" + + "\x6f\x42\x46\x58\x7d\x6b\x36\x55" + "\x1d\x44\x7d\x24\x89\x9e\xd0\xe7" + "\x48\xbf\x6f\x73\x4d\x40\x0b\x51" + "\x7d\xbd\x84\xe7\xd0\x03\xa0\x7f" + "\x96\x95\xfd\x17\x4f\x61\xf7\x25" + "\xdb\x98\xcb\x35\xa1\xe0\xe0\x49" + "\x6a\xa7\x83\x2e\x7b\x95\x65\x2c" + "\xf8\xe0\xdb\xcd\x8d\xda\x40\x5d" + + "\x9d\x93\x95\xa5\xb4\x8b\xf6\x37" + "\x17\x02\x74\x28\x79\x64\x55\x03" + "\x12\x76\xad\x84\x7c\x0e\x74\x8e" + "\x5f\x69\x44\x90\x43\xc8\x9b\xd8" + "\x4d\x18\xa9\x85\x5d\xda\xf3\xf7" + "\x74\xb0\xc0\x9f\xbb\x63\x25\x56" + "\x8e\x88\x8a\xf8\xaa\xe6\xd2\x06" + "\x7c\xbe\x1f\x16\x43\x86\x2d\x61" + + "\xb2\x0b\x53\x54\xa3\xbb\xb3\x9f" + "\xea\x69\x08\xcb\x77\xef\xe3\xbd" + "\x63\x11\x43\x0b\x46\x90\xbc\x89" + "\x35\x9a\x81\xe4\xd2\xd7\x03\x4d" + "\x82\xa7\xb6\x43\x9e\x4f\xae\x33" + "\x86\xa6\x88\x9c\x07\xb3\x6d\x21" + "\xd9\xed\xff\x00\xe0\x88\xdd\x91" + "\x40\x48\xbd\x12\x9f\xda\x80\xb2" + + "\xd7\x8c\x53\x3e\x91\x86\x8f\x45" + "\x53\xad\x08\x8e\x6c\x1f\x00\xa7" + "\xff\x15\x5d\xbf\xe6\xc6\xb8\x52" + "\xdd\x15\x12\x01\xa4\x34\x82\x54" + "\x45\x40\x5b\x3d\x2d\x9d\x5a\xff" + "\x90\x41\x90\x4a\xb6\xee\xff\xb0" + "\x8b\x7f\x60\x48\xa4\xac\xa3\x55" + "\x2a\x67\xa0\x30\x5c\x66\xbd\x8c" + + "\x37\x59\x7f\xf3\x73\x35\x7f\xa3" + "\xa5\xfc\xe4\xd1\x7d\x6c\x0f\xeb" + "\xfc\xb0\x8a\xac\x54\xa5\x65\x29" + "\xac\x76\x46\x27\x6c\xf5\xfb\x17" + "\x20\xd7\xf7\xac\xd9\x6b\x2f\x2e" + "\x66\x47\x22\x10\x88\x8f\xfc\x41" + "\xef\x3b\xd5\x85\xb3\x14\x7a\x51" + "\xd1\xa7\x76\x7d\xa5\x27\xe3\xda" + + "\xdc\x82\x5f\x1f\x89\x5c\x5d\x51" + "\x9e\x07\x61\x63\xd7\x67\x7f\x9a" + "\x30\x53\xa3\x11\xe3\x81\xda\xa8" + "\x1b\xbe\x18\x4b\xc4\x90\x49\xe4" + "\x59\x3e\x10\xaf\x95\xed\xd5\xc7" + "\x61\x92\xac\x8d\xa7\xab\xe8\xec" + "\xd3\xb8\x94\x93\x99\xb0\x82\xbe" + "\x83\xfe\xad\x16\x9a\xf0\x30\x68" + + "\xb1\xd9\xd7\x94\xc1\x1a\xc4\x43" + "\x17\x7f\x2e\xc8\x82\xdd\xaf\x5b" + "\xca\x0f\xda\x5f\xc1\x14\x06\xdf" + "\xad\x37\xae\xa8\xa7\x43\xb0\x74" + "\x4c\x73\x71\x9e\xa1\xaf\xa6\x3b" + "\x2e\x0f\x45\x9c\x7e\x43\xd5\x15" + "\xb1\x42\xe2\x67\xfe\x83\x58\x4a" + "\xc2\x53\x19\x2c\xc2\xbd\x43\x51" + + "\xf9\xf5\x53\x6b\x7c\xce\xa9\xa2" + "\x99\x6d\x17\x1b\x95\x65\x24\x64" + "\x1b\x08\x5c\xb9\x36\x8d\x29\xb1" + "\xe6\x9e\x9a\x1d\xb8\x5b\x50\x53" + "\xb0\x70\xba\xf2\x61\x9e\x6f\x3f" + "\x53\xd4\xfa\x8a\xc9\x16\x7e\xd0" + "\x6a\x4a\xeb\xe7\xbb\x94\x16\x9f" + "\x8e\xbc\xb0\x3c\xd9\xce\xeb\xdf" + + "\x0b\x39\xf3\xb1\xf2\xd7\x76\xc6" + "\x72\x12\xb6\xa5\x8c\x1b\x7a\x9f" + "\xa9\x27\xe1\xc2\xc9\xbf\xbe\x4e" + "\xbf\x97\xd9\x5d\x0c\x50\x02\x46" + "\x0f\x23\x11\x47\x1c\x77\x09\x7f" + "\xc1\x09\x0f\x02\x7c\xb3\x8e\x05" + "\x8b\xe3\xe5\xfe\x4b\x3d\x69\xab" + "\xc0\xcb\x53\x46\x1f\xeb\x89\x92" + + "\xa7\xf5\x70\x17\x39\x2b\x4d\xa4" + "\x82\xeb\x44\x0e\x91\xd7\xd4\xe4" + "\x2a\x71\x69\x3f\x1e\x9d\xe6\x42" + "\x0e\x82\x6a\xac\xd6\xc4\x11\xbf" + "\x4c\x22\xc4\x42\xe5\xf3\xe7\xb5" + "\x1c\x94\x9d\x44\x1c\xe8\xb4\xd6" + "\x78\xe8\x50\x54\x16\xbd\x72\x5d" + "\x54\xac\x25\xee\x8a\xe2\x61\x6a" + + "\x78\x25\x95\xab\xc7\x9d\xda\x54" + "\x0b\x4d\xe8\x26\xf2\x3d\x42\xb5" + "\x42\x20\x87\x9b\xeb\x4e\xb6\xa8" + "\xdf\xf6\x90\x59\x82\x57\x20\xac" + "\x7a\xc7\xf4\x21\xeb\x96\xf6\x4f" + "\xaf\x73\xb2\xaa\xe4\xc3\x79\x1a" + "\xf1\xb3\x36\x94\x2e\x92\xbc\x29" + "\x7a\xa2\xd9\xd6\xf8\x7e\x80\xff" + + "\x6c\x74\xf6\x33\xf8\xa8\xf3\xc7" + "\xca\x90\xa9\xfe\x65\x6f\xe4\x21" + "\xa9\xb0\xdd\xca\xc5\xd5\x5f\x91" + "\x55\x45\x61\x78\x16\xf0\x41\xbd" + "\x58\xfb\x6f\x42\x34\x44\x6f\x34" + "\x04\xc2\xdb\x14\x36\x94\x55\x80" + "\x7f\x9b\x96\x5a\xfe\x20\xdd\xf3" + "\x9a\xa3\x99\xe8\x56\xe9\x59\x9d" + + "\xc0\x56\x6f\xd0\x8f\x68\xca\xe4" + "\x72\x79\x02\xdf\x0d\xf7\x8a\xa4" + "\x9d\x60\x9a\x5e\x04\x0f\x1f\x69" + "\x0e\x27\x61\xee\xcd\x82\xdd\xa9" + "\xd3\x18\xef\xa0\x63\xca\x03\x89" + "\xbd\xa3\x6c\x3d\x35\xee\xb7\x9f" + "\x03\x7d\xf4\xab\x9c\xa0\xb4\xa7" + "\x8e\xde\x67\x1c\x01\xda\xda\x4c" + + "\x92\x15\x92\x74\x37\x56\xa0\xf9" + "\x31\x9d\xbb\xb9\x1d\x26\xf1\xb4" + "\x59\x54\x9c\x4e\xb7\x29\x14\x55" + "\x53\x1f\xa7\x6e\x6f\x2e\x18\xbe" + "\x73\x05\xc5\xdf\x7c\xb0\xa3\xd3" + "\x44\x8d\xbe\x62\xda\xaf\xa1\x9b" + "\xd3\x65\xab\x52\xcb\xd2\xcf\x9b" + "\x02\x18\x57\xa9\x47\xd5\x11\xdf" + + "\x75\xa6\x38\xe0\xc1\x7d\x12\xac" + "\x20\x63\x5c\x8c\xf3\xef\x9d\x72" + "\x53\x2c\x0d\xa9\xd4\x8f\xdf\xb7" + "\xd3\x7c\x1e\x68\xec\xb0\x74\x9b" + "\xe5\x07\xb4\xda\x23\xa6\xb5\x5c" + "\xc6\x40\xb3\x76\x15\x36\xbd\xcd" + "\x2c\x39\x28\x7d\x5a\x41\x84\xa1" + "\x30\x78\x6f\xe9\xd8\xc1\x84\xc1" + + "\x61\xfc\x43\x5e\x84\xb6\x89\xb1" + "\x57\xab\xd3\xe0\x75\x23\x28\xf3" + "\xa8\x1d\x18\xb1\x67\x4b\xa3\x4f" + "\xb8\x52\xee\x99\xb2\xd0\x1e\x62" + "\x76\x06\x99\xad\xe1\x8d\x17\x9b" + "\x65\x40\xd5\x56\x7b\xe6\x1d\xd5" + "\x01\xc2\x38\x75\xc4\x27\x2c\x2a" + "\x5c\x0f\xa4\x38\xc8\x6e\x85\x33" + + "\xc3\x85\x7e\x2f\x3b\x30\xa9\x86" + "\x9b\x8f\x98\x71\x21\x46\xce\x5f" + "\xb5\xac\x38\xc1\xf6\x5b\x93\x5b" + "\x12\x12\x66\x25\x67\x7d\xea\x30" + "\xa2\xb9\x1a\xe5\xf4\xb5\x1e\xef" + "\x78\x7c\x06\xae\x8a\xc9\x87\x05" + "\xa6\x9c\xca\x77\x3c\x1b\xce\xb3" + "\x57\xf0\xb5\x54\x4d\x3d\x55\x2a" + + "\x3d\xab\x21\xcd\xb2\x68\xe4\x89" + "\x92\xd3\x93\xc3\x22\xf0\x04\xe5" + "\xf9\x3a\x01\xa5\xd4\xe1\x21\xab" + "\xcb\x8a\xc2\xc2\x78\x3f\x28\xe3" + "\x9f\xf9\x6b\x22\xf6\x35\x8b\xf3" + "\x69\x1e\x29\x0e\x74\x42\x35\xe8" + "\x2d\x16\x0c\xb2\x15\x3a\x67\x61" + "\xbe\xbd\x4f\xb0\x75\xdc\x01\xc1" + + "\xa0\x94\x18\x0b\xe1\x56\x71\x2c" + "\xc0\x68\x1c\xd8\x01\x40\x03\x92" + "\xb5\x15\xb1\xc8\x00\x5d\x22\xed" + "\xf2\x07\xb9\x83\x22\x9c\x7f\x23" + "\xc0\xe2\x70\x44\x2f\xf3\xa2\x0e" + "\x95\x4e\xbe\x58\xc1\xf7\x25\xb7" + "\x63\x54\xae\xb1\xfa\xca\x1d\x0f" + "\x04\xfc\xa2\x1b\x87\x51\xed\x59" + + "\x57\xd6\xdd\x06\xe2\xbe\xdb\x35" + "\x6d\xa9\xf3\x2f\x11\xdd\xcb\xe7" + "\x58\xe7\x6b\x07\x68\x19\x38\x88" + "\x5d\x1f\xc9\x08\x72\x7e\x73\x2d" + "\x76\x37\xec\x86\x62\xab\x83\x5f" + "\xa1\xa7\x5f\x94\x9d\x64\xaa\x98" + "\x33\x09\xef\x72\x37\xec\x77\xf4" + "\xb1\x17\x8c\x09\x1e\x2b\xf5\x66" + + "\x11\x07\x52\xc9\xde\xcc\xb0\xd1" + "\xbf\x84\x8b\x3c\xed\xe4\xa9\x55" + "\x14\xf3\xfe\xa1\x39\xbd\x26\x94" + "\x2b\x3f\xb9\x6e\x8e\x63\x5f\x4f" + "\x1b\x34\xf9\x2b\xd3\x1e\x2a\xba" + "\xa9\xd5\x42\x4d\x21\x13\x3c\xd6" + "\xc5\xc7\x6d\x31\x89\x4a\x96\xd2" + "\x51\x18\x51\xca\x06\x96\x75\xd1" + + "\xbd\x7b\xe5\xcf\x0e\xc1\x2e\xb1" + "\xb5\xc2\xa0\x35\x56\xb6\xc7\x82" + "\xbd\x67\x1c\x16\xcd\xd5\xc7\xdd" + "\xcc\x32\x3a\xae\x85\x89\x2e\xe3" + "\x29\x55\x1a\xd1\x44\x94\xba\x7a" + "\x1a\xfa\x27\x24\x02\xed\x64\xe9" + "\x0a\x77\xa1\x24\x2d\x39\x28\x15" + "\xcd\x2f\xc7\x12\x2c\xce\x52\xa1" + + "\x87\x11\xc5\xf8\xea\x9f\xf6\xed" + "\xa7\x4d\x1e\x74\xec\x67\xbb\x05" + "\x45\x43\x11\x08\x32\x0f\xdf\x47" + "\xb1\x92\x97\xbb\x07\xcb\xfa\x56" + "\xe4\x29\x62\x8f\xe9\x07\xe0\xf3" + "\x0f\xba\x6f\x52\xf4\x03\xd1\x62" + "\x79\x9d\x33\xb0\xf7\xbe\x33\x4f" + "\xc1\xfe\x9b\xb5\x7b\x35\x41\x98" + + "\xba\xf5\x8e\xe2\x67\x0b\x1e\xae" + "\x69\xe1\x18\xcb\x99\x46\x9a\x2c" + "\x20\xbd\x6b\x1e\x33\x0e\xcd\x0e" + "\xd2\x81\x5e\xaf\x0e\x36\x1b\x57" + "\x45\x1d\x1c\x10\x58\xea\x9f\xcd" + "\x52\x04\x88\x18\x8e\x78\x51\x66" + "\x46\xd4\x8d\x1f\x35\x26\x97\xa9" + "\xd0\x81\x72\xe3\x22\xd0\xbe\x44" + + "\x1f\xac\xdb\x60\xea\x6e\x0e\x83" + "\xf7\xa2\x06\xda\x84\xc4\xd8\x23" + "\x5b\x53\xca\x50\xb0\x14\x67\x89" + "\x9b\x7a\xd9\xeb\x44\x36\x8d\xdc" + "\xb4\x77\x21\xb1\xfa\xf9\x6e\x10" + "\x9c\x5d\x4d\x53\x64\xf4\x9b\xf7" + "\x0b\x36\xab\xa6\x49\xa3\x37\x25" + "\x4f\x74\x0c\xa0\x53\x42\xc5\xc7" + + "\xd4\x69\xcf\xfa\xe5\x2d\xf8\xf0" + "\x4c\x34\x75\x47\x76\x7e\x3b\x36" + "\x04\x6d\xe3\xb2\x12\xf3\x94\x68" + "\xa5\xc9\xd1\x11\xfe\xb4\x6c\x3c" + "\xf2\xe1\x08\x40\x39\xc3\xd9\x85" + "\x6c\x32\x9f\x24\xea\x85\x9a\x5e" + "\x06\x5e\x8c\x67\x0a\xc6\x35\xdc" + "\xa9\xfb\x86\x9f\x4f\x94\x8b\xc0" + + "\xb0\x4a\x75\x68\xd1\x61\xd6\x24" + "\x76\x9a\x42\x6f\x1d\xce\x1f\x80" + "\x69\xe7\x8c\xa5\x5f\xa8\x68\xc0" + "\x2b\xca\x5e\x5d\x54\x5c\xc3\xed" + "\xd1\x60\xf6\xa3\x6f\x27\x31\xea" + "\x67\x71\xfc\xb8\xbe\x4e\x18\xa0" + "\xae\xb0\x8d\x1d\x1a\xf2\x20\x0f" + "\x12\x5e\xc3\x56\x5f\x09\x6d\xd9" + + "\x5f\xaa\x33\xb7\xa9\x0b\x2f\x3c" + "\x35\xf2\x5a\xf0\xcb\x47\xce\xde" + "\xa5\x82\xac\xa2\x15\xf7\xe3\xf8" + "\x8a\xf1\x03\x22\x41\xa6\x7b\xc9" + "\x60\x10\xc1\x09\x04\x55\xaf\xc3" + "\x2d\x51\xaf\x46\x05\x2c\xea\x56" + "\x46\x81\xf2\xf3\xaf\x8d\xc2\xfa" + "\x94\xf4\x9e\x95\x3a\xb4\xfa\x87" + + + "\x5f\x10\xc5\xd4\x41\x16\x89\x09" + "\x65\xbd\x7f\x6d\x8e\x0f\xe8\x1a" + "\xb0\xbd\xe6\xbe\x5f\x22\x67\x9d" + "\x60\xd8\xc4\x7f\x59\x3b\x43\x3b" + "\x38\x56\xe8\x93\xb6\x6d\xe6\x44" + "\x2f\x86\xe9\xe3\x52\x92\xb5\xf7" + "\xec\x32\x5c\x66\x57\x51\x78\xdb" + "\x50\x2f\x36\xae\xd7\xef\x2f\x70" + + "\xc3\xb0\xef\x0f\x5d\x47\x54\x37" + "\x5d\xc3\xd7\x46\x6b\xb5\x8f\xd4" + "\xa4\x98\x37\x36\x33\xb6\x70\xa0" + "\xe6\x98\xdb\x8f\xd2\xf3\x89\xae" + "\x4c\xd1\x63\x63\xc8\x89\x0b\x97" + "\x7d\xd2\xab\x67\x21\x75\x81\x89" + "\x21\xa0\xd5\x44\x74\xd4\xf7\x9b" + "\xee\x2a\xc7\xca\xaf\x3b\x08\xb3" + + "\x44\x9a\x94\xbe\xde\x41\x97\x38" + "\xa5\x4f\x6a\x54\x88\x93\x8e\x63" + "\xdc\x7b\x04\xa0\x9c\x41\xe6\x3f" + "\xca\x57\xea\xaa\x48\xf6\x47\x70" + "\x17\xab\xfb\x41\x90\x8a\xe4\x54" + "\xa2\xdb\x6b\x57\x28\x0b\x8e\xda" + "\xdc\xfd\x2a\xc7\xbc\xee\x07\xe8" + "\xbf\x77\x25\xf4\x6d\x33\xd3\x07" + + "\x25\x09\xe2\xbf\x44\xc2\xa8\x62" + "\x67\xe8\xdc\x8f\xc3\x9a\xc1\x91" + "\x63\x70\x38\xdd\xd5\xa5\x96\x5a" + "\xf6\x24\xd3\x21\xd4\x87\xd5\x61" + "\xea\x73\x71\xa3\xa2\x73\x76\xe8" + "\x65\x8b\x77\x53\x08\x80\x84\x23" + "\x3e\xb4\xba\x05\x1e\x44\xf8\x10" + "\xbe\xef\x21\x46\x12\xfe\x11\xfa" + + "\x7b\x5d\x68\x81\x2e\x77\x7b\x04" + "\x76\xa9\x34\xbf\x81\x7d\xf2\x23" + "\xef\x48\x5f\x91\xe2\x08\x76\xc2" + "\xc3\xd5\x21\xa5\xfa\x43\x0b\x3b" + "\x84\x72\xca\x63\x26\xfb\x13\x76" + "\x37\xb8\x4d\x1d\xb4\x29\x57\x7f" + "\x6b\x52\x3b\x58\x98\x48\xb1\x87" + "\xd1\xd3\xad\xbb\xa6\x32\xb7\x00" + + "\x96\xe3\x48\x20\x26\xf4\x02\x8e" + "\xe4\x9d\x3d\x38\xb6\x50\x6b\x43" + "\xad\x85\x1e\x47\x81\x34\x8d\xf7" + "\xd6\xc8\x05\xd0\x6a\xea\x01\x8b" + "\x07\x5c\x01\x97\xee\xaf\xc7\xd3" + "\xae\xa2\x3b\x4e\xa9\xf1\xcd\x46" + "\xd2\xa1\xd3\x83\x01\xe5\x42\x7a" + "\xf4\xdf\x41\xb5\x68\x52\x4b\xd5" + + "\xbc\xe9\x23\x4e\x30\xcf\x24\x3f" + "\x24\x36\x6e\x12\x16\xf8\x87\x43" + "\x61\x6d\x0b\x3b\x03\x6a\xa4\x26" + "\x7c\x77\x2d\x8b\x45\xc8\x1b\xaf" + "\x9c\xe7\x7d\x52\xba\x01\xc4\x25" + "\xb6\xbb\x61\x42\xd4\x46\x13\x0e" + "\xc7\x4b\x7b\x28\x4b\xc4\x96\x4b" + "\x2f\x56\x54\x52\xc7\x93\x84\x65" + + "\x20\x4a\xa2\xb8\xfe\x49\xf9\x23" + "\x3f\xa5\x2c\xf5\xd1\xfe\xeb\x17" + "\x53\x48\xfb\xbc\xbe\x1b\x69\x9b" + "\x5d\xa0\x78\x62\x6b\xff\x17\x56" + "\xbd\x9e\xc9\xe3\xc5\x34\x1b\x24" + "\x6a\x15\x84\x17\x2e\x24\x64\xfc" + "\xdf\x67\x5d\x69\x2f\x48\x06\x42" + "\x11\xc0\x27\xee\x0e\xce\x67\xb9" + + "\x5d\x0b\xc8\x21\x51\x37\xdb\x65" + "\xa0\xcc\x1e\xa3\x3c\x56\x7a\x2e" + "\x7e\xa0\x38\x52\x4e\xfc\x6f\xe5" + "\x54\xd8\xce\x32\x66\x29\x6c\x3d" + "\x85\xb8\x70\xaf\x1a\x7d\x9d\xe9" + "\x59\x64\x68\x2d\xd9\xba\xc3\xaf" + "\x5b\xba\xc8\x0c\x46\xbf\x78\x9c" + "\xa3\x5a\x95\x18\x19\x95\x43\x5a" + + "\x14\xe3\xe4\x5f\xa8\x17\xb5\xf8" + "\x6f\x90\xb8\xfc\xd0\x34\x02\xe6" + "\x23\x1b\x06\xf2\xac\x42\xe5\xff" + "\x9c\xb5\x4c\x6b\x1f\x19\x7e\x28" + "\xd8\x77\xd8\x09\xdc\x7d\x85\x21" + "\x41\x89\x67\x14\x8c\x47\x23\x1c" + "\xa4\x5e\xe0\xb6\x56\xc0\xf0\xbb" + "\xfe\x94\x15\xb0\x53\x4b\xda\x82" + + "\x08\x86\xdb\xfa\x91\x67\x52\xf7" + "\xf6\xcd\x74\x7b\x2d\x83\x9e\x04" + "\x34\x0a\xb9\xc2\xcc\x81\x35\xa4" + "\x0c\xb1\x60\x93\xb8\x9e\x63\x73" + "\x1b\xa7\xe4\xe1\x1f\x33\xba\x4f" + "\x19\xf9\x72\x80\x93\x6b\xfd\x6f" + "\x32\x90\x67\x65\x1c\x27\x53\x6e" + "\xce\x72\x42\xf1\x44\x64\x20\x67" + + "\x34\x58\x33\xb2\xa3\x34\xf7\xc0" + "\x60\x68\xef\x90\x5a\x20\x26\x95" + "\x0d\xbb\xe2\x04\x17\xe7\x8b\xcb" + "\xfa\x83\xf3\x02\x1e\x87\x18\x24" + "\x57\xc1\x82\x40\x81\x76\x17\xd7" + "\x73\x00\xc2\x29\xd0\x4a\x91\xcc" + "\x28\xe7\x87\xe5\xeb\xc1\x86\xf1" + "\xfd\xd5\xbc\x61\x22\x3c\xdb\x6f" + + "\xe9\xf8\xf9\xf2\xa6\x14\xd0\x30" + "\xd2\x49\xec\x4f\x23\xce\x3e\x96" + "\xd9\xa8\x05\x96\xc5\x25\x20\x86" + "\x9a\x92\xf8\x19\x45\x44\x87\x39" + "\x6a\x47\xbf\x12\x65\xff\xb6\x01" + "\x91\x7d\xcf\x09\xd8\x64\x8a\x59" + "\xca\x56\xbe\x93\x49\x77\xec\xd7" + "\x15\x36\xb3\xcb\x85\x97\x89\x10" + + "\xad\xe3\xee\x02\xfd\x92\xa0\xb8" + "\x70\x52\x14\x30\x35\x3d\x6b\xa8" + "\x75\xb6\x12\x85\xc6\x98\x3d\x32" + "\x0f\xb4\xeb\x62\x85\xc7\x8b\x4b" + "\xde\x9c\x3f\x41\x54\x1f\x30\x7d" + "\x64\x56\xab\x2b\x4f\xfb\xe4\xa5" + "\x23\xec\xbf\x1c\x2d\x25\x2b\x1d" + "\x0d\x12\x77\xe1\xbb\x76\xd5\xfc" + + "\x34\x1a\x73\x83\x3e\x7d\x42\x04" + "\x8e\x6e\x83\xed\x8e\x02\xb9\x2b" + "\x7c\xca\x12\xb6\xf8\xcf\x6a\xb3" + "\x3a\xc7\xd9\xd3\xef\xe5\x8f\xb8" + "\xb3\x4e\xea\xed\xc6\x6b\x2a\xbe" + "\x77\xec\x8e\x48\x33\x31\xb9\x43" + "\xe1\x06\x71\xb1\x66\xf5\x1f\xf4" + "\x32\xfa\x4e\x65\x72\x91\x9e\x46" + + "\xa3\x3f\xc2\x41\x04\x0f\x48\xb4" + "\x2e\x9a\x98\xc1\xb0\x2e\x71\xb4" + "\xa7\x9c\xa2\x93\x0f\xba\xcb\x3c" + "\x8c\x42\x19\xd6\x14\x5c\x20\x6e" + "\x86\x16\x64\xb3\x57\x79\xdb\x90" + "\x4e\x8b\xac\x45\x1d\x69\x32\x04" + "\x50\x03\x4e\xf6\xac\x59\xa7\x07" + "\x17\x25\x97\x9c\x9c\xd8\x14\x05" + + "\xc3\x7f\xe6\xa8\x7f\x14\x01\x17" + "\xbe\x85\x20\xab\x8b\x0b\x2e\x9e" + "\x57\x4e\x28\xac\x24\x18\x65\xd5" + "\x64\x36\x89\x74\x25\x43\x0d\x89" + "\xa3\x68\x5e\xc5\x6e\x5e\x7c\x8a" + "\x5a\xc8\x39\x43\x0b\xe9\x12\xbf" + "\x55\xb6\x22\xf9\x85\x6b\x84\x31" + "\x00\xd7\xf4\x0b\x4d\xce\x54\x9a" + + "\x95\x42\xa1\xf1\x3a\xe8\xf4\xd7" + "\xf9\xd4\x85\xb2\x5c\x95\x6f\x91" + "\xba\xda\xff\x99\xe0\xb0\x7b\xe5" + "\x52\xd1\xb0\xea\x34\x30\xa4\x28" + "\xf8\xce\xa9\xb8\xa2\xff\x36\x0a" + "\x1a\x05\xec\xb9\x7e\x40\x17\x55" + "\x72\xe6\x68\xea\x96\x60\x79\x9c" + "\xfb\x77\x3c\xfb\xfb\xb5\x3d\x85" + + "\x1a\xa5\x64\xe8\xa9\x4b\x47\x21" + "\x8b\x1b\x8a\x6e\x99\x76\x26\x6c" + "\x28\x0a\x12\x94\x26\x36\x82\x7c" + "\xdb\xa5\x83\x83\x48\x9a\x1e\xe6" + "\x6d\x21\x84\x9f\x03\x50\xd7\x7d" + "\x85\xcd\x43\xad\x07\x0d\x02\xab" + "\x59\xc6\x12\xda\x48\xae\x37\x94" + "\xad\x52\x54\xe6\xeb\xc2\x49\x64" + + "\xc1\xd7\xf9\x2c\x1c\x4c\x7c\xcc" + "\xab\xe5\x95\xee\x6a\x88\x20\x13" + "\x0c\x17\xae\xbe\x56\x90\x7b\xbb" + "\x62\xd6\xc0\xdb\x50\xb2\xa5\xc8" + "\x03\x23\x1d\xc1\x32\x14\xd8\x4e" + "\x9f\x76\x03\x1f\x12\x69\xa6\x7d" + "\x28\x98\x53\x84\xfd\xa5\xc7\x3a" + "\x02\xdd\xcc\x3b\x94\xda\xda\x14" + + "\xd1\xb0\xf6\x7e\x21\xc3\x84\x8b" + "\x22\x3f\x93\x7c\x7a\x47\xa9\x52" + "\x82\x0b\x44\xfd\x8a\x72\xf6\x5e" + "\x5e\xbd\xe4\x6c\x59\xd8\x3b\x5c" + "\x3e\x2d\x2c\xf2\xf5\x80\x8b\x91" + "\xc5\x6c\xbb\xb7\x40\x50\x8d\x36" + "\x1c\xa1\x95\x26\xa1\x42\x61\xb6" + "\x70\xea\x19\xeb\x3a\x58\xac\x60" + + "\x37\x24\xab\x0e\x98\xbb\x7c\x31" + "\xc8\x54\x26\x5e\x55\x8c\xc0\x8c" + "\x7f\x30\xd8\xe6\x20\x65\x2d\xfe" + "\x93\x89\x42\x57\xf3\x47\xf1\xe9" + "\xf1\x6c\xfd\xd2\x14\x7d\x9c\x5f" + "\xb0\xcb\x4f\x2d\x64\xd0\xec\xa3" + "\xf7\x41\x73\x8e\xf0\xfe\x83\xad" + "\x5c\x11\x63\x3a\xa0\x23\x3f\x64" + + "\x43\xb7\x5a\xe6\xab\x78\x8a\xd3" + "\x9c\xc8\xed\x35\xb1\x75\x7c\xbf" + "\x68\xf5\x0d\x53\x2e\x75\xd8\x3d" + "\x82\xc6\x08\xe3\x76\x4a\x5c\xf8" + "\x37\xcf\x8a\xe6\xb2\x55\x99\x4c" + "\x85\xaf\x32\xab\x3d\xdf\x44\xa5" + "\x93\xf4\x5c\xa2\xf5\xc3\x8e\x4b" + "\xeb\x2f\x62\x1a\x64\x27\x8f\x4d" + + "\x49\xbc\xdc\xf0\xaa\xf7\xb4\x7b" + "\x5b\xb4\xbb\x70\xf9\x51\xe5\x7d" + "\xe5\xa2\x2c\x9f\xe4\xf3\xd0\xcf" + "\xef\x76\x5c\x1f\x09\x87\xe5\xec" + "\xae\x79\x7d\x16\xdd\x0e\x92\x32" + "\xc1\x7e\x7d\xfa\xa2\xf8\x9d\x03" + "\x91\xaf\x30\xbb\xc0\x06\x62\xf4" + "\x59\x6b\x67\x22\xf5\xe2\xf5\x1f" + + "\x66\x1d\xa5\x6e\x39\xa0\xf4\x11" + "\x26\x7a\x7d\x80\x45\x14\x6c\x50" + "\x24\x9b\x5a\x75\x05\x57\xda\x60" + "\x9e\x31\x1a\x1f\x32\xcc\xc8\x8f" + "\x7d\xd6\x33\x94\x4d\x2d\x64\x83" + "\x96\xd2\x7d\x6a\x8f\xcb\xa5\x7f" + "\x07\xde\x7b\x9b\xdb\x91\x65\x57" + "\xfb\x16\x97\x41\x25\x3d\x17\x13" + + "\xff\x40\xb3\xd5\x9d\x59\x30\xea" + "\xc5\x76\xfe\xb0\x97\x52\x6b\xfc" + "\xdc\x5a\x8f\xab\xc8\x68\x69\x1c" + "\x8d\x92\x1c\x90\xf5\xc7\x23\xf7" + "\x02\xd4\x73\x97\x21\xc3\x03\x42" + "\x47\xdd\x51\x1b\xa3\x6a\x7c\xdf" + "\x3c\xe2\x2b\x55\x7a\xe3\x49\x3d" + "\x87\x6e\x5a\x0b\xe8\xbe\xfe\x57" + + "\x39\xe7\xd8\x7b\xe4\xbe\xec\xc5" + "\x75\xbf\x63\xae\x94\x49\xd4\x79" + "\x23\x89\xfb\x38\x0f\xd0\x8b\x16" + "\x30\x31\x53\xd0\xe4\x8e\xd4\x75" + "\x33\xdf\x5c\xdb\xaa\x77\x4f\x55" + "\x69\x67\x69\x3c\x96\xe8\x96\x33" + "\x4e\x67\xfd\xd3\xf2\xdb\xdd\x2f" + "\xe5\xe3\xd0\x99\xee\xf6\xb8\xbb" + + "\x70\x2f\xae\xcb\x51\x06\xb9\x51" + "\xeb\xa8\xaa\x93\x05\xbc\xc4\xef" + "\x99\xf4\x1d\xdd\x89\x86\xcd\x8e" + "\xa5\x67\xf3\x22\xa8\x99\xee\x1a" + "\xc5\x74\x82\xae\xb9\x85\xd4\x95" + "\x9c\xb3\x30\x7d\x45\xd4\x14\x6c" + "\x81\xef\xc1\xbc\x0b\xa9\xfe\xba" + "\xed\xa2\x59\xa4\x7a\x31\x5f\x7c" + + "\x27\x42\xf4\x4e\x75\x10\x21\x01" + "\x96\xf4\x20\xdc\x6e\xed\x7b\xa1" + "\xcd\x53\x98\x81\x24\xe4\xdf\x0c" + "\xe7\x2c\x1e\xf7\x98\x32\x79\x13" + "\x7b\x30\xbe\xdb\x78\x30\x1f\x3c" + "\x36\x99\xee\x76\x0e\xc2\xd1\x6d" + "\x20\xaa\x3c\x42\x57\x4b\xee\x23" + "\x0e\x84\xfb\x8e\x3b\x79\xc3\x4a" + + "\xa0\x8c\x1f\xed\xeb\x38\x44\x93" + "\xa2\x25\xbb\x4e\x58\x66\x54\x3e" + "\x6f\x89\x69\xc0\x0e\xaf\x15\xc4" + "\x3d\xa4\x5a\x9a\xb0\xdd\x3e\xc1" + "\xf6\xb8\x9e\xd4\x4f\x20\x04\x7a" + "\x70\x16\x4f\xd7\xfc\xbd\xd5\xd0" + "\x58\x05\xfc\x56\x86\xe2\x97\x36" + "\xde\xba\xce\x01\x71\x73\x20\x10" + + "\x2b\xa8\x47\x06\x90\xe6\x87\x5f" + "\x4f\x05\x40\x8f\xd4\x0e\x8e\x90" + "\x03\x38\x85\x79\xd4\x33\xf6\xa9" + "\x52\xb2\x28\x4a\x9a\x3c\xd1\x8e" + "\x64\x0f\x46\x1f\x76\xf6\x2e\x3e" + "\x36\x63\xd0\x36\x9b\x0b\x93\x53" + "\x9b\x97\xc4\x8f\xac\x73\x70\x34" + "\x97\x55\xcd\x5e\x0e\x0e\x38\x84" + + "\x39\x3c\xfe\xc4\x6b\x2c\xb2\xe3" + "\xdf\xeb\x7b\x6c\x53\x81\x4a\xba" + "\x59\x34\x69\x25\xb7\xb6\x3a\xf2" + "\x11\x2b\x92\x14\x70\x37\xbc\x53" + "\xdb\x60\xfc\x5a\xab\xc8\x45\x46" + "\xa3\xf2\xb9\x20\x55\x23\x02\xaa" + "\x07\xc5\x0f\xce\x4c\x95\xa2\x52" + "\xe7\xc2\xe1\x7c\xbb\x31\x27\x8c" + + + "\x89\xb8\x8f\xe4\xc2\x91\x70\x6a" + "\x06\x9d\x8a\x7b\x13\x2c\x88\x26" + "\xe2\xa0\x82\x1b\x63\x86\x49\xa2" + "\x2d\x15\x18\x35\x36\xd7\x4e\x84" + "\xc7\x27\x6e\xd8\x6f\x47\x2f\x28" + "\xdc\xef\xaf\x04\xca\xda\x4e\xa0" + "\x4d\xe3\x19\x61\xbc\x6e\x25\x8b" + "\x8b\xd7\x87\x07\xe9\x13\xa4\x56" + + "\x50\xbe\x74\x5a\x1d\x06\xee\x82" + "\xf5\x6f\xa1\xde\xc4\x81\x17\xe4" + "\xa2\xc8\xbf\x99\x1e\xc8\xb0\xe0" + "\x2d\x7e\x54\x0b\x69\x4d\x4f\x62" + "\xe4\x9a\xcc\xbd\x5d\x54\x83\x3a" + "\x8e\x1e\x9b\x40\xb6\xdb\x73\x25" + "\x39\x35\xc9\xa6\xc4\x60\x29\x48" + "\x98\x87\xe1\x5a\xad\x59\x10\xf0" + + "\x96\x9d\x55\x4d\x27\x1e\x15\x38" + "\x01\x6c\xdb\xb8\xd3\xc0\x18\x4f" + "\xaf\x21\x99\x6f\x83\xaa\xa3\x49" + "\x29\x60\x04\x8c\x7b\xb2\xea\xdb" + "\x3b\xbf\x40\x70\xaa\x9e\x2b\x24" + "\x91\xb0\x14\x16\xe5\x79\xc4\x39" + "\x5d\xaf\x4b\x0e\x2b\xde\x8e\x33" + "\x45\x39\xa5\xf0\xb7\x92\xb1\x5b" + + "\x5f\x79\x12\x31\x97\x9f\x5c\x71" + "\xe1\x6e\x4e\x98\x37\x44\x24\xe8" + "\xcd\x6b\xb6\xec\x58\x48\xcb\x55" + "\xee\xfb\xaf\xab\x35\x67\x13\x7c" + "\x8e\xc3\xbe\x5d\x95\x15\x66\x54" + "\x53\xd1\x8a\x38\x2c\x78\xc0\x51" + "\x2f\x95\xe0\xc6\x3a\xc5\xa4\x9b" + "\xa8\xdf\x21\x1b\x2a\x78\xe6\x27" + + "\x65\x7f\x5d\xec\x51\xc2\x89\x7d" + "\x87\x40\x39\x90\x16\x56\x8f\x0c" + "\xb3\x1a\x69\xf0\xfc\x1c\x9e\x60" + "\x21\x0b\xb2\xe9\xbf\x00\x03\x2a" + "\xf4\xfa\x14\xb1\xad\x2f\x53\xbf" + "\xd1\xf5\x1b\x52\xb9\xc0\x8f\x32" + "\xde\x36\xfc\x3b\x3c\xf9\x51\xbd" + "\x60\x5f\x4e\x7a\x0e\x05\x89\xd9" + + "\xc2\xdb\xd2\x4e\x3d\x90\x2f\x68" + "\x83\x2d\x3b\x7c\xc8\x59\xba\x0e" + "\x35\x93\x7e\x9c\x4d\xc8\x9d\x8e" + "\xd7\x26\xb2\x0e\xb0\x21\x9b\x5f" + "\xae\x7b\x26\xaf\x94\xd3\x3b\xe3" + "\xae\x15\x2e\xbe\x25\xcc\x86\xaa" + "\x00\xc5\x8e\x6a\x7d\xf6\x0b\x4f" + "\x58\x06\x63\xf9\x44\xaa\x46\x58" + + "\x78\xc2\xe0\xe7\x38\xba\x86\x67" + "\x6f\x2e\x8b\x58\xce\x87\xbf\x09" + "\x3a\xee\x5f\x46\x22\x70\x3b\x72" + "\x94\x23\x68\x64\x14\x41\xb8\x08" + "\x29\x46\xe6\x29\xe0\x2c\xb5\x0e" + "\x43\x8e\xa7\xcc\x8f\x0e\xb6\xad" + "\x91\xa9\x54\xb6\x62\x70\xdd\x20" + "\xe5\x6f\x9a\xc6\x28\xd4\x81\x42" + + "\x15\xbf\xc2\xe2\x40\x97\xb0\xfe" + "\x04\x97\xe9\xa9\x05\x22\x7a\x62" + "\x65\xc5\xfb\xc2\xd0\x73\x8d\xec" + "\xe8\x8d\x0c\xc2\x8f\xed\x3e\x22" + "\x49\x3b\x36\xa8\x83\x25\xe3\x1e" + "\xa6\xb0\xc2\xc9\xb9\x6c\x0b\x1a" + "\x5c\xc8\xdb\x90\xd2\xc3\xf7\x49" + "\xac\xc1\xf4\x1e\x97\xbb\xdf\xa8" + + "\xe1\x2e\x1e\xc0\xa3\x7c\x25\x5c" + "\x61\x69\xc3\x27\x14\x3a\xb4\x1f" + "\x24\xf3\x72\x34\xcb\xa7\x94\xd5" + "\x10\xbe\x0a\x66\x24\xc0\x5e\xc1" + "\xed\x4c\x61\x6b\x49\xd4\x76\xb1" + "\x85\xb8\xdb\x62\x4d\x73\x04\x0b" + "\x87\xb5\xdd\x36\xc6\x53\xb7\x2c" + "\x0c\x34\xcd\x14\xe6\x80\x1c\x9a" + + "\xab\xc2\xc7\x65\x4c\x4d\xb3\xaf" + "\x84\xea\xc5\xe2\xe7\x10\x46\x1d" + "\xb5\x4a\x3c\x97\x1b\x6d\x3f\x89" + "\xc4\xa5\x5b\x94\xe9\xd7\xcd\xa3" + "\xee\x17\x44\x06\x83\x49\x51\x60" + "\x2b\xdf\x6b\xad\x3c\xb2\x59\x14" + "\xc3\x26\xf7\x5c\x41\xc3\xb2\x23" + "\x4a\x35\xd6\x32\x35\x96\x82\x3a" + + "\xcd\xe7\x6f\xc0\x96\x56\xf6\xe9" + "\x15\x3a\xfd\x9a\x57\x30\x06\x51" + "\xed\x60\x53\x18\xa6\xac\xcd\x3d" + "\x2f\x3d\x85\xc1\x3d\x70\x41\x27" + "\xa0\xf1\x33\x1a\x4a\xd8\x8a\xbd" + "\x7c\xb0\x5c\xc3\x8c\x69\x6c\x5f" + "\xb9\xe6\x61\x65\x19\xd1\x2b\x21" + "\xd7\x4f\x7b\x61\x7e\xcd\x49\xf1" + + "\x18\x2c\x19\xab\x1f\x90\x4f\x29" + "\x4f\x16\x30\x70\xfe\xcb\x5f\xec" + "\xa6\x6b\x24\xe2\xb7\xfc\xe2\xe2" + "\x0c\x1a\x1a\x22\xb3\x88\x7c\x1e" + "\xc5\x88\x2d\xc9\x93\xdd\xc7\x72" + "\x59\xfb\x06\x11\x8e\x14\xc2\x41" + "\x14\x0f\xf6\xa0\xf5\xd4\x7d\x54" + "\x31\x0f\x96\x63\xb2\x52\x9b\xed" + + "\xf8\x2b\xe8\x30\xc5\xc9\xe3\x1c" + "\x2a\x77\xbb\x0d\x42\x25\x66\x4d" + "\x14\x72\xc1\xd9\x60\x5a\xe2\x19" + "\x55\xfa\x22\x77\x4c\xf8\xbc\x13" + "\xa7\xf7\x9e\xf8\x0e\xca\x8a\x22" + "\x55\xd4\x3e\xfd\x2f\x4e\xd6\x03" + "\x04\xc9\xe6\xdd\xf5\x90\xc3\xf1" + "\x8a\xe1\x78\x76\xa6\x52\x14\x73" + + "\x58\xb3\xa5\xb0\xeb\x49\x83\x6c" + "\xd6\x2e\x7e\x9e\xc2\xc5\x54\xb1" + "\xdb\x62\xa4\xed\xcf\xec\xd5\xca" + "\x69\x6b\xe6\x2d\xe4\xdb\xd6\xf2" + "\xb2\xe5\x65\x86\xf3\xed\x6a\x42" + "\x23\x57\x7f\x7b\x13\x85\x8a\x48" + "\x86\xb3\xcb\x8b\xb3\x43\xcc\x15" + "\x79\xd8\x91\xd7\xf3\x0a\xad\x27" + + "\xba\x2c\x63\xa0\x61\x6e\x00\x3c" + "\xcd\x5c\xb3\x45\x48\x92\x0d\x92" + "\x65\x7f\x5c\x7c\xfb\x79\x33\x4b" + "\x0b\x05\x5e\xb0\x10\xdf\x6c\x52" + "\xae\xf1\x1b\xd2\x36\xe9\x88\x31" + "\x2f\xbd\x4b\x62\x39\x7b\xe0\xb3" + "\x41\xa5\x67\x13\xf3\xfc\x9b\x7b" + "\x27\x79\x36\x8a\xc8\x8e\x9f\x03" + + "\x4f\x36\x6e\x84\x6e\x23\x6c\xc1" + "\xa0\x0c\xa5\xde\x7c\x52\x33\x7f" + "\x6d\xb8\x26\x09\x75\x07\x81\xc4" + "\x0c\xe7\x98\x05\x09\x36\x2a\x6c" + "\x24\xe9\x24\xf0\x52\x5e\x75\xa6" + "\xca\xaf\xb4\x9d\xa4\x07\xfa\xe0" + "\x90\x17\x83\x66\x7d\xce\xc3\x15" + "\xd6\xb0\xcb\xa6\x50\xf3\x4e\x5b" + + "\xf4\x82\x69\x43\xe0\x04\x85\x34" + "\x79\xec\xe3\xd8\xee\x05\x49\xc9" + "\x9e\x17\x09\x35\xcb\xfd\x2c\xb9" + "\x14\xd9\xe6\xf9\xd0\x66\x52\x24" + "\x55\x69\x31\xad\xd0\x50\xaa\x8b" + "\x60\x7f\x22\xca\x79\x5c\x23\x77" + "\xd8\xf9\xe5\x51\xc9\x27\xc9\xf2" + "\x0f\x94\x79\xe6\x30\x8c\xbf\xeb" + + "\x69\x59\x20\xb6\xc4\xaf\x4a\x2c" + "\x4f\x85\xc7\xf6\x02\x3f\x56\x42" + "\x48\x3b\x98\x1d\xd5\xce\x6a\x01" + "\x55\x97\x94\x99\xd8\x56\xb3\xfe" + "\xd7\x9b\xa3\xd1\x81\x2c\x2a\x8c" + "\xe9\x4a\x93\xe6\x0f\x34\x44\x8f" + "\xda\x04\x79\x44\x1c\xf9\x8c\x14" + "\x26\xa9\x51\x0f\x5f\x18\x40\x73" + + "\x90\x69\xac\xce\x66\x5f\xe9\xe4" + "\xce\x16\x6c\xbe\x16\x1d\xdc\x17" + "\xbe\x0c\xad\x45\x55\xa0\x67\x29" + "\xb6\x7e\x6f\x71\x97\x2f\x0e\xdd" + "\x91\x3b\xc3\x2d\xf3\x7f\x8b\x33" + "\xde\x76\xe9\x2f\xf5\xae\xf6\xdc" + "\x6e\x3f\x19\x43\x1c\xf7\x1c\xf5" + "\xe3\x77\xc0\xe8\xc4\x44\xe4\x15" + + "\x46\xab\x09\x74\xfb\x00\x8f\x2f" + "\xb2\x89\xe2\x80\xe6\x78\x7e\x05" + "\xd1\xe5\x88\xa8\x2c\x02\xe5\x03" + "\xe2\xe4\xed\x9d\x1a\x11\x87\x3c" + "\x0b\x46\x09\x78\x1c\x0e\x9b\x5b" + "\xc7\xab\xc9\x71\x52\xc8\x51\xe7" + "\xc9\x1d\xcc\xc7\x28\x4e\x94\x8b" + "\x08\xfa\x3c\x1d\xfa\x1f\x20\x4f" + + "\x49\xc0\x9f\x0f\x2d\xfe\x78\x60" + "\x1a\xd1\xf6\x40\x50\x97\x9d\xd9" + "\xb7\xc0\x54\x08\x97\x9a\xae\x87" + "\x79\xfb\x02\x93\x9c\xb0\xce\xf4" + "\x3f\xa8\x32\x2c\x68\x01\x2f\x50" + "\x24\x50\x68\xb1\x71\x27\x35\x1e" + "\x19\x2b\x79\x66\xf2\xf6\x0d\x97" + "\xfd\x87\x8d\x9c\xbb\xd0\x07\xf5" + + "\xce\x21\x67\x3e\x5c\x90\xfc\x02" + "\x4c\x67\xb3\xd0\xda\x70\x2d\xd5" + "\xa4\x0d\x81\x18\xca\xe5\xc2\x5d" + "\x99\xdd\x69\x5c\x73\xb2\x84\xa9" + "\xa4\x5c\xde\x84\x27\x25\xb9\x63" + "\xc4\xde\x52\xc8\x72\x98\x1c\x2f" + "\x09\xde\xe3\xc2\x93\x35\xb0\x18" + "\x2f\xdc\x13\x98\x01\x0b\xd7\x19" + + "\xb2\x38\x63\x42\xce\x40\x4e\x15" + "\xc9\x88\xaa\x96\x00\xb0\x2c\x7b" + "\x25\xf9\x51\xad\xfc\x01\xc9\xd5" + "\x10\xee\xd0\x7e\x6c\x21\xbd\x5a" + "\x64\xe1\x7d\xf8\x57\xd5\xc3\x73" + "\x6d\x51\x39\xe1\xdc\xd1\x3a\x69" + "\x7a\x54\xbd\x3e\x3a\x7b\x76\xb4" + "\x82\xa9\xf4\x20\x4c\xc2\xb3\xb8" + + "\x29\x1d\xdc\xa6\x2d\x6b\x80\x42" + "\x44\xe1\x71\xf8\x09\x00\x03\xd3" + "\x76\x92\xf4\xaa\x33\xb3\xfe\xa1" + "\x4b\xc0\x0b\xc7\x9e\x3b\x58\xb5" + "\x20\x5f\x69\x95\x78\xbe\xb0\x1d" + "\xb5\x12\xd0\x89\x11\x18\x84\xfc" + "\x43\x16\xf6\x05\x72\xf2\x09\x64" + "\x28\x31\x88\xd5\x74\x41\xd3\x40" + + "\x7b\x7c\x56\x08\xcd\xa0\xfb\x64" + "\x54\xfb\xcb\xa2\x0d\x59\xea\xc9" + "\x73\x0d\x6d\x13\x16\x77\x6f\x66" + "\x0d\xa3\xf2\x38\x48\x96\xa0\x2c" + "\xa9\x0c\x4e\x0f\x24\x45\xa5\x7f" + "\x4b\xb8\xbe\xc1\xa8\x01\x33\xef" + "\x2a\xb9\x62\xbc\x0e\x93\xcb\x45" + "\xea\xcb\xb6\x9b\x05\xc7\x4a\x96" + + "\x33\x98\x41\x67\xf5\x96\x91\xd7" + "\x08\x7b\x3b\x86\x52\xe2\x59\x60" + "\x0c\x70\x56\x1c\x17\x18\xda\x84" + "\xc4\x3e\x8d\xb2\x56\xee\x58\x57" + "\xa6\x0e\x3b\x01\x1d\x77\xa2\x7d" + "\xb9\xe9\xc5\x54\x4b\x52\xdf\xfd" + "\x80\x5d\x30\x24\xf8\xfa\xf4\x7d" + "\x3f\x76\x97\x3a\xbf\xc1\xf5\x58" + + "\x1f\x26\xf5\x81\xcc\x71\xf6\xea" + "\xef\x83\xfe\xbc\x06\x35\x08\x7d" + "\x6e\x53\x88\x31\x0b\xc5\xcd\x94" + "\xcd\x3e\xdd\x24\x41\x2c\x0b\x41" + "\x0c\x52\x05\x02\xcc\x99\xcb\x57" + "\x6d\x44\x06\x5f\x68\xa2\xf3\x23" + "\x17\x4b\xa0\x49\x43\x7e\xb2\xb2" + "\x12\x5a\x78\x81\xf3\x66\xb2\xab" + + "\x42\x60\x69\x7c\xf1\x37\xaf\xa5" + "\xde\x38\x25\x4a\x2c\xa2\xcb\xd4" + "\x00\x26\xa4\x9e\x95\xb9\x1c\x21" + "\x89\x98\x06\x7b\x41\x5f\x10\xcd" + "\x74\x1e\xb8\xdd\x19\xcf\xe1\xb1" + "\xca\xb8\x57\x51\x89\x2d\x2f\x47" + "\x85\xb8\x9d\xee\x08\xb0\x6f\x08" + "\x31\xd1\x26\x0f\x70\xd5\x5c\x36" + + "\x5a\xfe\xb7\x66\x5d\xba\xa7\x00" + "\x56\x5d\xfd\x05\xac\x74\x86\x81" + "\x57\x5a\x14\x04\x3c\xb0\x8f\x68" + "\x2c\x83\xd5\x97\x88\x65\xc1\x76" + "\xa7\xab\x45\x12\xd8\xdc\xf0\xa0" + "\xe9\xf6\x47\x18\xaa\x7c\x07\xdd" + "\xd0\xad\x34\x0d\x14\x53\x03\xf9" + "\xed\x3d\xb7\x48\x11\x7c\xe3\x22" + + "\x53\x70\xbe\xa2\xbb\x02\x4b\x28" + "\xd6\xa6\xb9\x7a\xc6\xf7\xbb\xdc" + "\x30\xa5\xf7\x20\x9c\x55\x25\x44" + "\xc8\x67\x87\x18\xfa\x2d\x1f\x96" + "\xc4\x80\xdc\x70\x35\x94\xfd\xe2" + "\x20\x41\x78\xf0\x63\x6b\x4d\x10" + "\x22\x71\x56\x53\xc1\x2b\x59\x7f" + "\x77\xad\x88\xf6\x46\x12\xbc\xf6" + + "\x06\xb0\x0a\xb7\x6b\x43\xfe\xfd" + "\x1d\x1a\x99\x18\x19\xd1\xe7\x57" + "\xb0\xc0\xd4\x34\x28\x42\x54\x3a" + "\x04\x84\xb5\x32\xd4\x1d\x09\x26" + "\x99\xf8\x2a\x27\xfc\x6d\x11\x8b" + "\x77\x87\x11\x34\x87\xdc\xf8\x51" + "\xbc\xf0\xa7\xdf\x40\xa3\xf0\xc0" + "\xdd\x97\xad\x56\xf6\xa5\xc5\x22" + + "\xe9\xdd\x15\x0f\x05\x4c\x21\x05" + "\x82\x2b\x5f\x0d\xa8\x76\x7a\xa4" + "\x62\x2b\xe8\x62\x30\x4d\x25\xbb" + "\xee\x55\xc9\x3e\xe0\x5f\xa0\x11" + "\x36\x9b\x52\x9d\x6e\xf4\xaf\x7e" + "\xf6\x3d\x9e\x8f\x01\x13\xab\x55" + "\x98\x76\x31\x99\x71\xe3\x63\xc4" + "\xad\x47\xda\xcc\x38\x14\x25\xfd" + + + "\x4e\x89\xfb\xdb\xf3\x22\x31\xe1" + "\x18\x4b\x27\xce\xf6\x79\x9b\xbe" + "\xdf\xaa\x58\xca\xe5\x9d\xa4\x85" + "\x51\x73\x48\x11\x58\x77\x95\x24" + "\x99\x90\x93\xbb\x61\xef\x1d\x11" + "\x94\x36\xd1\x26\x4a\x97\x6a\x1d" + "\x3b\x25\xfc\xd3\xce\xb4\x74\x44" + "\x5e\xb1\x5d\x4c\xe6\x85\x14\x3a" + + "\x18\x6f\xd6\x1e\xec\x86\xde\xeb" + "\x43\xce\x1f\xd6\x6b\x90\x5d\x22" + "\x4d\xd7\xbe\xe8\xd6\x07\xab\x5c" + "\xb7\x5a\x85\x27\x7f\x61\xe4\x16" + "\xdd\xc3\xfb\xb2\xdd\xaa\x68\x65" + "\x5b\xdf\xed\x8a\x4f\x48\xb5\xed" + "\xad\x2f\xcf\x6d\xe8\x20\x8f\x87" + "\x99\x56\x5f\x61\x7c\x49\x16\x35" + + "\xe2\xac\x7b\x70\xe8\xae\x58\x51" + "\x56\x1c\x6d\xf8\xc6\x14\x8d\x45" + "\xe2\xbe\xb9\xc1\x5c\xf1\xeb\x15" + "\xc0\x9c\x37\x0f\x66\xdf\x15\xa0" + "\x61\xd1\x2e\x20\xa3\xeb\x4c\xb2" + "\xf0\x3d\x4b\x20\x87\xf6\x58\x45" + "\x04\x4c\x26\xbe\xed\x8e\x0e\x89" + "\xb7\x8b\xde\x90\x10\x87\xb7\xb5" + + "\x69\x1e\x18\xfa\xec\x3f\x0a\xef" + "\x98\x9a\xd6\x30\x81\x2f\xa0\x9e" + "\x5d\xb9\xea\x66\x8e\xcf\xe9\xb2" + "\x21\x00\x72\x24\xeb\x2b\x0f\x52" + "\x61\x43\xf8\x1d\x0a\x54\x1c\x62" + "\x5d\x6d\xfa\x71\x21\x77\x03\x12" + "\xff\xf6\xf5\x0f\x51\x7b\x3c\x6e" + "\xf3\xbe\xb2\xab\x9b\x06\x7a\x81" + + "\x05\xcd\x81\x97\x11\x2f\x2b\x7e" + "\x2b\xa1\xaf\x7e\xe2\xc2\xa8\x77" + "\x5e\x38\x81\xa3\x3c\xd0\xfd\x78" + "\xad\x85\xab\x15\xbb\x54\x3b\xab" + "\xd4\x8a\x1c\xcf\xaa\x55\xbe\x48" + "\x81\xbc\x8a\x52\x58\x0c\xa6\x57" + "\xb3\x93\x68\x4a\xfe\xb5\xaf\xf8" + "\xcb\xcc\x66\x9a\xcf\x79\xd1\xbd" + + "\xb1\x09\x6c\x65\x77\x7d\x4f\xf1" + "\x00\xdf\xa9\x29\x95\xac\x40\x4b" + "\x33\x38\x10\x14\x82\x48\xdc\xe9" + "\xc7\x45\x17\x42\x33\x32\x63\x4c" + "\x69\x03\xc2\x75\xc5\xcc\x2f\xd2" + "\x36\x0c\x37\x89\xa5\x42\xf2\x47" + "\xcf\xec\xda\x4e\xae\x16\x8c\x1e" + "\xc4\x78\xcf\x4f\xb0\xab\x8e\xad" + + "\xcf\x98\xc5\x9e\xba\x05\xe6\x3d" + "\xae\x29\x30\x4d\xae\xd3\x33\x19" + "\x16\x05\x14\x9b\xbd\xfa\xf2\x6b" + "\x1c\xd0\xa7\x59\x55\xfc\x2d\x71" + "\x66\x63\x57\xd2\xe0\xaa\x3e\xff" + "\xf8\x1c\x70\x48\xf9\x07\xe4\x36" + "\xd4\x4b\x1f\xb4\x89\x1d\xe2\xed" + "\xa9\xef\x6e\x66\x5c\x2f\x29\xc5" + + "\xa6\xcd\x94\xb2\xb6\x2f\x57\x83" + "\x34\x9f\x03\xb9\x75\xbf\xe9\x6c" + "\x21\xbb\x5c\x09\xf0\x12\xe0\x20" + "\xda\xf0\x63\xd0\x1b\xcc\xae\xa0" + "\xe5\x09\x29\xf0\x3a\x1c\xc2\x57" + "\xdc\x9c\xce\x48\xcf\x9e\xd5\xc7" + "\xf8\x36\xe3\x8a\x44\xb8\x32\x27" + "\xf4\x85\x4f\x3f\x23\x37\x6e\x05" + + "\x52\xa8\x78\xef\x21\x5d\xb7\xf2" + "\x00\xa9\x31\xdd\x34\xcd\x38\xba" + "\x8a\xe1\xff\x58\x86\xa6\xb3\x72" + "\x45\x57\xd9\xbf\x0c\x19\x64\x74" + "\x81\x6e\xed\x77\x21\x53\x6e\x40" + "\xab\x5e\x53\xde\x5b\x97\xf0\x1a" + "\x82\x4c\xc5\x60\xc7\x22\xba\x66" + "\xe0\x2f\x0a\xb0\xce\xb1\xe3\x88" + + "\x15\x7b\x33\xf0\x77\xf9\xb7\x55" + "\x3a\x97\x94\x0e\xa3\x72\xc8\x3b" + "\xa0\xee\x0d\x77\x83\xd9\x4a\x62" + "\xdb\xef\xa5\x13\x64\x33\xab\xca" + "\x47\x42\x0d\x7a\x02\xd0\x1d\x39" + "\xd5\xae\x12\xf3\x5d\x0d\x59\x39" + "\xac\x65\x13\x35\xc9\x02\x28\x53" + "\x2a\xe2\xa2\x78\x45\x82\x2e\xdd" + + "\x87\xe6\xbe\x2e\xa5\xa6\xc6\x98" + "\x31\xc7\xc1\x56\xfa\x5b\xf6\xcd" + "\x10\xf2\xde\x72\x27\x13\xe8\x48" + "\xa5\xb5\x83\x80\x41\x19\xa1\x4e" + "\x25\xb5\xeb\xff\x4f\xea\xdc\x3f" + "\x72\xbf\x50\xfb\x19\xea\xaa\x55" + "\x0c\xb4\x85\x2a\x0a\xdc\xbe\x5f" + "\x9f\xf2\x44\xbf\x54\xd9\x6f\x0d" + + "\xca\x00\xe8\x89\x31\xb5\x10\x8a" + "\xfd\x08\x52\x14\x17\x0c\xfe\x50" + "\x37\xba\x14\xb7\xd3\xc0\x43\x9e" + "\xcc\x9a\x18\x34\x0e\x20\x7d\x42" + "\xc0\xe2\x16\xe6\x4f\xe2\xde\x05" + "\xc1\x54\x18\xee\xc8\xf4\x25\x9c" + "\x73\x2a\x34\x8f\xa5\x22\x32\x4d" + "\x52\xc9\x27\xa0\x4f\x80\x07\x08" + + "\x6f\x32\x8f\x2e\xf8\xb7\xbf\xba" + "\x19\xa5\x25\x56\x22\xac\x9c\xed" + "\xa9\xe0\xda\x0e\x1a\x9c\x10\xf1" + "\x59\x12\x52\x58\x98\x0a\xf8\x45" + "\x44\x1f\xb7\x5a\x07\x4b\xa4\x37" + "\x1b\x16\x21\x4a\xb6\x9e\x69\x21" + "\xee\x67\xfe\x56\xdf\xfd\x23\xb5" + "\x2e\xf7\xb9\x20\x21\x3a\x5c\x9f" + + "\x73\x6e\xd2\x50\x33\x4a\x41\xba" + "\x88\x26\xf7\x75\x94\x44\x69\x45" + "\x82\x0f\x55\xb1\xe3\xa6\x82\xd4" + "\x7e\x6d\x16\x43\xe6\xf7\x7f\xde" + "\x2a\x22\x94\x9c\x68\xc6\x97\xad" + "\x40\x98\xfa\x72\x2d\x92\xa5\x90" + "\x5f\xaa\xe6\x32\xbd\x86\x18\x37" + "\x44\x0d\x5e\x7f\x67\x4f\xbd\xf1" + + "\xc5\x19\xa3\xfb\x76\xb2\x8e\x05" + "\x4a\xa5\x7f\x7f\x12\x91\x3a\xd3" + "\xab\x2d\x2a\x93\xb4\xc1\x60\xf0" + "\xbf\xd9\xc7\x79\x4e\x22\x3a\xce" + "\x23\x28\xa9\x0b\x8c\x38\xb0\x6f" + "\x81\x78\x78\x69\x8a\x73\x31\x8d" + "\xb7\x00\xcd\x03\x02\xeb\x86\x2d" + "\x1b\x91\x69\x2b\x51\x44\x6e\x4e" + + "\xf3\x56\x0d\x4f\x3a\x65\x22\xc2" + "\x05\xb8\x28\xca\x47\x40\x1e\x96" + "\x4b\x43\x73\x4a\xb0\xf8\x03\x2c" + "\x19\x2a\x71\xab\x87\x67\x96\x4c" + "\x42\xee\x4f\x86\x42\x6c\x19\xcc" + "\x5c\xce\x0e\x5b\xda\x93\xbe\xc1" + "\x59\xc1\x31\xc1\x22\x9f\x7d\xa8" + "\x55\x56\xe4\xdc\x93\xd5\xb6\x2b" + + "\x42\x40\x89\x4c\xa9\x5a\x95\xec" + "\xed\x92\x2f\xf2\x9a\x17\x32\x9d" + "\x08\x65\x28\xfa\xf0\x0f\x02\x5e" + "\xda\x1c\x9b\x23\x3a\x86\x49\x46" + "\x8f\x45\xf1\x11\x92\x1b\x71\xa5" + "\x6d\x35\x9b\xde\xec\x93\xd4\x7d" + "\x94\x81\xad\x80\x82\x06\xf9\xe4" + "\x73\x97\x30\xfe\xc1\x7a\x86\x81" + + "\x3c\x91\x78\xad\xfe\x96\xdd\xe9" + "\xb5\xb7\xee\x86\x14\xb5\x5e\x32" + "\x8e\xb0\x93\xa1\x61\x74\x74\x85" + "\x41\x35\xdc\x5a\xaa\x0d\x84\xf5" + "\xda\x9f\x36\xdb\x44\x0c\x1d\xc1" + "\x05\x92\x75\xad\xd9\x4a\xb1\x3a" + "\xa2\xaf\x8f\x03\x3d\x9a\x3f\x53" + "\x04\xf7\xe3\xfd\x53\x65\xdf\xfd" + + "\xc6\xa4\x15\x29\x90\x69\xaf\xbe" + "\x11\x1c\xc3\x37\x4d\xc0\xdb\xd5" + "\xc8\xcb\x1f\x28\xba\x2a\xa7\xa7" + "\x21\xe6\x4a\x3f\x8d\xf2\x78\xa1" + "\x95\x08\x8d\x9b\x76\xdc\xdd\x23" + "\xd0\x06\xb2\x93\x84\xd7\xae\x88" + "\xe4\xa4\x32\x0e\x09\x1a\xe6\x6e" + "\xf4\x03\x2f\x26\x3b\x2e\x48\x1d" + + "\xce\xb7\x09\xb8\xc9\x9e\xc4\x22" + "\x2c\x2c\xc7\xe2\x6b\x48\x41\x8a" + "\x36\xbf\xa0\xfe\x20\x94\x3b\x81" + "\x69\xac\x6d\xa6\xe9\x6e\xd3\xb3" + "\x87\xc9\x8c\x32\x8a\xc0\xdd\x6f" + "\x61\x64\x32\x3a\x2c\xcd\x3b\x0a" + "\xba\xdb\x10\xd8\x9d\xc4\x03\x71" + "\xc4\xa4\x78\x4b\x28\x1a\xd8\xf9" + + "\x99\x0b\x18\xdd\xe8\xd8\xd1\xfe" + "\x49\x39\x3a\xd3\x3f\x33\x8c\xdd" + "\x99\x23\xb7\xb9\x2d\xdf\xdf\xcd" + "\x26\x55\x78\x8c\x3e\xe5\xa6\xad" + "\xb4\xe1\xbd\xc1\xed\xbf\xdf\xa0" + "\x4e\xd5\x77\x24\x81\x6b\x43\xc7" + "\xe8\x45\x32\xe7\x41\xd6\xec\x27" + "\x90\xcc\x97\xe0\xf1\x77\x8f\xb6" + + "\x66\x5c\x62\x2b\x1e\x62\xa3\x1a" + "\x0f\xe5\xea\xa9\xae\x5d\xdc\x48" + "\x58\xa1\x52\x7d\xc2\xac\x06\x57" + "\x5c\xa2\x91\xa9\xa2\x51\x15\x0a" + "\xeb\xb4\x0d\x97\x6a\x04\x54\x46" + "\x4b\x7e\xff\x35\x4d\x4d\xbe\x2b" + "\xb9\x2f\xa6\x18\xe7\x6a\x85\xd9" + "\x8e\xd3\xa7\x10\x04\x16\xa0\xac" + + "\x89\xdb\x76\x7a\xeb\xbb\xa0\x6b" + "\xf5\x2a\x35\x13\xbd\xc3\xc5\x1b" + "\x08\xbd\x44\xdd\x18\xfe\x3e\xb8" + "\x49\x24\xd8\x8d\xa7\xbe\xd6\x4b" + "\x0e\xd9\xf9\xda\x24\x31\x97\x4a" + "\x4c\xd8\x32\x33\x0c\x89\xdb\x6e" + "\x1b\x84\xbb\x9b\xe6\x39\x3e\xc2" + "\x6d\x3e\xae\x07\x45\x35\x8f\xc3" + + "\x41\x59\xd5\xe4\xad\x65\xe8\x3d" + "\x87\x40\x38\x30\x5e\xfa\xda\xde" + "\x9b\x8b\xf1\x4e\xbb\x4a\x41\x6f" + "\x68\x52\xee\xfa\x42\xea\xe9\x9e" + "\x4a\x5a\xa5\x37\x16\xaa\x0f\x26" + "\xb9\x93\x5f\x01\x14\xa5\x19\xeb" + "\x98\x35\x9c\x9e\xd2\xeb\xd7\x51" + "\x8e\x17\x32\x19\x6d\xc5\x3f\x52" + + "\xc8\xf1\xcf\x9a\x08\xdd\xc6\x9f" + "\x0d\xb6\x25\x9b\x2f\xac\xe8\x20" + "\x4c\x5c\xd9\xd4\xab\x30\x29\x22" + "\x7b\x50\xb2\x15\x4e\xb0\x77\x1e" + "\xeb\xda\x9c\x2d\x19\x88\x6b\x7a" + "\x3a\x79\x97\x31\x18\x4d\x5d\xf1" + "\x92\x4b\xed\x1c\x72\x2a\x70\x38" + "\x34\x93\xea\x37\xb0\x92\x8d\x94" + + "\x1d\x9d\xf3\x16\xa3\x9f\xf8\xda" + "\x51\x6f\x28\x60\xa3\xec\xdf\x4f" + "\xd2\x3a\x05\x79\xe9\xc5\x37\x1d" + "\x40\xfa\x58\x19\x30\x0e\xa7\xde" + "\x7c\xe6\x1f\x25\xef\x96\x0a\xd0" + "\x74\xbe\x94\xeb\x2b\x1a\xc0\xd8" + "\x75\x4b\xfd\x0c\x38\x44\x2a\x0e" + "\x2c\xf2\xbd\x85\xb2\xc7\x1b\x87" + + "\xf4\x22\x86\x3c\x28\x94\xff\x9f" + "\x40\x84\x46\x8c\x8f\x32\x6e\xb7" + "\x70\x0f\xae\x31\x97\xe1\xc5\x60" + "\xbc\x9c\x72\xec\x77\xd1\x6d\xf8" + "\xa2\x97\xf4\xf3\x30\x35\x81\x21" + "\xe7\xfe\x20\x59\xc1\x92\x31\x7f" + "\xe5\x1e\xc5\xe1\x31\x0c\x0f\x0e" + "\x10\xdd\xf4\x22\x73\xcd\x36\xf3" + + "\x84\xe6\x8f\xb9\x0c\x07\x1d\x50" + "\x58\x14\x4a\x12\x9a\xbe\x0f\xd6" + "\x3f\x6b\xbc\x92\xc8\x61\x57\xa4" + "\xcb\x27\x6f\xfe\x58\x48\x38\xf5" + "\x3b\x76\x9e\xb5\xf7\x71\x02\x4b" + "\x5e\x8e\x5a\x5b\xa9\x06\x46\x3d" + "\x92\x82\xa4\x05\x9b\x5d\xda\x1e" + "\x46\xc4\xfe\xe6\xd0\x31\x77\xda" + + "\x20\xff\x18\xeb\x77\x51\x7b\x27" + "\x62\x6d\xf0\x28\x98\x2e\x00\x48" + "\x8d\x6d\x50\x0e\xc3\xd6\xe8\xec" + "\x63\xf9\x9f\xcd\x58\x0a\xde\x5c" + "\x0e\xaa\x3b\x4e\xb7\xcd\x97\x3b" + "\xf9\x38\x12\x63\x0b\x0c\x56\x50" + "\x3d\x79\x79\xcf\x35\x1b\xc3\xe1" + "\x78\x21\x5e\x35\x14\x2f\xd1\x95" + + "\x37\x88\x42\x2f\xc3\xb9\x21\x3d" + "\xbf\x02\x34\x0f\x1e\x6b\xc9\x73" + "\x9e\xf3\x4f\x42\xc9\xbf\xf7\x6c" + "\x96\xd6\xd0\xf6\x59\xa4\x2d\xca" + "\x4e\x15\xb8\x3b\x9d\xd6\xf1\x3c" + "\xb4\xed\x30\x54\x16\x9b\x42\xc2" + "\x75\xd3\xd0\x15\x8a\x47\xc6\xd3" + "\x6b\x37\xe4\x7d\x7f\x06\x33\x5e" + + "\x62\x59\x20\xcb\x5d\x30\x8c\x37" + "\x9a\x59\x04\x3d\x9d\x9f\x40\xe1" + "\xb2\xc1\x57\x80\x27\xba\xec\x84" + "\xb1\x80\xbd\xa2\xe7\xac\x92\xcc" + "\x60\xc7\xc4\x4c\xdb\x11\x53\xcb" + "\xfe\x8e\x6d\x46\x63\xce\xf0\x18" + "\xee\x49\x72\x08\x1b\xeb\xa0\x0d" + "\xf3\xde\xfb\x56\xfb\xe3\x47\x7d" + + "\x71\x58\xd4\x90\x93\x36\xe3\xa3" + "\x8d\x6d\x16\x06\x40\x40\x76\xe9" + "\x03\x04\xa9\x89\x82\x36\xc3\xb5" + "\x37\xd6\xf1\x72\x83\x79\xd1\x4b" + "\x3a\xc5\xd2\xd5\x9e\x67\x16\xa6" + "\x87\x3b\xcf\xfd\xd8\xbc\xc4\x5e" + "\x4e\x69\x6a\xb6\x13\x76\x6d\xae" + "\xe5\x27\xfc\xe3\x76\xfc\x60\x74" + + + "\x62\x49\x3c\xc6\xe1\x1f\x53\x80" + "\x25\xdb\x1f\x98\x89\x1e\x54\x50" + "\x6b\x2b\x4c\xfd\xa1\x91\x12\xdc" + "\xca\x4f\xdf\xa6\x17\x3a\x69\xc0" + "\x03\xf2\x17\x01\x4e\x60\xc4\xb2" + "\xd0\xb8\x99\x0a\x63\x19\x5f\x24" + "\x44\x2c\x21\xc6\xaa\x20\xdc\xae" + "\xa8\x52\x0f\x52\x56\x4e\xed\xb1" + + "\xcd\x1a\x0a\x70\xb6\x0f\x56\xb5" + "\x81\x96\x99\xfd\x73\xfd\x23\xe8" + "\xba\xe1\xb4\x6c\x1f\x5d\x91\xda" + "\xa3\x00\xbe\x6e\x18\x01\x03\x0d" + "\xcd\xa8\xfc\x89\xc9\xb0\x4f\x74" + "\x0b\x0e\xda\xf9\xdb\x01\x0d\x97" + "\x6f\xd7\x31\x79\x64\xc5\xd8\x0a" + "\x6a\xb9\x59\xf6\xbf\x37\x57\xb1" + + "\xda\x22\xdf\x6b\x9c\x7a\xf3\x18" + "\xdf\x82\xdc\x90\x2f\x43\xbc\xef" + "\x51\x36\x70\x5d\x8e\xef\x2c\xc5" + "\xa5\x81\x98\xd9\xa0\x7b\x88\x82" + "\x1d\xec\x20\xb9\xda\x9d\xec\x7c" + "\x3b\x8d\x3e\xec\xc3\xe8\xd7\xd0" + "\x47\x87\xa8\x4c\x95\xc3\x5b\x44" + "\x35\x35\xd5\x9f\xe0\xa2\xea\xed" + + "\xd0\xc2\x53\xce\x4e\x38\x2b\xa1" + "\xda\x06\x46\x5e\x7d\x89\x9d\x77" + "\xb0\x12\xec\x73\xb0\x47\x3e\xa5" + "\xad\xf1\x56\x57\xba\xbb\x2d\x46" + "\xb6\x37\xfe\xca\xf2\x09\xfe\x69" + "\x17\x2e\xce\xec\xbf\x1e\x3d\x27" + "\xfd\x07\xf6\x3c\x38\xd5\xc1\x8a" + "\x25\x0c\xe1\x12\xff\xf7\x35\x80" + + "\x05\x90\x6c\x29\x0f\xcc\xd4\xb7" + "\xdb\xeb\x0a\x7b\xfa\x94\x90\x4b" + "\xd4\xc8\x0e\xc0\xf1\x10\xbf\xe1" + "\x01\xc1\x67\xd6\xc4\xb1\x07\xd8" + "\x83\x33\x71\xbe\xdf\x2c\x41\xa9" + "\xa1\x2b\x14\x81\x3e\x06\x5e\x43" + "\xdc\x6b\x0a\xaf\xec\x15\x4c\x98" + "\xb9\xda\xa3\x92\x60\x24\x2c\x59" + + "\x2a\xc2\x93\x20\x5a\x2d\x44\xca" + "\xed\x3a\x70\xd5\x31\xbd\xd0\xeb" + "\xb6\x87\x32\x65\xfd\x2a\x8f\x30" + "\xba\xc8\x1b\x0d\xac\x8b\xb8\x9b" + "\xb2\xe3\xc1\x75\x38\x85\xaf\xfb" + "\x7c\x44\x11\xca\x50\xc9\x2a\xbd" + "\x8d\x4c\x5c\xea\x6c\x81\x6d\x28" + "\x08\x32\xdc\x28\x00\xa8\x3a\xdc" + + "\x9d\x3e\xe2\x16\x00\x69\x65\x93" + "\xe1\x41\xcc\xa7\x6b\x0c\x22\xcb" + "\x5c\x24\xd6\x69\xc3\x20\x6b\xb3" + "\x6a\x9a\x2e\xb6\x48\xc3\x63\x2d" + "\xb5\xbc\xc0\xcd\x19\x3e\x47\xa3" + "\x98\x1b\x60\x8f\x3f\x8b\xf1\x70" + "\xe4\x46\xe3\xcd\xc7\xa2\xd7\x8a" + "\x64\xaa\x3a\xbd\xc3\x6e\x9f\xae" + + "\x20\x55\x6c\x7e\xc7\x34\x4d\x85" + "\x58\xea\xb9\xdc\xef\xf9\x7d\xc2" + "\x6d\x66\x86\xd6\x69\x23\x5f\x40" + "\x85\xaa\x17\x04\xbf\xfe\xd1\x29" + "\xfe\x0a\x47\x93\x9e\x81\x46\x98" + "\x9e\x7f\xa2\xe2\x69\x96\x6a\x3e" + "\x04\x65\x1e\xe3\xa2\x08\xd0\x24" + "\x0a\x68\xb7\x9c\xcf\xce\xa7\xdb" + + "\xe1\xc7\x74\x32\x50\x23\x02\x03" + "\x26\x6c\x4b\x4c\x93\x8c\xee\x61" + "\xce\x89\x93\x19\xe3\x97\x43\x3c" + "\xce\x57\x87\x48\x00\x26\x08\xe0" + "\xfb\xda\xb4\x06\xdf\xa2\xc3\xaa" + "\x6a\x5b\xff\xdd\x00\x07\xaf\x45" + "\xa0\x9f\x1d\x8c\x24\x74\x59\x0a" + "\x8b\xc6\x1f\x39\x7d\x08\x40\x16" + + "\x3d\xa5\x7f\xd0\x41\x3e\xa4\x26" + "\xc5\x5b\xe3\x74\x8a\xa7\x54\x31" + "\x8c\x2f\xda\xe0\x24\x89\x76\x7b" + "\x9a\x3f\x61\x23\x2b\x4a\x96\xba" + "\xc4\x16\x1d\xba\x35\x8d\x54\x5a" + "\x57\xd0\x54\xfb\xd1\xfe\x1b\x2e" + "\x05\x02\x64\xbc\x36\x21\x99\xff" + "\x29\xdf\x56\x81\x14\xb9\x9c\xf3" + + "\xbd\x48\x55\x4e\xcf\x3f\x87\xf4" + "\xf0\x57\xce\x03\x3f\xda\x25\x87" + "\x58\x32\x95\xca\x95\x5c\x2f\xd8" + "\x7e\x74\xf0\x7c\x12\x7f\x64\xac" + "\xd5\x0b\x57\x2d\xb0\x38\x20\xff" + "\x3f\xe0\x3a\xa1\x67\xa7\xc2\xb0" + "\x16\x2d\x93\xe9\xcd\x27\xaa\xeb" + "\x01\xe9\x34\x12\xfc\xe3\x86\xa6" + + "\xad\x44\xb4\x99\x46\xe6\x13\xc9" + "\xc5\x04\x05\xc4\x9d\xe9\xfc\xdd" + "\xdb\x53\x2e\xd4\x99\x2a\x48\x58" + "\x37\xf5\xaf\xd1\x25\x2c\xaf\x9a" + "\x67\xcf\x64\x26\x96\xf7\x90\xee" + "\x2b\x3e\x39\xf1\x99\x5c\xab\x74" + "\xb0\x5b\x22\xe6\xea\xfa\xd0\xfa" + "\x6c\xdd\x63\x2d\x8c\x64\x55\xc3" + + "\xcc\x1e\x26\x63\x5e\x43\x80\x9f" + "\xc9\xd6\x37\x43\x2e\xa6\x02\x63" + "\xa0\x58\x49\xca\x49\x6a\x91\x91" + "\xd3\xd5\x49\x31\x99\x58\x49\x55" + "\x3c\xde\x91\x9f\x0b\x02\x8d\x37" + "\x70\x51\xd2\x4d\xa3\x39\xb8\x47" + "\x58\xf2\xb7\x38\x41\x85\x25\x28" + "\xec\x7d\x7e\x43\xf7\x14\x5b\xea" + + "\x9d\xcf\x91\x1d\x27\x1d\xe3\xe4" + "\x0a\xb2\x77\xb3\xfd\xd4\x35\xcb" + "\x27\x13\x5e\x05\x45\x1e\xde\x74" + "\x75\x3e\x70\x28\x1b\xe3\x98\x32" + "\x39\x33\x01\xde\x37\x72\x08\x55" + "\xc6\x01\xd1\x23\x01\xf3\xcb\x32" + "\xdc\xb0\xaa\xe8\x22\xba\x0d\xc7" + "\xb9\x5b\x15\x3d\x3d\x62\x52\x4a" + + "\x44\x8f\x01\xb0\x36\x87\xf0\x74" + "\xf5\xd0\x46\xb4\x17\x34\xa0\xf4" + "\xb2\xa6\x0c\xa4\x2f\xaa\xa4\x66" + "\xed\x60\xdb\xba\xf0\x79\x56\x21" + "\xef\x4e\x3e\x32\x5a\x19\x71\x38" + "\x16\x2b\x95\x20\xc3\x40\x09\x8f" + "\x7d\x5f\x9d\x87\x62\xac\x8d\xfe" + "\x75\xe8\xa6\xc1\x23\xb6\x9c\x64" + + "\x43\x6e\x8d\x33\x41\xf5\xaf\xec" + "\xcc\xd5\x41\x45\x73\xdd\xf7\x56" + "\xca\x88\xbc\x96\xde\x26\xd4\xb5" + "\xc3\xa2\xd3\x9e\x6b\x4f\xd9\x48" + "\x9c\x27\xf8\x2e\xbb\xa3\x54\x63" + "\xf2\x67\x18\x0b\x5b\x46\x75\xd5" + "\x51\x51\x22\x95\xff\xb0\x99\xef" + "\xd8\x00\x45\xf9\x88\x9d\xe1\xf3" + + "\x08\xc1\x3e\x13\x87\x90\x6a\xa2" + "\xc0\xbd\x12\x27\x9f\x69\xc5\x5d" + "\xa9\x24\x42\xd1\x4d\x3f\x90\x96" + "\x80\x7b\xe4\x29\x24\x99\xa5\x3d" + "\x5a\xba\xdb\xf9\x2f\x71\x17\xb7" + "\xc9\x91\x63\x75\x4b\x00\x52\x9e" + "\x9c\x21\x9d\xcc\x1d\xa1\x69\xe6" + "\x7d\xc0\xd6\xd1\x84\x6b\x6e\x3b" + + "\x57\xcf\x5d\xc8\xac\x35\xf4\xdb" + "\x15\x54\x8f\xc8\x58\x56\x74\x61" + "\x07\x58\xc5\x17\x9a\x7e\x36\x26" + "\x6f\xc5\x90\xca\xa5\x77\xd0\x22" + "\x76\x4e\xe0\xa2\x58\x22\xf7\xfb" + "\x05\xe4\x06\x6e\x3e\x5d\x96\xba" + "\x54\xf9\xe6\xe3\x6f\xd0\x24\x57" + "\x74\x1a\x25\x81\x75\xd4\x47\x3e" + + "\xdb\xea\x6f\x67\x6a\xc0\xee\x5f" + "\x22\xf3\x69\x9d\xc5\x9b\x44\xfc" + "\x95\x88\xda\x7c\x5e\x7b\x8d\x1d" + "\xa7\x14\x33\x1a\xc1\x4d\xd5\x5e" + "\xc0\x89\xe8\x6d\xae\xd2\x11\x1a" + "\xd9\x2b\xed\x4c\x72\x79\xa9\xb2" + "\xf6\x5e\x6a\x30\x89\x69\xcf\x6e" + "\x49\xa2\xc8\x8c\x7b\xd5\x11\x16" + + "\xf7\x82\xfb\xe0\x51\x01\xba\xb8" + "\xc2\x8a\x66\xd5\x26\x07\x16\x0d" + "\xb0\x11\xd7\x14\x58\xa2\x2b\x62" + "\xf2\xe2\x3f\x7f\x57\xf5\xdd\x6a" + "\x35\x94\x9c\x6b\x1c\x1e\x83\x2b" + "\xbd\x26\x38\xb7\x0a\x06\x3a\xce" + "\x89\x0f\x24\x1c\xc1\x11\xfa\x93" + "\x3a\x30\x6e\x95\xd8\xc8\x9c\x4f" + + "\x87\xbf\x7c\x00\xba\x42\x99\x2d" + "\x26\xc9\x3f\xdf\xe6\xbc\x62\x4e" + "\xff\x0a\x56\xe4\xb0\xe5\xee\xe7" + "\xb7\x09\xb0\x7c\xbb\x63\x19\xe5" + "\xdd\x37\x9b\xe2\xce\x18\x51\xaa" + "\x03\x39\x26\x47\x47\x4a\xd8\x5c" + "\xd8\x55\x00\x62\xa6\xca\x50\x30" + "\x3d\x1e\x4b\x6c\xa7\x76\xf5\x7e" + + "\xc9\x82\x1f\x64\xf6\x31\x93\x4b" + "\x56\xc7\xfe\xdf\x54\x7c\x7c\xd9" + "\xab\x58\x91\x1a\x1f\x6d\xee\xf5" + "\x7f\xda\xc3\x85\xa3\x93\x44\x05" + "\xdf\x96\x7d\xeb\xf5\x05\x7a\xa5" + "\x39\x3a\x47\xe4\x47\xd4\xaf\xa3" + "\x55\x6d\xe1\x88\xc4\xd9\xa4\x42" + "\xae\x76\xf8\xf5\xf5\x44\xe1\x83" + + "\xf1\x8f\x00\xe6\xdd\xa4\x26\x90" + "\x6c\xd9\x8c\x1c\xad\x95\xe9\x49" + "\x9b\x58\x3e\x50\x73\x2e\x72\x80" + "\x26\xbc\xc2\x84\xe1\xbc\xbc\x05" + "\x2c\x2c\x68\xd4\xbb\x9a\x5f\x25" + "\x56\xd4\x84\xf0\xc2\xcf\x2b\xc4" + "\x67\x07\x1c\x64\xb0\xe9\xea\xa0" + "\x2d\x9a\x4c\x86\x2d\x63\x45\x1b" + + "\x20\xd6\x2d\xe3\x68\x32\xa8\x92" + "\xa2\x49\x78\x62\x9f\xc9\x3e\x91" + "\x82\x88\x37\x2c\xfa\xfd\xd8\xed" + "\xfe\x8c\x6f\xee\x3e\xf3\x96\xaf" + "\xa5\xa8\x3f\xdc\xe5\x37\x67\xc0" + "\x1d\x3a\xb0\xb0\x31\xb5\x6b\x23" + "\xb0\x37\xf0\x89\x29\x9f\xe5\x33" + "\x53\x2a\xa1\xd9\xa7\xb5\xf9\x13" + + "\xe0\x24\xe0\x6a\x3b\x79\x25\xcf" + "\xb0\xc4\xb5\x84\xb4\x07\x66\x1b" + "\xc8\x24\x16\x3f\x90\xfa\x79\x95" + "\xe8\x57\xbd\x68\xbe\x65\xfb\x37" + "\x03\xc2\x39\xfc\x5e\xa5\x93\xd6" + "\xe9\x52\x72\xc8\xc4\x7a\x26\x4e" + "\x13\x94\x89\x9f\xb0\x8b\xd7\xb8" + "\x08\x85\x3b\x0b\x07\x14\xc0\xe4" + + "\xa6\x9a\x02\x59\x95\xae\xd8\x50" + "\xed\xb2\x4d\x5a\x2c\x29\x4e\xd7" + "\x3d\x37\x8f\x84\x55\x33\x9c\x0b" + "\x38\xab\x45\xac\xb6\x8d\x01\xec" + "\xa8\x53\xcc\x69\x02\x69\x44\x1f" + "\x64\x98\x87\x1a\x8d\x62\x4b\x8c" + "\x5e\x47\x13\x4b\x28\x3d\x74\x1c" + "\xf6\x19\xde\x73\x38\x93\x4a\xbf" + + "\x53\x35\x3f\xbc\xe5\x06\x29\x66" + "\x84\x96\x45\x31\x35\xd5\x38\xde" + "\x0d\x28\xf7\x34\xc6\xa8\x46\x8f" + "\x8e\x19\x24\x3d\x87\x1b\xf9\xaa" + "\x7e\x11\x9b\x5f\x11\xee\xd5\xec" + "\xda\x8d\xae\x50\xbe\xff\x00\xce" + "\xae\xa9\x10\x77\x4e\x3d\x3a\x26" + "\x4f\xa7\x6b\xf2\x21\xf7\xf3\x0f" + + "\x69\xfa\xce\xf0\x47\x4f\x8a\x4a" + "\x66\x68\x54\xa4\xba\x4c\x8e\xdc" + "\xc1\x03\xf6\x23\x9b\xa6\x9b\x35" + "\xc5\x7a\x7b\x18\x01\xd6\xb4\xda" + "\xd9\xc8\xeb\xc1\x37\x43\xca\xa6" + "\x4b\x07\xb4\x52\x54\x58\xa6\x9f" + "\x33\xb7\x2f\x90\x81\x4f\x4b\x1a" + "\xaa\xde\x25\xa5\x7a\x5d\xbb\xd2" + + "\x7a\x57\xb3\xe6\xc2\x7a\x28\xcc" + "\x3b\x00\x12\xf6\xa7\x8c\x52\xd7" + "\xb8\x00\x14\x2c\xf1\xb6\xfd\x8a" + "\x8d\xdd\xa2\x46\xd3\x2e\x3a\x10" + "\x39\x13\xe2\x2e\x4d\xc5\xf8\xc8" + "\x20\x2d\x5a\x35\x92\x1b\x01\x8f" + "\xac\xf2\x46\x13\x9f\xfc\xc6\x81" + "\x4b\xd2\xa6\x05\xf0\x42\x60\xdb" + + "\x67\x95\x1f\xf8\xd5\x92\x2e\xeb" + "\x70\x84\x69\x4d\xea\x95\xcb\x54" + "\xeb\x81\x4c\xe0\x28\xcb\x2a\x5f" + "\x64\xec\xce\xf8\xc4\xbf\x1e\x1c" + "\x23\x74\xe0\x06\xac\x9f\x79\x8f" + "\x85\x0c\xfa\x37\x99\x5f\x22\x72" + "\x44\xdb\xf4\x34\x16\x86\xcd\xb0" + "\x91\x90\x2c\x75\x59\x61\xc3\x5e" + + "\x96\xf9\xa4\x0d\x63\xe3\x90\xfc" + "\xe4\x6f\x6d\xaa\x9d\xa4\xec\x8c" + "\x9b\x61\xfc\xbd\xfd\xaf\x84\x10" + "\x04\x0b\x14\xc1\x72\xf6\x29\x20" + "\x5e\x3e\x6f\x13\x5f\xc2\x6e\x60" + "\x4a\x4c\x22\x02\x9b\x14\x24\x6d" + "\x4c\xcf\xdf\xcf\x42\xf1\xb0\xab" + "\xed\xa0\xb1\xfa\x19\x04\x0d\xe4" + + "\x10\xb3\xef\x51\xce\xf6\x0d\x0d" + "\xbe\xf5\x8d\x95\xb4\x2e\x5b\xcb" + "\x59\x8e\x15\x36\x29\x9e\x45\xd6" + "\x36\xe3\x66\x14\xb9\xe2\xaa\x82" + "\x36\xa6\x1a\x41\x39\x8a\x65\xfb" + "\x33\xa9\xc0\xd4\xc5\xec\x52\x71" + "\xb7\x26\xf0\x49\x8a\x75\x0c\xf1" + "\x1f\x31\x09\xcb\x97\x7f\x83\xf4" + + + "\xd5\x32\x63\x62\x3a\x52\x4f\x99" + "\x44\xbb\x61\x55\x33\x88\xc3\x7b" + "\xa2\x5e\x84\x3d\xb0\xd4\x5e\x00" + "\x8a\xf0\xa1\xc2\xe1\x3e\x9d\xd3" + "\x0d\x6b\x67\xe7\xd3\xfd\x61\x65" + "\x17\x60\x70\xfb\xff\x35\x0e\x62" + "\xa8\xf9\x64\xf2\x4f\x42\xce\x36" + "\xf7\x81\x26\xda\x9f\x41\xc3\xc4" + + "\x48\x16\xb8\x9b\x76\x31\xf8\x00" + "\xd0\x20\x31\x65\x85\xb4\x9e\xd6" + "\x62\xbc\xca\x4c\xf4\x75\x7d\xd1" + "\xb1\xfc\x49\xb7\x82\x7f\xa0\x34" + "\x54\x55\xfb\xbb\x87\xf7\x3a\x2c" + "\xf8\x83\xe2\x62\xd0\xd4\x6e\xb0" + "\xa0\x13\x92\xa1\x9f\x88\x22\x57" + "\xb4\xc7\xf3\xdc\x5e\x08\x2b\x16" + + "\x7a\x0f\x30\xeb\xda\x0d\xd9\x36" + "\x01\xe8\xb5\xed\xfc\x7d\xcf\x9d" + "\x4c\x24\xd5\x74\x68\xb2\x5c\x64" + "\xa2\x3a\x8e\x34\x79\xee\x27\xa1" + "\xbb\x1d\x5f\x57\x53\xcc\x8a\x48" + "\x1e\x16\xe6\x80\x85\x7e\x03\x95" + "\xd0\x50\x26\x29\x83\x92\xe5\x57" + "\x16\x82\x93\x14\x99\x7d\xe6\xab" + + "\x1f\xe7\x89\x71\x2f\x0d\x67\x32" + "\xe7\x91\xcf\x5e\x48\x87\x43\xc6" + "\x21\x7a\x75\xdb\x57\x8e\x75\x15" + "\xe5\x9c\x0a\x29\xf8\x09\x7d\x42" + "\x7a\x4a\x38\x38\x8f\x30\x6a\x84" + "\x99\x2b\x73\xb0\xb4\xac\xc3\xaa" + "\x19\x58\x84\x17\x09\x10\x94\x9e" + "\x03\x5e\xce\xa7\x11\xa1\xcb\x95" + + "\x8e\x05\x78\x73\x37\xaa\x81\xeb" + "\x54\x11\x41\x04\xa1\x46\xc7\x41" + "\xc7\x8a\x82\xfb\xbc\x73\x0c\xa1" + "\x29\x2b\x97\x9d\x91\xbe\x39\x64" + "\xad\xfb\xa2\x43\xb0\xb4\xf3\x4b" + "\x40\xe8\xb5\x82\xdf\xda\xe6\x39" + "\x4c\xbd\x97\x63\x08\x64\x71\x4f" + "\xcb\xec\x1e\x7f\x68\xe5\x7d\x0f" + + "\xc3\xc3\x7e\xf3\x73\x2a\x33\xdb" + "\xa0\xeb\x59\xdd\xbd\x59\x52\xc6" + "\x57\x32\x4d\xdb\x9c\x70\x91\x22" + "\x90\x93\x38\xbd\x25\x3b\x79\x9a" + "\xf0\x56\x37\xe4\x4b\xe3\x9f\xf3" + "\xc9\x56\xfb\x9a\xce\xbd\x76\x2f" + "\x27\x8b\x20\x61\x7a\x86\x37\x9f" + "\xc3\x72\x99\x08\x07\x43\x1d\xea" + + "\x4f\x9f\x42\x8a\x87\x44\xa7\xd0" + "\x09\x66\x51\xdb\x2b\x71\x49\x06" + "\xdf\xb5\x69\xe7\x57\xba\x26\xb8" + "\xf2\xaa\xc7\x1f\xf2\x5d\x33\x82" + "\x95\xd9\x93\x5c\x67\xf0\x89\x23" + "\xe6\x7b\x67\x68\x7a\x36\xac\x59" + "\x1b\x95\xd9\x21\xff\x85\x79\xa7" + "\xce\x1c\x01\x85\xfb\x56\x89\x03" + + "\x9b\x5e\xca\xaa\x1a\x85\xb7\x97" + "\x97\x3b\x71\x56\x21\xa5\x8a\x51" + "\xf6\x61\x0a\x15\xc7\xe8\x57\x33" + "\x69\x2b\x2c\xec\xe2\xe7\x42\x78" + "\x48\xa5\x68\x68\x65\xaf\xff\x8d" + "\x81\xfc\x68\xe0\x82\xbd\x63\xd9" + "\x33\x77\x91\x65\x8b\x5c\xda\x64" + "\x28\x73\x24\x7b\xff\x90\x70\x92" + + "\x97\x0d\x6d\x2f\x94\xdb\xff\xd6" + "\x73\x93\x3b\x44\x41\xee\xc3\x05" + "\xb6\x6d\xd3\xff\xeb\x41\xe5\xb2" + "\x3e\xcc\x1d\xce\x96\x5a\x41\xb7" + "\xf6\xa2\x3a\x16\x2e\x68\x83\xe3" + "\x18\xf2\x3a\x2f\xd4\xbd\xfe\x46" + "\xdb\xba\xfd\xba\x7e\x50\xa0\x90" + "\x1a\xe2\x52\xce\x4d\xab\xa8\x4c" + + "\x73\xfb\x7c\x1b\x2e\x83\xf0\xa3" + "\xc9\x54\xc3\x3e\x52\xfe\x8a\x7a" + "\xca\xad\x8e\x37\x7e\xc9\x91\xae" + "\xbb\x32\x3b\xac\x99\xc5\x49\x74" + "\x55\x46\x1c\x0b\x71\xc3\x19\xa6" + "\x7e\xa8\x9d\xf7\x6a\x4c\x2e\x69" + "\x6a\xd9\x38\xde\x86\x5d\x3f\xff" + "\xec\xc0\x08\x1c\x42\x0f\x32\xc5" + + "\xec\x5d\xec\x8f\xbc\xf2\xa6\x92" + "\x6c\x78\xd6\x84\xff\x83\x13\xa7" + "\x84\xa0\xff\xdb\x06\x8c\x58\x87" + "\x15\xe7\x57\x68\xca\xf5\x85\x0d" + "\xd4\x74\xc7\xb6\xb3\x11\x73\xe8" + "\xa8\x21\x35\x4c\xc8\x57\x23\x67" + "\x0f\xfe\x29\x5b\x61\x74\xfe\xe5" + "\xcd\x58\x71\x5b\x10\x51\xbc\x02" + + "\x8e\xfc\x05\xa1\x48\x1e\xa0\x37" + "\x8c\xa4\x9b\x28\x4a\x75\x9d\x76" + "\x80\x21\x1c\xd5\xe1\x6f\x8c\xc0" + "\x87\x13\xbd\xb7\x33\xdd\x32\xb0" + "\xa6\x0a\x0b\x02\xdb\x26\x38\x95" + "\x3c\xc7\x64\x06\x80\x7e\x13\x05" + "\x5d\xf9\x0c\x66\xc4\x02\x63\xc6" + "\x8a\xf2\xce\xb2\x11\x4e\x00\x99" + + "\x36\x35\x97\x4f\x28\x5b\x4f\x82" + "\xea\x04\x5b\xd3\x9e\x29\x3e\xb4" + "\x89\x30\xa0\x4d\xf7\x88\x2c\xc7" + "\x2c\xe4\xa2\x45\x7a\xd5\x69\x82" + "\x8e\xb3\x07\x66\xfc\x63\x1e\x7c" + "\x0c\x0b\x39\x29\xaf\x2a\x9e\xe8" + "\x69\x28\xee\x1b\xda\x40\xc7\xc7" + "\x74\xb9\x3f\xaf\xfc\xf6\x56\x85" + + "\xd1\xbe\xb6\xa4\x95\x39\x0a\x1a" + "\x54\x5c\x09\x97\x95\x57\xab\x2d" + "\xe9\x3c\xa7\x2a\xff\xa1\xc6\x06" + "\xa7\x38\xe4\x4d\x4b\xa5\xd0\xad" + "\xcd\x06\xa9\xfc\x1a\x6b\x0b\x16" + "\xdd\x10\xde\x29\x16\x60\xfc\x25" + "\xa3\x3d\x63\xd3\x99\x9c\x8e\x34" + "\x5a\x4d\x8a\x15\x46\xf7\xe3\x1f" + + "\x1d\x5c\xe8\x8b\xc8\xed\x53\xc2" + "\xb6\x9c\xa0\x3c\x48\x0e\x3d\xdd" + "\x5a\x05\xe3\x9a\x87\xf6\x97\xb9" + "\xbf\x1d\x43\x07\xd0\x9a\x92\x0c" + "\x42\xdb\xd2\x84\x15\x62\xf1\xce" + "\xcd\x28\x88\x07\xef\xf3\x0d\xb5" + "\x66\x4b\xbd\x6d\x9d\xda\x89\x45" + "\x04\x2b\x9c\xd9\xe3\xd2\x4f\xbc" + + "\x41\xc2\x98\xd2\xa7\xc9\x4b\x21" + "\xfd\x7c\x80\x56\xba\x97\xb6\xe3" + "\xdb\xea\x64\x45\x02\x78\x1c\xef" + "\xc5\x49\x81\xb4\xcf\xcd\xe8\xdd" + "\x04\x26\x4d\x5a\xa7\xf0\x6b\x94" + "\xaf\x38\x15\x6c\x7f\x4d\x15\x27" + "\xcc\x1f\x5b\xde\x30\x92\xcc\x95" + "\x82\x4f\x86\x66\xe9\x19\x85\xd8" + + "\x77\xbc\x86\x62\xea\xa9\x01\x99" + "\xb0\x4d\x79\x69\x58\xfe\x9d\x24" + "\x21\xcd\xa6\xbb\xbd\x0b\x37\xc4" + "\x6b\x5e\xfc\x21\x31\x81\x8f\x71" + "\x61\x8b\xc7\x22\xbd\xed\xdf\x9c" + "\x71\x3d\xd4\xd9\xec\x3e\x31\x4b" + "\x22\x1b\xbb\x19\x1f\x03\x44\x41" + "\x58\x31\xa3\x07\xab\x73\x49\x97" + + "\x26\x65\x36\x06\xf4\xde\xaa\x67" + "\x96\x5d\x53\xae\x19\x30\xd5\xd7" + "\xc6\xeb\xa2\xe3\xa7\xdb\xfa\x72" + "\x16\x9d\x26\x75\xa5\x13\x23\xa3" + "\x2e\x92\x0d\xb5\x69\x1a\xfa\x97" + "\x45\x2b\x20\xca\xcf\x28\x6e\x4c" + "\x91\x0b\x10\x68\x00\x11\xbd\xb7" + "\x5d\x6a\xc9\x73\x8d\x41\x2e\xe0" + + "\x46\x55\x80\x8e\xdc\x6e\x9e\xfa" + "\x40\x98\x63\x82\x78\xe6\xe0\xc0" + "\x3d\x64\xbe\xb7\xa4\x58\x08\x43" + "\x1e\x5f\xcf\x18\x14\x24\x42\x1d" + "\xaf\x49\xef\x9f\x62\x0c\x99\x05" + "\x32\x1d\xc3\x5e\xcd\xe0\x46\x48" + "\xd4\x85\xbf\xba\xa8\x47\xdb\x46" + "\x7f\x9f\x75\xaa\xf1\xc9\x66\x5f" + + "\xa1\x6c\xea\x96\xf7\xe4\x13\x10" + "\x71\x28\x79\x1f\x2a\xdc\x7c\x56" + "\x45\x8d\x65\x5c\x70\x28\xb7\xad" + "\x98\x0e\x60\xce\x4a\xff\xc1\xf7" + "\x39\xad\x6c\x4b\x57\x86\xba\xa1" + "\x28\xb4\x20\xba\x34\xd6\x58\x3d" + "\xfb\xfd\xe6\xa2\xde\x1c\x01\xc0" + "\x0d\x96\x18\x7b\x7a\x36\x32\xa8" + + "\x07\x15\x52\x50\x8f\x2c\x39\xb7" + "\x9d\x2e\xef\xe5\x4b\x91\xb3\xac" + "\x85\x6f\x44\xea\x78\xb1\x70\x9a" + "\xee\xc3\xd8\x98\xa6\x43\x4c\xbd" + "\x77\x01\x4c\x84\xe5\xbb\x73\xa9" + "\xea\xb3\x2a\x06\x4d\x27\x9b\x29" + "\xaf\xda\x6a\x85\x7c\x0e\xba\x26" + "\xb8\xb2\x5c\x76\x94\x91\x9b\x13" + + "\x87\xd3\x9f\xbd\x9b\xe7\x21\x7b" + "\x71\x0c\x1c\x24\x9a\x76\x8f\xb4" + "\x93\x5a\x72\x8b\x36\x68\xe3\x83" + "\xe1\x96\x5b\x1f\x55\x4f\x9d\xef" + "\xa0\x10\x99\x2a\xa4\x39\x71\xc6" + "\x76\x5e\x09\x4e\xa2\xc8\xe1\x71" + "\xf2\xb8\x19\x27\x36\x7f\x2f\x21" + "\x17\x12\xfa\x00\x3f\xeb\x75\x9f" + + "\xb6\x6d\x3e\x34\x6e\x8e\x11\x4e" + "\x3f\x99\xb6\x25\x59\x55\xbd\x98" + "\x85\xfa\x2e\xb3\x14\xd5\x0d\xb4" + "\xa1\xe3\x24\x7a\x80\x55\x30\x7e" + "\xc3\x57\x58\x77\x50\x95\xcc\x7d" + "\xb0\xc1\x9b\x2c\x12\x11\x63\x05" + "\xe9\xdc\xa5\x02\xd5\x85\xae\x6e" + "\x72\x41\xeb\x34\xaa\xc9\x3f\xe5" + + "\xf7\x38\x49\x0e\x9f\x8c\x61\x47" + "\x9e\x71\x83\xdc\x69\x7d\xd4\x58" + "\xcc\x64\x1a\xf4\x23\x1a\x4c\xd7" + "\x66\x9f\x82\xb5\x68\xe0\x28\x5d" + "\xf6\x66\x04\x21\x29\x75\xd3\xd8" + "\xf8\x4e\xa6\xc6\x2f\x15\xf1\x2a" + "\x7a\x6a\xce\x19\x5c\x48\xd4\x55" + "\xd7\xe2\x48\xf6\xf5\xd2\x0b\x6d" + + "\x21\xb5\x9d\xf8\xb1\x6a\x2d\xf0" + "\xc6\xed\x0c\x65\xfc\x1a\xf4\x46" + "\x71\xdf\x8a\x1c\x96\x73\xbc\xb1" + "\xb9\xb1\xbd\x7e\xcb\x7f\x14\xd2" + "\x63\x03\x08\xc1\xf7\x0e\xaf\xca" + "\xc5\x09\x5c\xd9\xf3\x1a\x0b\xf9" + "\x83\x48\xf4\xf6\xd4\xbf\xaf\x7a" + "\x6d\x9b\x8d\x8a\x87\xe0\x64\x9b" + + "\xe5\x6a\x35\xbd\xe8\x9c\xfc\xee" + "\xf4\x5a\xd2\x2e\xc0\xa6\x98\x3d" + "\x84\xd8\x19\x63\x64\xf5\x73\x31" + "\x16\x4f\x6c\xca\x64\xed\x2d\x2b" + "\xd0\xfc\x6d\xce\xe5\x19\x7b\xe2" + "\xca\x87\xd8\xa0\x5f\xbc\x69\xa3" + "\x10\x37\x46\x07\x6e\x60\xc2\x59" + "\x4e\xe7\xc6\xf3\x2a\x11\xc1\x15" + + "\xa0\x13\x7a\x7e\x00\x30\xba\x4a" + "\xf5\xaa\xbb\x89\x47\xbb\x83\xf4" + "\x3f\x27\xfd\x9f\xf6\x50\x0d\x7c" + "\x92\xd6\xa4\xf4\x91\xc1\x63\x7e" + "\xe6\xd6\xf2\x42\x40\x34\xda\x8b" + "\xc6\x72\x8b\x93\xc2\xcd\xcf\xd7" + "\xe9\x54\x6e\x6f\xd2\xfb\x8a\xd2" + "\xe5\x3f\x8b\xc2\xb6\x23\x04\xd4" + + "\x8d\x44\x16\xf4\x2a\x03\xcc\x1e" + "\x71\xd9\x76\xec\x10\x8c\x7e\x4a" + "\xae\x6e\x0b\xb9\x05\x98\x4f\x85" + "\x94\x05\xed\x4b\x32\x15\x0b\xfd" + "\xa3\x5c\x8b\xd9\x48\x18\xf7\x89" + "\xef\xb3\x39\xf0\xfc\xe5\x1f\xd0" + "\x2e\xda\x7b\x62\x2e\x33\x81\x44" + "\x41\x3e\x07\xa5\xd7\xec\x7c\xe6" + + "\xcd\xec\x9c\x8a\x46\x16\x69\x2e" + "\xa1\x6d\x3a\x05\xcc\xeb\x92\xcc" + "\x64\x6b\x3a\x78\xb8\x76\x00\xa8" + "\xa2\x2f\x99\xa5\xa0\xe8\xd0\x42" + "\x30\xec\x56\x7c\x53\x1c\xc7\xd9" + "\x69\xc7\x6b\x6b\x96\x6a\x8b\x38" + "\xc7\x9f\xbf\xd3\xab\x33\xc2\xa0" + "\x69\x53\xc4\x2f\xd0\x5b\xf5\xd0" + + "\xf9\xee\x92\x32\x02\x33\x2c\xa7" + "\x16\x11\x8c\x9f\x36\x40\x5a\x0f" + "\x91\xa7\x96\x3e\xf0\x6e\x9e\x42" + "\x39\x39\x84\xf3\x81\x61\xeb\x60" + "\xd3\x18\x25\x90\x83\xf0\x49\xaf" + "\x0b\x39\xe8\xb9\x13\xc0\x65\xfe" + "\xa4\x34\x4d\xec\xb3\x7c\xb9\x7a" + "\x3d\x85\x4f\x8b\x08\x7a\x42\x72" + + "\x1f\xad\xfe\x2e\x68\xfc\x83\x38" + "\x68\x8d\x4d\xfc\xa1\x24\x72\xdd" + "\xdd\xaf\x1d\x9f\x4c\x84\x4e\x5c" + "\x7d\x9b\x11\x15\x8e\xd1\x40\x7f" + "\xeb\x68\xc2\xb7\x4c\xd1\xc6\x79" + "\xe1\x89\xae\xc2\x55\xc8\xb4\x65" + "\xa2\xd9\xb0\x7c\x99\xbb\x08\x35" + "\x5b\x4a\xc6\x2e\x5b\x63\x2c\xbc" + + "\x2c\x28\xb1\x7c\x1a\xdd\x28\xb8" + "\x3a\x97\x46\xbe\x26\x76\x8d\xa0" + "\xb2\xd6\x08\xe7\x40\x8d\xaf\x6b" + "\xf3\xb3\xae\x4d\xa1\x1f\x57\x72" + "\x98\xfd\x2d\xf2\x2f\x73\xb1\x85" + "\x8d\x10\x87\x00\xa7\x01\xab\x87" + "\x7a\x20\x88\x59\xa8\xfe\xaa\xaa" + "\x55\x07\xf0\x69\xf8\x32\xc8\xcc" + + + "\x1a\x9d\x8d\xca\x85\x11\x8f\x48" + "\xd2\xde\x87\xd9\x7d\xc7\xf2\xad" + "\x24\x61\xc4\x60\xf0\x39\x30\x5f" + "\xf4\x95\xe0\x71\x75\x0b\xd7\xe5" + "\x0f\xe7\x60\x62\x50\x86\xd5\x82" + "\x05\xd1\x50\xf7\xa7\x5e\xd7\x39" + "\x64\xc3\xba\x75\xb1\xd0\xf3\x8c" + "\x29\x13\xd0\x21\x4d\x56\xa7\xf3" + + "\xfc\x3e\xcd\x3f\x3e\xa4\x4a\xb2" + "\x9a\x8e\x08\xb8\x34\xc0\x26\xdd" + "\xea\x46\x3d\xbd\xc9\x4d\xef\xa5" + "\x6f\x6a\x4c\x8a\x58\x9d\xf9\xa2" + "\x6c\xa4\x1d\x2f\x55\xd3\xab\xdd" + "\xd1\xcd\xfa\x1a\xce\xf8\xc3\x72" + "\x78\x05\xd4\x92\xee\x4e\x0c\xd9" + "\x94\x3b\x62\xca\x1f\xb4\x8b\xd2" + + "\xe1\x7c\x41\xe7\xd2\x92\x27\x24" + "\xf5\xe7\x0e\x97\x71\xbc\x42\xff" + "\x1e\xa4\x67\x5c\x6d\xdc\xf4\x1f" + "\x58\x2a\x88\x20\x7b\x9b\x70\x77" + "\x2c\x7f\x21\xbe\x1d\x73\x54\x35" + "\x77\x21\xb7\x5b\xcd\xa8\xf2\x2a" + "\x59\xd0\x1d\x59\x69\xe7\xee\x58" + "\x77\x64\xba\x4b\xc9\x30\x29\xbb" + + "\xc0\xf2\x76\xf1\xda\xdd\x6a\x1e" + "\x58\x26\x57\xe2\x04\x46\xca\x01" + "\xfb\x2f\x34\x85\xed\x4d\x40\x0a" + "\xd6\x38\x18\x44\x96\x0f\xf6\x8c" + "\x4a\x1c\x07\xc9\x1c\x69\xbc\x9b" + "\x03\x28\x44\x34\x44\x87\x58\xfd" + "\x81\x0d\x9c\x80\x85\x1c\x10\x97" + "\x7f\x6f\x45\x8c\x4c\x75\xfb\xa7" + + "\x3f\x01\x71\xaf\xd5\xa1\xf7\x6a" + "\x46\xc9\xed\x0b\xe5\x16\x82\xe6" + "\xa0\x70\x73\xd2\x0b\xa3\xcb\xf4" + "\xcc\x21\x04\x87\xbf\xaf\x81\x79" + "\xe1\xf0\x49\x94\x67\x6a\x49\x02" + "\xae\xed\x47\x0a\xbe\xc4\xcf\x86" + "\x22\xca\xfe\xb1\x36\xc9\x73\x30" + "\xfb\xf8\xf8\x03\x12\x46\x69\xf5" + + "\xf8\x48\xde\x5b\x71\xd6\xad\xbc" + "\x7d\xbc\x89\x21\x73\x38\x70\xc9" + "\x8a\xee\x09\xc7\x9e\x29\x45\x5d" + "\xf8\xaf\x5a\x84\xe2\x7e\x28\xd1" + "\x1f\xbf\x1d\xdb\x74\x88\x1f\x7d" + "\xd6\x88\x0c\x99\x8b\x58\x46\xea" + "\x13\x83\x36\x84\x9a\x64\xba\x60" + "\xae\x43\xd5\x60\xce\xcb\xfd\xd5" + + "\x2d\x27\x90\x98\x95\xe9\x3d\xcf" + "\x10\x3a\x71\x3e\x2a\x43\xf3\x75" + "\xb8\x27\x82\xe2\x9f\x47\x13\x5e" + "\xc8\xcd\xfa\xfe\xa9\x1e\x56\xb8" + "\xfd\xaa\x32\x83\xa0\x97\xa2\xa6" + "\x62\x9b\x80\x73\xb5\x8b\x0d\x9b" + "\x6f\x03\x63\x0c\xfd\x1c\xfa\xd2" + "\xa8\xbd\x64\xbd\x55\xeb\x16\x7a" + + "\x27\x3e\xc1\x2a\x8a\x8e\xe4\xf7" + "\xf5\xa9\xb1\x4e\xdf\xf6\x94\x44" + "\x62\x0a\x1f\x98\xeb\x84\xbf\xed" + "\xf0\x38\x64\x53\x32\xdc\xba\x49" + "\x71\x75\x4f\x00\x41\xa5\xbe\x50" + "\xee\x94\x1c\xdf\x10\x7d\xc6\xba" + "\x31\xbc\x27\xb7\xa1\x73\x3d\x25" + "\x28\x6e\x68\x30\xf2\x1c\xd0\xb3" + + "\x3b\x5a\x6a\x30\x39\xc0\x0b\xa4" + "\x1b\x3a\x78\x96\xfd\x41\x0a\x4e" + "\xd4\xcd\x53\x02\x9a\xd3\xe8\xa1" + "\x38\x86\x38\xc7\x26\xbe\x80\x64" + "\x82\xf3\x85\x22\x1d\x5e\x36\xee" + "\x36\x5c\x0b\xec\x8f\x8d\x8d\x18" + "\x82\x4d\x0f\x1f\x48\x1a\xef\x34" + "\x9a\xd2\x87\xa4\xe1\x43\x8f\x1a" + + "\xa5\xdd\x02\x39\x7c\x14\xa8\xa5" + "\xb4\x73\x69\xfe\x06\xf7\xd2\x35" + "\x7e\x45\x57\xc2\xcf\xef\xc2\x5a" + "\x1b\x61\x00\x87\xd4\x48\x3f\x93" + "\xb2\xbe\x12\x49\x88\xaf\x65\xc3" + "\x94\xdf\x2e\x16\xe6\x4d\x5a\x7f" + "\x4b\xf3\x32\x0c\x7c\xba\x46\xc6" + "\x74\x10\x09\xb2\xf3\x6a\x2c\x63" + + "\x5f\x6f\xb2\x9b\x33\xa3\xf6\x10" + "\xb6\x85\x4d\x04\x8e\xdb\x85\x1e" + "\x54\x7e\x19\x94\x08\x7a\x69\xc3" + "\xa8\x4e\xcb\xa7\xc0\x8c\xe1\x65" + "\x6e\xfe\x71\xa4\x50\x4f\x8c\xa3" + "\x9c\x43\x13\x2f\x7a\x74\x31\xf0" + "\x8b\x31\x07\xc0\xba\xa6\xc4\x53" + "\x3d\xcb\xec\x1d\xe5\x3e\xda\xa8" + + "\x3f\x8f\xa4\x5c\xdf\x1a\xc0\xbf" + "\x84\x9b\x2a\xe2\x06\x2f\x35\x64" + "\x4a\x9e\x09\xc1\xa1\x4d\xe5\xce" + "\xc0\x89\x1b\xfa\xe8\x54\xda\xbb" + "\xfb\x55\x6e\x6f\xf5\x3d\x6a\x16" + "\x88\x6f\x17\x20\x24\x4a\xa4\x1c" + "\xff\xb5\xb7\xdf\x88\xfd\x6a\x93" + "\xa0\xd4\x11\x86\x37\x24\x4c\xe3" + + "\x92\x48\x55\x3e\x6d\x41\x24\x5f" + "\x45\x2a\x0e\x43\x3d\xb5\x13\x84" + "\xa0\xa2\x32\x90\xee\x6a\xc5\x99" + "\xb1\x67\xc3\xee\xf6\x2b\x43\x09" + "\xc1\xec\xf0\xda\xc6\x50\x28\x55" + "\x48\x20\xc9\x5b\x55\xce\xeb\x49" + "\x07\x13\x81\x54\xa6\x6b\xb6\xdf" + "\x97\x85\x29\x6f\x97\xf7\x84\x1b" + + "\xa4\xd5\xf8\x70\xeb\xd9\xb5\xd5" + "\x28\xb2\xbb\xd7\xe7\xdd\x5a\x37" + "\x32\x0b\x1c\x0c\x86\x8b\xe8\x31" + "\xaa\xdb\x3e\x17\xc4\x68\xf5\xd1" + "\x02\xdf\x59\x54\x83\xfc\x92\x15" + "\x7e\x9a\xcd\x0f\xfb\xc0\xea\x2b" + "\x0a\x3b\x47\x1b\xb8\xfd\xa6\xb0" + "\x48\xfc\xe8\x0f\x6f\x4c\x22\xe3" + + "\x89\xe1\x77\x57\x45\xc8\xa5\xa1" + "\x29\x28\x6f\x45\xe0\xbe\x10\xcc" + "\xd5\x2b\x76\xda\x56\x5c\xd9\x8a" + "\xa8\x1d\xd9\xe9\x14\x22\x2e\x15" + "\x74\x3c\xb2\x7c\x72\x0e\x5b\x97" + "\xdf\x66\x0c\xa9\x70\x76\x5d\xfd" + "\x53\xfc\x5f\x22\xad\xb8\xb5\xb5" + "\xae\xd2\xde\xfa\x73\xff\x6d\xab" + + "\xcf\x49\x35\x6d\x0f\xe5\x33\xd4" + "\x5e\x66\xcd\xfa\x6f\x69\x33\x6f" + "\xb4\xfc\x11\xce\xac\xfd\x5b\x69" + "\x60\x98\x7c\xaf\x52\xe2\x0e\x81" + "\x2c\xbb\x59\x71\xe1\x0f\x45\x65" + "\x7b\x35\x8b\x75\xbe\xbe\xdf\xf7" + "\x72\xea\x9f\xd6\x74\x7e\x05\x2b" + "\x45\x17\x73\x92\x7a\x71\x85\xd4" + + "\xef\xd7\x76\xb3\x84\x76\x6d\x8d" + "\x81\xda\xd5\x48\xac\x02\xbf\x3d" + "\x9c\x13\x89\x1b\x5a\x38\xa5\xfa" + "\xce\xa7\x20\x68\x85\xcb\x4d\x50" + "\x26\x9d\x1a\xe6\x45\x21\x98\xc0" + "\xaf\x25\x5d\xac\x32\x6c\x5c\xf3" + "\xc2\xb3\x27\x4e\x67\xa2\x3b\xaa" + "\xc5\x7a\x6c\x9f\xa0\xa3\x69\x2e" + + "\xcf\x86\x0b\xf3\x1d\x5c\x6a\x90" + "\x87\xef\x07\x4d\xfc\x66\x6f\xb1" + "\x61\x22\x01\xd4\xda\xc2\x75\xa9" + "\x1e\x36\xbc\x0f\xe6\x48\x97\xe6" + "\xc7\x00\x99\x2d\x36\x35\xa0\xa2" + "\x0f\xaa\xf6\x7c\xe1\x3c\x2a\x1f" + "\x87\x38\xe3\xa1\x3a\x44\xd5\x80" + "\xdf\xb4\x47\x5b\x8b\x24\xda\x6a" + + "\x1a\x72\x3c\xdd\x08\xbb\x9f\x1f" + "\x9c\x22\xb2\x46\x7e\xf9\xa1\x93" + "\xfb\x7e\xba\x31\x46\xad\xe5\x4e" + "\xa3\x10\xae\xf3\xa5\x5c\xaa\x6b" + "\x04\x02\x6c\x74\x3e\xfc\x81\x7d" + "\x0b\x06\x9a\x2b\xf0\x90\xcc\x9e" + "\xa7\x8c\x68\x7b\x2f\x16\x58\xdb" + "\xdf\xc1\x54\xf5\x99\x2a\x77\xf4" + + "\xf4\x4b\xdc\x67\x7c\x4e\xb2\xed" + "\x7b\x82\x4a\xaa\x43\xc7\xe4\xcb" + "\x2b\xf8\xcf\xfa\xf5\x72\x94\x22" + "\x9b\x4a\x2c\xcf\x82\xbb\xef\x2c" + "\xf1\x7f\x36\x59\xb8\x06\x6e\x38" + "\x75\xaf\xcd\xa3\x78\x59\x24\x32" + "\x98\xb1\x07\x98\x6d\xd3\xbd\x2d" + "\xe9\x11\x85\xb7\xe7\x95\x74\x43" + + "\x27\xa7\xdd\x77\x65\x6e\x16\x34" + "\xcf\xaa\xaa\x3e\xc1\xa3\xa4\xb6" + "\x40\x62\x2c\x9d\xc2\x49\xcd\x9c" + "\x63\xa1\x2b\xa4\x3d\x7f\xe1\xc2" + "\x33\x21\x6d\x7c\x5c\xeb\xf9\x91" + "\x06\x76\xa9\xe6\x2a\xbd\xce\x85" + "\xfb\x0d\xb0\x65\xbd\x35\x6e\x80" + "\x82\x2a\x39\xb9\x06\x79\x9f\x9e" + + "\x3b\x2b\x0d\x4d\x8a\x29\x9f\x23" + "\xf1\x07\xb2\xdb\xcf\x60\x97\x6c" + "\xeb\x2e\xf9\xd4\x3f\x20\xbf\xc8" + "\x9b\x4e\xa7\x7e\xe4\x2a\x0b\x29" + "\x3d\x7d\x3a\x16\x37\x93\xa6\x1f" + "\x14\xa4\xef\x87\xe8\x5e\x29\xd0" + "\x3f\x27\xf8\xf9\x37\x40\x84\x54" + "\x58\xab\x41\xe3\x62\xa8\x46\x30" + + "\x0b\xfc\xc6\x38\x53\xe9\x9f\xfb" + "\xc8\x79\x95\xac\xe8\xe2\x94\xe4" + "\x8b\xca\xd7\x69\x6f\xef\x24\xc4" + "\xec\x57\xb8\x4f\x15\x52\x0e\x63" + "\x48\xdf\xe2\x42\x2b\x11\x13\xf0" + "\xbf\x04\x52\x62\x08\xc9\xad\xef" + "\xce\xb0\x63\x11\x6c\xb1\x8b\x7d" + "\x89\x68\x14\xb7\xe3\x47\x51\xdf" + + "\xad\x75\xbf\xa2\x05\x8b\x37\x5b" + "\x92\x1e\xda\x25\x66\x4b\x37\xfe" + "\x12\x67\x76\xff\x00\x81\x4c\xfb" + "\x60\x46\xc8\xcb\x80\x63\x60\xbc" + "\xe4\xad\x10\x6c\xc9\x6e\x26\x27" + "\xa7\xec\xb6\x7a\xb5\xc2\x6a\xb4" + "\x00\xe8\x28\xbb\xd7\x73\xc6\xfd" + "\xfe\xe3\xc0\x23\x20\x5f\x64\xb5" + + "\x28\x2b\x56\x30\x5f\x0e\x43\x76" + "\x06\xd8\xea\x36\x10\xca\x41\x67" + "\x93\x12\x7f\x93\x31\x50\x6e\xbf" + "\xf0\x9a\x29\x22\x6e\x09\xc3\x32" + "\x22\xdd\x45\x21\x61\xb1\xa3\xd6" + "\x33\x86\x5e\xd7\x57\x90\x49\x6c" + "\xbd\xc2\xf1\x39\x51\x76\x99\xa5" + "\xf5\xab\x1f\x6b\x6d\x0c\x90\x3b" + + "\x63\x7c\x43\xe7\x16\x68\x29\xe8" + "\x11\x4c\x16\x76\xd2\xc0\xa7\x38" + "\x0e\x84\x29\x9c\xf9\x95\x10\x1f" + "\x3f\x09\xb9\x57\xb3\xb9\x12\x19" + "\x17\xc8\x39\xf8\x04\xd5\x09\xfe" + "\xdd\x4b\xdd\xbd\x3b\xfb\x64\x1f" + "\x34\x45\x04\xdb\x5b\xed\x42\xef" + "\xc8\x21\xe8\xb4\x95\xdd\x60\x15" + + "\x4e\x52\xb9\x70\x50\xaf\x39\xde" + "\x68\xc8\xd1\xad\xe9\x95\x69\x79" + "\xc9\x4c\x9a\x32\x28\xb8\x90\x97" + "\x64\xae\x62\x5b\xb7\xa2\xeb\x1e" + "\x2f\xc1\xe3\xd7\xf6\xd3\x7b\x61" + "\x21\x64\x33\xdf\x1c\x71\x7e\xdb" + "\xcf\x07\x89\xd7\x37\x09\xfc\x7d" + "\xd5\x8b\x1a\x84\x99\x7a\x93\x88" + + "\xba\x41\x0a\x5d\x4d\xc2\xa5\xb9" + "\x1e\x86\x6c\xb6\x02\x84\x29\x58" + "\xfc\xcd\x71\x4c\xf8\x6e\xdb\x99" + "\xd9\x4c\x36\xe6\xaa\xaa\xe2\x69" + "\xd9\xc7\x8b\x64\x18\x94\xf0\x4b" + "\x6f\x3c\x71\xeb\xe9\xc2\xb3\x5a" + "\xc2\x52\x6e\x0c\x58\xd5\x75\x6a" + "\x12\x00\x60\xe5\x24\x8a\x2b\x46" + + "\x8e\x85\x82\xfe\x08\x42\x54\xca" + "\x90\x1a\xc2\x3e\x4a\xaf\xa3\x51" + "\xd4\x14\x76\xc2\x63\x9e\xc1\x63" + "\x39\xe7\x05\xe0\x95\x8c\x08\x32" + "\x00\x8d\x4a\x94\xf9\x25\x50\x7c" + "\x48\x2a\x94\x9a\x7d\xe3\x98\x8f" + "\xe7\x45\x5c\x53\x51\x73\x35\x53" + "\x80\x1f\x89\x44\x1c\xf1\x41\xfe" + + "\x90\xc3\xa2\x5d\x9c\xe1\xf9\x20" + "\x8a\x6d\xbd\xda\x2f\xe6\x69\x1f" + "\x65\xbb\xaa\x27\x2e\xb6\x9e\x1b" + "\xb5\xbb\xbb\x3d\x37\x83\x09\xbb" + "\xda\x32\x36\x82\xc9\x88\x3b\x7d" + "\xde\xe7\x59\xa7\xf3\x74\x89\x6c" + "\x6c\x87\x52\x3d\x08\x78\x65\x49" + "\xd8\xcd\x45\xe0\xbc\x73\x64\xb5" + + "\x47\xe7\x53\x00\x0e\x7e\xe5\x5d" + "\x53\x8a\x1c\x56\x92\x65\xd3\x04" + "\xad\x2e\x7f\xca\x78\xd3\x06\x6a" + "\xdb\x59\xf8\x14\x20\x56\x61\xb3" + "\xf8\xf8\x19\x14\x17\x91\xb1\x4e" + "\x32\x99\x3b\x60\x25\x45\xbf\xd0" + "\x98\x58\xa1\x9d\xcd\x45\x3e\xfc" + "\x14\x8d\x32\x79\x71\x9f\xe8\x5e" + + "\x0c\x86\x36\xee\xe8\x42\x6c\x89" + "\x2d\xc2\x13\x41\xfd\x4d\xf0\xda" + "\x13\x42\x10\x44\xb7\xb7\xdb\x1a" + "\xea\x94\xd3\x1f\xa1\x5f\xfd\xe5" + "\x51\x05\x4e\x1a\x94\x5d\x23\x68" + "\x51\x01\xd1\x18\xbe\xcf\x72\x67" + "\x23\x45\x98\x09\xe3\x71\x60\x27" + "\x98\xba\x56\x5a\xde\x79\xe8\xe4" + + + "\x91\x94\x5b\x28\xb0\xaf\xaf\xaa" + "\x5e\x70\x4c\x1e\x88\xbe\xa0\x01" + "\xab\xca\xd9\x2a\x5d\x4f\x1d\xff" + "\x3f\x23\x7a\xc3\x4a\x9a\x34\x6e" + "\x16\x6a\x1c\x4a\x46\x12\x1c\xcf" + "\x60\x32\x38\x29\x66\x6b\x9e\xd9" + "\x71\x54\x6d\x5f\x66\x43\x3d\xea" + "\x9b\xc8\x8c\xff\x04\x4d\x97\x36" + + "\x57\x90\x92\x8f\x14\x9e\xf2\x27" + "\xdf\x53\xc8\xc0\x06\xae\x64\x7a" + "\xce\xc5\xe9\x58\x83\xd1\x6c\x25" + "\xa5\x92\xd0\xde\x82\xce\x9c\x9d" + "\xc7\xb7\x93\x6e\x79\x59\x6e\xcc" + "\x27\x9e\xbb\x31\x92\x70\xe4\xe1" + "\xa0\x29\x9e\xaa\x83\x30\x0b\xb7" + "\x44\xe6\x85\x37\x75\x1a\x18\xbf" + + "\x1e\x3f\x0a\x5c\xc8\xe8\xd6\x8e" + "\x7f\xc3\x87\x7c\x92\x24\xad\xbc" + "\x8d\xb7\xe3\x9e\xbb\x62\xfb\xfd" + "\x46\xba\xce\xcb\x77\xe4\xa8\xeb" + "\x4b\xde\xae\xee\xb0\x8c\xd3\x37" + "\xb6\xde\x76\x79\xe8\x98\xc4\x0b" + "\xfb\x47\x61\x6b\x04\x4c\x94\xb2" + "\x09\x96\x1f\xf7\x35\x3f\x12\x8b" + + "\xd0\xb9\x02\x14\x3f\xa1\xb3\xd3" + "\x63\xc8\x7b\x2c\xc3\x41\x34\x57" + "\x6e\x3e\x8c\x57\xc4\x1e\x30\x4b" + "\x7e\xf5\xda\x0a\xc4\xc9\x6f\xc2" + "\xa3\xce\x93\x74\xfd\x1b\xe7\x96" + "\x56\x14\xf8\x1a\x3f\x4b\x5d\xd0" + "\x8f\x60\x8c\x6a\x8a\x2a\xca\xda" + "\x76\xb2\x25\x07\xf6\x07\xef\x53" + + "\x78\x59\x43\xc7\xf0\x23\xe0\xba" + "\x19\x0e\xe3\x20\x88\xc8\x52\xb1" + "\xaf\x6f\xfa\xe3\x45\x16\x24\x9c" + "\x60\x3e\x82\x84\xc1\x95\x5d\x73" + "\x17\x53\x95\x03\x73\x75\x19\x03" + "\x95\x49\x3b\xf0\xa9\x02\x4b\x0b" + "\x00\x46\x27\x70\x59\xf5\x6b\x07" + "\x08\x75\xf5\xaa\x53\xcc\xc5\x32" + + "\xd2\xc5\xc7\xd5\xfd\xdb\x18\x03" + "\x2d\x34\x2b\x07\xa7\x8d\x8f\xb3" + "\x8a\xe3\x8d\x7b\xdc\xbd\x69\x35" + "\x42\x48\xc9\xa1\x87\x58\x5b\xf2" + "\x60\xad\x46\x29\x84\xb2\xd5\xb2" + "\x7e\x70\xd1\xe9\xad\x29\x4f\x85" + "\x09\x45\x6a\x2c\xdc\x59\x51\xaa" + "\x37\x98\x18\x57\xc0\x94\x9f\x89" + + "\xe7\x89\xce\x49\xe0\x36\xf5\x27" + "\xb5\x0c\x89\xcc\x39\x85\x90\x18" + "\xa1\x2a\x3c\xd8\xab\x09\x89\x30" + "\xd3\x3b\xb7\x1a\x2b\x14\xd3\xec" + "\x84\xab\xf5\xb3\x59\xbf\x85\x6a" + "\xc6\xa4\xbe\xf2\x68\x0a\x32\x3c" + "\x1f\x54\xa4\x6d\x38\xc5\x8d\xad" + "\x86\x11\xc4\xb7\xb0\x4e\xf3\xea" + + "\xd2\x49\xac\x46\xd6\xc9\xb5\xa6" + "\xa9\x7a\x13\x83\x0b\x7c\xc7\x42" + "\x38\x5a\x22\x68\xfc\x00\xd0\x24" + "\x07\xe9\xe1\x2f\xc8\xcf\x63\x0f" + "\x95\x1f\x44\xc6\x1b\xb0\xd1\x22" + "\x8f\x44\x8e\xec\x19\xf7\x38\x7d" + "\xba\xb1\x7f\x78\x5f\xfa\x33\x9b" + "\xdf\x58\x01\x19\xa1\xfd\xdc\x94" + + "\xca\x1a\x0a\x49\x26\x93\xc7\x63" + "\x02\x6b\x52\x41\x9c\xdd\x64\xcb" + "\x58\x92\x97\xa2\x91\x25\x77\xbb" + "\x46\x78\xd9\x48\x70\x29\x58\x3f" + "\xa7\x3b\x21\x7c\xd1\x70\x6b\xd6" + "\xd4\xce\xa0\xe8\xb5\xeb\x8f\xc2" + "\xc1\x38\x03\xc1\x31\x18\x91\x6b" + "\xf3\x26\x01\xbf\x89\xe3\x54\x0d" + + "\x9b\x68\x83\xb4\xfe\x2e\x24\x40" + "\x62\xc2\x3a\x51\xf6\xd3\x75\x25" + "\x72\xdb\xa6\x0c\xc8\x37\x00\xf3" + "\xe2\x4b\x86\x98\x82\xce\xfc\xc9" + "\x2d\x36\x49\x01\xff\x12\xa1\x84" + "\x71\xe9\x4a\x1c\x82\x75\xe5\x95" + "\x6c\xf8\x5c\x94\xa8\xb1\xa4\x1f" + "\x2f\x4a\x02\x0b\x34\xa7\x25\x45" + + "\x5f\xd8\x05\xc9\xc2\xd1\xea\xca" + "\x57\xae\x33\x07\x90\xf7\xd7\xe9" + "\x94\xdd\x7c\xf0\x5c\xa6\xc9\x24" + "\x31\x59\xb5\xa4\x9c\x35\x89\x73" + "\xf7\x45\x7e\x36\xb7\x09\x87\xf5" + "\xdc\x7a\x7e\xcb\x67\x30\x20\x1f" + "\x18\x28\xb7\xc7\xff\x4b\x44\x82" + "\x33\x80\xac\xba\x35\x3b\x30\x07" + + "\xfd\x09\x6f\x52\x45\xed\x7f\x05" + "\x0a\x24\x28\x81\x0c\xf1\xa4\xe8" + "\x8d\xfd\x2b\xff\xc4\xef\x32\x93" + "\x31\xaa\x35\xbd\xa0\x77\x4e\x21" + "\x0e\xa4\xfa\x14\x73\x6d\x89\x32" + "\x86\xf1\xe5\x01\xec\x67\x78\x76" + "\x3e\x81\xa1\x17\xf1\xf8\xad\xc9" + "\x95\x17\x74\x54\x78\xda\x6c\xcb" + + "\x85\xe1\xda\x01\x01\xd0\xb4\xb7" + "\xbc\x94\x7a\x9b\x0b\x4e\x43\x45" + "\x0b\xcb\xd8\xfb\xaf\x39\x43\xf5" + "\x9e\xf4\x8e\xe9\x9e\x56\xc4\xdc" + "\x99\x12\xa5\x09\x8a\x31\x89\x77" + "\xd8\x25\xb0\xb2\x06\xd2\xb4\x81" + "\x92\x57\xe8\xfa\x18\xa4\x4a\xf6" + "\xf7\xba\xd7\xac\x8f\x25\x50\x3e" + + "\x68\xd8\x9f\xa1\xd3\xeb\x72\xc0" + "\x3b\xdd\x8d\xdb\x1c\x48\x2e\x61" + "\x52\xd8\x64\x1a\x54\xd7\xe1\xb4" + "\xab\xc4\xc6\xc4\xac\x95\xef\x00" + "\x46\x6c\x0a\xaa\xed\xd2\x36\x15" + "\x90\x47\x77\x43\x86\x40\x29\x61" + "\x10\xda\x3f\x34\xe8\x25\xaf\x54" + "\xf2\xd6\x25\xfd\x8d\xd9\xf9\x9f" + + "\xa4\xbe\x79\x55\xdf\x96\xd2\x4c" + "\xf1\xda\xee\x5c\xc8\x5a\xe3\x10" + "\xb1\xc5\xbc\xe3\xfd\xc5\xc4\x04" + "\xf9\x2c\x41\x89\x8a\xee\xf9\x95" + "\x0f\xeb\xb6\x82\xee\x59\x94\x2c" + "\xdd\xaa\xc2\x95\x65\x57\x84\x2e" + "\xfe\xfc\x27\xd3\xae\x84\x4a\x77" + "\x76\xd4\x68\x03\x22\x37\xc9\xd8" + + "\xef\x36\x6c\x29\x10\xde\x1c\x21" + "\x77\xda\xc4\x82\x72\x96\xe8\x7e" + "\xda\x36\x78\xa5\x70\xd2\x17\xb6" + "\x0b\x56\xb7\x9c\x31\x9c\xcd\xf0" + "\x90\xfe\x55\xe4\xf7\xcb\xfd\x01" + "\xf3\x34\x73\x7e\xbb\x3c\xb5\x3f" + "\xec\xe4\x7d\x4e\xa4\x2e\x1e\x78" + "\xd0\x4f\x38\x0b\xad\xb3\xda\x8a" + + "\xb8\xb3\xba\xbb\xf2\x90\xe6\x60" + "\x6b\x81\x04\x8b\xae\xf8\x51\x48" + "\xd2\xe4\x92\x9c\xab\x46\x20\xc7" + "\x6b\x13\xf3\x7c\xa1\x74\x8c\x51" + "\x4c\x7d\x87\xf9\x0a\xb5\x4e\xff" + "\xbb\xca\x19\xa9\x90\x8d\x57\x14" + "\xb6\xb2\x5e\xac\xc4\xf8\x18\x82" + "\xe4\x16\x20\x54\x47\xc5\xcc\xa3" + + "\x85\x7b\xea\x1e\x6c\xa7\x3e\xe3" + "\x5e\xf8\xd4\x92\x61\xb4\x52\x23" + "\xbb\x15\xe1\xaf\x34\xd3\x01\xf1" + "\xa3\x75\x91\x88\x94\x12\xbc\xfa" + "\x25\xf9\x33\x52\xc0\xcd\x6b\x7f" + "\x55\xec\x7f\xe7\xdb\x02\xa8\xe0" + "\x59\xb6\x69\x80\x75\x7b\xb4\xbd" + "\x74\xbd\x8f\xf9\xde\x12\x5e\x1c" + + "\xbb\xdd\xd8\x89\x58\x46\x6c\x65" + "\xe8\x8e\xf3\x70\x6e\xb2\x30\x88" + "\xb0\x12\x12\xde\x5c\xfd\x20\x43" + "\xb2\xed\xa2\xe4\xcf\x30\x4f\xc3" + "\xb8\x64\xab\x56\xa3\x31\xb1\xab" + "\x26\x5d\x9c\xd9\xcc\xf0\x77\x7f" + "\x94\x1d\x98\xbf\x37\x6a\x85\x66" + "\x6e\xd7\x8b\x73\x09\x6d\xe7\x19" + + "\xc0\x18\xb6\x53\x7d\xd4\x6b\x1c" + "\x23\x79\x22\x6a\x6c\xf4\x24\xc4" + "\x64\xd9\x92\xdd\xde\xff\x03\x73" + "\xf2\xab\xb5\x71\x78\x28\x71\xe9" + "\x1d\x56\x15\xf8\x32\xa6\x48\x8f" + "\xd1\x55\xc0\xd3\xf5\x8f\xf4\x85" + "\x4f\x68\x25\x75\x27\x14\x2a\x22" + "\xc3\x0c\x36\x67\xa0\x41\xd8\xd0" + + "\x99\x4a\xc3\xf2\xb1\x44\x0c\x86" + "\xac\x55\x58\xbf\xa4\xac\x00\x3b" + "\xbe\x37\xaf\xfa\xa0\xaa\xf6\xab" + "\x08\xec\x53\x2a\x82\x36\xf4\x65" + "\xe1\x12\x1b\xa1\x01\x58\x9a\x1d" + "\x75\xd4\x0e\xe2\x2c\xab\xa7\x78" + "\xd5\xe0\x41\x9a\x7e\x06\xe1\x0d" + "\xea\x23\x50\x30\x5f\x3f\x47\x30" + + "\xc6\x68\x7f\xf9\x52\xb3\xb7\xdb" + "\x58\xcf\x02\x0b\x50\x3b\x77\x0c" + "\xd9\x96\x1f\x3c\x21\x48\x2e\xea" + "\x15\x18\xe0\xee\xb0\x57\xb3\xff" + "\x39\x80\xf2\xe0\xcd\x24\xc9\xb9" + "\xe4\xfb\xa3\x46\x5a\xc9\x36\x0b" + "\x6c\xdb\x46\x5e\xa4\xae\xaa\x1f" + "\xff\xaa\x28\x19\xc3\x75\xe5\xca" + + "\x6c\xb9\xcb\x70\x2a\x96\x3c\x26" + "\xa9\x24\xd1\xbc\x2a\x36\x34\xe0" + "\x8d\xe5\x2a\x3c\x28\xdb\x20\xf1" + "\x07\xd5\xf6\xfe\x49\x8d\xa3\xb9" + "\xfd\x40\xf1\x1f\x82\x2a\xfd\xb1" + "\xe0\xe7\xae\x20\x30\x2f\x16\xbd" + "\x49\x19\x25\xcb\xd4\xa5\x17\x4e" + "\x3d\x1c\x7e\x4f\x83\xcb\xeb\x2a" + + "\xf9\xf0\x9f\x59\x2b\x8a\x77\x01" + "\x6b\xfc\x04\x81\xd7\x23\xa9\x68" + "\xf3\x4f\x69\xda\xdf\x44\xfa\x5b" + "\x12\x7f\x66\xf7\xdb\x99\x71\x4f" + "\x79\x2a\x6f\xe4\xf6\x8f\x6d\xc0" + "\x1d\x13\xf8\xe9\xad\xde\xb5\x08" + "\x7c\xce\xb4\xab\x59\x9a\x51\x02" + "\x3e\xec\x2a\xb4\xbc\x10\xf7\xc4" + + "\x19\x27\xc2\xc0\xca\xd3\xbf\xd8" + "\x1e\x15\xca\xc9\xe4\x09\x02\xc6" + "\x9c\xa6\xa1\xd9\xb5\x4a\x74\x7a" + "\x8f\x7f\x93\x14\x8b\x04\xe5\x6d" + "\x04\xac\x15\xe1\xd8\x38\x19\x17" + "\xd2\x16\x6b\x1c\x40\x09\xf7\x7d" + "\xe7\x94\x8e\x7f\x63\xb6\xae\xa6" + "\x94\xf0\x2c\x2a\x8e\x38\x30\xc1" + + "\x7c\x33\x6f\x78\x9d\x71\xb6\xcd" + "\x7d\x39\x04\xe7\xd2\x1c\xc0\xd9" + "\xef\x2f\x5c\x55\x20\x3f\x4a\x0f" + "\x23\xf2\x0a\x7c\x09\x25\x45\x00" + "\x76\x8e\xdb\x84\x47\x80\xa5\x54" + "\x06\xaa\xc8\x93\xaa\xf1\xac\x3b" + "\x22\x94\x91\xf7\x7c\x95\xca\x11" + "\x40\xaa\xcd\x78\x53\x10\x64\x50" + + "\x75\xa7\x67\x6c\x31\xb7\x6e\x9f" + "\xb1\xd0\xc5\xef\x1a\x47\x10\xcb" + "\xb2\x06\xb8\xe1\x0c\x75\x33\xb4" + "\x7e\xae\xb1\x57\x4d\x71\xc5\x19" + "\x3f\xfd\x03\xed\x7b\x8b\xdc\xc0" + "\x4e\x19\xbc\x31\x4f\x34\x03\xdd" + "\xb5\x20\x63\x8c\xa7\x52\x6c\xa6" + "\x93\xfd\xb6\xd0\xe3\x2c\xc8\x8b" + + "\x0d\x04\x0b\x0e\x0f\xa9\x28\xb2" + "\x7f\x89\xff\x45\x82\x2d\xf0\xba" + "\x22\x61\xfa\x00\xe6\x79\xac\x2a" + "\x57\xf5\x36\x8e\x17\x88\x82\x24" + "\x56\xc3\x3e\x11\x31\x1d\x52\xb9" + "\xf8\xf1\xef\x15\x1e\x86\x48\x9e" + "\x15\x17\xd4\xe0\x12\xd4\xa1\x2a" + "\xb8\x31\xf1\x53\x03\x62\xf8\x71" + + "\x1e\xc5\x73\x6f\x3d\x48\x2a\x6d" + "\xdd\xc2\x0d\xea\x12\x24\xcb\xa4" + "\xff\x17\xb9\x1e\x41\x3c\x66\x50" + "\x9e\x29\xde\xea\xcf\x74\x3a\x3d" + "\x02\x92\x7a\x4a\x0f\x99\xb3\x29" + "\x3d\x5c\xb1\xa7\x59\xcf\xbc\xa9" + "\x08\x92\xdf\xa5\xdc\xcc\xa3\x66" + "\x29\xf9\xf2\x43\x14\x7c\x02\x48" + + "\xb4\xaf\x8c\x09\xbb\xa3\x44\xe0" + "\xaf\x8c\xd4\x60\x10\x23\xed\x27" + "\x4d\xb8\x31\x3a\x75\x56\x2b\x54" + "\xd7\xbe\xdd\xfc\x50\xdd\xf3\xcb" + "\x30\xd8\xb1\x41\x16\x1f\x03\x25" + "\x27\x1e\x0c\xcb\x1d\x85\xec\xa7" + "\xdb\x75\xae\xb5\xe0\x8f\x1c\xac" + "\x20\x21\xc5\x08\x57\x75\x4c\xb2" + + "\x9e\x03\x07\xd6\x71\x0e\xbb\x1f" + "\x46\x45\x3a\xcd\x15\xe2\x70\x2b" + "\x91\x40\x32\x53\x1d\xf0\xd2\x32" + "\x9b\xb1\x0a\x18\x08\xff\x96\xb7" + "\xaa\xc4\x57\x3c\x86\x7a\xd8\x32" + "\x27\x9a\xc4\xb7\xaf\x9c\xed\x2a" + "\x98\x0d\x63\x31\xac\x5e\xb3\x9f" + "\xa3\x20\x3e\x5c\xdf\x8c\x8e\x33" + + "\x40\x09\xd8\x4e\x8b\x36\x14\x30" + "\xdd\xce\x6f\x7a\x56\xd0\xe6\x67" + "\x9f\x57\x97\xca\x49\x8c\x20\x7c" + "\xf6\x97\x35\xa2\x81\x7a\x3d\xfe" + "\xe2\x6a\x09\x7e\x02\x32\x20\x5e" + "\x66\x93\xb3\x24\xe7\xe1\xf3\xb1" + "\xfc\xdf\xdc\x2f\xf3\x26\xda\x26" + "\x83\xbe\x97\x60\x1d\x2f\x42\x79" + + + "\x81\xb3\xb3\x9d\xfb\x2c\x3a\x26" + "\x4b\x0a\xdf\xd4\xee\x2d\x3a\x9c" + "\x1f\xe6\x04\x7d\xe9\x06\x8d\x72" + "\x25\x93\x44\x42\xbc\xdf\x1a\x8b" + "\x1b\x3a\x05\x7e\x39\xd9\xc1\x6e" + "\x07\xf7\xda\x66\xc7\xe5\x2b\xee" + "\xab\xc7\x0a\x81\x14\x1e\xba\x80" + "\x74\xf1\x30\xf5\x78\xe7\x2a\xdd" + + "\x8b\x9d\x5b\x20\x7a\xd9\x35\x04" + "\xd4\x56\x67\x05\x64\xf0\xb8\x6e" + "\x0e\x21\xf8\xb6\x8b\x8a\xe8\xd5" + "\xea\xd9\x9f\xec\x2d\xf1\x0e\x07" + "\x6a\x87\xcc\x3b\x05\x95\x84\x4d" + "\xe3\x4c\x40\xa7\x38\x53\xa7\x12" + "\x5e\xdb\xa1\xb8\xe1\x49\x2b\xd2" + "\xad\xa5\xbf\x14\x51\x20\x1f\xec" + + "\x36\x8f\x82\xb6\x79\xeb\xba\xad" + "\x9e\x5b\xbd\x01\x58\x02\x7a\x9d" + "\x0c\x4b\x84\x1e\x0d\x1e\xa0\xed" + "\xc9\xdf\x7e\x88\x75\x51\x62\x4b" + "\x21\xb6\x69\x96\xdd\x9f\x10\x14" + "\x98\x7b\xf8\xf6\x56\xca\xa2\x88" + "\xbc\xf6\x0d\x17\x88\xb7\x2e\xfe" + "\xf9\x73\xa4\xff\xf4\x06\xea\x0c" + + "\x33\x3d\xe8\xc4\xb5\x81\xed\x43" + "\x8b\x48\xfd\x5e\x79\x58\xf3\xd9" + "\x0f\x4d\xeb\x9d\x0f\x62\x4a\x16" + "\x94\x73\x6a\xac\xdb\x7b\x92\xc6" + "\x03\x0f\x9e\x9f\xf7\x8d\xc2\x45" + "\xa9\xe1\xd7\xfc\x1e\x66\x68\x28" + "\xf1\x48\xa3\xff\xd0\xe8\xf4\x7c" + "\xe0\x38\x85\x39\x84\xc2\xd4\x6b" + + "\x19\x86\x9a\x28\x91\xa0\x18\x26" + "\x73\xb1\x71\x66\x60\x6e\x79\xef" + "\x32\xc6\x90\x90\xe5\x46\x4e\x66" + "\xfb\xf8\x66\x1e\xd4\x62\x80\xa3" + "\x4e\x27\x73\x05\x20\x4a\x74\x6c" + "\x94\x13\x27\xa9\xe4\x67\x7b\xd0" + "\x20\x0e\xdc\x6b\xb2\x23\x12\x39" + "\xa7\x05\x0a\xeb\xf1\x93\x2d\xbe" + + "\x41\xd1\x36\x3f\x53\x2e\x3e\xf2" + "\x42\xa4\xfc\x4d\xd4\xb3\x4b\xe8" + "\x3a\x02\x7c\x6b\x8d\xa4\x04\xb8" + "\x3b\x1c\x43\x76\xfa\xa8\x16\x1e" + "\xe0\x72\xd4\xdd\xad\x52\x54\x1b" + "\x27\xe1\x1e\x0d\xe7\x5e\x40\x7d" + "\x99\x75\xa2\xff\x1d\x6f\xfc\x50" + "\x35\x1b\x39\xbf\x3c\xc5\x1a\x35" + + "\x6b\x89\x44\x44\xb8\x14\xfa\x7e" + "\xfb\x27\x40\xf9\x2f\x4d\x97\x64" + "\x7d\x48\x84\xde\xe8\xd0\xdc\xef" + "\x9b\x98\x48\x2b\x60\xb2\x45\x8c" + "\x87\x34\x46\xd8\xc2\xbb\xfc\xa8" + "\x6c\x47\xbc\x3f\xf7\xb3\xb2\xd1" + "\xc0\x43\xf4\xc8\xb7\x05\xd0\x21" + "\x9c\x13\xc0\x40\x67\x2e\x8f\x51" + + "\xc1\x5f\xd7\x06\x8c\x6e\x03\x56" + "\x9f\xa8\x49\x32\xb7\x7b\xcf\x2d" + "\xdd\xe7\x45\xe2\x3d\x1d\xdd\x81" + "\xa7\xe2\xd6\xeb\x4b\xdc\x78\xf5" + "\xa0\xe7\x2c\xdf\x03\x89\x02\x4c" + "\xac\xaf\x39\x9c\x88\x62\xe3\xae" + "\xab\x04\x64\x14\x31\x7c\x84\xdc" + "\x18\x78\xe9\xa4\xd8\xc0\x04\x63" + + "\x91\x67\x1f\xa9\xa2\xdc\x51\xae" + "\xfc\x9e\xaa\x9b\x90\x41\xbe\x2a" + "\xc1\x7a\x9c\x55\xf4\xe2\xd2\xd9" + "\x3a\x77\x9f\xfc\x51\x4b\x2f\xe8" + "\x1c\xe8\x73\x40\x27\x30\x71\xa7" + "\xfc\x96\xb5\xfb\xac\x6f\x27\xc0" + "\x0c\xf7\x84\xa6\xc9\x9f\x81\x1d" + "\xe0\xb1\xf7\xc9\xdd\x7f\xb4\x29" + + "\x40\x19\x9b\x45\x03\xe1\x8d\x35" + "\x93\x3e\x01\x5b\x59\x1c\x88\xec" + "\xd3\x2a\x53\x49\x93\x4c\x57\x51" + "\xde\x46\x7b\xb3\x45\xd4\xb1\x2d" + "\xd8\x9f\x23\xdf\x87\x5b\x44\xc6" + "\xee\x24\x1d\x15\x75\xaf\x18\xc7" + "\x59\x62\x3c\xf4\xa4\xc4\xa1\xae" + "\xf7\x02\xbe\x70\xd7\xe5\xc0\x40" + + "\xf2\x33\x1b\x72\xf4\x90\x45\x6a" + "\xea\x04\xdf\xfe\xfb\xf1\x24\x21" + "\xe7\xef\x45\x97\xde\x3c\xe5\xf8" + "\xd9\x46\xf0\x65\x32\x04\xe1\xe7" + "\xe6\xc7\xd0\xe4\x8e\xa2\xfc\xc3" + "\x1b\x3b\x25\x87\x9a\x33\x7e\x84" + "\x43\xe6\x43\x37\x48\x53\x59\x9b" + "\xc5\x2f\xd1\x4f\x0b\x0a\x6a\xcb" + + "\xcc\x2d\xd0\x27\xc3\x36\x68\xfb" + "\xc2\xbc\x68\x7a\x82\x09\xd0\x5a" + "\x2d\x91\x5e\x00\x4c\xb4\x24\x1b" + "\xfe\xdc\x1f\x81\x0f\xd2\x83\xcc" + "\x0c\xba\x6f\x66\xc1\x7e\x52\x36" + "\x35\x46\x75\x14\x97\x81\x94\x69" + "\xc2\xa9\x6d\x55\xa8\xb1\xdc\xfc" + "\xb2\x32\xa7\x81\x67\x42\x93\xa5" + + "\x1d\x18\x14\xa7\xed\x14\x12\xec" + "\x41\xb3\x67\x60\x3b\xc1\x9a\x60" + "\x1f\xdf\x45\xa5\x97\x4c\x4b\xff" + "\x6b\x07\xd2\x34\x01\x05\x24\xa1" + "\x97\xca\x09\x14\x23\x0c\xfa\x6e" + "\x43\x8c\x63\x20\xa8\xc1\x4c\x25" + "\xcd\x46\xfb\xdc\xaf\x63\xe3\xd4" + "\x27\x2a\x94\x03\xc3\xad\xc2\x62" + + "\x83\x64\xe4\x56\xf0\x9d\x7b\xc6" + "\x56\x63\x73\x63\x20\xbb\x5a\xa5" + "\x52\xbc\x51\xc5\x98\xc0\x93\xab" + "\x4b\xe6\x5f\xb1\xf9\x49\x2b\x38" + "\x47\x8d\xff\x4d\xad\x21\xc2\x9e" + "\xd6\xf4\x7d\x43\x15\xf6\xca\x79" + "\x09\x65\x45\xbb\x64\xdc\x13\x5f" + "\x14\x07\x1f\x19\xd9\x89\xc5\xe4" + + "\x09\x0e\xd4\x3f\xab\xa8\xb6\x27" + "\xa9\x3e\x31\x77\x2e\x84\x55\xe4" + "\x8b\x98\x55\x1f\xe2\xd1\x51\x8b" + "\xfc\xbb\x2b\x06\x73\xdd\x16\x57" + "\xde\xf3\x8b\x4e\xe5\x11\x3c\x63" + "\x3b\xbe\x85\x1b\xb6\x77\x0e\x9a" + "\xa6\xcc\x11\x09\x29\x07\x51\x56" + "\x0f\x59\xa6\xef\x95\x64\xe7\x27" + + "\xab\x3a\x0d\x07\x33\x8b\xac\xe4" + "\xe5\xd5\x2c\x9a\x2b\x67\x43\x26" + "\x73\x91\xfc\x1c\x9b\xf7\xef\x52" + "\x3f\xc1\xa7\x90\x9b\xa4\x5c\x66" + "\x98\xb9\xef\xb3\x59\xda\x8d\x5a" + "\x41\x13\x2f\x05\x2d\x92\x5b\x8a" + "\x30\xa5\xf9\x3c\xab\xbb\x9e\xae" + "\xd7\xa4\x6d\xf5\x7b\x6e\x98\x35" + + "\xcc\x13\x35\xff\x5c\x6b\x63\x3a" + "\xdd\xf7\x98\x31\xba\xf8\x0c\xbb" + "\x86\x6f\xf1\x41\x22\x05\xd4\xb8" + "\xbf\xa7\x13\xde\xd8\x75\x05\x76" + "\x81\xa1\x7a\x9f\x16\x4e\xf7\x36" + "\x1c\xed\x09\xf5\xcf\x3e\x3a\x16" + "\x91\xa4\x40\x3c\x1f\xd6\xea\x6a" + "\xaa\xfc\xe8\xdf\xfc\x95\x8c\x15" + + "\x6f\xa4\xcd\x13\x6e\x1b\x99\xa3" + "\xd0\xae\x2f\x34\x15\x24\x48\x79" + "\x70\x59\x6b\x66\xde\x5b\xba\xf3" + "\xdd\xb6\x6a\xb2\xbc\xe6\x52\x1d" + "\x3d\xdd\x08\x86\xe7\xa1\x8b\x76" + "\x86\x65\x07\xea\x2a\xdb\x30\x49" + "\xfa\x1a\xdc\xe7\x14\x57\x57\xd9" + "\x17\x88\xc5\xf7\x7d\xbf\xc7\x1f" + + "\x6c\xe9\xee\xd9\xcd\xac\x47\x6b" + "\x37\xec\x8c\xe5\xfb\x77\xa2\x0c" + "\x2a\xc4\x02\xe7\x13\xe4\x3f\x11" + "\x51\xbe\x7c\xc4\xee\x64\x17\xdd" + "\x39\xd7\x3e\x7b\xde\x7c\x1e\x04" + "\xc0\xe1\xe9\x5c\x59\x74\xcb\x50" + "\x12\xb2\x25\x29\x13\x85\x56\x35" + "\x1c\x08\x1b\x00\xc4\x95\xff\x7c" + + "\x54\xb4\x88\x80\xbd\x4c\xee\x63" + "\x8a\x0c\x9e\x9a\xf7\x32\x7f\xdb" + "\xcb\x47\x24\x6b\x18\xd4\x77\xb3" + "\x9b\x21\x70\xd3\xaa\x82\xe9\xe3" + "\x93\xa5\xa2\xc2\xe4\xc1\xcc\x06" + "\x4f\xf2\x73\x07\x65\x68\xc3\x72" + "\x23\x94\x85\x95\xa7\x4d\x3b\xa1" + "\x8f\x0c\x04\x75\x33\x1d\xbf\x8b" + + "\x91\xc9\x50\xda\x73\x09\x6f\x72" + "\xe2\x6e\x2d\x82\x5b\xcd\xaf\x48" + "\x71\x77\xfd\x20\x8b\x71\xfc\xe5" + "\xa1\x07\x08\xfd\x7d\xe7\xe8\xb9" + "\x3d\x70\xa7\x99\x44\x0f\x5e\x7f" + "\xf3\x36\x8e\x61\x0e\x93\x72\x69" + "\xbe\x7b\x80\x23\xb8\x77\x7c\x2b" + "\x50\xff\x27\xcb\x05\x24\xb8\xe5" + + "\x62\x90\x37\xbd\xe3\x8b\x8b\xba" + "\x92\x4a\xce\x2d\x1d\x7a\x4b\xd6" + "\x37\x2e\x95\xb2\xc5\x73\x0a\x04" + "\xca\xae\x38\xd4\x2e\x25\x9e\x0a" + "\xcb\x3b\x9d\xc3\x6b\x95\x43\xdd" + "\x63\x2d\x2b\xb3\x00\xca\x31\x1a" + "\x18\x7a\x41\x5c\xb8\x33\x71\xd6" + "\xc8\x42\xf4\x2e\x90\x47\x8e\xd0" + + "\x80\x09\x5c\x25\xe9\x1a\xcb\x98" + "\x9f\x73\x4a\x2b\x81\x63\xd8\x4b" + "\xa1\x45\x4a\x1e\xe1\x31\x5c\x5a" + "\x2f\xdb\xb0\x9c\xfe\x55\x5d\x1e" + "\x29\xcc\xf5\x8f\x06\x1b\x66\x74" + "\xf4\xa4\xb8\x0e\x9f\x38\x6b\x02" + "\x24\x8c\x84\x58\xa4\x21\x6b\x53" + "\xb0\x72\xdc\x81\xec\xf8\x5b\x2e" + + "\xac\x6a\x88\xad\xd0\x87\xc1\x03" + "\x45\xb6\x71\xb7\x8a\x87\x16\x5c" + "\xab\x45\x40\xc7\x6f\xfc\x7d\xb0" + "\xed\xca\x00\x78\xbf\x60\x63\x2c" + "\xa3\x72\xc9\xb9\xb5\x5b\x29\x24" + "\xba\x6d\x9a\x7c\x8e\xf8\xe6\xc9" + "\xa6\x9a\xa7\x92\x24\xbf\xff\x90" + "\xc2\x6a\xc2\x41\x0a\xd5\x29\xde" + + "\xe6\xcb\x09\xd3\x83\xf4\x0a\x9f" + "\x4f\xed\xbc\xe0\x8a\x0d\x02\x5b" + "\xe3\x23\x80\xb3\x6d\x98\x6e\x60" + "\x33\x69\xbc\x1a\x9d\x2c\x8f\xad" + "\x93\x0e\x40\xe7\x1d\x2e\x29\x19" + "\x4d\x5e\xbe\x52\xa9\x18\x3e\xfe" + "\xbf\x80\x06\x2e\x1d\x77\xe9\xe8" + "\x63\xb0\x4d\xc5\x98\xec\x5b\x8c" + + "\x1f\x5d\xa5\x74\x2a\x66\xf9\x2a" + "\xd8\x66\x6f\x04\x8f\xf2\xfb\xe3" + "\x94\x47\xdc\xd4\xb4\x2a\xa7\xa3" + "\xd8\x2d\x7c\x5c\x45\x9f\x77\x09" + "\x8d\x9d\xd1\xc3\xaf\xbd\x93\xd8" + "\xdf\xa6\xd6\x57\x94\x50\xa7\xd5" + "\x55\x62\x2e\x95\xf9\xfe\xf8\x8c" + "\xff\x8a\x9a\xda\xfb\x7c\xa6\x3d" + + "\xcd\x0d\x16\x2c\x2a\xf6\x23\x4c" + "\xef\xea\x90\x8f\xe3\xc5\xe6\x34" + "\x5a\x5d\xa6\xa9\x19\x55\x86\x35" + "\x3d\x8a\xd3\x8f\xae\x8a\xc4\x07" + "\x27\x85\x06\x50\xda\xae\xe7\xb7" + "\x6a\x93\x90\x1c\x23\xef\x09\x2c" + "\x4c\x32\x79\xe8\xb6\xfe\xec\x31" + "\x38\xc9\x0e\xfb\x6b\x1f\x87\xa0" + + "\x5d\x83\x4d\xd8\x68\xfb\xf0\xb1" + "\xe6\xc1\x1d\x86\x39\xaf\x0c\xc9" + "\xd7\xf8\x94\x75\x46\xb0\xe5\x12" + "\x92\x2b\x01\x65\xe2\x7a\x89\x26" + "\x5d\x75\xd6\xa4\x08\x8a\xf6\xbc" + "\xda\xfb\x91\x09\x1c\xe4\x3e\x40" + "\xe8\x17\xbf\x3b\x3e\x34\x3e\x73" + "\x65\x3d\x9b\x67\x0d\x98\xc7\xd2" + + "\x05\x13\xe1\xd2\x32\x62\x05\x33" + "\x6f\x7a\xc0\xf3\x92\xe4\x6b\x96" + "\x9d\x50\x15\xbb\xff\x78\x88\x6a" + "\xa4\x59\x9b\x0a\x01\x11\x22\xff" + "\x29\x01\xe3\xab\x4a\x56\x9f\x6c" + "\xcf\x64\x6e\x33\x40\xc9\xf2\xc6" + "\x22\x80\x0c\x8b\x62\x52\xe7\x0f" + "\x87\xdb\xe8\x6a\xe9\x67\x02\xbe" + + "\x2b\x04\xbc\x93\xf1\x92\xe1\x22" + "\x58\xc4\x37\xb2\x34\xb5\x85\xf0" + "\x68\x41\x2c\x83\xbd\x92\xd1\xa0" + "\x1d\x27\xf6\xbd\xe3\xe9\x76\x7a" + "\xb5\x11\x89\xb8\xfa\x82\xa8\x52" + "\xb5\x0e\xdb\xb4\xe4\x45\x53\xc8" + "\xff\xc3\xa7\x81\xa6\x02\xbe\xa3" + "\x69\x04\xec\xf0\x8c\x9c\x88\x51" + + "\xe5\x29\xe8\xa5\x69\x13\x03\x9d" + "\x41\xaa\x07\x16\xfc\xc6\xb4\xcb" + "\xc1\x84\x1d\x24\xa6\x59\xac\x75" + "\xee\xe0\x29\x88\xbf\xf2\x43\xc0" + "\x85\xe1\xa5\x8e\x75\x8f\xa3\x82" + "\x9f\xbd\x7c\xd8\xb9\x40\xda\x8b" + "\x01\xc6\x8f\x2d\x5e\xe7\x65\x9e" + "\xb3\x90\x56\xa3\x74\x5f\x51\x3d" + + "\xac\xe5\x79\xda\x4f\xcf\x4a\x53" + "\x5f\x21\x30\x86\x3a\x3b\xb8\x68" + "\x6e\x75\x85\xd0\x2e\x8b\x74\x5c" + "\xb2\x7c\xd3\xe5\x58\x72\x31\xb0" + "\xc4\xc2\xcc\xc5\x1a\x84\x35\x67" + "\x69\x50\x9d\x3d\x6b\xc9\x7d\x7d" + "\xbd\x54\x17\xfd\x10\xe4\x47\xa1" + "\xd5\xdd\x99\xd3\x94\x6e\x29\x65" + + + "\x3a\xfb\x0c\xb3\xcd\xc4\xe0\xd7" + "\xc8\xb4\x9d\x6c\xc1\xb8\x09\x6d" + "\xdf\xd9\xc8\x07\x42\x1a\xba\x40" + "\x6d\xc6\x52\x1c\xf7\x95\xd4\x6f" + "\xda\x64\x52\x27\x9f\x16\x0e\xfb" + "\x62\x83\x7d\xe5\x46\xb7\xc2\x80" + "\x22\x72\xad\x49\xf7\x87\xd9\xed" + "\x7b\xec\x98\x43\xaf\x29\xc2\xfd" + + "\x58\x6a\x66\x52\x84\xed\xd1\xb0" + "\xc2\xc3\xa9\xe6\x00\x6e\xcb\x4b" + "\x08\x64\x90\x26\x1c\x41\x57\x3c" + "\x00\x64\x55\x13\x55\x07\xc2\xcf" + "\xa3\xdb\x94\x52\x50\x1c\x8b\xa0" + "\x1e\xd3\x7d\x8b\x86\xa2\x0b\xa3" + "\x74\xca\x1e\x99\x0e\xa9\x0b\xd7" + "\xb9\xc2\x62\xe7\x2c\x14\x4e\x09" + + "\xef\x13\x7f\xac\x9b\x43\xea\x88" + "\x14\x7d\x9a\x8d\x3f\x14\xaa\x65" + "\x1a\x2f\xcb\x20\x2d\xcf\xe0\xff" + "\xd1\x6a\x1c\x38\xf1\x7b\x7b\x84" + "\x4d\x0b\xc8\x8a\x14\xb8\xf5\x56" + "\xf2\xaf\xce\x35\x18\x44\x1b\x04" + "\xef\xfc\xa5\xcd\xc0\x88\x90\xde" + "\xce\xb8\x83\xe0\x9b\x51\x68\xe6" + + "\x25\x39\x9f\x97\x3e\x78\x1d\xb8" + "\xa7\x89\x4c\xaf\x0a\x13\xfd\x1e" + "\xfa\xf7\x1b\xfd\x44\x21\x5c\x52" + "\x9e\x5a\x26\x1b\x04\x69\x29\x4b" + "\xb6\x65\xdb\xb9\x34\x96\x8e\xed" + "\x8a\x9d\x59\x03\x32\x2e\xc8\x35" + "\xf3\x63\x35\x40\x4f\xa5\xa7\xda" + "\xab\x38\x2c\x02\xad\x88\xf0\x9d" + + "\xee\x60\x62\x45\xc1\x5a\x69\x1c" + "\x93\x36\x78\x4d\xdf\xce\x3a\x4e" + "\x8f\x4a\x67\x11\x59\x52\xfd\xda" + "\xf9\x22\x7b\x6c\x40\x6d\x84\x21" + "\x55\x1f\x89\x17\xfc\x1c\x3d\x78" + "\x75\x04\x4d\xd7\x34\x3c\x17\x2a" + "\x20\xfa\x99\xb6\x7f\xbd\xfd\x3a" + "\x62\x9f\x82\xac\xb6\x8f\x24\x79" + + "\x0a\xd3\x3f\xbb\x66\xb0\xcf\xe5" + "\x4e\x35\xf0\xef\xda\x69\x91\x42" + "\x6c\xe3\x24\x35\x52\xf8\x9c\x80" + "\x1d\xbe\x55\x01\xb3\x4f\x6f\x13" + "\x12\xa7\xbb\x1f\x01\xaf\x26\x48" + "\xa1\xa1\x6b\x50\xb4\xf0\xf0\x6e" + "\x3e\xa7\xae\x77\x31\x8b\x92\xd9" + "\x4e\x24\xaa\x5e\xf2\x6a\xbf\xe2" + + "\xb2\x1d\xc8\x1a\x3a\x36\x28\x18" + "\x66\x06\x82\x48\xb3\x22\x2a\x75" + "\x6a\xab\x32\x3d\x03\x00\xc0\xcf" + "\xb1\x3c\x6a\xd9\xe1\x77\xd6\x2a" + "\x11\x30\x23\xc8\x72\xe6\xe3\xa7" + "\xb7\x03\x43\x5e\x7e\xe8\x65\x2c" + "\xcb\x04\xdf\xc6\x1b\xf7\x34\x18" + "\x34\xa8\xed\x3c\x2c\x77\xf8\x32" + + "\x4b\xb6\x37\x42\x12\x4f\x08\x8d" + "\x07\xfd\xec\xe3\x99\xbe\x8e\x68" + "\xd8\x5d\x84\xf6\x0c\xa7\xb8\x57" + "\x25\xa3\xa4\x5d\x9c\xc5\x8f\x80" + "\x62\x58\x58\xa3\x2b\x2b\x03\xa9" + "\x86\x93\xf2\xed\xd5\x25\x68\xb6" + "\x9b\xc2\x1e\x43\xdb\xa8\xa5\xb5" + "\xc8\x8d\x1e\x3a\x98\x3a\x14\xbb" + + "\xd9\xd1\xe9\xcf\x07\x6a\x35\x5b" + "\xdd\x48\x6f\x30\x3a\x68\xba\xd4" + "\xc1\x37\x64\x2c\xb5\xe7\x6a\x3b" + "\xd4\x4f\xb6\x54\xa1\xc1\xc0\xf9" + "\xd0\x52\x54\xed\xba\x0d\x66\x90" + "\x0f\x53\x50\x28\x95\x3e\x3f\x42" + "\x81\x4d\x27\x47\x06\xa2\x32\x14" + "\x74\x05\xb0\x7d\xf8\xf3\xeb\xcc" + + "\x1b\x38\xae\x12\xce\x94\xee\x35" + "\x90\xda\xcc\x86\x6c\x17\x7f\x3a" + "\xca\xea\x06\x46\x7e\x65\x3a\xc6" + "\xdf\x04\xcd\x43\x80\xa3\xe5\x9a" + "\x46\x1b\x25\xed\x15\x8d\xec\x9b" + "\x64\x5e\xca\xca\x30\x6d\x5d\x1f" + "\x07\x0f\xf2\x9f\x35\x3b\x7b\x34" + "\x86\xb2\xe4\xf7\x34\xf0\x65\x4d" + + "\x96\x29\xc8\x06\xf6\x81\x9f\xd8" + "\xfc\x92\xc5\x15\x88\x52\x73\x4f" + "\xc6\xa8\x49\xce\xa1\x03\x0c\x8c" + "\x07\x59\xf2\xb9\xe0\xff\x4d\xe0" + "\x4b\xab\xf7\x4a\x50\x21\x66\x22" + "\x4c\x5c\xa3\xf5\xf6\xff\x21\x9e" + "\x98\x91\x1e\x5a\x84\x44\x1d\x07" + "\x11\xfc\x09\x41\x5c\x95\x11\x08" + + "\x1e\x66\x11\xf1\x24\xba\x93\x9e" + "\x04\xeb\x05\xb1\x84\xd4\xce\xed" + "\x78\xb5\x24\xf4\xa1\x9b\xdc\x96" + "\x69\x90\x3e\xe8\xb7\x66\x8f\xbf" + "\x16\x82\xed\xd7\xf4\x4d\x2d\x87" + "\xcf\xbe\x2c\x8e\x77\xf3\x07\xbf" + "\x54\x37\xe7\x98\x99\xd8\x81\x42" + "\x08\x87\xab\x8a\xbb\x5f\xc8\xfe" + + "\x5b\x39\x11\x45\x1d\x41\x28\xd3" + "\xde\xf8\xcd\xe4\x79\xc0\x50\x31" + "\xd0\xbc\x34\x59\xc4\xe7\x4b\x22" + "\xae\xc9\x58\x43\x75\x71\x97\x9d" + "\x4d\xdb\x30\x22\x41\xbb\xb1\xdb" + "\xdc\x31\x8e\x0d\xbd\x84\x8e\x16" + "\xd2\x5f\x11\x1c\x34\x4f\x1b\xa6" + "\x8f\xc2\x88\x58\x15\xfa\x75\xc7" + + "\x0b\x5b\xba\xa5\xee\x0d\x3c\x9a" + "\x99\x52\xd0\x42\xce\x16\xa1\xe6" + "\x42\x2d\xb0\xe9\xfe\x75\x97\xae" + "\xb6\x5c\x54\xa1\x00\x52\xb0\x72" + "\xea\xb4\xa3\x31\x7d\x6f\x50\xbc" + "\x32\x9b\xbd\x8b\x78\x30\x89\xe5" + "\x97\x2a\xb1\xe4\x37\x5f\xbc\xc8" + "\x71\xb6\x73\x4a\x06\x0c\x00\x6b" + + "\x8a\x5f\xde\x17\x5c\x92\xc6\xf3" + "\xd5\x91\x49\xf3\x95\x4b\xcb\xa6" + "\x66\x05\xd5\x7d\xf0\x97\xbf\xa8" + "\x9e\xa0\x91\x0b\xe5\x55\x8d\x2c" + "\x20\xe7\xd7\x3a\xed\xc2\xdc\x6a" + "\x5a\xec\x93\x00\x48\x23\x4a\x73" + "\xaf\x36\xcb\x43\xbe\x8f\x1d\xfa" + "\xe4\xa7\xa8\xa4\x1c\xb8\x87\xdc" + + "\xd0\xa7\x5f\x76\x22\xbf\xb5\x13" + "\x70\x53\x6a\x1d\xf0\x5b\x80\x59" + "\x98\xdb\x80\x42\x9d\xe2\xa5\x67" + "\xe3\x1c\x6b\x77\x6f\x91\x53\x4f" + "\x26\xf6\xdd\x33\x1f\xf6\x4f\x71" + "\x03\xd1\x85\xa0\x8e\x23\x06\x42" + "\xe3\x9e\x80\xe5\xb7\xd4\x50\x1c" + "\x1d\xeb\xf8\x85\x0d\x45\x9f\x99" + + "\x25\xf3\x39\xa2\xb1\x04\x39\x5f" + "\x90\xad\x58\x1a\xf7\xa6\x26\xd0" + "\xed\x24\xb8\xd6\x36\x27\x54\x43" + "\xb8\x64\x93\x4a\x75\xa7\x41\x08" + "\xe9\x1d\xeb\xcf\x41\xcb\x97\x75" + "\x4f\x0a\x58\xbf\x7a\x2b\x25\x20" + "\x20\x8e\xc4\x17\x81\x92\x72\x37" + "\x71\xa0\xf5\xc6\x28\x1c\xdb\xda" + + "\x9b\x9e\xc7\xe4\x51\x60\x8a\x65" + "\xea\x9f\x6a\xc6\x73\xcb\x94\x13" + "\x23\x7b\xbe\xc6\xd5\x1e\xf3\x27" + "\xfe\xf8\xa6\x5a\x36\x8f\xc8\xf4" + "\x9e\x49\xaa\x4a\x1f\x72\xb0\x0f" + "\x6b\x2a\xfb\xe3\xd5\xa7\xb3\x68" + "\x1d\x85\x92\x3a\x7d\x09\x88\xa7" + "\x13\x49\x6f\xe9\x8a\x7f\x0e\x06" + + "\xc1\xfd\xdb\x88\xe2\x0c\xfa\xf1" + "\x08\xdd\xf8\xd2\x80\x74\x39\x3c" + "\xf0\x95\xdb\x4e\x8b\x0a\xf1\x0e" + "\x56\xe5\x47\x32\x75\xbc\x58\x45" + "\xa4\x4f\xc0\x0f\x5f\xef\x5c\x76" + "\x75\x3d\x6d\xd6\xe6\x2c\x9f\x72" + "\x66\xf0\x33\xb4\x5d\x27\x35\x6d" + "\x7e\x59\x4e\x36\x27\x5c\xd9\x31" + + "\xbc\x93\x3a\x1a\x73\xbe\xee\x82" + "\x1a\xdc\x1a\xa2\x65\xf4\xbb\x42" + "\xfd\x0e\x03\xef\xa4\x6f\x0b\xc1" + "\xbb\x97\xb0\x87\xc7\xa4\x7a\x24" + "\xda\x77\x0c\xf6\x32\xc6\x8d\x8b" + "\x3e\x52\x23\xc2\x6a\xc2\xfb\x6f" + "\xcf\x79\x45\x34\x11\xff\xf6\xa4" + "\xf6\x50\x02\x98\x3c\x65\x25\x58" + + "\x8b\x39\x1f\xcc\x9a\xef\xea\x88" + "\x95\x7e\x21\xf4\x25\x9a\x18\x85" + "\xef\xfc\x68\xb9\xf5\xf5\x24\x94" + "\x28\x22\x07\xd0\xf9\x8a\x5d\xc0" + "\x2a\xb2\xa1\x49\x8c\xfa\x36\x0b" + "\xce\x5f\x11\xf1\x57\x36\x1c\xe6" + "\x3f\x43\x62\x42\xc0\xf0\xcd\x06" + "\xdc\x20\xc8\x9e\x2d\xc5\x8a\x9d" + + "\xb9\xa2\x1a\xbc\x7e\x09\xdd\xb2" + "\x3a\x33\xa0\x37\x93\x93\x88\x07" + "\x38\xdb\xa0\x37\x71\x5e\xf5\x1c" + "\x13\x16\x2c\x79\x7f\x48\x48\x26" + "\x61\xf2\xce\x3f\x36\x13\xd0\xda" + "\x29\xf1\xab\x0e\x1d\xc8\x39\x62" + "\xe2\x6b\x27\x9d\xde\x61\xe7\x8e" + "\xd3\x6a\xda\x1e\x34\x7a\x6a\x40" + + "\x07\x6a\x02\xd5\xac\x10\x73\x01" + "\x1c\x28\x93\xe7\x54\xc9\x26\x35" + "\x51\xac\x00\x76\xc5\x7b\x6b\x41" + "\xa7\x44\x2b\xd4\x52\x89\x67\x09" + "\xb1\x9f\x04\xb6\xb7\x3f\xda\xab" + "\x7b\xef\xad\xdf\x59\xa6\xb0\x3c" + "\x0d\x0c\x8b\x1b\x72\x31\x79\x58" + "\x1b\x61\x9d\x4e\x6e\x47\x73\xfe" + + "\x31\x3b\x49\x4a\xba\x67\xf3\x4b" + "\x26\xf0\xf7\x9b\x52\x0a\xf2\x54" + "\x4b\x91\x95\x97\x62\xe0\x96\xb6" + "\xac\x36\xf2\x8b\x6d\xb9\xda\xcd" + "\x13\xea\x25\xed\x0a\xc7\xf2\x4f" + "\xe7\xbb\xcb\x81\xeb\x09\x1d\xfa" + "\xc5\x44\x85\x46\x87\x8c\xfc\x88" + "\x17\x33\x6b\x69\x0d\x67\x7a\x84" + + "\x59\x9a\x51\x45\xe2\xaf\x10\x84" + "\x74\xd7\x30\xbc\xaf\x39\x97\x9a" + "\x88\x4a\xf4\xd8\x03\xde\x33\x66" + "\x37\xdb\x5d\x50\xb3\x9b\x6a\xd5" + "\x14\x5e\x81\x46\x07\x7c\x66\x66" + "\xbb\x93\x44\x88\xed\xf8\x28\x22" + "\x82\x48\xab\x17\x1a\x56\xcc\x23" + "\xce\x1b\x1a\x52\x59\x07\x83\x99" + + "\x26\xb6\xbc\x64\x1e\x42\x33\xf1" + "\xb5\xe0\xde\x26\xc8\x38\xa6\xae" + "\x6c\x34\x10\xb3\x0b\x68\xe7\xd6" + "\xd3\xce\xd4\xd5\x97\x40\x6f\xe0" + "\x0b\xa3\x12\x75\x52\x14\x96\x09" + "\x9a\xa5\x89\xe5\xfd\x67\xd8\xf3" + "\x80\xc1\xd0\x52\x4f\x25\x73\x2e" + "\xac\x74\x3c\x33\xa3\xd8\x63\x90" + + "\x7a\x6f\xee\xe2\x44\x27\x14\x12" + "\x3f\x60\x21\x65\x10\x9d\x38\x63" + "\x3a\x81\x9c\x9e\xc7\x82\xcd\xa1" + "\xeb\x42\xe3\x5a\x1c\x64\x09\xc1" + "\xe9\x06\xbb\x04\x30\xfb\x85\x3c" + "\x7f\xf1\x12\xc2\x1c\x44\xed\x1f" + "\x53\x1a\xf6\x82\xac\xdf\x56\x16" + "\x5f\x8f\xd9\xce\x30\x7a\xec\x88" + + "\xbc\xe7\x14\xd3\x95\xc5\xa6\xed" + "\xed\x99\x78\x46\x4b\x46\xe7\x2e" + "\xd3\xd5\x1e\x0a\x3c\x42\xef\x1c" + "\x13\x76\xcc\x69\xea\x76\x7e\x21" + "\x17\xa9\xcd\xe7\x1f\xce\xcc\x27" + "\x16\x3f\x89\x8a\x6b\x01\xd8\x12" + "\x6b\x4f\xc7\x9f\x84\xde\xd6\xbc" + "\x61\x4e\x14\xf3\xe2\x17\x58\xfa" + + "\xce\x5e\xc5\x9b\xb5\x39\x89\x0b" + "\xff\x70\xaa\xcb\x3b\xb3\x64\xb1" + "\x91\xb7\x2a\x3f\x0f\x01\x6b\xaf" + "\x37\xcb\x52\x7b\xba\x67\xb7\x98" + "\x41\x65\xf8\xfc\x80\xf3\x0d\xbd" + "\x4a\x01\xa1\x64\x54\xf3\x94\x51" + "\x25\xf6\x35\x4c\x2e\xf2\xc1\x42" + "\x1b\xf5\xbb\xf7\xe2\xf3\x70\x9a" + + "\x4c\xee\x21\x08\x64\x41\x35\x1f" + "\x92\x19\xc6\x0b\xb4\xea\x83\x15" + "\x9f\x87\x72\x1d\xf6\xca\x90\x74" + "\xb2\xe7\x6a\xf7\xf3\xd9\x8a\x99" + "\xf7\x57\x11\xa4\x50\x19\x18\x1e" + "\x7e\x3a\xda\xe8\xe6\xe1\xd7\xa9" + "\x5f\xb9\x26\x84\xeb\x84\x37\x96" + "\x10\x2a\x2e\x54\x6e\xed\xe4\x0e" + + "\x83\xfd\x12\x96\xb8\x35\x4d\xbc" + "\xe9\x05\x40\x5c\x50\xca\x77\xf4" + "\xd1\xec\x7e\xa8\x3d\x20\x62\xb7" + "\x86\x25\x08\x38\x22\x9b\xac\x68" + "\x91\x35\x78\xcc\x59\xd6\x96\x66" + "\xb4\x52\x63\xd3\xdd\x43\x46\x25" + "\x69\x1d\xad\x9d\xd9\x70\xe3\xcd" + "\xfa\x5d\x71\x62\x6c\xf2\x7a\x9d" + + "\x7b\x1e\x75\xac\xc5\x4c\x9d\xb7" + "\xbd\x11\x42\xfd\x72\x64\xf9\x93" + "\xc6\x4f\xde\xc8\xd2\xd3\x72\x8c" + "\x64\xf0\x44\xdf\xf5\xcb\x69\x7b" + "\xe1\x94\xbf\xf4\xa2\x0c\xa9\x3d" + "\xe2\x94\x28\xf1\xf8\x25\x53\x1a" + "\x0b\xd6\x17\x79\x6c\x7f\x43\x0a" + "\x5d\xcb\xc9\x96\x86\x04\xe7\x9b" + + + "\x26\x7c\x33\xe1\x76\x99\x9c\x94" + "\xe5\x68\x3d\xd7\xbd\xde\xaa\x6f" + "\xd9\x68\xb7\xf1\x14\x86\x15\x9e" + "\x69\xf0\xc4\x9c\x57\xa5\xdf\x22" + "\xd6\xc6\x93\xbe\x17\xda\xd6\xcc" + "\xb9\xf5\x04\xa5\x61\x6c\x86\x24" + "\xa1\x4d\x69\x8d\x3c\x35\x21\x21" + "\xc6\xb8\x40\x01\x80\xa5\x6c\x1c" + + "\xb8\x9b\xb7\xd4\x7d\x4a\x60\xf1" + "\xc8\x78\xc8\x52\xfb\x06\xe8\xae" + "\xe8\xb8\x47\x8d\x11\x4f\x14\x34" + "\x54\x90\x9f\x94\x2b\xf5\xed\x72" + "\x5a\x01\x27\x21\x4e\xa8\xfc\xeb" + "\xf3\xce\xb7\x9c\xc0\xd0\x51\x90" + "\xc8\xee\x6d\x29\x58\xfe\xe8\x86" + "\x74\x0d\x01\x41\x88\x81\xb2\x33" + + "\x40\x9f\xed\x9a\xed\x60\x56\xbd" + "\x99\x8c\x2a\x53\xd1\x6a\xca\x70" + "\xea\x71\xc3\x95\xfb\x8b\x97\xc4" + "\x9d\x10\x03\x70\x0d\x4d\x46\xe5" + "\xef\x35\xe5\xd9\xdf\x2f\xf3\x1a" + "\x5b\x18\xc9\x98\xa7\x7e\xf5\xab" + "\x88\x24\xb4\x12\x17\x74\x7a\xed" + "\xfa\x86\x72\xe9\xa7\x96\x02\x8e" + + "\x5f\x44\x1b\x17\x83\x93\x07\x01" + "\x4c\xad\x31\x81\xe3\x21\xcf\x9b" + "\xe8\x87\x39\xc9\x05\xe2\xdf\x8c" + "\x8f\x8c\x2e\xc9\x52\x41\x3f\xe6" + "\x3d\xd4\xad\x30\xa9\x62\x94\x72" + "\x5a\xf0\x80\xc9\x43\xb1\xeb\x62" + "\x68\xe9\x06\x3b\xe5\x54\x39\x4f" + "\xb1\xf6\x2c\x24\xad\x75\x1d\xfe" + + "\x5e\x7d\x01\x1f\x6e\x41\x57\x8b" + "\x9b\xe9\x74\x76\x96\x33\x53\x37" + "\xa0\x88\xf4\xe8\xc0\x94\x6d\x6e" + "\x5e\xf9\x16\xdc\x7a\x78\x3a\xb9" + "\xcc\x9c\xc9\xdc\xa2\x51\xac\xc3" + "\x1d\x7c\xa4\x9a\x13\xb4\x34\xc1" + "\xd5\xd8\xdf\xaf\xaf\xcd\x8f\xf2" + "\xed\x31\xb8\x10\x8e\xbd\x57\x0d" + + "\x46\xfc\xbc\xf0\xcc\xfb\x76\x92" + "\xe6\xfe\xcf\xb5\xce\x2a\x82\x3a" + "\x5b\x91\x5d\xc7\xfe\xd2\x8e\x32" + "\x6c\x47\x59\xc3\x13\xc1\x45\xa1" + "\xcd\x7b\xe1\x8b\x53\x81\x1a\xf6" + "\x8f\x3d\x6c\xaa\xc3\x67\xe8\x01" + "\x2f\xc8\x16\x65\x5d\xe1\x34\x56" + "\xb0\xb9\x48\x69\xd2\x7b\x43\xc1" + + "\xc7\xd4\x19\x6c\x00\xd2\xfc\xd2" + "\x76\xe9\xb1\xe1\x37\xc4\xf3\xa0" + "\xe8\x37\xf2\x94\xf6\x5f\x54\xf0" + "\xb1\x8b\xbf\xc0\x3f\xec\x10\xdd" + "\xe1\xd3\x7c\xac\x6c\x69\x89\x4f" + "\xe6\xbf\x24\x5f\xec\x14\x37\xed" + "\x06\x77\xaf\x5f\xd8\xb1\x3e\x36" + "\x32\xcc\x27\xc0\x4d\x60\xbd\xfc" + + "\xc8\x85\x86\xaf\xc7\xc6\x95\x5f" + "\xaa\x01\x8f\x2f\xce\xc8\xc1\xd4" + "\x2a\x69\x74\x25\x32\xbe\x4b\xc4" + "\x68\xa0\xa4\xd4\x78\x34\x00\xb8" + "\xdb\x3c\xca\x2e\xe5\xc6\x8f\x7c" + "\x99\xd3\x04\xec\x6b\xb1\x1d\xea" + "\xcf\xc5\x2b\x8f\x2e\xc8\x5b\xb0" + "\xd2\x93\x47\xf4\x7f\x51\x3d\x76" + + "\x3b\x36\x55\xc3\xdd\x8e\xce\x16" + "\x6e\x0d\x82\xf8\x0f\xf7\xf2\x4a" + "\x08\xa5\x61\x76\xd2\xd4\x7e\xcb" + "\x72\x54\x19\xdd\x4e\x44\xd3\x41" + "\x49\x96\xda\x38\xb4\xa2\xfe\x17" + "\x00\xa2\xb4\xae\x56\x93\xf6\x9b" + "\x3d\x9c\xb1\x6a\x91\x5f\x3b\xa1" + "\xa6\x60\x93\xdc\x14\x9c\x51\xc0" + + "\x71\xe1\x42\x2e\xe9\x1a\x57\xc2" + "\xf9\xcc\x41\xed\x63\xab\x31\xcb" + "\x4f\x85\xc8\xb5\x76\xc5\xf3\x37" + "\xa1\x92\x23\xc6\x1b\x19\xe5\x66" + "\x3b\x68\xd5\x6c\x1c\x5a\x56\x71" + "\x89\xe6\x6f\x60\x83\x02\x4b\x48" + "\xa6\xfd\xe2\x67\x67\x5d\xa2\xf3" + "\xa4\xc0\x65\x8a\xde\x21\xba\x87" + + "\xd1\x84\x06\xa7\x9c\xe4\x74\xde" + "\x3d\x0c\xe8\x33\x61\x76\xe8\x3a" + "\x4d\xc3\xa5\x16\xa9\xa2\x84\x59" + "\x35\x8c\x29\xb8\xcc\x3e\xa8\x09" + "\xc0\xa4\x4c\xaa\x7c\x86\x19\x9a" + "\xff\xb8\x75\xb3\x10\x56\x08\x02" + "\xdc\x96\x03\xf7\x8b\x32\x96\xf2" + "\x63\xae\x6f\xde\x4c\xdc\x9d\x9c" + + "\xd0\x98\xbd\x08\xb8\xc1\x51\x44" + "\x40\xf2\x75\x65\xd4\x1c\x4b\x64" + "\x70\xd2\x75\x73\x33\xeb\x07\x69" + "\xbd\x86\x22\xfa\xbd\xbe\xc8\x56" + "\x46\x2b\x63\xc4\xac\xd2\x13\xc7" + "\x42\x02\xd6\xaf\x7a\x42\xda\x17" + "\x46\x75\x5c\xc9\xb7\x65\x30\x31" + "\xde\xa3\x17\xbf\x98\x98\x23\xf8" + + "\x6e\x3b\x08\x0b\x26\x3d\x68\x94" + "\x4d\xa5\xf6\x06\xeb\x52\x37\x0a" + "\xdd\x74\x20\x75\x23\xdc\xbe\x48" + "\x93\x25\x82\x3e\xfc\x22\x76\x63" + "\x3b\x5d\xe5\x6b\x13\x05\x00\xea" + "\x6d\x00\x4d\x32\xf4\x12\x5e\x9f" + "\x70\x02\xfc\x64\xa9\x86\x94\x52" + "\xe6\x99\x33\x92\x0c\x0d\xba\x09" + + "\x80\x70\x97\x3a\x47\x58\x38\x36" + "\xb6\x6a\x6a\x0c\xb8\xe1\xf8\x4c" + "\x1e\x26\x82\x04\x6c\x5c\x9a\x91" + "\x06\x48\xce\xe5\xd0\x9a\x7a\x51" + "\xaa\xa7\x6a\x05\x0c\xd4\x92\x27" + "\xb0\x61\x6c\xe5\xda\x6a\x7c\x4c" + "\x0c\x9e\xb1\xa4\x78\xb1\x9c\xf1" + "\x7f\x26\xba\xe4\x4f\x5c\x6d\x04" + + "\xb3\x50\x15\x12\xab\x26\xe9\xd3" + "\x84\xce\x47\xc1\x4a\x5e\x97\xe4" + "\x2a\x72\xff\x5e\xf9\xe0\x8b\x7a" + "\xa0\xf2\xd4\x6f\x2c\x70\xe4\x71" + "\x80\xb2\xb7\x3c\xcf\x2a\xb9\x13" + "\x73\x2d\x27\x28\x6d\x71\x88\xc5" + "\x5c\xfe\xa9\xda\xf3\x7b\x2c\x86" + "\x42\x9e\xa7\xe2\xf2\x08\xc0\x78" + + "\x20\x03\x83\x4c\x3f\x96\xb7\xf3" + "\xe3\x03\x32\x90\xa0\x7a\x2c\x84" + "\xfb\x7a\x32\xe7\x0a\xca\x22\xaf" + "\xb6\x09\x76\x96\x92\x30\xe1\x38" + "\xf1\x58\x75\x75\x62\xfb\xb8\x73" + "\xc1\xa8\xec\xf7\x31\xe8\xc3\x3c" + "\x27\x16\x33\xf6\x74\x44\x17\xe4" + "\x34\x02\xc4\xc3\xca\x89\x79\xa7" + + "\x1f\xfa\x36\xf5\xc5\x32\x58\xed" + "\xa4\x44\x82\x92\x55\x3f\x6f\xe1" + "\x90\xe1\x5b\xbf\x21\x26\x3a\xf4" + "\x2b\x6b\x2b\xca\xc3\x72\xd6\xf7" + "\x83\x5b\x7a\x82\x45\x62\xf8\x64" + "\x72\x7f\xe9\x00\xf5\x09\xa1\xc1" + "\xbb\x27\x73\xa4\x5c\x78\x59\xc2" + "\xb6\x62\x6a\x7f\xe9\x09\xf1\xda" + + "\x20\x51\x56\x57\x18\xdf\xab\x88" + "\xf1\x2b\x5f\xf2\x72\xbc\x34\xbf" + "\x40\xea\x83\x62\x22\x6a\x21\x0c" + "\xe4\x18\x2e\x07\x46\x20\x3d\x57" + "\x36\x81\xbe\x11\x6a\x0f\x11\x11" + "\x1b\x86\xe4\xd6\x84\x2a\xf3\x10" + "\x31\x75\x29\xee\xe2\xde\xed\x3e" + "\x69\x42\x40\xd3\x99\x7f\xf3\xb3" + + "\x3a\xd4\xc1\x1c\xe9\xf5\xa3\xce" + "\xf4\x3a\x23\x6a\xdb\xca\x4a\x62" + "\xc2\xe7\xef\xd0\xa9\x18\xdf\xc9" + "\xf3\x79\xba\x79\xe8\x0b\x0d\xfe" + "\xea\xf5\x2f\x52\x56\x5a\x4c\xc7" + "\x4e\x51\x7d\x6c\xf0\x79\xc3\x4a" + "\x9f\xa2\x0e\xd7\x04\x14\x92\x64" + "\x70\xf2\x69\x02\x91\xe5\x3e\x44" + + "\xe0\x81\xa0\x44\xa1\x17\xfd\xe5" + "\x6a\x29\x0e\xb7\x7d\xfb\x97\xd7" + "\x9c\x71\x1f\x48\x30\x2b\x47\x2b" + "\x52\x8c\x6f\xfe\x98\x2a\x63\x0e" + "\x84\xc2\xf0\xc5\x16\xd1\xcc\x89" + "\x62\x7c\x98\x2d\xaf\x88\x10\xf5" + "\xcf\xe6\x2d\x4c\xda\xcc\x2b\x2a" + "\xf9\xf0\x79\xf6\xfe\x9e\x0f\x81" + + "\x39\xa5\x1e\xa6\x43\xf4\x74\x38" + "\xdf\xfe\x06\xc2\x11\xa3\xa3\x90" + "\x85\x87\xbd\x0f\x5b\x7b\x2a\x96" + "\x8b\x1c\xc3\x58\x70\xe9\x37\xfc" + "\x48\x10\x1a\x5f\x38\x55\xeb\xcd" + "\x55\x62\xcd\x8c\x22\x51\x20\x5a" + "\x8b\x1b\x4f\x9c\x96\xd4\x62\x97" + "\xde\x05\x2f\xd5\x03\x88\x3d\x21" + + "\xf6\x73\x4c\xe5\x7b\x37\x64\x7c" + "\xc0\xfb\x4e\x5a\x04\xfe\xbf\x65" + "\x41\x85\xf5\x36\x63\x30\xd2\xd0" + "\xf0\xbd\xcd\x25\x6f\x06\xd6\x54" + "\x5b\x6d\xf8\x5c\x63\x2d\x5f\x68" + "\xe5\xf6\x2e\xf1\xc1\xe9\x51\x8e" + "\x82\x6d\x34\xcb\x2d\x04\xaf\xa6" + "\x6f\x81\x73\x00\x79\x50\x95\x37" + + "\xf4\xf7\xc5\x13\xa7\xd3\x9c\xc8" + "\xed\x2e\x35\xac\x4e\xb5\x9c\x0d" + "\x88\x47\xb3\x33\xee\x7a\x2e\x46" + "\x9a\x8d\x99\x7c\x43\xf1\x1a\x83" + "\x87\x4f\xe0\x11\xc9\x02\x88\xed" + "\x69\xd9\x38\x19\x0b\xa0\xa1\x1c" + "\x10\x93\xbb\x7b\xb4\x5b\x80\x52" + "\x10\x64\xc1\x31\xe4\xcd\xa3\xca" + + "\x3e\x4b\xfe\x7f\xb9\x94\xf3\xb0" + "\x21\x5d\xfa\xe5\x21\x1d\x69\x0b" + "\x75\xbc\xfb\x9d\x47\x77\xbd\xb0" + "\x00\x8b\xf7\xfa\xda\x0f\x83\xd2" + "\x57\x4f\x43\x52\x9c\x24\x8c\xf7" + "\xab\x6d\x09\x98\x45\x75\x1f\x4b" + "\xb3\xc0\xf8\x8f\x94\x6f\xbf\x73" + "\x4c\x13\x4e\x45\x3d\xf0\xae\x34" + + "\x59\xc0\x0b\x39\xd5\x56\xb8\x2e" + "\xdf\x12\x13\x04\x5f\xbd\xea\xc0" + "\x7b\xd6\x36\x86\xdf\x45\xef\x7e" + "\xb5\x7f\xea\xdf\x1f\xe8\x09\x69" + "\x37\x77\xda\x31\x53\x8c\x8e\x62" + "\xbc\x55\x5b\x75\xe3\x8b\x2f\x1b" + "\xd7\x41\x78\x13\x12\x05\xba\x35" + "\x7d\xe5\x7c\x31\x59\x03\x55\x59" + + "\xc9\x6d\xd1\xf5\x07\xd4\x51\xb2" + "\x1c\xcc\x72\x4c\xaf\xaa\x1f\x54" + "\xcc\x73\x81\xe5\xac\x70\x81\xd2" + "\x5a\x1b\x0c\x7b\xc5\x57\xc0\x1c" + "\x74\x23\x06\x21\xe6\x74\xb2\x04" + "\x79\x8c\xcb\xe2\xa7\xca\xac\xef" + "\x95\x94\xea\x24\xec\xc3\x66\xc4" + "\x15\x7c\xef\x67\xf3\x6e\x51\xc3" + + "\x1c\x5c\x57\x45\x3b\x00\xef\x34" + "\x0c\xfe\xc2\x49\xa0\xe7\xb3\xde" + "\x63\x9c\x14\xf7\x1d\xc0\x8e\x04" + "\x6c\x98\x9a\xc7\xb9\x69\x38\x20" + "\xef\x80\x1e\x6c\x83\x40\x7c\xcf" + "\x47\x44\x29\x8e\xd5\x17\x0e\x21" + "\x1c\x60\x12\x12\x2e\x7d\x50\x2b" + "\x79\xe2\x17\x5a\xfa\xd3\xed\x98" + + "\xc5\x7e\xac\xb7\xf4\x51\xd1\xf8" + "\xd5\xa7\x0d\xe5\x5a\xb9\xce\xd6" + "\xb8\x0e\x3a\xdc\xb0\x92\xb4\xa1" + "\x63\x28\xdd\xb3\x69\x7b\x15\x75" + "\x62\x3d\x41\xc5\x4e\xc7\xc4\xe2" + "\xc7\xc4\x5f\xbc\xf7\x9f\x32\xbe" + "\xda\x9d\xfa\x60\xea\x2a\x5a\x83" + "\x87\xcb\x45\x74\xad\xf5\x17\xf1" + + "\x1d\x69\x1d\xe9\x36\x26\xf4\x9b" + "\xe4\x7b\xc0\x8f\x42\x32\xcc\x0b" + "\x90\xaa\xe9\x69\xae\x5c\x20\x5b" + "\x5e\xf7\x9c\x39\x2b\x72\x69\x6f" + "\x35\x42\x42\x79\xf6\x59\xb0\x3d" + "\x63\x54\x20\xa2\x04\xb4\x98\x6b" + "\x51\xf4\x60\x6f\xe4\xf5\xca\x68" + "\x9e\x93\x08\xad\x66\xfc\xf1\xe8" + + "\x1f\xb2\x46\x63\xd4\x1b\x66\x36" + "\xf0\x9d\xb6\x3c\x1d\xb0\x6f\xde" + "\x0a\xb4\x84\xa8\xe4\xa0\x05\x7d" + "\xbf\x4a\x3d\xef\xd4\x69\x25\xd9" + "\xf8\x61\xb2\xe6\xe1\xd7\x2b\x1c" + "\xef\xdb\x4d\xc7\xe5\xb0\x03\x05" + "\x37\x4c\x9a\xe0\x39\x1a\x36\x6a" + "\x73\x84\xff\xe7\x08\x75\xd5\x7f" + + "\xf8\xed\x76\xc7\x67\xfd\x39\x19" + "\x8a\x84\x5c\xcb\x70\x7c\x84\xd0" + "\xd1\x03\xde\x5a\x91\x53\xf5\x4f" + "\x3e\x82\xa9\xcf\x83\x4d\xb5\x8f" + "\x04\x4e\x0d\xf1\x6e\x14\x08\xb3" + "\x36\x2a\xcb\xb6\xb3\x91\xa6\x14" + "\x7f\x65\x20\xc6\x93\x9b\x41\x2f" + "\x7f\xda\xe1\xd3\xa2\xaa\xb7\x4d" + + "\x7a\x6f\x16\xb0\xf4\x17\x83\xae" + "\xe6\x74\xec\xce\xf7\xe3\xd3\xfb" + "\xfd\x4b\x87\xe0\xac\x16\xb5\xfd" + "\xa3\xf3\x81\xc6\x19\x60\x84\x3d" + "\xb0\x20\x16\x7c\x5c\xee\x12\x0b" + "\x01\xc5\x63\x2b\xdd\xb4\x68\xba" + "\x1e\xc5\x68\x66\x32\xcd\x03\xac" + "\x5b\xcb\x0b\x4e\xf7\x79\x62\x2a" + + + "\xa8\xcd\x5f\x8f\x9f\x13\x8e\xfd" + "\xfd\x5b\xee\xbd\xc4\x58\xe5\xf3" + "\x77\x9f\x3f\xe3\xf4\xba\x6c\xd7" + "\x69\x19\x77\x71\xa4\x97\x4c\x3a" + "\xa7\xe6\xdc\xf6\x4b\xe8\x27\xda" + "\xd1\xc2\xe6\x13\x96\x3d\x37\xff" + "\xe9\xa6\x59\xd7\x3c\x19\x15\xf1" + "\x2c\x26\xd2\x63\x25\x70\x9b\x3f" + + "\xc8\x5c\x33\x1a\x91\x84\x31\x8c" + "\xe4\x13\x59\x6a\xba\x59\x34\x56" + "\x19\x29\xb3\xc7\x61\x0d\x92\x1b" + "\xad\x25\x24\xa0\xb6\xb8\x5a\x80" + "\x86\x60\x00\x8d\xda\x12\xc5\x2a" + "\xfd\xc0\xf5\xbc\x6a\x84\xa4\x6c" + "\xd7\x38\x21\xac\xd8\x51\xea\xaf" + "\x43\xd4\x4c\x34\x45\x75\x64\xcb" + + "\x85\xca\xed\xcd\x66\x24\x1b\x9f" + "\x8c\x53\x09\x1a\x10\xb7\x0b\x14" + "\x5d\x11\x11\x5e\x51\xe8\x8a\xac" + "\x9e\xf5\x03\x6f\x67\xff\x63\x0d" + "\xfb\x4a\x23\x7d\x51\x55\x5e\x75" + "\xc1\x8f\x20\x7e\x4e\xdb\xc2\x61" + "\x5d\x4b\x8a\xf2\xce\x59\x98\xaa" + "\x0f\x03\xaf\x34\xfc\xd4\xd6\xbd" + + "\x74\x47\x54\x53\xe4\x53\x10\x51" + "\xbc\xa2\xdb\x3a\xcc\x0e\x4d\x83" + "\xf5\x71\xe3\xba\xf7\xd7\x15\x42" + "\xbc\x63\x86\x6c\xbf\x57\xfd\xfc" + "\x1d\x1b\x90\xd6\x3d\x38\xd2\xde" + "\xc3\x7d\x58\xb5\xb4\xfb\x49\x3b" + "\x62\x5f\x62\x07\x8d\xa0\x44\xfd" + "\x62\xb7\xe9\x9d\x5b\xd6\xe4\x3e" + + "\xde\x15\x78\x71\x6e\x4b\x99\x5a" + "\xd1\x31\xe1\xa7\xa0\xc7\x95\xd9" + "\xaa\x23\xc0\x26\xf2\x6d\xb4\xc8" + "\xed\xfc\x2a\x70\x4d\x09\xfd\x8c" + "\x86\xa8\xd6\xce\xcd\x43\xc7\x7b" + "\x75\xbe\xca\x1f\xc4\x0e\xd7\xb7" + "\x90\x93\xac\xdd\x47\x9e\x6c\x2a" + "\x90\xaa\x10\x93\x25\x94\x06\x72" + + "\xeb\xd0\x64\x54\xf5\x80\x7e\xd1" + "\xa7\x13\xa6\x67\xa7\xe1\xd3\x89" + "\xad\x7d\xc9\xc8\x60\x12\x79\x77" + "\xe7\xcb\xf0\xe4\x1f\xf2\x2f\xec" + "\x10\xbc\xe6\xe9\xc2\x4a\x98\xed" + "\x05\xa3\xcb\x77\xe8\x3d\xc5\xe3" + "\xdc\x4f\x62\x83\xb2\xf9\xba\x9b" + "\xec\xc0\x85\x14\xcd\x51\x94\x5e" + + "\xc8\x1e\x76\xb1\x6d\x75\x13\x1f" + "\x55\x7e\xb9\xa4\x98\x8b\x3c\xe5" + "\x28\xcc\x96\x40\xf8\xe3\xae\xb2" + "\x8d\x1a\x0f\x92\xa0\x61\xc3\x48" + "\x0a\x19\x31\x8c\x2d\x67\x8b\xa9" + "\xd4\x55\x18\x00\xd1\xe7\xc1\x7b" + "\x2a\x4b\x3f\xbf\x07\xfb\x2c\x24" + "\xc4\x8b\xa2\x32\x3f\x4a\xf4\x9b" + + "\xfa\xd1\x63\x0d\x7d\x13\xe5\x64" + "\x9f\xd8\xa9\x02\x52\xc0\x8f\x65" + "\x09\x63\x43\x50\x74\x48\x89\x48" + "\x61\xda\x98\xd5\xf8\x30\xae\xe9" + "\x91\xaf\x8b\x81\xd1\x10\xd7\x2e" + "\x20\x0c\x6a\x8b\x06\x9e\x7e\xe2" + "\x44\x6b\x1a\x1c\xfb\xdc\x28\x1e" + "\xdc\x57\xac\xd6\x64\xcb\x3a\x88" + + "\xa5\x76\xe1\x42\xac\xe2\x82\x99" + "\x64\x2b\x78\xe2\x46\xba\x4e\x32" + "\xf5\x50\x83\xe1\xaf\xaa\x8c\x3d" + "\xca\x74\xd6\xf5\xf2\x2a\xd8\xf3" + "\x1e\x0d\x60\x56\xed\x0f\x09\xc2" + "\x07\xde\x50\x59\xef\xe0\x48\x45" + "\xeb\x4f\x5a\x76\x3f\x02\xf0\xb2" + "\x90\x67\xf1\x39\x33\x10\x03\xb3" + + "\xb3\xc8\xa3\x61\x1d\x78\x92\xa6" + "\x0e\x6d\x87\x32\x54\x38\xbc\x08" + "\x03\x7b\x02\x28\xfb\x05\xcf\xbe" + "\x2f\xe1\xb1\xa4\x7d\x68\x6c\x63" + "\x58\x7c\x21\x07\x3d\x00\xe3\x00" + "\xa3\xb2\x01\x5e\x37\xa9\x3b\x61" + "\x6e\xe1\x1d\x88\x05\x84\x8c\xa5" + "\x8b\xf4\xf8\x14\x30\xc4\x53\xc6" + + "\xf9\xd0\xa0\xd6\x97\x68\x1c\xbc" + "\x55\x7f\x0d\x3b\x0e\xea\xe0\xd8" + "\xad\x7a\x5b\xb8\x92\xaa\x5b\xb3" + "\xf4\x48\x4e\x67\xb7\xd1\xec\x2b" + "\xc2\x9a\x7a\x6d\x8d\xf7\xd7\xe2" + "\xd0\x95\x9c\xf9\x62\x42\x07\xf5" + "\xe9\x11\xf6\x89\x0a\x47\x52\x48" + "\xec\x9d\x86\x92\x19\x91\xaa\xf7" + + "\xe2\xaa\x6d\x4e\x77\x2e\x7f\xed" + "\xbc\x19\x0a\x9e\xe3\xe0\x3a\x7b" + "\x7e\x67\xae\x91\x8a\x3f\x29\xd3" + "\x1f\x61\xc8\x45\xcb\xb0\x63\xd3" + "\x3b\xe9\x9a\x30\xcf\x1c\x1d\xbe" + "\xe1\xca\x20\x39\xe7\x0b\xf8\xa3" + "\x01\xdf\x8e\x49\x74\xba\xac\xaa" + "\x90\xac\xf5\xb2\x4a\x2a\x6d\x1e" + + "\xf1\x50\x35\x23\x3f\xf0\xc5\x60" + "\x2e\xfd\x5a\x92\x11\x94\xd0\xd4" + "\xa6\xe5\x58\xd2\xc3\x65\x5b\xa9" + "\x6a\x2c\x90\x9f\xb5\xcf\x19\x1a" + "\x68\x5c\xad\xf5\x3a\x01\x86\xb4" + "\xf3\x38\x96\x97\x76\x67\x50\xa2" + "\x28\x0b\x8e\xa3\xd0\xb4\x32\x12" + "\x4f\x7b\x6a\xd3\xb8\x84\x47\xa6" + + "\x96\xa6\x66\x02\x9e\xa1\xcf\x7f" + "\x4b\xfb\xc3\x92\xfd\x64\x1f\x5e" + "\xdf\x19\x6d\x50\x11\x49\x95\x6d" + "\xa1\x3c\x7a\x69\xe1\x9f\x98\x9f" + "\x7d\xa8\x27\x23\x8c\x8d\x48\x7e" + "\x17\xa3\x7d\x03\x28\xce\x43\xa5" + "\x18\x55\x3c\xf9\x76\x1d\x07\xea" + "\x3b\x6d\x0a\x22\x48\xfd\x5f\x58" + + "\x03\x0e\xd7\xe7\x9d\x17\x55\x56" + "\x70\x45\xa8\x72\x5c\x0c\x78\x3e" + "\x9c\x02\x50\x1d\xcb\xb4\x02\xc1" + "\x39\xe8\x75\xf0\xd5\xbd\x71\x3e" + "\x22\xb8\x98\xb4\xf0\xf4\x60\x64" + "\xa5\x8d\x4b\x6d\x6c\xe0\x82\x26" + "\xd4\x40\xa7\x96\xc9\x53\xae\x4e" + "\x2c\x70\x89\x63\xef\x8b\x9d\xc1" + + "\x70\xff\xc6\xc2\x8d\x72\x35\x87" + "\x35\x22\xdc\xc5\x2f\x12\xd6\x79" + "\xf9\x77\xe2\x19\x03\xd0\xf5\x23" + "\xc7\x8c\xed\xdd\x25\x4e\xe8\x7e" + "\x0a\x88\xcd\x63\xb0\xaf\xa8\x91" + "\x60\xaf\x74\x35\xc6\xa7\x3e\x3f" + "\x42\x7f\xde\x02\x84\xdc\xfc\x0c" + "\x52\xa1\x1a\xb3\x2f\x79\xd0\x62" + + "\x55\x16\x3b\xee\xb2\x47\x9a\x95" + "\x5b\x3d\x88\xec\xdd\xb9\x99\xc7" + "\x04\x38\x93\xb7\x80\x9f\xc0\x2d" + "\xb8\x3d\x2d\x3d\x88\xe8\x69\xae" + "\xf4\x0a\xe7\x25\x2f\x5e\x5d\xc1" + "\x85\x00\x04\x05\xce\xd9\x5f\x87" + "\xf2\x38\x5a\x6b\xd0\xe8\x50\x28" + "\xda\xb0\xbe\x9a\x35\x7f\x22\x15" + + "\xf2\x23\xe5\xe0\x37\x10\x0f\x65" + "\x3b\x01\x83\x95\x43\xab\x38\x44" + "\x5e\x90\xc0\xef\xfb\x68\x42\x03" + "\x6b\x77\x06\x0c\xa2\x4b\x28\x7b" + "\x33\x11\x6c\x1b\xc4\x49\xb9\x02" + "\x4f\xef\x4b\x19\x47\x8d\x3b\x7c" + "\x35\x05\x7e\x0e\x00\x5b\xe1\x5f" + "\xb4\x26\xb1\x28\x74\x66\x26\xc3" + + "\x44\x11\x92\xe0\x42\x93\xb9\xf8" + "\x2c\x3e\x03\xb5\xf1\xc6\x4f\xf1" + "\x54\xcf\xda\xdc\x60\x37\xfb\x7d" + "\xa5\x7b\x8d\xd8\x31\x0a\x5a\xd2" + "\x77\x49\xf7\x68\xcb\x2f\xed\x4d" + "\x07\x40\x76\x9a\x65\x47\x88\xf1" + "\xc7\xf4\xdc\xf2\x69\xb1\x9d\x87" + "\x6a\xf9\x6d\xd1\xd5\x75\x4d\x74" + + "\xb5\xef\xcc\xbe\xaa\xf5\xfd\x40" + "\xc7\xd7\x21\x36\xe9\xed\x56\xcf" + "\xc1\x76\xb5\x52\xce\xa9\x32\xb6" + "\x27\x60\x6f\x9a\xe8\x3a\x40\xd3" + "\x64\x5a\x78\xe8\x0d\x05\x0a\x66" + "\x2e\x65\x82\x96\x47\xd6\xf3\x10" + "\x02\xbe\xbc\x4f\xdf\x5e\xb2\x78" + "\x5d\x31\xf9\xb4\xde\x0f\x71\xc9" + + "\xf9\x35\x02\x1e\x9a\x00\x88\x0f" + "\xa1\xb8\x20\x48\x27\x40\xed\x2f" + "\x40\x11\x08\x86\xac\xb7\x72\xbe" + "\xe3\x63\x11\x60\x72\x26\x16\xd4" + "\xea\x71\x0c\x75\xad\xa3\x1e\xf7" + "\xe3\x8b\xdc\xaf\x40\x71\x34\x02" + "\x6b\xa6\x5a\xc6\x29\x6f\xe6\xa5" + "\xc8\x8f\x39\x07\x64\xec\xc7\xf3" + + "\xa2\x38\x99\x17\x63\x67\x09\x14" + "\x77\xb8\x1c\x1c\x71\x0e\xba\x4f" + "\xcf\x7c\xcf\x7c\x2f\x2a\x6f\xda" + "\x65\xde\x1b\x09\x4e\x1a\x24\x91" + "\xd8\xfc\x71\x1e\xc3\x56\x28\xcc" + "\xc3\x1c\x44\x12\x7c\x7e\xb8\xc0" + "\xaa\x24\xf2\xe5\x1e\x68\xd1\x3d" + "\xea\x08\x73\xad\xf6\xd6\xae\x30" + + "\x22\x3e\xb5\x28\x17\xb0\xb8\xd4" + "\x71\x7c\x7b\x0f\x48\xd9\x94\xe3" + "\xdf\xaf\x1c\xb2\x68\x23\x1f\xe2" + "\x33\x78\xcc\x86\xb6\xfa\x11\xc9" + "\xd7\xcc\xd1\x39\xfd\xf6\x61\x0f" + "\xa9\x90\x8d\x24\x8b\xeb\x16\xe2" + "\x0d\xd2\x22\xfc\x44\x8f\x05\xa5" + "\x28\x96\xc6\x57\x92\x96\x26\x91" + + "\xce\x07\x58\x8a\x43\x4e\x1b\x8e" + "\x7e\x9a\x10\xe4\x93\x38\x28\xad" + "\xda\x9d\xd5\xaf\xcb\xc9\x0c\xc3" + "\x93\x80\x8d\x3d\xc6\x36\x5f\xf6" + "\xb2\x32\x0d\xa6\x9e\x46\x31\xdf" + "\xc8\x91\x81\x3e\x4b\xdf\x93\xee" + "\xb5\xde\x5b\x35\xc5\x17\x10\x9c" + "\x28\xaa\x16\x86\x85\x31\x62\xd2" + + "\x10\xed\x48\xa4\x64\x4f\xed\x38" + "\x8b\xb7\xef\xc4\xa8\x03\xeb\x81" + "\x52\x3b\x32\x91\x5c\x1b\xd9\xbf" + "\x2e\xff\xbe\xb6\x33\x2b\x88\xed" + "\xa1\xd7\x22\x67\x51\x45\xfb\xd0" + "\xab\xe8\x9f\x94\x1b\x44\x91\x6f" + "\xa6\x81\xc1\x3a\x99\x4a\xa4\x63" + "\x74\x6b\x0b\x95\x5f\x2b\xa6\xf4" + + "\xcf\xa2\x01\xe8\x46\x44\x61\x22" + "\xdf\x8c\x47\x2e\x27\x20\x3a\xfa" + "\xb3\x50\xc6\x98\x9a\x0c\x2a\x10" + "\x70\xff\x73\x48\x98\x93\x00\xc5" + "\x01\x6d\xa1\xfa\x06\x86\xec\x87" + "\x8b\x4d\xdd\x9e\x94\x27\xc1\x0f" + "\x60\xd4\x6b\x6f\x00\x7a\xa9\xe7" + "\x59\xff\xbe\x5e\x30\xd1\x9c\xf6" + + "\x28\xa2\xb5\x62\x86\xd1\x09\x62" + "\x26\x8b\x40\xd4\xaa\x7d\x5d\xb8" + "\x00\xb3\xb1\x8e\x0f\x11\x48\x7e" + "\xab\xaa\x64\x04\xd2\x3c\x78\x66" + "\x61\xa0\x8b\x0f\x25\x8b\xf6\x2d" + "\xeb\x8a\xa0\xb2\x61\xc4\xe0\x97" + "\x38\x0d\x64\xbd\x0e\x6f\x8f\x6f" + "\xa6\x5d\x47\x41\xe1\x22\x33\x99" + + "\x0e\x98\x45\x32\xe7\xad\x55\xd6" + "\x00\x72\x06\x81\x57\x96\xf5\xa6" + "\xe1\x6b\x13\xdb\xbe\x23\xfc\xe4" + "\x79\xd8\x13\xaf\xdc\x6c\x24\x9f" + "\x0e\xac\x61\xf9\x17\x31\xb9\xc2" + "\x1a\x9e\xdb\xeb\xb5\x41\xa7\xc8" + "\xd1\x3b\x69\x6c\x46\xe2\xed\x82" + "\x1e\x70\xd1\x3d\x4f\x6b\xde\xfc" + + "\x6f\x64\xa4\xca\x00\x4e\x80\x1f" + "\x24\x49\x94\x70\x88\xdc\x43\x86" + "\xe9\x6d\xf8\x73\xa2\x1c\x7f\xa3" + "\x98\x98\x88\x28\x92\x9f\x19\xa3" + "\xdf\x4a\x1e\x0c\x58\xba\x73\xc2" + "\xf0\x82\xbc\x65\xaf\x38\x0d\x0f" + "\x3b\xcd\xa6\xf8\xb5\x8a\xb2\xd8" + "\x8e\x4d\x89\x75\x85\xe0\xa6\xee" + + "\x15\x32\xc9\x0e\x98\xb9\x42\x46" + "\x9f\x34\x9d\x29\x0a\x17\x19\xb7" + "\xba\xb5\x36\xbc\x2b\x16\x2c\xb3" + "\xa2\x3c\xd2\x4b\x85\x73\x35\x06" + "\x15\x81\xf6\xdf\x92\x62\x41\xff" + "\x99\xdb\xb5\x4b\xe3\x50\xa1\xb7" + "\x55\x3d\xc1\xa3\x28\x20\x7a\xb9" + "\x06\x45\x42\xe5\xc1\x06\xf4\x86" + + "\xcf\x95\xcd\xb9\xb9\xc1\xb0\xfa" + "\x73\xae\xa9\x11\xb3\xab\x85\x36" + "\xa3\xa9\x96\xa9\xaf\x3e\x97\x02" + "\x1d\x57\x34\x29\xaf\x9b\x6f\xff" + "\xe8\x40\x7c\x25\x21\x81\xab\xe4" + "\xb1\x30\x2d\xd9\xe4\x28\xad\x09" + "\x82\xb5\xe4\x09\x35\xa0\x51\x7c" + "\x0f\x12\x5b\xc3\xf8\x01\xbb\x60" + + "\x21\x1a\xc3\xde\xf9\x83\x2c\xb0" + "\x73\xd5\xd9\x6a\x23\x8b\x8c\x98" + "\x65\xe3\x7b\xa5\xae\x83\xe9\x53" + "\x4e\x83\x6f\x64\x4d\x73\x68\xe9" + "\x9b\x30\xa6\x5d\x8f\xea\x37\x91" + "\x16\xce\xf1\xc1\x24\xa6\xf3\x10" + "\x21\x09\x44\xca\xa2\x9e\x2a\x78" + "\xb5\xf1\x46\x5b\x9e\x73\x94\xdf" + + + "\x6a\xb1\xf8\xf4\x0e\x41\xf8\x56" + "\x6a\x26\x7b\xc4\xfe\x1a\x24\x97" + "\xc1\x87\x9c\x6d\x8e\x6b\x40\x0a" + "\x1b\xab\x42\xcd\x02\x3e\x3f\x80" + "\x69\xec\xdb\x04\xa8\x09\x03\x7f" + "\x5f\xd0\xba\x3b\xf7\x85\x3b\xa8" + "\x7f\x19\x8e\xad\x73\x72\x09\xc6" + "\xc1\xad\x67\x50\x0e\x44\x97\xc0" + + "\x8c\x89\x11\xb3\xa0\x7f\x74\x3f" + "\x65\xac\x0e\xcd\xe4\x72\xa2\xe2" + "\xbc\xd0\x14\xf9\x51\x58\xba\x4b" + "\xe3\x3e\xa4\xc4\x60\x96\x1a\x7a" + "\xe9\xcd\xc8\xa1\xce\x67\xa3\xe5" + "\xe3\xab\x71\x72\xa9\x8b\x95\x9d" + "\xcd\x15\x16\x3d\xb6\x7e\xff\xf3" + "\xb0\x20\xae\xf5\xce\x0d\x28\xa2" + + "\xdc\xf8\x94\x37\xa4\x44\x63\x26" + "\x36\x5c\x3c\x48\x3a\x92\xca\xdc" + "\xa0\x10\x9d\x3f\xbf\x6b\x6b\x2d" + "\xf3\xbd\xd9\x81\xca\xc5\x20\xb3" + "\x95\x0a\xb5\x47\xff\x28\x0e\x62" + "\x71\x33\xf0\xce\x01\x3b\x3e\x93" + "\x53\x01\x10\x99\x85\xbf\x81\xf0" + "\xd6\xc8\xa8\xc3\xa0\xe9\x3b\x18" + + "\x66\xa5\xdc\x41\xc3\x85\xc1\xb6" + "\xa3\x2a\x62\xd8\xda\xfe\xe7\x7d" + "\xfb\x6d\x1b\x90\x92\x4d\xe8\x99" + "\x88\xd2\x4a\x7c\x0e\x2b\xa0\x30" + "\x36\xcf\xd3\x2f\xaa\x1d\xc8\xc7" + "\x9f\xe5\x89\xdf\x47\x95\x31\xd1" + "\x33\x67\x49\xcd\x84\x81\xbe\xb2" + "\x2b\x41\xd3\x93\xeb\x49\xf4\xd5" + + "\x6b\x11\x85\xe0\xab\x0f\x47\x25" + "\x10\x53\x28\x87\x75\x33\xa4\x04" + "\x2f\xd5\xbf\xe2\x7e\x18\x39\x4e" + "\x74\xbc\x9e\x7d\x44\x6b\x16\x36" + "\x2c\x32\x4b\xfd\x3c\x43\xad\x92" + "\x51\xab\x79\xba\x17\xa8\x6a\x72" + "\xeb\x15\xdb\xc1\xd8\xac\x6e\xf9" + "\x63\xbe\x76\x04\x91\x1e\xf7\xfa" + + "\x16\x65\x7e\xc9\xda\x9b\x4e\xd7" + "\x9e\xf4\x30\xc2\x60\x93\x77\x88" + "\x49\xea\x74\x1e\xe3\x1d\xec\xa6" + "\xa2\x45\xb6\x3f\xe5\xce\x1d\x58" + "\x14\x3f\x48\x8f\x91\x23\xef\xba" + "\x3b\xd1\x37\xd1\xfc\xdd\x2d\x6d" + "\x42\x3a\x74\xd2\x0e\xe5\xcd\x54" + "\x67\x7e\xd9\xe4\xc5\x4f\xa3\x89" + + "\x68\xe1\xde\x49\xe9\xd2\xcf\x72" + "\x39\xf2\x2a\x3e\x23\x52\xe0\x1a" + "\x6a\x06\x94\x1d\xbe\x75\x9e\x00" + "\x13\xf4\xab\x38\xc7\x31\xca\x6c" + "\x08\x99\xc4\x9b\x1d\xd6\x0b\xb5" + "\x1e\xbc\xe2\xf5\x8c\x4a\x9b\x4a" + "\xac\x83\x6f\x94\xf7\xc5\x6c\xeb" + "\x28\xab\xff\xeb\xfc\x93\xda\x27" + + "\x4c\xf6\xd8\x4c\x64\xec\x92\xc4" + "\x51\x7b\x9d\x27\x90\xd7\xa2\x58" + "\x56\x52\xc7\x1f\xc5\x1f\xed\x0c" + "\x17\x30\x43\x8f\xed\x8a\x65\x3e" + "\xeb\x59\xda\x05\x2e\x94\x61\x0b" + "\x22\x37\xdc\x0d\xa3\x60\x3d\xba" + "\x87\x7f\x2e\x74\xd1\x1c\x31\x7c" + "\x6e\x1b\xb0\xf6\xee\xff\x73\x64" + + "\x51\x7c\x25\x76\xef\x19\xe5\x3c" + "\xe7\x77\xd4\x18\xd3\x18\x58\x6f" + "\xc0\xed\x63\x79\x03\x2e\x02\xab" + "\xf3\xf5\xd1\x8b\x89\x3a\x40\xf0" + "\xca\x33\x60\x49\xa0\x8d\x3b\xe4" + "\x72\xdd\xcf\xa1\x0e\xe1\x94\x09" + "\xe2\xc0\x73\xba\x20\x6d\xec\xb1" + "\xd1\xfa\xbc\xb6\xec\xc9\x29\x03" + + "\x9d\xbd\x84\x2c\xa1\x42\xff\xf1" + "\x4a\x67\x0c\x39\xc4\x3e\x1f\x75" + "\xca\xe0\xe5\x01\xf7\x36\xbb\x27" + "\x92\x66\xaf\x5c\x51\xff\xdf\x65" + "\x3f\xbd\x7b\xcd\xc4\x79\xf5\x5d" + "\x05\x12\x59\x85\x97\xb2\x8f\xef" + "\x32\xc7\x7a\xe4\x03\x72\xed\x1d" + "\x1a\x33\x1c\xcd\x5c\xc4\x3d\xa9" + + "\xd4\xd2\x18\x33\x8e\x33\xec\xbd" + "\x63\xe9\x8d\xbe\xbb\xd7\x3d\x73" + "\xbd\x7e\xc4\xa2\xba\xc3\xbc\x61" + "\xde\xcb\xef\x35\x19\xad\x21\xa8" + "\x5c\xdd\x4c\x02\x8c\x66\xac\x91" + "\x49\xfa\xcd\xc1\xe4\x58\xa5\x7b" + "\xda\xb4\x8f\x90\xe0\x4c\x1d\x49" + "\xe8\xbd\x85\xf6\xf9\x69\xa8\x7b" + + "\x78\x1c\xf4\x81\xcb\x0b\x2a\x7b" + "\xe1\x40\xd2\x1f\x85\x2c\x52\x5c" + "\xf6\xe3\x5c\xdf\x68\x2e\x51\xce" + "\x13\xee\xd5\xb6\x52\xb9\xd4\xa7" + "\xaf\x7e\xad\x31\x8b\x0a\xdc\x8c" + "\x20\x5e\x91\x1b\x75\x86\x5e\x16" + "\xf4\x77\x64\x5d\x9b\x26\x8c\x8e" + "\x91\x1b\x42\x44\xde\x5a\x8d\xd2" + + "\xba\x64\xf4\x79\xc2\x5e\x1b\xed" + "\x26\x2e\xd7\x47\x2c\xe4\x65\x2d" + "\x26\xf9\x67\x9e\x74\xe5\x98\x81" + "\x44\x7e\x74\x34\x38\x67\x06\x41" + "\x47\x54\x7e\xe3\xc1\xac\x37\x46" + "\x22\x58\xe1\xf3\xec\xc9\xcb\x02" + "\x3c\xa8\x5a\x80\x8e\xe9\xa8\x58" + "\x00\xe8\x95\x55\x6e\xcd\xfa\x73" + + "\x18\x23\xa9\x32\xb3\xfd\x7c\x19" + "\xb6\x87\xac\x25\x41\xa8\xbe\x9e" + "\x7a\x0c\x51\xa3\xf7\x05\xd8\x4c" + "\x8e\x42\x6e\xe0\x9a\x99\xdf\x24" + "\x9c\x45\x71\x4d\xdc\xd5\x4d\xd5" + "\x3c\xa0\xb8\x20\x4f\x32\x84\x14" + "\x27\xb9\x74\x31\xd9\xf2\x24\x79" + "\x50\xde\x3a\xf9\xbf\xac\xb8\x42" + + "\x07\x05\x33\x38\x03\xf8\x8f\x46" + "\x3e\xa5\x37\x40\xdf\x4d\xf3\x06" + "\xa4\x93\x69\x8d\x40\x1a\xcd\x70" + "\x22\xc0\xe5\x43\x97\x15\x5a\xf8" + "\x7d\xa6\x25\xc1\xc2\xc9\x6f\x39" + "\xcb\xbf\x64\x10\xbf\xbe\xb7\x03" + "\xcb\x6d\x80\xa9\x92\x45\x44\x7c" + "\x54\xcd\x87\x44\x4b\x61\x02\x1b" + + "\x42\xc5\x2a\x69\x4f\x60\x03\x83" + "\xd3\x91\x7b\x22\xe1\xff\x79\xf0" + "\xbd\xf9\xaa\x15\x63\x3e\xf6\x19" + "\xfb\x44\xf3\xf1\x65\xe5\x9e\xf9" + "\x99\x91\x21\xd6\x1f\x66\x1d\x8a" + "\x1c\xe4\x8c\xd4\xc6\x3b\x88\x8c" + "\x04\xd9\x74\x3c\x8f\x11\x65\x10" + "\x1b\x8b\xaf\x0f\xee\x89\x38\x71" + + "\xb6\x1b\xe2\x0d\xf7\x60\x7b\xb4" + "\xca\x36\xd8\xdc\x4f\xae\xac\x64" + "\x63\xce\x44\xc7\x6d\xea\x75\x33" + "\x5b\x95\x47\xb0\x5f\x26\x64\xb7" + "\xc3\xc2\x41\x98\x4c\x5d\x8a\xc6" + "\x60\x4f\x45\xcf\xd7\x8f\xe9\x60" + "\x0c\xea\x6a\x75\xe2\xfb\x01\xc7" + "\x79\x1c\xb2\xaa\x5e\x88\xc8\x09" + + "\xcf\xbd\xd1\x91\xef\x59\x13\xca" + "\x86\x25\x59\xf3\x57\x21\x08\x6a" + "\x1c\x95\x51\x39\x94\xa5\xae\xd9" + "\x06\xe7\xb7\xa2\x24\xef\xab\x57" + "\xa2\xb1\x2e\x2e\x1e\x72\xa5\x3f" + "\x98\xce\x6a\x51\xac\xee\x68\x3c" + "\xdf\x82\x87\xc2\x47\x9d\xa7\xff" + "\x7b\x57\x16\x4e\x63\x9f\xd6\xbd" + + "\x6c\xd4\xd2\x69\x08\x81\xbb\x45" + "\x5a\x36\xc8\x68\x39\x8b\x7c\xe4" + "\xbd\x51\x75\x26\x63\x76\xb8\xf3" + "\x7a\x54\x67\x5b\x8f\x76\x90\x15" + "\xff\xd3\x2e\xfb\xb2\x1d\x1c\x37" + "\x40\x94\xa5\x17\x19\x69\x16\xe3" + "\x14\x2c\x24\xdf\x78\xd1\xc0\x03" + "\xc1\x2a\x86\xed\xce\x3f\xc9\x40" + + "\xaf\x84\xbb\xc5\x60\x79\x2b\x40" + "\x39\xa6\xc8\xbc\xdc\xc7\x29\xcf" + "\x6d\x7c\x8f\x47\xff\x9d\xf1\xfa" + "\x22\xbd\x37\x33\xe4\x6a\x30\x71" + "\x7a\x9b\x59\xbf\x05\x55\x7c\xef" + "\xa8\x91\x46\x9c\x9e\x15\x9e\xe0" + "\x19\xb1\xce\x74\x18\xe8\x03\xd4" + "\x8d\xa9\x11\x52\x02\xe7\x25\x53" + + "\xd6\x82\xc9\x2b\x69\xda\x86\x12" + "\xe3\xe7\xda\x7b\xf2\x80\x6d\x5f" + "\xfb\x64\xf0\xa6\x47\x56\x9c\x3d" + "\x40\x15\x4c\xd7\xa1\xe6\xc8\xfd" + "\x5a\x13\x8b\xd6\xc6\x48\xda\x97" + "\xff\xbf\x6d\xd6\x79\x79\x09\xc2" + "\x1d\x53\x20\xea\xb9\xad\x96\x02" + "\xf0\xc8\xb2\x4a\x0d\x73\x33\xa3" + + "\x33\x19\x25\x7a\x2b\x12\x97\xaf" + "\x45\x33\x23\xc1\x9c\x34\xc7\x36" + "\xb0\x00\xf4\x73\x88\xde\x87\x56" + "\xaf\x95\x75\x70\xa3\x47\x28\x92" + "\xc1\xde\xf6\x7f\x58\x18\xe0\xb7" + "\xcb\x91\xc1\x2f\xce\x3e\x28\x6e" + "\x56\xdc\x20\x1c\x8b\xef\xc2\x78" + "\xdc\xd2\x2e\x45\x5e\x53\xe6\x51" + + "\xed\x7f\x84\x29\x54\x56\xb3\x0e" + "\xd0\x3d\x67\x0a\x86\x42\xc1\xfd" + "\x0b\xdd\x62\x8b\x27\x36\x1b\x72" + "\x71\x57\x1a\x71\x3e\x29\x5a\x10" + "\x27\x19\x76\x7f\xce\x1c\x00\xdf" + "\x7d\x4c\xd0\x11\xb0\x81\xb6\xf7" + "\x96\x19\xac\xa3\x92\xf7\xdf\x16" + "\x30\xae\xc4\x0f\x0b\x12\x0c\x58" + + "\xc7\xb8\x0e\x96\x97\xf6\x35\xc0" + "\xd3\x04\xde\xe2\x2c\x9f\x59\xf1" + "\x28\x92\xad\xd2\xf8\x50\x24\x89" + "\xab\xc1\x29\xb8\x9b\x12\x48\x7d" + "\xc9\xaf\x50\x3a\xe1\x85\xd7\x24" + "\xe0\x6e\xa9\x63\x27\xba\x45\x27" + "\x7b\x6d\xfb\x3b\x01\x34\x65\x95" + "\x42\x2a\xad\x1b\x67\x02\x62\x53" + + "\xbc\xd0\xe8\x7e\x4f\x3d\xea\x31" + "\xdc\xc3\x42\x0f\x2a\xf2\x32\x38" + "\xf4\xa2\x87\x1a\x1a\x06\x61\xc6" + "\x6b\x57\x45\x4b\xf6\xc9\x78\x09" + "\xd2\x5f\xfb\x6d\x3c\xac\xab\xb7" + "\x90\x1b\xe0\xb7\x00\x6a\xf3\x27" + "\x36\x9e\x42\xe9\xcd\x33\xf7\x68" + "\xcb\xe8\xbf\xdc\x81\x46\x3a\x95" + + "\xe3\xc2\x03\x41\x24\xff\x96\xe3" + "\xe7\xad\x06\x1b\x1c\x56\x33\x41" + "\x34\xa7\xd0\x65\xac\xb9\x20\xe1" + "\xd9\x19\x79\x92\x07\x6f\x6f\x57" + "\x5a\x95\x1f\x69\x46\xc8\xcf\xa0" + "\x65\x9d\x44\xa6\xc0\x2b\x2e\x3d" + "\x9b\xed\x67\x97\xb8\x41\xa5\x7b" + "\xc7\x15\x92\xdc\x04\x1b\xb2\xd1" + + "\xaf\x1e\xfe\x67\x10\xc4\xb7\xbf" + "\x85\xa7\x29\x69\x6a\x3c\x07\xa2" + "\x79\xdb\x5f\xa7\xf4\x36\x25\x6f" + "\x69\xca\x9b\x80\x6d\xd2\x9a\x85" + "\x7b\x7e\x19\x3b\x69\xc0\xf2\x06" + "\x73\xa5\xc0\x8e\xf4\xd9\x6a\x65" + "\x62\x02\x4d\x9a\x1f\x90\xc7\xe7" + "\x2b\x60\x38\xb9\x43\x94\xc2\xbe" + + "\xa4\x73\x00\x0f\xfc\x97\x03\xd0" + "\x5f\x67\x8d\x6f\xa4\x8f\x66\x5b" + "\x8c\x10\x22\x15\xc9\x4a\x37\x14" + "\x2e\xe4\x83\x02\xd1\xa7\xef\x92" + "\x4a\x02\x6d\x0b\xf9\x6d\x3e\x67" + "\x26\x1f\x58\x57\xd4\x14\xf9\x05" + "\x12\x8c\xdf\x67\x62\x51\xc8\xf5" + "\x62\x24\x6c\xe0\xb4\xf1\x97\x11" + + "\xc1\x90\x9c\xdd\xb3\x1c\x2d\x6e" + "\x9e\x57\x90\x79\x5a\x2d\xf8\x28" + "\x95\x61\x22\x06\xcd\x89\xe1\x90" + "\x74\xdc\xb0\x19\xdf\x39\x29\xbd" + "\x77\x71\x91\xc0\x05\x85\xb1\x18" + "\xc4\xd9\x17\x31\x0d\x47\xd5\xee" + "\xa0\x3c\x89\x6c\xeb\x92\xef\x39" + "\x40\x19\xa4\x44\x82\xef\x33\x45" + + "\x95\x75\x2d\x2d\x3c\x85\xac\x62" + "\x54\xad\x8f\x59\xb7\xda\x83\x48" + "\xa4\xd7\x32\x6d\xd1\xf5\xf7\xbb" + "\x81\xd8\x1d\xfd\x2d\x4f\xfb\x95" + "\x80\xc5\x5d\x54\xf2\xae\x39\xe2" + "\xb9\x39\x1e\x4d\x0a\xa7\x09\x46" + "\xb2\xbb\x8e\x33\x3e\xb3\xd3\x61" + "\x61\x54\xbd\x15\xc2\x1d\x05\x06" + + "\xda\x3d\x94\x34\xec\x9d\xee\xca" + "\x82\x67\x4b\x8b\x8e\xe9\x50\x8e" + "\x1f\x3a\xea\x91\xa5\x8e\x35\x24" + "\x94\xc1\xe1\xa9\x27\xc8\xc4\x71" + "\x94\x7a\xbb\x09\x5d\xaa\x8b\xa3" + "\x9c\x8f\xb5\x57\xc0\xb4\x4a\xfb" + "\x19\xee\xe0\x24\x5e\x06\x01\x4a" + "\xbf\x77\xb8\x07\x51\x80\xcf\xb9" + + "\xbe\xb3\xa1\x81\x8f\x3f\x2b\x97" + "\xa0\x64\x27\xce\x45\xe1\x3c\x4f" + "\xf7\xf5\xc4\x28\xcc\xf1\xd0\xe2" + "\x5b\x98\xf3\xc7\x0d\x0c\xee\xde" + "\xc3\x25\x9e\xd3\xc0\xad\xf4\x7d" + "\x80\xa0\x67\xc4\x20\x98\x61\x40" + "\x58\x5a\xcf\x61\x93\xbc\x0e\x44" + "\x00\xd6\x2a\x42\xa6\x29\x77\x52" + + + "\x49\xf4\x73\x3f\x75\x6a\xb2\xef" + "\x79\xfc\x44\x8d\xf8\x94\x1c\x1d" + "\x4d\xdc\xc0\x3b\xc5\xfb\xf0\x49" + "\xd0\xa0\x98\x36\x0b\xea\x47\xb7" + "\x1e\x29\x8d\x22\xfe\xc3\x18\x52" + "\xd6\x29\xc1\x43\xb5\x04\xb8\x35" + "\x16\xc5\xac\xd1\xb8\x59\xc8\xfa" + "\x68\xe6\xd6\x95\x7d\x69\x10\x6c" + + "\xdb\x2f\x45\xcb\x1a\x25\x30\x6e" + "\x50\x06\xf3\x50\x65\x69\xee\x31" + "\xd9\x48\x35\x93\x08\xe5\xb3\xb0" + "\x5b\xef\xb0\xf4\x4f\x9a\x94\xb8" + "\xbd\xf3\x88\x3c\x26\x83\x8b\x20" + "\x89\x99\x1d\xdb\x30\x7c\x14\xab" + "\x03\xdf\xd4\x44\xfd\x15\x65\xed" + "\xc5\xb0\x2e\xe7\x75\x2f\xa1\x17" + + "\x89\xfe\xe3\x28\xe0\xbb\x6c\x7a" + "\xeb\xc0\xaa\xc5\xe4\xfe\xe1\xe7" + "\x40\x51\x7e\x69\xa5\xed\x47\x7f" + "\x1f\x92\x54\xb4\x37\x01\x45\x4f" + "\x85\x81\xcd\x95\x84\x5f\x62\xdb" + "\x83\xe5\xb2\xcd\xa1\x0b\xbe\x74" + "\xe4\x6d\x5e\xdd\x7c\xfd\xe4\xae" + "\x39\x17\x10\xe8\x7d\x43\x51\x42" + + "\x90\xad\xfd\x81\x78\x4f\x91\x25" + "\xab\xf6\x2c\x0d\x56\x8f\x63\xcf" + "\xe5\x4d\x05\xcc\x3f\xc0\x0b\xb9" + "\x50\x63\xb0\x18\xa7\x11\x28\x93" + "\xff\x11\xbd\x9b\x30\xb3\x00\x2f" + "\x74\x49\x04\xb4\x6f\x8a\x10\x76" + "\x66\xd2\x51\xa8\xe0\xb9\x1b\x80" + "\xc1\x90\x89\xbf\xbe\x99\xd0\x0d" + + "\x61\x70\x7d\x51\x0a\xb2\x5e\x11" + "\x83\xf6\x2d\x6c\x33\x34\xfe\x77" + "\x67\xfc\xc6\xcd\xc7\xdd\x70\x68" + "\x83\xde\x87\x0b\x88\x05\x61\xb1" + "\xbe\xdd\xc4\xd9\xca\x84\x35\x34" + "\xe2\x4b\x75\x3d\x1c\x4f\x16\xb3" + "\x94\xc8\xe6\xc1\x3a\xed\x31\x07" + "\x4c\x90\x6b\x4f\xec\x7d\x32\x26" + + "\x55\x38\x1c\xc6\xae\x7b\x26\x29" + "\x3b\xfd\xc1\x58\x9d\x42\xff\xeb" + "\xb8\x93\x0b\x8c\xc0\x86\xd8\x22" + "\x53\x89\xdb\x2d\xb2\x00\x5e\xca" + "\xb7\xd8\xfe\xc3\x17\x01\x33\xcf" + "\xf6\x01\x9c\x81\xfa\xc6\x9a\xd4" + "\x54\xbd\x0f\x3c\xbd\xa6\xda\x6d" + "\xcf\xa2\x49\x80\x68\x30\x74\x91" + + "\x5a\x76\x72\x76\x3c\x06\x6a\x0a" + "\xbf\xb9\x47\x05\x64\xce\xa3\x37" + "\x33\xa6\xb1\x98\xc8\x99\xc0\x42" + "\x61\x69\xee\x05\x0d\x80\xab\xb5" + "\xd6\xac\xa5\x11\x59\x3f\x96\xf1" + "\x63\x10\x20\x46\x57\x61\xee\xba" + "\x0a\x21\x96\xa5\x49\xa6\xd9\x36" + "\x8c\x13\xa7\x1b\x63\x43\xd0\xae" + + "\x46\xcd\xd6\x58\x8a\xdd\xc6\x14" + "\xd2\x34\x66\x8e\xb5\x33\xb6\x9c" + "\x28\xc3\x1b\xf8\x47\x50\x30\xc1" + "\xe5\x77\xa1\x26\xe2\xe0\xed\x12" + "\x4f\x6f\x5a\x06\x62\xca\x2c\x33" + "\x7b\x48\xbe\x67\xcd\x7e\xa4\xc3" + "\x1c\xed\x47\x0f\x87\xb1\x1e\x74" + "\x14\x8b\x59\xe7\x58\x6e\xe6\x99" + + "\x6e\xe7\x1f\xf5\x76\x28\x82\x36" + "\x89\x25\xd6\x11\xcc\x11\x68\x8a" + "\x18\x57\x22\x46\x65\x7e\xfc\xc3" + "\xcd\xdb\x2f\xc8\x9f\x2c\xdf\xb7" + "\x5b\x20\x7b\xdd\x52\x4e\x1d\x3b" + "\x14\xe4\xa2\x47\x78\x94\x95\xb6" + "\x48\x11\xa9\xef\x93\xd7\xe4\x05" + "\x75\x96\x2e\xfd\x46\xd4\x7e\xb4" + + "\x2f\x23\xf3\xeb\xe2\xd0\x0e\x8f" + "\xdd\x2e\x2a\xc5\x9e\x0f\xf8\xff" + "\xdb\x5f\xb5\x75\x33\xb4\x9a\xad" + "\x11\x0c\x2e\xe4\x20\x78\xca\x73" + "\x46\x1b\x25\xe6\xa0\xe0\xac\x6d" + "\x2d\x93\x0d\x4c\x5c\x6b\xbc\x89" + "\x9a\xa1\x5d\x09\x77\xcd\x38\x34" + "\xfb\xbd\x48\x8d\x39\xa9\x24\x2f" + + "\x92\xb8\x41\x55\x51\xc4\x5d\x1d" + "\x54\x9e\x9d\xfc\x41\xee\x86\xb1" + "\x0d\x61\xbf\xd5\x5e\x34\x9f\x9d" + "\x9f\xca\xac\xf6\x5d\xa6\x7b\x3e" + "\x86\x94\x36\xa8\x7a\x78\xda\x9d" + "\x53\xba\xb5\x8e\xb7\xda\xf9\x09" + "\xc3\x1b\x48\xd6\x33\x20\xfb\x5a" + "\x04\x21\xa6\xaf\x30\xce\xf4\x76" + + "\x3d\xc9\x0a\x7b\x77\xa6\xd6\xeb" + "\xd7\xe0\xf5\x78\x0d\x7b\xe3\xa6" + "\x2b\x49\xf5\x76\x96\xc0\x16\x25" + "\x3a\x5f\xc0\x9a\x88\xf8\x4b\x1e" + "\x2b\xba\xf0\x4d\xe0\x2c\xb4\xcd" + "\x1b\x34\x62\x50\xfd\x5c\x5d\x93" + "\x20\xac\xac\x82\x33\x33\x30\x8a" + "\x0e\xb0\x98\x51\xc4\x38\x94\x42" + + "\x24\x8e\x1f\x5a\x3c\x18\x99\x3f" + "\xf0\x55\xd2\x9d\xfa\x18\xb1\xfd" + "\xa6\x62\x7f\xc2\x90\x8b\xb1\xb9" + "\x91\xc1\x6e\x39\xf7\x32\xf7\xe8" + "\xab\x86\xe7\x0b\x91\x2d\x4a\x52" + "\xf5\xa0\xc5\x0a\xef\xad\x32\x5d" + "\x94\xf6\x25\x97\xd6\xd4\x53\x9b" + "\x89\xba\x10\x05\xc6\x76\x2a\x03" + + "\x1c\xb1\x58\x57\x59\x5d\x9b\xa4" + "\x40\x4f\x65\xc8\x93\x28\x85\x0b" + "\x47\x94\x37\x52\xf4\xf6\x3e\xb6" + "\x0c\x69\x5e\x10\x29\x7d\x95\xd4" + "\xb0\x59\x65\x64\x63\x43\x48\x7d" + "\x8e\x8a\x78\x49\x3c\x27\xa8\xf4" + "\xa9\x54\xce\x34\xb8\x6c\x40\xee" + "\x9b\xda\x6f\xf8\x0f\x26\x1c\x1e" + + "\x50\x47\x95\x0e\x74\x79\xbd\x9d" + "\xc6\xd2\xf9\x64\x88\xde\x21\x01" + "\x2e\x23\x85\xd9\x42\x7b\x59\x2e" + "\x77\x17\x45\x53\xc5\xc3\xb6\x55" + "\xfb\xb9\x9c\x51\x47\xe5\x53\xbb" + "\x0d\x60\x28\x84\x9f\x01\x34\xf1" + "\x1a\x79\x81\xe0\x76\x31\x47\x5a" + "\x08\x0c\xfb\x35\x63\x22\x3e\x2f" + + "\xe0\x73\xe5\x67\xbe\x38\x28\xfb" + "\x4b\xc4\x84\x40\xb9\x1d\x89\x05" + "\xc5\xc2\xc1\x96\x73\x13\x31\x91" + "\x4b\x44\x58\xd9\x3f\xfa\xeb\x6a" + "\xc1\x55\x6e\xe5\xe9\xdc\x9c\xac" + "\xd0\x46\xaa\x2c\xd3\xce\x48\x71" + "\xeb\xe8\x1f\xb6\xef\xc7\x10\x2e" + "\x4d\xcf\x97\xff\xda\x35\xd8\x9f" + + "\xdd\x99\x1d\x43\x8d\xa1\xed\x9b" + "\xe1\xcc\xd5\xf3\x3d\x0b\x69\xf7" + "\xc9\x6e\x32\xb7\x6d\x65\xfb\x97" + "\x9c\x73\x95\x8c\x44\x71\xb2\xc1" + "\x98\xe2\x21\x9c\x89\xea\xec\x65" + "\x34\x57\x35\x37\x91\x72\xe5\xd0" + "\x3d\xeb\x65\x21\x2b\x7c\xbd\x80" + "\xc0\xf1\xc0\xdc\xe7\x16\x1e\xdf" + + "\x32\xc8\x07\x0c\xad\x8f\xe5\x97" + "\x9b\x43\xc3\x41\xa4\x50\xee\x73" + "\x20\x0e\x1f\x8e\xa4\x43\x06\x23" + "\xa3\xc6\xeb\xce\x8b\x7f\x3c\x53" + "\xb5\xe1\x63\x71\xb3\x47\xa6\x4d" + "\xfa\x26\x0b\x41\x4c\x0d\x65\x1a" + "\xfb\xfd\xe8\xdd\x64\x3a\xa5\x0d" + "\x73\x0c\xd8\x88\xdf\x86\xe7\x0c" + + "\xca\x0a\x8f\x23\x27\x92\xcf\x19" + "\xfd\x4c\xac\xab\xd4\xad\x86\x63" + "\x7f\xde\x5c\x5e\xa0\xc4\xb6\x17" + "\x07\x56\xaa\xc9\x58\x57\x2b\x17" + "\x8c\xe7\x01\x5f\xc5\x65\xa2\x0f" + "\x1e\x4d\x12\xdc\xfb\xfd\xb2\x1f" + "\xf8\x23\xf2\x9b\x3c\x8d\x23\xcf" + "\x6b\xbb\x94\x03\x8d\x2c\x5c\x3c" + + "\x16\x06\x77\xc1\x56\x6f\x62\x6c" + "\x2d\x9a\xda\x09\x9e\x90\x51\x53" + "\x45\x0e\x73\xa3\x25\x68\x8e\xe5" + "\x79\x0a\xef\x03\xc0\x8b\x8c\x9d" + "\xfd\xec\x6b\x05\xb6\x78\x3f\x54" + "\x6d\xb3\x90\xa0\x53\x32\xf1\x33" + "\xf9\x32\x44\x79\x97\x49\xad\x82" + "\x02\xf5\x21\x47\x3c\x49\x86\x13" + + "\x14\xd7\x9e\xd4\xf1\x13\xc4\xdc" + "\xd8\xb4\xc2\x6a\x27\xd6\xd3\x18" + "\xf8\xbc\x47\x53\x45\x7a\x15\x0f" + "\x44\xc9\x94\x26\x12\xf4\x13\x4a" + "\xdd\x00\x77\x39\x7c\xbf\xab\xe3" + "\x39\xef\x4e\x6c\x91\x8a\xa8\x72" + "\x9c\x47\x06\x46\xdb\xf8\x49\xb1" + "\xb3\xd3\xc2\x54\xab\xb1\x44\xff" + + "\x09\x3d\x83\x4b\x36\xac\x75\x88" + "\x9b\x5c\xed\xf0\x12\x77\xc9\xca" + "\x0d\x52\x81\x02\x8f\x5d\xf5\x7a" + "\x37\x62\x93\x46\x3b\x47\xf7\x06" + "\xd6\x84\x6f\xfe\x51\xca\x5b\x8a" + "\xa7\x4f\x27\x84\x4b\x6f\x4b\x76" + "\x1d\xc0\x64\xb9\xdc\x91\x30\xfa" + "\x46\xb8\x3a\x0a\xf6\x26\x1f\x6d" + + "\xf0\xcf\xc0\x8a\x5f\xf5\x0b\x0d" + "\x54\xeb\x50\xc1\x82\x88\x59\xd9" + "\xd0\x93\xc2\x51\x2c\xa7\xa4\x22" + "\x8a\x19\x3c\x64\xf6\x57\x6c\xf8" + "\x10\x57\x39\x20\xb0\x91\xab\x97" + "\xc0\xdb\x70\x19\x6c\x71\xe1\x9a" + "\xf8\x3d\xe5\xcc\xa2\x2b\x7a\x5b" + "\x4c\xd6\x85\xfc\x99\x9a\x79\xb2" + + "\x2a\xa8\xbe\x5a\xfa\xee\x94\x37" + "\xd4\x62\xfe\x93\xb9\x11\xc6\x8d" + "\x06\xf6\x1e\x28\x37\xaf\xf1\x69" + "\x69\x9e\x83\x39\xc8\x46\xf5\x6a" + "\x23\xec\x77\xc9\xc7\x78\x55\x62" + "\x76\x05\x5c\xbd\x4c\x29\xde\xa8" + "\xc0\xa4\xd1\x7c\x0f\xaf\xdd\xe2" + "\xd4\xf4\x95\x4f\x70\xfc\x43\x82" + + "\x12\x18\xe7\x50\xda\xab\xc5\x94" + "\x7c\x6a\xbb\x03\x35\x74\x94\x02" + "\x14\xbf\x8f\x79\xab\x53\xa1\x02" + "\x4e\x28\x2f\x7a\xc8\x26\xef\xf8" + "\xdc\x9e\xf9\x05\x5d\x92\x3c\x86" + "\xdd\x35\x9b\x40\xe6\x81\x6d\x97" + "\x70\x91\xe9\xdc\x99\x5a\x3a\xef" + "\xe6\x1d\x13\x53\xec\x80\xbc\xaa" + + "\x35\xb3\x40\xc9\x64\x7c\x41\x19" + "\xe9\x97\x6e\xaf\xf5\x4e\x45\x51" + "\x9c\x30\x16\xed\xac\x9b\x3c\x76" + "\x04\x48\x46\x81\x4d\x17\x6d\xe2" + "\x97\x74\x19\x35\x86\x42\x5a\xa0" + "\x09\xb1\xed\xad\x71\xfa\x10\xa4" + "\x6e\xf7\x95\xda\xb7\xca\x19\x72" + "\x1f\xd1\x88\xbe\xe7\x23\xc3\x74" + + "\x3c\x10\xdb\xb2\xd6\x91\xbb\xe1" + "\xe3\xc2\xe2\x92\xb1\x3d\x59\xbe" + "\xc1\x25\x5e\xb4\xca\x49\xf9\x53" + "\x23\x2f\x6e\x0a\x16\xe6\x39\x6a" + "\x0a\xd7\x57\x13\x6e\xe2\x13\x02" + "\x9c\x3e\x62\x8e\x1a\x1c\x74\x73" + "\xb2\x99\x93\x8d\xba\xa9\xdf\x54" + "\x32\x8c\x59\x0c\x40\x0c\x31\x86" + + "\x3a\x73\x08\xb0\x00\xf4\x66\xe5" + "\x57\x1f\x2e\x51\x7d\x69\xa0\xcb" + "\xd0\x9c\x50\x40\xb2\xc2\x37\x95" + "\x8c\x3d\x35\x57\x69\x9c\x98\x5f" + "\x2f\x2b\x3c\x4c\x72\xc9\xbe\x7d" + "\xa8\x1f\x03\xff\xa8\x2f\xe0\x90" + "\x1f\xd1\xd5\xcf\x53\x5c\xd1\xf4" + "\xfc\x4d\x31\x48\xae\x4f\x40\xb3" + + "\xef\x5f\xca\xb4\xa3\xbb\xf0\xb6" + "\x08\x90\xd1\x0f\xe2\xfc\x19\x49" + "\xdc\x2a\xd1\x1b\x8d\xd1\xb4\x18" + "\x9c\x8e\x1c\xc8\x88\x3a\x2f\xb2" + "\x49\x29\x7c\xcc\x2c\xb1\xf5\x86" + "\x7f\x98\xde\x05\xd8\x1a\xf6\xa2" + "\x70\x79\x72\xed\x72\x21\x74\x69" + "\xc7\x4e\x43\xd7\x8e\x2c\x9f\x3e" + + "\xb4\x52\x2c\x21\xf8\x0e\x49\xd1" + "\x7b\x5a\xb7\x00\xea\xfd\x2f\x5b" + "\xa1\x8b\x95\xbf\x3e\xb2\xc7\xf2" + "\xaa\xba\x6c\x69\x39\x20\xb4\x43" + "\x96\x34\xbe\x02\x94\xde\x5b\x1f" + "\xc4\xa5\xef\x39\x6b\x9d\xbe\x3a" + "\x82\x7e\x07\x47\xde\x7f\x20\x2a" + "\x28\x29\x86\x65\xfc\x74\xc3\x3b" + + "\xc4\x04\x06\x54\x1d\x0e\xd4\x35" + "\xed\x6f\x48\x3a\x3a\xb3\xa4\x16" + "\xa1\xa4\x43\xee\x6c\x49\x70\x91" + "\xaf\x8a\x94\xad\xe1\xdb\x4a\x17" + "\x99\xdf\x51\x54\x0a\xa3\x47\x8a" + "\xa1\x91\x17\x9e\xd1\xbd\xca\x7c" + "\x2a\xf1\xfc\xec\x3a\xb5\x12\x71" + "\xd2\xc6\xb5\xfa\x95\xb3\x1e\x56" + + "\x87\x93\x1e\x08\x09\xa1\x6d\xa3" + "\x28\x58\x93\x8c\xd7\x80\x97\xfb" + "\x15\xb0\x40\xe5\x32\x03\x94\xd5" + "\xfa\x66\xf4\xe0\x1b\xb5\xd7\xc9" + "\x71\xf6\xd9\xd6\x41\xcd\xad\xfa" + "\x17\xac\xa2\xb1\x28\x1e\x6c\xba" + "\x5f\x1e\x20\xed\x33\x78\x6a\x06" + "\x2b\x46\x0f\xf9\x19\x97\xd9\x19" + + + "\x61\x5f\x0b\x06\x62\xf4\x31\xf4" + "\xc2\x57\xd0\x7b\xb4\x46\x6f\xa5" + "\x65\xbf\xe1\x47\x6c\xca\x8d\x34" + "\xff\xf1\xbc\x41\x3e\x78\x38\x9a" + "\x18\x07\x71\xda\xa9\x33\x5d\x7a" + "\xf6\xea\x0a\x2e\x87\x99\x77\x5a" + "\x87\xd1\x29\x2d\x4d\x31\x87\xca" + "\x33\xd7\x87\xc6\x3e\xdc\x0e\xfa" + + "\xc7\x8a\x19\xcb\x49\x48\x89\x1c" + "\x65\x46\x26\x0f\x3d\xa9\x84\xa8" + "\x78\x06\x20\x9b\xef\x64\xa9\x2d" + "\xe6\x34\x98\x00\x87\x1b\x35\x3c" + "\x4b\xb4\xc4\xe2\x9f\xef\xb2\xaf" + "\x0c\x79\x26\x33\x47\x6c\x0f\x58" + "\x4a\x26\x02\x0b\x21\x05\x48\xb8" + "\xe2\x94\xa1\x42\xe2\xf9\xa6\x8b" + + "\x0e\x3c\xb0\x5e\xb6\x6a\x9b\x49" + "\xde\x3f\xbc\x72\x54\x79\x9b\xf1" + "\xd2\x80\x3a\x6e\x9c\x5b\x6b\xa8" + "\x9f\x81\x42\x6d\x08\x75\x37\xe4" + "\xa3\xe8\x3e\xbb\x50\x36\x66\xc1" + "\x5f\x07\x32\xb1\xfc\x14\xeb\x75" + "\xf6\x34\xd8\x7a\x06\xc9\xcc\xa8" + "\xfd\x2f\xe9\xe6\x74\x24\x6a\xea" + + "\xf1\x95\xc0\xd3\xab\x34\xd9\x39" + "\x71\x6d\xb7\xe4\xbe\x61\xb2\x04" + "\x84\x69\x3e\xe7\x70\x69\x2e\x1d" + "\x11\xcb\x5f\x5e\x3b\xb2\x9f\x87" + "\x90\x54\xd7\xdf\x72\x6c\x50\x11" + "\xc1\xf1\xbc\x61\x85\xd0\x97\x3a" + "\x07\x70\x5e\xbf\x82\x1d\x20\x43" + "\xa7\x32\x82\x79\x2f\xc5\x0a\x7f" + + "\x36\x91\x04\x4b\xee\x20\x4d\xcb" + "\x13\x46\x6a\x35\x12\xbf\x63\x8b" + "\x28\x81\xe0\x70\xf6\xae\x21\x12" + "\x16\x6b\xcb\x4a\x51\x8c\x2d\xe6" + "\x96\x78\x9e\x37\x67\x4a\xf6\x71" + "\xa5\x7f\xfd\xca\xa2\x37\x52\xb2" + "\x6a\xba\x41\x38\x98\xbd\x77\xf0" + "\x7e\x6e\xd1\x3c\x44\x02\xac\xc4" + + "\x82\x76\x9d\x31\xfb\x01\x51\xb2" + "\xee\x2f\x98\x0a\x29\x31\x29\xb0" + "\x44\xb3\x61\x02\xb9\xc9\xc1\x51" + "\xfa\x71\xd3\xbf\x5b\x8c\x00\x0e" + "\x33\xca\x78\x02\x1c\xdd\x66\xd8" + "\xb1\x53\xaa\xe5\xa6\x76\x6f\x66" + "\xcf\xa2\x13\x60\x79\xb7\xcf\xe5" + "\x36\x18\x52\xa3\xad\x1a\x3a\x1d" + + "\x9c\x5f\xf7\x50\xff\x04\x56\x3c" + "\x22\x2b\x75\x7e\xf3\xdd\x8e\x1d" + "\x18\x11\x9a\x3c\xdd\x74\xf0\x0e" + "\x7b\x6d\xb8\xcc\x72\xc1\xff\xd0" + "\xf2\x90\x7d\x03\xe3\xec\xd1\xab" + "\x6c\x85\x55\x60\xd6\x07\xf3\xe3" + "\xaf\x6d\x4c\x7e\x28\x93\x2f\x42" + "\xa0\x79\x48\x33\x66\xac\x2a\x90" + + "\xec\x93\x71\x56\x1a\x13\xb4\x76" + "\x0b\xe7\xf6\xe5\x5a\x30\x3c\xaf" + "\xdd\xeb\x1e\x03\x39\xbd\x87\x95" + "\x31\xe8\xbb\x71\xf8\xde\x09\x57" + "\x69\xb6\xb2\x0e\x83\x99\x05\x57" + "\x29\x70\x5b\x87\x1b\xce\x80\x4d" + "\x16\xac\x64\x03\xa8\x7d\x8a\x83" + "\xab\x83\x1c\xbe\x23\x1d\x43\x2f" + + "\x1e\xc7\x40\xb9\x4c\x87\x52\x8e" + "\x3a\x4b\x5f\xdb\xa9\x35\x19\x21" + "\xc3\x1d\x1b\x30\x92\x04\x35\x94" + "\x20\x86\x95\x29\x6d\x64\xd2\x33" + "\x04\x14\x91\xef\x4b\xd6\xb0\x16" + "\xf4\x5e\x3c\x9a\xea\x25\x1f\x9d" + "\x78\x2c\x35\x4a\xeb\x00\xf2\x20" + "\x28\xb4\xd0\x4b\x2c\x9f\x92\x43" + + "\x4e\x5d\x23\x38\x66\x27\x81\xe7" + "\x98\x32\x6e\x49\x67\xbd\x62\x1c" + "\xc8\x5b\x17\x3f\x0c\x66\x78\x83" + "\x4d\xdd\xaf\x17\x89\xe1\x04\x4d" + "\x8c\x06\xa8\x85\x01\x16\xa8\x32" + "\x85\x9a\xb2\x92\xe1\xe4\x58\xdb" + "\x3b\x8a\x0d\xc7\x86\x5b\xa6\xe8" + "\x3b\x40\xa0\x98\x4e\x6f\x0e\x5f" + + "\x9e\x9f\x2c\xe8\xe6\x36\x46\xd4" + "\x43\x10\x3a\xc3\x7c\xb8\x1d\x71" + "\x05\xec\x8a\xaa\x63\x12\x43\x6f" + "\xaa\xa4\x44\x27\x0d\x12\xff\x43" + "\x9b\x77\x77\xae\x2f\x89\xbd\xd3" + "\x82\x9f\xdc\x8c\xc9\x0c\xfe\xf0" + "\xbc\xb1\xc5\xf1\xe6\x7f\x5f\xca" + "\x72\x9a\x92\x44\x82\xa6\x63\xcc" + + "\xe0\x4a\x89\x3f\xb7\x92\x24\x2c" + "\xce\x18\x5f\xb7\xe5\xf3\x9d\xf5" + "\xd0\xca\x53\x8f\xd2\x40\xb7\x7c" + "\x94\x12\xf0\xc4\xfb\x85\xb5\x3e" + "\x17\xf7\xc7\x32\x86\x0c\xda\x17" + "\x4c\x3f\x94\xaf\x5b\x79\x8c\xeb" + "\xd2\x51\x7c\xf6\xb5\x3f\xe2\x4e" + "\x49\x99\x88\x68\x75\x75\x18\xef" + + "\x6f\xff\x8d\xb3\x3e\xda\x34\x28" + "\xe8\x6b\x63\xea\x52\x2c\x01\xbe" + "\xf8\x37\xdd\x61\x8c\x23\x2d\x29" + "\xdb\x42\x81\x8f\x3f\x52\x54\x0e" + "\xd8\x05\x6a\x03\x36\xb4\x1e\xe3" + "\xff\xc0\x93\x1e\xff\xcd\xe3\x83" + "\xdf\x1d\x82\x50\x0f\xfe\xd2\x3f" + "\x3b\xb3\x9e\xff\x0d\x9b\xe1\xc8" + + "\xd0\xf0\x22\xe8\xa4\x11\xa0\x3e" + "\xf8\x04\x87\x5a\xd1\x7a\x64\xbc" + "\x0f\x82\xc6\x50\x35\x5b\x31\xbb" + "\xec\x6b\xe7\xb7\x3d\xec\x3d\x86" + "\xc7\xbf\x17\xf0\x3a\x5d\xff\x01" + "\x29\x82\x6b\x97\x39\x44\x05\x20" + "\x3b\x0d\xbd\x0b\x37\xca\x7f\x06" + "\x0f\x3d\x5e\x7f\x64\xde\x3d\xf6" + + "\x95\xa8\x9c\x5e\x52\x90\x7d\x14" + "\xdf\x72\x20\x97\x1e\xd3\x4d\x2f" + "\x5c\x75\xc6\xe6\x8e\xda\x6f\xa1" + "\x58\x65\x19\xcf\xff\x26\x68\xc6" + "\x95\x38\xf4\x0c\xa3\x76\x1a\x1f" + "\x7b\x09\xc3\x83\xe0\x04\xd6\xa9" + "\x0e\x0e\x39\x66\x09\x83\x90\xe1" + "\xff\x5e\xc8\xb3\x53\xf7\x0b\xa5" + + "\xcf\xcc\xf7\xad\x15\xbc\xd9\x75" + "\xb0\xe1\xa1\xdf\xd6\xe5\xa3\x81" + "\x7e\xc1\x9b\x24\x44\xe4\x39\x8c" + "\x43\xfd\xa7\x8e\xb2\xcc\x7d\xf3" + "\x12\xba\x7f\x90\x73\x48\x65\xda" + "\x04\x29\x37\x4a\xda\xa6\xda\x35" + "\xc5\xa6\x83\x62\xc6\xcf\x64\x05" + "\xbf\x95\x93\x4a\xf6\xa4\x9f\xd0" + + "\x31\x84\x56\x6f\xa7\xf9\x64\x0d" + "\x8c\x89\xf8\x02\x7c\xc2\x48\xf8" + "\xd5\x5b\x0b\x26\xe1\xad\x18\xf4" + "\xe8\xde\x73\x69\x23\xe3\xf3\xc1" + "\xdd\x85\xc1\x26\x9c\x31\xe9\x46" + "\xc4\x0a\x6f\x54\xd8\xb7\x85\x6d" + "\x57\x9d\x7f\x24\xf2\x65\x79\x42" + "\x48\x5f\x03\xb0\x36\xb6\x19\xb5" + + "\xff\x9d\xa3\x6a\xb5\xb3\x10\xb5" + "\x8c\x4d\x8e\x9f\xa2\x3d\xb4\x59" + "\x9f\x4b\x4c\x9e\xfd\x31\xce\xa8" + "\x01\x3c\x30\xc1\x26\xbe\x20\x0e" + "\xc9\x47\xee\xe8\x82\x71\x18\x18" + "\x01\x81\xb9\x7d\xdb\x7c\x68\xd9" + "\xf6\x4f\xe1\xa1\x4d\x0e\x52\x7a" + "\x72\xd5\x36\x88\xba\x08\x98\x42" + + "\xc6\xe5\xa9\xdd\xe5\xc1\x2a\x68" + "\x95\xfc\xa9\xca\x72\x3c\x0d\x4e" + "\x44\xea\x2b\x77\xde\xaa\xfa\x17" + "\xc8\x09\x00\xab\x8c\x42\xf8\x5e" + "\x16\xf0\x0f\x46\x7a\xe4\x4c\xcc" + "\xcb\x81\x52\x72\xbf\x12\x6d\xda" + "\xd2\xaa\x23\x02\x48\x78\xc6\x44" + "\x28\x6e\x25\x36\xfa\x2a\x34\x6e" + + "\x8e\x76\x16\x6d\x99\x46\x4d\x17" + "\x17\xf2\x8b\x62\x6a\xff\xc4\x9f" + "\x0d\x49\x4e\x15\x94\x5a\x70\x77" + "\x7a\x99\x2d\x8d\x28\xdd\x96\x9d" + "\xc4\x72\x5d\xce\xd8\xd9\xe2\x77" + "\x4f\x71\x1c\xc1\xa4\xc5\x06\x9d" + "\x3e\xa0\xe4\x79\x36\x51\xaa\x02" + "\x8b\xf2\x0f\x03\xc2\xb3\x86\x13" + + "\xc2\xc9\xce\x8b\xb6\x86\x61\xb8" + "\x06\x9f\x0b\x68\xf9\x4d\xf2\x7c" + "\x81\x92\xd2\xc0\xea\x45\x6b\xc4" + "\x12\x0e\xb1\x07\xc5\x2b\xf4\xff" + "\x27\x94\x28\x4d\x40\x3c\x26\x12" + "\xc4\x8e\x84\xb4\x99\x18\x5f\x3d" + "\x0c\x80\x40\xd0\x10\x70\xf9\x11" + "\x20\xeb\x0f\x30\x29\xf5\xc5\xb4" + + "\x3a\xdc\x40\xea\x69\x2d\xa4\x26" + "\x8f\x01\xcc\xae\x22\xad\x84\xdc" + "\x4a\xf0\x70\x32\x7b\x6c\xc3\x25" + "\xed\x72\xfa\x50\x47\x6d\xba\x46" + "\x8e\x8a\xe5\x93\xc5\xd1\x37\x6c" + "\x8c\x08\x0c\x12\x31\x47\x39\xa2" + "\xda\x86\x6e\xcb\x63\x42\xbe\xc3" + "\x38\xd0\x26\x71\x36\x7d\x41\x2c" + + "\xd0\x59\x71\xb0\x6d\x11\x3d\x9d" + "\x10\x62\x89\xc1\x7f\xa6\x07\xae" + "\x79\x15\x96\xbb\x87\x4d\xc8\x8f" + "\xd6\x8d\x1f\x1c\x49\x9e\x00\x30" + "\x19\x28\x13\xe3\x22\xaf\x8c\x8a" + "\xff\xb4\x3a\xf2\x7c\x19\xfa\xcf" + "\x87\xd6\x5d\x20\x44\x3a\x10\x58" + "\xa2\x67\xed\x0d\xc3\x96\xb7\x57" + + "\x29\x22\x0e\x44\xbb\x23\xa5\xcc" + "\x04\x4d\xef\x73\xa2\x73\x46\x32" + "\x39\xec\x11\x3e\x34\xdf\x3a\xaf" + "\xd3\x68\x59\xdc\xf1\xd7\x36\x61" + "\x27\xa9\x53\xb0\x99\x28\x7b\x7a" + "\xcd\x7e\x06\xae\x61\x26\xaa\x3e" + "\xd9\x9c\x77\x02\xc8\xb9\x49\x85" + "\xea\x85\x33\xc5\x40\x79\x1d\x06" + + "\xe7\x3c\xe9\xb3\x89\x7a\xd2\xd7" + "\x1b\x2c\x3a\x5d\x75\xa8\xb5\xf7" + "\x8a\x21\x5b\x25\xa0\x68\x9e\xb2" + "\x54\x67\xf7\x8a\x7e\x83\x33\xb5" + "\x2e\xab\x9f\x57\x73\x5a\xb0\xd1" + "\x85\x43\xd7\xec\xa1\x55\x10\xb4" + "\x15\x91\x5e\x44\x74\x92\x36\xb2" + "\x4e\x27\x20\xf5\xc4\xa7\x72\x29" + + "\x2b\x90\xa2\xaa\xfc\x41\x71\xe0" + "\xd3\x9a\xf6\xe4\x99\xd7\x9a\x53" + "\xfd\x9f\x3f\x81\x94\x3f\x45\xa6" + "\xf7\xc2\x5b\x37\x48\x3c\x8d\xc5" + "\x96\x4e\xc6\x5d\xad\x6f\x32\xb3" + "\x54\xe3\x40\xb2\xa9\xca\xaf\x3a" + "\xa9\xe7\xa1\xac\x03\x09\x1b\x1d" + "\xa0\xb8\x11\x12\x67\x97\xeb\x4c" + + "\xa0\x10\x17\xc8\x79\x2e\x94\x5e" + "\xd4\xad\xcc\x27\x36\x4a\x7e\x55" + "\x0c\x6d\xcf\x4b\x56\xbc\xa2\x72" + "\x0c\xb8\xd7\x26\x43\x5f\xee\x09" + "\x19\x2f\x29\xd4\xe9\xdb\x70\x6b" + "\x18\x6b\xf1\x63\x26\x4c\xf7\x56" + "\x2a\xb4\xfb\x35\xf7\xb0\x3d\xc2" + "\x40\x00\xe1\x6a\xf6\xbd\x06\xb6" + + "\x58\x2d\x03\x87\x46\xde\xb4\x1e" + "\xe0\x79\x2c\x5e\x83\x3d\x4f\xc5" + "\x23\xef\x04\x5d\xf4\x8d\x81\x07" + "\xb4\x41\x3d\x67\xc8\xa9\xfa\x55" + "\x55\x53\xb9\x89\x6f\x4f\xd6\xce" + "\x84\x5c\x41\xb7\xea\xd2\x60\x48" + "\xd3\xba\x0e\x05\xd2\x9b\xdb\x5f" + "\xbf\xa5\x85\x66\xcc\xe0\x53\xdb" + + "\xb3\xa7\x1e\x8b\xa0\xd2\x61\x9a" + "\x85\x14\x8b\xae\x63\xab\x95\xd4" + "\x99\x2f\x05\x87\x84\x0f\x74\x38" + "\xea\x4e\x97\xb2\x5b\xbe\x8e\x17" + "\x7f\xd1\x36\x5b\xca\xbc\x0b\x03" + "\xea\x6e\xf8\xaa\xe3\xcc\xe4\xb5" + "\xe0\xe9\xf8\x68\x20\x02\x1a\xb5" + "\x75\x3e\xeb\x09\x96\x87\x34\xa4" + + "\xca\xe1\xfa\xab\x5f\xca\x9f\x91" + "\x9b\x45\x21\x1a\xac\xfa\x7a\x93" + "\xd2\xa4\x66\x1f\x1c\xa9\x0c\x9e" + "\x31\x13\xec\x23\xf3\xc7\x4c\x19" + "\x90\x16\xa1\x8a\x3a\x14\x25\xad" + "\x08\x9e\xb5\x09\x8d\xad\x40\xbe" + "\x0a\x86\x50\xe7\x9b\x0d\xd6\x37" + "\x4c\x43\xbf\xc6\x08\xb0\x53\x6c" + + "\x17\xc5\x3e\x1d\xd0\xa0\x61\xa6" + "\xae\x21\x23\x51\x52\x46\x74\x98" + "\x98\x25\xa9\xec\x91\xa5\x4c\x08" + "\xeb\x3f\xcb\x1d\xc9\x9d\xbb\xa9" + "\x40\xc2\xb4\x78\x55\x43\xc5\x14" + "\xdc\xaf\x0c\x61\x3b\x2a\xd6\x5e" + "\x6b\x84\x38\x1b\x37\x2f\x51\x07" + "\x61\x81\xe3\xb0\x0a\xb7\x1b\x57" + + "\x2d\x24\x6b\xeb\x80\x70\x2d\x83" + "\x46\xe2\x71\x3b\x23\xd0\x0b\xd3" + "\x9d\x13\x31\xbe\x1b\x99\x27\x70" + "\x53\x4e\x2e\x46\x91\x7e\x79\x68" + "\x5a\x18\x4e\x6b\x0a\xe2\x3f\x42" + "\x07\xb7\xd9\x42\x7e\xc6\xf2\x82" + "\x1b\x81\xf7\x4c\x68\x17\xc8\x25" + "\x5d\xb9\x5b\x04\x5e\x00\x53\xbd" + + + "\xfd\x68\x8e\x9d\xbe\x49\xf6\xe5" + "\x20\x43\x04\x1b\x33\x05\x0f\xdb" + "\x98\x33\xc3\xe0\xb3\xe9\xfd\xf6" + "\xae\xcf\xc8\x66\x9b\x20\xf4\x92" + "\x4b\x9d\x73\x1a\xcc\xaf\xd1\xe9" + "\xde\xb8\x8a\xa2\x5f\xa7\xae\x09" + "\xd0\xf1\xc6\xea\xb5\x5f\x37\x14" + "\xa5\x7a\x8f\x70\x60\xb5\x20\x64" + + "\x41\xdc\x54\x62\x9c\x49\xae\x9e" + "\x7e\x7e\x83\x7a\x24\x39\x29\x7e" + "\xa7\x24\x05\x09\x8c\xc0\xae\x74" + "\xf2\x55\x6f\x8d\x19\x92\x2b\xf8" + "\xc5\xce\x02\x14\x2e\x96\x3c\x49" + "\xe7\x30\x2f\xfa\x17\xca\x17\x9f" + "\xcb\x79\xb8\xe9\xe8\x83\xd7\xbc" + "\x5f\x14\x6f\x5a\x14\x8c\x3d\xea" + + "\x6e\xee\x0d\x5e\xe7\x15\xde\xde" + "\xa2\x8a\x62\xdc\x72\x48\xf2\x74" + "\x93\xbb\x61\x78\xfe\xc4\xe9\xd3" + "\xe0\xb2\x87\x61\x2a\x82\xd4\x56" + "\xf9\x26\x98\xc5\xcf\x17\x64\xb6" + "\x9e\x16\x08\x24\x69\x09\x26\xca" + "\x85\xf8\x9e\xc7\x06\x9d\xf6\xed" + "\x8f\x13\x7d\xdc\x8a\x1f\x03\x00" + + "\x26\xf7\xbc\x0e\xe6\x46\x3c\x10" + "\x0e\x47\x31\x62\x31\xb8\x82\x44" + "\x09\x21\x7c\x48\xca\xfa\x6d\x6f" + "\xef\x66\xe6\x62\x97\xce\x0a\x2e" + "\x42\x1f\x8d\x1f\xd3\xa9\x46\x32" + "\xd2\x44\x49\x57\xf1\x83\x1e\x1b" + "\x4b\x33\x7f\xa5\x3a\xa6\xdf\x13" + "\x81\x5d\x02\x9f\xed\xda\xf8\x0c" + + "\xc1\x11\xee\x00\xa8\x8e\xd7\x30" + "\x75\xdd\xe3\xb5\xd4\x3c\x05\xeb" + "\xc5\x43\x8c\xd5\x3e\xb1\x65\x9b" + "\x63\x16\x15\xbd\xbd\x49\xad\xc3" + "\x90\x79\x42\xb6\x41\x8e\xfd\x99" + "\x1e\xae\x7e\x70\xbd\x15\xcf\x12" + "\x1e\xb7\xab\x1a\x1b\x4f\xad\x29" + "\x0e\x5d\x54\x07\x4d\xe7\x43\x51" + + "\xe1\xde\x8b\xc8\x36\x63\x26\x30" + "\x7c\x76\x76\x58\x06\x93\xf2\x25" + "\x96\x19\x73\xc6\x71\x85\x07\x9c" + "\x51\x29\x55\xed\xb2\x90\x86\xc8" + "\xb4\x05\x27\x85\x2d\x2c\x4f\x27" + "\x2d\x55\x09\x4e\x44\x8d\xbf\xb0" + "\xd1\x75\x65\x98\xeb\xbe\x28\x76" + "\x51\x46\x86\x7f\x38\xe2\x7b\x40" + + "\x6b\xfc\x39\xa6\x49\x30\x5e\x0e" + "\x25\x36\x00\x86\xd9\x35\x5c\xe7" + "\x46\x16\xcc\x5d\xd8\x5b\xf3\x0c" + "\x3a\x27\x26\x6c\xd2\xce\xca\x8b" + "\x42\x67\x53\xb5\x1d\xcf\x2e\xe2" + "\x8b\x06\x9e\x1a\x97\xd8\x3d\x01" + "\xc5\x09\x79\x8a\xcb\x11\xf4\x17" + "\x06\xd5\x1d\x86\x98\xac\x57\x57" + + "\xbb\x5a\x93\x1e\x0d\x1f\xde\x85" + "\x7a\xe3\x4d\x15\xb4\x10\xfd\xde" + "\xb5\xeb\x9c\x36\x92\xe3\xd9\xb8" + "\xbe\x24\x13\x76\x9b\xef\xd5\x54" + "\x26\x7e\xf1\x74\xba\x41\x63\x4d" + "\xe4\xdd\xc1\x78\xc8\xe3\xa0\xc0" + "\xfd\x18\xd9\x87\x81\x75\xd7\xa6" + "\x13\x3a\xca\x02\x15\x60\x87\x66" + + "\xf0\x58\x66\xf3\x9c\x3e\x31\xc7" + "\x7e\x05\xf8\x71\x1c\xef\x33\xc4" + "\x5a\x83\x6a\x1b\x46\x62\x32\x85" + "\x4c\x39\x86\x7c\x98\x53\xf0\xc8" + "\xa1\xc4\x83\xe9\xdf\x8c\x39\xff" + "\x31\xb9\xb7\x03\x62\x81\x5e\xbf" + "\x5b\x04\xb9\xb7\x46\x3c\x19\x93" + "\x6b\xe4\xa6\xa4\x5d\xbf\x4e\x1e" + + "\xe7\x4f\xa2\x43\x60\x2a\x94\xf9" + "\x2b\x49\xb3\xff\x1e\x19\xc1\x29" + "\x05\xde\x2f\x90\x49\x24\x66\x9f" + "\x2d\xc3\x13\x67\xac\xa7\x92\xc7" + "\x2c\x98\x37\xb7\xd8\x8a\xd8\x2f" + "\xe3\x60\x1e\xa2\x19\x03\x3a\x7e" + "\x1a\x59\x83\x73\x44\xde\xb0\x09" + "\x56\xa4\x10\x83\xee\x41\xf1\x6d" + + "\x71\xf4\xd6\xe6\x39\xa0\xc1\xae" + "\x2e\xd1\x98\x11\x0f\xba\xb2\x14" + "\xac\xe5\xee\x3a\x60\xa1\xc1\xeb" + "\xce\x64\xb9\xe0\x36\x48\x1f\x40" + "\x66\x3f\xd0\x4f\x96\x37\xe4\x2e" + "\x12\x3f\x8f\xdd\x49\x4e\xdb\x3f" + "\x18\x0f\x38\x29\xf6\x67\xf2\x6e" + "\x16\x4d\xa6\x8d\x70\x96\x8e\x3e" + + "\xf1\x74\x76\x20\x0c\x18\x19\xbc" + "\xdb\x8f\xae\x33\xa7\x09\x2e\x11" + "\x1e\xb7\xae\x6a\x54\x75\x66\x99" + "\xc7\xb1\x01\xe1\xf1\x2a\x43\x79" + "\xc6\xde\x2d\xde\x8f\x55\xeb\xd5" + "\x3f\x75\x57\x53\x1f\x2d\x39\x81" + "\x8a\x15\xe1\x3a\x97\x6b\xa7\xa7" + "\x91\x99\x89\x4a\xff\xbb\x6f\x41" + + "\xcf\x9d\x4a\x0d\xfd\xfd\x65\x9e" + "\x12\xdf\x4d\x94\x48\x9e\xc2\x7b" + "\x66\x68\x85\x3c\xd9\x92\x1a\xbc" + "\xe2\xdf\x98\x6e\x05\x69\x3c\x27" + "\xb8\xa6\xfa\xcd\x18\xe4\xfc\x69" + "\x9f\xc6\x61\x50\x23\xd8\x6b\x60" + "\x27\x5e\xf7\x6a\xa0\x95\xd4\x42" + "\x1f\x3a\x87\x6d\x05\xd5\xd3\x8e" + + "\x6a\x5b\xb2\x6a\x41\x28\x55\xaf" + "\x23\x45\x1a\x2b\xc7\xff\xc0\xc6" + "\x03\x9e\xc9\x21\x7b\x82\x18\xab" + "\x1b\x69\x34\x90\x48\x86\x0e\x06" + "\x98\xf3\xc7\x93\x0f\xf9\x07\x52" + "\x0b\xd1\xf8\x82\xcb\x96\x4a\x9f" + "\xe3\xf9\xd0\x3a\x79\xcd\x71\xdd" + "\xf5\x54\x3a\xfc\xd2\x35\xf4\x84" + + "\x7f\x78\x33\x8e\x5b\xc5\x03\x4b" + "\x73\x46\x38\xa6\x75\xf9\x42\xef" + "\xf0\xb9\x51\x50\xf7\x04\x73\xff" + "\xc2\x87\x1c\x74\xdc\xa1\xac\x18" + "\x80\xfe\x4b\x2d\xa7\x20\xf1\x56" + "\x2c\x73\x3e\x05\x3d\x3b\x82\xfd" + "\x16\xca\x37\x75\xe4\xcf\xbc\x11" + "\x6b\x99\x5a\x1b\x74\x9c\x6c\xdf" + + "\xfa\xc3\x4f\x90\xc7\x32\x73\xee" + "\x6a\x63\xe3\xc7\x45\x3f\xa2\x14" + "\xaa\xd9\x91\xf0\xc3\x59\x86\xc3" + "\x40\x85\x2d\xb1\x5d\x5e\x99\x4a" + "\x8a\x59\xa5\xf3\xec\x3b\xa5\x20" + "\x95\xa9\xea\xb1\x17\x4b\x53\x56" + "\x3c\xe0\x04\xbf\xa4\xdc\xd3\x9e" + "\x68\x62\xd5\xd8\x3a\x56\x6c\x71" + + "\xe7\x78\x61\x1d\xa4\x77\xba\x27" + "\x8e\xff\xa1\x68\x40\x0c\xc8\xe4" + "\x3d\xf6\x13\x0a\x99\x10\x01\x75" + "\xf3\x46\x1d\xa6\x21\x35\xf3\x7b" + "\xbb\x65\xb3\x10\x8e\x21\xff\x0a" + "\x75\xea\xd7\x0f\x04\x18\x02\x81" + "\x25\xa9\xb3\xa4\x8a\xfd\xa3\x05" + "\xe6\xb4\x3d\x9b\x5f\xe7\x29\xb8" + + "\xfb\xe5\x53\x4d\xa5\x75\xdc\x6b" + "\xe3\x17\x27\xd5\x02\xdc\xa5\x04" + "\xc2\x2e\xa4\xe9\x2f\x50\xaf\x86" + "\x82\xe3\x30\x26\xfb\xe8\x67\x88" + "\x9b\x88\xc9\xbe\x6e\x5c\x84\xbf" + "\x8d\xc9\x47\xcb\xf2\x91\xf4\x54" + "\x12\x2a\x0c\x79\xba\x1f\x09\xa3" + "\x8b\x70\x0f\xc2\x78\xfd\xf6\xd7" + + "\x17\x5e\xde\xac\x30\xac\x69\xa5" + "\xd7\xb4\x52\x68\xd0\x96\xf9\xd0" + "\x54\xae\x09\x46\xb5\x4b\x1d\xe5" + "\x61\xd0\xae\x0d\x17\x7d\xa3\x3f" + "\x41\xfb\xb8\x34\x84\x86\xa8\x62" + "\xf1\x64\xfb\x9e\xbd\xac\xa2\x99" + "\xf2\xe1\x48\x64\x5e\x1a\x5c\xb7" + "\x69\xa0\xb5\x42\x1a\x95\x99\xfa" + + "\xe7\x26\x3b\x2f\x89\x6e\x95\x6d" + "\x47\x52\x87\xda\x60\x98\x70\xf4" + "\xa3\xdd\x82\x24\x79\x51\xd1\x3a" + "\xf0\x82\x7d\x01\xe3\x10\x41\xd6" + "\xe4\x14\xd4\xfa\x2c\x8d\x92\x14" + "\x24\x2b\xd0\x2e\x58\x5f\x15\x2b" + "\xf1\x1b\x82\xcb\x1b\x14\x1a\x48" + "\xda\xf5\x81\x4f\x70\xc7\xe3\x12" + + "\x81\x83\xff\x9f\xe5\x5d\x9c\xe4" + "\x94\xc8\xbe\x5b\x32\x32\x05\x11" + "\xc4\x88\x4d\x45\xcc\x51\xd0\xa0" + "\x1b\x53\x8e\x1f\x9c\xb8\x6d\x4f" + "\x44\x3a\x56\xca\xd6\x3f\xfe\x34" + "\xb9\x8a\xda\x58\x15\x22\x5c\x7f" + "\xa1\xf0\x74\x94\x6d\x01\x45\x84" + "\x0a\x8a\x7d\xcb\x61\x4d\xd3\x17" + + "\x19\x40\x47\x1c\x10\x39\x9d\x8e" + "\xfb\xee\x2c\xd5\x29\x26\xff\xca" + "\x2b\x2c\x62\xc1\x32\x3e\xcf\xf9" + "\x05\x1a\x07\xe9\x3c\x5e\xb9\xd4" + "\x8c\x43\x94\x15\x1f\xa6\xbc\xfb" + "\xdf\xde\xaa\x04\xa6\xe6\xb6\x1e" + "\x40\x49\xe1\x68\xf4\x27\x30\x85" + "\x9c\xda\xab\xdf\x2a\x32\x1d\x22" + + "\x9a\x17\xcb\xb7\xf6\xa9\x8e\xed" + "\xcc\x4d\x93\xb7\x4d\x76\x7b\xdc" + "\x0d\x18\x09\x5e\x40\x39\xb1\xfc" + "\xdd\xc2\x7d\xb4\xbf\xa6\x29\x66" + "\x5e\x91\x5a\x9f\x4e\x5e\xc5\xbf" + "\x1e\x44\x04\x62\x37\x9d\xdb\xb1" + "\x53\x5f\x0c\x93\xcf\x68\x2d\xf8" + "\xb1\x05\xb6\xcb\x42\xa1\xd3\x17" + + "\xf2\x80\x87\x30\xea\x44\x59\xdd" + "\xe4\xf5\x45\x38\x61\xe7\x8d\xdc" + "\xa3\xd7\x24\x76\x7d\xba\xea\x6b" + "\x1e\xf1\x4d\x30\xfd\x9a\x70\x1e" + "\x56\x04\x17\x02\x76\x43\x36\x95" + "\x64\x4b\xf9\xc8\x3a\x4b\x20\xbf" + "\x68\xca\x80\x56\x7c\xaf\x53\x4e" + "\x74\x75\xc6\xe0\x4a\x07\x26\x05" + + "\xf6\x2a\xd9\xec\xf8\xce\xd8\x95" + "\x5a\x74\xd1\x6c\x7a\xfa\xb9\xe6" + "\xe4\xc3\x25\xa3\x3d\x6d\x54\x3d" + "\xae\x3a\xe9\x9a\x1d\x69\x57\x1f" + "\x33\x1a\x2e\x9d\xfe\xf3\x91\xe8" + "\x35\x3d\x06\xac\x3f\x09\x30\xd4" + "\x27\xa3\x13\x55\x12\x9b\xa5\xed" + "\x8f\xf1\x36\x55\xf3\x34\x21\xdc" + + "\x86\x02\x21\x5c\x2c\xfe\x51\xaa" + "\x8c\x65\xab\x1c\xee\xaa\x68\x3f" + "\x92\x72\x35\xf9\x0b\xa0\x23\x5a" + "\xed\xab\xfd\x7e\x39\x6f\x62\x9a" + "\xe3\x78\x9d\x19\xf3\x3b\x2b\xfe" + "\x45\xc3\xbb\x71\x77\xaf\xa2\xb7" + "\x2c\x80\x59\x1e\x7a\x82\x19\x3d" + "\x1c\xa5\x87\xb4\x15\xbc\x3b\x82" + + "\x22\xa4\xd0\x99\xf2\x39\x61\x85" + "\xfb\xc6\x56\xf4\x65\xdf\xc3\x9a" + "\xd6\x8b\x1f\x70\xc6\x65\xdf\xad" + "\x87\xdf\x58\x37\x1e\x32\x9f\x14" + "\xba\x7e\x1b\x72\x14\xf7\xec\xb1" + "\x2a\x31\xa3\x31\x98\xf0\x7d\xe1" + "\x81\xd5\xc4\xd5\xec\xd6\x2f\xdb" + "\xb3\xa1\xce\x8f\x6f\x99\x02\xfd" + + "\x4f\xf1\x82\x78\x3e\xa6\x9f\xe2" + "\xdc\xca\xc6\x07\x35\xdc\xf6\xc9" + "\xd0\xbe\x82\xb8\x6f\x2d\xf2\x46" + "\x2c\xe5\x18\xd1\x5b\x75\x45\x1a" + "\xcf\x08\x46\x7c\x27\x7c\x2c\x9f" + "\xc2\x12\x80\x56\x32\xdf\xcb\x7c" + "\x0e\x9b\x72\x61\xdd\xae\xb0\xfc" + "\xbf\x5d\xd7\xf7\x9e\xca\xa2\x7c" + + "\x62\x0f\x64\x6f\xb1\xec\x8f\xf5" + "\x46\x19\xf5\x39\x2b\xb9\x74\xe2" + "\x44\xaf\x88\x62\x04\xfc\x4d\x7f" + "\xe5\x29\xc3\xea\x2a\xf3\x91\x0a" + "\x31\xba\xaa\xd6\x4b\x27\xad\x43" + "\xf9\x84\x68\x0f\x40\x16\x9a\x71" + "\x20\x1e\xf9\xda\xf6\x29\x5d\x68" + "\x52\x9d\xe4\x27\x33\xcc\xc1\x5e" + + "\x59\xa0\x54\x3b\x96\xde\xf4\x38" + "\xb3\xfd\xbc\xef\xe5\x15\x00\x0e" + "\xa6\x8d\xbb\x4d\xd9\x23\x7d\x17" + "\xad\x17\xa6\x97\xa2\x4a\x72\x98" + "\x8e\x55\xb6\xfd\x5b\x88\xf0\x30" + "\x96\x9a\x89\xc7\x8a\xa2\xf7\xf9" + "\x12\xc1\x2d\x87\xc8\x8a\xae\xd2" + "\x59\xc4\xc3\x73\xca\x42\x06\xfa" + + "\xd6\xc8\xdf\xe7\x81\x69\x29\x15" + "\x4a\xb9\xb5\x1f\x50\x44\xcd\x67" + "\x37\xfd\xdd\x0e\xf1\x1c\xc7\x0e" + "\xc7\xdd\x8e\x9a\xb3\xee\xe5\xc7" + "\x28\x50\xd9\x81\x3d\x8e\xac\x02" + "\x5d\xe3\xb0\x70\x72\xf1\x88\x00" + "\xe3\x1f\x88\xe1\xab\x1f\x04\xec" + "\xaa\x7f\x9e\xd9\xb8\x71\xcf\x62" + + "\xc2\x22\xf2\xe0\xa7\xde\x43\x50" + "\x42\x51\xe6\x72\xac\x42\x9d\x30" + "\x30\xcd\x16\x92\xdd\x9d\xfe\x94" + "\xec\xfe\x87\x0f\x7d\x9c\x53\xd6" + "\xd7\xc7\x2a\x43\x7c\xa5\xc5\x03" + "\x10\xda\x7f\x32\xf0\x2c\x69\x72" + "\xde\x98\x06\x28\x5f\xc8\x28\xec" + "\xb1\x83\xc2\x7e\x46\xfb\x31\x23" + + + "\x77\xa4\x57\xe4\xea\x8e\x15\xa0" + "\x05\xdc\x6d\xee\xdb\x57\x98\xd1" + "\x71\x16\xc4\x18\x24\x52\x26\xb3" + "\x58\x0d\x2c\x3c\x7e\xfc\xfd\x3f" + "\xda\x7c\xee\x26\x54\x52\x3a\x3a" + "\xa8\xc3\x02\xdf\x69\x08\x1b\x34" + "\xc8\xbf\x3b\x72\x42\xbf\x23\xa0" + "\x91\x26\x45\x14\x2a\x00\x15\x3d" + + "\x30\xfa\xed\x85\x4c\x32\xf7\x5e" + "\xda\xf3\xd4\x87\x54\x65\x97\x25" + "\x86\x0c\xb5\xdc\xc0\x5b\x2f\x35" + "\x6c\xa9\x32\x48\xb0\x27\x69\x8f" + "\x4c\xf9\xf2\x55\xba\xe1\x8e\xd0" + "\xfa\x45\x4b\x34\x99\x6f\x99\x6a" + "\x5d\x45\xaa\xa8\x8d\xcb\x33\xe1" + "\xf7\xc1\x8d\x75\xec\x21\x07\x5d" + + "\x39\x35\x2a\x26\xe9\xe7\xca\xf3" + "\x9e\xd5\x70\x66\x1d\x9d\xa4\x78" + "\xb9\xe1\xc5\xc1\x63\x0f\xde\x37" + "\x1c\x7c\xcb\x69\x0c\xc3\x72\x30" + "\xe6\x50\xc8\x77\x52\x8a\x27\x1d" + "\xe6\x3d\x6a\x1f\x8f\x5f\xf1\x84" + "\xad\xa7\x2c\x59\x45\xbb\xa8\x46" + "\xb8\x24\xd4\xe4\xee\xe3\x12\x19" + + "\x67\xfb\xe5\x79\x20\xa9\xa7\x6b" + "\x5e\x72\xaa\x70\xeb\x1f\x33\xe1" + "\x37\xd8\xf5\x7d\xf5\xcc\x80\x50" + "\x21\x2e\xf7\x7f\x1d\xe0\xca\xe4" + "\x7d\xa7\x12\x04\xe6\x3e\x24\xd9" + "\x25\x90\x44\xdf\xac\x7c\xff\x06" + "\x31\x5a\xef\x23\xcd\xf7\x75\xbe" + "\xa8\xf7\xde\x0d\x22\x78\x95\xbc" + + "\x8b\x66\x5e\x36\x86\x80\x98\xdc" + "\xfb\xa5\xbd\xaa\xda\xdc\xa8\xad" + "\xbe\x1f\x5f\x25\x4c\x6b\x14\xbc" + "\xc3\xcf\x34\xcf\x29\xde\xfc\x9c" + "\xe4\xd1\x85\x7e\x3e\x45\xbb\xac" + "\xb5\x58\x23\xf9\x79\x96\xa0\x9c" + "\xff\x23\x08\x24\x96\x2d\xfc\x15" + "\x1e\xd1\x11\x0c\xf7\xad\x65\x8d" + + "\x55\x1c\xce\xb0\x0c\x23\xf7\x8c" + "\x07\xb6\xbf\x0b\x05\x4d\x53\x5b" + "\x3b\x36\x16\x0e\x13\xf1\x1e\xee" + "\x82\x9e\x99\xb4\x7a\xaa\xe0\x27" + "\x41\x2c\x36\x79\x2d\xac\x1d\xce" + "\xb0\x6c\xbb\x91\x90\x0c\x92\x67" + "\x24\xdf\x23\x22\x63\x8d\x64\x1e" + "\x28\x8f\x2e\xe3\xef\x9e\x7d\x0f" + + "\xfd\xf4\x96\x02\xf1\x57\x55\x77" + "\x36\xb4\x51\xea\xa3\x76\xca\x1d" + "\x05\x08\x95\xfb\x60\x8f\xe9\xf3" + "\xf1\xf7\x1c\x83\xea\x32\xff\x31" + "\x4b\x71\x2c\x8d\xf1\x7b\x3e\x64" + "\xca\x2a\x9d\x2e\x39\xc3\xb5\x64" + "\x23\x2d\xdc\x6a\xcc\x9c\xfd\xa9" + "\x9b\x1b\x72\xcc\xec\x97\x23\xfc" + + "\x34\x38\x83\xfa\x9a\xf3\x43\x69" + "\x62\x85\x32\xa6\x22\x17\x95\x22" + "\x10\xfc\x70\x41\xd5\x3d\xd6\x81" + "\x6d\x2e\xcc\xae\x8f\xa5\x5f\x9f" + "\x3b\x9a\x7d\xe7\x25\x87\x6c\xb6" + "\xe0\xeb\x84\x63\xea\x5c\x23\x11" + "\x4a\xe2\x45\x58\x18\xc1\xa8\x06" + "\xb1\x93\xd0\xeb\x86\xb2\x37\x01" + + "\x7d\xc5\x8e\xb4\x2d\x18\x31\xf0" + "\xb9\x33\xb2\x04\xf8\x32\x5d\x51" + "\x26\xad\x3a\x09\xd4\xb1\xbb\x06" + "\xec\xd1\x83\x0d\xfe\x42\xa1\x88" + "\xf8\x73\x5c\x24\x99\xc0\x95\x3b" + "\x32\xcd\xed\x52\xaf\xd4\x26\xb1" + "\xe6\x52\xcb\x8f\x1e\x2c\x02\xf8" + "\x39\xd3\x06\x01\x4c\xac\x51\x5a" + + "\x50\xe1\xac\x44\xce\xe1\x89\xc5" + "\x7c\xe9\x81\x43\xd9\xd3\xf8\xe0" + "\xb8\xa4\xc5\x62\x11\x9b\xe9\x59" + "\xf9\xc9\x0e\xfd\xf7\x62\xd2\x90" + "\xc9\x13\x3e\x28\xc9\x54\xc8\xfb" + "\x85\x70\xdc\xae\xe7\xfd\x04\x2d" + "\xcb\xbe\xdc\x47\x65\x77\x7d\x05" + "\x5f\xfa\x76\x9a\x91\xf5\xbd\x8d" + + "\x54\xa0\x64\x7c\x1a\x0a\xf7\xb7" + "\x79\x3e\xb4\x9d\xdf\xc0\xc1\x0d" + "\xd6\x63\xfe\x51\xe2\x4a\x0a\x6d" + "\xbf\x8a\x0c\x7f\x32\xe3\xd5\xe0" + "\xe8\xce\x7e\x2b\x36\x00\x55\xff" + "\x08\x50\x05\x5d\xf7\xe6\xa0\x3e" + "\x4f\xc8\x4a\xf2\x2f\xb6\xde\x30" + "\xb7\x16\x71\x5d\xfd\x69\x69\x93" + + "\x78\xe5\xe1\x0d\x95\x06\x15\xd0" + "\xc6\x2b\xf7\xe9\xe7\x63\x14\x2e" + "\xa5\xec\x39\x1b\x41\x84\xa6\xff" + "\x2f\x7f\x03\x7c\x30\x85\x3c\x67" + "\xda\x91\x7f\x74\x00\xa6\xd6\xd0" + "\xe9\x78\xcb\xc9\xe1\x43\x8d\xb0" + "\xf5\xce\xb5\x27\x44\xc6\xc0\x0f" + "\xd6\x2f\x0a\xa6\x0a\x16\x1d\x5c" + + "\x7f\xcf\x17\x26\x12\x76\xda\x02" + "\x60\x52\xe3\xee\x4e\x5d\xe2\xd6" + "\xe9\x33\x35\xfd\x0a\x5b\xfa\xb2" + "\x88\x6f\x12\xb9\xb0\xb7\x6b\xe7" + "\x66\x68\x85\x88\x99\x6a\x2e\x69" + "\xca\x65\xdb\x49\x4f\x39\xdf\x3f" + "\x06\xd6\xd8\x22\x91\x69\x29\x25" + "\xcf\xc4\xd7\x3d\xbf\xbf\x15\xe8" + + "\x3b\xe1\xc8\x28\x53\xae\x8c\xf9" + "\xd1\xdc\xed\xb2\xc4\x10\x5f\x37" + "\xad\x06\xce\x5c\x7f\x8b\xeb\xd4" + "\xef\xe1\xa2\x80\x45\x9f\x66\xb4" + "\x99\x86\xbd\x5b\xd0\xf9\x93\xd5" + "\x13\x6d\x97\xe7\xc9\xa4\x28\x55" + "\xd3\x28\x7e\x1c\x95\xe0\x23\x39" + "\x77\xb5\x6b\x3f\x90\x37\x29\xb9" + + "\x7f\x4e\x84\x4d\xed\x84\xc9\x69" + "\x82\x8a\x2e\x4a\x17\xb2\x54\xd3" + "\x36\x41\x2c\xfb\xdd\x4a\xbd\x25" + "\xe1\x26\x4b\x14\xde\xf4\x2d\xf7" + "\xfd\x1a\x10\xe6\xb0\x9d\xaa\xd0" + "\xb8\xd1\x9b\xe4\xaa\xef\x45\x44" + "\xb2\x93\x15\x33\xee\x4e\xc5\x5d" + "\x0b\xf1\x4b\x09\xb9\xe3\x35\xfa" + + "\xd2\xd6\x2b\xc4\x6a\x7d\x56\xdb" + "\xae\x96\x1f\xbb\x68\x64\xf8\x6d" + "\x8e\xb2\x43\x48\x1a\x5b\xfe\x0e" + "\x40\xb2\x79\x63\x05\xbb\x1b\x96" + "\x6b\xa2\xa6\x70\xf0\xf5\xca\xb6" + "\x39\x6e\x8e\x32\x0d\x6c\x68\x70" + "\xd3\xc8\x5f\x89\xcf\x06\xda\x80" + "\xc9\xfd\x63\xb3\x10\x88\x4d\x80" + + "\xc3\x89\xa0\x3e\x89\x0f\x0a\x66" + "\x09\x9b\x00\xc9\xaa\x23\x58\xa2" + "\xe5\xf5\x81\xa6\x7b\x2d\x26\xb2" + "\x3a\x86\x13\x34\x8c\x0c\xc3\x4f" + "\xf7\x59\x20\xc3\xb7\x44\x15\x69" + "\x34\x61\x1c\xb2\x76\xf2\x5c\xf6" + "\xba\xda\x04\x51\x2a\x6b\xa9\xe3" + "\x2f\xe4\x3e\xa4\x09\xd1\x08\xbb" + + "\x70\x16\x7f\x20\x7b\x87\x22\xbe" + "\x91\x52\x61\x4e\x88\xd1\x0d\x9b" + "\xbf\xc2\xa3\x97\xdc\xe8\x5a\x62" + "\xe8\x86\x9b\x43\xf7\x4e\x58\x08" + "\xff\x98\xd8\xdc\xa5\x90\x71\xde" + "\x3d\xee\x58\x20\x40\x6c\x28\x26" + "\xc1\xb1\x87\x5f\x17\xb2\xb0\x3d" + "\xb5\x6d\x2a\x10\x71\x47\x33\xcc" + + "\x61\x68\x91\xf9\x69\x2d\xa5\x85" + "\x13\xa8\x4f\xda\xa4\x69\x54\x59" + "\x2f\x50\x38\x33\x6e\x78\xd7\x1d" + "\xc5\x3a\x96\x53\x28\xef\xb8\x34" + "\x25\x1b\x89\x1a\xf8\x19\xf0\xc0" + "\x75\xd7\x4b\x4f\x0c\x97\x19\xb6" + "\x81\xf6\x19\xbe\xf3\x5a\x2a\x8c" + "\x28\x17\xec\x98\x04\xdb\x63\x94" + + "\xb1\x0f\x77\x2f\x54\xe9\x9d\xd9" + "\x5e\x53\xd7\x4c\x20\xc6\xc1\x97" + "\xfc\xce\x09\x3f\x48\xc4\xb6\xd3" + "\xf8\xb4\x63\x5a\x15\xaf\x25\xd7" + "\xec\x20\x1e\xc0\x4f\xd2\x95\x0c" + "\x1f\x12\xe7\x9a\x94\x74\xd3\xdf" + "\xec\xb7\x77\xec\x72\xdb\x6d\x7d" + "\xae\xa4\x53\x03\x3b\x9d\x07\xfe" + + "\xab\x9e\xf3\x01\x78\xc2\x62\xeb" + "\xaa\xa4\xb3\x0a\x34\x39\xde\x27" + "\x8d\xca\x82\xa9\x20\x75\xd1\xfb" + "\xed\xc6\xbd\xe4\xc2\x7e\x81\x58" + "\x13\xac\xc6\x31\xde\x78\x2d\x31" + "\xa6\x2e\x20\x09\x76\xbf\x83\x94" + "\xe1\xd8\xc6\x22\xb6\xb8\x4a\xf6" + "\x74\xde\x80\xe5\x9c\x58\xdf\xdd" + + "\xd2\xc8\x6a\x2e\x0a\xe7\x66\x30" + "\x05\x5c\x6e\x10\x43\x5a\x6b\x9c" + "\x8c\x9b\xe5\xed\xf5\xc6\xd3\x52" + "\xae\xc9\xce\xfc\xc3\xa5\xd6\x30" + "\xef\xa9\xc0\x4f\x22\x7c\xec\xed" + "\xed\x6c\xc1\x95\x83\xf0\x0f\x19" + "\xde\x0f\xde\x94\x8f\xec\x12\xbe" + "\x33\x34\x2d\x85\xb8\x1a\x13\x0d" + + "\x2a\xa9\x98\xee\x36\x33\xfa\xe0" + "\x45\xd7\xa4\x66\xef\xee\x80\x7d" + "\xd3\x19\x01\xba\x1b\x53\x12\xb6" + "\x15\xfe\x51\xb3\xc1\x70\xe7\x86" + "\x97\xa3\xd5\x82\xf8\xd6\xba\xaf" + "\x10\x01\xbf\x0d\xb8\x1c\x5f\x1e" + "\x3d\x06\x79\x9f\xc0\x8a\x13\x25" + "\x56\xa1\x46\x27\x2f\xd2\x9e\x08" + + "\x91\x12\x70\x85\x7e\xe0\xac\x42" + "\xa8\x61\x40\x19\xd9\x3e\x79\x94" + "\x85\xa4\xf4\xd7\xd6\x3e\xe8\x30" + "\x4d\xff\xee\xf9\x69\x72\xec\x9e" + "\x05\x80\x9d\x0c\x59\xba\xac\x90" + "\xd1\xb9\x79\x1e\x58\xa4\xec\x5f" + "\x1e\x6a\x50\x1d\x27\x54\xbe\x8f" + "\xa7\xcf\x39\x24\x8e\x2c\x2b\xa3" + + "\xde\x8d\x8b\x7d\x5d\x1b\x8d\x19" + "\xfb\x37\xab\x8d\x07\x11\x2c\xf3" + "\x74\x38\xb9\x42\x6d\xcb\x5f\xf1" + "\x84\x4f\xf9\x41\x4f\xb7\xdd\x91" + "\xb2\x24\x15\x27\x0a\x54\x64\x6a" + "\x64\x5a\x8b\x75\x12\x0c\x0a\x95" + "\x80\x95\xce\x3d\x93\x37\xf2\xf9" + "\x32\xce\xf8\x2c\xab\xd0\xed\xc8" + + "\x4e\x0b\xdd\x73\x73\xc1\x71\x16" + "\xc6\x54\xa0\x44\x14\x82\xa2\x37" + "\xf1\x53\x8b\x4e\x1b\x0a\x76\x81" + "\x9e\x3b\xf9\xf9\x24\x42\xc0\xa6" + "\x3c\x1e\x67\xcf\x34\x4b\x78\x18" + "\x94\xb9\xa9\xcd\xd2\xec\xbb\x81" + "\x48\x38\xab\xb2\x79\x19\x83\x38" + "\x2d\x3c\xe0\xf2\xb7\xfe\x54\xef" + + "\xb7\x46\x10\xae\x7e\x35\xc6\xef" + "\xe4\x32\x29\x61\x29\x49\x70\xe6" + "\x17\x5b\x35\xb1\xd4\x05\x03\xa2" + "\x56\xa1\xb4\x58\x6a\x13\xa9\x88" + "\xec\x75\xd2\xb4\x85\x99\x37\xbc" + "\x8b\x33\xaf\x6e\x31\x91\x8b\x71" + "\x09\xa5\x52\xd1\x7a\x9a\x22\x61" + "\xe9\x7a\x15\x45\xc4\xf7\x09\x11" + + "\xfa\x88\x80\xfb\xa7\x7c\x19\xcf" + "\xc5\x96\xdc\x4d\x47\x72\x42\x01" + "\x76\x71\x77\x30\x0a\x55\xd2\xa2" + "\x1d\xf7\x0c\x4d\x98\x98\x46\x53" + "\xc6\xaa\x2a\x3a\xb8\x37\xe9\x6c" + "\x9b\x8d\xf3\x5a\xc3\x1d\xf9\xe9" + "\x99\x28\xbf\xc8\x83\xad\x98\x25" + "\x16\x6c\x53\xb5\xc9\x6a\x70\x8e" + + "\x2c\x5c\xf8\x0d\x14\x42\xde\x2b" + "\x63\x7a\x8a\x05\xf4\x39\xb8\x4f" + "\x31\x12\xf5\x47\x2a\x57\x10\x7c" + "\x4e\x82\x89\x19\x23\x26\x88\x87" + "\x4a\x56\xe1\x16\x20\x3d\x29\xa8" + "\x76\x45\xc0\x18\xf8\xc0\x11\xcb" + "\x31\xc6\x40\x97\x7d\x1e\xb9\x83" + "\xa0\xce\xff\xcb\xd0\x23\xcb\xbd" + + "\x98\xdc\x88\xf6\x95\x74\xdc\x40" + "\xfc\x4a\x4c\x12\xd7\x0c\x49\x26" + "\x5c\x77\x18\x1f\x84\xec\x51\xe6" + "\x4a\xaf\xfd\xb4\xc3\xa6\x3e\x39" + "\x0d\x8e\x33\x7f\x43\x33\x1f\x1e" + "\xb5\xe7\x53\x60\x2b\x83\xfb\x39" + "\xd5\x14\x9e\x61\xda\x02\xe7\x46" + "\xe0\xf6\xee\xcd\xd1\xac\x9c\x85" + + "\xc8\xbf\x94\x90\x2a\xfd\xbd\x64" + "\x1e\x4d\xc5\x0f\xc6\xac\x58\x85" + "\x1e\x72\x27\xaf\x8f\x84\x92\x39" + "\x09\xd0\x4c\xa1\xda\xcb\x8f\x7a" + "\xc2\xb9\xa4\x00\x09\x12\xe6\x6d" + "\x28\x8f\xcf\x20\x1b\x2b\x19\xbd" + "\x83\xbe\xd9\x68\x01\xb9\x56\x23" + "\x8a\xa4\x49\x4a\x94\x7a\x1e\xce" + + "\x7d\x00\x62\x44\xe7\x9c\xb9\x63" + "\xb7\xf5\xb5\x4c\xa5\x48\xab\xb8" + "\xe7\xdd\x5e\xf5\xd2\x73\xc6\x9e" + "\xda\xef\xfa\x8c\x74\x7f\x56\xd1" + "\xec\xbc\x87\x08\x6b\x1b\x38\x46" + "\xc2\xf3\x78\xe1\xce\x97\x44\x69" + "\xcb\x66\x62\x1e\xe3\x25\x65\x5e" + "\x13\x64\x7d\x69\x26\xde\x31\x59" + + + "\x7a\x50\x93\x1a\x02\x55\x2b\x14" + "\xcf\x06\x3c\x8d\x87\x11\xcd\xb4" + "\x40\x3f\xec\x91\x6a\xe7\x70\xdf" + "\xc2\x53\x75\x4e\xad\x81\x4e\x48" + "\x6e\x9d\x2e\x27\xb5\x87\x0f\x83" + "\x4a\x51\xff\xc6\xe5\x93\x1c\xea" + "\x8e\x2a\x19\xc4\xdc\x2a\xcc\x67" + "\x5a\x53\xf4\x42\xe2\x27\x7e\xc7" + + "\x99\x51\xc0\xd0\xf2\x9c\xda\x8c" + "\x54\x84\xe7\xfa\x22\xbc\x2f\x50" + "\x82\xa1\x72\xf5\xdf\xa9\xbd\xc0" + "\x72\xb3\x58\x61\xb8\x71\x9b\x5f" + "\x07\xdd\x82\x2b\x59\x3a\xf3\xe0" + "\x2e\x03\x23\x95\x35\x27\x30\x76" + "\x32\x5a\x50\xc4\x21\xa7\xe1\x7f" + "\x9f\x40\x96\xf7\x82\x3e\x6e\x7b" + + "\x9e\xba\x37\xea\x56\x63\xc6\xb4" + "\x5d\xf5\xff\x0a\x15\x84\xdc\x1a" + "\x62\xc8\x6c\x59\xf9\x0e\x08\xf0" + "\xb6\x7a\x64\x6d\xb8\x85\x6c\x75" + "\x15\xc2\xb9\x1d\xaa\x94\xdb\xc9" + "\xa5\xb1\x13\x20\xb1\x6d\xd3\x2d" + "\x03\xc9\x86\x42\x1c\xc6\x6a\xde" + "\x84\xf8\x6c\xc7\x88\x2f\xd3\x3f" + + "\x4a\xb3\xd0\x35\xc0\x7b\x41\xe3" + "\xa7\xc0\x27\x83\x6b\x38\x0b\x44" + "\xd1\x62\x03\xac\x2d\x26\xb7\x8f" + "\x43\xf9\xcd\xe0\x4c\x11\x41\x2c" + "\xb1\xa0\x95\xad\xf1\xce\xa5\x2b" + "\x62\x43\xd5\x67\xa8\x37\x9b\xc0" + "\xc9\x86\xe4\x01\xd2\xcd\xd6\x26" + "\x97\x92\xff\x42\xbf\x7a\x47\x20" + + "\x8d\x46\xe9\x11\xec\x82\xca\x31" + "\xa0\x5f\xa0\x1c\xb6\x0e\x5d\xcf" + "\x73\x2e\x96\xaa\x05\xa3\xba\x49" + "\x56\xe4\x15\x40\xb9\x61\x2b\xad" + "\x35\x38\x21\x6c\x5f\x8e\x2b\x6d" + "\x63\x47\xf7\x48\x2b\x1c\xf1\x0e" + "\x68\xa7\x8b\xc1\x5e\x7b\xcd\xa8" + "\xec\xcc\x7e\x15\xef\x4d\xc8\x73" + + "\x7d\x1e\x58\x51\xf6\x6a\x54\x13" + "\x2e\xdb\xc7\x39\x87\x0b\xe2\x0c" + "\x46\x7c\x12\xd9\xed\xe2\xb1\xfa" + "\xa8\xe6\x35\x6f\xc4\x1d\x9a\xba" + "\x7b\x0e\x69\x80\x6f\x66\x69\x1b" + "\xa0\x90\x88\x64\x3d\x0e\x53\xd6" + "\x00\x3e\xc2\x99\xb1\x4c\xbd\x37" + "\x00\x7a\xba\xb7\x2c\x4e\x27\xe7" + + "\x3a\x24\x57\x67\xb6\x50\xac\x9f" + "\x72\x24\xf3\x23\x61\x79\x41\x8f" + "\xf4\xcb\x72\xb3\x56\x7a\x36\xeb" + "\x03\x92\x79\xb7\x5c\xe1\x37\xbe" + "\xdd\x33\x40\xdc\xdf\x1f\x52\x1b" + "\x7f\x8d\x8d\xae\xed\x10\xf4\x21" + "\x47\x75\xdc\xbd\x4e\xf2\x6a\xbe" + "\x4d\xa7\x18\x6e\x84\xae\x65\x99" + + "\x87\x92\x2a\x29\xb3\xdc\x04\xa0" + "\xc7\x92\xb0\x77\xf6\x5c\xc1\xdd" + "\x05\x06\x6c\x80\x64\x84\x3a\x08" + "\xb0\x97\xb9\x3d\x70\xdf\x68\x4a" + "\xd0\x7d\xbf\x05\x45\x4e\x13\x9c" + "\x8c\x7f\xcf\x8c\x39\x3d\xe6\xa4" + "\xaf\xf8\xb5\x41\x7f\x51\xe6\xa6" + "\xcc\xc1\x7b\xad\x42\x93\x8b\xaa" + + "\xc1\x5a\x89\x16\xcd\xb0\xa9\x6a" + "\x37\x4c\x8e\xf2\x53\xd3\xdc\xad" + "\x0a\xae\x90\x6f\xbd\x3a\x47\xff" + "\x8e\x14\x8a\x31\x09\x24\x48\x76" + "\x21\x27\x19\xca\xcc\x5e\xeb\xc5" + "\xae\x22\xd2\xfb\x27\x25\x54\x58" + "\x94\x0d\xb5\x81\xa9\x52\x48\x59" + "\xba\x8c\x6a\xe2\x03\x4e\x1f\xa0" + + "\x4a\xf9\xe0\xc2\xf5\xc5\x1d\xe1" + "\xc7\x6c\x98\x71\x4e\xfa\xb6\x1f" + "\x02\x8d\xb3\xa5\x96\x19\xfc\x0f" + "\x3f\x40\x85\x93\x8e\x26\x06\x0e" + "\x95\x61\x1a\xd0\x09\x1f\xd1\x93" + "\x17\x65\x46\x5d\x40\x96\xeb\x05" + "\xdf\x5a\xed\x77\xcc\x85\xa8\x63" + "\x72\xea\xa0\x35\x25\xdc\x07\xd5" + + "\x38\xc3\x4f\xa9\x81\xad\xe7\x68" + "\x9d\x4d\x22\x5a\x4b\x70\x6c\x31" + "\x5f\x59\x26\x4f\x38\xa9\x4f\xe3" + "\x36\x18\x96\x98\xe9\x1f\x17\x86" + "\x6c\x49\x27\x39\xc4\x1b\x99\x98" + "\xd7\x61\x87\xc6\x5a\xdb\x6f\xce" + "\xd6\x96\x9e\xb2\xfc\xfe\x24\x0a" + "\xa3\x66\xac\xe5\xa6\xff\x2d\xc7" + + "\xd9\x6a\x70\x1e\xb5\x35\x6f\x12" + "\xdf\xeb\xa9\xc3\xb4\xeb\x9c\xb9" + "\x90\x8d\x60\xbf\xaf\x89\x53\xa7" + "\x58\x98\xc8\xc6\x4f\x3c\x11\x76" + "\xaa\xb5\xe2\x97\xb0\x8e\xde\x80" + "\x04\x13\xb9\x63\xcc\x22\x10\x7e" + "\x6c\x06\xcc\x6c\x05\xb6\xda\x3b" + "\x00\xf9\xed\xb2\x44\xb1\xcb\x33" + + "\x5b\x8a\xe0\x8a\x3a\x14\x83\xb4" + "\xa6\x2b\x0b\xe6\xa1\x8f\x27\x4e" + "\xfb\x42\x78\x31\x25\x1c\xb3\x24" + "\x08\x38\xcd\x90\x7c\xcf\xe4\xd4" + "\x78\xf8\x5e\x69\x86\x4d\xdf\x5c" + "\xe8\x3a\x9a\x59\x50\xab\x2a\x36" + "\xfc\x44\x58\xb3\x76\x00\xe0\x22" + "\x04\x1a\xe7\xc8\xb1\x6e\x87\xa6" + + "\xd9\x0d\x72\xce\xff\x4b\x34\x73" + "\xa1\xe6\x3b\xfe\xc0\x16\xa6\x62" + "\x2a\x16\xec\x41\xbc\x17\x41\x30" + "\x0d\x67\x13\x3e\xf6\xb1\xbe\x79" + "\x6d\x3a\x90\x68\xc5\x3f\xaa\xcc" + "\xaf\xfe\x31\xf5\xac\x57\x9b\x99" + "\x55\x30\x17\xdf\xd7\x95\x63\xab" + "\x0f\xf8\x72\xfc\x97\x1d\x7f\x7b" + + "\xe6\x4a\x28\xa6\xd9\x91\x9a\x48" + "\x6b\x86\xad\x69\x31\xd4\xe6\x47" + "\x97\x7f\x17\x39\x33\xe5\xe5\x93" + "\x80\xeb\x59\x2c\x8a\x2c\x5d\x23" + "\x46\xc5\xe9\x94\x77\x69\xde\xed" + "\x83\x43\x93\xd5\xbc\x75\x42\xf9" + "\x53\x46\x82\xec\xbf\x71\x2f\xac" + "\x8a\x3d\xd0\x17\x67\x09\x52\x14" + + "\xd2\x15\xf7\x7a\x71\x64\x17\xc4" + "\x96\x4a\x13\xd0\x94\xf5\xf7\xe2" + "\x56\xc9\x1e\xa4\xef\x73\x18\x2c" + "\x04\x13\x82\x77\xf6\xb4\xe7\xe4" + "\x4a\x37\xd5\x88\x97\xff\xc8\xe5" + "\x5b\x3d\x82\x80\x63\x5e\x91\x2b" + "\xe2\x8f\xee\xb2\x55\xc7\x6b\xea" + "\x51\x26\x11\xe7\x4c\x62\x57\x66" + + "\x15\x49\xcb\x8a\xac\xb3\x30\xfd" + "\x60\x4b\x00\xe1\xbf\x18\x22\x8c" + "\xcc\x5d\xc2\x4d\xfe\x4c\xa6\x80" + "\xda\xb9\xd0\x95\x6e\xf2\x06\x05" + "\x37\xef\xc3\x41\xfd\x94\xaa\xab" + "\x26\xef\xbc\x89\x9d\xd2\x66\x23" + "\x63\xea\xe4\x4b\x8f\xe7\xd0\x6b" + "\x1f\x33\x21\x2e\x5f\xf3\x86\x06" + + "\xce\xd9\x90\x05\xf3\xc7\x0f\xcb" + "\x3b\xd5\x0a\xea\xd9\xc3\x22\xc0" + "\x33\x29\xba\x84\xb3\x29\xc4\xa9" + "\xcf\x92\xb8\x9d\x36\x52\xe6\xfc" + "\x52\x8d\x51\x1f\x62\x28\x70\x48" + "\x32\x31\x38\x10\x1e\x7d\xdf\x25" + "\x5b\x79\x36\xaa\xbd\x0e\x17\x3f" + "\x47\x7e\x95\x34\x4f\x88\x31\xa9" + + "\x4a\xf1\x33\x58\xea\xfb\x39\xdc" + "\x33\x0f\xd5\x88\xc1\xa3\x10\xb0" + "\x2c\x75\xf5\x76\xbc\x45\x61\xcd" + "\x77\xde\x12\x7e\x21\x25\x3b\x11" + "\xa5\x39\x18\x04\x66\x78\x41\x62" + "\xd7\x09\xf3\x0e\xcb\x58\xca\x95" + "\x49\x22\xd0\xa2\x9d\xcc\x02\x6d" + "\xbb\x3a\xfd\xb8\x4b\xb5\x45\x87" + + "\xca\x5a\xce\xda\x01\xf1\x7a\x15" + "\x67\xa2\xa6\x11\xf2\xbc\xfd\xc4" + "\x09\x86\x9c\xc4\x40\xf3\xdd\xda" + "\x65\x4a\x60\xe9\x52\x9f\xe4\x97" + "\xd5\x2a\x7e\x93\x90\xe7\xe8\x9b" + "\xf1\x17\x6e\x32\x08\x25\x6e\x84" + "\xdc\xc0\xbb\x0b\x7a\x00\x38\x3f" + "\xd6\x16\x1e\xb1\x3f\x60\x03\xcf" + + "\xfe\xbc\xd3\x4e\x0a\x15\x89\x05" + "\xb9\x0c\xd8\x6c\x5c\xb6\x62\xf4" + "\x5d\x1c\x53\x29\xa8\xad\x12\x34" + "\x75\xa6\x14\x2f\xe7\x69\xe9\x90" + "\x4c\x5b\xb9\xc7\x06\x89\x6c\x48" + "\x0c\x78\xb4\xbc\x4c\xa9\x67\x5a" + "\x85\xf9\x2d\xd2\x13\x15\x61\xde" + "\x0c\xe0\x1b\x48\x9a\x86\xb4\xba" + + "\x1f\x8f\xd9\xb8\xc5\xa4\xea\x2f" + "\x50\x02\x05\x41\x9c\x02\x09\x7c" + "\x2f\x13\x56\x1b\x77\x42\xfa\xd4" + "\xe5\x35\x12\xda\xf1\x57\xb2\xec" + "\xaf\xae\x46\x6a\x58\x21\x7e\x61" + "\xae\x3e\x65\xd4\x00\xf3\xef\x65" + "\x01\x2a\x56\x03\xad\x13\x7a\xf6" + "\x27\x70\xc7\x70\x87\xfa\x7f\x95" + + "\x2f\x1c\xc1\x46\x90\xc4\xf2\x89" + "\x18\x08\xd5\xd7\xd6\x06\xbc\xbd" + "\xe2\x51\xbe\x82\x60\xc1\xdf\x13" + "\x95\x98\x71\xc1\xf6\x3a\x0b\x71" + "\x75\x84\xdd\x61\x43\x46\xd5\x0b" + "\x29\xe0\x44\x45\xd3\x8e\x8a\xa1" + "\x7d\xbb\x3f\xdc\xcf\xd2\x1a\xe1" + "\x8a\x78\xe8\x79\x9b\xd7\x77\xb1" + + "\xd5\xf1\x42\x74\xe0\x00\xf8\xd6" + "\xab\xe3\xe0\x66\xd1\x07\x56\x47" + "\x47\x40\xc6\xb7\x16\x7f\x80\x82" + "\x3d\x88\x49\xa7\xe3\xe1\x58\x88" + "\x10\xee\x31\x82\x0b\x12\x59\x58" + "\xce\x1e\x8a\x63\xeb\xe7\x80\x1b" + "\xa4\x73\xaa\xc6\x5a\x52\x72\xcb" + "\xac\x23\x44\x84\x3d\xea\xcd\xa7" + + "\x3e\xed\x80\x6b\xb0\x8d\x3a\x86" + "\x13\xfa\xd3\x75\xe3\x47\xa7\x19" + "\x01\xf7\xc8\x69\x2e\xcf\x35\x5a" + "\xe9\xbb\xe5\xf8\x13\x04\x9f\x76" + "\x6a\xe5\x64\x1d\xc0\x36\x6d\x3b" + "\x96\x98\x6a\x45\x32\x2b\xd9\xb9" + "\xda\x9c\x8e\xcf\x70\xce\x47\x0d" + "\x64\x98\x01\x6c\x5e\x35\xe3\x19" + + "\xed\x23\x51\x02\xac\x1a\x10\x7f" + "\x06\x06\xad\x93\xef\x93\x6e\xf1" + "\xd1\x85\xcf\x46\x48\x89\xfe\x89" + "\x0e\x91\x8e\xf7\xcb\x0c\x1d\xe3" + "\x78\xf6\x61\xd5\x1c\xab\xab\xbc" + "\x33\x28\xc9\x87\xc8\xe5\x31\x73" + "\x8d\xf6\x72\x0e\x26\xad\x38\x63" + "\xc3\x05\xdb\x35\x3e\x05\x0c\x80" + + "\x08\x6b\xb0\xa1\x76\xeb\xe2\x81" + "\xc9\x82\x7e\x8d\x78\x55\xae\x81" + "\x96\x8a\xf7\x48\x38\x3e\xec\x03" + "\x01\x9b\xa3\x81\x53\xf7\xb4\x1b" + "\x26\x8a\xee\xeb\x1c\xb0\x4e\x42" + "\x2c\x8f\xae\xd4\xf5\xf7\x11\x13" + "\xf1\x01\x8c\xaf\x76\xb0\x3a\x15" + "\x77\xc1\x02\x5e\x83\x4c\xc9\x2e" + + "\x38\x7c\xae\xf8\x07\xc0\xd0\x5e" + "\x92\x01\x74\x3d\x5c\x7a\xb0\x6d" + "\xb3\x6d\xe3\x5f\x2a\x9c\x5e\xbe" + "\x46\x50\xe9\x76\x7a\xd5\xb9\xd5" + "\xf2\x20\xba\x8e\xe7\x32\xac\x54" + "\x52\xa3\xb9\x71\x8f\xca\x11\xef" + "\x58\xa6\x98\xff\x3e\x37\x5e\x30" + "\x67\xb6\x3e\x82\x00\xa1\xe5\xff" + + "\xcf\xee\x8c\xdc\x00\xc8\xb7\x46" + "\xa5\x94\x59\x81\x2d\x9c\xe4\xd6" + "\xea\x56\x62\xbb\xfc\x14\x78\x6b" + "\x22\x10\x6e\x4a\xfc\x51\x8f\x7e" + "\x38\x20\xde\xca\x83\x53\x80\xf9" + "\xea\xfb\x54\x74\x31\x2f\x76\x9f" + "\x68\x80\x38\x65\x29\x0c\xba\x5a" + "\x51\xb2\x1c\x72\xfa\x61\x75\xa2" + + "\xcf\x32\x5e\x94\x38\x49\x14\x5c" + "\xa6\x91\x82\x5a\x75\x7e\x99\x9e" + "\xd6\x07\x6e\xfc\x46\xe8\x70\x05" + "\x7d\x44\x74\x1e\x64\x13\x68\xe2" + "\xe2\xf2\x1f\x72\xce\x10\x17\xbf" + "\x3d\xe8\x14\xf8\x19\x08\x45\xea" + "\xd2\x7a\x69\xed\x0b\xa7\xf0\x27" + "\x36\x3f\x6b\x08\x99\x98\x36\x90" + + "\xdb\xcf\x46\xdb\xfc\x40\xff\xe9" + "\xc4\x94\x7e\x5e\x15\x67\x52\x1b" + "\xbf\xb3\x00\x97\xc5\x6b\x98\xb8" + "\x28\x31\x8c\x0c\x59\xaf\x8c\xc9" + "\xeb\xbb\x1b\x30\x5d\x01\xfb\xd1" + "\xa9\xd1\x2f\xba\x28\x4f\xe6\x18" + "\x70\x5b\x36\xc0\x7e\x78\x12\x92" + "\x04\x6c\x38\x98\xd0\x51\x4b\xc6" + + "\xd2\x32\x17\xe5\x11\x7b\x47\x57" + "\x0e\xfc\x38\x25\x28\xeb\xd6\xdf" + "\xc5\xee\x39\x3b\xcc\xb0\x43\x5c" + "\x57\xcc\x36\xcb\x78\x27\xf1\x6a" + "\xae\x25\xc4\x06\x2d\x85\xb0\x70" + "\x9b\x1b\x22\x5c\x8c\x2f\xf9\x6d" + "\x9c\x6d\x82\xce\x9e\x4f\x8d\x6c" + "\xc3\x59\x93\xb4\x7b\xba\x9a\xf5" + + + "\xa4\x3a\x1d\x42\x2e\x2c\x7e\xc3" + "\x40\xa8\x4f\xe8\x7c\x40\x26\xf9" + "\x1c\xe4\x54\x14\x3d\xc0\xab\x18" + "\x44\xf6\x7a\x3f\xcd\x5e\x60\x26" + "\xbf\xea\xa5\xd6\xa6\x41\x23\x24" + "\x8e\x66\x6b\x21\xf4\x84\xdb\x1e" + "\x02\x01\x01\x04\xb8\xed\x36\xd8" + "\x8c\x1d\x5e\x94\xe7\x7c\x33\x5b" + + "\x82\xdc\x3d\xd2\x86\x6b\x07\x4c" + "\xf0\x43\x01\x7e\x4c\x34\xfd\x03" + "\xc5\xf2\x7a\x31\xff\x62\x53\xa9" + "\x4f\x7a\x8b\xe1\xb7\x3d\xdd\x0a" + "\x1b\xe0\x60\x82\x3f\x3e\x67\x9c" + "\x91\xcc\xa1\x54\xe5\x49\xeb\xfb" + "\x33\xe4\xf2\x92\xf2\x1b\x35\x91" + "\xeb\x41\x11\x85\xec\xe7\x55\xc7" + + "\x04\x38\x9f\xda\x68\xe3\x9a\x34" + "\x9c\x34\x64\xa1\xfe\x07\x0f\x47" + "\xa5\xba\x62\x85\xc9\x4c\x2f\xd5" + "\xf3\x0d\x29\x2b\x86\x9e\x4a\xc7" + "\x24\x1a\x47\x43\x35\xaa\xa1\xd3" + "\x11\x45\x19\xb8\xbe\x46\x94\x23" + "\x4d\xd4\xdc\x81\x00\xdd\xc2\xbe" + "\x2d\xc8\x2a\xc4\x0f\x7f\x3d\xca" + + "\xd5\x06\x32\xf2\x47\xdb\xf5\x2b" + "\x52\x01\x26\x1d\x20\x34\x6d\x2f" + "\x9a\xf8\x8f\x3f\x53\x76\xb8\x17" + "\x58\xa4\x8f\x37\x0c\xc3\x57\x51" + "\x36\xb9\x4f\x2d\xc5\xc5\x17\x75" + "\xdc\x8c\x51\xe6\xac\xf7\x22\xef" + "\x64\x7a\x84\xbf\xe6\x83\xb4\xde" + "\x89\xfa\xe0\x92\x58\x45\x08\xf5" + + "\x60\x31\x58\x9b\xa6\xc2\x18\xb4" + "\x94\x91\xe5\xb4\xd4\xfc\x74\xbe" + "\xff\xe3\x83\x3c\xaa\xee\x78\xf1" + "\x9b\xf2\x96\xe2\x95\xf8\x51\xe0" + "\x4a\xb8\xce\x06\x38\x52\x23\xd0" + "\x6b\xfe\x11\xe1\xce\x48\xce\x5a" + "\x45\x55\x04\x1c\x49\x3a\xe4\x40" + "\x46\x21\x52\xdd\xdd\x86\xfa\xf3" + + "\xb5\xc5\x8e\x90\xfa\x16\x96\x95" + "\x2d\xb1\x1a\xa0\x1d\x66\x2d\x88" + "\x8a\xae\x82\x43\x82\x60\x9f\xc4" + "\x5e\x3f\x13\x5d\xeb\x92\xdf\x5c" + "\xc1\xc9\xf6\x5e\x42\xcc\xce\x98" + "\xee\x84\x4d\x66\x82\x66\x2d\xb5" + "\xc4\xb8\x25\x6f\xd8\x5e\x28\x9e" + "\x88\xbe\xde\x48\xc7\xcd\x80\xeb" + + "\xa0\x2b\x22\xec\xc1\x94\x97\x2d" + "\x48\x5d\x3e\x52\x2f\xf4\xdf\xc3" + "\x6b\x84\xe4\x0f\x70\xd5\x7c\x4a" + "\x74\x51\x13\xff\x13\xb1\xc5\xef" + "\x85\x5e\xb0\xc6\x5b\xb2\x30\x26" + "\x77\xd0\x4c\x65\x29\x30\x6d\x0a" + "\x9d\xb8\xd8\x32\x4f\xf5\xf1\xb4" + "\x27\xfc\x27\x16\xf2\xaf\x3b\xde" + + "\xd4\x04\x73\xdf\xd8\x59\x96\xab" + "\x8e\x0e\x21\xff\x1b\xcf\x1b\xb7" + "\x60\xbd\x3f\xd7\x8b\x43\xa2\xa9" + "\xde\xb4\x11\x5d\x1f\xcd\x95\x45" + "\x9d\x85\x35\x48\x9a\x32\x0d\x9c" + "\x56\x6e\xbb\x7d\x2d\x0d\x0f\x4a" + "\x4e\x8a\x92\xdf\x5e\x8e\x03\xc6" + "\x54\xd1\x5a\x8f\x21\x96\x42\xc9" + + "\x3e\xdf\xa2\xa4\x3b\xb8\x83\xb8" + "\x63\xa3\xe5\x44\xc2\x7c\x5b\x04" + "\xde\x96\x0d\x4e\x73\xd7\x2b\xa4" + "\x65\xc1\x93\x8d\x47\x75\x25\xb9" + "\x8e\x13\xc8\x73\x26\x01\xf9\xe8" + "\xbf\x84\x7d\x60\x4d\xe7\x8e\x5a" + "\x63\x43\xea\x49\x50\xbb\xec\x1b" + "\x86\x32\xda\x5a\x14\x61\x4b\x1d" + + "\x15\x3b\x09\xaa\xb5\x78\xb6\xeb" + "\x0c\xb4\xe2\xd3\x44\xdf\xac\x0e" + "\x9f\x19\x89\x20\xc4\x23\x42\xbc" + "\xa4\x06\x0a\x49\xb4\x2b\x25\x0e" + "\xf7\x5d\x2c\xcc\xb5\x79\x64\x1e" + "\x8a\x32\x94\xba\xd2\x22\x69\x8b" + "\x8c\x94\x8b\x21\xe7\xcc\x78\x42" + "\x39\x4f\x06\xe6\x5c\x99\x7e\x94" + + "\x94\x69\xd9\xf1\x65\x2d\xf3\xcd" + "\x18\x2b\x5b\xb7\xf3\xd8\xb3\x8b" + "\x98\x77\x30\xcb\xa3\xd2\x95\x5a" + "\xb5\xa8\x15\xcb\xcc\x29\x86\xdf" + "\x26\x49\x8c\x54\xbe\xdc\x5b\x37" + "\xa6\xb3\x25\x3c\xc6\x58\xad\x94" + "\x88\x48\xac\x8f\x52\x0d\x4e\xe9" + "\xe3\x5b\xba\x69\x46\x77\xbe\x9c" + + "\xc4\x6e\x0c\xa7\x40\x38\xa3\x08" + "\x95\x11\x31\xe0\xf7\x19\x88\x9e" + "\x02\xb2\x8a\x70\x96\x9d\x20\xed" + "\x27\x3a\x94\xce\xe7\xc4\xd7\x10" + "\xa1\x49\x9b\xa2\x17\xb3\x2f\x37" + "\x1f\x7d\x62\x46\xb3\x7f\xa6\x57" + "\xec\x39\xdf\x7c\x1e\x56\x12\xf9" + "\x17\x8f\x7c\x6f\xf2\xe6\x3c\xfa" + + "\xc1\xed\x2f\x78\xe7\x6d\xc1\x04" + "\xc4\xe7\x3a\x09\x1a\xc1\xe2\xfe" + "\xb1\x90\xde\x3d\x85\x7d\x7a\x35" + "\xdc\x23\x69\xce\xf2\x6a\x13\x68" + "\x36\x45\x86\x8e\x44\x9b\xaa\x0a" + "\x2f\x1c\xaa\xfe\x52\x34\xb5\x16" + "\x55\xd9\x46\x59\xd1\x94\xf4\xe8" + "\xe3\x69\x15\x3b\x51\x16\x31\xb5" + + "\xe7\xe3\x51\xbe\x7d\xfd\xeb\xdd" + "\x31\x68\x02\x7f\x40\xfc\x25\x0b" + "\xd1\x5f\xe4\xac\x3b\xad\x3b\x4f" + "\xa7\x09\x68\x70\xba\x32\xb3\x8c" + "\xca\x3f\xb9\xd6\xb1\x60\xe1\x40" + "\xed\xbd\x28\x8b\xdf\x8e\x36\x85" + "\xfd\xc2\xb4\x90\x8c\x0a\x6f\x26" + "\x4f\xd2\xaa\xff\xf6\x87\xd9\xaa" + + "\x3b\x62\x1b\x4e\x42\x0d\x31\x9f" + "\xa5\x66\x62\x81\x9b\x74\x45\xf0" + "\x27\x78\xdb\xa0\x51\xd7\x4f\x94" + "\x59\x72\x1d\x68\xa6\x0d\x12\x80" + "\x88\xc5\xa9\x31\x0d\xd2\xcd\x00" + "\xf1\x4b\xae\x97\xd3\xab\xf2\x7b" + "\x6a\xc0\x08\x6b\x90\x22\x5a\xf7" + "\x8b\xdc\x12\x4a\x84\xe5\xa3\x0f" + + "\x92\x2d\x3f\xf2\x62\x34\x21\x91" + "\x78\x40\xb9\x60\xbd\x71\xab\x6c" + "\x20\xde\x6c\x17\x63\x0a\xdd\x6b" + "\xbc\x54\x4d\xee\x0c\xb2\xc9\x54" + "\x2f\xc0\x2a\x9f\xaa\xd8\xd2\x3c" + "\xb0\xed\x6e\x20\x17\xe6\xf8\x03" + "\x34\x64\x08\x93\x16\x8e\xf6\xc7" + "\xb9\x3d\xdd\x92\xc5\x69\x14\x83" + + "\x41\x22\xba\x69\xfe\x2c\x5e\xf3" + "\xbd\xd5\xf4\x8c\xe0\x6c\x44\x95" + "\x92\x4f\xdb\xb8\xcd\x1b\xba\xdc" + "\x58\xd9\x70\x59\x8e\xae\x79\x96" + "\x4b\xb9\xd5\x40\x45\xb4\x9c\x95" + "\xd2\x1f\xa3\x33\x14\x78\x56\xad" + "\xc1\x2b\x00\x1b\xd1\xc3\xd4\xc7" + "\xe3\x53\xc8\x8a\xcc\x81\xa2\x59" + + "\xcd\xb1\x28\xdd\xc0\xae\x75\xfd" + "\xc2\x4d\x37\x7a\x05\x02\x12\xc7" + "\x2f\x62\xf0\x08\xe4\x2b\x6a\xab" + "\x58\x8b\x26\x12\xa1\xd0\x4a\xcb" + "\x94\x3a\x19\xf5\x7c\xed\xf8\x34" + "\x2b\x9c\x45\x1c\x7e\x16\xcd\xba" + "\x74\xe2\xbc\x57\x54\x62\xcc\x24" + "\xec\x60\x40\x2d\xa8\x64\x71\xf4" + + "\x1b\x75\xac\xe2\x5a\x6e\x5d\x0f" + "\x69\x45\x4d\xd4\xf3\xb3\x09\xc6" + "\x33\x4c\x96\x0b\x80\xac\xc4\x38" + "\x05\xc5\x43\xc1\x1b\x45\xf9\xde" + "\x86\x75\x4d\x39\x95\x92\x1f\x98" + "\xd1\xa6\x58\xd0\x9b\x1e\x0d\x4c" + "\x3d\x80\xe8\x07\x1c\xcf\xa4\x76" + "\xd6\x01\xdd\x4d\x33\x76\x5f\x2b" + + "\x5f\x3c\x3f\x65\x65\x74\x7d\xfe" + "\xb1\xfe\x40\xf0\x5e\xd4\x3d\x28" + "\xfe\xed\xb7\xf3\x9b\x59\xfe\x91" + "\x11\x93\x37\x80\xad\x39\xf0\x5f" + "\x49\xfa\x96\x4e\x5b\x99\x76\xbf" + "\x94\x50\xe2\xa3\xb2\xb6\x40\x26" + "\x74\x3f\xc8\xc1\x41\x63\x09\x8b" + "\xc3\x0a\x56\xfa\x84\xc8\xbe\xd2" + + "\x05\x14\xf3\xb9\x6b\x57\x6b\x09" + "\x5e\x2b\xb0\x62\x87\x22\xfc\x40" + "\x18\x61\x2f\xe6\xbb\xbd\xb2\x42" + "\x1a\x49\x03\x73\xf7\x80\x8d\x62" + "\x96\xbe\x33\x8f\xfd\xd8\x7e\x89" + "\x0a\x8d\x49\x48\xca\x69\x56\x4d" + "\xef\x9d\x9c\xe9\x1a\x40\x4c\xf7" + "\x5a\xb8\x44\x65\x5b\xeb\x38\x79" + + "\x88\x12\xf2\xe7\x12\xd3\x0b\x43" + "\x33\xe3\x94\x87\x25\xa7\x81\x73" + "\xfc\xd2\x53\xb2\x8b\x2f\x5d\x94" + "\x9e\xff\xa3\xbe\x85\x35\x59\x79" + "\x06\x60\xaf\x8d\x7f\xf6\xc3\xb0" + "\x77\xd8\xa6\x19\x85\xd0\x48\x78" + "\x4f\x1b\x21\x62\x1b\x70\x38\x6e" + "\x6d\x39\x06\x05\x6e\xf0\x07\xaf" + + "\xff\xb8\xfa\x91\x8d\xc8\x9a\xe5" + "\xed\x96\x7c\x3f\x0e\x1c\x5e\x2f" + "\x79\x50\x08\xb4\x16\x8a\xf2\xff" + "\x9f\xc0\xe0\x94\x9e\x5f\x76\x8d" + "\xbe\x37\x03\xa0\xce\x3e\xa5\xd2" + "\x88\xd0\xfa\x4a\xbd\x5d\x21\x98" + "\x20\x89\x23\xa9\xa9\x6f\x2b\xa3" + "\x2a\xed\xd9\x64\x15\x80\x65\xe1" + + "\x54\x13\x98\x8f\x24\xdf\x21\x85" + "\x59\xa2\x88\x35\xec\x23\x7e\x58" + "\x2c\x99\xa0\xd7\x81\xf2\xed\xcb" + "\x07\x14\x96\x38\x55\x0a\x93\x06" + "\x21\xbe\x5b\xbe\xeb\x0d\x32\x09" + "\x7f\x81\x91\x24\xb5\xa5\xff\xa7" + "\x60\x51\x06\x09\xd9\xb4\xc8\xe6" + "\xa9\xd2\xf6\xff\x92\x39\x4f\xac" + + "\x76\x9c\x7b\x56\xf5\xc8\x5d\x5c" + "\xc6\x9a\xd1\x96\xbe\xcc\xe0\xaa" + "\x5f\xa2\x26\xcf\xa8\xf8\x71\xd4" + "\x08\x52\x36\x37\x4a\x70\xf9\x1d" + "\x05\xda\x45\xa1\x1b\x54\xbc\xab" + "\xaf\xd8\xb7\xf5\x3d\x32\x43\x9d" + "\xdd\x53\xe2\xf1\x92\xb0\xaf\xa3" + "\xcf\x36\xcb\xdb\x79\xeb\xa7\xc4" + + "\x23\x91\xaa\xa3\x15\x6f\x4d\x2e" + "\x42\xd3\x4d\x38\x8c\x9c\xff\x33" + "\x0c\x1b\x2d\x8f\x17\x86\x16\xb0" + "\x62\x05\x6d\xbd\x7d\xd8\xae\x66" + "\xe8\x66\xa4\x4e\xac\x76\x31\x40" + "\x7b\xbe\x10\x1e\x0c\x8f\x4d\x15" + "\x4b\xa4\xd1\x58\x76\xf7\x75\x5f" + "\x05\x39\xa5\x33\x10\x98\xb2\xc9" + + "\x01\xb1\x7f\xa4\xf5\x73\xbd\x56" + "\xfb\x59\xbf\xfb\x84\x86\x25\x36" + "\x2b\x84\x4c\x86\x38\xdd\xc8\x43" + "\x03\x87\x4e\xf5\x92\x65\x46\xf1" + "\xc5\x78\x06\xd1\x92\xc3\x37\x11" + "\x8a\x91\xd5\xf0\xde\x82\xa8\x86" + "\xd0\x33\x10\x2d\x4d\xd2\xe1\x8e" + "\x26\xe9\x76\xe3\x62\xe1\x9c\x64" + + "\x66\xda\x53\xcc\xa3\xb2\x4e\x2e" + "\x4e\x9b\x7a\xf1\x71\x8a\x70\x04" + "\x2c\x5b\xe0\x0d\xb2\xc7\xfd\xdb" + "\x01\xa2\x07\x49\xee\x9a\xdc\x4c" + "\x66\x55\x47\x6c\xfc\x8d\xcc\xe5" + "\x91\x16\xbe\x47\xfb\xcb\x83\x2b" + "\xfd\xc3\x05\x4c\xa7\x33\x58\x69" + "\xb0\xde\xb0\x43\x72\x8a\x93\xee" + + "\x0f\x8f\x42\x3f\x77\x25\x86\x07" + "\x1f\xed\x3d\x4c\xa9\xdb\x63\x9b" + "\xbd\x51\x67\x35\x44\xae\x2a\x85" + "\x80\x1c\x2f\x3b\x11\x49\xec\xe2" + "\xfb\x20\xc4\x73\x54\xf3\xb0\xed" + "\xc3\x55\xc2\x0b\xab\xcc\x63\xd6" + "\xa9\x46\xae\xcf\x5d\x01\x3e\x1c" + "\x84\x7d\x18\x1f\x99\x89\x55\x98" + + "\x1a\x3d\x8b\xb7\x1e\x4f\xd3\x2c" + "\x0e\x4c\xf8\x5f\xc6\xfa\x13\x17" + "\x60\xec\x9c\xc2\xc9\xfa\xe9\xde" + "\x52\xa5\x7a\xb2\xfd\x7b\x91\x53" + "\x9f\x12\x64\xee\x4d\x53\x6f\x89" + "\xe0\x1e\xeb\xdb\xf2\x23\xa5\x76" + "\x27\x11\x59\xd2\x09\x33\xc1\xe1" + "\x6c\xf6\x4c\xad\x57\x1d\x6f\x87" + + "\xa9\xa3\x76\xb5\x89\xc7\x32\xc6" + "\xc8\xd7\x0d\x69\xf2\x21\xc0\xcf" + "\x6d\xad\x84\xeb\x32\xea\x55\xcf" + "\x66\x95\x05\x72\x2b\xb7\x70\x61" + "\x28\xf2\xa5\xcf\x10\x56\xa0\xfb" + "\x1a\xbf\x4c\x89\x15\xdd\xb3\xc1" + "\x36\xf4\x4f\x31\xf0\x24\xc5\xc6" + "\xdd\xff\xa1\x07\x61\x0c\x7e\xb2" + + "\xbd\xc1\xe9\x3a\x58\xa1\xa7\x7a" + "\x40\xe2\x7c\xe3\x98\x6d\xaf\xe0" + "\xb4\x38\xab\x28\xd9\x42\x43\xe5" + "\xca\x98\x1c\x0a\x07\x50\xb7\xe8" + "\xf2\x58\x23\xe0\xaf\x86\xce\xef" + "\x28\x12\x92\xea\x56\xb8\xb8\x31" + "\xfc\x67\x1c\x0a\x12\x19\x2a\x05" + "\x59\xad\xae\xe3\xa4\x9e\x06\xb4" + + + "\x19\xf0\x8d\x55\x9e\x43\x51\x9f" + "\x27\x2b\x71\xac\xba\xa4\x0d\x23" + "\x24\x5a\x18\x55\xe3\x19\x89\x51" + "\x50\x8f\xb7\x84\xdd\xfc\xce\x4d" + "\x5a\x4c\x7d\xa4\xb2\x0f\xd9\xa7" + "\x9e\x00\x0e\xb3\xbf\x9a\xac\x55" + "\x73\xd2\xee\x74\x59\xc3\x2f\xfd" + "\xaf\x8f\xea\xdb\x4c\x82\x2d\xb7" + + "\x89\x92\x7d\xef\xb5\xb2\x9d\x54" + "\x5a\x01\x7f\x19\xa8\xd4\x80\x24" + "\xb6\x93\x04\xc4\x0b\x59\xd5\x61" + "\x31\x03\x78\x6f\x2e\xb5\x55\x3a" + "\xb0\xad\x9e\x30\x15\x81\xeb\x40" + "\x25\xc6\xe5\x92\x5a\xde\xa7\xde" + "\x5a\x3d\x6a\xcc\xf0\x31\xd6\x64" + "\x61\xdd\xe8\x93\x7c\x9d\x5e\x9d" + + "\xdd\x2b\xc8\x04\x8d\x58\x7a\x1b" + "\xfd\x9d\x31\xf8\x34\x55\x00\x68" + "\x80\x95\xeb\xd8\xb5\x55\x8a\xde" + "\x81\xca\x5b\x8d\xda\x86\xa8\x5e" + "\x4d\x0b\x2a\x25\x01\x0a\x53\xe8" + "\xa1\xa0\xea\x35\xfe\xb4\xff\x1b" + "\x63\x95\xe9\xd8\xb1\x28\xd8\x2a" + "\x87\xcd\xf9\x95\xf5\x6e\xe9\x7d" + + "\xe5\xe0\x84\x1e\x41\x60\x68\x19" + "\x93\x4c\xa3\xae\xd3\x84\xdb\xa5" + "\x32\xa7\x73\x70\x19\xbb\xd5\xf9" + "\xc0\xd7\xcf\x6b\x56\xfe\xd2\xb8" + "\xfa\x82\xeb\xf3\x36\x5f\x77\x45" + "\x58\x8b\xff\xfd\xcc\x0c\xb2\x8c" + "\x10\xc1\x74\x83\x5f\xb6\x59\x16" + "\x9a\x78\x0c\x33\x22\xa4\xb4\xb8" + + "\xdc\x73\xa9\x7e\xe5\x41\x57\x74" + "\x2e\x8f\x88\x20\x70\xca\x00\x5c" + "\xf1\x9c\xfd\x45\xcf\xe3\xdc\x7c" + "\x72\xf8\x07\x55\xf1\x1e\x74\x8a" + "\xec\x4c\x6b\x19\x2f\x1c\xc5\x47" + "\x18\xa6\x7e\xc9\x43\x8e\xd0\x70" + "\x2b\x8a\xb1\x15\x5c\xa1\x0d\x93" + "\x14\x05\x61\x2f\x78\xc6\xb6\x33" + + "\x9f\xae\xdb\xae\x87\xff\x25\xc9" + "\x54\x0a\x88\x36\xb9\x0e\xaf\x7d" + "\x71\x0e\x4d\x9c\xf5\xdd\x84\x92" + "\xf5\x8c\x6f\x31\x93\xcf\x81\x15" + "\x52\xf4\xc1\x3a\x87\xa8\xec\x3e" + "\xfe\xef\x6a\xfb\xe9\xfc\x17\xb4" + "\xc3\x8d\xfb\xee\x46\x80\x91\xa5" + "\x00\x94\x20\x02\xac\x18\xd3\x73" + + "\x8b\x78\x85\x9a\xda\x35\xa5\x6b" + "\xd4\x26\x06\xbd\xae\x03\x1f\xd2" + "\x64\xdc\x73\xe8\x47\x8c\x9f\x09" + "\x7e\xc9\x8e\x01\x4d\x56\xa8\xcd" + "\x8c\xc6\x92\xde\x5c\x7a\x8d\x3e" + "\xc4\x3c\x32\x73\xa1\x35\xe0\x78" + "\x7c\xff\x80\xf8\x75\x62\xf2\x3e" + "\xaa\xed\x3e\x27\xff\x3d\xee\xa4" + + "\x2f\xbc\x2e\xaf\xa3\xcd\xf4\xc4" + "\x24\xfe\x4e\xcb\x3d\x84\xaf\xa0" + "\xb1\x10\xcd\x9c\xc1\x57\xb8\x53" + "\x04\x3e\x4d\x91\xeb\xd1\xc9\xdd" + "\xeb\x1d\x77\x62\xbb\xc8\xde\x7b" + "\x81\xaa\xc5\x91\xaa\x77\x92\x82" + "\xae\x91\x23\x83\xd6\x8d\xf1\x7a" + "\xca\x84\x1a\xc7\x16\xf3\x40\x17" + + "\xed\x73\x6d\xa5\x88\x5c\x9e\xba" + "\xd3\x54\xa0\x2c\x71\xf7\x24\x6c" + "\xe1\xea\x3b\x08\x35\xc2\x37\x4a" + "\xfd\xe9\x83\x64\xb2\x83\xa8\x04" + "\x5d\x2c\x7c\xe2\xae\xf3\x63\x0c" + "\xf1\x71\x46\xae\x8d\xa8\x1d\x0e" + "\xdb\xe1\x95\x59\xe2\xe8\x77\xa5" + "\x6a\x06\xd6\x6e\xb1\xb1\xc4\xbf" + + "\xf8\x31\x2b\xe1\xd8\x12\x4a\xdd" + "\xe6\x36\x77\x17\xbc\x29\x7e\x57" + "\xe8\x35\x89\xa8\x2b\x72\x53\x23" + "\x6d\x28\x5f\x01\x29\x37\x1d\xca" + "\x35\xe0\xa3\x39\xa2\xb6\xc7\x86" + "\x9f\x3a\xb0\xd3\xbf\x50\x52\x6e" + "\x6e\x53\x0d\xfd\x30\x89\xd9\x79" + "\x32\x38\x0c\xfa\xab\xbb\x4c\x8c" + + "\x39\x23\x3b\xa4\xc9\x38\x9b\x16" + "\xab\xbf\x32\x17\xd9\x08\x43\x88" + "\xdd\x02\xf2\x8f\xa2\x93\xb5\xe4" + "\x6c\x37\x65\x1e\x1f\xd1\x51\xaf" + "\xff\x25\x15\x74\xde\x48\xc6\x6e" + "\x28\xc6\xf4\x9f\x36\xbd\x3c\xf9" + "\x79\x9c\x12\xb1\xef\xf9\x6d\xc7" + "\x94\x72\xa6\xb7\xe2\xf2\xa5\x31" + + "\x1e\x1f\xb9\xca\x10\x09\x50\x2d" + "\x16\xd2\x1c\x4d\x44\x9e\xdd\xbe" + "\x52\x22\xd0\xed\x4f\xb7\x34\xd6" + "\x7a\x61\x58\x12\xe1\xf8\x60\xbd" + "\x4a\x61\x05\x9e\x7b\x53\xc7\xd8" + "\xc5\x5f\xaf\xe7\x66\xc7\x26\xfd" + "\x26\xd9\x2b\x58\x81\xb5\x60\x06" + "\xc8\x7f\xf0\xac\x44\x92\x01\x87" + + "\x8e\xfe\xdc\xba\x22\x73\x3b\x2c" + "\x04\x5a\xe2\xc5\xfa\x16\x06\x6e" + "\xa2\xe4\xa6\x3d\x75\x12\x3c\x0a" + "\x01\xca\x7b\x07\x7e\x95\x6c\xe4" + "\x4b\xe6\x4b\xda\xe3\xa4\x6c\xb4" + "\x78\xee\x75\x8e\x66\xda\x9b\xa5" + "\xf2\x98\xde\xa4\x84\x51\x83\x41" + "\x68\xa5\xd6\x4e\x92\x1f\xfb\x6e" + + "\xb6\xec\x64\xaf\xcf\x6c\xa2\xaf" + "\x75\x27\xd7\x4b\x97\x4f\x05\xe6" + "\x5a\x69\x0f\x14\x5b\xab\xcb\xbb" + "\xde\xef\x48\xe3\xa4\xb4\x71\xbc" + "\x63\xd9\x96\xcc\xbe\x52\x2e\xfc" + "\x18\x90\x5d\x5e\x5f\xbf\x0a\x15" + "\x71\x87\x56\x04\xa6\x2f\x18\xbd" + "\x83\x9f\x33\x70\x61\xc0\xb4\x35" + + "\x05\x06\x37\x11\xb3\xb9\x41\x47" + "\x55\xb3\x09\x5d\xf7\x72\xfa\x47" + "\x6a\x4c\x14\x7a\xac\x71\x1a\x39" + "\xca\xe3\xb6\x98\xf4\xc0\x08\x08" + "\x00\x39\xe5\x7f\xef\xd9\xae\x7e" + "\xba\x30\xa8\xe5\xa5\xa2\x57\xf1" + "\xfc\x4a\x97\x27\x91\xc0\x3e\xd1" + "\x7d\x99\x87\x0b\xa7\x10\xd7\x78" + + "\x49\x8c\xaf\xee\x9a\xe9\x28\x89" + "\x28\xd7\x24\x6e\x3d\xa7\x7a\xee" + "\x6c\x15\x2b\xe7\xc2\x07\x50\x4c" + "\x1d\x8a\x40\xed\xc5\x57\xcf\x5f" + "\x04\x76\x05\xb6\x39\x9e\x71\x9f" + "\xbf\x8b\x86\xc2\x01\x3c\x34\x7d" + "\x2d\x3e\x10\x7e\x4b\x25\xca\x2c" + "\xa2\xbe\x31\xf1\xa9\x38\xeb\xe6" + + "\x11\x19\x20\xcd\xec\xd3\xe1\x27" + "\xeb\xc0\x72\xad\x70\x9a\x11\xb1" + "\xfb\x7f\xb5\x6a\xaf\xe3\xb3\xf8" + "\x2b\xc4\x92\x5b\x5b\x68\xc1\x23" + "\xaf\x7a\x8d\xd0\xb9\xb7\x27\x2c" + "\x1c\x59\x9a\x18\xc3\x0d\x66\x0f" + "\xca\x43\xc8\xad\x02\xa1\xca\x7b" + "\x52\x76\xb2\x1a\xb4\x8b\xd3\xde" + + "\x52\xff\x40\x5f\x4e\xa0\x24\xc6" + "\x4a\x91\xd2\xfc\xcf\xd7\x11\x36" + "\xd6\xbf\xd3\x1f\x2b\xb4\xe8\xb7" + "\x3a\x06\x85\xfa\xfd\x40\xde\x6c" + "\x5b\x7e\x8b\x17\x49\xc4\x11\x78" + "\x13\xcc\x72\x29\x31\x09\xb6\x4c" + "\x35\x61\xb4\x33\x5e\x12\x79\xf5" + "\x6e\xe5\xa4\x88\xf7\x2e\x10\xca" + + "\x84\x0b\xef\x5d\x7f\x67\xbd\x96" + "\xb9\x99\xde\x97\x7b\xa8\x6f\xe9" + "\x53\x15\xbe\x4e\xc1\xfe\xd3\x5d" + "\xcd\x75\x42\x7e\xe6\x43\x57\x31" + "\x23\x83\xb4\xb1\x25\x31\xf1\x81" + "\x75\x8e\x49\x4d\xdd\xb1\xaf\xc4" + "\xd9\xda\x15\x3f\x7d\x8e\x56\x84" + "\xb8\x73\xae\xa3\x1b\xa6\xe3\xd8" + + "\x0d\x1b\x98\x0a\x52\xe3\xa4\x0b" + "\xa4\x41\x1a\xbd\xb3\x4c\x35\x1c" + "\x9c\xab\x9f\xdf\x3a\xaa\xab\x1a" + "\xd5\x18\xc4\x53\xd1\xa7\x01\x07" + "\x21\xb9\xf2\xdc\xef\x7c\x1a\xdd" + "\x61\x80\xf4\xbc\xb3\xf0\xee\x6c" + "\xe6\xcc\x25\xde\x98\xb5\x83\x10" + "\x34\x5e\x0a\xe9\xc7\x54\x0a\x89" + + "\xf4\xca\x02\x1c\x42\xb4\x2b\xa6" + "\x5a\x7b\x62\xdb\x1d\x48\x74\x6a" + "\x2d\xf5\x6b\x2c\xf6\x25\x56\x1d" + "\xa0\x46\xb2\x73\x4c\xfd\xc5\x1f" + "\x3d\x81\x31\x17\x62\xfc\x6d\x3f" + "\xbe\x54\x88\xe5\x79\xdf\x22\x83" + "\xe4\x2e\x8b\xfa\xb2\x38\x14\xe5" + "\xa0\xcd\x4a\x2d\x48\x78\x73\xbe" + + "\x07\x18\xac\x40\x66\x95\x35\xc5" + "\x1e\x0b\xda\x84\x66\xe5\xc1\xd4" + "\x21\x24\xb8\xe0\x97\x3f\xb3\xc4" + "\x00\xbe\x41\x7b\x17\x23\xbd\xd0" + "\xe1\x72\x7b\x14\x2e\xb4\xa4\x53" + "\x4c\x10\x77\xf7\x5f\x9f\xd3\xf8" + "\x0d\x53\xfb\xd3\x64\x4e\xe6\x36" + "\xdd\x4f\x07\x56\x67\xba\xa6\xa7" + + "\x71\x7c\xca\x1e\xe3\x8f\x65\x1b" + "\xb8\xda\xad\xe4\x14\x52\x94\x20" + "\x99\xc2\xf9\x11\x3f\x5d\x4e\x7d" + "\x04\x50\x84\x2f\xe7\x2a\xf6\xd7" + "\x92\x1e\x2a\xe2\x6a\x6d\x7e\x41" + "\x41\x71\x4c\xca\x85\x7f\xb6\x1a" + "\xed\xb5\x9a\x27\xc0\xd9\xb2\x44" + "\x11\xce\x57\xfa\xb8\xf0\x0b\x2d" + + "\xb1\x01\x6d\x4f\xdb\x18\x57\x40" + "\xa0\xe8\x11\x8f\xc2\x6b\x3c\xe7" + "\x3b\x1a\x59\xa0\x8c\xbb\x11\xac" + "\x31\x45\xcc\x0a\x5a\x9a\xd0\x12" + "\xf4\x13\xde\xe7\xee\x74\xf1\xcb" + "\x82\xd6\x4f\x04\xe6\x2b\x7e\x17" + "\x70\xaf\x48\x1c\xcb\x74\xf5\x65" + "\x7c\xcb\x61\x99\x92\x66\x59\xce" + + "\xe9\xba\xf6\x10\xfc\x6b\x83\x64" + "\x08\x76\x08\x0a\x6e\x61\xd5\x6b" + "\x07\x78\x0b\x2f\x63\xc4\xd5\xcf" + "\x78\x85\xa0\x61\x12\x27\x68\x05" + "\xcd\x2c\x0f\x63\x77\x37\x30\x30" + "\x40\xab\xe2\xc2\x32\xa7\xfd\x9e" + "\x92\x95\x0f\x6b\xc5\xb1\x95\xca" + "\xd8\xf2\xf2\xd0\x3e\xb2\x8f\xf7" + + "\x9f\xab\x6f\xbc\x4e\xe8\x9f\x98" + "\x74\x64\x0f\xc8\xb1\xe6\x0c\xe7" + "\xbc\xa1\x02\x3b\x05\xf3\x9f\xbe" + "\xd3\xaf\xc0\x99\x66\x48\xef\x12" + "\x26\x1a\x41\xe3\xf9\x57\xd9\x22" + "\x98\x5b\x48\x7b\x81\xd8\x41\x0b" + "\x19\x01\xe2\x4a\xd0\x56\x0e\x82" + "\xe0\x28\x85\x32\x1f\xd0\xe3\x81" + + "\x8a\x7c\x82\xbe\x77\xd4\x7d\xd4" + "\x4d\xe4\x10\xec\xe7\x69\x4a\xee" + "\x7c\xd7\x0e\x13\x38\x60\x23\xaf" + "\xf0\x65\x4c\x80\xce\x5c\x04\xf2" + "\xdb\x70\x4b\x2a\x03\x19\x87\xfb" + "\xf5\x9f\x3c\xb3\xcc\xb3\x36\xff" + "\x3d\x78\xd2\x1f\xe6\xf2\x37\x4c" + "\xd6\x71\x00\x91\xde\x7e\x11\xe5" + + "\xa1\x52\x87\x04\x6c\xed\x9e\xc5" + "\xb4\x41\x13\xa0\x2e\x70\xf2\x41" + "\x92\xb0\xc6\x9d\x3b\x90\x35\x6e" + "\x23\x5b\x5b\x1f\xa8\xab\x91\x42" + "\x1d\xd6\x53\xa6\x70\xaa\x73\x81" + "\x1e\xb5\x2e\x4f\xd4\x48\xb6\xd1" + "\x8f\x3f\xb9\x5a\x06\xce\xb7\x31" + "\xfe\xf4\xe2\x99\xee\x08\x54\xa5" + + "\x04\x44\xdc\xda\x8b\xfa\xc4\x1b" + "\xe3\x2e\xa1\xda\x34\x95\xdb\x0e" + "\x9c\x28\xf7\xa5\xb6\x81\x44\x08" + "\xd2\xb3\x8f\x9d\x1d\x46\x42\x7f" + "\x70\x3c\x29\x12\x32\x1d\x3f\xf9" + "\xa3\x3e\xb7\x6b\x59\x06\x47\xc1" + "\xad\x9c\x33\xde\xaf\x34\x08\xf8" + "\x53\x29\xf2\x81\x00\xfc\xdc\x99" + + "\x60\x41\xe3\x85\x09\xed\xa4\x1f" + "\xe2\xcd\x03\x7a\xc3\x7d\x6d\xa2" + "\x2d\xdf\x84\xfa\x48\x08\xac\x1d" + "\x08\x71\x69\x1b\xd6\x28\x9a\x5e" + "\xa1\x0e\xea\x14\xd9\x04\x80\xa8" + "\x20\x55\xfe\x3f\x28\x54\xd1\xa8" + "\x9c\x13\x9b\x63\xae\x2d\x42\x4f" + "\x61\xa8\xb5\xd4\x0d\xcc\xdc\xee" + + "\xcd\x8e\x74\xd7\x36\x16\x1d\x54" + "\x2e\x5c\x86\x7b\xf0\xab\x5a\x38" + "\x31\xe4\xdc\xe1\xec\xf9\xc2\xd2" + "\x52\xe0\x95\x8b\x25\x03\x16\xff" + "\x7a\x07\x33\x7a\x3f\x4c\xde\x0c" + "\x97\x1f\xe4\x12\x56\xdd\x5b\x67" + "\xf1\xa6\xf5\x71\xae\x81\x51\xc3" + "\xf8\x3e\x75\xae\xc8\x00\x56\xd5" + + "\xb4\x62\xe7\x8b\x4f\x62\x3e\xb3" + "\x13\x34\x8e\x05\xd1\xe4\x9e\x2a" + "\xfa\x05\xd8\x67\x69\x63\x8e\x96" + "\xd7\xbf\xb8\x7d\x9b\x94\x48\x98" + "\x17\x84\x3a\xd2\xe5\xd7\x08\x53" + "\xa5\x9d\xe2\xf3\x1d\x3b\x2f\x89" + "\x1f\x47\xee\x3d\x9e\x13\x5c\xc9" + "\x89\xe0\x57\xd7\x4d\x59\x31\x86" + + + "\x15\x56\x09\x1f\xea\xe2\x83\x10" + "\x33\x8c\xe6\x14\x77\xad\x28\x0a" + "\xbe\x18\x88\x3d\x52\x02\xfc\x6b" + "\xcd\x50\x58\xf3\x3a\x11\x85\xb5" + "\xa1\x8a\xdf\x30\x0b\x5f\x93\x7d" + "\xac\xe3\xb7\x4a\x7c\xa0\xdd\xad" + "\xcb\x00\x2f\x55\x99\x42\xc3\x92" + "\x6c\xdf\x09\x29\xde\xd1\x3e\xc3" + + "\x3c\x11\x07\x3e\x48\x0d\xc4\x2d" + "\xae\x63\x8b\x7d\x39\x5d\x4a\x6e" + "\x2b\x4c\x68\x79\x4b\xa9\x82\x55" + "\x6c\xa2\x2d\x62\xd4\x33\x2b\x93" + "\x8d\xf0\xbb\x0d\x51\xf6\x34\xf5" + "\x52\x3a\xc2\x64\xc9\x07\x1d\x21" + "\x9b\xdc\x5b\xee\x0f\xce\xee\x0e" + "\x58\x55\x01\xf7\x68\x81\x17\xdf" + + "\x0e\xd6\xcd\x83\x5a\x90\xe7\xab" + "\x84\x01\x17\xa1\xb5\x2f\x60\x50" + "\x2a\x64\x23\xb0\xcd\x86\x98\x68" + "\x00\xfb\xe1\xa6\x90\xd0\x68\xd5" + "\x7f\x21\x59\x02\xc7\x22\x19\x5b" + "\xe4\x41\x31\xc4\xd9\x1c\x83\x93" + "\x6e\xf8\x95\x0c\x87\x35\xca\xdf" + "\x28\xe8\x8a\x56\x7a\x05\xc2\xde" + + "\x6d\xc1\x3c\x91\x25\x89\x8f\x56" + "\x5a\x6f\xa2\xe1\x6d\x5b\xbc\x18" + "\xae\x99\xf4\xf5\xbe\x13\xa4\xdf" + "\x84\xae\xf0\xc3\xec\x5d\x83\xf8" + "\xb0\x0a\xa4\x65\xd8\x0b\xe6\xb6" + "\x7e\x37\x4b\x19\x39\x64\x59\x65" + "\x69\x4a\x08\x92\x25\x56\xd8\xbc" + "\xe0\xed\x23\x4f\xb9\x33\xe4\x5c" + + "\x89\x61\xe0\x42\x3d\x52\x0d\x86" + "\x13\xff\x3a\x4e\x41\x79\x07\xbf" + "\x50\x06\xb2\xc1\xca\x6d\x61\x0b" + "\x0d\x30\x31\x21\xd1\xd6\x6d\xe6" + "\xde\xab\x99\xff\x67\xfd\xa0\xd4" + "\x0d\xc5\xaa\xc7\x50\x35\x90\xc9" + "\xd7\xb2\x46\x7c\x8b\xcf\x2e\x02" + "\xaf\x92\xbf\x3a\xe8\xb1\x33\x33" + + "\x5d\x36\xd6\x84\xe7\x65\xda\xc0" + "\xb8\x9f\x75\x8f\x3f\x44\xb7\xbc" + "\x30\x19\xe8\x7a\xb1\x12\xc7\x35" + "\xab\x08\x6e\x4c\xff\x8d\x42\x80" + "\x43\xf8\xfa\xa4\xef\xaf\x9d\xf1" + "\x5f\x85\xa9\xff\x8d\x53\xd8\xce" + "\xce\xc7\x3a\xbe\x9c\x40\xac\x20" + "\x1e\xa7\x2d\x88\xb6\x1f\x8c\x35" + + "\x82\xa5\x42\xbe\xf7\xde\xec\xef" + "\xe6\x6b\x04\x65\x80\x60\xfc\xd3" + "\xa9\xdb\xe8\x09\xc8\x13\xaf\xc9" + "\xff\x91\x14\x64\x47\x98\x6c\x1e" + "\xf7\x31\x0c\xd3\x25\x49\x57\x3b" + "\x22\x21\x2a\xac\xba\x72\xeb\xb7" + "\xe7\x59\x08\xef\xac\x0d\x6a\x77" + "\x42\x09\x90\x21\x14\xc3\xfe\x06" + + "\x2b\x12\x50\x7e\xb0\x94\x47\x32" + "\xa5\x7c\xf0\x4a\x8b\x4f\x74\xdd" + "\x7b\xc9\x3f\xd6\x08\x2f\xa1\x30" + "\x9d\x6d\x62\x76\x1a\x0f\x65\x39" + "\x77\x84\xa3\x1f\xf7\x47\x1b\x10" + "\x4f\x12\xdc\xd4\x19\x5f\x81\x3d" + "\x8a\xb5\x6e\xb2\x95\xae\x69\x15" + "\x87\x18\xfb\x95\x88\xe1\xcd\xc3" + + "\x21\x7f\x73\xf4\xbb\x2f\xc6\x7e" + "\xac\xf5\x09\x62\xab\xa5\xdb\xd8" + "\xbe\xad\xf9\xa5\xa9\xd7\xb5\x24" + "\x68\xc7\x1d\xa6\xf7\x28\x7d\x70" + "\xea\x99\xa9\xca\x0b\x46\x11\x77" + "\xcc\xe4\x92\x1c\x4d\x17\x7b\xba" + "\x2d\xbf\xd4\x18\x66\xab\x4b\x3c" + "\x79\xd2\x8b\xeb\x80\xc9\xf0\xb8" + + "\xbf\x91\x06\x79\x32\x89\x65\x9d" + "\xae\x36\xb7\x06\x89\x05\x61\xed" + "\x6e\x3b\xd6\xc0\x04\x2f\x2c\x71" + "\x8f\x48\x3d\xc6\xd5\x6f\xf0\x5c" + "\x41\x8e\x58\xd9\xac\x3f\x36\x97" + "\x7e\x25\x93\x2b\x62\xf7\x9b\x1f" + "\xce\xca\x7a\x66\xc4\xff\xd1\xa9" + "\xcf\x1e\x06\x0a\xaa\xa1\xf4\x1c" + + "\x23\x9a\x51\xc0\xb2\x75\xd6\x28" + "\xe3\x52\x69\x4f\xfe\x94\xbf\x9e" + "\x8a\x4a\x29\xa2\x67\xb7\x8b\xf2" + "\xf5\xf3\x0a\xfe\x4d\x2b\x51\x85" + "\x0d\x6a\xb1\x99\xa8\x8b\x95\x18" + "\xa7\x48\x75\xba\x0c\x43\xc2\x95" + "\x15\xe6\x6b\xa1\x10\x1b\x0d\xb3" + "\x4c\xb7\xbf\x85\x97\xbb\xeb\xe3" + + "\x45\x36\xe6\xb2\x5e\x3f\xb5\x07" + "\x32\x42\xc8\x84\x47\xe5\x57\xbe" + "\xcf\xd5\x14\x72\x16\xc2\x79\xd7" + "\xca\x3a\x9a\x02\xcd\x69\x79\x61" + "\xa0\x17\x70\x8a\xcd\x68\x76\xd1" + "\xe8\x7e\x9b\xbe\x9a\xd1\xb4\x77" + "\x76\x17\x16\x9c\x93\x0e\xfd\x58" + "\x72\x8a\x96\xd5\xef\xf4\xc4\xa8" + + "\x23\xca\xfd\xd2\x65\xb8\xee\x81" + "\x95\xf8\x8e\xcc\x08\xee\x15\x5a" + "\x14\x56\x90\x01\x0a\xa1\x8f\x76" + "\x9b\xe1\x0e\x88\xef\xb8\xf5\xef" + "\x0e\x8a\x1c\xcb\xbb\xca\xc0\xf0" + "\xf9\x38\xc8\xb8\xcd\xe9\x1e\x2e" + "\xc0\x14\x4a\x8a\xb8\xd8\x87\x05" + "\xe5\x98\xf6\x2f\x96\x78\xf2\xf6" + + "\x80\xda\x44\xbf\xb3\x34\x9d\x51" + "\x66\x2e\xb3\x5a\xf9\x34\x38\x28" + "\x00\xa0\x78\x62\x97\x87\x60\x6e" + "\xf6\x12\x73\x62\x0e\x96\x62\x1e" + "\x55\x1c\x90\xe6\x7b\xb2\x87\x9b" + "\x1f\xbc\xfd\x24\x38\x85\xe7\x80" + "\x7d\xc2\xac\x2f\x51\x09\xbc\xbb" + "\x5a\x3b\x14\xac\x39\x42\x39\x06" + + "\x99\xce\x2f\x9e\x6e\x64\x4b\x9c" + "\x7f\x85\x80\x1e\x81\x10\xa2\x68" + "\x2a\xb5\x43\x36\x44\x4e\xd5\x06" + "\x43\xb8\x8e\x0d\x63\x6d\x8d\xde" + "\x0a\x6a\x14\x42\x63\x15\x32\x70" + "\x22\x36\xaa\x5e\xf2\x26\xa8\x8b" + "\x87\x87\x13\x86\xbd\x58\x7a\x22" + "\x37\x1d\x28\x10\x3c\xc0\xb6\x43" + + "\xff\xde\x41\x2f\x95\x7a\xb3\x02" + "\xb7\x89\x3b\xe6\x9a\xa5\x44\x0e" + "\x51\xf9\x3f\x14\xdc\x57\x32\x67" + "\xf4\xba\x52\xd7\x05\x22\xc0\x19" + "\x92\xd6\xb7\xc4\x69\x30\xc2\x46" + "\xac\x02\x15\xfd\xc3\x92\x63\x2e" + "\x46\x08\x22\x1b\xa2\xb1\x57\x60" + "\x63\x5b\x1b\x0c\x46\xf9\x1f\xe5" + + "\xf0\xc0\x2f\xf0\x32\x26\xca\x7a" + "\x86\x1c\xf0\xc7\x7d\x33\x2b\xb9" + "\x7d\xdc\xfb\x5a\xbf\xc4\x4b\x62" + "\x5e\x1a\xe2\x4d\xbc\x07\x2b\x81" + "\xcc\x90\x20\x0b\x24\x37\xd1\x29" + "\x32\x21\x1b\x5a\x09\xc5\x03\x04" + "\x15\xe0\x35\x0e\xd5\x34\xca\x1d" + "\x6f\xb6\xbb\x3b\x7d\xed\x85\xf0" + + "\x35\x57\xae\x2e\x86\x66\xc8\xbe" + "\x3e\xf0\xb6\xf9\xf2\x01\x05\x58" + "\xc2\x74\x0e\x99\x63\x20\xff\x8b" + "\x40\xc8\x40\x9f\x3d\x4e\xdc\xfa" + "\x2a\x6f\xeb\x32\xa0\xd3\x57\x03" + "\x8a\xc9\xf1\x0d\x2e\xb2\x18\xe3" + "\x38\xdd\x2a\x50\x8d\x2d\x9a\xbb" + "\x6a\xce\x84\x4a\x7a\x95\x7e\x6f" + + "\x65\xe8\x81\xf7\xf9\x98\x7b\xc2" + "\x45\x13\x4e\x99\x92\xf6\xe1\x51" + "\xee\x61\x93\xe1\x16\xd5\x07\x08" + "\xef\x8a\x99\xfb\xef\x5c\x88\x13" + "\x17\x8a\x0f\x2f\xe9\xd5\x23\xd2" + "\x80\x02\xd2\xe8\x10\x20\x67\x48" + "\x98\xac\x7e\x23\x60\xfd\x02\x6f" + "\xe7\x7e\xda\x9a\xad\xbf\x51\xcc" + + "\x48\x36\x1f\x3d\x67\x8d\xe7\x0b" + "\x44\x26\xf8\x26\xbf\xae\x70\xb1" + "\xf5\xa6\xaa\x11\xaf\xb5\x88\x9d" + "\xb2\x0e\x93\x40\xb2\x4e\x44\x57" + "\x06\x29\xd9\x4a\x76\x4a\x96\xd0" + "\x5f\x7e\xf8\xbf\xe3\x5d\xa0\x4c" + "\x84\x90\x86\x0b\xc8\xa6\x41\x11" + "\x8d\x94\xda\x4a\xa3\xfc\x83\x31" + + "\x1d\x70\x09\x1e\xdd\xbc\x56\x27" + "\x80\x5c\xd4\x90\xb9\x1d\xe3\x94" + "\x84\xe5\x66\x85\xa9\x56\xe8\xb9" + "\xf3\xe3\x10\xab\xde\xd9\x87\x4f" + "\xb2\x9c\xed\x3d\x37\xcb\x6e\x16" + "\x3e\x3d\x65\x3f\x07\xc7\x14\xfd" + "\x25\xc4\xae\x92\x9b\x04\x5d\x10" + "\x11\x2e\xa4\x09\x49\x7e\x65\x7f" + + "\xa1\x09\xd6\xa5\x9b\xa3\x80\xc3" + "\xcb\x0e\xc1\x24\x77\x1e\x71\x6c" + "\x70\xd0\x22\xb9\xc6\x3c\xd5\xe8" + "\x84\x7d\xb5\x0a\x81\x7b\xc3\xea" + "\xa7\xca\x70\xa7\x78\xc9\x60\xe2" + "\xb5\xf4\x71\xaa\x29\x61\xf2\xdb" + "\x30\x8e\x9a\x48\xb6\xd9\xee\xe2" + "\xfe\x75\x3f\xeb\x7f\xd2\x8f\x48" + + "\x94\x95\x15\x6a\x07\x90\x64\xea" + "\x52\xce\x97\x1f\x6b\x4d\x42\x3e" + "\xcb\x8c\x5e\x18\x0a\xf3\x6d\xac" + "\xbf\x47\x77\x51\x80\xec\x56\xad" + "\x93\xfe\x91\x43\xcf\x5c\x93\xf0" + "\x40\x1d\x81\x03\x0f\x26\x6b\x86" + "\xbe\x9a\x7b\x9f\xb9\x47\x20\x79" + "\x84\x2d\xe4\x8e\xc8\x0b\x60\xb1" + + "\x23\x71\xa3\x7c\x92\x45\x58\xdd" + "\xd5\xbd\x8b\x08\x11\x13\x3f\x90" + "\x2e\x27\xc2\xa2\x65\xcf\xde\xdc" + "\xe0\x6f\x1f\xd6\x26\x6e\x35\x9e" + "\xc0\x0d\x48\x54\x9d\x9f\xad\xee" + "\x5a\xbe\x46\x14\x40\xa1\xca\x91" + "\xd1\x75\xc0\xc4\x8d\xcc\x66\x9c" + "\xb8\xc9\x85\xbc\x62\x9a\x52\x5e" + + "\x5f\xa8\x68\x77\xdb\xb3\x97\x2d" + "\x38\xe0\x87\x42\x33\xf6\x78\x2b" + "\xb1\x2b\x89\x6f\x67\x47\xc9\x86" + "\x00\xc2\xa9\xc0\x1a\xfb\x0b\x92" + "\xb2\x41\x20\x33\xec\xf6\x92\x42" + "\x54\x9d\x98\xc9\x37\xb9\x0b\xa3" + "\x9e\x87\xd5\xc6\xeb\x41\xf9\x39" + "\x87\xb1\xdb\xdf\xfc\x50\xa4\x76" + + "\x90\xa8\x29\x9c\xc3\x93\xb7\x5f" + "\xb1\x11\xa8\x87\xfd\x3b\xa0\xb0" + "\xd3\x28\xf1\x12\x49\x9e\x24\xb0" + "\xde\x3e\xed\x5a\x13\x3a\x7b\x10" + "\x32\xd9\x34\x20\x56\x99\xe1\x98" + "\x1c\xd7\xc7\x0d\x71\xc7\xce\xd8" + "\xb2\xe0\x31\xb2\x13\x37\x56\xe7" + "\x02\x8c\x96\xac\x85\xd2\x84\x62" + + "\xb6\x0d\x43\xee\x89\x60\x25\x31" + "\x56\x6f\x83\xf6\xd8\x9b\xce\xae" + "\x46\xa0\x85\xfb\x4b\xfc\x4c\x48" + "\xb9\xb2\x99\x15\x2c\x3e\x1e\xee" + "\xaf\x2e\x12\x3d\x90\x38\x3c\x7e" + "\x6c\x55\x70\xc7\xe0\x0c\x94\xaa" + "\xe8\xfa\x08\x1b\x63\xd6\x02\x48" + "\xba\xf8\x69\x7f\x80\x85\x8a\xb0" + + "\xae\x1e\x41\x05\x04\x0a\xed\x70" + "\x66\x4c\x49\x16\x8f\xb0\xde\x60" + "\xbb\x97\x37\x13\xc6\x0f\xf2\x8c" + "\x10\xc3\x6b\x0c\xf5\xf4\x30\x3e" + "\xc7\x46\x9c\x74\x29\x7c\x67\x1a" + "\x1c\x98\x1e\xf1\xf4\x93\x1d\xfe" + "\x8b\x68\x3e\x2e\xd8\x03\x73\x93" + "\x85\x9e\xaa\xa6\xa7\xf5\xae\x01" + + "\x20\xb9\x59\xb9\x95\xf4\x02\x49" + "\x85\xd8\xa2\xfc\xbd\xfd\xb0\x13" + "\xfa\xf0\xa2\xb6\xe7\xd9\xcb\x41" + "\x87\x0b\x43\x56\x10\xf1\xbd\xf9" + "\xb9\x19\x4d\x95\x23\xa2\x05\xd7" + "\xde\x4f\x2a\x97\x5c\xfc\xd0\x74" + "\xea\x77\x29\x91\xd6\xfe\xcb\xcb" + "\xaf\xa5\x59\xcc\xfd\x11\x06\x87" + + "\x57\x2f\x30\xbb\xab\x19\x72\xba" + "\x30\x27\xb3\xfa\x59\x00\xce\x28" + "\x22\x43\xf5\xa8\xa0\xdc\x26\xfd" + "\xcf\xbd\x6b\xb2\x6b\x0d\xa9\x69" + "\x8b\x63\x49\x89\xbc\xd3\x5d\xe9" + "\x2d\x6a\x2b\x92\xf1\xa4\xe1\x76" + "\xfd\x2c\x87\xd5\xb1\x3c\xf7\x99" + "\xce\xa3\x32\xdb\x9a\x14\x2b\x75" + + "\x6a\x23\x89\x40\xd0\x9b\xf1\xf4" + "\x0b\x0e\x3d\x31\x12\x6c\x20\x3b" + "\xb2\xae\xfe\x03\xf3\x0d\xe7\x73" + "\xe0\xef\xd1\x9b\xeb\xa0\xdb\x09" + "\x05\x53\x4e\xfc\x32\xd5\x7f\x4c" + "\x7a\x78\x3d\xe9\xed\xff\x92\xd7" + "\x10\x50\x24\xe4\xe2\xc4\x2d\xc7" + "\xbd\xbb\x66\x04\x7d\xd4\xe0\xe7" + + "\x43\x5c\x6c\x56\x51\xcb\x85\x6e" + "\x46\xf0\x97\x35\x19\xc9\xf9\xcf" + "\x4a\xd9\x94\x49\x0c\xe9\x54\x93" + "\x7d\x92\x47\x21\x32\x93\xa3\xe0" + "\x2b\xeb\xc1\x0d\xc1\xfa\x27\x84" + "\xfa\x19\xf3\x2f\xc2\xd8\xcf\x88" + "\x74\x52\x96\x01\x84\xe6\xd4\xe2" + "\x46\xa7\xaa\x67\x7d\x06\x2e\xfa" + + + "\x11\x9f\x5f\x3e\x7f\x2a\xd9\xb6" + "\x8e\x3b\xcb\xd6\x3a\x15\xfe\x9a" + "\xbd\x00\xf8\xdd\xd7\x6d\x1a\x4d" + "\x19\x7e\xf1\xca\xc0\x3c\xc1\xf6" + "\xee\xc3\x5f\x32\x8e\xc5\xf6\x15" + "\xb2\xc3\x1d\xa3\x00\x54\x09\x71" + "\xe7\xd3\xa3\xaf\x07\x7c\x8e\x16" + "\x2d\xae\xc7\x94\xa1\x17\x84\x3f" + + "\xc3\x40\x95\x31\x9b\x58\x42\x28" + "\xf8\xd6\x83\xa2\x59\x0f\x49\x18" + "\xcb\x9f\xae\xda\x84\x1f\x73\xa2" + "\xa0\x3b\x68\xc3\x60\xd9\xb6\x3d" + "\x69\x10\x61\x14\xbb\x63\x5c\xc8" + "\x05\xbf\x88\x07\xaf\x36\x94\xb1" + "\xd2\x60\x74\x34\xdf\x59\x54\x90" + "\xb1\x7d\x1a\xe1\x94\xe0\xf6\x73" + + "\x38\x9c\x1b\xc3\x91\xbb\x85\x7b" + "\xb5\x57\xef\x48\x0b\xa9\x5a\x0c" + "\x6f\xab\x3b\xaf\x69\xb1\xde\xde" + "\x85\x36\x37\x2d\x73\xad\x10\xe6" + "\x15\x8e\xba\x02\xdf\x70\x38\xf1" + "\x71\xf7\xa7\x8c\xb6\xed\x37\x03" + "\x6c\x03\x2c\xb6\x47\xf7\xac\xe4" + "\x81\x4e\xb9\xb6\x76\xd5\x21\xd9" + + "\xcb\x76\x3c\xee\xc8\xa3\x06\xf3" + "\x6e\x1f\x2a\xd3\x23\x16\xf1\x3c" + "\x56\xe9\x63\x68\x64\xab\xd5\xe6" + "\x26\x5c\x00\x5c\xbe\x4c\x8a\x3b" + "\x27\xbb\xe6\x9c\xa5\x29\xd5\xdc" + "\x6f\xb1\xd4\x04\x52\xaa\xaf\xc4" + "\x8d\x79\x23\x79\x26\x4a\x62\xb0" + "\xab\x7f\x30\x6b\xf6\x6d\xe5\x85" + + "\x14\xd6\x9d\x85\x34\x53\x3e\x3a" + "\xee\xc8\xd0\x18\x5b\x5b\x47\x9c" + "\xd5\x51\xcd\x07\x1f\x0d\x08\x63" + "\x26\x43\x8b\xb8\xa6\xd0\xc0\xc9" + "\x6f\x29\x34\xc2\x91\x86\xc9\x1a" + "\xb6\x7f\x88\x94\xa4\x83\x0a\x2a" + "\xf2\x9c\xea\x0c\x27\x14\x51\x56" + "\xf5\x02\x48\xa2\xe8\xa6\x30\x52" + + "\xaf\x13\xe9\xbc\x3d\xc7\x0f\xad" + "\xcb\x07\x8a\x45\x7b\x58\x9e\x90" + "\x8a\x0c\xf0\xd4\x84\xda\x00\x13" + "\xac\x66\x44\xb5\x48\xd0\x5c\x42" + "\xbf\xd8\xe9\x90\xbe\xb9\x9c\xb5" + "\x0e\x1b\x43\x3e\xdb\x16\x16\x99" + "\xff\xec\x1a\x53\x7a\x11\xaa\xd3" + "\x3b\xdc\xf4\x59\xd3\x92\xaf\x91" + + "\x36\x5c\x44\x20\x07\xe2\x3e\x7a" + "\x74\x71\x87\x59\x82\xac\xd1\x71" + "\xe9\x73\x9f\x94\xf7\x39\xc5\x0f" + "\x81\x30\x2e\x98\xd7\xf3\x5c\xd0" + "\x29\x71\x1c\x7b\x0b\xe2\x58\x87" + "\xf2\x61\x9e\x56\x20\xcc\xad\xff" + "\x2d\x4c\x54\x59\x2f\x3a\x5d\xb0" + "\x53\x5e\xff\x9f\xc1\xf5\x16\xbe" + + "\x63\xa4\x4c\x4e\xef\x0f\x33\xb2" + "\x63\xcc\x66\x35\x87\x72\xef\xbc" + "\x00\x09\x78\xcf\xca\xd2\x61\xd1" + "\x7d\x82\x54\x5b\x39\xc5\x5d\x13" + "\xc6\x1b\xbf\x27\x2e\x05\x8f\x63" + "\x6c\xa0\xdf\x07\xf0\x24\xa2\x10" + "\xda\x21\x33\x6d\x6d\x58\x73\xe9" + "\x8f\x2c\x15\x26\x38\x57\x0c\x8b" + + "\x98\x60\x55\xb9\x8b\x17\x43\x70" + "\x86\x38\x1c\x80\xdf\xa1\x90\x40" + "\x12\xb9\x67\x9b\xff\x00\x98\x75" + "\xc8\x20\x26\x23\x04\x03\x5c\x3e" + "\xca\xee\xdc\x70\x4b\x3c\x9d\x4b" + "\x8e\x64\x1f\x18\x15\x3c\x2d\xbb" + "\x5c\x34\x33\x6e\x37\xd8\x81\xf9" + "\x7a\x29\xf2\x0c\x9b\x28\x26\xb6" + + "\x0f\x5e\xbe\x32\xbd\x4c\xc7\x9d" + "\x75\x13\xa0\x17\xb7\xbc\x75\x74" + "\xb1\x72\xd8\x50\xc9\x77\x84\x43" + "\x3d\xd6\xe1\xff\x79\x78\xc6\xce" + "\x70\x8c\x57\xd8\x14\x60\x00\x9b" + "\x8b\x6b\xbb\x78\xa8\x99\xad\xc9" + "\x06\x38\xfb\x11\x8e\x00\x99\x67" + "\xb3\xca\x44\xcd\x35\x14\xe8\xcf" + + "\xe4\xd2\xf2\x9e\xc1\xfe\x3f\x11" + "\x7f\xea\xa0\xd5\x7e\x76\xf6\x1b" + "\x0a\x4c\x71\x03\x5e\xf7\xff\x57" + "\xee\xe9\x23\x0a\x2e\x42\x3c\xa2" + "\xaf\x83\x0f\x54\x2d\x6b\x5f\xdd" + "\xa7\x46\xea\x55\x7e\xc2\xc2\xc2" + "\x08\x12\x2a\x67\x46\x42\x6b\xeb" + "\x7a\x4f\x63\xae\xf7\x99\x35\xd1" + + "\xf7\xaa\x84\x98\x95\x95\x68\x89" + "\xa6\x48\xb3\x07\xe3\x9b\x95\xb1" + "\x87\x7c\x14\x3c\x57\x0e\x25\x96" + "\xf8\x61\x0c\xdd\x3a\xfb\x0e\xae" + "\x5e\x32\x8c\xca\x5e\x74\x00\xed" + "\x70\x3f\xff\xec\x96\x16\x91\x3c" + "\x1d\xd4\x9a\x31\x65\xbc\xac\x73" + "\xef\xc7\xb1\xf0\x20\xa0\x01\x7b" + + "\x6e\x04\x79\x9d\x0d\x79\x89\xaf" + "\x76\x09\xee\x6c\x2d\x0f\x65\x4d" + "\xca\x1e\x07\x43\x9a\x5d\x93\xa3" + "\xfe\x0b\x3b\x28\xc9\xd2\xfc\x66" + "\xf1\x05\x66\x69\xb5\x5e\x66\x0e" + "\x8d\xd3\x4c\xa5\x07\x5d\x7e\xe7" + "\xcf\x50\xd9\x43\x0a\x05\xee\x90" + "\xb5\x69\x2e\xd3\xda\xeb\xdd\x86" + + "\xe8\x31\x86\x3a\x9b\xb8\xed\xd2" + "\x46\x37\x21\x7a\xde\x55\xe8\x8d" + "\x11\x5f\x0c\xb0\xb7\x6c\x05\xb2" + "\xe4\x85\x9b\x2c\xd0\xfb\xae\xde" + "\x2d\x89\x50\xd1\x8d\x9a\xf3\x03" + "\x85\x79\x8b\x21\x86\x46\xb8\x37" + "\x1a\x5f\x37\xb7\xd8\x6d\x29\x36" + "\x8e\x89\x8e\xb7\xb1\xd4\x2c\x47" + + "\x93\xbd\x8f\x30\x53\xae\x45\xeb" + "\xda\x6f\xc3\x02\x2e\x5a\xcd\x46" + "\x85\x83\xa4\xba\x90\x4e\x3d\x6a" + "\x60\x99\xbe\x9d\x2e\xe6\x55\xdd" + "\xe7\xed\x81\x2a\xa0\x6a\x40\xa1" + "\xa7\x4e\x27\xf9\x14\xdd\x60\x68" + "\x86\x4f\x41\x80\xc2\xb0\xdc\xcf" + "\x27\x43\xf9\x22\x10\x0b\x41\xff" + + "\x96\xd8\xa5\x23\x6b\xba\x10\x99" + "\x4e\x36\xe4\x7f\x35\x9e\xe1\x1f" + "\x77\xc6\x33\x9a\xc3\xa8\x1d\x6e" + "\xd0\x9f\xfd\x29\x8b\x48\xb4\x15" + "\xbf\x22\x1f\x1a\x54\x92\x43\x1f" + "\xe8\x63\x81\xab\x70\x8a\x0a\x92" + "\x8e\x65\xe5\x07\x49\xb2\xd1\x3f" + "\x9b\x83\xec\xb6\x9c\xf7\xc4\xf2" + + "\x84\x3f\x4a\xb4\xe3\x5d\xd5\x17" + "\x90\xc6\xc6\x17\x44\xf3\xb2\xac" + "\x90\x23\x23\x10\x68\x81\x08\x32" + "\xf7\x3b\x73\x6c\x1f\xa6\xe8\xf2" + "\x52\x76\x2d\x9c\xb6\xaa\x74\xa7" + "\xbc\xc5\x95\xed\xe3\x07\x53\xfb" + "\x10\xf1\x81\x49\xc2\x73\x5c\xa0" + "\xc9\x58\x94\xa3\x1c\xe3\xaa\x1b" + + "\x8b\x2d\x5d\xc5\xbb\xb2\x1d\xce" + "\x56\xca\xf6\xf4\xb7\x8b\xd5\x41" + "\x14\x76\x87\x8f\x80\xb6\x50\x76" + "\xed\x49\xc3\xf4\xba\x16\x5e\x90" + "\xac\xac\x61\xf6\x40\x51\x41\xed" + "\xaf\x70\x22\xcb\xf0\x84\x87\x3b" + "\xba\x2c\x40\x8a\xac\x80\xc2\x3b" + "\x1a\x92\x37\x09\x46\x71\x3f\xd5" + + "\x30\x17\x34\x78\x6c\xd8\x1e\x7f" + "\x48\xe2\x25\xb5\xb8\xbe\xf5\x8e" + "\x38\xbf\x4f\xb7\xfd\x89\xc4\xbb" + "\x82\xb3\xa0\x91\x0e\x2a\xa9\x38" + "\xcf\x3c\x43\x22\x3f\xba\x77\x7a" + "\xa9\x05\x9f\xa2\xd6\x62\x83\xde" + "\xfc\x9a\x18\x61\xea\x30\x6a\x7f" + "\x4f\x11\xef\x59\x05\x55\x3b\x69" + + "\xdc\x08\x4c\x22\xb5\x43\x21\x26" + "\x91\x0c\xb5\x81\xb4\x09\xbb\x2b" + "\x4f\xc8\xa8\xac\x09\xd7\x6e\xc1" + "\xa8\x0c\x85\xb2\x9d\x0d\x21\xa6" + "\xd6\x54\xcb\x09\x7a\xf6\x8d\x6d" + "\xa4\x19\x09\x50\xe0\xf6\xee\x91" + "\x57\x28\x13\x0f\x81\x13\xf6\x90" + "\x8b\x02\xd5\xf8\x47\xde\xce\x9a" + + "\xb8\x06\xd8\xce\xa8\x2f\x1a\x07" + "\x78\x14\x7f\x69\x34\x61\x2e\x22" + "\xbf\xdb\xfc\xab\x5d\xfd\x16\xdc" + "\xb8\x53\x1b\x12\xbf\x2e\x91\x44" + "\x7c\xc2\x96\x24\x74\x36\x94\xac" + "\xb0\x26\xfc\x1f\x6c\x17\xa3\x8e" + "\x2c\xbf\xde\x13\xac\x24\xe2\xb6" + "\x32\xa8\x72\xf3\x35\xc2\x4c\x52" + + "\x2f\x96\x67\x35\x7d\x36\x98\x7e" + "\xfb\xbf\x88\x81\x1f\xd6\x9e\x37" + "\xa1\x30\xf1\xfa\x48\xa3\xbb\x73" + "\x34\xd7\x4e\x90\xe1\x75\x1f\x6c" + "\xfc\x79\x4a\x3b\x42\x66\x95\x18" + "\x93\x44\xef\x54\x3d\xc8\x0b\xf2" + "\xa1\xec\x11\x91\x5d\x42\x6d\x83" + "\xcf\x8d\x9a\x00\x18\xc3\xb5\xe5" + + "\x34\xd5\x85\xda\xbd\xa5\x71\x27" + "\xea\x0e\x98\xff\x1f\x8c\xe7\x53" + "\xe7\x85\x03\x90\x84\xcf\xf1\xad" + "\x62\x7b\x38\xc9\xf6\x14\x3b\x7d" + "\xd2\x2b\x8f\xcb\xb0\x74\x0e\x17" + "\x93\xa9\x7f\x82\x86\xb4\x50\x2d" + "\xab\x2b\xf3\xf6\x9a\x8c\xbe\xcd" + "\xb8\x3a\xb9\xc3\xb0\x06\xe9\x55" + + "\xa5\xa6\x16\x14\x69\xa0\xce\x84" + "\x1c\x88\xef\x43\x79\x0c\x86\x8f" + "\x5d\x8a\x03\x38\x8a\x1f\x31\x41" + "\x67\x20\x61\xfc\xc0\x2e\x8c\xe7" + "\x81\x35\xd7\x5a\x81\x2e\x4d\x49" + "\x97\x40\x60\x59\x00\x9e\xcc\xb4" + "\xba\x2c\x61\xf3\xec\x8a\x55\xff" + "\x9e\xc3\x36\x9e\x7a\xef\xbe\x35" + + "\xee\x06\xba\x36\xcc\xc0\x4e\x32" + "\x0c\xcc\xd2\x3d\x15\x31\xce\xfa" + "\x1f\xe9\x33\xf3\xbe\xf3\x64\xb3" + "\xb0\x32\xe8\x28\x73\xff\x8a\xef" + "\x1b\x84\x05\x2d\x04\xad\x9b\x1e" + "\xe2\x21\x6a\x35\xdf\xe3\xf0\x42" + "\x7e\x62\xdd\x4a\xcb\x0b\x27\xa3" + "\x11\xe7\x22\xd3\x58\x81\x9a\xb0" + + "\x04\x6e\x92\x66\xcd\x8e\x3f\x32" + "\xba\xc1\x10\x81\x8f\xe3\x01\x00" + "\x07\x7f\x6a\xfc\x12\xac\xbc\x8d" + "\x27\x08\xec\x0c\x58\x1d\x5e\xd6" + "\x2d\xca\x76\xbe\x41\x41\xcd\xd2" + "\x3a\xf3\x92\xe8\x5c\xcf\x95\x78" + "\xd2\x39\x71\x36\x0d\x23\x6d\x95" + "\xc1\xc4\x12\xd0\x3e\xbd\x1a\xa9" + + "\x26\xd4\x95\x62\x9d\x77\xff\x28" + "\x7b\xad\xa3\x3f\xc7\x6a\x4f\x0c" + "\x04\x26\x8e\x8b\x54\xd0\x44\xec" + "\xe1\x50\x00\x8b\x6d\xa6\x32\x9b" + "\xe2\x6c\x47\xf0\x66\x33\x94\x1f" + "\xb4\xc7\x02\xa6\x53\xd9\x54\x75" + "\x09\x28\x4f\x52\xa6\xac\x35\xbe" + "\xea\xdb\x4e\xfd\x29\x12\x88\xb6" + + "\x29\x36\x67\xde\x46\x14\xe2\x45" + "\x21\x2d\x3c\x70\x1e\xaa\xf7\x57" + "\xc7\x68\xc8\x98\x7f\x9b\xe9\xa0" + "\x76\x16\x64\x8b\x6d\xf6\x42\x4e" + "\x96\x78\x07\x91\xdc\x84\x28\x60" + "\x5b\x88\xc9\xc2\xcf\x90\xd6\xa0" + "\x87\x51\x9a\x3b\x33\xda\xb4\xfe" + "\xee\x87\x3c\x15\x98\x95\x78\x5f" + + "\x90\x96\xf0\x15\xe7\xdc\x82\xb7" + "\xc9\x0f\xfc\x2d\x12\x9b\x8b\x50" + "\xc6\x9f\xd8\x65\x4b\xab\x15\x90" + "\x0f\xbb\xd5\xd6\xb7\xda\x79\x5e" + "\xa2\x5a\x77\x6c\xf0\x21\xf0\x64" + "\xa1\xec\xc7\x37\xcc\xd8\x09\xdf" + "\x06\xa5\x2f\xef\x67\x13\x76\x9a" + "\xc6\xee\x81\x5b\x76\xa4\x4c\xed" + + "\x7c\x86\xb0\x67\x19\x71\x83\x3b" + "\x20\x45\x36\x9d\x08\x0d\x5e\x8d" + "\xe3\xf0\x30\xd9\x1e\xcc\xdc\x52" + "\xaf\xbb\x20\xbf\xc7\xce\xbb\xef" + "\x10\xad\x63\x02\xab\xfc\xcf\x99" + "\x8a\x8f\xd1\xfc\x6d\x9e\x19\xd8" + "\x17\x06\xf1\xe9\x3f\x77\xe2\x64" + "\x48\x48\x70\x08\xe1\xe8\x79\x00" + + "\x2b\x34\x2f\x5c\x4d\xce\x9c\xbb" + "\xae\x7a\x2d\xb5\x7a\x90\x80\xbf" + "\xd0\xbc\x61\x21\xcd\xd3\xf3\x97" + "\x4d\x74\x62\x09\x34\x08\x5b\xb2" + "\xda\x1d\x3a\x6c\xa5\x8e\xb1\xc5" + "\x17\x23\xc9\x06\xeb\xc7\x4e\xfe" + "\xfe\x4a\x1c\xad\x90\xb8\x87\xb7" + "\x1a\x80\xde\x0e\x92\x9a\xcd\xdc" + + "\xe8\x7e\x49\x76\x9c\x61\x5c\x8b" + "\x0e\x37\x17\xc7\xc6\x0a\x2b\x5d" + "\xe1\x68\xcf\x4f\xb6\x4c\x20\x98" + "\x92\x67\xbc\x62\x11\xc2\xde\x0b" + "\x11\x10\x3b\xa6\xef\xcc\x73\x69" + "\xc5\x1a\xde\xe0\x97\xfa\xe3\xf9" + "\x8b\x0c\x0e\x3d\x3e\x69\xfb\x5e" + "\xb4\xfc\xd4\xd2\xe9\x48\x72\x03" + + + "\x9e\x4f\xc3\x1e\xc9\x2d\x80\x80" + "\x03\x06\x81\x33\x35\x2d\x77\xd8" + "\xf3\xb4\x0c\x53\x6c\xd6\x06\x3f" + "\x29\xc1\x75\xc4\x0d\xed\xe5\x7b" + "\x10\x2b\xe8\x31\x19\x3c\x9e\xcb" + "\x4c\x6b\xff\xc9\x57\x28\x3d\xc6" + "\x5e\xb4\xa1\x92\xc6\x18\x21\xb9" + "\xca\xbb\x85\x72\x14\x44\xec\x0a" + + "\xef\xa3\x29\x1e\xe7\x9a\x18\xfc" + "\x2e\x30\x93\x4c\xf0\x06\xe9\xcb" + "\x0e\xe1\xaa\xce\x14\x79\x10\xd0" + "\xf8\x19\x8e\xb6\x34\x3f\xa2\xb7" + "\x9d\x11\xd2\xef\xc2\x75\xd8\xe9" + "\xc8\xc9\xad\xfc\x6e\x8c\x19\x03" + "\x13\x71\xa1\x4d\xf6\x1b\x59\x65" + "\x38\x30\x44\x3d\xf8\xbb\xf0\x3c" + + "\x59\x47\x72\x2b\xb7\x5b\x48\xae" + "\x3a\xc6\xd4\xb2\xe1\x53\x53\x94" + "\x2c\x6f\x7d\xde\x07\x9d\x15\x82" + "\x09\xb1\xc5\x4e\xf3\xae\x9c\x38" + "\x14\xef\x65\xdb\x53\xbb\x8e\x4a" + "\x43\xde\x99\xdd\x7e\xcb\xc2\x2d" + "\x5f\x40\xf2\x83\xed\xa3\x6f\x81" + "\xa3\x08\x42\xc1\xb9\x9b\x42\x73" + + "\x27\x6e\x1e\xb0\x90\xd5\x18\xb6" + "\xdc\xb2\x80\xe1\xcd\x2c\x7e\x04" + "\xa9\xa4\xae\x04\xb5\x99\xb2\xd1" + "\xa4\x03\xa4\x9f\x1e\x9e\x2c\x41" + "\x52\x75\x40\x79\x36\x8a\xd2\x88" + "\xe3\xb8\x32\xf3\x36\x01\xc5\x49" + "\x19\xde\x68\xe6\xcc\x6f\x1b\x3a" + "\x97\x2b\x12\x75\xbc\x51\x88\x17" + + "\x4c\xfa\x85\xfb\x52\x37\xe1\xb1" + "\xe9\x8c\x3c\x38\xce\x57\x12\xd6" + "\xae\x4d\xf7\xd2\x70\xa6\x3d\xd4" + "\xbb\x6b\x84\xbf\x3f\xa2\x5a\xa3" + "\x83\xfc\x21\x44\x5d\x23\x74\x5e" + "\x3b\x47\x63\xc3\xe0\x8e\xdf\xf6" + "\x58\xa1\x4a\x3c\x2a\xf5\xd7\x34" + "\x2e\xd2\xc6\x9b\xab\x5a\xd0\x50" + + "\xf4\x85\x47\xa6\x35\xe7\x56\x8c" + "\x07\xcd\x29\x5f\x7b\x63\x56\xbc" + "\x67\x50\xe3\x3e\x80\xbb\xb2\x53" + "\x70\x92\x91\xdc\x0f\x5a\x23\x50" + "\x65\xaa\xc4\xf2\xd8\xb6\x1a\x19" + "\x3b\x02\x96\x83\x31\x58\x47\xc3" + "\xba\x05\xf8\xf0\xa5\x0b\x40\x80" + "\x0f\xf8\xc0\x5e\x5b\x06\x81\x88" + + "\x83\x5e\x1b\xcc\x22\xe5\x70\xc3" + "\xfb\x8b\x0b\x86\xd1\x4a\x2d\xde" + "\xdf\x56\xb2\x67\xf0\x4d\x36\xad" + "\x97\x89\x13\xe0\x2e\x50\x12\x8f" + "\x0a\x92\x83\x77\xdc\xa0\x3f\x50" + "\x6a\x86\xbc\xc0\xad\x14\x00\xe8" + "\xa6\x4b\x06\xd3\x44\xb7\x89\x3f" + "\xa5\xdb\xa5\xcb\xcd\x1d\x51\x03" + + "\xa2\xb1\xa7\x95\x6d\xd4\x7d\x19" + "\xfb\x41\x63\x3c\xd6\x7a\x4e\x9c" + "\xce\x2e\x4c\x48\x29\xca\x6e\x42" + "\x8a\x4f\x7f\xde\x89\xe4\x11\x92" + "\xf4\xf1\x8e\xc7\x6e\x7f\x99\x14" + "\x86\x45\x57\x06\x10\x09\x2c\x2b" + "\xe8\xed\x3e\x1c\x6e\x6a\x28\x17" + "\x18\xe0\x60\x0f\x47\x2e\xf9\x25" + + "\x36\x0a\x89\x31\x46\x56\x5c\x80" + "\x5b\xea\xfe\x57\x00\xf6\x3e\x70" + "\x30\x30\x3c\xaf\x7c\x74\x9f\x38" + "\x39\x37\xdd\x54\xeb\xda\xe5\xe0" + "\x55\xf1\xc9\xc9\xc3\xa4\x24\xfe" + "\x62\x39\x39\xb5\x76\xf1\x4b\x7e" + "\x29\xbf\x20\xaf\xe2\x3d\x18\x37" + "\x3b\x8c\x5a\xf9\xb5\xd7\x1b\x4a" + + "\x3d\x1d\x19\x46\x99\x96\x3b\xa8" + "\x57\xf2\x87\x7b\xdd\xc8\x1f\x28" + "\x88\x75\x10\x54\x13\x2c\x8e\xb1" + "\xe8\xaf\x2b\x9b\xf7\xde\x72\x63" + "\xca\x72\x89\x0d\x48\xbb\xf4\xda" + "\x3f\x7a\x16\x56\xb7\xd4\x2d\x3f" + "\xf4\x0c\x31\x84\x2d\xe3\xac\x1e" + "\xaa\x00\x27\xe4\xaf\xef\xbc\xe3" + + "\x3d\xe7\x85\xd7\x1e\x69\xe5\x5f" + "\x67\x04\xa6\x2e\xb6\x5a\xdb\xa5" + "\x4a\x51\xc6\xdf\x41\x3d\xe2\x02" + "\x65\x36\x3c\xe0\x8e\x04\xe8\x35" + "\xf8\xa0\xda\x1a\x8f\x11\x8b\x3f" + "\x5a\x1a\xce\x84\x45\x3b\xec\x28" + "\xb8\x46\x66\x2c\x6e\xcc\xca\xe8" + "\x0f\xe4\xd0\xdb\x85\xd1\x43\x13" + + "\x8c\x35\xaa\xca\x44\xf8\xd7\xe5" + "\x2a\x18\x24\x99\xe4\xb7\x1d\x1a" + "\x9a\x5d\x87\x9c\x2d\xd4\x4c\xd6" + "\xc8\xee\x2e\x04\x5f\x51\x7b\xb3" + "\xbe\x5f\x16\x7b\x09\xd4\x4d\x4d" + "\xf3\xef\x06\xe2\xd9\x2e\x32\xfc" + "\x7e\xe1\xb7\x59\x02\x41\xee\x7d" + "\x00\xca\x36\x82\xc0\x81\xa4\x55" + + "\x75\xc9\x3f\xc2\x12\x53\x88\x8c" + "\x7b\x29\xd6\x05\x06\x58\x71\x15" + "\x39\xdd\x8e\xf7\x8e\x86\x78\xa0" + "\x52\x5e\xc4\x03\xe0\x31\x6b\x95" + "\xa6\x33\x7b\xff\xd5\x75\x02\x47" + "\x3f\x67\x7e\x0c\x3a\xdc\xd5\xc8" + "\x98\x25\x2f\x7e\xb4\x27\x92\x41" + "\x75\xa9\x14\x4c\x34\xb6\x37\x8b" + + "\x8c\x88\x11\x8b\xd6\x7e\x66\xd0" + "\xdc\x25\x3e\x80\x3e\x8c\x0e\x5e" + "\x4a\xa2\x87\xb9\xdc\xd0\xe5\x34" + "\x23\x03\x92\xae\x3b\xac\x40\x9f" + "\x3a\xf6\xe0\x34\x95\xde\x63\x54" + "\xf9\x28\x63\x6b\x92\xbf\x28\xa1" + "\xb7\xf1\x64\xda\x7c\xcd\x1c\x49" + "\x35\xde\x7b\xc4\x27\xec\xf1\x7e" + + "\x37\x27\x6a\xa3\x0f\x24\x57\xa8" + "\xc1\x1b\x62\x63\x66\x13\xdc\x35" + "\x97\x68\xfb\xd4\x53\x64\x3a\x7a" + "\x9d\x31\x29\xc9\x39\xa4\xf1\x80" + "\xa0\x0b\xcb\xf8\x4b\x27\x18\xfc" + "\xeb\xc5\x78\x80\x66\x37\xb5\xb0" + "\xef\xd0\x01\x1e\x24\x49\x0d\xfb" + "\x9c\xb0\x2a\x37\x7d\xc6\xd7\x50" + + "\x68\xc9\xea\x3a\xaf\x70\xe3\xb4" + "\x66\x32\xb6\xc4\xe9\xfe\xf7\xe4" + "\x64\x56\xac\xe3\xc2\xd4\xac\xb4" + "\xbf\x8c\xb3\xce\xd2\x0b\x91\xf8" + "\x6e\x72\xc0\xc9\x0c\xe5\x3a\x1c" + "\xbf\x40\x7b\xd9\x69\x95\x30\x15" + "\x1b\x5a\x5a\xfd\x7f\x4b\x88\x70" + "\xcd\x14\x83\xef\x6a\x89\x90\x38" + + "\x93\x8c\x61\xa5\x5c\x51\xe1\x58" + "\xd1\x42\xd9\x77\x2b\x43\x65\xe6" + "\xa8\x67\xf7\xb6\xbf\x81\x21\xb3" + "\x10\x41\x60\x3a\xe8\x94\x37\x75" + "\xcc\xdb\xc0\xe8\x7c\xeb\xaf\x09" + "\xa3\x73\x86\x59\x13\x26\xe0\x31" + "\x00\xdb\x46\x7d\x57\xe5\x98\x5d" + "\x28\x5b\x98\x9d\x8c\xfb\x21\xfc" + + "\x0b\x3e\x84\xb0\x16\x01\x04\xc9" + "\x31\x45\xb0\x69\xa8\xb3\xb1\x53" + "\x30\xd8\xd7\x85\xf0\x49\x16\xdd" + "\xe8\x27\x74\xcb\x87\xcc\x3b\xbb" + "\x83\xce\x3d\xc9\x00\x11\x26\x77" + "\x2a\x2a\x92\xa1\x61\xda\x79\x7e" + "\xe8\x9c\x14\xf3\x02\x2b\x7a\x58" + "\x83\xec\x92\xde\x84\x13\x7e\x14" + + "\x30\x7f\x07\xaf\xd3\x83\x4c\x48" + "\x3a\xb5\x58\x06\x44\xf8\x78\xea" + "\x53\xec\x7a\x02\xc2\x76\x20\x91" + "\x7d\x17\xc8\x93\xe3\x14\x47\xf3" + "\x84\x6c\x37\xc2\x15\x5d\xef\x37" + "\x83\xa7\x1a\x3d\x59\xb6\x15\x83" + "\x90\x2a\x85\xef\x84\xc4\x75\x3a" + "\xd4\x6b\x08\x16\x8a\xc5\xa0\x0b" + + "\x48\x6d\x9a\x52\x7a\x8d\x68\x29" + "\x03\x92\xf1\xc2\x0d\x25\x7f\x9c" + "\xf9\x2d\x2e\x68\xfb\x42\x30\x12" + "\xbc\x21\x81\xad\xe7\x87\x75\x2b" + "\x65\x2a\x18\xe0\x33\x02\xfc\x30" + "\x8a\x12\xe1\xe3\x87\xcf\x2e\xb8" + "\x8f\x09\xfb\x93\x61\x28\x68\x71" + "\xa7\xe6\xe9\x85\xae\x21\x3e\x04" + + "\xea\x34\xc8\x66\xd6\x49\x5b\xab" + "\x87\x42\x41\x47\x18\x3e\xe4\x3b" + "\x47\x2a\x9a\x21\x59\xb8\x0f\xf4" + "\x3c\xdf\x58\xcc\xe9\x59\x65\x0e" + "\xb4\x15\x66\x0c\x8e\xfe\x1d\xfe" + "\x70\x9d\x45\x56\xfd\xc8\xab\x14" + "\x86\x03\xde\x05\x8e\xfa\xe0\x7b" + "\x7c\x5c\x03\xe9\x68\xef\x63\x8e" + + "\x91\x1e\xb3\x53\xb4\x01\x64\x11" + "\xd8\xb4\x36\x44\xd4\x7a\xba\x0c" + "\x66\xfd\x7a\x10\xa0\xf9\x51\x91" + "\xc4\xe4\x0e\x1f\xd0\xa8\xac\xaf" + "\x1c\x76\xe9\x9e\x1d\x5c\xfe\x75" + "\x8f\x58\xc0\xf0\x6b\xa1\x97\x34" + "\x4c\x80\x04\x03\xbd\xbe\xe2\x3e" + "\xb9\x90\xc9\xc2\x60\x9a\xfb\xa8" + + "\x14\x11\x25\x39\xfe\x32\x4d\xd1" + "\x66\x33\xc7\xca\xbc\x25\xbf\x36" + "\x5c\x49\xa7\xdb\x66\x2c\x56\xc9" + "\x8b\x34\xad\x46\x1b\x30\x4d\x32" + "\x7e\x40\x70\xd6\x0c\x62\x46\x9f" + "\x01\x3a\x73\xe3\xf1\xd4\xa8\x0e" + "\xe0\x24\xc3\xb0\x32\xd5\x96\xd3" + "\xcd\x17\xc3\x03\x0e\x1a\x21\x5b" + + "\x37\x7b\xfe\x5f\x20\x7d\x0d\x09" + "\xda\xd2\x47\x17\xfb\x3e\x7f\x3b" + "\x19\xc5\x4f\xb5\x5f\x52\xcb\xa2" + "\x1e\x97\x6a\xf6\x32\x09\x22\x6e" + "\x40\xd4\x86\xb4\xdf\x60\xc1\xdd" + "\x65\x34\xe1\x3f\x46\xec\xcf\x7f" + "\x51\xc1\xe4\x76\x4e\x7e\xda\x83" + "\xb5\x02\xd3\xd8\xa1\x48\xfa\xd6" + + "\x88\xcd\x72\x58\x26\x4f\x30\xc6" + "\xa1\x90\x8b\x27\x3c\x1d\x6c\x80" + "\x1c\xbc\xf0\xca\x25\xe7\x53\x35" + "\x5c\x8d\x9d\xbb\x03\xe6\x59\xff" + "\xdd\x85\x0b\x7a\x32\x0f\x55\xa4" + "\x17\xc2\xec\x93\x0a\x72\xc5\xde" + "\x13\x22\xd6\x69\x41\xb7\x88\x0b" + "\x55\x59\x36\x5b\x45\xf2\x12\x72" + + "\x87\xe7\xca\xb5\x11\x41\x76\x20" + "\x24\x31\xfd\x1d\x58\x7f\xcb\x13" + "\xfb\xae\x75\x11\xda\x77\xca\x2d" + "\x75\xe7\xaa\xff\x6b\x46\x75\xeb" + "\x32\xff\x6c\xdb\x3b\x6f\xd7\x74" + "\x9a\xda\xfc\x61\x7a\xf3\x40\x74" + "\x8b\x02\x25\xb5\x92\xac\xb3\x1b" + "\x29\x5f\x97\xa1\xf7\xf8\xfb\x20" + + "\x7f\x09\x83\xdf\xe1\x92\x26\x98" + "\x00\x08\x4b\x55\x6c\x8f\x73\x28" + "\x2f\x2f\xce\xa2\x17\x37\x70\xdc" + "\x94\x41\x81\x40\x3c\xb9\x13\x79" + "\x36\x96\xe8\x1f\x93\x45\x92\x04" + "\xa6\x34\x88\xf7\x3f\x44\x98\x7b" + "\xa1\xa5\x14\x51\x01\xab\xc6\x11" + "\x4c\x5f\xba\xff\x83\xb3\xde\x60" + + "\xe6\x82\xa9\x01\xc6\x54\xaa\x4c" + "\x26\xcd\x91\x34\x11\x5e\xd3\x1d" + "\x05\x6b\xbd\x7c\x5f\x31\x3c\x97" + "\x24\x47\x49\x52\x75\x07\xb0\xca" + "\x5a\xe1\x65\x65\x1f\x9b\x65\x04" + "\x26\xb0\x8f\x8c\x29\xf5\x30\xbf" + "\x37\xde\xa0\xa8\x1b\x64\x21\xfc" + "\x14\x51\x5e\xfa\x66\xa3\xc7\xe9" + + "\xd8\x3a\xf0\x52\xa5\x9c\x84\xdb" + "\xc0\x35\x4e\x02\xe9\xdb\xe8\xc7" + "\x89\xc7\xc3\xcf\xac\xbb\xa2\xa1" + "\x62\xf2\x26\x9c\x7d\x3e\x73\xbf" + "\x23\x48\x44\xb8\xf5\xfb\x2f\x88" + "\x3b\x48\xf8\x6b\x88\x4e\x22\xb7" + "\x40\xf6\xbe\x65\x8b\x3b\x02\x53" + "\xcd\xf8\xd5\xd4\x91\xec\xbf\xaa" + + "\xbd\xa1\x9e\x07\x10\x15\x0e\xa4" + "\x26\x5d\x5d\xd0\xdc\xad\xd9\x1a" + "\x4f\x8d\xe6\x13\xab\x2e\x3f\xdb" + "\x3f\x80\x0f\x64\xe2\x1a\xff\x1c" + "\x17\xe1\xce\xd4\x49\xb7\xe7\xe0" + "\x09\xd9\x36\x40\x5b\x27\x9f\x8e" + "\x38\x4c\x4d\x8f\x1d\xe3\x34\xce" + "\xfc\x30\x51\xd7\x69\x7f\xb3\x22" + + "\x04\x46\x01\xb4\xfd\xf1\xe0\x83" + "\x78\x50\x41\x89\x19\x99\xce\xa8" + "\xfe\x2e\x79\x41\x75\x5b\x37\x82" + "\x5b\x51\xd4\x97\x5c\xbf\x59\x4f" + "\x7d\x27\x3a\x92\x4f\x32\x4f\xac" + "\x06\x34\x0f\x65\x7d\x9b\xbc\xd9" + "\x51\xbc\x39\x8a\xd1\x87\xfa\xc6" + "\x8f\x10\xcc\x5c\x30\x85\x58\x82" + + "\x34\xc6\xe4\x82\x9f\x3c\xed\x5c" + "\xf8\x64\x44\x3a\x14\x83\xfb\x8e" + "\x25\xca\x1d\x7a\x1b\x38\x06\xe7" + "\x2b\x41\x2a\x5a\x3c\x5a\xd1\x6c" + "\xb5\x8f\xcd\xbf\xfd\xa8\x47\x93" + "\x22\xcd\x54\x6e\xef\x2e\xdb\x31" + "\x2f\x93\xd8\xf8\x1e\xb1\xae\xc4" + "\xaf\x11\x44\x34\xed\xc1\xe7\x11" diff --git a/src/crypto/elliptic/p256_asm_table_test.go b/src/crypto/elliptic/p256_asm_table_test.go index 6b64f26286..d704dae299 100644 --- a/src/crypto/elliptic/p256_asm_table_test.go +++ b/src/crypto/elliptic/p256_asm_table_test.go @@ -8,6 +8,7 @@ package elliptic import ( + "encoding/binary" "reflect" "testing" ) @@ -45,7 +46,12 @@ func TestP256PrecomputedTable(t *testing.T) { copy(t1[8:12], basePoint[8:12]) - if got, want := p256Precomputed[i][j*8:(j*8)+8], t1[:8]; !reflect.DeepEqual(got, want) { + buf := make([]byte, 8*8) + for i, u := range t1[:8] { + binary.LittleEndian.PutUint64(buf[i*8:i*8+8], u) + } + start := i*32*8*8 + j*8*8 + if got, want := p256Precomputed[start:start+64], string(buf); !reflect.DeepEqual(got, want) { t.Fatalf("Unexpected table entry at [%d][%d:%d]: got %v, want %v", i, j*8, (j*8)+8, got, want) } } From 13eccaa9902f3bb17999f1f7f14b7da39d60e0ea Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 26 Oct 2021 09:01:34 -0700 Subject: [PATCH 174/406] embed/internal/embedtest: use parenthesized vars for one test The gofrontend code mishandled this case, so add it to the test. Change-Id: I183b8fab57552320b04c4826c590b7c6d36b6548 Reviewed-on: https://go-review.googlesource.com/c/go/+/358836 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Than McIntosh --- src/embed/internal/embedtest/embed_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/embed/internal/embedtest/embed_test.go b/src/embed/internal/embedtest/embed_test.go index b41359f4c2..bfd94af69d 100644 --- a/src/embed/internal/embedtest/embed_test.go +++ b/src/embed/internal/embedtest/embed_test.go @@ -89,11 +89,13 @@ func TestDir(t *testing.T) { testDir(t, all, "testdata/i/j/k", "k8s.txt") } -//go:embed testdata -var testHiddenDir embed.FS +var ( + //go:embed testdata + testHiddenDir embed.FS -//go:embed testdata/* -var testHiddenStar embed.FS + //go:embed testdata/* + testHiddenStar embed.FS +) func TestHidden(t *testing.T) { dir := testHiddenDir From ca5f65d771bc24b9717dca615fa4ad25dcd94fad Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Mon, 25 Oct 2021 14:16:53 +0700 Subject: [PATCH 175/406] cmd/compile: fix generic type handling when crawling inline body For base generic type that is written to export file, we need to mark all of its methods, include exported+unexported methods, as reachable, so they can be available for instantiation if necessary. But markType only looks for exported methods, thus causing the crash in #49143. To fix this, we introduce new method p.markGeneric, to mark all methods of the base generic type. This issue has happend for a while (maybe since we add generic import/export during go1.18 cycle), and was un-intentionally "fixed" in CL 356254, when we agresssively call p.markEmbed(t). CL 357232 fixed that wrong agressive behavior, thus reproduce the bug on tip. Fixes #49143 Change-Id: Ie64574a05fffb282e9dcc8739df4378c5b6b0468 Reviewed-on: https://go-review.googlesource.com/c/go/+/358814 Trust: Cuong Manh Le Trust: Dan Scales Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Keith Randall Reviewed-by: Dan Scales --- src/cmd/compile/internal/typecheck/crawler.go | 33 +++++++++++++++---- test/fixedbugs/issue49143.dir/a.go | 24 ++++++++++++++ test/fixedbugs/issue49143.dir/b.go | 16 +++++++++ test/fixedbugs/issue49143.dir/c.go | 15 +++++++++ test/fixedbugs/issue49143.dir/p.go | 11 +++++++ test/fixedbugs/issue49143.go | 7 ++++ 6 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 test/fixedbugs/issue49143.dir/a.go create mode 100644 test/fixedbugs/issue49143.dir/b.go create mode 100644 test/fixedbugs/issue49143.dir/c.go create mode 100644 test/fixedbugs/issue49143.dir/p.go create mode 100644 test/fixedbugs/issue49143.go diff --git a/src/cmd/compile/internal/typecheck/crawler.go b/src/cmd/compile/internal/typecheck/crawler.go index e1489ceedd..ae2b3b1df4 100644 --- a/src/cmd/compile/internal/typecheck/crawler.go +++ b/src/cmd/compile/internal/typecheck/crawler.go @@ -20,6 +20,7 @@ func crawlExports(exports []*ir.Name) { p := crawler{ marked: make(map[*types.Type]bool), embedded: make(map[*types.Type]bool), + generic: make(map[*types.Type]bool), } for _, n := range exports { p.markObject(n) @@ -29,6 +30,7 @@ func crawlExports(exports []*ir.Name) { type crawler struct { marked map[*types.Type]bool // types already seen by markType embedded map[*types.Type]bool // types already seen by markEmbed + generic map[*types.Type]bool // types already seen by markGeneric } // markObject visits a reachable object (function, method, global type, or global variable) @@ -168,6 +170,30 @@ func (p *crawler) markEmbed(t *types.Type) { } } +// markGeneric takes an instantiated type or a base generic type t, and +// marks all the methods of the base generic type of t. If a base generic +// type is written to export file, even if not explicitly marked for export, +// all of its methods need to be available for instantiation if needed. +func (p *crawler) markGeneric(t *types.Type) { + if t.IsPtr() { + t = t.Elem() + } + if t.OrigSym() != nil { + // Convert to the base generic type. + t = t.OrigSym().Def.Type() + } + if p.generic[t] { + return + } + p.generic[t] = true + + if t.Sym() != nil && t.Kind() != types.TINTER { + for _, m := range t.Methods().Slice() { + p.markObject(m.Nname.(*ir.Name)) + } + } +} + // markInlBody marks n's inline body for export and recursively // ensures all called functions are marked too. func (p *crawler) markInlBody(n *ir.Name) { @@ -197,12 +223,7 @@ func (p *crawler) markInlBody(n *ir.Name) { t := n.Type() if t != nil { if t.HasTParam() || t.IsFullyInstantiated() { - // Ensure that we call markType() on any base generic type - // that is written to the export file (even if not explicitly - // marked for export), so we will call markInlBody on its - // methods, and the methods will be available for - // instantiation if needed. - p.markType(t) + p.markGeneric(t) } if base.Debug.Unified == 0 { // If a method of un-exported type is promoted and accessible by diff --git a/test/fixedbugs/issue49143.dir/a.go b/test/fixedbugs/issue49143.dir/a.go new file mode 100644 index 0000000000..5aefcd8780 --- /dev/null +++ b/test/fixedbugs/issue49143.dir/a.go @@ -0,0 +1,24 @@ +// Copyright 2021 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 a + +import "sync" + +type Loader[K comparable, R any] struct { + batch *LoaderBatch[K, R] +} + +func (l *Loader[K, R]) Load() error { + l.batch.f() + return nil +} + +type LoaderBatch[K comparable, R any] struct { + once *sync.Once +} + +func (b *LoaderBatch[K, R]) f() { + b.once.Do(func() {}) +} diff --git a/test/fixedbugs/issue49143.dir/b.go b/test/fixedbugs/issue49143.dir/b.go new file mode 100644 index 0000000000..48eecdbaaf --- /dev/null +++ b/test/fixedbugs/issue49143.dir/b.go @@ -0,0 +1,16 @@ +// Copyright 2021 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 b + +import "./a" + + +type Loaders struct { + Loader *a.Loader[int, int] +} + +func NewLoaders() *Loaders { + return new(Loaders) +} diff --git a/test/fixedbugs/issue49143.dir/c.go b/test/fixedbugs/issue49143.dir/c.go new file mode 100644 index 0000000000..89262e374a --- /dev/null +++ b/test/fixedbugs/issue49143.dir/c.go @@ -0,0 +1,15 @@ +// Copyright 2021 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 c + +import "./b" + +type Resolver struct{} + +type todoResolver struct{ *Resolver } + +func (r *todoResolver) F() { + b.NewLoaders().Loader.Load() +} diff --git a/test/fixedbugs/issue49143.dir/p.go b/test/fixedbugs/issue49143.dir/p.go new file mode 100644 index 0000000000..f11d2f22eb --- /dev/null +++ b/test/fixedbugs/issue49143.dir/p.go @@ -0,0 +1,11 @@ +// Copyright 2021 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 p + +import ( + "./c" +) + +var _ = &c.Resolver{} diff --git a/test/fixedbugs/issue49143.go b/test/fixedbugs/issue49143.go new file mode 100644 index 0000000000..87b4ff46c1 --- /dev/null +++ b/test/fixedbugs/issue49143.go @@ -0,0 +1,7 @@ +// compiledir -G=3 + +// Copyright 2021 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 ignored From 5786a54cfe34069c865fead1b6d9c9e3485a40a5 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 26 Oct 2021 09:13:16 +0200 Subject: [PATCH 176/406] syscall: use dup3 in forkAndExecInChild on NetBSD Use dup3(oldfd, newfd, O_CLOEXEC) to atomically duplicate the file descriptor and mark is as close-on-exec instead of dup2 & fcntl. The dup3 syscall was added in NetBSD 6.0. Change-Id: I01a4f8c62bfa8fb7f9f3166070380dd2002bb564 Reviewed-on: https://go-review.googlesource.com/c/go/+/358755 Trust: Tobias Klauser Trust: Benny Siegert Run-TryBot: Tobias Klauser Reviewed-by: Benny Siegert TryBot-Result: Go Bot --- src/syscall/exec_bsd.go | 33 ++++++++++++++++++++------- src/syscall/syscall_dragonfly.go | 2 ++ src/syscall/syscall_netbsd.go | 2 ++ src/syscall/syscall_openbsd_mips64.go | 2 ++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/syscall/exec_bsd.go b/src/syscall/exec_bsd.go index 4c36f9ec13..d2e50e3dd3 100644 --- a/src/syscall/exec_bsd.go +++ b/src/syscall/exec_bsd.go @@ -8,6 +8,7 @@ package syscall import ( + "runtime" "unsafe" ) @@ -181,11 +182,19 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr // Pass 1: look for fd[i] < i and move those up above len(fd) // so that pass 2 won't stomp on an fd it needs later. if pipe < nextfd { - _, _, err1 = RawSyscall(SYS_DUP2, uintptr(pipe), uintptr(nextfd), 0) - if err1 != 0 { - goto childerror + switch runtime.GOOS { + case "netbsd": + _, _, err1 = RawSyscall(_SYS_DUP3, uintptr(pipe), uintptr(nextfd), O_CLOEXEC) + if err1 != 0 { + goto childerror + } + default: + _, _, err1 = RawSyscall(SYS_DUP2, uintptr(pipe), uintptr(nextfd), 0) + if err1 != 0 { + goto childerror + } + RawSyscall(SYS_FCNTL, uintptr(nextfd), F_SETFD, FD_CLOEXEC) } - RawSyscall(SYS_FCNTL, uintptr(nextfd), F_SETFD, FD_CLOEXEC) pipe = nextfd nextfd++ } @@ -194,11 +203,19 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr if nextfd == pipe { // don't stomp on pipe nextfd++ } - _, _, err1 = RawSyscall(SYS_DUP2, uintptr(fd[i]), uintptr(nextfd), 0) - if err1 != 0 { - goto childerror + switch runtime.GOOS { + case "netbsd": + _, _, err1 = RawSyscall(_SYS_DUP3, uintptr(fd[i]), uintptr(nextfd), O_CLOEXEC) + if err1 != 0 { + goto childerror + } + default: + _, _, err1 = RawSyscall(SYS_DUP2, uintptr(fd[i]), uintptr(nextfd), 0) + if err1 != 0 { + goto childerror + } + RawSyscall(SYS_FCNTL, uintptr(nextfd), F_SETFD, FD_CLOEXEC) } - RawSyscall(SYS_FCNTL, uintptr(nextfd), F_SETFD, FD_CLOEXEC) fd[i] = nextfd nextfd++ } diff --git a/src/syscall/syscall_dragonfly.go b/src/syscall/syscall_dragonfly.go index 16adf306d5..cc92c4a93e 100644 --- a/src/syscall/syscall_dragonfly.go +++ b/src/syscall/syscall_dragonfly.go @@ -17,6 +17,8 @@ import ( "unsafe" ) +const _SYS_DUP3 = 0 + // See version list in https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/param.h var ( osreldateOnce sync.Once diff --git a/src/syscall/syscall_netbsd.go b/src/syscall/syscall_netbsd.go index 6f05b0d43d..cebef10be8 100644 --- a/src/syscall/syscall_netbsd.go +++ b/src/syscall/syscall_netbsd.go @@ -14,6 +14,8 @@ package syscall import "unsafe" +const _SYS_DUP3 = SYS_DUP3 + type SockaddrDatalink struct { Len uint8 Family uint8 diff --git a/src/syscall/syscall_openbsd_mips64.go b/src/syscall/syscall_openbsd_mips64.go index b259dc6975..e8ae2e9911 100644 --- a/src/syscall/syscall_openbsd_mips64.go +++ b/src/syscall/syscall_openbsd_mips64.go @@ -4,6 +4,8 @@ package syscall +const _SYS_DUP3 = 0 + func setTimespec(sec, nsec int64) Timespec { return Timespec{Sec: sec, Nsec: nsec} } From bdefb77309fdc6e47102a8d6272fd2293aefa1d9 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Tue, 26 Oct 2021 09:15:17 +0800 Subject: [PATCH 177/406] internal/poll: improve the padding calculation inside struct splicePipe Updates #48968 and CL 358114 Change-Id: Ic68b4c5420c1c32f78b56874b53d717fa9af1f74 Reviewed-on: https://go-review.googlesource.com/c/go/+/358734 Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Trust: Tobias Klauser --- src/internal/poll/splice_linux.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/internal/poll/splice_linux.go b/src/internal/poll/splice_linux.go index 6869a40b24..2d87c3d023 100644 --- a/src/internal/poll/splice_linux.go +++ b/src/internal/poll/splice_linux.go @@ -154,14 +154,18 @@ func splice(out int, in int, max int, flags int) (int, error) { return int(n), err } -type splicePipe struct { +type splicePipeFields struct { rfd int wfd int data int +} + +type splicePipe struct { + splicePipeFields // We want to use a finalizer, so ensure that the size is // large enough to not use the tiny allocator. - _ [24 - 3*unsafe.Sizeof(int(0))]byte + _ [24 - unsafe.Sizeof(splicePipeFields{})%24]byte } // splicePipePool caches pipes to avoid high-frequency construction and destruction of pipe buffers. @@ -222,7 +226,7 @@ func newPipe() (sp *splicePipe) { return nil } - sp = &splicePipe{rfd: fds[0], wfd: fds[1]} + sp = &splicePipe{splicePipeFields: splicePipeFields{rfd: fds[0], wfd: fds[1]}} if p == nil { p = new(bool) From cfb532158fc5b5cd6b9c35bbc2ff7c203fe5f09b Mon Sep 17 00:00:00 2001 From: Cholerae Hu Date: Wed, 27 Oct 2021 11:41:47 +0800 Subject: [PATCH 178/406] cmd/go: add darwin/arm64 in the list of supported systems in help message Fixes #49173. Change-Id: I71270b4ff7e9ede3cdfa5946b73142a731752adf Reviewed-on: https://go-review.googlesource.com/c/go/+/358901 Reviewed-by: Alberto Donizetti Reviewed-by: Keith Randall Trust: Alberto Donizetti Run-TryBot: Alberto Donizetti TryBot-Result: Go Bot --- src/cmd/go/alldocs.go | 2 +- src/cmd/go/internal/work/build.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 8178073103..9d8c321307 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -114,7 +114,7 @@ // The default is GOMAXPROCS, normally the number of CPUs available. // -race // enable data race detection. -// Supported only on linux/amd64, freebsd/amd64, darwin/amd64, windows/amd64, +// Supported only on linux/amd64, freebsd/amd64, darwin/amd64, darwin/arm64, windows/amd64, // linux/ppc64le and linux/arm64 (only for 48-bit VMA). // -msan // enable interoperation with memory sanitizer. diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index ffe33bfa4d..9d0ad27f0d 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -68,7 +68,7 @@ and test commands: The default is GOMAXPROCS, normally the number of CPUs available. -race enable data race detection. - Supported only on linux/amd64, freebsd/amd64, darwin/amd64, windows/amd64, + Supported only on linux/amd64, freebsd/amd64, darwin/amd64, darwin/arm64, windows/amd64, linux/ppc64le and linux/arm64 (only for 48-bit VMA). -msan enable interoperation with memory sanitizer. From 4f73fd05a91a9b8ceced6b7f89d35f363c414ec8 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 11 Oct 2021 11:57:24 -0400 Subject: [PATCH 179/406] cmd: move internal/str back to cmd/go cmd/go is not subject to all the same restrictions as most of cmd. In particular it need not be buildable with the bootstrap toolchain. So it is better to keep as little code shared between cmd/go and cmd/compile, cmd/link, cmd/cgo as possible. cmd/internal/str started as cmd/go/internal/str but was moved to cmd/internal in order to make use of the quoted string code. Move that code to cmd/internal/quoted and then move the rest of cmd/internal/str back to cmd/go/internal/str. Change-Id: I3a98f754d545cc3af7e9a32c2b77a5a035ea7b9a Reviewed-on: https://go-review.googlesource.com/c/go/+/355010 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/cmd/cgo/gcc.go | 4 +- .../compile/internal/ssa/stmtlines_test.go | 4 +- src/cmd/dist/buildtool.go | 2 +- src/cmd/go/internal/base/base.go | 2 +- src/cmd/go/internal/base/flag.go | 4 +- src/cmd/go/internal/envcmd/env.go | 4 +- src/cmd/go/internal/fix/fix.go | 2 +- src/cmd/go/internal/generate/generate.go | 2 +- src/cmd/go/internal/get/get.go | 2 +- src/cmd/go/internal/list/list.go | 2 +- src/cmd/go/internal/load/flag.go | 4 +- src/cmd/go/internal/load/pkg.go | 2 +- src/cmd/go/internal/load/test.go | 2 +- src/cmd/go/internal/modcmd/vendor.go | 2 +- .../go/internal/modfetch/codehost/codehost.go | 2 +- src/cmd/go/internal/modfetch/codehost/vcs.go | 2 +- src/cmd/go/internal/modget/query.go | 2 +- src/cmd/go/internal/modload/load.go | 2 +- src/cmd/go/internal/modload/query.go | 2 +- src/cmd/go/internal/run/run.go | 2 +- src/cmd/{ => go}/internal/str/path.go | 0 src/cmd/go/internal/str/str.go | 111 +++++++++ src/cmd/go/internal/str/str_test.go | 29 +++ src/cmd/go/internal/test/test.go | 2 +- src/cmd/go/internal/vcs/vcs.go | 2 +- src/cmd/go/internal/work/buildid.go | 2 +- src/cmd/go/internal/work/exec.go | 5 +- src/cmd/go/internal/work/gc.go | 5 +- src/cmd/go/internal/work/gccgo.go | 2 +- src/cmd/go/internal/work/init.go | 4 +- src/cmd/internal/quoted/quoted.go | 127 ++++++++++ .../str_test.go => quoted/quoted_test.go} | 30 +-- src/cmd/internal/str/str.go | 227 ------------------ src/cmd/link/dwarf_test.go | 4 +- src/cmd/link/internal/ld/main.go | 6 +- 35 files changed, 314 insertions(+), 292 deletions(-) rename src/cmd/{ => go}/internal/str/path.go (100%) create mode 100644 src/cmd/go/internal/str/str.go create mode 100644 src/cmd/go/internal/str/str_test.go create mode 100644 src/cmd/internal/quoted/quoted.go rename src/cmd/internal/{str/str_test.go => quoted/quoted_test.go} (79%) delete mode 100644 src/cmd/internal/str/str.go diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index c78197896c..997a830994 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -29,7 +29,7 @@ import ( "unicode" "unicode/utf8" - "cmd/internal/str" + "cmd/internal/quoted" ) var debugDefine = flag.Bool("debug-define", false, "print relevant #defines") @@ -1568,7 +1568,7 @@ func checkGCCBaseCmd() ([]string, error) { if value == "" { value = defaultCC(goos, goarch) } - args, err := str.SplitQuotedFields(value) + args, err := quoted.Split(value) if err != nil { return nil, err } diff --git a/src/cmd/compile/internal/ssa/stmtlines_test.go b/src/cmd/compile/internal/ssa/stmtlines_test.go index 843db8c07e..90dd261c55 100644 --- a/src/cmd/compile/internal/ssa/stmtlines_test.go +++ b/src/cmd/compile/internal/ssa/stmtlines_test.go @@ -2,7 +2,7 @@ package ssa_test import ( cmddwarf "cmd/internal/dwarf" - "cmd/internal/str" + "cmd/internal/quoted" "debug/dwarf" "debug/elf" "debug/macho" @@ -58,7 +58,7 @@ func TestStmtLines(t *testing.T) { if extld == "" { extld = "gcc" } - extldArgs, err := str.SplitQuotedFields(extld) + extldArgs, err := quoted.Split(extld) if err != nil { t.Fatal(err) } diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go index 320c62f850..75f04a975c 100644 --- a/src/cmd/dist/buildtool.go +++ b/src/cmd/dist/buildtool.go @@ -46,8 +46,8 @@ var bootstrapDirs = []string{ "cmd/internal/obj/...", "cmd/internal/objabi", "cmd/internal/pkgpath", + "cmd/internal/quoted", "cmd/internal/src", - "cmd/internal/str", "cmd/internal/sys", "cmd/link", "cmd/link/internal/...", diff --git a/src/cmd/go/internal/base/base.go b/src/cmd/go/internal/base/base.go index 0144525e30..954ce47a98 100644 --- a/src/cmd/go/internal/base/base.go +++ b/src/cmd/go/internal/base/base.go @@ -17,7 +17,7 @@ import ( "sync" "cmd/go/internal/cfg" - "cmd/internal/str" + "cmd/go/internal/str" ) // A Command is an implementation of a go command diff --git a/src/cmd/go/internal/base/flag.go b/src/cmd/go/internal/base/flag.go index 7e5121bffb..2c72c7e562 100644 --- a/src/cmd/go/internal/base/flag.go +++ b/src/cmd/go/internal/base/flag.go @@ -9,7 +9,7 @@ import ( "cmd/go/internal/cfg" "cmd/go/internal/fsys" - "cmd/internal/str" + "cmd/internal/quoted" ) // A StringsFlag is a command-line flag that interprets its argument @@ -18,7 +18,7 @@ type StringsFlag []string func (v *StringsFlag) Set(s string) error { var err error - *v, err = str.SplitQuotedFields(s) + *v, err = quoted.Split(s) if *v == nil { *v = []string{} } diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go index 181d2a2ca1..e56dd8223f 100644 --- a/src/cmd/go/internal/envcmd/env.go +++ b/src/cmd/go/internal/envcmd/env.go @@ -26,7 +26,7 @@ import ( "cmd/go/internal/load" "cmd/go/internal/modload" "cmd/go/internal/work" - "cmd/internal/str" + "cmd/internal/quoted" ) var CmdEnv = &base.Command{ @@ -470,7 +470,7 @@ func checkEnvWrite(key, val string) error { if val == "" { break } - args, err := str.SplitQuotedFields(val) + args, err := quoted.Split(val) if err != nil { return fmt.Errorf("invalid %s: %v", key, err) } diff --git a/src/cmd/go/internal/fix/fix.go b/src/cmd/go/internal/fix/fix.go index cc5940fccd..988d45e71c 100644 --- a/src/cmd/go/internal/fix/fix.go +++ b/src/cmd/go/internal/fix/fix.go @@ -10,7 +10,7 @@ import ( "cmd/go/internal/cfg" "cmd/go/internal/load" "cmd/go/internal/modload" - "cmd/internal/str" + "cmd/go/internal/str" "context" "fmt" "os" diff --git a/src/cmd/go/internal/generate/generate.go b/src/cmd/go/internal/generate/generate.go index 5981e5ecdb..a3873d1138 100644 --- a/src/cmd/go/internal/generate/generate.go +++ b/src/cmd/go/internal/generate/generate.go @@ -26,7 +26,7 @@ import ( "cmd/go/internal/load" "cmd/go/internal/modload" "cmd/go/internal/work" - "cmd/internal/str" + "cmd/go/internal/str" ) var CmdGenerate = &base.Command{ diff --git a/src/cmd/go/internal/get/get.go b/src/cmd/go/internal/get/get.go index 0412506b9e..f46313dcff 100644 --- a/src/cmd/go/internal/get/get.go +++ b/src/cmd/go/internal/get/get.go @@ -20,7 +20,7 @@ import ( "cmd/go/internal/vcs" "cmd/go/internal/web" "cmd/go/internal/work" - "cmd/internal/str" + "cmd/go/internal/str" "golang.org/x/mod/module" ) diff --git a/src/cmd/go/internal/list/list.go b/src/cmd/go/internal/list/list.go index 821e622abb..8c85ddcf21 100644 --- a/src/cmd/go/internal/list/list.go +++ b/src/cmd/go/internal/list/list.go @@ -24,7 +24,7 @@ import ( "cmd/go/internal/modinfo" "cmd/go/internal/modload" "cmd/go/internal/work" - "cmd/internal/str" + "cmd/go/internal/str" ) var CmdList = &base.Command{ diff --git a/src/cmd/go/internal/load/flag.go b/src/cmd/go/internal/load/flag.go index d0d5716c3f..de079decdf 100644 --- a/src/cmd/go/internal/load/flag.go +++ b/src/cmd/go/internal/load/flag.go @@ -6,7 +6,7 @@ package load import ( "cmd/go/internal/base" - "cmd/internal/str" + "cmd/internal/quoted" "fmt" "strings" ) @@ -63,7 +63,7 @@ func (f *PerPackageFlag) set(v, cwd string) error { match = MatchPackage(pattern, cwd) v = v[i+1:] } - flags, err := str.SplitQuotedFields(v) + flags, err := quoted.Split(v) if err != nil { return err } diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index dfe7849516..c6c5fb00a8 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -38,9 +38,9 @@ import ( "cmd/go/internal/modload" "cmd/go/internal/par" "cmd/go/internal/search" + "cmd/go/internal/str" "cmd/go/internal/trace" "cmd/go/internal/vcs" - "cmd/internal/str" "cmd/internal/sys" "golang.org/x/mod/modfile" diff --git a/src/cmd/go/internal/load/test.go b/src/cmd/go/internal/load/test.go index 4cefb62d51..8a18dfbe93 100644 --- a/src/cmd/go/internal/load/test.go +++ b/src/cmd/go/internal/load/test.go @@ -23,7 +23,7 @@ import ( "cmd/go/internal/fsys" "cmd/go/internal/trace" - "cmd/internal/str" + "cmd/go/internal/str" ) var TestMainDeps = []string{ diff --git a/src/cmd/go/internal/modcmd/vendor.go b/src/cmd/go/internal/modcmd/vendor.go index 57189b4607..484e095cc7 100644 --- a/src/cmd/go/internal/modcmd/vendor.go +++ b/src/cmd/go/internal/modcmd/vendor.go @@ -24,7 +24,7 @@ import ( "cmd/go/internal/imports" "cmd/go/internal/load" "cmd/go/internal/modload" - "cmd/internal/str" + "cmd/go/internal/str" "golang.org/x/mod/module" "golang.org/x/mod/semver" diff --git a/src/cmd/go/internal/modfetch/codehost/codehost.go b/src/cmd/go/internal/modfetch/codehost/codehost.go index efb4b1516a..378fbae34f 100644 --- a/src/cmd/go/internal/modfetch/codehost/codehost.go +++ b/src/cmd/go/internal/modfetch/codehost/codehost.go @@ -21,7 +21,7 @@ import ( "cmd/go/internal/cfg" "cmd/go/internal/lockedfile" - "cmd/internal/str" + "cmd/go/internal/str" ) // Downloaded size limits. diff --git a/src/cmd/go/internal/modfetch/codehost/vcs.go b/src/cmd/go/internal/modfetch/codehost/vcs.go index 5d810d2621..c2cca084e3 100644 --- a/src/cmd/go/internal/modfetch/codehost/vcs.go +++ b/src/cmd/go/internal/modfetch/codehost/vcs.go @@ -20,7 +20,7 @@ import ( "cmd/go/internal/lockedfile" "cmd/go/internal/par" - "cmd/internal/str" + "cmd/go/internal/str" ) // A VCSError indicates an error using a version control system. diff --git a/src/cmd/go/internal/modget/query.go b/src/cmd/go/internal/modget/query.go index d7341e7813..887cb51b31 100644 --- a/src/cmd/go/internal/modget/query.go +++ b/src/cmd/go/internal/modget/query.go @@ -14,7 +14,7 @@ import ( "cmd/go/internal/base" "cmd/go/internal/modload" "cmd/go/internal/search" - "cmd/internal/str" + "cmd/go/internal/str" "golang.org/x/mod/module" ) diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go index 0f5b015000..845bf2f8a2 100644 --- a/src/cmd/go/internal/modload/load.go +++ b/src/cmd/go/internal/modload/load.go @@ -119,7 +119,7 @@ import ( "cmd/go/internal/mvs" "cmd/go/internal/par" "cmd/go/internal/search" - "cmd/internal/str" + "cmd/go/internal/str" "golang.org/x/mod/module" "golang.org/x/mod/semver" diff --git a/src/cmd/go/internal/modload/query.go b/src/cmd/go/internal/modload/query.go index c9ed129dbf..1eb484de9d 100644 --- a/src/cmd/go/internal/modload/query.go +++ b/src/cmd/go/internal/modload/query.go @@ -22,7 +22,7 @@ import ( "cmd/go/internal/modfetch" "cmd/go/internal/search" "cmd/go/internal/trace" - "cmd/internal/str" + "cmd/go/internal/str" "golang.org/x/mod/module" "golang.org/x/mod/semver" diff --git a/src/cmd/go/internal/run/run.go b/src/cmd/go/internal/run/run.go index 11e2c81b9a..03895d27eb 100644 --- a/src/cmd/go/internal/run/run.go +++ b/src/cmd/go/internal/run/run.go @@ -19,7 +19,7 @@ import ( "cmd/go/internal/load" "cmd/go/internal/modload" "cmd/go/internal/work" - "cmd/internal/str" + "cmd/go/internal/str" ) var CmdRun = &base.Command{ diff --git a/src/cmd/internal/str/path.go b/src/cmd/go/internal/str/path.go similarity index 100% rename from src/cmd/internal/str/path.go rename to src/cmd/go/internal/str/path.go diff --git a/src/cmd/go/internal/str/str.go b/src/cmd/go/internal/str/str.go new file mode 100644 index 0000000000..5bc521b9df --- /dev/null +++ b/src/cmd/go/internal/str/str.go @@ -0,0 +1,111 @@ +// Copyright 2017 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 str provides string manipulation utilities. +package str + +import ( + "bytes" + "fmt" + "unicode" + "unicode/utf8" +) + +// StringList flattens its arguments into a single []string. +// Each argument in args must have type string or []string. +func StringList(args ...interface{}) []string { + var x []string + for _, arg := range args { + switch arg := arg.(type) { + case []string: + x = append(x, arg...) + case string: + x = append(x, arg) + default: + panic("stringList: invalid argument of type " + fmt.Sprintf("%T", arg)) + } + } + return x +} + +// ToFold returns a string with the property that +// strings.EqualFold(s, t) iff ToFold(s) == ToFold(t) +// This lets us test a large set of strings for fold-equivalent +// duplicates without making a quadratic number of calls +// to EqualFold. Note that strings.ToUpper and strings.ToLower +// do not have the desired property in some corner cases. +func ToFold(s string) string { + // Fast path: all ASCII, no upper case. + // Most paths look like this already. + for i := 0; i < len(s); i++ { + c := s[i] + if c >= utf8.RuneSelf || 'A' <= c && c <= 'Z' { + goto Slow + } + } + return s + +Slow: + var buf bytes.Buffer + for _, r := range s { + // SimpleFold(x) cycles to the next equivalent rune > x + // or wraps around to smaller values. Iterate until it wraps, + // and we've found the minimum value. + for { + r0 := r + r = unicode.SimpleFold(r0) + if r <= r0 { + break + } + } + // Exception to allow fast path above: A-Z => a-z + if 'A' <= r && r <= 'Z' { + r += 'a' - 'A' + } + buf.WriteRune(r) + } + return buf.String() +} + +// FoldDup reports a pair of strings from the list that are +// equal according to strings.EqualFold. +// It returns "", "" if there are no such strings. +func FoldDup(list []string) (string, string) { + clash := map[string]string{} + for _, s := range list { + fold := ToFold(s) + if t := clash[fold]; t != "" { + if s > t { + s, t = t, s + } + return s, t + } + clash[fold] = s + } + return "", "" +} + +// Contains reports whether x contains s. +func Contains(x []string, s string) bool { + for _, t := range x { + if t == s { + return true + } + } + return false +} + +// Uniq removes consecutive duplicate strings from ss. +func Uniq(ss *[]string) { + if len(*ss) <= 1 { + return + } + uniq := (*ss)[:1] + for _, s := range *ss { + if s != uniq[len(uniq)-1] { + uniq = append(uniq, s) + } + } + *ss = uniq +} diff --git a/src/cmd/go/internal/str/str_test.go b/src/cmd/go/internal/str/str_test.go new file mode 100644 index 0000000000..8ea758e0a8 --- /dev/null +++ b/src/cmd/go/internal/str/str_test.go @@ -0,0 +1,29 @@ +// Copyright 2020 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 str + +import ( + "testing" +) + +var foldDupTests = []struct { + list []string + f1, f2 string +}{ + {StringList("math/rand", "math/big"), "", ""}, + {StringList("math", "strings"), "", ""}, + {StringList("strings"), "", ""}, + {StringList("strings", "strings"), "strings", "strings"}, + {StringList("Rand", "rand", "math", "math/rand", "math/Rand"), "Rand", "rand"}, +} + +func TestFoldDup(t *testing.T) { + for _, tt := range foldDupTests { + f1, f2 := FoldDup(tt.list) + if f1 != tt.f1 || f2 != tt.f2 { + t.Errorf("foldDup(%q) = %q, %q, want %q, %q", tt.list, f1, f2, tt.f1, tt.f2) + } + } +} diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index dc1bea505b..ea1d4ff20e 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -33,7 +33,7 @@ import ( "cmd/go/internal/search" "cmd/go/internal/trace" "cmd/go/internal/work" - "cmd/internal/str" + "cmd/go/internal/str" "cmd/internal/test2json" ) diff --git a/src/cmd/go/internal/vcs/vcs.go b/src/cmd/go/internal/vcs/vcs.go index 941bd57147..c4853d7ae3 100644 --- a/src/cmd/go/internal/vcs/vcs.go +++ b/src/cmd/go/internal/vcs/vcs.go @@ -27,7 +27,7 @@ import ( "cmd/go/internal/cfg" "cmd/go/internal/search" "cmd/go/internal/web" - "cmd/internal/str" + "cmd/go/internal/str" "golang.org/x/mod/module" ) diff --git a/src/cmd/go/internal/work/buildid.go b/src/cmd/go/internal/work/buildid.go index 15f944d2af..d4f2a716d7 100644 --- a/src/cmd/go/internal/work/buildid.go +++ b/src/cmd/go/internal/work/buildid.go @@ -16,7 +16,7 @@ import ( "cmd/go/internal/cfg" "cmd/go/internal/fsys" "cmd/internal/buildid" - "cmd/internal/str" + "cmd/go/internal/str" ) // Build IDs diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index 62d8143828..03f8866cf2 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -34,8 +34,9 @@ import ( "cmd/go/internal/fsys" "cmd/go/internal/load" "cmd/go/internal/modload" + "cmd/go/internal/str" "cmd/go/internal/trace" - "cmd/internal/str" + "cmd/internal/quoted" "cmd/internal/sys" ) @@ -2666,7 +2667,7 @@ func envList(key, def string) []string { if v == "" { v = def } - args, err := str.SplitQuotedFields(v) + args, err := quoted.Split(v) if err != nil { panic(fmt.Sprintf("could not parse environment variable %s with value %q: %v", key, v, err)) } diff --git a/src/cmd/go/internal/work/gc.go b/src/cmd/go/internal/work/gc.go index 3eb9b35f40..e3b4a817e7 100644 --- a/src/cmd/go/internal/work/gc.go +++ b/src/cmd/go/internal/work/gc.go @@ -20,8 +20,9 @@ import ( "cmd/go/internal/cfg" "cmd/go/internal/fsys" "cmd/go/internal/load" + "cmd/go/internal/str" "cmd/internal/objabi" - "cmd/internal/str" + "cmd/internal/quoted" "cmd/internal/sys" "crypto/sha1" ) @@ -565,7 +566,7 @@ func setextld(ldflags []string, compiler []string) ([]string, error) { return ldflags, nil } } - joined, err := str.JoinAndQuoteFields(compiler) + joined, err := quoted.Join(compiler) if err != nil { return nil, err } diff --git a/src/cmd/go/internal/work/gccgo.go b/src/cmd/go/internal/work/gccgo.go index 3cb7b64183..60181b99e4 100644 --- a/src/cmd/go/internal/work/gccgo.go +++ b/src/cmd/go/internal/work/gccgo.go @@ -17,7 +17,7 @@ import ( "cmd/go/internal/fsys" "cmd/go/internal/load" "cmd/internal/pkgpath" - "cmd/internal/str" + "cmd/go/internal/str" ) // The Gccgo toolchain. diff --git a/src/cmd/go/internal/work/init.go b/src/cmd/go/internal/work/init.go index 56e39f8c52..4dbbd2a13f 100644 --- a/src/cmd/go/internal/work/init.go +++ b/src/cmd/go/internal/work/init.go @@ -11,7 +11,7 @@ import ( "cmd/go/internal/cfg" "cmd/go/internal/fsys" "cmd/go/internal/modload" - "cmd/internal/str" + "cmd/internal/quoted" "cmd/internal/sys" "fmt" "os" @@ -46,7 +46,7 @@ func BuildInit() { // Make sure CC, CXX, and FC are absolute paths. for _, key := range []string{"CC", "CXX", "FC"} { value := cfg.Getenv(key) - args, err := str.SplitQuotedFields(value) + args, err := quoted.Split(value) if err != nil { base.Fatalf("go: %s environment variable could not be parsed: %v", key, err) } diff --git a/src/cmd/internal/quoted/quoted.go b/src/cmd/internal/quoted/quoted.go new file mode 100644 index 0000000000..e7575dfc66 --- /dev/null +++ b/src/cmd/internal/quoted/quoted.go @@ -0,0 +1,127 @@ +// Copyright 2017 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 quoted provides string manipulation utilities. +package quoted + +import ( + "flag" + "fmt" + "strings" + "unicode" +) + +func isSpaceByte(c byte) bool { + return c == ' ' || c == '\t' || c == '\n' || c == '\r' +} + +// Split splits s into a list of fields, +// allowing single or double quotes around elements. +// There is no unescaping or other processing within +// quoted fields. +func Split(s string) ([]string, error) { + // Split fields allowing '' or "" around elements. + // Quotes further inside the string do not count. + var f []string + for len(s) > 0 { + for len(s) > 0 && isSpaceByte(s[0]) { + s = s[1:] + } + if len(s) == 0 { + break + } + // Accepted quoted string. No unescaping inside. + if s[0] == '"' || s[0] == '\'' { + quote := s[0] + s = s[1:] + i := 0 + for i < len(s) && s[i] != quote { + i++ + } + if i >= len(s) { + return nil, fmt.Errorf("unterminated %c string", quote) + } + f = append(f, s[:i]) + s = s[i+1:] + continue + } + i := 0 + for i < len(s) && !isSpaceByte(s[i]) { + i++ + } + f = append(f, s[:i]) + s = s[i:] + } + return f, nil +} + +// Join joins a list of arguments into a string that can be parsed +// with Split. Arguments are quoted only if necessary; arguments +// without spaces or quotes are kept as-is. No argument may contain both +// single and double quotes. +func Join(args []string) (string, error) { + var buf []byte + for i, arg := range args { + if i > 0 { + buf = append(buf, ' ') + } + var sawSpace, sawSingleQuote, sawDoubleQuote bool + for _, c := range arg { + switch { + case c > unicode.MaxASCII: + continue + case isSpaceByte(byte(c)): + sawSpace = true + case c == '\'': + sawSingleQuote = true + case c == '"': + sawDoubleQuote = true + } + } + switch { + case !sawSpace && !sawSingleQuote && !sawDoubleQuote: + buf = append(buf, []byte(arg)...) + + case !sawSingleQuote: + buf = append(buf, '\'') + buf = append(buf, []byte(arg)...) + buf = append(buf, '\'') + + case !sawDoubleQuote: + buf = append(buf, '"') + buf = append(buf, []byte(arg)...) + buf = append(buf, '"') + + default: + return "", fmt.Errorf("argument %q contains both single and double quotes and cannot be quoted", arg) + } + } + return string(buf), nil +} + +// A Flag parses a list of string arguments encoded with Join. +// It is useful for flags like cmd/link's -extldflags. +type Flag []string + +var _ flag.Value = (*Flag)(nil) + +func (f *Flag) Set(v string) error { + fs, err := Split(v) + if err != nil { + return err + } + *f = fs[:len(fs):len(fs)] + return nil +} + +func (f *Flag) String() string { + if f == nil { + return "" + } + s, err := Join(*f) + if err != nil { + return strings.Join(*f, " ") + } + return s +} diff --git a/src/cmd/internal/str/str_test.go b/src/cmd/internal/quoted/quoted_test.go similarity index 79% rename from src/cmd/internal/str/str_test.go rename to src/cmd/internal/quoted/quoted_test.go index 3609af6a06..d76270c87b 100644 --- a/src/cmd/internal/str/str_test.go +++ b/src/cmd/internal/quoted/quoted_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. -package str +package quoted import ( "reflect" @@ -10,27 +10,7 @@ import ( "testing" ) -var foldDupTests = []struct { - list []string - f1, f2 string -}{ - {StringList("math/rand", "math/big"), "", ""}, - {StringList("math", "strings"), "", ""}, - {StringList("strings"), "", ""}, - {StringList("strings", "strings"), "strings", "strings"}, - {StringList("Rand", "rand", "math", "math/rand", "math/Rand"), "Rand", "rand"}, -} - -func TestFoldDup(t *testing.T) { - for _, tt := range foldDupTests { - f1, f2 := FoldDup(tt.list) - if f1 != tt.f1 || f2 != tt.f2 { - t.Errorf("foldDup(%q) = %q, %q, want %q, %q", tt.list, f1, f2, tt.f1, tt.f2) - } - } -} - -func TestSplitQuotedFields(t *testing.T) { +func TestSplit(t *testing.T) { for _, test := range []struct { name string value string @@ -54,7 +34,7 @@ func TestSplitQuotedFields(t *testing.T) { {name: "quote_unclosed", value: `'a`, wantErr: "unterminated ' string"}, } { t.Run(test.name, func(t *testing.T) { - got, err := SplitQuotedFields(test.value) + got, err := Split(test.value) if err != nil { if test.wantErr == "" { t.Fatalf("unexpected error: %v", err) @@ -73,7 +53,7 @@ func TestSplitQuotedFields(t *testing.T) { } } -func TestJoinAndQuoteFields(t *testing.T) { +func TestJoin(t *testing.T) { for _, test := range []struct { name string args []string @@ -88,7 +68,7 @@ func TestJoinAndQuoteFields(t *testing.T) { {name: "unquoteable", args: []string{`'"`}, wantErr: "contains both single and double quotes and cannot be quoted"}, } { t.Run(test.name, func(t *testing.T) { - got, err := JoinAndQuoteFields(test.args) + got, err := Join(test.args) if err != nil { if test.wantErr == "" { t.Fatalf("unexpected error: %v", err) diff --git a/src/cmd/internal/str/str.go b/src/cmd/internal/str/str.go deleted file mode 100644 index 409cf8f7b4..0000000000 --- a/src/cmd/internal/str/str.go +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright 2017 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 str provides string manipulation utilities. -package str - -import ( - "bytes" - "flag" - "fmt" - "strings" - "unicode" - "unicode/utf8" -) - -// StringList flattens its arguments into a single []string. -// Each argument in args must have type string or []string. -func StringList(args ...interface{}) []string { - var x []string - for _, arg := range args { - switch arg := arg.(type) { - case []string: - x = append(x, arg...) - case string: - x = append(x, arg) - default: - panic("stringList: invalid argument of type " + fmt.Sprintf("%T", arg)) - } - } - return x -} - -// ToFold returns a string with the property that -// strings.EqualFold(s, t) iff ToFold(s) == ToFold(t) -// This lets us test a large set of strings for fold-equivalent -// duplicates without making a quadratic number of calls -// to EqualFold. Note that strings.ToUpper and strings.ToLower -// do not have the desired property in some corner cases. -func ToFold(s string) string { - // Fast path: all ASCII, no upper case. - // Most paths look like this already. - for i := 0; i < len(s); i++ { - c := s[i] - if c >= utf8.RuneSelf || 'A' <= c && c <= 'Z' { - goto Slow - } - } - return s - -Slow: - var buf bytes.Buffer - for _, r := range s { - // SimpleFold(x) cycles to the next equivalent rune > x - // or wraps around to smaller values. Iterate until it wraps, - // and we've found the minimum value. - for { - r0 := r - r = unicode.SimpleFold(r0) - if r <= r0 { - break - } - } - // Exception to allow fast path above: A-Z => a-z - if 'A' <= r && r <= 'Z' { - r += 'a' - 'A' - } - buf.WriteRune(r) - } - return buf.String() -} - -// FoldDup reports a pair of strings from the list that are -// equal according to strings.EqualFold. -// It returns "", "" if there are no such strings. -func FoldDup(list []string) (string, string) { - clash := map[string]string{} - for _, s := range list { - fold := ToFold(s) - if t := clash[fold]; t != "" { - if s > t { - s, t = t, s - } - return s, t - } - clash[fold] = s - } - return "", "" -} - -// Contains reports whether x contains s. -func Contains(x []string, s string) bool { - for _, t := range x { - if t == s { - return true - } - } - return false -} - -// Uniq removes consecutive duplicate strings from ss. -func Uniq(ss *[]string) { - if len(*ss) <= 1 { - return - } - uniq := (*ss)[:1] - for _, s := range *ss { - if s != uniq[len(uniq)-1] { - uniq = append(uniq, s) - } - } - *ss = uniq -} - -func isSpaceByte(c byte) bool { - return c == ' ' || c == '\t' || c == '\n' || c == '\r' -} - -// SplitQuotedFields splits s into a list of fields, -// allowing single or double quotes around elements. -// There is no unescaping or other processing within -// quoted fields. -func SplitQuotedFields(s string) ([]string, error) { - // Split fields allowing '' or "" around elements. - // Quotes further inside the string do not count. - var f []string - for len(s) > 0 { - for len(s) > 0 && isSpaceByte(s[0]) { - s = s[1:] - } - if len(s) == 0 { - break - } - // Accepted quoted string. No unescaping inside. - if s[0] == '"' || s[0] == '\'' { - quote := s[0] - s = s[1:] - i := 0 - for i < len(s) && s[i] != quote { - i++ - } - if i >= len(s) { - return nil, fmt.Errorf("unterminated %c string", quote) - } - f = append(f, s[:i]) - s = s[i+1:] - continue - } - i := 0 - for i < len(s) && !isSpaceByte(s[i]) { - i++ - } - f = append(f, s[:i]) - s = s[i:] - } - return f, nil -} - -// JoinAndQuoteFields joins a list of arguments into a string that can be parsed -// with SplitQuotedFields. Arguments are quoted only if necessary; arguments -// without spaces or quotes are kept as-is. No argument may contain both -// single and double quotes. -func JoinAndQuoteFields(args []string) (string, error) { - var buf []byte - for i, arg := range args { - if i > 0 { - buf = append(buf, ' ') - } - var sawSpace, sawSingleQuote, sawDoubleQuote bool - for _, c := range arg { - switch { - case c > unicode.MaxASCII: - continue - case isSpaceByte(byte(c)): - sawSpace = true - case c == '\'': - sawSingleQuote = true - case c == '"': - sawDoubleQuote = true - } - } - switch { - case !sawSpace && !sawSingleQuote && !sawDoubleQuote: - buf = append(buf, []byte(arg)...) - - case !sawSingleQuote: - buf = append(buf, '\'') - buf = append(buf, []byte(arg)...) - buf = append(buf, '\'') - - case !sawDoubleQuote: - buf = append(buf, '"') - buf = append(buf, []byte(arg)...) - buf = append(buf, '"') - - default: - return "", fmt.Errorf("argument %q contains both single and double quotes and cannot be quoted", arg) - } - } - return string(buf), nil -} - -// A QuotedStringListFlag parses a list of string arguments encoded with -// JoinAndQuoteFields. It is useful for flags like cmd/link's -extldflags. -type QuotedStringListFlag []string - -var _ flag.Value = (*QuotedStringListFlag)(nil) - -func (f *QuotedStringListFlag) Set(v string) error { - fs, err := SplitQuotedFields(v) - if err != nil { - return err - } - *f = fs[:len(fs):len(fs)] - return nil -} - -func (f *QuotedStringListFlag) String() string { - if f == nil { - return "" - } - s, err := JoinAndQuoteFields(*f) - if err != nil { - return strings.Join(*f, " ") - } - return s -} diff --git a/src/cmd/link/dwarf_test.go b/src/cmd/link/dwarf_test.go index f7bbb014d9..78ef3cfe97 100644 --- a/src/cmd/link/dwarf_test.go +++ b/src/cmd/link/dwarf_test.go @@ -8,7 +8,7 @@ import ( "bytes" cmddwarf "cmd/internal/dwarf" "cmd/internal/objfile" - "cmd/internal/str" + "cmd/internal/quoted" "debug/dwarf" "internal/testenv" "os" @@ -68,7 +68,7 @@ func testDWARF(t *testing.T, buildmode string, expectDWARF bool, env ...string) if extld == "" { extld = "gcc" } - extldArgs, err := str.SplitQuotedFields(extld) + extldArgs, err := quoted.Split(extld) if err != nil { t.Fatal(err) } diff --git a/src/cmd/link/internal/ld/main.go b/src/cmd/link/internal/ld/main.go index a5a5a71250..a1d86965e4 100644 --- a/src/cmd/link/internal/ld/main.go +++ b/src/cmd/link/internal/ld/main.go @@ -34,7 +34,7 @@ import ( "bufio" "cmd/internal/goobj" "cmd/internal/objabi" - "cmd/internal/str" + "cmd/internal/quoted" "cmd/internal/sys" "cmd/link/internal/benchmark" "flag" @@ -76,8 +76,8 @@ var ( flagLibGCC = flag.String("libgcc", "", "compiler support lib for internal linking; use \"none\" to disable") flagTmpdir = flag.String("tmpdir", "", "use `directory` for temporary files") - flagExtld str.QuotedStringListFlag - flagExtldflags str.QuotedStringListFlag + flagExtld quoted.Flag + flagExtldflags quoted.Flag flagExtar = flag.String("extar", "", "archive program for buildmode=c-archive") flagA = flag.Bool("a", false, "no-op (deprecated)") From c0ac39c70eeeaadbebe13efb407a1a272a926d30 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Mon, 25 Oct 2021 13:26:54 -0400 Subject: [PATCH 180/406] go/types: remove a stale comment Clean up a comment that was deleted in types2 in CL 353135. Change-Id: If339efa133e2a3d1eaa3b1e69458471677018261 Reviewed-on: https://go-review.googlesource.com/c/go/+/358517 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/typestring.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/go/types/typestring.go b/src/go/types/typestring.go index 2feaf627d6..9154ebc406 100644 --- a/src/go/types/typestring.go +++ b/src/go/types/typestring.go @@ -275,9 +275,6 @@ func (w *typeWriter) typ(typ Type) { break } // Optionally write out package for typeparams (like Named). - // TODO(danscales): this is required for import/export, so - // we maybe need a separate function that won't be changed - // for debugging purposes. if t.obj.pkg != nil { writePackage(w.buf, t.obj.pkg, w.qf) } From bb49eb3e6a464fbbebd425c4b84c32609b27ecf2 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 26 Oct 2021 21:12:31 -0700 Subject: [PATCH 181/406] cmd/compile/internal/syntax: fix constraint literal parsing for generic functions Fixes #49174. Change-Id: I943c370f7abd5f50a541e682f130b3526c3b5bdb Reviewed-on: https://go-review.googlesource.com/c/go/+/359014 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/syntax/parser.go | 14 +++++++++++++- .../compile/internal/syntax/testdata/typeset.go2 | 13 ++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go index e78e77561d..af5a505cdb 100644 --- a/src/cmd/compile/internal/syntax/parser.go +++ b/src/cmd/compile/internal/syntax/parser.go @@ -588,19 +588,24 @@ func (p *parser) typeDecl(group *Group) Decl { d.Name = p.name() if p.tok == _Lbrack { // array/slice or generic type + // name "[" ... pos := p.pos() p.next() switch p.tok { case _Rbrack: + // name "[" "]" ... p.next() d.Type = p.sliceType(pos) case _Name: // array or generic type + // name "[" name ... p.xnest++ + // TODO(gri) p.expr may consume an opening "[" when it shouldn't (issue #49175) x := p.expr() p.xnest-- if name0, ok := x.(*Name); p.allowGenerics() && ok && p.tok != _Rbrack { // generic type + // name "[" name ... d.TParamList = p.paramList(name0, _Rbrack, true) pos := p.pos() if p.gotAssign() { @@ -609,12 +614,14 @@ func (p *parser) typeDecl(group *Group) Decl { d.Type = p.typeOrNil() } else { // x is the array length expression + // name "[" x ... if debug && x == nil { panic("length expression is nil") } d.Type = p.arrayType(pos, x) } default: + // name "[" ... d.Type = p.arrayType(pos, nil) } } else { @@ -1816,7 +1823,7 @@ func (p *parser) embeddedTerm() Expr { // ParameterDecl = [ IdentifierList ] [ "..." ] Type . func (p *parser) paramDeclOrNil(name *Name, follow token) *Field { if trace { - defer p.trace("paramDecl")() + defer p.trace("paramDeclOrNil")() } // type set notation is ok in type parameter lists @@ -1849,6 +1856,11 @@ func (p *parser) paramDeclOrNil(name *Name, follow token) *Field { // name "[" n "]" E f.Name = name } + if typeSetsOk && p.tok == _Operator && p.op == Or { + // name "[" ... "]" "|" ... + // name "[" n "]" E "|" ... + f = p.embeddedElem(f) + } return f } diff --git a/src/cmd/compile/internal/syntax/testdata/typeset.go2 b/src/cmd/compile/internal/syntax/testdata/typeset.go2 index a173bb1d4f..78d3fe1ae5 100644 --- a/src/cmd/compile/internal/syntax/testdata/typeset.go2 +++ b/src/cmd/compile/internal/syntax/testdata/typeset.go2 @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // This file contains test cases for typeset-only constraint elements. -// TODO(gri) gofmt once/if gofmt supports this notation. package p @@ -44,8 +43,20 @@ type ( _[_ ~t|struct{}] t _[_ t|~struct{}] t _[_ ~t|~struct{}] t + + // TODO(gri) fix this (issue #49175) + // _[_ []t]t + _[_ ~[]t]t ) +// test cases for issue #49174 +func _[_ t]() {} +func _[_ []t]() {} +func _[_ []t | t]() {} +func _[_ t | []t]() {} +func _[_ []t | []t]() {} +func _[_ t[t] | t[t]]() {} + // Single-expression type parameter lists and those that don't start // with a (type parameter) name are considered array sizes. // The term must be a valid expression (it could be a type - and then From 259735f97a2dfd33849eacef15047f5a0964498e Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Tue, 24 Aug 2021 14:09:26 -0500 Subject: [PATCH 182/406] cmd/compile: enable branchelim pass on ppc64 and fix/cleanup lowering of the SSA operator created by the pass. Change-Id: I7e6153194fd16013e3b24da8aa40683adafa3d15 Reviewed-on: https://go-review.googlesource.com/c/go/+/344573 Run-TryBot: Paul Murphy TryBot-Result: Go Bot Reviewed-by: Lynn Boger Reviewed-by: Cherry Mui Trust: Josh Bleecher Snyder --- src/cmd/compile/internal/ssa/branchelim.go | 2 +- src/cmd/compile/internal/ssa/gen/PPC64.rules | 7 ++- src/cmd/compile/internal/ssa/rewritePPC64.go | 51 +++++++++++++------- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/cmd/compile/internal/ssa/branchelim.go b/src/cmd/compile/internal/ssa/branchelim.go index 1d34f8160b..be5f9e0a8b 100644 --- a/src/cmd/compile/internal/ssa/branchelim.go +++ b/src/cmd/compile/internal/ssa/branchelim.go @@ -22,7 +22,7 @@ import "cmd/internal/src" func branchelim(f *Func) { // FIXME: add support for lowering CondSelects on more architectures switch f.Config.arch { - case "arm64", "amd64", "wasm": + case "arm64", "ppc64le", "ppc64", "amd64", "wasm": // implemented default: return diff --git a/src/cmd/compile/internal/ssa/gen/PPC64.rules b/src/cmd/compile/internal/ssa/gen/PPC64.rules index ccca72a416..c3f07a4e22 100644 --- a/src/cmd/compile/internal/ssa/gen/PPC64.rules +++ b/src/cmd/compile/internal/ssa/gen/PPC64.rules @@ -561,8 +561,10 @@ ((EQ|NE|LT|LE|GT|GE) (CMPconst [0] z:(OR x y)) yes no) && z.Uses == 1 => ((EQ|NE|LT|LE|GT|GE) (ORCC x y) yes no) ((EQ|NE|LT|LE|GT|GE) (CMPconst [0] z:(XOR x y)) yes no) && z.Uses == 1 => ((EQ|NE|LT|LE|GT|GE) (XORCC x y) yes no) -(CondSelect x y bool) && flagArg(bool) != nil => (ISEL [2] x y bool) -(CondSelect x y bool) && flagArg(bool) == nil => (ISEL [2] x y (CMPWconst [0] bool)) +// Only lower after bool is lowered. It should always lower. This helps ensure the folding below happens reliably. +(CondSelect x y bool) && flagArg(bool) == nil => (ISEL [6] x y (CMPWconst [0] bool)) +// Fold any CR -> GPR -> CR transfers when applying the above rule. +(ISEL [6] x y (CMPWconst [0] (ISELB [c] one cmp))) => (ISEL [c] x y cmp) // Lowering loads (Load ptr mem) && (is64BitInt(t) || isPtr(t)) => (MOVDload ptr mem) @@ -849,6 +851,7 @@ (NEG (ADDconst [c] x)) && is32Bit(-c) => (SUBFCconst [-c] x) (NEG (SUBFCconst [c] x)) && is32Bit(-c) => (ADDconst [-c] x) (NEG (SUB x y)) => (SUB y x) +(NEG (NEG x)) => x // Use register moves instead of stores and loads to move int<=>float values // Common with math Float64bits, Float64frombits diff --git a/src/cmd/compile/internal/ssa/rewritePPC64.go b/src/cmd/compile/internal/ssa/rewritePPC64.go index ea1c1fa60a..7592b4f505 100644 --- a/src/cmd/compile/internal/ssa/rewritePPC64.go +++ b/src/cmd/compile/internal/ssa/rewritePPC64.go @@ -1168,23 +1168,8 @@ func rewriteValuePPC64_OpCondSelect(v *Value) bool { v_0 := v.Args[0] b := v.Block // match: (CondSelect x y bool) - // cond: flagArg(bool) != nil - // result: (ISEL [2] x y bool) - for { - x := v_0 - y := v_1 - bool := v_2 - if !(flagArg(bool) != nil) { - break - } - v.reset(OpPPC64ISEL) - v.AuxInt = int32ToAuxInt(2) - v.AddArg3(x, y, bool) - return true - } - // match: (CondSelect x y bool) // cond: flagArg(bool) == nil - // result: (ISEL [2] x y (CMPWconst [0] bool)) + // result: (ISEL [6] x y (CMPWconst [0] bool)) for { x := v_0 y := v_1 @@ -1193,7 +1178,7 @@ func rewriteValuePPC64_OpCondSelect(v *Value) bool { break } v.reset(OpPPC64ISEL) - v.AuxInt = int32ToAuxInt(2) + v.AuxInt = int32ToAuxInt(6) v0 := b.NewValue0(v.Pos, OpPPC64CMPWconst, types.TypeFlags) v0.AuxInt = int32ToAuxInt(0) v0.AddArg(bool) @@ -5910,6 +5895,28 @@ func rewriteValuePPC64_OpPPC64ISEL(v *Value) bool { v.AddArg(y) return true } + // match: (ISEL [6] x y (CMPWconst [0] (ISELB [c] one cmp))) + // result: (ISEL [c] x y cmp) + for { + if auxIntToInt32(v.AuxInt) != 6 { + break + } + x := v_0 + y := v_1 + if v_2.Op != OpPPC64CMPWconst || auxIntToInt32(v_2.AuxInt) != 0 { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpPPC64ISELB { + break + } + c := auxIntToInt32(v_2_0.AuxInt) + cmp := v_2_0.Args[1] + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, cmp) + return true + } // match: (ISEL [2] x _ (FlagEQ)) // result: x for { @@ -11384,6 +11391,16 @@ func rewriteValuePPC64_OpPPC64NEG(v *Value) bool { v.AddArg2(y, x) return true } + // match: (NEG (NEG x)) + // result: x + for { + if v_0.Op != OpPPC64NEG { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } return false } func rewriteValuePPC64_OpPPC64NOR(v *Value) bool { From 514ebaec358488d1dcf7253b9d05b4ad8c76c390 Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Fri, 22 Oct 2021 15:59:15 -0400 Subject: [PATCH 183/406] internal/fuzz: don't deflake coverage found while fuzzing Previously, the worker would attempt to deflake an input that was reported to have caused new coverage. The chances of a flake causing new coverage seem pretty low to me, and even if it was a flake that caused it, adding that input to the cache doesn't seem like a bad thing. The input is already going to be deflaked during minimization anyway. If by some off-chance the code is causing a lot of flaky coverage increases, and the user doesn't want minimization to occur, then setting -fuzzminimizetime=1x will deflake in the way they want without minimizing. This can be documented as needed. This fixes a bug where the mem.header().count could have been one too large if an unrecoverable crash occured while deflaking an input that caused code coverage. Fixes #49047 Change-Id: Ibdf893d7a89a46dd700702afb09e35623615390e Reviewed-on: https://go-review.googlesource.com/c/go/+/358094 Trust: Katie Hockman Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Julie Qiu Reviewed-by: Roland Shoemaker Reviewed-by: Bryan C. Mills --- .../script/test_fuzz_mutator_repeat.txt | 24 ++++++++++++------- src/internal/fuzz/worker.go | 17 +++---------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt b/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt index f2952c349b..15d7cb6b32 100644 --- a/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt +++ b/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt @@ -1,5 +1,3 @@ -skip # Flaky: https://golang.org/issue/49047 - # TODO(jayconrod): support shared memory on more platforms. [!darwin] [!linux] [!windows] skip @@ -9,11 +7,11 @@ skip # Flaky: https://golang.org/issue/49047 [short] skip -# Start fuzzing. The worker crashes after ~100 iterations. +# Start fuzzing. The worker crashes after 100 iterations. # The fuzz function writes the crashing input to "want" before exiting. # The fuzzing engine reconstructs the crashing input and saves it to testdata. ! exists want -! go test -fuzz=. -parallel=1 +! go test -fuzz=. -parallel=1 -fuzztime=110x -fuzzminimizetime=10x -v stdout 'fuzzing process terminated unexpectedly' stdout 'Crash written to testdata' @@ -46,12 +44,20 @@ func FuzzRepeat(f *testing.F) { if i == 100 { f, err := os.OpenFile("want", os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0666) if err != nil { - // Couldn't create the file, probably because it already exists, - // and we're minimizing now. Return without crashing. - return + // Couldn't create the file. Return without crashing, and try + // again. + i-- + t.Skip(err) + } + if _, err := f.Write(b); err != nil { + // We already created the file, so if we failed to write it + // there's not much we can do. The test will fail anyway, but + // at least make sure the error is logged to stdout. + t.Fatal(err) + } + if err := f.Close(); err != nil { + t.Fatal(err) } - f.Write(b) - f.Close() os.Exit(1) // crash without communicating } diff --git a/src/internal/fuzz/worker.go b/src/internal/fuzz/worker.go index b36ebe2a7e..388675f713 100644 --- a/src/internal/fuzz/worker.go +++ b/src/internal/fuzz/worker.go @@ -738,20 +738,9 @@ func (ws *workerServer) fuzz(ctx context.Context, args fuzzArgs) (resp fuzzRespo return resp } if cov != nil { - // Found new coverage. Before reporting to the coordinator, - // run the same values once more to deflake. - if !shouldStop() { - dur, cov, errMsg = fuzzOnce(entry) - if errMsg != "" { - resp.Err = errMsg - return resp - } - } - if cov != nil { - resp.CoverageData = cov - resp.InterestingDuration = dur - return resp - } + resp.CoverageData = cov + resp.InterestingDuration = dur + return resp } if shouldStop() { return resp From ffd2284db06d433d60aa75ea413f407b90e583b6 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 27 Oct 2021 15:06:23 -0400 Subject: [PATCH 184/406] cmd/go: fix testdata/script/mod_vendor_goversion for new compiler output The message is now a single line, but I couldn't get '\n?' to work. (This test does not run in short mode.) Change-Id: I3d7033f78ac2bf41db7fdfe96cbb988c4533d834 Reviewed-on: https://go-review.googlesource.com/c/go/+/359095 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/cmd/go/testdata/script/mod_vendor_goversion.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/go/testdata/script/mod_vendor_goversion.txt b/src/cmd/go/testdata/script/mod_vendor_goversion.txt index b4489dae7e..a92eb73d27 100644 --- a/src/cmd/go/testdata/script/mod_vendor_goversion.txt +++ b/src/cmd/go/testdata/script/mod_vendor_goversion.txt @@ -3,7 +3,6 @@ [short] skip - # Control case: without a vendor directory, need117 builds and bad114 doesn't. go build example.net/need117 @@ -26,7 +25,8 @@ go mod vendor ! grep 1.17 vendor/modules.txt ! go build example.net/need117 -stderr '^vendor[/\\]example\.net[/\\]need117[/\\]need117.go:5:1[89]:.*\n\tconversion of slices to array pointers only supported as of -lang=go1\.17' +stderr '^vendor[/\\]example\.net[/\\]need117[/\\]need117.go:5:1[89]:' +stderr 'conversion of slices to array pointers only supported as of -lang=go1\.17' ! grep 1.13 vendor/modules.txt go build example.net/bad114 From 68bd5121ee8954cfd7e3f7edb5d035f0e8b1bccc Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 27 Oct 2021 14:29:29 -0400 Subject: [PATCH 185/406] cmd/go: remove support for -buildmode=shared It never worked in module mode (or with a read-only GOROOT). A proposal to drop it was filed (and approved) in https://golang.org/issue/47788. Fixes #47788 Change-Id: I0c12f38eb0c5dfe9384fbdb49ed202301fa4273d Reviewed-on: https://go-review.googlesource.com/c/go/+/359096 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- doc/go1.18.html | 7 + misc/cgo/testshared/overlaydir_test.go | 78 -- misc/cgo/testshared/shared_test.go | 1080 ----------------- misc/cgo/testshared/testdata/dep2/dep2.go | 15 - misc/cgo/testshared/testdata/dep3/dep3.go | 22 - misc/cgo/testshared/testdata/depBase/asm.s | 10 - misc/cgo/testshared/testdata/depBase/dep.go | 37 - misc/cgo/testshared/testdata/depBase/gccgo.go | 9 - misc/cgo/testshared/testdata/depBase/stubs.go | 9 - .../testshared/testdata/division/division.go | 17 - misc/cgo/testshared/testdata/exe/exe.go | 45 - misc/cgo/testshared/testdata/exe2/exe2.go | 8 - misc/cgo/testshared/testdata/exe3/exe3.go | 7 - misc/cgo/testshared/testdata/execgo/exe.go | 8 - .../testshared/testdata/explicit/explicit.go | 9 - .../testshared/testdata/gcdata/main/main.go | 37 - misc/cgo/testshared/testdata/gcdata/p/p.go | 7 - misc/cgo/testshared/testdata/global/main.go | 71 -- .../testshared/testdata/globallib/global.go | 17 - misc/cgo/testshared/testdata/iface/main.go | 17 - misc/cgo/testshared/testdata/iface_a/a.go | 17 - misc/cgo/testshared/testdata/iface_b/b.go | 17 - misc/cgo/testshared/testdata/iface_i/i.go | 17 - .../testshared/testdata/implicit/implicit.go | 5 - .../testdata/implicitcmd/implicitcmd.go | 10 - misc/cgo/testshared/testdata/issue25065/a.go | 20 - .../testdata/issue30768/issue30768lib/lib.go | 11 - .../testshared/testdata/issue30768/x_test.go | 22 - .../cgo/testshared/testdata/issue39777/a/a.go | 9 - .../cgo/testshared/testdata/issue39777/b/b.go | 7 - .../cgo/testshared/testdata/issue44031/a/a.go | 9 - .../cgo/testshared/testdata/issue44031/b/b.go | 17 - .../testdata/issue44031/main/main.go | 20 - .../cgo/testshared/testdata/issue47837/a/a.go | 19 - .../testdata/issue47837/main/main.go | 14 - .../testshared/testdata/trivial/trivial.go | 9 - src/cmd/dist/test.go | 9 - src/cmd/go/alldocs.go | 9 - src/cmd/go/internal/help/helpdoc.go | 5 - src/cmd/go/internal/list/list.go | 3 +- src/cmd/go/internal/work/build.go | 3 - src/cmd/go/internal/work/init.go | 31 +- .../go/testdata/script/list_linkshared.txt | 16 - src/cmd/internal/sys/supported.go | 7 - 44 files changed, 30 insertions(+), 1786 deletions(-) delete mode 100644 misc/cgo/testshared/overlaydir_test.go delete mode 100644 misc/cgo/testshared/shared_test.go delete mode 100644 misc/cgo/testshared/testdata/dep2/dep2.go delete mode 100644 misc/cgo/testshared/testdata/dep3/dep3.go delete mode 100644 misc/cgo/testshared/testdata/depBase/asm.s delete mode 100644 misc/cgo/testshared/testdata/depBase/dep.go delete mode 100644 misc/cgo/testshared/testdata/depBase/gccgo.go delete mode 100644 misc/cgo/testshared/testdata/depBase/stubs.go delete mode 100644 misc/cgo/testshared/testdata/division/division.go delete mode 100644 misc/cgo/testshared/testdata/exe/exe.go delete mode 100644 misc/cgo/testshared/testdata/exe2/exe2.go delete mode 100644 misc/cgo/testshared/testdata/exe3/exe3.go delete mode 100644 misc/cgo/testshared/testdata/execgo/exe.go delete mode 100644 misc/cgo/testshared/testdata/explicit/explicit.go delete mode 100644 misc/cgo/testshared/testdata/gcdata/main/main.go delete mode 100644 misc/cgo/testshared/testdata/gcdata/p/p.go delete mode 100644 misc/cgo/testshared/testdata/global/main.go delete mode 100644 misc/cgo/testshared/testdata/globallib/global.go delete mode 100644 misc/cgo/testshared/testdata/iface/main.go delete mode 100644 misc/cgo/testshared/testdata/iface_a/a.go delete mode 100644 misc/cgo/testshared/testdata/iface_b/b.go delete mode 100644 misc/cgo/testshared/testdata/iface_i/i.go delete mode 100644 misc/cgo/testshared/testdata/implicit/implicit.go delete mode 100644 misc/cgo/testshared/testdata/implicitcmd/implicitcmd.go delete mode 100644 misc/cgo/testshared/testdata/issue25065/a.go delete mode 100644 misc/cgo/testshared/testdata/issue30768/issue30768lib/lib.go delete mode 100644 misc/cgo/testshared/testdata/issue30768/x_test.go delete mode 100644 misc/cgo/testshared/testdata/issue39777/a/a.go delete mode 100644 misc/cgo/testshared/testdata/issue39777/b/b.go delete mode 100644 misc/cgo/testshared/testdata/issue44031/a/a.go delete mode 100644 misc/cgo/testshared/testdata/issue44031/b/b.go delete mode 100644 misc/cgo/testshared/testdata/issue44031/main/main.go delete mode 100644 misc/cgo/testshared/testdata/issue47837/a/a.go delete mode 100644 misc/cgo/testshared/testdata/issue47837/main/main.go delete mode 100644 misc/cgo/testshared/testdata/trivial/trivial.go delete mode 100644 src/cmd/go/testdata/script/list_linkshared.txt diff --git a/doc/go1.18.html b/doc/go1.18.html index 985689cf31..63a6ed8fcd 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -89,6 +89,13 @@ Do not send CLs removing the interior tags from such phrases. package.

+

+ The go command no longer supports -linkshared + and -buildmode=shared. + (shared building and linking has never worked in module mode or + when GOROOT is not writable.) +

+

TODO: complete this section, or delete if not needed

diff --git a/misc/cgo/testshared/overlaydir_test.go b/misc/cgo/testshared/overlaydir_test.go deleted file mode 100644 index eb587a2d44..0000000000 --- a/misc/cgo/testshared/overlaydir_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2019 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 shared_test - -import ( - "io" - "os" - "path/filepath" - "strings" -) - -// overlayDir makes a minimal-overhead copy of srcRoot in which new files may be added. -// -// TODO: Once we no longer need to support the misc module in GOPATH mode, -// factor this function out into a package to reduce duplication. -func overlayDir(dstRoot, srcRoot string) error { - dstRoot = filepath.Clean(dstRoot) - if err := os.MkdirAll(dstRoot, 0777); err != nil { - return err - } - - srcRoot, err := filepath.Abs(srcRoot) - if err != nil { - return err - } - - return filepath.Walk(srcRoot, func(srcPath string, info os.FileInfo, err error) error { - if err != nil || srcPath == srcRoot { - return err - } - - suffix := strings.TrimPrefix(srcPath, srcRoot) - for len(suffix) > 0 && suffix[0] == filepath.Separator { - suffix = suffix[1:] - } - dstPath := filepath.Join(dstRoot, suffix) - - perm := info.Mode() & os.ModePerm - if info.Mode()&os.ModeSymlink != 0 { - info, err = os.Stat(srcPath) - if err != nil { - return err - } - perm = info.Mode() & os.ModePerm - } - - // Always copy directories (don't symlink them). - // If we add a file in the overlay, we don't want to add it in the original. - if info.IsDir() { - return os.MkdirAll(dstPath, perm|0200) - } - - // If the OS supports symlinks, use them instead of copying bytes. - if err := os.Symlink(srcPath, dstPath); err == nil { - return nil - } - - // Otherwise, copy the bytes. - src, err := os.Open(srcPath) - if err != nil { - return err - } - defer src.Close() - - dst, err := os.OpenFile(dstPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm) - if err != nil { - return err - } - - _, err = io.Copy(dst, src) - if closeErr := dst.Close(); err == nil { - err = closeErr - } - return err - }) -} diff --git a/misc/cgo/testshared/shared_test.go b/misc/cgo/testshared/shared_test.go deleted file mode 100644 index 672811fe0e..0000000000 --- a/misc/cgo/testshared/shared_test.go +++ /dev/null @@ -1,1080 +0,0 @@ -// Copyright 2015 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 shared_test - -import ( - "bufio" - "bytes" - "debug/elf" - "encoding/binary" - "flag" - "fmt" - "go/build" - "io" - "log" - "os" - "os/exec" - "path/filepath" - "regexp" - "runtime" - "sort" - "strings" - "testing" - "time" -) - -var gopathInstallDir, gorootInstallDir string - -// This is the smallest set of packages we can link into a shared -// library (runtime/cgo is built implicitly). -var minpkgs = []string{"runtime", "sync/atomic"} -var soname = "libruntime,sync-atomic.so" - -var testX = flag.Bool("testx", false, "if true, pass -x to 'go' subcommands invoked by the test") -var testWork = flag.Bool("testwork", false, "if true, log and do not delete the temporary working directory") - -// run runs a command and calls t.Errorf if it fails. -func run(t *testing.T, msg string, args ...string) { - runWithEnv(t, msg, nil, args...) -} - -// runWithEnv runs a command under the given environment and calls t.Errorf if it fails. -func runWithEnv(t *testing.T, msg string, env []string, args ...string) { - c := exec.Command(args[0], args[1:]...) - if len(env) != 0 { - c.Env = append(os.Environ(), env...) - } - if output, err := c.CombinedOutput(); err != nil { - t.Errorf("executing %s (%s) failed %s:\n%s", strings.Join(args, " "), msg, err, output) - } -} - -// goCmd invokes the go tool with the installsuffix set up by TestMain. It calls -// t.Fatalf if the command fails. -func goCmd(t *testing.T, args ...string) string { - newargs := []string{args[0]} - if *testX { - newargs = append(newargs, "-x") - } - newargs = append(newargs, args[1:]...) - c := exec.Command("go", newargs...) - stderr := new(strings.Builder) - c.Stderr = stderr - - if testing.Verbose() && t == nil { - fmt.Fprintf(os.Stderr, "+ go %s\n", strings.Join(args, " ")) - c.Stderr = os.Stderr - } - output, err := c.Output() - - if err != nil { - if t != nil { - t.Helper() - t.Fatalf("executing %s failed %v:\n%s", strings.Join(c.Args, " "), err, stderr) - } else { - // Panic instead of using log.Fatalf so that deferred cleanup may run in testMain. - log.Panicf("executing %s failed %v:\n%s", strings.Join(c.Args, " "), err, stderr) - } - } - if testing.Verbose() && t != nil { - t.Logf("go %s", strings.Join(args, " ")) - if stderr.Len() > 0 { - t.Logf("%s", stderr) - } - } - return string(bytes.TrimSpace(output)) -} - -// TestMain calls testMain so that the latter can use defer (TestMain exits with os.Exit). -func testMain(m *testing.M) (int, error) { - workDir, err := os.MkdirTemp("", "shared_test") - if err != nil { - return 0, err - } - if *testWork || testing.Verbose() { - fmt.Printf("+ mkdir -p %s\n", workDir) - } - if !*testWork { - defer os.RemoveAll(workDir) - } - - // Some tests need to edit the source in GOPATH, so copy this directory to a - // temporary directory and chdir to that. - gopath := filepath.Join(workDir, "gopath") - modRoot, err := cloneTestdataModule(gopath) - if err != nil { - return 0, err - } - if testing.Verbose() { - fmt.Printf("+ export GOPATH=%s\n", gopath) - fmt.Printf("+ cd %s\n", modRoot) - } - os.Setenv("GOPATH", gopath) - // Explicitly override GOBIN as well, in case it was set through a GOENV file. - os.Setenv("GOBIN", filepath.Join(gopath, "bin")) - os.Chdir(modRoot) - os.Setenv("PWD", modRoot) - - // The test also needs to install libraries into GOROOT/pkg, so copy the - // subset of GOROOT that we need. - // - // TODO(golang.org/issue/28553): Rework -buildmode=shared so that it does not - // need to write to GOROOT. - goroot := filepath.Join(workDir, "goroot") - if err := cloneGOROOTDeps(goroot); err != nil { - return 0, err - } - if testing.Verbose() { - fmt.Fprintf(os.Stderr, "+ export GOROOT=%s\n", goroot) - } - os.Setenv("GOROOT", goroot) - - myContext := build.Default - myContext.GOROOT = goroot - myContext.GOPATH = gopath - runtimeP, err := myContext.Import("runtime", ".", build.ImportComment) - if err != nil { - return 0, fmt.Errorf("import failed: %v", err) - } - gorootInstallDir = runtimeP.PkgTargetRoot + "_dynlink" - - // All tests depend on runtime being built into a shared library. Because - // that takes a few seconds, do it here and have all tests use the version - // built here. - goCmd(nil, append([]string{"install", "-buildmode=shared"}, minpkgs...)...) - - myContext.InstallSuffix = "_dynlink" - depP, err := myContext.Import("./depBase", ".", build.ImportComment) - if err != nil { - return 0, fmt.Errorf("import failed: %v", err) - } - if depP.PkgTargetRoot == "" { - gopathInstallDir = filepath.Dir(goCmd(nil, "list", "-buildmode=shared", "-f", "{{.Target}}", "./depBase")) - } else { - gopathInstallDir = filepath.Join(depP.PkgTargetRoot, "testshared") - } - return m.Run(), nil -} - -func TestMain(m *testing.M) { - log.SetFlags(log.Lshortfile) - flag.Parse() - - exitCode, err := testMain(m) - if err != nil { - log.Fatal(err) - } - os.Exit(exitCode) -} - -// cloneTestdataModule clones the packages from src/testshared into gopath. -// It returns the directory within gopath at which the module root is located. -func cloneTestdataModule(gopath string) (string, error) { - modRoot := filepath.Join(gopath, "src", "testshared") - if err := overlayDir(modRoot, "testdata"); err != nil { - return "", err - } - if err := os.WriteFile(filepath.Join(modRoot, "go.mod"), []byte("module testshared\n"), 0644); err != nil { - return "", err - } - return modRoot, nil -} - -// cloneGOROOTDeps copies (or symlinks) the portions of GOROOT/src and -// GOROOT/pkg relevant to this test into the given directory. -// It must be run from within the testdata module. -func cloneGOROOTDeps(goroot string) error { - oldGOROOT := strings.TrimSpace(goCmd(nil, "env", "GOROOT")) - if oldGOROOT == "" { - return fmt.Errorf("go env GOROOT returned an empty string") - } - - // Before we clone GOROOT, figure out which packages we need to copy over. - listArgs := []string{ - "list", - "-deps", - "-f", "{{if and .Standard (not .ForTest)}}{{.ImportPath}}{{end}}", - } - stdDeps := goCmd(nil, append(listArgs, minpkgs...)...) - testdataDeps := goCmd(nil, append(listArgs, "-test", "./...")...) - - pkgs := append(strings.Split(strings.TrimSpace(stdDeps), "\n"), - strings.Split(strings.TrimSpace(testdataDeps), "\n")...) - sort.Strings(pkgs) - var pkgRoots []string - for _, pkg := range pkgs { - parentFound := false - for _, prev := range pkgRoots { - if strings.HasPrefix(pkg, prev) { - // We will copy in the source for pkg when we copy in prev. - parentFound = true - break - } - } - if !parentFound { - pkgRoots = append(pkgRoots, pkg) - } - } - - gorootDirs := []string{ - "pkg/tool", - "pkg/include", - } - for _, pkg := range pkgRoots { - gorootDirs = append(gorootDirs, filepath.Join("src", pkg)) - } - - for _, dir := range gorootDirs { - if testing.Verbose() { - fmt.Fprintf(os.Stderr, "+ cp -r %s %s\n", filepath.Join(oldGOROOT, dir), filepath.Join(goroot, dir)) - } - if err := overlayDir(filepath.Join(goroot, dir), filepath.Join(oldGOROOT, dir)); err != nil { - return err - } - } - - return nil -} - -// The shared library was built at the expected location. -func TestSOBuilt(t *testing.T) { - _, err := os.Stat(filepath.Join(gorootInstallDir, soname)) - if err != nil { - t.Error(err) - } -} - -func hasDynTag(f *elf.File, tag elf.DynTag) bool { - ds := f.SectionByType(elf.SHT_DYNAMIC) - if ds == nil { - return false - } - d, err := ds.Data() - if err != nil { - return false - } - for len(d) > 0 { - var t elf.DynTag - switch f.Class { - case elf.ELFCLASS32: - t = elf.DynTag(f.ByteOrder.Uint32(d[0:4])) - d = d[8:] - case elf.ELFCLASS64: - t = elf.DynTag(f.ByteOrder.Uint64(d[0:8])) - d = d[16:] - } - if t == tag { - return true - } - } - return false -} - -// The shared library does not have relocations against the text segment. -func TestNoTextrel(t *testing.T) { - sopath := filepath.Join(gorootInstallDir, soname) - f, err := elf.Open(sopath) - if err != nil { - t.Fatal("elf.Open failed: ", err) - } - defer f.Close() - if hasDynTag(f, elf.DT_TEXTREL) { - t.Errorf("%s has DT_TEXTREL set", soname) - } -} - -// The shared library does not contain symbols called ".dup" -// (See golang.org/issue/14841.) -func TestNoDupSymbols(t *testing.T) { - sopath := filepath.Join(gorootInstallDir, soname) - f, err := elf.Open(sopath) - if err != nil { - t.Fatal("elf.Open failed: ", err) - } - defer f.Close() - syms, err := f.Symbols() - if err != nil { - t.Errorf("error reading symbols %v", err) - return - } - for _, s := range syms { - if s.Name == ".dup" { - t.Fatalf("%s contains symbol called .dup", sopath) - } - } -} - -// The install command should have created a "shlibname" file for the -// listed packages (and runtime/cgo, and math on arm) indicating the -// name of the shared library containing it. -func TestShlibnameFiles(t *testing.T) { - pkgs := append([]string{}, minpkgs...) - pkgs = append(pkgs, "runtime/cgo") - if runtime.GOARCH == "arm" { - pkgs = append(pkgs, "math") - } - for _, pkg := range pkgs { - shlibnamefile := filepath.Join(gorootInstallDir, pkg+".shlibname") - contentsb, err := os.ReadFile(shlibnamefile) - if err != nil { - t.Errorf("error reading shlibnamefile for %s: %v", pkg, err) - continue - } - contents := strings.TrimSpace(string(contentsb)) - if contents != soname { - t.Errorf("shlibnamefile for %s has wrong contents: %q", pkg, contents) - } - } -} - -// Is a given offset into the file contained in a loaded segment? -func isOffsetLoaded(f *elf.File, offset uint64) bool { - for _, prog := range f.Progs { - if prog.Type == elf.PT_LOAD { - if prog.Off <= offset && offset < prog.Off+prog.Filesz { - return true - } - } - } - return false -} - -func rnd(v int32, r int32) int32 { - if r <= 0 { - return v - } - v += r - 1 - c := v % r - if c < 0 { - c += r - } - v -= c - return v -} - -func readwithpad(r io.Reader, sz int32) ([]byte, error) { - data := make([]byte, rnd(sz, 4)) - _, err := io.ReadFull(r, data) - if err != nil { - return nil, err - } - data = data[:sz] - return data, nil -} - -type note struct { - name string - tag int32 - desc string - section *elf.Section -} - -// Read all notes from f. As ELF section names are not supposed to be special, one -// looks for a particular note by scanning all SHT_NOTE sections looking for a note -// with a particular "name" and "tag". -func readNotes(f *elf.File) ([]*note, error) { - var notes []*note - for _, sect := range f.Sections { - if sect.Type != elf.SHT_NOTE { - continue - } - r := sect.Open() - for { - var namesize, descsize, tag int32 - err := binary.Read(r, f.ByteOrder, &namesize) - if err != nil { - if err == io.EOF { - break - } - return nil, fmt.Errorf("read namesize failed: %v", err) - } - err = binary.Read(r, f.ByteOrder, &descsize) - if err != nil { - return nil, fmt.Errorf("read descsize failed: %v", err) - } - err = binary.Read(r, f.ByteOrder, &tag) - if err != nil { - return nil, fmt.Errorf("read type failed: %v", err) - } - name, err := readwithpad(r, namesize) - if err != nil { - return nil, fmt.Errorf("read name failed: %v", err) - } - desc, err := readwithpad(r, descsize) - if err != nil { - return nil, fmt.Errorf("read desc failed: %v", err) - } - notes = append(notes, ¬e{name: string(name), tag: tag, desc: string(desc), section: sect}) - } - } - return notes, nil -} - -func dynStrings(t *testing.T, path string, flag elf.DynTag) []string { - t.Helper() - f, err := elf.Open(path) - if err != nil { - t.Fatalf("elf.Open(%q) failed: %v", path, err) - } - defer f.Close() - dynstrings, err := f.DynString(flag) - if err != nil { - t.Fatalf("DynString(%s) failed on %s: %v", flag, path, err) - } - return dynstrings -} - -func AssertIsLinkedToRegexp(t *testing.T, path string, re *regexp.Regexp) { - t.Helper() - for _, dynstring := range dynStrings(t, path, elf.DT_NEEDED) { - if re.MatchString(dynstring) { - return - } - } - t.Errorf("%s is not linked to anything matching %v", path, re) -} - -func AssertIsLinkedTo(t *testing.T, path, lib string) { - t.Helper() - AssertIsLinkedToRegexp(t, path, regexp.MustCompile(regexp.QuoteMeta(lib))) -} - -func AssertHasRPath(t *testing.T, path, dir string) { - t.Helper() - for _, tag := range []elf.DynTag{elf.DT_RPATH, elf.DT_RUNPATH} { - for _, dynstring := range dynStrings(t, path, tag) { - for _, rpath := range strings.Split(dynstring, ":") { - if filepath.Clean(rpath) == filepath.Clean(dir) { - return - } - } - } - } - t.Errorf("%s does not have rpath %s", path, dir) -} - -// Build a trivial program that links against the shared runtime and check it runs. -func TestTrivialExecutable(t *testing.T) { - goCmd(t, "install", "-linkshared", "./trivial") - run(t, "trivial executable", "../../bin/trivial") - AssertIsLinkedTo(t, "../../bin/trivial", soname) - AssertHasRPath(t, "../../bin/trivial", gorootInstallDir) - checkSize(t, "../../bin/trivial", 100000) // it is 19K on linux/amd64, 100K should be enough -} - -// Build a trivial program in PIE mode that links against the shared runtime and check it runs. -func TestTrivialExecutablePIE(t *testing.T) { - goCmd(t, "build", "-buildmode=pie", "-o", "trivial.pie", "-linkshared", "./trivial") - run(t, "trivial executable", "./trivial.pie") - AssertIsLinkedTo(t, "./trivial.pie", soname) - AssertHasRPath(t, "./trivial.pie", gorootInstallDir) - checkSize(t, "./trivial.pie", 100000) // it is 19K on linux/amd64, 100K should be enough -} - -// Check that the file size does not exceed a limit. -func checkSize(t *testing.T, f string, limit int64) { - fi, err := os.Stat(f) - if err != nil { - t.Fatalf("stat failed: %v", err) - } - if sz := fi.Size(); sz > limit { - t.Errorf("file too large: got %d, want <= %d", sz, limit) - } -} - -// Build a division test program and check it runs. -func TestDivisionExecutable(t *testing.T) { - goCmd(t, "install", "-linkshared", "./division") - run(t, "division executable", "../../bin/division") -} - -// Build an executable that uses cgo linked against the shared runtime and check it -// runs. -func TestCgoExecutable(t *testing.T) { - goCmd(t, "install", "-linkshared", "./execgo") - run(t, "cgo executable", "../../bin/execgo") -} - -func checkPIE(t *testing.T, name string) { - f, err := elf.Open(name) - if err != nil { - t.Fatal("elf.Open failed: ", err) - } - defer f.Close() - if f.Type != elf.ET_DYN { - t.Errorf("%s has type %v, want ET_DYN", name, f.Type) - } - if hasDynTag(f, elf.DT_TEXTREL) { - t.Errorf("%s has DT_TEXTREL set", name) - } -} - -func TestTrivialPIE(t *testing.T) { - name := "trivial_pie" - goCmd(t, "build", "-buildmode=pie", "-o="+name, "./trivial") - defer os.Remove(name) - run(t, name, "./"+name) - checkPIE(t, name) -} - -func TestCgoPIE(t *testing.T) { - name := "cgo_pie" - goCmd(t, "build", "-buildmode=pie", "-o="+name, "./execgo") - defer os.Remove(name) - run(t, name, "./"+name) - checkPIE(t, name) -} - -// Build a GOPATH package into a shared library that links against the goroot runtime -// and an executable that links against both. -func TestGopathShlib(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") - shlib := goCmd(t, "list", "-f", "{{.Shlib}}", "-buildmode=shared", "-linkshared", "./depBase") - AssertIsLinkedTo(t, shlib, soname) - goCmd(t, "install", "-linkshared", "./exe") - AssertIsLinkedTo(t, "../../bin/exe", soname) - AssertIsLinkedTo(t, "../../bin/exe", filepath.Base(shlib)) - AssertHasRPath(t, "../../bin/exe", gorootInstallDir) - AssertHasRPath(t, "../../bin/exe", filepath.Dir(gopathInstallDir)) - // And check it runs. - run(t, "executable linked to GOPATH library", "../../bin/exe") -} - -// The shared library contains a note listing the packages it contains in a section -// that is not mapped into memory. -func testPkgListNote(t *testing.T, f *elf.File, note *note) { - if note.section.Flags != 0 { - t.Errorf("package list section has flags %v, want 0", note.section.Flags) - } - if isOffsetLoaded(f, note.section.Offset) { - t.Errorf("package list section contained in PT_LOAD segment") - } - if note.desc != "testshared/depBase\n" { - t.Errorf("incorrect package list %q, want %q", note.desc, "testshared/depBase\n") - } -} - -// The shared library contains a note containing the ABI hash that is mapped into -// memory and there is a local symbol called go.link.abihashbytes that points 16 -// bytes into it. -func testABIHashNote(t *testing.T, f *elf.File, note *note) { - if note.section.Flags != elf.SHF_ALLOC { - t.Errorf("abi hash section has flags %v, want SHF_ALLOC", note.section.Flags) - } - if !isOffsetLoaded(f, note.section.Offset) { - t.Errorf("abihash section not contained in PT_LOAD segment") - } - var hashbytes elf.Symbol - symbols, err := f.Symbols() - if err != nil { - t.Errorf("error reading symbols %v", err) - return - } - for _, sym := range symbols { - if sym.Name == "go.link.abihashbytes" { - hashbytes = sym - } - } - if hashbytes.Name == "" { - t.Errorf("no symbol called go.link.abihashbytes") - return - } - if elf.ST_BIND(hashbytes.Info) != elf.STB_LOCAL { - t.Errorf("%s has incorrect binding %v, want STB_LOCAL", hashbytes.Name, elf.ST_BIND(hashbytes.Info)) - } - if f.Sections[hashbytes.Section] != note.section { - t.Errorf("%s has incorrect section %v, want %s", hashbytes.Name, f.Sections[hashbytes.Section].Name, note.section.Name) - } - if hashbytes.Value-note.section.Addr != 16 { - t.Errorf("%s has incorrect offset into section %d, want 16", hashbytes.Name, hashbytes.Value-note.section.Addr) - } -} - -// A Go shared library contains a note indicating which other Go shared libraries it -// was linked against in an unmapped section. -func testDepsNote(t *testing.T, f *elf.File, note *note) { - if note.section.Flags != 0 { - t.Errorf("package list section has flags %v, want 0", note.section.Flags) - } - if isOffsetLoaded(f, note.section.Offset) { - t.Errorf("package list section contained in PT_LOAD segment") - } - // libdepBase.so just links against the lib containing the runtime. - if note.desc != soname { - t.Errorf("incorrect dependency list %q, want %q", note.desc, soname) - } -} - -// The shared library contains notes with defined contents; see above. -func TestNotes(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") - shlib := goCmd(t, "list", "-f", "{{.Shlib}}", "-buildmode=shared", "-linkshared", "./depBase") - f, err := elf.Open(shlib) - if err != nil { - t.Fatal(err) - } - defer f.Close() - notes, err := readNotes(f) - if err != nil { - t.Fatal(err) - } - pkgListNoteFound := false - abiHashNoteFound := false - depsNoteFound := false - for _, note := range notes { - if note.name != "Go\x00\x00" { - continue - } - switch note.tag { - case 1: // ELF_NOTE_GOPKGLIST_TAG - if pkgListNoteFound { - t.Error("multiple package list notes") - } - testPkgListNote(t, f, note) - pkgListNoteFound = true - case 2: // ELF_NOTE_GOABIHASH_TAG - if abiHashNoteFound { - t.Error("multiple abi hash notes") - } - testABIHashNote(t, f, note) - abiHashNoteFound = true - case 3: // ELF_NOTE_GODEPS_TAG - if depsNoteFound { - t.Error("multiple dependency list notes") - } - testDepsNote(t, f, note) - depsNoteFound = true - } - } - if !pkgListNoteFound { - t.Error("package list note not found") - } - if !abiHashNoteFound { - t.Error("abi hash note not found") - } - if !depsNoteFound { - t.Error("deps note not found") - } -} - -// Build a GOPATH package (depBase) into a shared library that links against the goroot -// runtime, another package (dep2) that links against the first, and an -// executable that links against dep2. -func TestTwoGopathShlibs(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./dep2") - goCmd(t, "install", "-linkshared", "./exe2") - run(t, "executable linked to GOPATH library", "../../bin/exe2") -} - -func TestThreeGopathShlibs(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./dep2") - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./dep3") - goCmd(t, "install", "-linkshared", "./exe3") - run(t, "executable linked to GOPATH library", "../../bin/exe3") -} - -// If gccgo is not available or not new enough, call t.Skip. -func requireGccgo(t *testing.T) { - t.Helper() - - gccgoName := os.Getenv("GCCGO") - if gccgoName == "" { - gccgoName = "gccgo" - } - gccgoPath, err := exec.LookPath(gccgoName) - if err != nil { - t.Skip("gccgo not found") - } - cmd := exec.Command(gccgoPath, "-dumpversion") - output, err := cmd.CombinedOutput() - if err != nil { - t.Fatalf("%s -dumpversion failed: %v\n%s", gccgoPath, err, output) - } - if string(output) < "5" { - t.Skipf("gccgo too old (%s)", strings.TrimSpace(string(output))) - } - - gomod, err := exec.Command("go", "env", "GOMOD").Output() - if err != nil { - t.Fatalf("go env GOMOD: %v", err) - } - if len(bytes.TrimSpace(gomod)) > 0 { - t.Skipf("gccgo not supported in module mode; see golang.org/issue/30344") - } -} - -// Build a GOPATH package into a shared library with gccgo and an executable that -// links against it. -func TestGoPathShlibGccgo(t *testing.T) { - requireGccgo(t) - - libgoRE := regexp.MustCompile("libgo.so.[0-9]+") - - goCmd(t, "install", "-compiler=gccgo", "-buildmode=shared", "-linkshared", "./depBase") - - // Run 'go list' after 'go install': with gccgo, we apparently don't know the - // shlib location until after we've installed it. - shlib := goCmd(t, "list", "-compiler=gccgo", "-buildmode=shared", "-linkshared", "-f", "{{.Shlib}}", "./depBase") - - AssertIsLinkedToRegexp(t, shlib, libgoRE) - goCmd(t, "install", "-compiler=gccgo", "-linkshared", "./exe") - AssertIsLinkedToRegexp(t, "../../bin/exe", libgoRE) - AssertIsLinkedTo(t, "../../bin/exe", filepath.Base(shlib)) - AssertHasRPath(t, "../../bin/exe", filepath.Dir(shlib)) - // And check it runs. - run(t, "gccgo-built", "../../bin/exe") -} - -// The gccgo version of TestTwoGopathShlibs: build a GOPATH package into a shared -// library with gccgo, another GOPATH package that depends on the first and an -// executable that links the second library. -func TestTwoGopathShlibsGccgo(t *testing.T) { - requireGccgo(t) - - libgoRE := regexp.MustCompile("libgo.so.[0-9]+") - - goCmd(t, "install", "-compiler=gccgo", "-buildmode=shared", "-linkshared", "./depBase") - goCmd(t, "install", "-compiler=gccgo", "-buildmode=shared", "-linkshared", "./dep2") - goCmd(t, "install", "-compiler=gccgo", "-linkshared", "./exe2") - - // Run 'go list' after 'go install': with gccgo, we apparently don't know the - // shlib location until after we've installed it. - dep2 := goCmd(t, "list", "-compiler=gccgo", "-buildmode=shared", "-linkshared", "-f", "{{.Shlib}}", "./dep2") - depBase := goCmd(t, "list", "-compiler=gccgo", "-buildmode=shared", "-linkshared", "-f", "{{.Shlib}}", "./depBase") - - AssertIsLinkedToRegexp(t, depBase, libgoRE) - AssertIsLinkedToRegexp(t, dep2, libgoRE) - AssertIsLinkedTo(t, dep2, filepath.Base(depBase)) - AssertIsLinkedToRegexp(t, "../../bin/exe2", libgoRE) - AssertIsLinkedTo(t, "../../bin/exe2", filepath.Base(dep2)) - AssertIsLinkedTo(t, "../../bin/exe2", filepath.Base(depBase)) - - // And check it runs. - run(t, "gccgo-built", "../../bin/exe2") -} - -// Testing rebuilding of shared libraries when they are stale is a bit more -// complicated that it seems like it should be. First, we make everything "old": but -// only a few seconds old, or it might be older than gc (or the runtime source) and -// everything will get rebuilt. Then define a timestamp slightly newer than this -// time, which is what we set the mtime to of a file to cause it to be seen as new, -// and finally another slightly even newer one that we can compare files against to -// see if they have been rebuilt. -var oldTime = time.Now().Add(-9 * time.Second) -var nearlyNew = time.Now().Add(-6 * time.Second) -var stampTime = time.Now().Add(-3 * time.Second) - -// resetFileStamps makes "everything" (bin, src, pkg from GOPATH and the -// test-specific parts of GOROOT) appear old. -func resetFileStamps() { - chtime := func(path string, info os.FileInfo, err error) error { - return os.Chtimes(path, oldTime, oldTime) - } - reset := func(path string) { - if err := filepath.Walk(path, chtime); err != nil { - log.Panicf("resetFileStamps failed: %v", err) - } - - } - reset("../../bin") - reset("../../pkg") - reset("../../src") - reset(gorootInstallDir) -} - -// touch changes path and returns a function that changes it back. -// It also sets the time of the file, so that we can see if it is rewritten. -func touch(t *testing.T, path string) (cleanup func()) { - t.Helper() - data, err := os.ReadFile(path) - if err != nil { - t.Fatal(err) - } - old := make([]byte, len(data)) - copy(old, data) - if bytes.HasPrefix(data, []byte("!\n")) { - // Change last digit of build ID. - // (Content ID in the new content-based build IDs.) - const marker = `build id "` - i := bytes.Index(data, []byte(marker)) - if i < 0 { - t.Fatal("cannot find build id in archive") - } - j := bytes.IndexByte(data[i+len(marker):], '"') - if j < 0 { - t.Fatal("cannot find build id in archive") - } - i += len(marker) + j - 1 - if data[i] == 'a' { - data[i] = 'b' - } else { - data[i] = 'a' - } - } else { - // assume it's a text file - data = append(data, '\n') - } - - // If the file is still a symlink from an overlay, delete it so that we will - // replace it with a regular file instead of overwriting the symlinked one. - fi, err := os.Lstat(path) - if err == nil && !fi.Mode().IsRegular() { - fi, err = os.Stat(path) - if err := os.Remove(path); err != nil { - t.Fatal(err) - } - } - if err != nil { - t.Fatal(err) - } - - // If we're replacing a symlink to a read-only file, make the new file - // user-writable. - perm := fi.Mode().Perm() | 0200 - - if err := os.WriteFile(path, data, perm); err != nil { - t.Fatal(err) - } - if err := os.Chtimes(path, nearlyNew, nearlyNew); err != nil { - t.Fatal(err) - } - return func() { - if err := os.WriteFile(path, old, perm); err != nil { - t.Fatal(err) - } - } -} - -// isNew returns if the path is newer than the time stamp used by touch. -func isNew(t *testing.T, path string) bool { - t.Helper() - fi, err := os.Stat(path) - if err != nil { - t.Fatal(err) - } - return fi.ModTime().After(stampTime) -} - -// Fail unless path has been rebuilt (i.e. is newer than the time stamp used by -// isNew) -func AssertRebuilt(t *testing.T, msg, path string) { - t.Helper() - if !isNew(t, path) { - t.Errorf("%s was not rebuilt (%s)", msg, path) - } -} - -// Fail if path has been rebuilt (i.e. is newer than the time stamp used by isNew) -func AssertNotRebuilt(t *testing.T, msg, path string) { - t.Helper() - if isNew(t, path) { - t.Errorf("%s was rebuilt (%s)", msg, path) - } -} - -func TestRebuilding(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") - goCmd(t, "install", "-linkshared", "./exe") - info := strings.Fields(goCmd(t, "list", "-buildmode=shared", "-linkshared", "-f", "{{.Target}} {{.Shlib}}", "./depBase")) - if len(info) != 2 { - t.Fatalf("go list failed to report Target and/or Shlib") - } - target := info[0] - shlib := info[1] - - // If the source is newer than both the .a file and the .so, both are rebuilt. - t.Run("newsource", func(t *testing.T) { - resetFileStamps() - cleanup := touch(t, "./depBase/dep.go") - defer func() { - cleanup() - goCmd(t, "install", "-linkshared", "./exe") - }() - goCmd(t, "install", "-linkshared", "./exe") - AssertRebuilt(t, "new source", target) - AssertRebuilt(t, "new source", shlib) - }) - - // If the .a file is newer than the .so, the .so is rebuilt (but not the .a) - t.Run("newarchive", func(t *testing.T) { - resetFileStamps() - AssertNotRebuilt(t, "new .a file before build", target) - goCmd(t, "list", "-linkshared", "-f={{.ImportPath}} {{.Stale}} {{.StaleReason}} {{.Target}}", "./depBase") - AssertNotRebuilt(t, "new .a file before build", target) - cleanup := touch(t, target) - defer func() { - cleanup() - goCmd(t, "install", "-v", "-linkshared", "./exe") - }() - goCmd(t, "install", "-v", "-linkshared", "./exe") - AssertNotRebuilt(t, "new .a file", target) - AssertRebuilt(t, "new .a file", shlib) - }) -} - -func appendFile(t *testing.T, path, content string) { - t.Helper() - f, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND, 0660) - if err != nil { - t.Fatalf("os.OpenFile failed: %v", err) - } - defer func() { - err := f.Close() - if err != nil { - t.Fatalf("f.Close failed: %v", err) - } - }() - _, err = f.WriteString(content) - if err != nil { - t.Fatalf("f.WriteString failed: %v", err) - } -} - -func createFile(t *testing.T, path, content string) { - t.Helper() - f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644) - if err != nil { - t.Fatalf("os.OpenFile failed: %v", err) - } - _, err = f.WriteString(content) - if closeErr := f.Close(); err == nil { - err = closeErr - } - if err != nil { - t.Fatalf("WriteString failed: %v", err) - } -} - -func TestABIChecking(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") - goCmd(t, "install", "-linkshared", "./exe") - - // If we make an ABI-breaking change to depBase and rebuild libp.so but not exe, - // exe will abort with a complaint on startup. - // This assumes adding an exported function breaks ABI, which is not true in - // some senses but suffices for the narrow definition of ABI compatibility the - // toolchain uses today. - resetFileStamps() - - createFile(t, "./depBase/break.go", "package depBase\nfunc ABIBreak() {}\n") - defer os.Remove("./depBase/break.go") - - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") - c := exec.Command("../../bin/exe") - output, err := c.CombinedOutput() - if err == nil { - t.Fatal("executing exe did not fail after ABI break") - } - scanner := bufio.NewScanner(bytes.NewReader(output)) - foundMsg := false - const wantPrefix = "abi mismatch detected between the executable and lib" - for scanner.Scan() { - if strings.HasPrefix(scanner.Text(), wantPrefix) { - foundMsg = true - break - } - } - if err = scanner.Err(); err != nil { - t.Errorf("scanner encountered error: %v", err) - } - if !foundMsg { - t.Fatalf("exe failed, but without line %q; got output:\n%s", wantPrefix, output) - } - - // Rebuilding exe makes it work again. - goCmd(t, "install", "-linkshared", "./exe") - run(t, "rebuilt exe", "../../bin/exe") - - // If we make a change which does not break ABI (such as adding an unexported - // function) and rebuild libdepBase.so, exe still works, even if new function - // is in a file by itself. - resetFileStamps() - createFile(t, "./depBase/dep2.go", "package depBase\nfunc noABIBreak() {}\n") - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") - run(t, "after non-ABI breaking change", "../../bin/exe") -} - -// If a package 'explicit' imports a package 'implicit', building -// 'explicit' into a shared library implicitly includes implicit in -// the shared library. Building an executable that imports both -// explicit and implicit builds the code from implicit into the -// executable rather than fetching it from the shared library. The -// link still succeeds and the executable still runs though. -func TestImplicitInclusion(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./explicit") - goCmd(t, "install", "-linkshared", "./implicitcmd") - run(t, "running executable linked against library that contains same package as it", "../../bin/implicitcmd") -} - -// Tests to make sure that the type fields of empty interfaces and itab -// fields of nonempty interfaces are unique even across modules, -// so that interface equality works correctly. -func TestInterface(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./iface_a") - // Note: iface_i gets installed implicitly as a dependency of iface_a. - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./iface_b") - goCmd(t, "install", "-linkshared", "./iface") - run(t, "running type/itab uniqueness tester", "../../bin/iface") -} - -// Access a global variable from a library. -func TestGlobal(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./globallib") - goCmd(t, "install", "-linkshared", "./global") - run(t, "global executable", "../../bin/global") - AssertIsLinkedTo(t, "../../bin/global", soname) - AssertHasRPath(t, "../../bin/global", gorootInstallDir) -} - -// Run a test using -linkshared of an installed shared package. -// Issue 26400. -func TestTestInstalledShared(t *testing.T) { - goCmd(t, "test", "-linkshared", "-test.short", "sync/atomic") -} - -// Test generated pointer method with -linkshared. -// Issue 25065. -func TestGeneratedMethod(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue25065") -} - -// Test use of shared library struct with generated hash function. -// Issue 30768. -func TestGeneratedHash(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue30768/issue30768lib") - goCmd(t, "test", "-linkshared", "./issue30768") -} - -// Test that packages can be added not in dependency order (here a depends on b, and a adds -// before b). This could happen with e.g. go build -buildmode=shared std. See issue 39777. -func TestPackageOrder(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue39777/a", "./issue39777/b") -} - -// Test that GC data are generated correctly by the linker when it needs a type defined in -// a shared library. See issue 39927. -func TestGCData(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./gcdata/p") - goCmd(t, "build", "-linkshared", "./gcdata/main") - runWithEnv(t, "running gcdata/main", []string{"GODEBUG=clobberfree=1"}, "./main") -} - -// Test that we don't decode type symbols from shared libraries (which has no data, -// causing panic). See issue 44031. -func TestIssue44031(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue44031/a") - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue44031/b") - goCmd(t, "run", "-linkshared", "./issue44031/main") -} - -// Test that we use a variable from shared libraries (which implement an -// interface in shared libraries.). A weak reference is used in the itab -// in main process. It can cause unreacheble panic. See issue 47873. -func TestIssue47873(t *testing.T) { - goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue47837/a") - goCmd(t, "run", "-linkshared", "./issue47837/main") -} diff --git a/misc/cgo/testshared/testdata/dep2/dep2.go b/misc/cgo/testshared/testdata/dep2/dep2.go deleted file mode 100644 index 94f38cf507..0000000000 --- a/misc/cgo/testshared/testdata/dep2/dep2.go +++ /dev/null @@ -1,15 +0,0 @@ -package dep2 - -import "testshared/depBase" - -var W int = 1 - -var hasProg depBase.HasProg - -type Dep2 struct { - depBase.Dep -} - -func G() int { - return depBase.F() + 1 -} diff --git a/misc/cgo/testshared/testdata/dep3/dep3.go b/misc/cgo/testshared/testdata/dep3/dep3.go deleted file mode 100644 index 6b02ad2ee5..0000000000 --- a/misc/cgo/testshared/testdata/dep3/dep3.go +++ /dev/null @@ -1,22 +0,0 @@ -package dep3 - -// The point of this test file is that it references a type from -// depBase that is also referenced in dep2, but dep2 is loaded by the -// linker before depBase (because it is earlier in the import list). -// There was a bug in the linker where it would not correctly read out -// the type data in this case and later crash. - -import ( - "testshared/dep2" - "testshared/depBase" -) - -type Dep3 struct { - dep depBase.Dep - dep2 dep2.Dep2 -} - -func D3() int { - var x Dep3 - return x.dep.X + x.dep2.X -} diff --git a/misc/cgo/testshared/testdata/depBase/asm.s b/misc/cgo/testshared/testdata/depBase/asm.s deleted file mode 100644 index 0f1111f392..0000000000 --- a/misc/cgo/testshared/testdata/depBase/asm.s +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2014 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. - -// +build gc - -#include "textflag.h" - -TEXT ·ImplementedInAsm(SB),NOSPLIT,$0-0 - RET diff --git a/misc/cgo/testshared/testdata/depBase/dep.go b/misc/cgo/testshared/testdata/depBase/dep.go deleted file mode 100644 index e7cc7c81eb..0000000000 --- a/misc/cgo/testshared/testdata/depBase/dep.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2016 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 depBase - -import ( - "os" - "reflect" -) - -var SlicePtr interface{} = &[]int{} - -var V int = 1 - -var HasMask []string = []string{"hi"} - -type HasProg struct { - array [1024]*byte -} - -type Dep struct { - X int -} - -func (d *Dep) Method() int { - // This code below causes various go.itab.* symbols to be generated in - // the shared library. Similar code in ../exe/exe.go results in - // exercising https://golang.org/issues/17594 - reflect.TypeOf(os.Stdout).Elem() - return 10 -} - -func F() int { - defer func() {}() - return V -} diff --git a/misc/cgo/testshared/testdata/depBase/gccgo.go b/misc/cgo/testshared/testdata/depBase/gccgo.go deleted file mode 100644 index 2b02a1e83b..0000000000 --- a/misc/cgo/testshared/testdata/depBase/gccgo.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2016 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. - -// +build gccgo - -package depBase - -func ImplementedInAsm() {} diff --git a/misc/cgo/testshared/testdata/depBase/stubs.go b/misc/cgo/testshared/testdata/depBase/stubs.go deleted file mode 100644 index c77953803b..0000000000 --- a/misc/cgo/testshared/testdata/depBase/stubs.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2016 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. - -// +build gc - -package depBase - -func ImplementedInAsm() diff --git a/misc/cgo/testshared/testdata/division/division.go b/misc/cgo/testshared/testdata/division/division.go deleted file mode 100644 index bb5fc98460..0000000000 --- a/misc/cgo/testshared/testdata/division/division.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 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 main - -//go:noinline -func div(x, y uint32) uint32 { - return x / y -} - -func main() { - a := div(97, 11) - if a != 8 { - panic("FAIL") - } -} diff --git a/misc/cgo/testshared/testdata/exe/exe.go b/misc/cgo/testshared/testdata/exe/exe.go deleted file mode 100644 index ee95f97bc9..0000000000 --- a/misc/cgo/testshared/testdata/exe/exe.go +++ /dev/null @@ -1,45 +0,0 @@ -package main - -import ( - "os" - "reflect" - "runtime" - - "testshared/depBase" -) - -// Having a function declared in the main package triggered -// golang.org/issue/18250 -func DeclaredInMain() { -} - -type C struct { -} - -func F() *C { - return nil -} - -var slicePtr interface{} = &[]int{} - -func main() { - defer depBase.ImplementedInAsm() - // This code below causes various go.itab.* symbols to be generated in - // the executable. Similar code in ../depBase/dep.go results in - // exercising https://golang.org/issues/17594 - reflect.TypeOf(os.Stdout).Elem() - runtime.GC() - depBase.V = depBase.F() + 1 - - var c *C - if reflect.TypeOf(F).Out(0) != reflect.TypeOf(c) { - panic("bad reflection results, see golang.org/issue/18252") - } - - sp := reflect.New(reflect.TypeOf(slicePtr).Elem()) - s := sp.Interface() - - if reflect.TypeOf(s) != reflect.TypeOf(slicePtr) { - panic("bad reflection results, see golang.org/issue/18729") - } -} diff --git a/misc/cgo/testshared/testdata/exe2/exe2.go b/misc/cgo/testshared/testdata/exe2/exe2.go deleted file mode 100644 index 433f331e36..0000000000 --- a/misc/cgo/testshared/testdata/exe2/exe2.go +++ /dev/null @@ -1,8 +0,0 @@ -package main - -import "testshared/dep2" - -func main() { - d := &dep2.Dep2{} - dep2.W = dep2.G() + 1 + d.Method() -} diff --git a/misc/cgo/testshared/testdata/exe3/exe3.go b/misc/cgo/testshared/testdata/exe3/exe3.go deleted file mode 100644 index 533e3a9e3d..0000000000 --- a/misc/cgo/testshared/testdata/exe3/exe3.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "testshared/dep3" - -func main() { - dep3.D3() -} diff --git a/misc/cgo/testshared/testdata/execgo/exe.go b/misc/cgo/testshared/testdata/execgo/exe.go deleted file mode 100644 index 0427be8bdf..0000000000 --- a/misc/cgo/testshared/testdata/execgo/exe.go +++ /dev/null @@ -1,8 +0,0 @@ -package main - -/* - */ -import "C" - -func main() { -} diff --git a/misc/cgo/testshared/testdata/explicit/explicit.go b/misc/cgo/testshared/testdata/explicit/explicit.go deleted file mode 100644 index af969fcb23..0000000000 --- a/misc/cgo/testshared/testdata/explicit/explicit.go +++ /dev/null @@ -1,9 +0,0 @@ -package explicit - -import ( - "testshared/implicit" -) - -func E() int { - return implicit.I() -} diff --git a/misc/cgo/testshared/testdata/gcdata/main/main.go b/misc/cgo/testshared/testdata/gcdata/main/main.go deleted file mode 100644 index 394862fd94..0000000000 --- a/misc/cgo/testshared/testdata/gcdata/main/main.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2020 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. - -// Test that GC data is generated correctly for global -// variables with types defined in a shared library. -// See issue 39927. - -// This test run under GODEBUG=clobberfree=1. The check -// *x[i] == 12345 depends on this debug mode to clobber -// the value if the object is freed prematurely. - -package main - -import ( - "fmt" - "runtime" - "testshared/gcdata/p" -) - -var x p.T - -func main() { - for i := range x { - x[i] = new(int) - *x[i] = 12345 - } - runtime.GC() - runtime.GC() - runtime.GC() - for i := range x { - if *x[i] != 12345 { - fmt.Printf("x[%d] == %d, want 12345\n", i, *x[i]) - panic("FAIL") - } - } -} diff --git a/misc/cgo/testshared/testdata/gcdata/p/p.go b/misc/cgo/testshared/testdata/gcdata/p/p.go deleted file mode 100644 index 1fee75429e..0000000000 --- a/misc/cgo/testshared/testdata/gcdata/p/p.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2020 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 p - -type T [10]*int diff --git a/misc/cgo/testshared/testdata/global/main.go b/misc/cgo/testshared/testdata/global/main.go deleted file mode 100644 index f43e7c3fb3..0000000000 --- a/misc/cgo/testshared/testdata/global/main.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2017 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 main - -import ( - "testshared/globallib" -) - -//go:noinline -func testLoop() { - for i, s := range globallib.Data { - if s != int64(i) { - panic("testLoop: mismatch") - } - } -} - -//go:noinline -func ptrData() *[1<<20 + 10]int64 { - return &globallib.Data -} - -//go:noinline -func testMediumOffset() { - for i, s := range globallib.Data[1<<16-2:] { - if s != int64(i)+1<<16-2 { - panic("testMediumOffset: index mismatch") - } - } - - x := globallib.Data[1<<16-1] - if x != 1<<16-1 { - panic("testMediumOffset: direct mismatch") - } - - y := &globallib.Data[1<<16-3] - if y != &ptrData()[1<<16-3] { - panic("testMediumOffset: address mismatch") - } -} - -//go:noinline -func testLargeOffset() { - for i, s := range globallib.Data[1<<20:] { - if s != int64(i)+1<<20 { - panic("testLargeOffset: index mismatch") - } - } - - x := globallib.Data[1<<20+1] - if x != 1<<20+1 { - panic("testLargeOffset: direct mismatch") - } - - y := &globallib.Data[1<<20+2] - if y != &ptrData()[1<<20+2] { - panic("testLargeOffset: address mismatch") - } -} - -func main() { - testLoop() - - // SSA rules commonly merge offsets into addresses. These - // tests access global data in different ways to try - // and exercise different SSA rules. - testMediumOffset() - testLargeOffset() -} diff --git a/misc/cgo/testshared/testdata/globallib/global.go b/misc/cgo/testshared/testdata/globallib/global.go deleted file mode 100644 index b4372a2e9e..0000000000 --- a/misc/cgo/testshared/testdata/globallib/global.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 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 globallib - -// Data is large enough to that offsets into it do not fit into -// 16-bit or 20-bit immediates. Ideally we'd also try and overrun -// 32-bit immediates, but that requires the test machine to have -// too much memory. -var Data [1<<20 + 10]int64 - -func init() { - for i := range Data { - Data[i] = int64(i) - } -} diff --git a/misc/cgo/testshared/testdata/iface/main.go b/misc/cgo/testshared/testdata/iface/main.go deleted file mode 100644 index d26ebbcc9c..0000000000 --- a/misc/cgo/testshared/testdata/iface/main.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 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 main - -import "testshared/iface_a" -import "testshared/iface_b" - -func main() { - if iface_a.F() != iface_b.F() { - panic("empty interfaces not equal") - } - if iface_a.G() != iface_b.G() { - panic("non-empty interfaces not equal") - } -} diff --git a/misc/cgo/testshared/testdata/iface_a/a.go b/misc/cgo/testshared/testdata/iface_a/a.go deleted file mode 100644 index e2cef1ecda..0000000000 --- a/misc/cgo/testshared/testdata/iface_a/a.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 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 iface_a - -import "testshared/iface_i" - -//go:noinline -func F() interface{} { - return (*iface_i.T)(nil) -} - -//go:noinline -func G() iface_i.I { - return (*iface_i.T)(nil) -} diff --git a/misc/cgo/testshared/testdata/iface_b/b.go b/misc/cgo/testshared/testdata/iface_b/b.go deleted file mode 100644 index dd3e027b37..0000000000 --- a/misc/cgo/testshared/testdata/iface_b/b.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 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 iface_b - -import "testshared/iface_i" - -//go:noinline -func F() interface{} { - return (*iface_i.T)(nil) -} - -//go:noinline -func G() iface_i.I { - return (*iface_i.T)(nil) -} diff --git a/misc/cgo/testshared/testdata/iface_i/i.go b/misc/cgo/testshared/testdata/iface_i/i.go deleted file mode 100644 index 31c80387c7..0000000000 --- a/misc/cgo/testshared/testdata/iface_i/i.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 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 iface_i - -type I interface { - M() -} - -type T struct { -} - -func (t *T) M() { -} - -// *T implements I diff --git a/misc/cgo/testshared/testdata/implicit/implicit.go b/misc/cgo/testshared/testdata/implicit/implicit.go deleted file mode 100644 index 5360188c56..0000000000 --- a/misc/cgo/testshared/testdata/implicit/implicit.go +++ /dev/null @@ -1,5 +0,0 @@ -package implicit - -func I() int { - return 42 -} diff --git a/misc/cgo/testshared/testdata/implicitcmd/implicitcmd.go b/misc/cgo/testshared/testdata/implicitcmd/implicitcmd.go deleted file mode 100644 index 4d4296738e..0000000000 --- a/misc/cgo/testshared/testdata/implicitcmd/implicitcmd.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -import ( - "testshared/explicit" - "testshared/implicit" -) - -func main() { - println(implicit.I() + explicit.E()) -} diff --git a/misc/cgo/testshared/testdata/issue25065/a.go b/misc/cgo/testshared/testdata/issue25065/a.go deleted file mode 100644 index 979350ff24..0000000000 --- a/misc/cgo/testshared/testdata/issue25065/a.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2018 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 issue25065 has a type with a method that is -// 1) referenced in a method expression -// 2) not called -// 3) not converted to an interface -// 4) is a value method but the reference is to the pointer method -// These cases avoid the call to makefuncsym from typecheckfunc, but we -// still need to call makefuncsym somehow or the symbol will not be defined. -package issue25065 - -type T int - -func (t T) M() {} - -func F() func(*T) { - return (*T).M -} diff --git a/misc/cgo/testshared/testdata/issue30768/issue30768lib/lib.go b/misc/cgo/testshared/testdata/issue30768/issue30768lib/lib.go deleted file mode 100644 index 9e45ebe683..0000000000 --- a/misc/cgo/testshared/testdata/issue30768/issue30768lib/lib.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2019 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 issue30768lib - -// S is a struct that requires a generated hash function. -type S struct { - A string - B int -} diff --git a/misc/cgo/testshared/testdata/issue30768/x_test.go b/misc/cgo/testshared/testdata/issue30768/x_test.go deleted file mode 100644 index 1bbd139d3e..0000000000 --- a/misc/cgo/testshared/testdata/issue30768/x_test.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2019 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 issue30768_test - -import ( - "testing" - - "testshared/issue30768/issue30768lib" -) - -type s struct { - s issue30768lib.S -} - -func Test30768(t *testing.T) { - // Calling t.Log will convert S to an empty interface, - // which will force a reference to the generated hash function, - // defined in the shared library. - t.Log(s{}) -} diff --git a/misc/cgo/testshared/testdata/issue39777/a/a.go b/misc/cgo/testshared/testdata/issue39777/a/a.go deleted file mode 100644 index c7bf835951..0000000000 --- a/misc/cgo/testshared/testdata/issue39777/a/a.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2020 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 a - -import "testshared/issue39777/b" - -func F() { b.F() } diff --git a/misc/cgo/testshared/testdata/issue39777/b/b.go b/misc/cgo/testshared/testdata/issue39777/b/b.go deleted file mode 100644 index 4e681965e6..0000000000 --- a/misc/cgo/testshared/testdata/issue39777/b/b.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2020 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 b - -func F() {} diff --git a/misc/cgo/testshared/testdata/issue44031/a/a.go b/misc/cgo/testshared/testdata/issue44031/a/a.go deleted file mode 100644 index 48827e682f..0000000000 --- a/misc/cgo/testshared/testdata/issue44031/a/a.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2021 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 a - -type ATypeWithALoooooongName interface { // a long name, so the type descriptor symbol name is mangled - M() -} diff --git a/misc/cgo/testshared/testdata/issue44031/b/b.go b/misc/cgo/testshared/testdata/issue44031/b/b.go deleted file mode 100644 index ad3ebec2b9..0000000000 --- a/misc/cgo/testshared/testdata/issue44031/b/b.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2021 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 b - -import "testshared/issue44031/a" - -type T int - -func (T) M() {} - -var i = a.ATypeWithALoooooongName(T(0)) - -func F() { - i.M() -} diff --git a/misc/cgo/testshared/testdata/issue44031/main/main.go b/misc/cgo/testshared/testdata/issue44031/main/main.go deleted file mode 100644 index 47f2e3a98e..0000000000 --- a/misc/cgo/testshared/testdata/issue44031/main/main.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2021 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 main - -import "testshared/issue44031/b" - -type t int - -func (t) m() {} - -type i interface{ m() } // test that unexported method is correctly marked - -var v interface{} = t(0) - -func main() { - b.F() - v.(i).m() -} diff --git a/misc/cgo/testshared/testdata/issue47837/a/a.go b/misc/cgo/testshared/testdata/issue47837/a/a.go deleted file mode 100644 index 68588eda2f..0000000000 --- a/misc/cgo/testshared/testdata/issue47837/a/a.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2021 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 a - -type A interface { - M() -} - -//go:noinline -func TheFuncWithArgA(a A) { - a.M() -} - -type ImplA struct{} - -//go:noinline -func (A *ImplA) M() {} diff --git a/misc/cgo/testshared/testdata/issue47837/main/main.go b/misc/cgo/testshared/testdata/issue47837/main/main.go deleted file mode 100644 index 77c6f34379..0000000000 --- a/misc/cgo/testshared/testdata/issue47837/main/main.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2021 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 main - -import ( - "testshared/issue47837/a" -) - -func main() { - var vara a.ImplA - a.TheFuncWithArgA(&vara) -} diff --git a/misc/cgo/testshared/testdata/trivial/trivial.go b/misc/cgo/testshared/testdata/trivial/trivial.go deleted file mode 100644 index 6ade47ce36..0000000000 --- a/misc/cgo/testshared/testdata/trivial/trivial.go +++ /dev/null @@ -1,9 +0,0 @@ -package main - -func main() { - // This is enough to make sure that the executable references - // a type descriptor, which was the cause of - // https://golang.org/issue/25970. - c := make(chan int) - _ = c -} diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index 5935011e19..87238cc74f 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -762,9 +762,6 @@ func (t *tester) registerTests() { if t.supportedBuildmode("c-shared") { t.registerHostTest("testcshared", "../misc/cgo/testcshared", "misc/cgo/testcshared", ".") } - if t.supportedBuildmode("shared") { - t.registerTest("testshared", "../misc/cgo/testshared", t.goTest(), t.timeout(600), ".") - } if t.supportedBuildmode("plugin") { t.registerTest("testplugin", "../misc/cgo/testplugin", t.goTest(), t.timeout(600), ".") } @@ -1047,12 +1044,6 @@ func (t *tester) supportedBuildmode(mode string) bool { return true } return false - case "shared": - switch pair { - case "linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-s390x": - return true - } - return false case "plugin": // linux-arm64 is missing because it causes the external linker // to crash, see https://golang.org/issue/17138 diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 9d8c321307..685ccac826 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -162,9 +162,6 @@ // flags has a similar effect. // -ldflags '[pattern=]arg list' // arguments to pass on each go tool link invocation. -// -linkshared -// build code that will be linked against shared libraries previously -// created with -buildmode=shared. // -mod mode // module download mode to use: readonly, vendor, or mod. // By default, if a vendor directory is present and the go version in go.mod @@ -778,7 +775,6 @@ // Name string // package name // Doc string // package documentation string // Target string // install path -// Shlib string // the shared library that contains this package (only set when -linkshared) // Goroot bool // is this package in the Go root? // Standard bool // is this package part of the standard Go library? // Stale bool // would 'go install' do anything for this package? @@ -1799,11 +1795,6 @@ // non-main packages are built into .a files (the default // behavior). // -// -buildmode=shared -// Combine all the listed non-main packages into a single shared -// library that will be used when building with the -linkshared -// option. Packages named main are ignored. -// // -buildmode=exe // Build the listed main packages and everything they import into // executables. Packages not named main are ignored. diff --git a/src/cmd/go/internal/help/helpdoc.go b/src/cmd/go/internal/help/helpdoc.go index 035235fe1b..2bb3584eba 100644 --- a/src/cmd/go/internal/help/helpdoc.go +++ b/src/cmd/go/internal/help/helpdoc.go @@ -726,11 +726,6 @@ are: non-main packages are built into .a files (the default behavior). - -buildmode=shared - Combine all the listed non-main packages into a single shared - library that will be used when building with the -linkshared - option. Packages named main are ignored. - -buildmode=exe Build the listed main packages and everything they import into executables. Packages not named main are ignored. diff --git a/src/cmd/go/internal/list/list.go b/src/cmd/go/internal/list/list.go index 8c85ddcf21..f23fbe5fea 100644 --- a/src/cmd/go/internal/list/list.go +++ b/src/cmd/go/internal/list/list.go @@ -23,8 +23,8 @@ import ( "cmd/go/internal/load" "cmd/go/internal/modinfo" "cmd/go/internal/modload" - "cmd/go/internal/work" "cmd/go/internal/str" + "cmd/go/internal/work" ) var CmdList = &base.Command{ @@ -56,7 +56,6 @@ to -f '{{.ImportPath}}'. The struct being passed to the template is: Name string // package name Doc string // package documentation string Target string // install path - Shlib string // the shared library that contains this package (only set when -linkshared) Goroot bool // is this package in the Go root? Standard bool // is this package part of the standard Go library? Stale bool // would 'go install' do anything for this package? diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index 9d0ad27f0d..e39ffcbd50 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -116,9 +116,6 @@ and test commands: flags has a similar effect. -ldflags '[pattern=]arg list' arguments to pass on each go tool link invocation. - -linkshared - build code that will be linked against shared libraries previously - created with -buildmode=shared. -mod mode module download mode to use: readonly, vendor, or mod. By default, if a vendor directory is present and the go version in go.mod diff --git a/src/cmd/go/internal/work/init.go b/src/cmd/go/internal/work/init.go index 4dbbd2a13f..b2ee00d53c 100644 --- a/src/cmd/go/internal/work/init.go +++ b/src/cmd/go/internal/work/init.go @@ -246,16 +246,20 @@ func buildModeInit() { } ldBuildmode = "pie" case "shared": - pkgsFilter = pkgsNotMain - if gccgo { - codegenArg = "-fPIC" - } else { - codegenArg = "-dynlink" + if cfg.Goos == "linux" { + switch cfg.Goarch { + case "386", "amd64", "arm", "arm64", "ppc64le", "s390x": + // -buildmode=shared was supported on these platforms at one point, but + // never really worked in module mode. + // Support was officially dropped as of Go 1.18. + // (See https://golang.org/issue/47788.) + base.Fatalf("-buildmode=shared no longer supported as of Go 1.18") + + // TODO(#47788): Remove supporting code for -buildmode=shared. + // (For the Go 1.18 release, we will keep most of the code around but + // disabled to avoid merge conflicts in case we need to revert quickly.) + } } - if cfg.BuildO != "" { - base.Fatalf("-buildmode=shared and -o not supported together") - } - ldBuildmode = "shared" case "plugin": pkgsFilter = oneMainPkg if gccgo { @@ -274,6 +278,15 @@ func buildModeInit() { } if cfg.BuildLinkshared { + if cfg.Goos == "linux" { + switch cfg.Goarch { + case "386", "amd64", "arm", "arm64", "ppc64le", "s390x": + base.Fatalf("-linkshared no longer supported as of Go 1.18") + // TODO(#47788): Remove supporting code for linkshared. + // (For the Go 1.18 release, we will keep most of the code around but + // disabled to avoid merge conflicts in case we need to revert quickly.) + } + } if !sys.BuildModeSupported(cfg.BuildToolchainName, "shared", cfg.Goos, cfg.Goarch) { base.Fatalf("-linkshared not supported on %s/%s\n", cfg.Goos, cfg.Goarch) } diff --git a/src/cmd/go/testdata/script/list_linkshared.txt b/src/cmd/go/testdata/script/list_linkshared.txt deleted file mode 100644 index baae1e2be8..0000000000 --- a/src/cmd/go/testdata/script/list_linkshared.txt +++ /dev/null @@ -1,16 +0,0 @@ -env GO111MODULE=on - -# golang.org/issue/35759: 'go list -linkshared' -# panicked if invoked on a test-only package. - -[!buildmode:shared] skip - -go list -f '{{.ImportPath}}: {{.Target}} {{.Shlib}}' -linkshared . -stdout '^example.com: $' - --- go.mod -- -module example.com - -go 1.14 --- x.go -- -package x diff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go index e6c56fbc56..473e390587 100644 --- a/src/cmd/internal/sys/supported.go +++ b/src/cmd/internal/sys/supported.go @@ -109,13 +109,6 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool { } return false - case "shared": - switch platform { - case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x": - return true - } - return false - case "plugin": switch platform { case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le", From 3f1b0ce6bb4f2e7d44791c5532728f86e24f1f1f Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 25 Oct 2021 09:13:16 -0700 Subject: [PATCH 186/406] cmd/compile/internal/types2: clarify is/underIs semantics and implementation The behavior of is/underIs was murky with the presence of a top type term (corresponding to a type set that is not constrained by any types, yet the function argument f of is/underIs was called with that term). Change is/underIs to call f explicitly for existing specific type terms, otherwise return the result of f(nil). Review all uses of is/underIs and variants. This makes the conversion code slightly more complicated because we need to explicitly exclude type parameters without specific types; but the code is clearer now. Change-Id: I6115cb46f7f2a8d0f54799aafff9a67c4cca5e30 Reviewed-on: https://go-review.googlesource.com/c/go/+/358594 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/builtins.go | 5 +- .../compile/internal/types2/conversions.go | 11 ++++- src/cmd/compile/internal/types2/expr.go | 2 + src/cmd/compile/internal/types2/infer.go | 2 +- src/cmd/compile/internal/types2/operand.go | 3 ++ src/cmd/compile/internal/types2/typeparam.go | 11 +++++ src/cmd/compile/internal/types2/typeset.go | 46 ++++++++++--------- 7 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index 37e1f00d26..318894b69b 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -834,7 +834,10 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x Type) Type { // Test if t satisfies the requirements for the argument // type and collect possible result types at the same time. var terms []*Term - if !tp.iface().typeSet().is(func(t *term) bool { + if !tp.is(func(t *term) bool { + if t == nil { + return false + } if r := f(t.typ); r != nil { terms = append(terms, NewTerm(t.tilde, r)) return true diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index a4fba28fce..8389770ce5 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -20,7 +20,7 @@ func (check *Checker) conversion(x *operand, T Type) { var cause string switch { case constArg && isConstType(T): - // constant conversion + // constant conversion (T cannot be a type parameter) switch t := asBasic(T); { case representableConst(x.val, check, t, &x.val): ok = true @@ -94,8 +94,15 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { return true } + // determine type parameter operands with specific type terms Vp, _ := under(x.typ).(*TypeParam) Tp, _ := under(T).(*TypeParam) + if Vp != nil && !Vp.hasTerms() { + Vp = nil + } + if Tp != nil && !Tp.hasTerms() { + Tp = nil + } errorf := func(format string, args ...interface{}) { if check != nil && cause != nil { @@ -107,7 +114,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { } } - // generic cases + // generic cases with specific type terms // (generic operands cannot be constants, so we can ignore x.val) switch { case Vp != nil && Tp != nil: diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index 3a39de7406..9afe3b7f01 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -155,6 +155,8 @@ var op2str2 = [...]string{ syntax.Shl: "shift", } +// If typ is a type parameter, underIs returns the result of typ.underIs(f). +// Otherwise, underIs returns the result of f(under(typ)). func underIs(typ Type, f func(Type) bool) bool { u := under(typ) if tpar, _ := u.(*TypeParam); tpar != nil { diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go index ad8c6ac412..142ae6cb33 100644 --- a/src/cmd/compile/internal/types2/infer.go +++ b/src/cmd/compile/internal/types2/infer.go @@ -320,7 +320,7 @@ func (w *tpWalker) isParameterized(typ Type) (res bool) { } } return tset.is(func(t *term) bool { - return w.isParameterized(t.typ) + return t != nil && w.isParameterized(t.typ) }) case *Map: diff --git a/src/cmd/compile/internal/types2/operand.go b/src/cmd/compile/internal/types2/operand.go index 5c8654dbf1..69426f4d03 100644 --- a/src/cmd/compile/internal/types2/operand.go +++ b/src/cmd/compile/internal/types2/operand.go @@ -273,6 +273,9 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er if t, ok := under(T).(*TypeParam); ok { return t.is(func(t *term) bool { // TODO(gri) this could probably be more efficient + if t == nil { + return false + } if t.tilde { // TODO(gri) We need to check assignability // for the underlying type of x. diff --git a/src/cmd/compile/internal/types2/typeparam.go b/src/cmd/compile/internal/types2/typeparam.go index f7cdff0180..75e2fe8f0e 100644 --- a/src/cmd/compile/internal/types2/typeparam.go +++ b/src/cmd/compile/internal/types2/typeparam.go @@ -119,10 +119,21 @@ func (t *TypeParam) structuralType() Type { return t.iface().typeSet().structuralType() } +// hasTerms reports whether the type parameter constraint has specific type terms. +func (t *TypeParam) hasTerms() bool { + return t.iface().typeSet().hasTerms() +} + +// is calls f with the specific type terms of t's constraint and reports whether +// all calls to f returned true. If there are no specific terms, is +// returns the result of f(nil). func (t *TypeParam) is(f func(*term) bool) bool { return t.iface().typeSet().is(f) } +// underIs calls f with the underlying types of the specific type terms +// of t's constraint and reports whether all calls to f returned true. +// If there are no specific terms, underIs returns the result of f(nil). func (t *TypeParam) underIs(f func(Type) bool) bool { return t.iface().typeSet().underIs(f) } diff --git a/src/cmd/compile/internal/types2/typeset.go b/src/cmd/compile/internal/types2/typeset.go index f9e3af7ba8..c99d02744b 100644 --- a/src/cmd/compile/internal/types2/typeset.go +++ b/src/cmd/compile/internal/types2/typeset.go @@ -39,7 +39,7 @@ func (s *_TypeSet) IsComparable() bool { return s.comparable } return s.is(func(t *term) bool { - return Comparable(t.typ) + return t != nil && Comparable(t.typ) }) } @@ -101,27 +101,29 @@ func (s *_TypeSet) String() string { // ---------------------------------------------------------------------------- // Implementation -func (s *_TypeSet) hasTerms() bool { return !s.terms.isEmpty() && !s.terms.isAll() } -func (s *_TypeSet) structuralType() Type { return s.terms.structuralType() } -func (s *_TypeSet) includes(t Type) bool { return s.terms.includes(t) } +// hasTerms reports whether the type set has specific type terms. +func (s *_TypeSet) hasTerms() bool { return !s.terms.isEmpty() && !s.terms.isAll() } + +// structuralType returns the single type in s if there is exactly one; otherwise the result is nil. +func (s *_TypeSet) structuralType() Type { return s.terms.structuralType() } + +// includes reports whether t ∈ s. +func (s *_TypeSet) includes(t Type) bool { return s.terms.includes(t) } + +// subsetOf reports whether s1 ⊆ s2. func (s1 *_TypeSet) subsetOf(s2 *_TypeSet) bool { return s1.terms.subsetOf(s2.terms) } // TODO(gri) TypeSet.is and TypeSet.underIs should probably also go into termlist.go -var topTerm = term{false, theTop} - +// is calls f with the specific type terms of s and reports whether +// all calls to f returned true. If there are no specific terms, is +// returns the result of f(nil). func (s *_TypeSet) is(f func(*term) bool) bool { - if len(s.terms) == 0 { - return false + if !s.hasTerms() { + return f(nil) } for _, t := range s.terms { - // Terms represent the top term with a nil type. - // The rest of the type checker uses the top type - // instead. Convert. - // TODO(gri) investigate if we can do without this - if t.typ == nil { - t = &topTerm - } + assert(t.typ != nil) if !f(t) { return false } @@ -129,17 +131,17 @@ func (s *_TypeSet) is(f func(*term) bool) bool { return true } +// underIs calls f with the underlying types of the specific type terms +// of s and reports whether all calls to f returned true. If there are +// no specific terms, is returns the result of f(nil). func (s *_TypeSet) underIs(f func(Type) bool) bool { - if len(s.terms) == 0 { - return false + if !s.hasTerms() { + return f(nil) } for _, t := range s.terms { - // see corresponding comment in TypeSet.is + assert(t.typ != nil) + // x == under(x) for ~x terms u := t.typ - if u == nil { - u = theTop - } - // t == under(t) for ~t terms if !t.tilde { u = under(u) } From 56dcf976561ff6c666d9d1fe6231557ac2072883 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 22 Oct 2021 09:49:15 -0700 Subject: [PATCH 187/406] cmd/compile/internal/types2: generalize assignability to generic types Similar to conversions, handle ordinary cases first, followed by type-by-type assignability tests in case of type parameters with specific types in their type sets. Add a new class of type checker tests, in testdata/spec, which I hope we can populate over time with tests following the spec organization. Moved the conversions.go2 tests in the same dir. Change-Id: Iac253ae375c08022bdc39e92e3951ec3f509e432 Reviewed-on: https://go-review.googlesource.com/c/go/+/357917 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/check_test.go | 1 + src/cmd/compile/internal/types2/operand.go | 107 ++++++-- .../types2/testdata/spec/assignability.go2 | 234 ++++++++++++++++++ .../{examples => spec}/conversions.go2 | 0 4 files changed, 316 insertions(+), 26 deletions(-) create mode 100644 src/cmd/compile/internal/types2/testdata/spec/assignability.go2 rename src/cmd/compile/internal/types2/testdata/{examples => spec}/conversions.go2 (100%) diff --git a/src/cmd/compile/internal/types2/check_test.go b/src/cmd/compile/internal/types2/check_test.go index e71df87f2c..d4c7b7b39b 100644 --- a/src/cmd/compile/internal/types2/check_test.go +++ b/src/cmd/compile/internal/types2/check_test.go @@ -278,6 +278,7 @@ func TestManual(t *testing.T) { // TODO(gri) go/types has extra TestLongConstants and TestIndexRepresentability tests func TestCheck(t *testing.T) { DefPredeclaredTestFuncs(); testDirFiles(t, "testdata/check", 75, false) } // TODO(gri) narrow column tolerance +func TestSpec(t *testing.T) { DefPredeclaredTestFuncs(); testDirFiles(t, "testdata/spec", 0, false) } func TestExamples(t *testing.T) { testDirFiles(t, "testdata/examples", 0, false) } func TestFixedbugs(t *testing.T) { testDirFiles(t, "testdata/fixedbugs", 0, false) } diff --git a/src/cmd/compile/internal/types2/operand.go b/src/cmd/compile/internal/types2/operand.go index 69426f4d03..92ae0a95fc 100644 --- a/src/cmd/compile/internal/types2/operand.go +++ b/src/cmd/compile/internal/types2/operand.go @@ -249,53 +249,46 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er V := x.typ - const debugAssignableTo = false - if debugAssignableTo && check != nil { - check.dump("V = %s", V) - check.dump("T = %s", T) - } - // x's type is identical to T if Identical(V, T) { return true, 0 } - Vu := optype(V) - Tu := optype(T) - - if debugAssignableTo && check != nil { - check.dump("Vu = %s", Vu) - check.dump("Tu = %s", Tu) - } + Vu := under(V) + Tu := under(T) + Vp, _ := Vu.(*TypeParam) + Tp, _ := Tu.(*TypeParam) // x is an untyped value representable by a value of type T. if isUntyped(Vu) { - if t, ok := under(T).(*TypeParam); ok { - return t.is(func(t *term) bool { - // TODO(gri) this could probably be more efficient + assert(Vp == nil) + if Tp != nil { + // T is a type parameter: x is assignable to T if it is + // representable by each specific type in the type set of T. + return Tp.is(func(t *term) bool { if t == nil { return false } - if t.tilde { - // TODO(gri) We need to check assignability - // for the underlying type of x. - } - ok, _ := x.assignableTo(check, t.typ, reason) - return ok + // A term may be a tilde term but the underlying + // type of an untyped value doesn't change so we + // don't need to do anything special. + newType, _, _ := check.implicitTypeAndValue(x, t.typ) + return newType != nil }), _IncompatibleAssign } - newType, _, _ := check.implicitTypeAndValue(x, Tu) + newType, _, _ := check.implicitTypeAndValue(x, T) return newType != nil, _IncompatibleAssign } // Vu is typed // x's type V and T have identical underlying types // and at least one of V or T is not a named type - if Identical(Vu, Tu) && (!isNamed(V) || !isNamed(T)) { + // and neither is a type parameter. + if Identical(Vu, Tu) && (!isNamed(V) || !isNamed(T)) && Vp == nil && Tp == nil { return true, 0 } - // T is an interface type and x implements T + // T is an interface type and x implements T and T is not a type parameter if Ti, ok := Tu.(*Interface); ok { if m, wrongType := check.missingMethod(V, Ti, true); m != nil /* Implements(V, Ti) */ { if reason != nil { @@ -325,7 +318,69 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er } } - return false, _IncompatibleAssign + // common case: if we don't have type parameters, we're done + if Vp == nil && Tp == nil { + return false, _IncompatibleAssign + } + + // determine type parameter operands with specific type terms + if Vp != nil && !Vp.hasTerms() { + Vp = nil + } + if Tp != nil && !Tp.hasTerms() { + Tp = nil + } + + errorf := func(format string, args ...interface{}) { + if check != nil && reason != nil { + msg := check.sprintf(format, args...) + if *reason != "" { + msg += "\n\t" + *reason + } + *reason = msg + } + } + + ok := false + code := _IncompatibleAssign + switch { + case Vp != nil && Tp != nil: + x := *x // don't clobber outer x + ok = Vp.is(func(V *term) bool { + x.typ = V.typ + return Tp.is(func(T *term) bool { + ok, code = x.assignableTo(check, T.typ, reason) + if !ok { + errorf("cannot assign %s (in %s) to %s (in %s)", V.typ, Vp, T.typ, Tp) + return false + } + return true + }) + }) + case Vp != nil: + x := *x // don't clobber outer x + ok = Vp.is(func(V *term) bool { + x.typ = V.typ + ok, code = x.assignableTo(check, T, reason) + if !ok { + errorf("cannot assign %s (in %s) to %s", V.typ, Vp, T) + return false + } + return true + }) + case Tp != nil: + x := *x // don't clobber outer x + ok = Tp.is(func(T *term) bool { + ok, code = x.assignableTo(check, T.typ, reason) + if !ok { + errorf("cannot assign %s to %s (in %s)", x.typ, T.typ, Tp) + return false + } + return true + }) + } + + return ok, code } // kind2tok translates syntax.LitKinds into token.Tokens. diff --git a/src/cmd/compile/internal/types2/testdata/spec/assignability.go2 b/src/cmd/compile/internal/types2/testdata/spec/assignability.go2 new file mode 100644 index 0000000000..1507cabb1d --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/spec/assignability.go2 @@ -0,0 +1,234 @@ +// Copyright 2021 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 assignability + +// See the end of this package for the declarations +// of the types and variables used in these tests. + +// "x's type is identical to T" +func _[TP any](X TP) { + b = b + a = a + l = l + s = s + p = p + f = f + i = i + m = m + c = c + d = d + + B = B + A = A + L = L + S = S + P = P + F = F + I = I + M = M + C = C + D = D + X = X +} + +// "x's type V and T have identical underlying types and at least one +// of V or T is not a defined type and neither is a type parameter" +func _[TP1, TP2 Interface](X1 TP1, X2 TP2) { + b = B // ERROR cannot use B .* as int value + a = A + l = L + s = S + p = P + f = F + i = I + m = M + c = C + d = D + + B = b // ERROR cannot use b .* as Basic value + A = a + L = l + S = s + P = p + F = f + I = i + M = m + C = c + D = d + X1 = i // ERROR cannot use i .* as TP1 value + X1 = X2 // ERROR cannot use X2 .* as TP1 value +} + +// "T is an interface type and x implements T and T is not a type parameter" +func _[TP Interface](X TP) { + i = d // ERROR missing method m + i = D + i = X + X = i // ERROR cannot use i .* as TP value +} + +// "x is a bidirectional channel value, T is a channel type, x's type V and T have identical element types, and at least one of V or T is not a defined type" +type ( + _SendChan = chan<- int + _RecvChan = <-chan int + + SendChan _SendChan + RecvChan _RecvChan +) + +func _[ + _CC ~_Chan, + _SC ~_SendChan, + _RC ~_RecvChan, + + CC Chan, + SC SendChan, + RC RecvChan, +]() { + var ( + _ _SendChan = c + _ _RecvChan = c + _ _Chan = c + + _ _SendChan = C + _ _RecvChan = C + _ _Chan = C + + _ SendChan = c + _ RecvChan = c + _ Chan = c + + _ SendChan = C // ERROR cannot use C .* as SendChan value + _ RecvChan = C // ERROR cannot use C .* as RecvChan value + _ Chan = C + _ Chan = make /* ERROR cannot use make\(chan Basic\) .* as Chan value */ (chan Basic) + ) + + var ( + _ _CC = C + _ _SC = C + _ _RC = C + + _ CC = _CC(nil) + _ SC = _CC(nil) + _ RC = _CC(nil) + + _ CC = C + _ SC = C // ERROR cannot use C .* as SC value .* cannot assign Chan to SendChan + _ RC = C // ERROR cannot use C .* as RC value .* cannot assign Chan to RecvChan + ) +} + +// "x is the predeclared identifier nil and T is a pointer, function, slice, map, channel, or interface type" +func _[TP Interface](X TP) { + b = nil // ERROR cannot use untyped nil + a = nil // ERROR cannot use untyped nil + l = nil + s = nil // ERROR cannot use untyped nil + p = nil + f = nil + i = nil + m = nil + c = nil + d = nil // ERROR cannot use untyped nil + + B = nil // ERROR cannot use untyped nil + A = nil // ERROR cannot use untyped nil + L = nil + S = nil // ERROR cannot use untyped nil + P = nil + F = nil + I = nil + M = nil + C = nil + D = nil // ERROR cannot use untyped nil + X = nil // ERROR cannot use untyped nil +} + +// "x is an untyped constant representable by a value of type T" +func _[ + Int8 ~int8, + Int16 ~int16, + Int32 ~int32, + Int64 ~int64, + Int8_16 ~int8 | ~int16, +]( + i8 Int8, + i16 Int16, + i32 Int32, + i64 Int64, + i8_16 Int8_16, +) { + b = 42 + b = 42.0 + // etc. + + i8 = -1 << 7 + i8 = 1<<7 - 1 + i16 = -1 << 15 + i16 = 1<<15 - 1 + i32 = -1 << 31 + i32 = 1<<31 - 1 + i64 = -1 << 63 + i64 = 1<<63 - 1 + + i8_16 = -1 << 7 + i8_16 = 1<<7 - 1 + i8_16 = - /* ERROR cannot use .* as Int8_16 */ 1 << 15 + i8_16 = 1 /* ERROR cannot use .* as Int8_16 */ <<15 - 1 +} + +// proto-types for tests + +type ( + _Basic = int + _Array = [10]int + _Slice = []int + _Struct = struct{ f int } + _Pointer = *int + _Func = func(x int) string + _Interface = interface{ m() int } + _Map = map[string]int + _Chan = chan int + + Basic _Basic + Array _Array + Slice _Slice + Struct _Struct + Pointer _Pointer + Func _Func + Interface _Interface + Map _Map + Chan _Chan + Defined _Struct +) + +func (Defined) m() int + +// proto-variables for tests + +var ( + b _Basic + a _Array + l _Slice + s _Struct + p _Pointer + f _Func + i _Interface + m _Map + c _Chan + d _Struct + + B Basic + A Array + L Slice + S Struct + P Pointer + F Func + I Interface + M Map + C Chan + D Defined +) diff --git a/src/cmd/compile/internal/types2/testdata/examples/conversions.go2 b/src/cmd/compile/internal/types2/testdata/spec/conversions.go2 similarity index 100% rename from src/cmd/compile/internal/types2/testdata/examples/conversions.go2 rename to src/cmd/compile/internal/types2/testdata/spec/conversions.go2 From d611f092001f76942251f68023dba137b8a3e821 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 25 Oct 2021 17:22:55 -0700 Subject: [PATCH 188/406] cmd/compile/internal/types2: clean up asT converters (step 1 of 2) This CL changes the convenience converters asT to use under instead of optype. To make sure the effect is well understood, in a first step, all asT functions are renamed to toT so that we can see which call sites are affected. In almost all places, the change is what we want. In some places we may get more conservative behavior (which is easy to relax if need be). In some places (function calls through a type parameter, append built-in) we now use singleUnder instead, for a more general behavior, matching other primary expressions or built- ins. This change removes the last use of optype and thus also theTop and top, all of which have been deleted from the code. The next CL renames the toT converters back to their asT form. Change-Id: I35d1ad866ce46de175a055b36ef577d99bb9de22 Reviewed-on: https://go-review.googlesource.com/c/go/+/358597 Trust: Robert Griesemer Reviewed-by: Robert Findley --- .../compile/internal/types2/assignments.go | 2 +- src/cmd/compile/internal/types2/builtins.go | 29 +++-- src/cmd/compile/internal/types2/call.go | 7 +- .../compile/internal/types2/conversions.go | 24 +++-- src/cmd/compile/internal/types2/expr.go | 8 +- src/cmd/compile/internal/types2/index.go | 6 +- src/cmd/compile/internal/types2/infer.go | 4 +- src/cmd/compile/internal/types2/lookup.go | 8 +- src/cmd/compile/internal/types2/predicates.go | 10 +- .../compile/internal/types2/sizeof_test.go | 1 - src/cmd/compile/internal/types2/sizes.go | 2 +- src/cmd/compile/internal/types2/subst.go | 2 +- .../internal/types2/testdata/check/issues.go2 | 7 ++ src/cmd/compile/internal/types2/type.go | 102 +++++------------- src/cmd/compile/internal/types2/typestring.go | 5 +- src/cmd/compile/internal/types2/typexpr.go | 4 +- 16 files changed, 91 insertions(+), 130 deletions(-) diff --git a/src/cmd/compile/internal/types2/assignments.go b/src/cmd/compile/internal/types2/assignments.go index bfc5578683..0d647a493d 100644 --- a/src/cmd/compile/internal/types2/assignments.go +++ b/src/cmd/compile/internal/types2/assignments.go @@ -71,7 +71,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) { // x.typ is typed // A generic (non-instantiated) function value cannot be assigned to a variable. - if sig := asSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { + if sig := toSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { check.errorf(x, "cannot use generic function %s without instantiation in %s", x, context) } diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index 318894b69b..b08a1343f3 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -82,7 +82,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // of S and the respective parameter passing rules apply." S := x.typ var T Type - if s := asSlice(S); s != nil { + if s, _ := singleUnder(S).(*Slice); s != nil { T = s.elem } else { check.errorf(x, invalidArg+"%s is not a slice", x) @@ -291,8 +291,10 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( } // the argument types must be of floating-point type - f := func(x Type) Type { - if t := asBasic(x); t != nil { + // (applyTypeFunc never calls f with a type parameter) + f := func(typ Type) Type { + assert(asTypeParam(typ) == nil) + if t := toBasic(typ); t != nil { switch t.kind { case Float32: return Typ[Complex64] @@ -413,8 +415,10 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( } // the argument must be of complex type - f := func(x Type) Type { - if t := asBasic(x); t != nil { + // (applyTypeFunc never calls f with a type parameter) + f := func(typ Type) Type { + assert(asTypeParam(typ) == nil) + if t := toBasic(typ); t != nil { switch t.kind { case Complex64: return Typ[Float32] @@ -700,7 +704,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( return } - typ := asPointer(x.typ) + typ := toPointer(x.typ) if typ == nil { check.errorf(x, invalidArg+"%s is not a pointer", x) return @@ -816,7 +820,7 @@ func hasVarSize(t Type) bool { } case *TypeParam: return true - case *Named, *Union, *top: + case *Named, *Union: unreachable() } return false @@ -847,13 +851,8 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x Type) Type { return nil } - // TODO(gri) Would it be ok to return just the one type - // if len(rtypes) == 1? What about top-level - // uses of real() where the result is used to - // define type and initialize a variable? - - // Construct a suitable new type parameter for the sum type. The - // type param is placed in the current package so export/import + // Construct a suitable new type parameter for the result type. + // The type parameter is placed in the current package so export/import // works as expected. tpar := NewTypeName(nopos, check.pkg, "", nil) ptyp := check.newTypeParam(tpar, NewInterfaceType(nil, []Type{NewUnion(terms)})) // assigns type to tpar as a side-effect @@ -885,7 +884,7 @@ func makeSig(res Type, args ...Type) *Signature { // otherwise it returns typ. func arrayPtrDeref(typ Type) Type { if p, ok := typ.(*Pointer); ok { - if a := asArray(p.base); a != nil { + if a := toArray(p.base); a != nil { return a } } diff --git a/src/cmd/compile/internal/types2/call.go b/src/cmd/compile/internal/types2/call.go index 3859e39550..e4d57d4543 100644 --- a/src/cmd/compile/internal/types2/call.go +++ b/src/cmd/compile/internal/types2/call.go @@ -130,9 +130,9 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind { case 1: check.expr(x, call.ArgList[0]) if x.mode != invalid { - if t := asInterface(T); t != nil { + if t := toInterface(T); t != nil { if !t.IsMethodSet() { - check.errorf(call, "cannot use interface %s in conversion (contains type list or is comparable)", T) + check.errorf(call, "cannot use interface %s in conversion (contains specific type constraints or is comparable)", T) break } } @@ -167,7 +167,8 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind { // signature may be generic cgocall := x.mode == cgofunc - sig := asSignature(x.typ) + // a type parameter may be "called" if all types have the same signature + sig, _ := singleUnder(x.typ).(*Signature) if sig == nil { check.errorf(x, invalidOp+"cannot call non-function %s", x) x.mode = invalid diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index 8389770ce5..8897a15c4f 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -21,7 +21,7 @@ func (check *Checker) conversion(x *operand, T Type) { switch { case constArg && isConstType(T): // constant conversion (T cannot be a type parameter) - switch t := asBasic(T); { + switch t := toBasic(T); { case representableConst(x.val, check, t, &x.val): ok = true case isInteger(x.typ) && isString(t): @@ -200,9 +200,9 @@ func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { // "V a slice, T is a pointer-to-array type, // and the slice and array types have identical element types." - if s := asSlice(V); s != nil { - if p := asPointer(T); p != nil { - if a := asArray(p.Elem()); a != nil { + if s := toSlice(V); s != nil { + if p := toPointer(T); p != nil { + if a := toArray(p.Elem()); a != nil { if Identical(s.Elem(), a.Elem()) { if check == nil || check.allowVersion(check.pkg, 1, 17) { return true @@ -225,27 +225,31 @@ func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { return false } +// Helper predicates for convertibleToImpl. The types provided to convertibleToImpl +// may be type parameters but they won't have specific type terms. Thus it is ok to +// use the toT convenience converters in the predicates below. + func isUintptr(typ Type) bool { - t := asBasic(typ) + t := toBasic(typ) return t != nil && t.kind == Uintptr } func isUnsafePointer(typ Type) bool { - // TODO(gri): Is this asBasic(typ) instead of typ.(*Basic) correct? + // TODO(gri): Is this toBasic(typ) instead of typ.(*Basic) correct? // (The former calls under(), while the latter doesn't.) // The spec does not say so, but gc claims it is. See also // issue 6326. - t := asBasic(typ) + t := toBasic(typ) return t != nil && t.kind == UnsafePointer } func isPointer(typ Type) bool { - return asPointer(typ) != nil + return toPointer(typ) != nil } func isBytesOrRunes(typ Type) bool { - if s := asSlice(typ); s != nil { - t := asBasic(s.elem) + if s := toSlice(typ); s != nil { + t := toBasic(s.elem) return t != nil && (t.kind == Byte || t.kind == Rune) } return false diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index 9afe3b7f01..c87e7fba82 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -113,8 +113,10 @@ func (check *Checker) overflow(x *operand) { // Typed constants must be representable in // their type after each constant operation. + // x.typ cannot be a type parameter (type + // parameters cannot be constant types). if isTyped(x.typ) { - check.representable(x, asBasic(x.typ)) + check.representable(x, toBasic(x.typ)) return } @@ -615,7 +617,7 @@ func (check *Checker) updateExprType(x syntax.Expr, typ Type, final bool) { // If the new type is not final and still untyped, just // update the recorded type. if !final && isUntyped(typ) { - old.typ = asBasic(typ) + old.typ = toBasic(typ) check.untyped[x] = old return } @@ -1385,7 +1387,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin duplicate := false // if the key is of interface type, the type is also significant when checking for duplicates xkey := keyVal(x.val) - if asInterface(utyp.key) != nil { + if toInterface(utyp.key) != nil { for _, vtyp := range visited[xkey] { if Identical(vtyp, x.typ) { duplicate = true diff --git a/src/cmd/compile/internal/types2/index.go b/src/cmd/compile/internal/types2/index.go index 62f49b95da..325d3c2585 100644 --- a/src/cmd/compile/internal/types2/index.go +++ b/src/cmd/compile/internal/types2/index.go @@ -34,7 +34,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo return false case value: - if sig := asSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { + if sig := toSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { // function instantiation return true } @@ -72,7 +72,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo x.typ = typ.elem case *Pointer: - if typ := asArray(typ.base); typ != nil { + if typ := toArray(typ.base); typ != nil { valid = true length = typ.len x.mode = variable @@ -242,7 +242,7 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) { x.typ = &Slice{elem: u.elem} case *Pointer: - if u := asArray(u.base); u != nil { + if u := toArray(u.base); u != nil { valid = true length = u.len x.typ = &Slice{elem: u.elem} diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go index 142ae6cb33..9b892029f9 100644 --- a/src/cmd/compile/internal/types2/infer.go +++ b/src/cmd/compile/internal/types2/infer.go @@ -275,7 +275,7 @@ func (w *tpWalker) isParameterized(typ Type) (res bool) { }() switch t := typ.(type) { - case nil, *top, *Basic: // TODO(gri) should nil be handled here? + case nil, *Basic: // TODO(gri) should nil be handled here? break case *Array: @@ -504,7 +504,7 @@ func (w *cycleFinder) typ(typ Type) { defer delete(w.seen, typ) switch t := typ.(type) { - case *Basic, *top: + case *Basic: // nothing to do case *Array: diff --git a/src/cmd/compile/internal/types2/lookup.go b/src/cmd/compile/internal/types2/lookup.go index e0fd74482a..652a04a6e3 100644 --- a/src/cmd/compile/internal/types2/lookup.go +++ b/src/cmd/compile/internal/types2/lookup.go @@ -306,7 +306,7 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method, return } - if ityp := asInterface(V); ityp != nil { + if ityp := toInterface(V); ityp != nil { // TODO(gri) the methods are sorted - could do this more efficiently for _, m := range T.typeSet().methods { _, f := ityp.typeSet().LookupMethod(m.pkg, m.name) @@ -417,7 +417,7 @@ func (check *Checker) assertableTo(V *Interface, T Type) (method, wrongType *Fun // no static check is required if T is an interface // spec: "If T is an interface type, x.(T) asserts that the // dynamic type of x implements the interface T." - if asInterface(T) != nil && !forceStrict { + if toInterface(T) != nil && !forceStrict { return } return check.missingMethod(T, V, false) @@ -435,8 +435,8 @@ func deref(typ Type) (Type, bool) { // derefStructPtr dereferences typ if it is a (named or unnamed) pointer to a // (named or unnamed) struct and returns its base. Otherwise it returns typ. func derefStructPtr(typ Type) Type { - if p := asPointer(typ); p != nil { - if asStruct(p.base) != nil { + if p := toPointer(typ); p != nil { + if toStruct(p.base) != nil { return p.base } } diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go index 74ad3da72c..f89575b24c 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -56,7 +56,7 @@ func isNumericOrString(typ Type) bool { return is(typ, IsNumeric|IsString) } // are not fully set up. func isTyped(typ Type) bool { // isTyped is called with types that are not fully - // set up. Must not call asBasic()! + // set up. Must not call toBasic()! t, _ := typ.(*Basic) return t == nil || t.info&IsUntyped == 0 } @@ -70,13 +70,13 @@ func isOrdered(typ Type) bool { return is(typ, IsOrdered) } func isConstType(typ Type) bool { // Type parameters are never const types. - t, _ := under(typ).(*Basic) + t := toBasic(typ) return t != nil && t.info&IsConstType != 0 } // IsInterface reports whether typ is an interface type. func IsInterface(typ Type) bool { - return asInterface(typ) != nil + return toInterface(typ) != nil } // Comparable reports whether values of type T are comparable. @@ -339,10 +339,6 @@ func identical(x, y Type, cmpTags bool, p *ifacePair) bool { case *TypeParam: // nothing to do (x and y being equal is caught in the very beginning of this function) - case *top: - // Either both types are theTop in which case the initial x == y check - // will have caught them. Otherwise they are not identical. - case nil: // avoid a crash in case of nil type diff --git a/src/cmd/compile/internal/types2/sizeof_test.go b/src/cmd/compile/internal/types2/sizeof_test.go index d47e23f735..99b846b80b 100644 --- a/src/cmd/compile/internal/types2/sizeof_test.go +++ b/src/cmd/compile/internal/types2/sizeof_test.go @@ -34,7 +34,6 @@ func TestSizeof(t *testing.T) { {Named{}, 68, 128}, {TypeParam{}, 28, 48}, {term{}, 12, 24}, - {top{}, 0, 0}, // Objects {PkgName{}, 64, 104}, diff --git a/src/cmd/compile/internal/types2/sizes.go b/src/cmd/compile/internal/types2/sizes.go index 6a3d19d8ea..28597340e3 100644 --- a/src/cmd/compile/internal/types2/sizes.go +++ b/src/cmd/compile/internal/types2/sizes.go @@ -243,7 +243,7 @@ func (conf *Config) offsetsof(T *Struct) []int64 { func (conf *Config) offsetof(typ Type, index []int) int64 { var o int64 for _, i := range index { - s := asStruct(typ) + s := toStruct(typ) o += conf.offsetsof(s)[i] typ = s.fields[i].typ } diff --git a/src/cmd/compile/internal/types2/subst.go b/src/cmd/compile/internal/types2/subst.go index a5ebd416aa..269b284ac4 100644 --- a/src/cmd/compile/internal/types2/subst.go +++ b/src/cmd/compile/internal/types2/subst.go @@ -74,7 +74,7 @@ func (subst *subster) typ(typ Type) Type { // Call typOrNil if it's possible that typ is nil. panic("nil typ") - case *Basic, *top: + case *Basic: // nothing to do case *Array: diff --git a/src/cmd/compile/internal/types2/testdata/check/issues.go2 b/src/cmd/compile/internal/types2/testdata/check/issues.go2 index 7c5659ba17..8608473135 100644 --- a/src/cmd/compile/internal/types2/testdata/check/issues.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/issues.go2 @@ -223,6 +223,13 @@ func _[T interface{ ~func() }](f T) { go f() } +type F1 func() +type F2 func() +func _[T interface{ func()|F1|F2 }](f T) { + f() + go f() +} + // We must compare against the underlying type of type list entries // when checking if a constraint is satisfied by a type. The under- // lying type of each type list entry must be computed after the diff --git a/src/cmd/compile/internal/types2/type.go b/src/cmd/compile/internal/types2/type.go index 3fb05e9d63..9ff8ad57d2 100644 --- a/src/cmd/compile/internal/types2/type.go +++ b/src/cmd/compile/internal/types2/type.go @@ -9,26 +9,13 @@ package types2 type Type interface { // Underlying returns the underlying type of a type // w/o following forwarding chains. Only used by - // client packages (here for backward-compatibility). + // client packages. Underlying() Type // String returns a string representation of a type. String() string } -// top represents the top of the type lattice. -// It is the underlying type of a type parameter that -// can be satisfied by any type (ignoring methods), -// because its type constraint contains no restrictions -// besides methods. -type top struct{} - -// theTop is the singleton top type. -var theTop = &top{} - -func (t *top) Underlying() Type { return t } -func (t *top) String() string { return TypeString(t, nil) } - // under returns the true expanded underlying type. // If it doesn't exist, the result is Typ[Invalid]. // under must only be called when a type is known @@ -40,78 +27,47 @@ func under(t Type) Type { return t } -// optype returns a type's operational type. Except for -// type parameters, the operational type is the same -// as the underlying type (as returned by under). For -// Type parameters, the operational type is the structural -// type, if any; otherwise it's the top type. -// The result is never the incoming type parameter. -func optype(typ Type) Type { - if t := asTypeParam(typ); t != nil { - // TODO(gri) review accuracy of this comment - // If the optype is typ, return the top type as we have - // no information. It also prevents infinite recursion - // via the asTypeParam converter function. This can happen - // for a type parameter list of the form: - // (type T interface { type T }). - // See also issue #39680. - if u := t.structuralType(); u != nil { - assert(u != typ) // "naked" type parameters cannot be embedded - return under(u) // optype should always return an underlying type - } - return theTop - } - return under(typ) +// Convenience converters + +func toBasic(t Type) *Basic { + u, _ := under(t).(*Basic) + return u } -// Converters -// -// A converter must only be called when a type is -// known to be fully set up. A converter returns -// a type's operational type (see comment for optype) -// or nil if the type argument is not of the -// respective type. - -func asBasic(t Type) *Basic { - op, _ := optype(t).(*Basic) - return op +func toArray(t Type) *Array { + u, _ := under(t).(*Array) + return u } -func asArray(t Type) *Array { - op, _ := optype(t).(*Array) - return op +func toSlice(t Type) *Slice { + u, _ := under(t).(*Slice) + return u } -func asSlice(t Type) *Slice { - op, _ := optype(t).(*Slice) - return op +func toStruct(t Type) *Struct { + u, _ := under(t).(*Struct) + return u } -func asStruct(t Type) *Struct { - op, _ := optype(t).(*Struct) - return op +func toPointer(t Type) *Pointer { + u, _ := under(t).(*Pointer) + return u } -func asPointer(t Type) *Pointer { - op, _ := optype(t).(*Pointer) - return op +func toSignature(t Type) *Signature { + u, _ := under(t).(*Signature) + return u } -func asSignature(t Type) *Signature { - op, _ := optype(t).(*Signature) - return op -} - -// If the argument to asInterface, asNamed, or asTypeParam is of the respective type -// (possibly after expanding an instance type), these methods return that type. -// Otherwise the result is nil. - -// asInterface does not need to look at optype (type sets don't contain interfaces) -func asInterface(t Type) *Interface { +func toInterface(t Type) *Interface { u, _ := under(t).(*Interface) return u } +// If the argument to asNamed, or asTypeParam is of the respective type +// (possibly after expanding resolving a *Named type), these methods return that type. +// Otherwise the result is nil. + func asNamed(t Type) *Named { e, _ := t.(*Named) if e != nil { @@ -127,8 +83,8 @@ func asTypeParam(t Type) *TypeParam { // Exported for the compiler. -func AsPointer(t Type) *Pointer { return asPointer(t) } +func AsPointer(t Type) *Pointer { return toPointer(t) } func AsNamed(t Type) *Named { return asNamed(t) } -func AsSignature(t Type) *Signature { return asSignature(t) } -func AsInterface(t Type) *Interface { return asInterface(t) } +func AsSignature(t Type) *Signature { return toSignature(t) } +func AsInterface(t Type) *Interface { return toInterface(t) } func AsTypeParam(t Type) *TypeParam { return asTypeParam(t) } diff --git a/src/cmd/compile/internal/types2/typestring.go b/src/cmd/compile/internal/types2/typestring.go index 61c8a9158c..1804df2d99 100644 --- a/src/cmd/compile/internal/types2/typestring.go +++ b/src/cmd/compile/internal/types2/typestring.go @@ -272,9 +272,6 @@ func (w *typeWriter) typ(typ Type) { } w.string(t.obj.name + subscript(t.id)) - case *top: - w.error("⊤") - default: // For externally defined implementations of Type. // Note: In this case cycles won't be caught. @@ -358,7 +355,7 @@ func (w *typeWriter) tuple(tup *Tuple, variadic bool) { } else { // special case: // append(s, "foo"...) leads to signature func([]byte, string...) - if t := asBasic(typ); t == nil || t.kind != String { + if t := toBasic(typ); t == nil || t.kind != String { w.error("expected string type") continue } diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go index 20e56caf1e..3704cda6a8 100644 --- a/src/cmd/compile/internal/types2/typexpr.go +++ b/src/cmd/compile/internal/types2/typexpr.go @@ -144,11 +144,11 @@ func (check *Checker) typ(e syntax.Expr) Type { func (check *Checker) varType(e syntax.Expr) Type { typ := check.definedType(e, nil) - // We don't want to call under() (via asInterface) or complete interfaces while we + // We don't want to call under() (via toInterface) or complete interfaces while we // are in the middle of type-checking parameter declarations that might belong to // interface methods. Delay this check to the end of type-checking. check.later(func() { - if t := asInterface(typ); t != nil { + if t := toInterface(typ); t != nil { pos := syntax.StartPos(e) tset := computeInterfaceTypeSet(check, pos, t) // TODO(gri) is this the correct position? if !tset.IsMethodSet() { From a155a307fbeda88fd44c5399d4fb7ea9e34db545 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 25 Oct 2021 20:54:05 -0700 Subject: [PATCH 189/406] cmd/compile/internal/types2: clean up asT converters (step 2 of 2) This CL renames the toT converters back to their asT names. Change-Id: If4bda5a78525f9722f044f5544f400fa8bb6f437 Reviewed-on: https://go-review.googlesource.com/c/go/+/358774 Trust: Robert Griesemer Reviewed-by: Robert Findley --- .../compile/internal/types2/assignments.go | 2 +- src/cmd/compile/internal/types2/builtins.go | 8 ++++---- src/cmd/compile/internal/types2/call.go | 2 +- .../compile/internal/types2/conversions.go | 20 +++++++++---------- src/cmd/compile/internal/types2/expr.go | 6 +++--- src/cmd/compile/internal/types2/index.go | 6 +++--- src/cmd/compile/internal/types2/lookup.go | 8 ++++---- src/cmd/compile/internal/types2/predicates.go | 6 +++--- src/cmd/compile/internal/types2/sizes.go | 2 +- src/cmd/compile/internal/types2/type.go | 20 +++++++++---------- src/cmd/compile/internal/types2/typestring.go | 2 +- src/cmd/compile/internal/types2/typexpr.go | 2 +- 12 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/cmd/compile/internal/types2/assignments.go b/src/cmd/compile/internal/types2/assignments.go index 0d647a493d..bfc5578683 100644 --- a/src/cmd/compile/internal/types2/assignments.go +++ b/src/cmd/compile/internal/types2/assignments.go @@ -71,7 +71,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) { // x.typ is typed // A generic (non-instantiated) function value cannot be assigned to a variable. - if sig := toSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { + if sig := asSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { check.errorf(x, "cannot use generic function %s without instantiation in %s", x, context) } diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index b08a1343f3..7897dafa46 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -294,7 +294,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // (applyTypeFunc never calls f with a type parameter) f := func(typ Type) Type { assert(asTypeParam(typ) == nil) - if t := toBasic(typ); t != nil { + if t := asBasic(typ); t != nil { switch t.kind { case Float32: return Typ[Complex64] @@ -418,7 +418,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // (applyTypeFunc never calls f with a type parameter) f := func(typ Type) Type { assert(asTypeParam(typ) == nil) - if t := toBasic(typ); t != nil { + if t := asBasic(typ); t != nil { switch t.kind { case Complex64: return Typ[Float32] @@ -704,7 +704,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( return } - typ := toPointer(x.typ) + typ := asPointer(x.typ) if typ == nil { check.errorf(x, invalidArg+"%s is not a pointer", x) return @@ -884,7 +884,7 @@ func makeSig(res Type, args ...Type) *Signature { // otherwise it returns typ. func arrayPtrDeref(typ Type) Type { if p, ok := typ.(*Pointer); ok { - if a := toArray(p.base); a != nil { + if a := asArray(p.base); a != nil { return a } } diff --git a/src/cmd/compile/internal/types2/call.go b/src/cmd/compile/internal/types2/call.go index e4d57d4543..1618e88fef 100644 --- a/src/cmd/compile/internal/types2/call.go +++ b/src/cmd/compile/internal/types2/call.go @@ -130,7 +130,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind { case 1: check.expr(x, call.ArgList[0]) if x.mode != invalid { - if t := toInterface(T); t != nil { + if t := asInterface(T); t != nil { if !t.IsMethodSet() { check.errorf(call, "cannot use interface %s in conversion (contains specific type constraints or is comparable)", T) break diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index 8897a15c4f..a456f89f7e 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -21,7 +21,7 @@ func (check *Checker) conversion(x *operand, T Type) { switch { case constArg && isConstType(T): // constant conversion (T cannot be a type parameter) - switch t := toBasic(T); { + switch t := asBasic(T); { case representableConst(x.val, check, t, &x.val): ok = true case isInteger(x.typ) && isString(t): @@ -200,9 +200,9 @@ func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { // "V a slice, T is a pointer-to-array type, // and the slice and array types have identical element types." - if s := toSlice(V); s != nil { - if p := toPointer(T); p != nil { - if a := toArray(p.Elem()); a != nil { + if s := asSlice(V); s != nil { + if p := asPointer(T); p != nil { + if a := asArray(p.Elem()); a != nil { if Identical(s.Elem(), a.Elem()) { if check == nil || check.allowVersion(check.pkg, 1, 17) { return true @@ -230,26 +230,26 @@ func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { // use the toT convenience converters in the predicates below. func isUintptr(typ Type) bool { - t := toBasic(typ) + t := asBasic(typ) return t != nil && t.kind == Uintptr } func isUnsafePointer(typ Type) bool { - // TODO(gri): Is this toBasic(typ) instead of typ.(*Basic) correct? + // TODO(gri): Is this asBasic(typ) instead of typ.(*Basic) correct? // (The former calls under(), while the latter doesn't.) // The spec does not say so, but gc claims it is. See also // issue 6326. - t := toBasic(typ) + t := asBasic(typ) return t != nil && t.kind == UnsafePointer } func isPointer(typ Type) bool { - return toPointer(typ) != nil + return asPointer(typ) != nil } func isBytesOrRunes(typ Type) bool { - if s := toSlice(typ); s != nil { - t := toBasic(s.elem) + if s := asSlice(typ); s != nil { + t := asBasic(s.elem) return t != nil && (t.kind == Byte || t.kind == Rune) } return false diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index c87e7fba82..9142eee85c 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -116,7 +116,7 @@ func (check *Checker) overflow(x *operand) { // x.typ cannot be a type parameter (type // parameters cannot be constant types). if isTyped(x.typ) { - check.representable(x, toBasic(x.typ)) + check.representable(x, asBasic(x.typ)) return } @@ -617,7 +617,7 @@ func (check *Checker) updateExprType(x syntax.Expr, typ Type, final bool) { // If the new type is not final and still untyped, just // update the recorded type. if !final && isUntyped(typ) { - old.typ = toBasic(typ) + old.typ = asBasic(typ) check.untyped[x] = old return } @@ -1387,7 +1387,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin duplicate := false // if the key is of interface type, the type is also significant when checking for duplicates xkey := keyVal(x.val) - if toInterface(utyp.key) != nil { + if asInterface(utyp.key) != nil { for _, vtyp := range visited[xkey] { if Identical(vtyp, x.typ) { duplicate = true diff --git a/src/cmd/compile/internal/types2/index.go b/src/cmd/compile/internal/types2/index.go index 325d3c2585..62f49b95da 100644 --- a/src/cmd/compile/internal/types2/index.go +++ b/src/cmd/compile/internal/types2/index.go @@ -34,7 +34,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo return false case value: - if sig := toSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { + if sig := asSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { // function instantiation return true } @@ -72,7 +72,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo x.typ = typ.elem case *Pointer: - if typ := toArray(typ.base); typ != nil { + if typ := asArray(typ.base); typ != nil { valid = true length = typ.len x.mode = variable @@ -242,7 +242,7 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) { x.typ = &Slice{elem: u.elem} case *Pointer: - if u := toArray(u.base); u != nil { + if u := asArray(u.base); u != nil { valid = true length = u.len x.typ = &Slice{elem: u.elem} diff --git a/src/cmd/compile/internal/types2/lookup.go b/src/cmd/compile/internal/types2/lookup.go index 652a04a6e3..e0fd74482a 100644 --- a/src/cmd/compile/internal/types2/lookup.go +++ b/src/cmd/compile/internal/types2/lookup.go @@ -306,7 +306,7 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method, return } - if ityp := toInterface(V); ityp != nil { + if ityp := asInterface(V); ityp != nil { // TODO(gri) the methods are sorted - could do this more efficiently for _, m := range T.typeSet().methods { _, f := ityp.typeSet().LookupMethod(m.pkg, m.name) @@ -417,7 +417,7 @@ func (check *Checker) assertableTo(V *Interface, T Type) (method, wrongType *Fun // no static check is required if T is an interface // spec: "If T is an interface type, x.(T) asserts that the // dynamic type of x implements the interface T." - if toInterface(T) != nil && !forceStrict { + if asInterface(T) != nil && !forceStrict { return } return check.missingMethod(T, V, false) @@ -435,8 +435,8 @@ func deref(typ Type) (Type, bool) { // derefStructPtr dereferences typ if it is a (named or unnamed) pointer to a // (named or unnamed) struct and returns its base. Otherwise it returns typ. func derefStructPtr(typ Type) Type { - if p := toPointer(typ); p != nil { - if toStruct(p.base) != nil { + if p := asPointer(typ); p != nil { + if asStruct(p.base) != nil { return p.base } } diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go index f89575b24c..4faa09ebd0 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -56,7 +56,7 @@ func isNumericOrString(typ Type) bool { return is(typ, IsNumeric|IsString) } // are not fully set up. func isTyped(typ Type) bool { // isTyped is called with types that are not fully - // set up. Must not call toBasic()! + // set up. Must not call asBasic()! t, _ := typ.(*Basic) return t == nil || t.info&IsUntyped == 0 } @@ -70,13 +70,13 @@ func isOrdered(typ Type) bool { return is(typ, IsOrdered) } func isConstType(typ Type) bool { // Type parameters are never const types. - t := toBasic(typ) + t := asBasic(typ) return t != nil && t.info&IsConstType != 0 } // IsInterface reports whether typ is an interface type. func IsInterface(typ Type) bool { - return toInterface(typ) != nil + return asInterface(typ) != nil } // Comparable reports whether values of type T are comparable. diff --git a/src/cmd/compile/internal/types2/sizes.go b/src/cmd/compile/internal/types2/sizes.go index 28597340e3..6a3d19d8ea 100644 --- a/src/cmd/compile/internal/types2/sizes.go +++ b/src/cmd/compile/internal/types2/sizes.go @@ -243,7 +243,7 @@ func (conf *Config) offsetsof(T *Struct) []int64 { func (conf *Config) offsetof(typ Type, index []int) int64 { var o int64 for _, i := range index { - s := toStruct(typ) + s := asStruct(typ) o += conf.offsetsof(s)[i] typ = s.fields[i].typ } diff --git a/src/cmd/compile/internal/types2/type.go b/src/cmd/compile/internal/types2/type.go index 9ff8ad57d2..33d3d3642c 100644 --- a/src/cmd/compile/internal/types2/type.go +++ b/src/cmd/compile/internal/types2/type.go @@ -29,37 +29,37 @@ func under(t Type) Type { // Convenience converters -func toBasic(t Type) *Basic { +func asBasic(t Type) *Basic { u, _ := under(t).(*Basic) return u } -func toArray(t Type) *Array { +func asArray(t Type) *Array { u, _ := under(t).(*Array) return u } -func toSlice(t Type) *Slice { +func asSlice(t Type) *Slice { u, _ := under(t).(*Slice) return u } -func toStruct(t Type) *Struct { +func asStruct(t Type) *Struct { u, _ := under(t).(*Struct) return u } -func toPointer(t Type) *Pointer { +func asPointer(t Type) *Pointer { u, _ := under(t).(*Pointer) return u } -func toSignature(t Type) *Signature { +func asSignature(t Type) *Signature { u, _ := under(t).(*Signature) return u } -func toInterface(t Type) *Interface { +func asInterface(t Type) *Interface { u, _ := under(t).(*Interface) return u } @@ -83,8 +83,8 @@ func asTypeParam(t Type) *TypeParam { // Exported for the compiler. -func AsPointer(t Type) *Pointer { return toPointer(t) } +func AsPointer(t Type) *Pointer { return asPointer(t) } func AsNamed(t Type) *Named { return asNamed(t) } -func AsSignature(t Type) *Signature { return toSignature(t) } -func AsInterface(t Type) *Interface { return toInterface(t) } +func AsSignature(t Type) *Signature { return asSignature(t) } +func AsInterface(t Type) *Interface { return asInterface(t) } func AsTypeParam(t Type) *TypeParam { return asTypeParam(t) } diff --git a/src/cmd/compile/internal/types2/typestring.go b/src/cmd/compile/internal/types2/typestring.go index 1804df2d99..709499792b 100644 --- a/src/cmd/compile/internal/types2/typestring.go +++ b/src/cmd/compile/internal/types2/typestring.go @@ -355,7 +355,7 @@ func (w *typeWriter) tuple(tup *Tuple, variadic bool) { } else { // special case: // append(s, "foo"...) leads to signature func([]byte, string...) - if t := toBasic(typ); t == nil || t.kind != String { + if t := asBasic(typ); t == nil || t.kind != String { w.error("expected string type") continue } diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go index 3704cda6a8..d8183bfd9c 100644 --- a/src/cmd/compile/internal/types2/typexpr.go +++ b/src/cmd/compile/internal/types2/typexpr.go @@ -148,7 +148,7 @@ func (check *Checker) varType(e syntax.Expr) Type { // are in the middle of type-checking parameter declarations that might belong to // interface methods. Delay this check to the end of type-checking. check.later(func() { - if t := toInterface(typ); t != nil { + if t := asInterface(typ); t != nil { pos := syntax.StartPos(e) tset := computeInterfaceTypeSet(check, pos, t) // TODO(gri) is this the correct position? if !tset.IsMethodSet() { From 5c4d7c50c7266bfbce3f43f04a0fb622b9e45805 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 25 Oct 2021 21:43:07 -0700 Subject: [PATCH 190/406] cmd/compile/internal/types2: rename isNamed predicate to hasName isNamed(t) is easily confused with asNamed(t) != nil (e.g., we have isPointer(t) that is defined as asPointer(t) != nil). This rename also helped clarifying a couple of places in the assignability rules where it makes sense to simply look for types that have names. Change-Id: Ie995908613a26883ffe0562343d297a1e981e9ef Reviewed-on: https://go-review.googlesource.com/c/go/+/358621 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/operand.go | 9 ++++----- src/cmd/compile/internal/types2/predicates.go | 7 ++++--- .../internal/types2/testdata/spec/assignability.go2 | 8 +++++--- src/cmd/compile/internal/types2/unify.go | 6 +++--- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/cmd/compile/internal/types2/operand.go b/src/cmd/compile/internal/types2/operand.go index 92ae0a95fc..e4db0554f3 100644 --- a/src/cmd/compile/internal/types2/operand.go +++ b/src/cmd/compile/internal/types2/operand.go @@ -282,9 +282,8 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er // Vu is typed // x's type V and T have identical underlying types - // and at least one of V or T is not a named type - // and neither is a type parameter. - if Identical(Vu, Tu) && (!isNamed(V) || !isNamed(T)) && Vp == nil && Tp == nil { + // and at least one of V or T is not a named type. + if Identical(Vu, Tu) && (!hasName(V) || !hasName(T)) { return true, 0 } @@ -311,10 +310,10 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er // x is a bidirectional channel value, T is a channel // type, x's type V and T have identical element types, - // and at least one of V or T is not a named type + // and at least one of V or T is not a named type. if Vc, ok := Vu.(*Chan); ok && Vc.dir == SendRecv { if Tc, ok := Tu.(*Chan); ok && Identical(Vc.elem, Tc.elem) { - return !isNamed(V) || !isNamed(T), _InvalidChanAssign + return !hasName(V) || !hasName(T), _InvalidChanAssign } } diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go index 4faa09ebd0..409715ad9d 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -6,9 +6,10 @@ package types2 -// isNamed reports whether typ has a name. -// isNamed may be called with types that are not fully set up. -func isNamed(typ Type) bool { +// hasName reports whether typ has a name. This includes +// predeclared types, defined types, and type parameters. +// hasName may be called with types that are not fully set up. +func hasName(typ Type) bool { switch typ.(type) { case *Basic, *Named, *TypeParam: return true diff --git a/src/cmd/compile/internal/types2/testdata/spec/assignability.go2 b/src/cmd/compile/internal/types2/testdata/spec/assignability.go2 index 1507cabb1d..ab8f9c08b2 100644 --- a/src/cmd/compile/internal/types2/testdata/spec/assignability.go2 +++ b/src/cmd/compile/internal/types2/testdata/spec/assignability.go2 @@ -33,8 +33,9 @@ func _[TP any](X TP) { X = X } -// "x's type V and T have identical underlying types and at least one -// of V or T is not a defined type and neither is a type parameter" +// "x's type V and T have identical underlying types +// and at least one of V or T is not a named type." +// (here a named type is a type with a name) func _[TP1, TP2 Interface](X1 TP1, X2 TP2) { b = B // ERROR cannot use B .* as int value a = A @@ -69,7 +70,8 @@ func _[TP Interface](X TP) { X = i // ERROR cannot use i .* as TP value } -// "x is a bidirectional channel value, T is a channel type, x's type V and T have identical element types, and at least one of V or T is not a defined type" +// "x is a bidirectional channel value, T is a channel type, x's type V and T have identical element types, and at least one of V or T is not a named type" +// (here a named type is a type with a name) type ( _SendChan = chan<- int _RecvChan = <-chan int diff --git a/src/cmd/compile/internal/types2/unify.go b/src/cmd/compile/internal/types2/unify.go index a252c5e1a5..7f636c30d3 100644 --- a/src/cmd/compile/internal/types2/unify.go +++ b/src/cmd/compile/internal/types2/unify.go @@ -235,13 +235,13 @@ func (u *unifier) nify(x, y Type, p *ifacePair) bool { // If exact unification is known to fail because we attempt to // match a type name against an unnamed type literal, consider // the underlying type of the named type. - // (Subtle: We use isNamed to include any type with a name (incl. + // (Subtle: We use hasName to include any type with a name (incl. // basic types and type parameters. We use asNamed because we only // want *Named types.) switch { - case !isNamed(x) && y != nil && asNamed(y) != nil: + case !hasName(x) && y != nil && asNamed(y) != nil: return u.nify(x, under(y), p) - case x != nil && asNamed(x) != nil && !isNamed(y): + case x != nil && asNamed(x) != nil && !hasName(y): return u.nify(under(x), y, p) } } From 6a7eb56cd1837b961ea815105235a3fd96fda94b Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 26 Oct 2021 13:55:53 -0700 Subject: [PATCH 191/406] cmd/compile/internal/types2: remove unused position computation (cleanup) The position computation was needed for type list support. With that gone, we don't need this code anymore. Change-Id: I3f36b3d108a1fae9947fd259d4892e0287cb78ef Reviewed-on: https://go-review.googlesource.com/c/go/+/358701 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/union.go | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/cmd/compile/internal/types2/union.go b/src/cmd/compile/internal/types2/union.go index 87985dd133..5379bde02c 100644 --- a/src/cmd/compile/internal/types2/union.go +++ b/src/cmd/compile/internal/types2/union.go @@ -75,28 +75,16 @@ func parseUnion(check *Checker, tlist []syntax.Expr) Type { continue } - x := tlist[i] - pos := syntax.StartPos(x) - // We may not know the position of x if it was a typechecker- - // introduced ~T term for a type list entry T. Use the position - // of T instead. - // TODO(gri) remove this test once we don't support type lists anymore - if !pos.IsKnown() { - if op, _ := x.(*syntax.Operation); op != nil { - pos = syntax.StartPos(op.X) - } - } - u := under(t.typ) f, _ := u.(*Interface) if t.tilde { if f != nil { - check.errorf(x, "invalid use of ~ (%s is an interface)", t.typ) + check.errorf(tlist[i], "invalid use of ~ (%s is an interface)", t.typ) continue // don't report another error for t } if !Identical(u, t.typ) { - check.errorf(x, "invalid use of ~ (underlying type of %s is %s)", t.typ, u) + check.errorf(tlist[i], "invalid use of ~ (underlying type of %s is %s)", t.typ, u) continue // don't report another error for t } } @@ -105,14 +93,14 @@ func parseUnion(check *Checker, tlist []syntax.Expr) Type { // in the beginning. Embedded interfaces with tilde are excluded above. If we reach // here, we must have at least two terms in the union. if f != nil && !f.typeSet().IsTypeSet() { - check.errorf(pos, "cannot use %s in union (interface contains methods)", t) + check.errorf(tlist[i], "cannot use %s in union (interface contains methods)", t) continue // don't report another error for t } // Report overlapping (non-disjoint) terms such as // a|a, a|~a, ~a|~a, and ~a|A (where under(A) == a). if j := overlappingTerm(terms[:i], t); j >= 0 { - check.softErrorf(pos, "overlapping terms %s and %s", t, terms[j]) + check.softErrorf(tlist[i], "overlapping terms %s and %s", t, terms[j]) } } }) From bbc059572d599a414653e4ac659b4738d434e1f1 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 26 Oct 2021 17:07:32 -0700 Subject: [PATCH 192/406] cmd/compile/internal/types2: implement singleType and structure (type) Rename structuralType to singleType throughout. This reflects more closely what the function does: if a type set consists of exactly one type term, singleType returns the corresponding type. Rename singleUnder to structure. The structure function returns the "type structure" of a type, either its underlying type for a non-type parameter, or the single underlying type (if it exists) for a type parameter. Change constraint type inference to use the structure type for inference, unless the structure type is the underlying type of a single defined type, in which case it uses the latter. This preserves existing behavior while making constraint type inference slightly more flexible. Change-Id: I38ee89ffdabd12bfeaa0be2ad6af8fb373c11fc9 Reviewed-on: https://go-review.googlesource.com/c/go/+/359015 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/builtins.go | 26 +++++++++---------- src/cmd/compile/internal/types2/call.go | 2 +- src/cmd/compile/internal/types2/expr.go | 2 +- src/cmd/compile/internal/types2/index.go | 2 +- src/cmd/compile/internal/types2/infer.go | 13 +++++++--- src/cmd/compile/internal/types2/stmt.go | 2 +- src/cmd/compile/internal/types2/termlist.go | 4 +-- .../compile/internal/types2/termlist_test.go | 6 ++--- .../types2/testdata/examples/inference.go2 | 23 ++++++++++++++++ src/cmd/compile/internal/types2/typeparam.go | 6 ++--- src/cmd/compile/internal/types2/typeset.go | 4 +-- 11 files changed, 59 insertions(+), 31 deletions(-) diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index 7897dafa46..e8de0077d4 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -82,7 +82,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // of S and the respective parameter passing rules apply." S := x.typ var T Type - if s, _ := singleUnder(S).(*Slice); s != nil { + if s, _ := structure(S).(*Slice); s != nil { T = s.elem } else { check.errorf(x, invalidArg+"%s is not a slice", x) @@ -327,14 +327,14 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( case _Copy: // copy(x, y []T) int - dst, _ := singleUnder(x.typ).(*Slice) + dst, _ := structure(x.typ).(*Slice) var y operand arg(&y, 1) if y.mode == invalid { return } - src, _ := singleUnderString(y.typ).(*Slice) + src, _ := structureString(y.typ).(*Slice) if dst == nil || src == nil { check.errorf(x, invalidArg+"copy expects slice arguments; found %s and %s", x, &y) @@ -464,7 +464,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( } var min int // minimum number of arguments - switch singleUnder(T).(type) { + switch structure(T).(type) { case *Slice: min = 2 case *Map, *Chan: @@ -767,11 +767,11 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( return true } -// If typ is a type parameter, single under returns the single underlying -// type of all types in the corresponding type constraint if it exists, or -// nil if it doesn't exist. If typ is not a type parameter, singleUnder -// just returns the underlying type. -func singleUnder(typ Type) Type { +// If typ is a type parameter, structure returns the single underlying +// type of all types in the corresponding type constraint if it exists, +// or nil otherwise. If typ is not a type parameter, structure returns +// the underlying type. +func structure(typ Type) Type { var su Type if underIs(typ, func(u Type) bool { if su != nil && !Identical(su, u) { @@ -786,10 +786,10 @@ func singleUnder(typ Type) Type { return nil } -// singleUnderString is like singleUnder but also considers []byte and -// string as "identical". In this case, if successful, the result is always -// []byte. -func singleUnderString(typ Type) Type { +// structureString is like structure but also considers []byte and +// string as "identical". In this case, if successful, the result +// is always []byte. +func structureString(typ Type) Type { var su Type if underIs(typ, func(u Type) bool { if isString(u) { diff --git a/src/cmd/compile/internal/types2/call.go b/src/cmd/compile/internal/types2/call.go index 1618e88fef..220ba940b3 100644 --- a/src/cmd/compile/internal/types2/call.go +++ b/src/cmd/compile/internal/types2/call.go @@ -168,7 +168,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind { cgocall := x.mode == cgofunc // a type parameter may be "called" if all types have the same signature - sig, _ := singleUnder(x.typ).(*Signature) + sig, _ := structure(x.typ).(*Signature) if sig == nil { check.errorf(x, invalidOp+"cannot call non-function %s", x) x.mode = invalid diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index 9142eee85c..ae7b205e53 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -1257,7 +1257,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin goto Error } - switch utyp := singleUnder(base).(type) { + switch utyp := structure(base).(type) { case *Struct: if len(e.ElemList) == 0 { break diff --git a/src/cmd/compile/internal/types2/index.go b/src/cmd/compile/internal/types2/index.go index 62f49b95da..23e433ac6a 100644 --- a/src/cmd/compile/internal/types2/index.go +++ b/src/cmd/compile/internal/types2/index.go @@ -207,7 +207,7 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) { valid := false length := int64(-1) // valid if >= 0 - switch u := singleUnder(x.typ).(type) { + switch u := structure(x.typ).(type) { case nil: check.errorf(x, invalidOp+"cannot slice %s: type set has no single underlying type", x) x.mode = invalid diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go index 9b892029f9..156c2290f7 100644 --- a/src/cmd/compile/internal/types2/infer.go +++ b/src/cmd/compile/internal/types2/infer.go @@ -363,7 +363,7 @@ func (w *tpWalker) isParameterizedTypeList(list []Type) bool { func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type, index int) { assert(len(tparams) >= len(targs) && len(targs) > 0) - // Setup bidirectional unification between those structural bounds + // Setup bidirectional unification between constraints // and the corresponding type arguments (which may be nil!). u := newUnifier(false) u.x.init(tparams) @@ -376,11 +376,16 @@ func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type, } } - // Unify type parameters with their structural constraints, if any. + // If a constraint has a structural type, unify the corresponding type parameter with it. for _, tpar := range tparams { typ := tpar - sbound := typ.structuralType() + sbound := structure(tpar) if sbound != nil { + // If the structural type is the underlying type of a single + // defined type in the constraint, use that defined type instead. + if named, _ := tpar.singleType().(*Named); named != nil { + sbound = named + } if !u.unify(typ, sbound) { check.errorf(tpar.obj, "%s does not match %s", tpar.obj, sbound) return nil, 0 @@ -389,7 +394,7 @@ func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type, } // u.x.types() now contains the incoming type arguments plus any additional type - // arguments for which there were structural constraints. The newly inferred non- + // arguments which were inferred from structural types. The newly inferred non- // nil entries may still contain references to other type parameters. // For instance, for [A any, B interface{ []C }, C interface{ *A }], if A == int // was given, unification produced the type list [int, []C, *A]. We eliminate the diff --git a/src/cmd/compile/internal/types2/stmt.go b/src/cmd/compile/internal/types2/stmt.go index 10741a90e2..dd2100f711 100644 --- a/src/cmd/compile/internal/types2/stmt.go +++ b/src/cmd/compile/internal/types2/stmt.go @@ -836,7 +836,7 @@ func (check *Checker) rangeStmt(inner stmtContext, s *syntax.ForStmt, rclause *s if x.mode != invalid { // Ranging over a type parameter is permitted if it has a single underlying type. var cause string - u := singleUnder(x.typ) + u := structure(x.typ) switch t := u.(type) { case nil: cause = "type set has no single underlying type" diff --git a/src/cmd/compile/internal/types2/termlist.go b/src/cmd/compile/internal/types2/termlist.go index 378ba6b8f4..844e39e3bf 100644 --- a/src/cmd/compile/internal/types2/termlist.go +++ b/src/cmd/compile/internal/types2/termlist.go @@ -93,8 +93,8 @@ func (xl termlist) norm() termlist { } // If the type set represented by xl is specified by a single (non-𝓤) term, -// structuralType returns that type. Otherwise it returns nil. -func (xl termlist) structuralType() Type { +// singleType returns that type. Otherwise it returns nil. +func (xl termlist) singleType() Type { if nl := xl.norm(); len(nl) == 1 { return nl[0].typ // if nl.isAll() then typ is nil, which is ok } diff --git a/src/cmd/compile/internal/types2/termlist_test.go b/src/cmd/compile/internal/types2/termlist_test.go index ed1330d26f..1bdf9e1386 100644 --- a/src/cmd/compile/internal/types2/termlist_test.go +++ b/src/cmd/compile/internal/types2/termlist_test.go @@ -106,7 +106,7 @@ func TestTermlistNorm(t *testing.T) { } } -func TestTermlistStructuralType(t *testing.T) { +func TestTermlistSingleType(t *testing.T) { // helper to deal with nil types tstring := func(typ Type) string { if typ == nil { @@ -128,9 +128,9 @@ func TestTermlistStructuralType(t *testing.T) { "∅ ∪ ~int ∪ string": "nil", } { xl := maketl(test) - got := tstring(xl.structuralType()) + got := tstring(xl.singleType()) if got != want { - t.Errorf("(%v).structuralType() == %v; want %v", test, got, want) + t.Errorf("(%v).singleType() == %v; want %v", test, got, want) } } } diff --git a/src/cmd/compile/internal/types2/testdata/examples/inference.go2 b/src/cmd/compile/internal/types2/testdata/examples/inference.go2 index e169aec746..4eb18eb239 100644 --- a/src/cmd/compile/internal/types2/testdata/examples/inference.go2 +++ b/src/cmd/compile/internal/types2/testdata/examples/inference.go2 @@ -99,3 +99,26 @@ func _() { related2(1.0, []int{}) related2( /* ERROR does not satisfy */ float64(1.0), []int{}) // TODO(gri) fix error position } + +type List[P any] []P + +func related3[Elem any, Slice []Elem | List[Elem]]() Slice { return nil } + +func _() { + // related3 can be instantiated explicitly + related3[int, []int]() + related3[byte, List[byte]]() + + // Alternatively, the 2nd type argument can be inferred + // from the first one through constraint type inference. + related3[int]() + + // The inferred type is the structural type of the Slice + // type parameter. + var _ []int = related3[int]() + + // It is not the defined parameterized type List. + type anotherList []float32 + var _ anotherList = related3[float32]() // valid + var _ anotherList = related3 /* ERROR cannot use .* \(value of type List\[float32\]\) as anotherList */ [float32, List[float32]]() +} diff --git a/src/cmd/compile/internal/types2/typeparam.go b/src/cmd/compile/internal/types2/typeparam.go index 75e2fe8f0e..099bc429c3 100644 --- a/src/cmd/compile/internal/types2/typeparam.go +++ b/src/cmd/compile/internal/types2/typeparam.go @@ -114,9 +114,9 @@ func (t *TypeParam) iface() *Interface { return ityp } -// structuralType returns the structural type of the type parameter's constraint; or nil. -func (t *TypeParam) structuralType() Type { - return t.iface().typeSet().structuralType() +// singleType returns the single type of the type parameter constraint; or nil. +func (t *TypeParam) singleType() Type { + return t.iface().typeSet().singleType() } // hasTerms reports whether the type parameter constraint has specific type terms. diff --git a/src/cmd/compile/internal/types2/typeset.go b/src/cmd/compile/internal/types2/typeset.go index c99d02744b..445a62f9e0 100644 --- a/src/cmd/compile/internal/types2/typeset.go +++ b/src/cmd/compile/internal/types2/typeset.go @@ -104,8 +104,8 @@ func (s *_TypeSet) String() string { // hasTerms reports whether the type set has specific type terms. func (s *_TypeSet) hasTerms() bool { return !s.terms.isEmpty() && !s.terms.isAll() } -// structuralType returns the single type in s if there is exactly one; otherwise the result is nil. -func (s *_TypeSet) structuralType() Type { return s.terms.structuralType() } +// singleType returns the single type in s if there is exactly one; otherwise the result is nil. +func (s *_TypeSet) singleType() Type { return s.terms.singleType() } // includes reports whether t ∈ s. func (s *_TypeSet) includes(t Type) bool { return s.terms.includes(t) } From 30a82efcf403fed76bf1542e9477047660d5f54d Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Fri, 24 Sep 2021 16:46:05 -0400 Subject: [PATCH 193/406] cmd/compile, runtime: track argument stack slot liveness Currently, for stack traces (e.g. at panic or when runtime.Stack is called), we print argument values from the stack. With register ABI, we may never store the argument to stack therefore the argument value on stack may be meaningless. This causes confusion. This CL makes the compiler keep trace of which argument stack slots are meaningful. If it is meaningful, it will be printed in stack traces as before. If it may not be meaningful, it will be printed as the stack value with a question mark ("?"). In general, the value could be meaningful on some code paths but not others depending on the execution, and the compiler couldn't know statically, so we still print the stack value, instead of not printing it at all. Also note that if the argument variable is updated in the function body the printed value may be stale (like before register ABI) but still considered meaningful. Arguments passed on stack are always meaningful therefore always printed without a question mark. Results are never printed, as before. (Due to a bug in the compiler we sometimes don't spill args into their dedicated spill slots (as we should), causing it having fewer meaningful values than it should be.) This increases binary sizes a bit: old new hello 1129760 1142080 +1.09% cmd/go 13932320 14088016 +1.12% cmd/link 6267696 6329168 +0.98% Fixes #45728. Change-Id: I308a0402e5c5ab94ca0953f8bd85a56acd28f58c Reviewed-on: https://go-review.googlesource.com/c/go/+/352057 Trust: Cherry Mui Reviewed-by: Michael Knyszek --- src/cmd/compile/internal/bitvec/bv.go | 11 + src/cmd/compile/internal/gc/obj.go | 7 +- src/cmd/compile/internal/liveness/arg.go | 339 +++++++++++++++++++++ src/cmd/compile/internal/liveness/bvset.go | 11 +- src/cmd/compile/internal/liveness/plive.go | 5 +- src/cmd/compile/internal/ssa/op.go | 4 + src/cmd/compile/internal/ssagen/ssa.go | 17 ++ src/cmd/internal/obj/link.go | 1 + src/cmd/internal/obj/objfile.go | 4 +- src/cmd/internal/objabi/funcdata.go | 2 + src/cmd/link/internal/ld/symtab.go | 1 + src/runtime/funcdata.h | 2 + src/runtime/symtab.go | 2 + src/runtime/traceback.go | 33 +- src/runtime/traceback_test.go | 113 +++++++ 15 files changed, 538 insertions(+), 14 deletions(-) create mode 100644 src/cmd/compile/internal/liveness/arg.go diff --git a/src/cmd/compile/internal/bitvec/bv.go b/src/cmd/compile/internal/bitvec/bv.go index bcac1fe351..ad7ed0a196 100644 --- a/src/cmd/compile/internal/bitvec/bv.go +++ b/src/cmd/compile/internal/bitvec/bv.go @@ -128,10 +128,21 @@ func (bv BitVec) IsEmpty() bool { return true } +func (bv BitVec) Count() int { + n := 0 + for _, x := range bv.B { + n += bits.OnesCount32(x) + } + return n +} + func (bv BitVec) Not() { for i, x := range bv.B { bv.B[i] = ^x } + if bv.N%wordBits != 0 { + bv.B[len(bv.B)-1] &= 1< 0xff { + // We only print a limited number of args, with stack + // offsets no larger than 255. + continue + } + lv.args = append(lv.args, nameOff{n, off}) + } + } + if len(lv.args) > 10 { + lv.args = lv.args[:10] // We print no more than 10 args. + } + + // We spill address-taken or non-SSA-able value upfront, so they are always live. + alwaysLive := func(n *ir.Name) bool { return n.Addrtaken() || !f.Frontend().CanSSA(n.Type()) } + + // We'll emit the smallest offset for the slots that need liveness info. + // No need to include a slot with a lower offset if it is always live. + for len(lv.args) > 0 && alwaysLive(lv.args[0].n) { + lv.args = lv.args[1:] + } + if len(lv.args) == 0 { + return // everything is always live + } + + for i, a := range lv.args { + lv.idx[a] = int32(i) + } + + nargs := int32(len(lv.args)) + bulk := bitvec.NewBulk(nargs, int32(len(f.Blocks)*2)) + for _, b := range f.Blocks { + be := &lv.be[b.ID] + be.livein = bulk.Next() + be.liveout = bulk.Next() + + // initialize to all 1s, so we can AND them + be.livein.Not() + be.liveout.Not() + } + + entrybe := &lv.be[f.Entry.ID] + entrybe.livein.Clear() + for i, a := range lv.args { + if alwaysLive(a.n) { + entrybe.livein.Set(int32(i)) + } + } + + // Visit blocks in reverse-postorder, compute block effects. + po := f.Postorder() + for i := len(po) - 1; i >= 0; i-- { + b := po[i] + be := &lv.be[b.ID] + + // A slot is live at block entry if it is live in all predecessors. + for _, pred := range b.Preds { + pb := pred.Block() + be.livein.And(be.livein, lv.be[pb.ID].liveout) + } + + be.liveout.Copy(be.livein) + for _, v := range b.Values { + lv.valueEffect(v, be.liveout) + } + } + + // Coalesce identical live vectors. Compute liveness indices at each PC + // where it changes. + live := bitvec.New(nargs) + addToSet := func(bv bitvec.BitVec) (int, bool) { + if bv.Count() == int(nargs) { // special case for all live + return allLiveIdx, false + } + return lv.bvset.add(bv) + } + for _, b := range lv.f.Blocks { + be := &lv.be[b.ID] + lv.blockIdx[b.ID], _ = addToSet(be.livein) + + live.Copy(be.livein) + var lastv *ssa.Value + for i, v := range b.Values { + if lv.valueEffect(v, live) { + // Record that liveness changes but not emit a map now. + // For a sequence of StoreRegs we only need to emit one + // at last. + lastv = v + } + if lastv != nil && (mayFault(v) || i == len(b.Values)-1) { + // Emit the liveness map if it may fault or at the end of + // the block. We may need a traceback if the instruction + // may cause a panic. + var added bool + lv.valueIdx[lastv.ID], added = addToSet(live) + if added { + // live is added to bvset and we cannot modify it now. + // Make a copy. + t := live + live = bitvec.New(nargs) + live.Copy(t) + } + lastv = nil + } + } + + // Sanity check. + if !live.Eq(be.liveout) { + panic("wrong arg liveness map at block end") + } + } + + // Emit funcdata symbol, update indices to offsets in the symbol data. + lsym := lv.emit() + fn.LSym.Func().ArgLiveInfo = lsym + + //lv.print() + + p := pp.Prog(obj.AFUNCDATA) + p.From.SetConst(objabi.FUNCDATA_ArgLiveInfo) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = lsym + + return lv.blockIdx, lv.valueIdx +} + +// valueEffect applies the effect of v to live, return whether it is changed. +func (lv *argLiveness) valueEffect(v *ssa.Value, live bitvec.BitVec) bool { + if v.Op != ssa.OpStoreReg { // TODO: include other store instructions? + return false + } + n, off := ssa.AutoVar(v) + if n.Class != ir.PPARAM { + return false + } + i, ok := lv.idx[nameOff{n, off}] + if !ok || live.Get(i) { + return false + } + live.Set(i) + return true +} + +func mayFault(v *ssa.Value) bool { + switch v.Op { + case ssa.OpLoadReg, ssa.OpStoreReg, ssa.OpCopy, ssa.OpPhi, + ssa.OpVarDef, ssa.OpVarKill, ssa.OpVarLive, ssa.OpKeepAlive, + ssa.OpSelect0, ssa.OpSelect1, ssa.OpSelectN, ssa.OpMakeResult, + ssa.OpConvert, ssa.OpInlMark, ssa.OpGetG: + return false + } + if len(v.Args) == 0 { + return false // assume constant op cannot fault + } + return true // conservatively assume all other ops could fault +} + +func (lv *argLiveness) print() { + fmt.Println("argument liveness:", lv.f.Name) + live := bitvec.New(int32(len(lv.args))) + for _, b := range lv.f.Blocks { + be := &lv.be[b.ID] + + fmt.Printf("%v: live in: ", b) + lv.printLivenessVec(be.livein) + if idx, ok := lv.blockIdx[b.ID]; ok { + fmt.Printf(" #%d", idx) + } + fmt.Println() + + for _, v := range b.Values { + if lv.valueEffect(v, live) { + fmt.Printf(" %v: ", v) + lv.printLivenessVec(live) + if idx, ok := lv.valueIdx[v.ID]; ok { + fmt.Printf(" #%d", idx) + } + fmt.Println() + } + } + + fmt.Printf("%v: live out: ", b) + lv.printLivenessVec(be.liveout) + fmt.Println() + } + fmt.Println("liveness maps data:", lv.fn.LSym.Func().ArgLiveInfo.P) +} + +func (lv *argLiveness) printLivenessVec(bv bitvec.BitVec) { + for i, a := range lv.args { + if bv.Get(int32(i)) { + fmt.Printf("%v ", a) + } + } +} + +func (lv *argLiveness) emit() *obj.LSym { + livenessMaps := lv.bvset.extractUnique() + + // stack offsets of register arg spill slots + argOffsets := make([]uint8, len(lv.args)) + for i, a := range lv.args { + off := a.FrameOffset() + if off > 0xff { + panic("offset too large") + } + argOffsets[i] = uint8(off) + } + + idx2off := make([]int, len(livenessMaps)) + + lsym := base.Ctxt.Lookup(lv.fn.LSym.Name + ".argliveinfo") + lsym.Set(obj.AttrContentAddressable, true) + + off := objw.Uint8(lsym, 0, argOffsets[0]) // smallest offset that needs liveness info. + for idx, live := range livenessMaps { + idx2off[idx] = off + off = objw.BitVec(lsym, off, live) + } + + // Update liveness indices to offsets. + for i, x := range lv.blockIdx { + if x != allLiveIdx { + lv.blockIdx[i] = idx2off[x] + } + } + for i, x := range lv.valueIdx { + if x != allLiveIdx { + lv.valueIdx[i] = idx2off[x] + } + } + + return lsym +} diff --git a/src/cmd/compile/internal/liveness/bvset.go b/src/cmd/compile/internal/liveness/bvset.go index 3431f54ede..60b2593867 100644 --- a/src/cmd/compile/internal/liveness/bvset.go +++ b/src/cmd/compile/internal/liveness/bvset.go @@ -47,9 +47,10 @@ func (m *bvecSet) grow() { m.index = newIndex } -// add adds bv to the set and returns its index in m.extractUnique. -// The caller must not modify bv after this. -func (m *bvecSet) add(bv bitvec.BitVec) int { +// add adds bv to the set and returns its index in m.extractUnique, +// and whether it is newly added. +// If it is newly added, the caller must not modify bv after this. +func (m *bvecSet) add(bv bitvec.BitVec) (int, bool) { if len(m.uniq)*4 >= len(m.index) { m.grow() } @@ -62,12 +63,12 @@ func (m *bvecSet) add(bv bitvec.BitVec) int { // New bvec. index[h] = len(m.uniq) m.uniq = append(m.uniq, bv) - return len(m.uniq) - 1 + return len(m.uniq) - 1, true } jlive := m.uniq[j] if bv.Eq(jlive) { // Existing bvec. - return j + return j, false } h++ diff --git a/src/cmd/compile/internal/liveness/plive.go b/src/cmd/compile/internal/liveness/plive.go index 56580d11b5..3202e506c8 100644 --- a/src/cmd/compile/internal/liveness/plive.go +++ b/src/cmd/compile/internal/liveness/plive.go @@ -854,8 +854,9 @@ func (lv *liveness) epilogue() { if lv.fn.OpenCodedDeferDisallowed() { lv.livenessMap.DeferReturn = objw.LivenessDontCare } else { + idx, _ := lv.stackMapSet.add(livedefer) lv.livenessMap.DeferReturn = objw.LivenessIndex{ - StackMapIndex: lv.stackMapSet.add(livedefer), + StackMapIndex: idx, IsUnsafePoint: false, } } @@ -902,7 +903,7 @@ func (lv *liveness) compact(b *ssa.Block) { isUnsafePoint := lv.allUnsafe || v.Op != ssa.OpClobber && lv.unsafePoints.Get(int32(v.ID)) idx := objw.LivenessIndex{StackMapIndex: objw.StackMapDontCare, IsUnsafePoint: isUnsafePoint} if hasStackMap { - idx.StackMapIndex = lv.stackMapSet.add(lv.livevars[pos]) + idx.StackMapIndex, _ = lv.stackMapSet.add(lv.livevars[pos]) pos++ } if hasStackMap || isUnsafePoint { diff --git a/src/cmd/compile/internal/ssa/op.go b/src/cmd/compile/internal/ssa/op.go index 421d856a4f..a1835dcd30 100644 --- a/src/cmd/compile/internal/ssa/op.go +++ b/src/cmd/compile/internal/ssa/op.go @@ -103,6 +103,10 @@ func (a *AuxNameOffset) String() string { return fmt.Sprintf("%s+%d", a.Name.Sym().Name, a.Offset) } +func (a *AuxNameOffset) FrameOffset() int64 { + return a.Name.FrameOffset() + a.Offset +} + type AuxCall struct { Fn *obj.LSym reg *regInfo // regInfo for this call diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go index 6b595ea75d..b84199790f 100644 --- a/src/cmd/compile/internal/ssagen/ssa.go +++ b/src/cmd/compile/internal/ssagen/ssa.go @@ -6729,6 +6729,7 @@ func genssa(f *ssa.Func, pp *objw.Progs) { s.livenessMap, s.partLiveArgs = liveness.Compute(e.curfn, f, e.stkptrsize, pp) emitArgInfo(e, f, pp) + argLiveBlockMap, argLiveValueMap := liveness.ArgLiveness(e.curfn, f, pp) openDeferInfo := e.curfn.LSym.Func().OpenCodedDeferInfo if openDeferInfo != nil { @@ -6786,6 +6787,8 @@ func genssa(f *ssa.Func, pp *objw.Progs) { // Progs that are in the set above and have that source position. var inlMarksByPos map[src.XPos][]*obj.Prog + var argLiveIdx int = -1 // argument liveness info index + // Emit basic blocks for i, b := range f.Blocks { s.bstart[b.ID] = s.pp.Next @@ -6799,6 +6802,13 @@ func genssa(f *ssa.Func, pp *objw.Progs) { // preemptible, unless this function is "all unsafe". s.pp.NextLive = objw.LivenessIndex{StackMapIndex: -1, IsUnsafePoint: liveness.IsUnsafe(f)} + if idx, ok := argLiveBlockMap[b.ID]; ok && idx != argLiveIdx { + argLiveIdx = idx + p := s.pp.Prog(obj.APCDATA) + p.From.SetConst(objabi.PCDATA_ArgLiveIndex) + p.To.SetConst(int64(idx)) + } + // Emit values in block Arch.SSAMarkMoves(&s, b) for _, v := range b.Values { @@ -6855,6 +6865,13 @@ func genssa(f *ssa.Func, pp *objw.Progs) { Arch.SSAGenValue(&s, v) } + if idx, ok := argLiveValueMap[v.ID]; ok && idx != argLiveIdx { + argLiveIdx = idx + p := s.pp.Prog(obj.APCDATA) + p.From.SetConst(objabi.PCDATA_ArgLiveIndex) + p.To.SetConst(int64(idx)) + } + if base.Ctxt.Flag_locationlists { valueToProgAfter[v.ID] = s.pp.Next } diff --git a/src/cmd/internal/obj/link.go b/src/cmd/internal/obj/link.go index abb37416cc..4bcfb05a5e 100644 --- a/src/cmd/internal/obj/link.go +++ b/src/cmd/internal/obj/link.go @@ -486,6 +486,7 @@ type FuncInfo struct { StackObjects *LSym OpenCodedDeferInfo *LSym ArgInfo *LSym // argument info for traceback + ArgLiveInfo *LSym // argument liveness info for traceback FuncInfoSym *LSym } diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go index a590549f52..fa616691eb 100644 --- a/src/cmd/internal/obj/objfile.go +++ b/src/cmd/internal/obj/objfile.go @@ -347,7 +347,8 @@ func (w *writer) Sym(s *LSym) { strings.HasPrefix(name, "runtime.gcbits."), strings.HasSuffix(name, ".opendefer"), strings.HasSuffix(name, ".arginfo0"), - strings.HasSuffix(name, ".arginfo1"): + strings.HasSuffix(name, ".arginfo1"), + strings.HasSuffix(name, ".argliveinfo"): // These are just bytes, or varints. align = 1 case strings.HasPrefix(name, "gclocals·"): @@ -415,6 +416,7 @@ func contentHashSection(s *LSym) byte { strings.HasSuffix(name, ".opendefer") || strings.HasSuffix(name, ".arginfo0") || strings.HasSuffix(name, ".arginfo1") || + strings.HasSuffix(name, ".argliveinfo") || strings.HasSuffix(name, ".args_stackmap") || strings.HasSuffix(name, ".stkobj") { return 'F' // go.func.* or go.funcrel.* diff --git a/src/cmd/internal/objabi/funcdata.go b/src/cmd/internal/objabi/funcdata.go index 4ff0ebe13d..4d49a8d548 100644 --- a/src/cmd/internal/objabi/funcdata.go +++ b/src/cmd/internal/objabi/funcdata.go @@ -14,6 +14,7 @@ const ( PCDATA_UnsafePoint = 0 PCDATA_StackMapIndex = 1 PCDATA_InlTreeIndex = 2 + PCDATA_ArgLiveIndex = 3 FUNCDATA_ArgsPointerMaps = 0 FUNCDATA_LocalsPointerMaps = 1 @@ -21,6 +22,7 @@ const ( FUNCDATA_InlTree = 3 FUNCDATA_OpenCodedDeferInfo = 4 FUNCDATA_ArgInfo = 5 + FUNCDATA_ArgLiveInfo = 6 // ArgsSizeUnknown is set in Func.argsize to mark all functions // whose argument size is unknown (C vararg functions, and diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index 7b1a0b7d1a..720c03afd2 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -566,6 +566,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind { strings.HasSuffix(name, ".opendefer"), strings.HasSuffix(name, ".arginfo0"), strings.HasSuffix(name, ".arginfo1"), + strings.HasSuffix(name, ".argliveinfo"), strings.HasSuffix(name, ".args_stackmap"), strings.HasSuffix(name, ".stkobj"): ldr.SetAttrNotInSymbolTable(s, true) diff --git a/src/runtime/funcdata.h b/src/runtime/funcdata.h index 15f1b5c9a1..a454dcaa69 100644 --- a/src/runtime/funcdata.h +++ b/src/runtime/funcdata.h @@ -11,6 +11,7 @@ #define PCDATA_UnsafePoint 0 #define PCDATA_StackMapIndex 1 #define PCDATA_InlTreeIndex 2 +#define PCDATA_ArgLiveIndex 3 #define FUNCDATA_ArgsPointerMaps 0 /* garbage collector blocks */ #define FUNCDATA_LocalsPointerMaps 1 @@ -18,6 +19,7 @@ #define FUNCDATA_InlTree 3 #define FUNCDATA_OpenCodedDeferInfo 4 /* info for func with open-coded defers */ #define FUNCDATA_ArgInfo 5 +#define FUNCDATA_ArgLiveInfo 6 // Pseudo-assembly statements. diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index ced39026c9..41161d6f90 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -301,6 +301,7 @@ const ( _PCDATA_UnsafePoint = 0 _PCDATA_StackMapIndex = 1 _PCDATA_InlTreeIndex = 2 + _PCDATA_ArgLiveIndex = 3 _FUNCDATA_ArgsPointerMaps = 0 _FUNCDATA_LocalsPointerMaps = 1 @@ -308,6 +309,7 @@ const ( _FUNCDATA_InlTree = 3 _FUNCDATA_OpenCodedDeferInfo = 4 _FUNCDATA_ArgInfo = 5 + _FUNCDATA_ArgLiveInfo = 6 _ArgsSizeUnknown = -0x80000000 ) diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 7e1b14ccf2..5de1abce9a 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -427,7 +427,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in } print(name, "(") argp := unsafe.Pointer(frame.argp) - printArgs(f, argp) + printArgs(f, argp, tracepc) print(")\n") print("\t", file, ":", line) if frame.pc > f.entry() { @@ -540,7 +540,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in } // printArgs prints function arguments in traceback. -func printArgs(f funcInfo, argp unsafe.Pointer) { +func printArgs(f funcInfo, argp unsafe.Pointer, pc uintptr) { // The "instruction" of argument printing is encoded in _FUNCDATA_ArgInfo. // See cmd/compile/internal/ssagen.emitArgInfo for the description of the // encoding. @@ -564,7 +564,25 @@ func printArgs(f funcInfo, argp unsafe.Pointer) { return } - print1 := func(off, sz uint8) { + liveInfo := funcdata(f, _FUNCDATA_ArgLiveInfo) + liveIdx := pcdatavalue(f, _PCDATA_ArgLiveIndex, pc, nil) + startOffset := uint8(0xff) // smallest offset that needs liveness info (slots with a lower offset is always live) + if liveInfo != nil { + startOffset = *(*uint8)(liveInfo) + } + + isLive := func(off, slotIdx uint8) bool { + if liveInfo == nil || liveIdx <= 0 { + return true // no liveness info, always live + } + if off < startOffset { + return true + } + bits := *(*uint8)(add(liveInfo, uintptr(liveIdx)+uintptr(slotIdx/8))) + return bits&(1<<(slotIdx%8)) != 0 + } + + print1 := func(off, sz, slotIdx uint8) { x := readUnaligned64(add(argp, uintptr(off))) // mask out irrelevant bits if sz < 8 { @@ -576,6 +594,9 @@ func printArgs(f funcInfo, argp unsafe.Pointer) { } } print(hex(x)) + if !isLive(off, slotIdx) { + print("?") + } } start := true @@ -585,6 +606,7 @@ func printArgs(f funcInfo, argp unsafe.Pointer) { } } pi := 0 + slotIdx := uint8(0) // register arg spill slot index printloop: for { o := p[pi] @@ -609,7 +631,10 @@ printloop: printcomma() sz := p[pi] pi++ - print1(o, sz) + print1(o, sz, slotIdx) + if o >= startOffset { + slotIdx++ + } } start = false } diff --git a/src/runtime/traceback_test.go b/src/runtime/traceback_test.go index 83b86a7e90..de9580ae53 100644 --- a/src/runtime/traceback_test.go +++ b/src/runtime/traceback_test.go @@ -6,6 +6,7 @@ package runtime_test import ( "bytes" + "internal/goexperiment" "runtime" "testing" ) @@ -13,6 +14,13 @@ import ( var testTracebackArgsBuf [1000]byte func TestTracebackArgs(t *testing.T) { + abiSel := func(x, y string) string { // select expected output based on ABI + if goexperiment.RegabiArgs { + return x + } + return y + } + tests := []struct { fn func() int expect string @@ -105,6 +113,52 @@ func TestTracebackArgs(t *testing.T) { func() int { return testTracebackArgs8d(testArgsType8d{1, 2, 3, 4, 5, 6, 7, 8, [3]int{9, 10, 11}, 12}) }, "testTracebackArgs8d({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, {0x9, 0xa, ...}, ...})", }, + + // Register argument liveness. + // 1, 3 are used and live, 2, 4 are dead (in register ABI). + // Address-taken (7) and stack ({5, 6}) args are always live. + { + func() int { + poisonStack() // poison arg area to make output deterministic + return testTracebackArgs9(1, 2, 3, 4, [2]int{5, 6}, 7) + }, + abiSel( + "testTracebackArgs9(0x1, 0xffffffff?, 0x3, 0xff?, {0x5, 0x6}, 0x7)", + "testTracebackArgs9(0x1, 0x2, 0x3, 0x4, {0x5, 0x6}, 0x7)"), + }, + // No live. + // (Note: this assume at least 5 int registers if register ABI is used.) + { + func() int { + poisonStack() // poison arg area to make output deterministic + return testTracebackArgs10(1, 2, 3, 4, 5) + }, + abiSel( + "testTracebackArgs10(0xffffffff?, 0xffffffff?, 0xffffffff?, 0xffffffff?, 0xffffffff?)", + "testTracebackArgs10(0x1, 0x2, 0x3, 0x4, 0x5)"), + }, + // Conditional spills. + // Spill in conditional, not executed. + { + func() int { + poisonStack() // poison arg area to make output deterministic + return testTracebackArgs11a(1, 2, 3) + }, + abiSel( + "testTracebackArgs11a(0xffffffff?, 0xffffffff?, 0xffffffff?)", + "testTracebackArgs11a(0x1, 0x2, 0x3)"), + }, + // 2 spills in conditional, not executed; 3 spills in conditional, executed, but not statically known. + // So print 0x3?. + { + func() int { + poisonStack() // poison arg area to make output deterministic + return testTracebackArgs11b(1, 2, 3, 4) + }, + abiSel( + "testTracebackArgs11b(0xffffffff?, 0xffffffff?, 0x3?, 0x4)", + "testTracebackArgs11b(0x1, 0x2, 0x3, 0x4)"), + }, } for _, test := range tests { n := test.fn() @@ -290,3 +344,62 @@ func testTracebackArgs8d(a testArgsType8d) int { } return n } + +//go:noinline +func testTracebackArgs9(a int64, b int32, c int16, d int8, x [2]int, y int) int { + if a < 0 { + println(&y) // take address, make y live, even if no longer used at traceback + } + n := runtime.Stack(testTracebackArgsBuf[:], false) + if a < 0 { + // use half of in-reg args to keep them alive, the other half are dead + return int(a) + int(c) + } + return n +} + +//go:noinline +func testTracebackArgs10(a, b, c, d, e int32) int { + // no use of any args + return runtime.Stack(testTracebackArgsBuf[:], false) +} + +// norace to avoid race instrumentation changing spill locations. +// +//go:norace +//go:noinline +func testTracebackArgs11a(a, b, c int32) int { + if a < 0 { + println(a, b, c) // spill in a conditional, may not execute + } + if b < 0 { + return int(a + b + c) + } + return runtime.Stack(testTracebackArgsBuf[:], false) +} + +// norace to avoid race instrumentation changing spill locations. +// +//go:norace +//go:noinline +func testTracebackArgs11b(a, b, c, d int32) int { + var x int32 + if a < 0 { + print() // spill b in a conditional + x = b + } else { + print() // spill c in a conditional + x = c + } + if d < 0 { // d is always needed + return int(x + d) + } + return runtime.Stack(testTracebackArgsBuf[:], false) +} + +// Poison the arg area with deterministic values. +// +//go:noinline +func poisonStack() [20]int { + return [20]int{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1} +} From 51be206114b559f7ea26fe2290f8ed274a2080c3 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Thu, 28 Oct 2021 01:55:10 +0700 Subject: [PATCH 194/406] runtime/testdata/testprogcgo: fix TestCgoPanicCallback A cgo file with "//export" declarations is not permitted to have function definitions in the cgo comments. Fixes #49188 Change-Id: I5c24b62b259871473ee984cea96a0edd7d42d23a Reviewed-on: https://go-review.googlesource.com/c/go/+/359195 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/runtime/testdata/testprogcgo/panic.c | 9 +++++++++ src/runtime/testdata/testprogcgo/panic.go | 8 +------- 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 src/runtime/testdata/testprogcgo/panic.c diff --git a/src/runtime/testdata/testprogcgo/panic.c b/src/runtime/testdata/testprogcgo/panic.c new file mode 100644 index 0000000000..deb5ed5a60 --- /dev/null +++ b/src/runtime/testdata/testprogcgo/panic.c @@ -0,0 +1,9 @@ +// Copyright 2021 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. + +extern void panic_callback(); + +void call_callback(void) { + panic_callback(); +} diff --git a/src/runtime/testdata/testprogcgo/panic.go b/src/runtime/testdata/testprogcgo/panic.go index 4ddef3abcd..57ac89540e 100644 --- a/src/runtime/testdata/testprogcgo/panic.go +++ b/src/runtime/testdata/testprogcgo/panic.go @@ -1,16 +1,10 @@ package main -import "C" - // This program will crash. // We want to test unwinding from a cgo callback. /* -void panic_callback(); - -static void call_callback(void) { - panic_callback(); -} +void call_callback(void); */ import "C" From 4fefd439a4087ec4a4cb7a61cfe15801115321d2 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Fri, 22 Oct 2021 12:36:00 +1100 Subject: [PATCH 195/406] cmd/go: fix recognition of Fossil checkout directories Use ".fslckout" or "_FOSSIL_" files to correctly identify the root of Fossil checkout directories. Previously, Go has assumed VCS checkouts are indicated by a dot-file named after the VCS command (eg, .git, .hg, .fossil). This is not normally true for Fossil, but has worked so far since Go downloads repositories into a ".fossil" file before opening (checking out). Using the incorrect path prevents Go identifying Fossil checkouts and correctly tagging with -buildvcs (to be added in a follow up CL). Change-Id: I3c030a0b600dfe7f4b3fcf1551b1d7cb84629b81 Reviewed-on: https://go-review.googlesource.com/c/go/+/357954 Trust: Ian Lance Taylor Reviewed-by: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot --- src/cmd/go/internal/vcs/vcs.go | 53 +++++++++++++++++++++-------- src/cmd/go/internal/vcs/vcs_test.go | 52 +++++++++++++++------------- 2 files changed, 67 insertions(+), 38 deletions(-) diff --git a/src/cmd/go/internal/vcs/vcs.go b/src/cmd/go/internal/vcs/vcs.go index c4853d7ae3..990e1d4248 100644 --- a/src/cmd/go/internal/vcs/vcs.go +++ b/src/cmd/go/internal/vcs/vcs.go @@ -35,8 +35,9 @@ import ( // A Cmd describes how to use a version control system // like Mercurial, Git, or Subversion. type Cmd struct { - Name string - Cmd string // name of binary to invoke command + Name string + Cmd string // name of binary to invoke command + RootNames []string // filename indicating the root of a checkout directory CreateCmd []string // commands to download a fresh copy of a repository DownloadCmd []string // commands to download updates into an existing repository @@ -129,8 +130,9 @@ func vcsByCmd(cmd string) *Cmd { // vcsHg describes how to use Mercurial. var vcsHg = &Cmd{ - Name: "Mercurial", - Cmd: "hg", + Name: "Mercurial", + Cmd: "hg", + RootNames: []string{".hg"}, CreateCmd: []string{"clone -U -- {repo} {dir}"}, DownloadCmd: []string{"pull"}, @@ -212,8 +214,9 @@ func parseRevTime(out []byte) (string, time.Time, error) { // vcsGit describes how to use Git. var vcsGit = &Cmd{ - Name: "Git", - Cmd: "git", + Name: "Git", + Cmd: "git", + RootNames: []string{".git"}, CreateCmd: []string{"clone -- {repo} {dir}", "-go-internal-cd {dir} submodule update --init --recursive"}, DownloadCmd: []string{"pull --ff-only", "submodule update --init --recursive"}, @@ -325,8 +328,9 @@ func gitStatus(vcsGit *Cmd, rootDir string) (Status, error) { // vcsBzr describes how to use Bazaar. var vcsBzr = &Cmd{ - Name: "Bazaar", - Cmd: "bzr", + Name: "Bazaar", + Cmd: "bzr", + RootNames: []string{".bzr"}, CreateCmd: []string{"branch -- {repo} {dir}"}, @@ -387,8 +391,9 @@ func bzrResolveRepo(vcsBzr *Cmd, rootDir, remoteRepo string) (realRepo string, e // vcsSvn describes how to use Subversion. var vcsSvn = &Cmd{ - Name: "Subversion", - Cmd: "svn", + Name: "Subversion", + Cmd: "svn", + RootNames: []string{".svn"}, CreateCmd: []string{"checkout -- {repo} {dir}"}, DownloadCmd: []string{"update"}, @@ -437,8 +442,9 @@ const fossilRepoName = ".fossil" // vcsFossil describes how to use Fossil (fossil-scm.org) var vcsFossil = &Cmd{ - Name: "Fossil", - Cmd: "fossil", + Name: "Fossil", + Cmd: "fossil", + RootNames: []string{".fslckout", "_FOSSIL_"}, CreateCmd: []string{"-go-internal-mkdir {dir} clone -- {repo} " + filepath.Join("{dir}", fossilRepoName), "-go-internal-cd {dir} open .fossil"}, DownloadCmd: []string{"up"}, @@ -662,7 +668,7 @@ func FromDir(dir, srcRoot string, allowNesting bool) (repoDir string, vcsCmd *Cm origDir := dir for len(dir) > len(srcRoot) { for _, vcs := range vcsList { - if _, err := os.Stat(filepath.Join(dir, "."+vcs.Cmd)); err == nil { + if _, err := statAny(dir, vcs.RootNames); err == nil { // Record first VCS we find. // If allowNesting is false (as it is in GOPATH), keep looking for // repositories in parent directories and report an error if one is @@ -698,6 +704,25 @@ func FromDir(dir, srcRoot string, allowNesting bool) (repoDir string, vcsCmd *Cm return repoDir, vcsCmd, nil } +// statAny provides FileInfo for the first filename found in the directory. +// Otherwise, it returns the last error seen. +func statAny(dir string, filenames []string) (os.FileInfo, error) { + if len(filenames) == 0 { + return nil, errors.New("invalid argument: no filenames provided") + } + + var err error + var fi os.FileInfo + for _, name := range filenames { + fi, err = os.Stat(filepath.Join(dir, name)) + if err == nil { + return fi, nil + } + } + + return nil, err +} + type vcsNotFoundError struct { dir string } @@ -855,7 +880,7 @@ func CheckNested(vcs *Cmd, dir, srcRoot string) error { otherDir := dir for len(otherDir) > len(srcRoot) { for _, otherVCS := range vcsList { - if _, err := os.Stat(filepath.Join(otherDir, "."+otherVCS.Cmd)); err == nil { + if _, err := statAny(otherDir, otherVCS.RootNames); err == nil { // Allow expected vcs in original dir. if otherDir == dir && otherVCS == vcs { continue diff --git a/src/cmd/go/internal/vcs/vcs_test.go b/src/cmd/go/internal/vcs/vcs_test.go index 9ac0a56a07..c4e4f4d3c6 100644 --- a/src/cmd/go/internal/vcs/vcs_test.go +++ b/src/cmd/go/internal/vcs/vcs_test.go @@ -6,6 +6,7 @@ package vcs import ( "errors" + "fmt" "internal/testenv" "os" "path/filepath" @@ -214,32 +215,35 @@ func TestFromDir(t *testing.T) { defer os.RemoveAll(tempDir) for j, vcs := range vcsList { - dir := filepath.Join(tempDir, "example.com", vcs.Name, "."+vcs.Cmd) - if j&1 == 0 { - err := os.MkdirAll(dir, 0755) - if err != nil { - t.Fatal(err) + for r, rootName := range vcs.RootNames { + vcsName := fmt.Sprint(vcs.Name, r) + dir := filepath.Join(tempDir, "example.com", vcsName, rootName) + if j&1 == 0 { + err := os.MkdirAll(dir, 0755) + if err != nil { + t.Fatal(err) + } + } else { + err := os.MkdirAll(filepath.Dir(dir), 0755) + if err != nil { + t.Fatal(err) + } + f, err := os.Create(dir) + if err != nil { + t.Fatal(err) + } + f.Close() } - } else { - err := os.MkdirAll(filepath.Dir(dir), 0755) - if err != nil { - t.Fatal(err) - } - f, err := os.Create(dir) - if err != nil { - t.Fatal(err) - } - f.Close() - } - wantRepoDir := filepath.Dir(dir) - gotRepoDir, gotVCS, err := FromDir(dir, tempDir, false) - if err != nil { - t.Errorf("FromDir(%q, %q): %v", dir, tempDir, err) - continue - } - if gotRepoDir != wantRepoDir || gotVCS.Name != vcs.Name { - t.Errorf("FromDir(%q, %q) = RepoDir(%s), VCS(%s); want RepoDir(%s), VCS(%s)", dir, tempDir, gotRepoDir, gotVCS.Name, wantRepoDir, vcs.Name) + wantRepoDir := filepath.Dir(dir) + gotRepoDir, gotVCS, err := FromDir(dir, tempDir, false) + if err != nil { + t.Errorf("FromDir(%q, %q): %v", dir, tempDir, err) + continue + } + if gotRepoDir != wantRepoDir || gotVCS.Name != vcs.Name { + t.Errorf("FromDir(%q, %q) = RepoDir(%s), VCS(%s); want RepoDir(%s), VCS(%s)", dir, tempDir, gotRepoDir, gotVCS.Name, wantRepoDir, vcs.Name) + } } } } From de1abf76fb69739c6cad463454a55fe9c33f63ac Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Fri, 22 Oct 2021 11:21:28 +1100 Subject: [PATCH 196/406] cmd/go: stamp Fossil VCS status into binaries For #37475 Change-Id: I09fa1344051088ce37727176d9ec6b38891d1a9f Reviewed-on: https://go-review.googlesource.com/c/go/+/357955 Trust: Ian Lance Taylor Trust: Bryan C. Mills Reviewed-by: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot --- src/cmd/go/internal/vcs/vcs.go | 55 ++++++++++++ .../script/version_buildvcs_fossil.txt | 90 +++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 src/cmd/go/testdata/script/version_buildvcs_fossil.txt diff --git a/src/cmd/go/internal/vcs/vcs.go b/src/cmd/go/internal/vcs/vcs.go index 990e1d4248..6d2996e17a 100644 --- a/src/cmd/go/internal/vcs/vcs.go +++ b/src/cmd/go/internal/vcs/vcs.go @@ -455,6 +455,7 @@ var vcsFossil = &Cmd{ Scheme: []string{"https", "http"}, RemoteRepo: fossilRemoteRepo, + Status: fossilStatus, } func fossilRemoteRepo(vcsFossil *Cmd, rootDir string) (remoteRepo string, err error) { @@ -465,6 +466,60 @@ func fossilRemoteRepo(vcsFossil *Cmd, rootDir string) (remoteRepo string, err er return strings.TrimSpace(string(out)), nil } +var errFossilInfo = errors.New("unable to parse output of fossil info") + +func fossilStatus(vcsFossil *Cmd, rootDir string) (Status, error) { + outb, err := vcsFossil.runOutputVerboseOnly(rootDir, "info") + if err != nil { + return Status{}, err + } + out := string(outb) + + // Expect: + // ... + // checkout: 91ed71f22c77be0c3e250920f47bfd4e1f9024d2 2021-09-21 12:00:00 UTC + // ... + + // Extract revision and commit time. + // Ensure line ends with UTC (known timezone offset). + const prefix = "\ncheckout:" + const suffix = " UTC" + i := strings.Index(out, prefix) + if i < 0 { + return Status{}, errFossilInfo + } + checkout := out[i+len(prefix):] + i = strings.Index(checkout, suffix) + if i < 0 { + return Status{}, errFossilInfo + } + checkout = strings.TrimSpace(checkout[:i]) + + i = strings.IndexByte(checkout, ' ') + if i < 0 { + return Status{}, errFossilInfo + } + rev := checkout[:i] + + commitTime, err := time.ParseInLocation("2006-01-02 15:04:05", checkout[i+1:], time.UTC) + if err != nil { + return Status{}, fmt.Errorf("%v: %v", errFossilInfo, err) + } + + // Also look for untracked changes. + outb, err = vcsFossil.runOutputVerboseOnly(rootDir, "changes --differ") + if err != nil { + return Status{}, err + } + uncommitted := len(outb) > 0 + + return Status{ + Revision: rev, + CommitTime: commitTime, + Uncommitted: uncommitted, + }, nil +} + func (v *Cmd) String() string { return v.Name } diff --git a/src/cmd/go/testdata/script/version_buildvcs_fossil.txt b/src/cmd/go/testdata/script/version_buildvcs_fossil.txt new file mode 100644 index 0000000000..3a4bde883f --- /dev/null +++ b/src/cmd/go/testdata/script/version_buildvcs_fossil.txt @@ -0,0 +1,90 @@ +# This test checks that VCS information is stamped into Go binaries by default, +# controlled with -buildvcs. This test focuses on Fossil specifics. +# The Git test covers common functionality. + +# "fossil" is the Fossil file server on Plan 9. +[plan9] skip +[!exec:fossil] skip +[short] skip +env GOBIN=$WORK/gopath/bin +env oldpath=$PATH +env HOME=$WORK +env USER=gopher +[!windows] env fslckout=.fslckout +[windows] env fslckout=_FOSSIL_ +exec pwd +exec fossil init repo.fossil +cd repo/a + +# If there's no local repository, there's no VCS info. +go install +go version -m $GOBIN/a$GOEXE +! stdout fossilrevision +rm $GOBIN/a$GOEXE + +# If there is a repository, but it can't be used for some reason, +# there should be an error. It should hint about -buildvcs=false. +cd .. +mkdir $fslckout +env PATH=$WORK${/}fakebin${:}$oldpath +chmod 0755 $WORK/fakebin/fossil +! exec fossil help +cd a +! go install +stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$' +rm $GOBIN/a$GOEXE +cd .. +env PATH=$oldpath +rm $fslckout + +# Revision and commit time are tagged for repositories with commits. +exec fossil open ../repo.fossil -f +exec fossil add a README +exec fossil commit -m 'initial commit' +cd a +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\tfossilrevision\t' +stdout '^\tbuild\tfossilcommittime\t' +stdout '^\tbuild\tfossiluncommitted\tfalse$' +rm $GOBIN/a$GOEXE + +# Building with -buildvcs=false suppresses the info. +go install -buildvcs=false +go version -m $GOBIN/a$GOEXE +! stdout fossilrevision +rm $GOBIN/a$GOEXE + +# An untracked file is shown as uncommitted, even if it isn't part of the build. +cp ../../outside/empty.txt . +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\tfossiluncommitted\ttrue$' +rm empty.txt +rm $GOBIN/a$GOEXE + +# An edited file is shown as uncommitted, even if it isn't part of the build. +cp ../../outside/empty.txt ../README +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\tfossiluncommitted\ttrue$' +exec fossil revert ../README +rm $GOBIN/a$GOEXE + +-- $WORK/fakebin/fossil -- +#!/bin/sh +exit 1 +-- $WORK/fakebin/fossil.bat -- +exit 1 +-- repo/README -- +Far out in the uncharted backwaters of the unfashionable end of the western +spiral arm of the Galaxy lies a small, unregarded yellow sun. +-- repo/a/go.mod -- +module example.com/a + +go 1.18 +-- repo/a/a.go -- +package main + +func main() {} +-- outside/empty.txt -- From a3c4ac0fbca51fc2e3369c93738419fc947bda77 Mon Sep 17 00:00:00 2001 From: zhouguangyuan Date: Fri, 22 Oct 2021 17:00:46 +0800 Subject: [PATCH 197/406] reflect: skip duplicate check in StructOf when the name of a field is "_" Fixes #49110 Change-Id: I32c2cb26cca067a4a676ce4bbc3e51f1e0cdb259 Reviewed-on: https://go-review.googlesource.com/c/go/+/357959 Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Reviewed-by: Dan Kortschak Reviewed-by: Sebastien Binet Trust: Cuong Manh Le --- src/reflect/type.go | 2 +- test/fixedbugs/issue49110.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/issue49110.go diff --git a/src/reflect/type.go b/src/reflect/type.go index 2bb2438381..0896949d7e 100644 --- a/src/reflect/type.go +++ b/src/reflect/type.go @@ -2606,7 +2606,7 @@ func StructOf(fields []StructField) Type { } } } - if _, dup := fset[name]; dup { + if _, dup := fset[name]; dup && name != "_" { panic("reflect.StructOf: duplicate field " + name) } fset[name] = struct{}{} diff --git a/test/fixedbugs/issue49110.go b/test/fixedbugs/issue49110.go new file mode 100644 index 0000000000..5e1bde9f00 --- /dev/null +++ b/test/fixedbugs/issue49110.go @@ -0,0 +1,16 @@ +// run + +// Copyright 2021 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 main + +import "reflect" + +func main() { + _ = reflect.StructOf([]reflect.StructField{ + {Name: "_", PkgPath: "main", Type: reflect.TypeOf(int(0))}, + {Name: "_", PkgPath: "main", Type: reflect.TypeOf(int(0))}, + }) +} From 063ff7f7a0fb41442916d0eda3fc128ca779d424 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Fri, 22 Oct 2021 18:23:18 +1100 Subject: [PATCH 198/406] cmd/go: stamp Bazaar VCS status into binaries For #37475 Change-Id: I728b7aeee5c38ec337e9a5b073050c3b0afc720d Reviewed-on: https://go-review.googlesource.com/c/go/+/357956 Trust: Ian Lance Taylor Reviewed-by: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot --- src/cmd/go/internal/vcs/vcs.go | 58 ++++++++++ .../testdata/script/version_buildvcs_bzr.txt | 104 ++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 src/cmd/go/testdata/script/version_buildvcs_bzr.txt diff --git a/src/cmd/go/internal/vcs/vcs.go b/src/cmd/go/internal/vcs/vcs.go index 6d2996e17a..b2ce80325a 100644 --- a/src/cmd/go/internal/vcs/vcs.go +++ b/src/cmd/go/internal/vcs/vcs.go @@ -346,6 +346,7 @@ var vcsBzr = &Cmd{ PingCmd: "info -- {scheme}://{repo}", RemoteRepo: bzrRemoteRepo, ResolveRepo: bzrResolveRepo, + Status: bzrStatus, } func bzrRemoteRepo(vcsBzr *Cmd, rootDir string) (remoteRepo string, err error) { @@ -389,6 +390,63 @@ func bzrResolveRepo(vcsBzr *Cmd, rootDir, remoteRepo string) (realRepo string, e return strings.TrimSpace(out), nil } +func bzrStatus(vcsBzr *Cmd, rootDir string) (Status, error) { + outb, err := vcsBzr.runOutputVerboseOnly(rootDir, "version-info") + if err != nil { + return Status{}, err + } + out := string(outb) + + // Expect (non-empty repositories only): + // + // revision-id: gopher@gopher.net-20211021072330-qshok76wfypw9lpm + // date: 2021-09-21 12:00:00 +1000 + // ... + var rev string + var commitTime time.Time + + for _, line := range strings.Split(out, "\n") { + i := strings.IndexByte(line, ':') + if i < 0 { + continue + } + key := line[:i] + value := strings.TrimSpace(line[i+1:]) + + switch key { + case "revision-id": + rev = value + case "date": + var err error + commitTime, err = time.Parse("2006-01-02 15:04:05 -0700", value) + if err != nil { + return Status{}, errors.New("unable to parse output of bzr version-info") + } + } + } + + outb, err = vcsBzr.runOutputVerboseOnly(rootDir, "status") + if err != nil { + return Status{}, err + } + + // Skip warning when working directory is set to an older revision. + if bytes.HasPrefix(outb, []byte("working tree is out of date")) { + i := bytes.IndexByte(outb, '\n') + if i < 0 { + i = len(outb) + } + outb = outb[:i] + } + uncommitted := len(outb) > 0 + + return Status{ + Revision: rev, + CommitTime: commitTime, + Uncommitted: uncommitted, + }, nil +} + // vcsSvn describes how to use Subversion. var vcsSvn = &Cmd{ Name: "Subversion", diff --git a/src/cmd/go/testdata/script/version_buildvcs_bzr.txt b/src/cmd/go/testdata/script/version_buildvcs_bzr.txt new file mode 100644 index 0000000000..83069713d7 --- /dev/null +++ b/src/cmd/go/testdata/script/version_buildvcs_bzr.txt @@ -0,0 +1,104 @@ +# This test checks that VCS information is stamped into Go binaries by default, +# controlled with -buildvcs. This test focuses on Bazaar specifics. +# The Git test covers common functionality. + +[!exec:bzr] skip +[short] skip +env GOBIN=$WORK/gopath/bin +env oldpath=$PATH +env HOME=$WORK +cd repo/a +exec bzr whoami 'J.R. Gopher ' + +# If there's no local repository, there's no VCS info. +go install +go version -m $GOBIN/a$GOEXE +! stdout bzrrevision +rm $GOBIN/a$GOEXE + +# If there is a repository, but it can't be used for some reason, +# there should be an error. It should hint about -buildvcs=false. +cd .. +mkdir .bzr +env PATH=$WORK${/}fakebin${:}$oldpath +chmod 0755 $WORK/fakebin/bzr +! exec bzr help +cd a +! go install +stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$' +rm $GOBIN/a$GOEXE +cd .. +env PATH=$oldpath +rm .bzr + +# If there is an empty repository in a parent directory, only "uncommitted" is tagged. +exec bzr init +cd a +go install +go version -m $GOBIN/a$GOEXE +! stdout bzrrevision +! stdout bzrcommittime +stdout '^\tbuild\tbzruncommitted\ttrue$' +cd .. + +# Revision and commit time are tagged for repositories with commits. +exec bzr add a README +exec bzr commit -m 'initial commit' +cd a +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\tbzrrevision\t' +stdout '^\tbuild\tbzrcommittime\t' +stdout '^\tbuild\tbzruncommitted\tfalse$' +rm $GOBIN/a$GOEXE + +# Building an earlier commit should still build clean. +cp ../../outside/empty.txt ../NEWS +exec bzr add ../NEWS +exec bzr commit -m 'add NEWS' +exec bzr update -r1 +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\tbzrrevision\t' +stdout '^\tbuild\tbzrcommittime\t' +stdout '^\tbuild\tbzruncommitted\tfalse$' + +# Building with -buildvcs=false suppresses the info. +go install -buildvcs=false +go version -m $GOBIN/a$GOEXE +! stdout bzrrevision +rm $GOBIN/a$GOEXE + +# An untracked file is shown as uncommitted, even if it isn't part of the build. +cp ../../outside/empty.txt . +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\tbzruncommitted\ttrue$' +rm empty.txt +rm $GOBIN/a$GOEXE + +# An edited file is shown as uncommitted, even if it isn't part of the build. +cp ../../outside/empty.txt ../README +go install +go version -m $GOBIN/a$GOEXE +stdout '^\tbuild\tbzruncommitted\ttrue$' +exec bzr revert ../README +rm $GOBIN/a$GOEXE + +-- $WORK/fakebin/bzr -- +#!/bin/sh +exit 1 +-- $WORK/fakebin/bzr.bat -- +exit 1 +-- repo/README -- +Far out in the uncharted backwaters of the unfashionable end of the western +spiral arm of the Galaxy lies a small, unregarded yellow sun. +-- repo/a/go.mod -- +module example.com/a + +go 1.18 +-- repo/a/a.go -- +package main + +func main() {} +-- outside/empty.txt -- From 749f6e9eb6d101ef2ea4b7228a966391a80aa89b Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Fri, 22 Oct 2021 18:41:41 +1100 Subject: [PATCH 199/406] doc/go1.18: document Fossil/Bazaar and commit time build tag support Change-Id: I032791a3cda1916099b0fd2955dcca4e69763660 Reviewed-on: https://go-review.googlesource.com/c/go/+/357958 Trust: Ian Lance Taylor Reviewed-by: Bryan C. Mills --- doc/go1.18.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/go1.18.html b/doc/go1.18.html index 63a6ed8fcd..875577fd10 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -67,12 +67,13 @@ Do not send CLs removing the interior tags from such phrases.

The go command now embeds version control information in - binaries including the currently checked-out revision and a flag indicating - whether edited or untracked files are present. Version control information - is embedded if the go command is invoked in a directory within a - Git or Mercurial repository, and the main package and its - containing main module are in the same repository. This information may be - omitted using the flag -buildvcs=false. + binaries including the currently checked-out revision, commit time, and a + flag indicating whether edited or untracked files are present. Version + control information is embedded if the go command is invoked in + a directory within a Git, Mercurial, Fossil, or Bazaar repository, and the + main package and its containing main module are in the same + repository. This information may be omitted using the flag + -buildvcs=false.

From 79ff663754f4238bd1fe2e56f460c2f603c71b80 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 27 Oct 2021 14:11:33 -0700 Subject: [PATCH 200/406] constraints: remove Slice/Map/Chan Now that we permit arbitrary types as constraints, we no longer need them. For #48424 Change-Id: I15fef26a563988074650cb0801895b002c44148a Reviewed-on: https://go-review.googlesource.com/c/go/+/359258 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Robert Griesemer --- src/constraints/constraints.go | 15 ------- src/constraints/constraints_test.go | 62 ++++++----------------------- test/typeparam/issue48609.go | 4 +- 3 files changed, 13 insertions(+), 68 deletions(-) diff --git a/src/constraints/constraints.go b/src/constraints/constraints.go index 2a5f673a7e..2c033dff47 100644 --- a/src/constraints/constraints.go +++ b/src/constraints/constraints.go @@ -48,18 +48,3 @@ type Complex interface { type Ordered interface { Integer | Float | ~string } - -// Slice is a constraint that matches slices of any element type. -type Slice[Elem any] interface { - ~[]Elem -} - -// Map is a constraint that matches maps of any element and value type. -type Map[Key comparable, Val any] interface { - ~map[Key]Val -} - -// Chan is a constraint that matches channels of any element type. -type Chan[Elem any] interface { - ~chan Elem -} diff --git a/src/constraints/constraints_test.go b/src/constraints/constraints_test.go index db5a957313..538dc843cc 100644 --- a/src/constraints/constraints_test.go +++ b/src/constraints/constraints_test.go @@ -15,15 +15,12 @@ import ( ) type ( - testSigned[T Signed] struct{ f T } - testUnsigned[T Unsigned] struct{ f T } - testInteger[T Integer] struct{ f T } - testFloat[T Float] struct{ f T } - testComplex[T Complex] struct{ f T } - testOrdered[T Ordered] struct{ f T } - testSlice[T Slice[E], E any] struct{ f T } - testMap[T Map[K, V], K comparable, V any] struct{ f T } - testChan[T Chan[E], E any] struct{ f T } + testSigned[T Signed] struct{ f T } + testUnsigned[T Unsigned] struct{ f T } + testInteger[T Integer] struct{ f T } + testFloat[T Float] struct{ f T } + testComplex[T Complex] struct{ f T } + testOrdered[T Ordered] struct{ f T } ) // TestTypes passes if it compiles. @@ -40,35 +37,6 @@ type TestTypes struct { _ testOrdered[int] _ testOrdered[float64] _ testOrdered[string] - _ testSlice[[]int, int] - _ testMap[map[int]bool, int, bool] - _ testChan[chan int, int] -} - -func infer1[S Slice[E], E any](s S, v E) S { return s } -func infer2[M Map[K, V], K comparable, V any](m M, k K, v V) M { return m } -func infer3[C Chan[E], E any](c C, v E) C { return c } - -func TestInference(t *testing.T) { - var empty interface{} - - type S []int - empty = infer1(S{}, 0) - if _, ok := empty.(S); !ok { - t.Errorf("infer1(S) returned %T, expected S", empty) - } - - type M map[int]bool - empty = infer2(M{}, 0, false) - if _, ok := empty.(M); !ok { - t.Errorf("infer2(M) returned %T, expected M", empty) - } - - type C chan bool - empty = infer3(make(C), true) - if _, ok := empty.(C); !ok { - t.Errorf("infer3(C) returned %T, expected C", empty) - } } var prolog = []byte(` @@ -77,15 +45,12 @@ package constrainttest import "constraints" type ( - testSigned[T constraints.Signed] struct{ f T } - testUnsigned[T constraints.Unsigned] struct{ f T } - testInteger[T constraints.Integer] struct{ f T } - testFloat[T constraints.Float] struct{ f T } - testComplex[T constraints.Complex] struct{ f T } - testOrdered[T constraints.Ordered] struct{ f T } - testSlice[T constraints.Slice[E], E any] struct{ f T } - testMap[T constraints.Map[K, V], K comparable, V any] struct{ f T } - testChan[T constraints.Chan[E], E any] struct{ f T } + testSigned[T constraints.Signed] struct{ f T } + testUnsigned[T constraints.Unsigned] struct{ f T } + testInteger[T constraints.Integer] struct{ f T } + testFloat[T constraints.Float] struct{ f T } + testComplex[T constraints.Complex] struct{ f T } + testOrdered[T constraints.Ordered] struct{ f T } ) `) @@ -115,9 +80,6 @@ func TestFailure(t *testing.T) { {"testFloat", "int8"}, {"testComplex", "float64"}, {"testOrdered", "bool"}, - {"testSlice", "int, int"}, - {"testMap", "string, string, string"}, - {"testChan", "[]int, int"}, } { i := i test := test diff --git a/test/typeparam/issue48609.go b/test/typeparam/issue48609.go index 3ca9d6e7d6..6cf6908291 100644 --- a/test/typeparam/issue48609.go +++ b/test/typeparam/issue48609.go @@ -6,9 +6,7 @@ package p -import "constraints" - -func f[T constraints.Chan[E], E any](e E) T { +func f[T ~chan E, E any](e E) T { ch := make(T) go func() { defer close(ch) From a91d0b649c9ee8c64328fb124eff94dfca300d39 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 27 Oct 2021 13:55:15 -0700 Subject: [PATCH 201/406] cmd/compile/internal/types2: disallow lone type parameter on RHS of type declaration We may revisit this decision in a future release. By disallowing this for Go 1.18 we are ensuring that we don't lock in the generics design in a place that may need to change later. (Type declarations are the primary construct where it crucially matters what the underlying type of a type parameter is.) Comment out all tests that rely on this feature; add comments referring to issue so we can find all places easily should we change our minds. Fixes #45639. Change-Id: I730510e4da66d3716d455a9071c7778a1e4a1152 Reviewed-on: https://go-review.googlesource.com/c/go/+/359177 Trust: Robert Griesemer Trust: Dan Scales Reviewed-by: Dan Scales --- src/cmd/compile/internal/types2/api_test.go | 14 --- src/cmd/compile/internal/types2/decl.go | 9 +- .../internal/types2/testdata/check/linalg.go2 | 61 +++++----- .../types2/testdata/check/typeinst.go2 | 5 +- .../types2/testdata/check/typeinst2.go2 | 30 ++--- .../types2/testdata/check/typeparams.go2 | 19 ++-- .../types2/testdata/examples/methods.go2 | 31 +++--- .../types2/testdata/examples/types.go2 | 13 ++- .../types2/testdata/fixedbugs/issue39634.go2 | 7 +- .../types2/testdata/fixedbugs/issue39768.go2 | 17 +-- .../types2/testdata/fixedbugs/issue39938.go2 | 2 +- .../types2/testdata/fixedbugs/issue45639.go2 | 13 ++- .../types2/testdata/fixedbugs/issue47747.go2 | 67 +++++------ test/typeparam/absdiff.go | 105 +++++++++--------- test/typeparam/absdiffimp.dir/a.go | 71 ++++++------ test/typeparam/absdiffimp.dir/main.go | 38 +++---- test/typeparam/boundmethod.go | 34 +++--- test/typeparam/issue47708.go | 45 ++++---- test/typeparam/issue47740.go | 23 ++-- test/typeparam/issue47740.out | 2 - 20 files changed, 297 insertions(+), 309 deletions(-) diff --git a/src/cmd/compile/internal/types2/api_test.go b/src/cmd/compile/internal/types2/api_test.go index ecb5a29830..26652f3e74 100644 --- a/src/cmd/compile/internal/types2/api_test.go +++ b/src/cmd/compile/internal/types2/api_test.go @@ -622,13 +622,6 @@ func TestDefsInfo(t *testing.T) { {`package p3; type x int`, `x`, `type p3.x int`}, {`package p4; func f()`, `f`, `func p4.f()`}, {`package p5; func f() int { x, _ := 1, 2; return x }`, `_`, `var _ int`}, - - // generic types must be sanitized - // (need to use sufficiently nested types to provoke unexpanded types) - {genericPkg + `g0; type t[P any] P; const x = t[int](42)`, `x`, `const generic_g0.x generic_g0.t[int]`}, - {genericPkg + `g1; type t[P any] P; var x = t[int](42)`, `x`, `var generic_g1.x generic_g1.t[int]`}, - {genericPkg + `g2; type t[P any] P; type x struct{ f t[int] }`, `x`, `type generic_g2.x struct{f generic_g2.t[int]}`}, - {genericPkg + `g3; type t[P any] P; func f(x struct{ f t[string] }); var g = f`, `g`, `var generic_g3.g func(x struct{f generic_g3.t[string]})`}, } for _, test := range tests { @@ -667,13 +660,6 @@ func TestUsesInfo(t *testing.T) { {`package p2; func _() { _ = x }; var x int`, `x`, `var p2.x int`}, {`package p3; func _() { type _ x }; type x int`, `x`, `type p3.x int`}, {`package p4; func _() { _ = f }; func f()`, `f`, `func p4.f()`}, - - // generic types must be sanitized - // (need to use sufficiently nested types to provoke unexpanded types) - {genericPkg + `g0; func _() { _ = x }; type t[P any] P; const x = t[int](42)`, `x`, `const generic_g0.x generic_g0.t[int]`}, - {genericPkg + `g1; func _() { _ = x }; type t[P any] P; var x = t[int](42)`, `x`, `var generic_g1.x generic_g1.t[int]`}, - {genericPkg + `g2; func _() { type _ x }; type t[P any] P; type x struct{ f t[int] }`, `x`, `type generic_g2.x struct{f generic_g2.t[int]}`}, - {genericPkg + `g3; func _() { _ = f }; type t[P any] P; func f(x struct{ f t[string] })`, `f`, `func generic_g3.f(x struct{f generic_g3.t[string]})`}, } for _, test := range tests { diff --git a/src/cmd/compile/internal/types2/decl.go b/src/cmd/compile/internal/types2/decl.go index 63be4b3223..5d2a6c531b 100644 --- a/src/cmd/compile/internal/types2/decl.go +++ b/src/cmd/compile/internal/types2/decl.go @@ -604,9 +604,12 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *Named named.underlying = Typ[Invalid] } - // If the RHS is a type parameter, it must be from this type declaration. - if tpar, _ := named.underlying.(*TypeParam); tpar != nil && tparamIndex(named.TypeParams().list(), tpar) < 0 { - check.errorf(tdecl.Type, "cannot use function type parameter %s as RHS in type declaration", tpar) + // Disallow a lone type parameter as the RHS of a type declaration (issue #45639). + // We can look directly at named.underlying because even if it is still a *Named + // type (underlying not fully resolved yet) it cannot become a type parameter due + // to this very restriction. + if tpar, _ := named.underlying.(*TypeParam); tpar != nil { + check.error(tdecl.Type, "cannot use a type parameter as RHS in type declaration") named.underlying = Typ[Invalid] } } diff --git a/src/cmd/compile/internal/types2/testdata/check/linalg.go2 b/src/cmd/compile/internal/types2/testdata/check/linalg.go2 index efc090a1d1..f02e773dbe 100644 --- a/src/cmd/compile/internal/types2/testdata/check/linalg.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/linalg.go2 @@ -4,8 +4,6 @@ package linalg -import "math" - // Numeric is type bound that matches any numeric type. // It would likely be in a constraints package in the standard library. type Numeric interface { @@ -52,32 +50,33 @@ type Complex interface { ~complex64 | ~complex128 } -// OrderedAbs is a helper type that defines an Abs method for -// ordered numeric types. -type OrderedAbs[T OrderedNumeric] T - -func (a OrderedAbs[T]) Abs() OrderedAbs[T] { - if a < 0 { - return -a - } - return a -} - -// ComplexAbs is a helper type that defines an Abs method for -// complex types. -type ComplexAbs[T Complex] T - -func (a ComplexAbs[T]) Abs() ComplexAbs[T] { - r := float64(real(a)) - i := float64(imag(a)) - d := math.Sqrt(r * r + i * i) - return ComplexAbs[T](complex(d, 0)) -} - -func OrderedAbsDifference[T OrderedNumeric](a, b T) T { - return T(AbsDifference(OrderedAbs[T](a), OrderedAbs[T](b))) -} - -func ComplexAbsDifference[T Complex](a, b T) T { - return T(AbsDifference(ComplexAbs[T](a), ComplexAbs[T](b))) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// // OrderedAbs is a helper type that defines an Abs method for +// // ordered numeric types. +// type OrderedAbs[T OrderedNumeric] T +// +// func (a OrderedAbs[T]) Abs() OrderedAbs[T] { +// if a < 0 { +// return -a +// } +// return a +// } +// +// // ComplexAbs is a helper type that defines an Abs method for +// // complex types. +// type ComplexAbs[T Complex] T +// +// func (a ComplexAbs[T]) Abs() ComplexAbs[T] { +// r := float64(real(a)) +// i := float64(imag(a)) +// d := math.Sqrt(r * r + i * i) +// return ComplexAbs[T](complex(d, 0)) +// } +// +// func OrderedAbsDifference[T OrderedNumeric](a, b T) T { +// return T(AbsDifference(OrderedAbs[T](a), OrderedAbs[T](b))) +// } +// +// func ComplexAbsDifference[T Complex](a, b T) T { +// return T(AbsDifference(ComplexAbs[T](a), ComplexAbs[T](b))) +// } diff --git a/src/cmd/compile/internal/types2/testdata/check/typeinst.go2 b/src/cmd/compile/internal/types2/testdata/check/typeinst.go2 index 14f1b07ee2..a3d1b5e28f 100644 --- a/src/cmd/compile/internal/types2/testdata/check/typeinst.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/typeinst.go2 @@ -8,7 +8,8 @@ type myInt int // Parameterized type declarations -type T1[P any] P +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +type T1[P any] P // ERROR cannot use a type parameter as RHS in type declaration type T2[P any] struct { f P @@ -19,7 +20,7 @@ type List[P any] []P // Alias type declarations cannot have type parameters. // Issue #46477 proposses to change that. -type A1[P any] = /* ERROR cannot be alias */ P +type A1[P any] = /* ERROR cannot be alias */ struct{} // Pending clarification of #46477 we disallow aliases // of generic types. diff --git a/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 b/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 index 783ff346c9..5529bd093d 100644 --- a/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 @@ -87,25 +87,27 @@ type NumericAbs[T any] interface { func AbsDifference[T NumericAbs[T]](x T) { panic(0) } -type OrderedAbs[T any] T - -func (a OrderedAbs[T]) Abs() OrderedAbs[T] - -func OrderedAbsDifference[T any](x T) { - AbsDifference(OrderedAbs[T](x)) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type OrderedAbs[T any] T +// +// func (a OrderedAbs[T]) Abs() OrderedAbs[T] +// +// func OrderedAbsDifference[T any](x T) { +// AbsDifference(OrderedAbs[T](x)) +// } // same code, reduced to essence func g[P interface{ m() P }](x P) { panic(0) } -type T4[P any] P - -func (_ T4[P]) m() T4[P] - -func _[Q any](x Q) { - g(T4[Q](x)) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type T4[P any] P +// +// func (_ T4[P]) m() T4[P] +// +// func _[Q any](x Q) { +// g(T4[Q](x)) +// } // Another test case that caused problems in the past diff --git a/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 b/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 index 1200a6e874..11adb21d95 100644 --- a/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 @@ -353,15 +353,16 @@ func _() { // the previous example was extracted from -func f12[T interface{m() T}]() {} - -type A[T any] T - -func (a A[T]) m() A[T] - -func _[T any]() { - f12[A[T]]() -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// func f12[T interface{m() T}]() {} +// +// type A[T any] T +// +// func (a A[T]) m() A[T] +// +// func _[T any]() { +// f12[A[T]]() +// } // method expressions diff --git a/src/cmd/compile/internal/types2/testdata/examples/methods.go2 b/src/cmd/compile/internal/types2/testdata/examples/methods.go2 index 4e87041e54..1d76d553dc 100644 --- a/src/cmd/compile/internal/types2/testdata/examples/methods.go2 +++ b/src/cmd/compile/internal/types2/testdata/examples/methods.go2 @@ -6,8 +6,6 @@ package p -import "unsafe" - // Parameterized types may have methods. type T1[A any] struct{ a A } @@ -97,17 +95,18 @@ type T0 struct{} func (T0) _() {} func (T1[A]) _() {} -// A generic receiver type may constrain its type parameter such -// that it must be a pointer type. Such receiver types are not -// permitted. -type T3a[P interface{ ~int | ~string | ~float64 }] P - -func (T3a[_]) m() {} // this is ok - -type T3b[P interface{ ~unsafe.Pointer }] P - -func (T3b /* ERROR invalid receiver */ [_]) m() {} - -type T3c[P interface{ *int | *string }] P - -func (T3c /* ERROR invalid receiver */ [_]) m() {} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// // A generic receiver type may constrain its type parameter such +// // that it must be a pointer type. Such receiver types are not +// // permitted. +// type T3a[P interface{ ~int | ~string | ~float64 }] P +// +// func (T3a[_]) m() {} // this is ok +// +// type T3b[P interface{ ~unsafe.Pointer }] P +// +// func (T3b /* ERROR invalid receiver */ [_]) m() {} +// +// type T3c[P interface{ *int | *string }] P +// +// func (T3c /* ERROR invalid receiver */ [_]) m() {} diff --git a/src/cmd/compile/internal/types2/testdata/examples/types.go2 b/src/cmd/compile/internal/types2/testdata/examples/types.go2 index f177c78d06..72b74cee01 100644 --- a/src/cmd/compile/internal/types2/testdata/examples/types.go2 +++ b/src/cmd/compile/internal/types2/testdata/examples/types.go2 @@ -185,12 +185,13 @@ type _ struct { // _ = y < 0 // } -// It is not permitted to declare a local type whose underlying -// type is a type parameter not declared by that type declaration. -func _[T any]() { - type _ T // ERROR cannot use function type parameter T as RHS in type declaration - type _ [_ any] T // ERROR cannot use function type parameter T as RHS in type declaration -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// // It is not permitted to declare a local type whose underlying +// // type is a type parameter not declared by that type declaration. +// func _[T any]() { +// type _ T // ERROR cannot use function type parameter T as RHS in type declaration +// type _ [_ any] T // ERROR cannot use function type parameter T as RHS in type declaration +// } // As a special case, an explicit type argument may be omitted // from a type parameter bound if the type bound expects exactly diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2 index 200484b6d9..9a98f7f955 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go2 @@ -74,9 +74,10 @@ func F20[t Z20]() { F20(t /* ERROR invalid composite literal type */ {}) } type Z21 /* ERROR illegal cycle */ interface{ Z21 } func F21[T Z21]() { ( /* ERROR not used */ F21[Z21]) } -// crash 24 -type T24[P any] P -func (r T24[P]) m() { T24 /* ERROR without instantiation */ .m() } +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// // crash 24 +// type T24[P any] P +// func (r T24[P]) m() { T24 /* ERROR without instantiation */ .m() } // crash 25 type T25[A any] int diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39768.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39768.go2 index fb522733e0..696d9d9bee 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39768.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39768.go2 @@ -4,14 +4,15 @@ package p -type T[P any] P -type A = T // ERROR cannot use generic type -var x A[int] -var _ A - -type B = T[int] -var y B = x -var _ B /* ERROR not a generic type */ [int] +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type T[P any] P +// type A = T // ERROR cannot use generic type +// var x A[int] +// var _ A +// +// type B = T[int] +// var y B = x +// var _ B /* ERROR not a generic type */ [int] // test case from issue diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39938.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39938.go2 index 31bec5fb01..114646786d 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39938.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39938.go2 @@ -8,7 +8,7 @@ package p -type E0[P any] P +type E0[P any] []P type E1[P any] *P type E2[P any] struct{ _ P } type E3[P any] struct{ _ *P } diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45639.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45639.go2 index 441fb4cb34..80148fe481 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45639.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45639.go2 @@ -4,9 +4,10 @@ package P -// It is not permitted to declare a local type whose underlying -// type is a type parameters not declared by that type declaration. -func _[T any]() { - type _ T // ERROR cannot use function type parameter T as RHS in type declaration - type _ [_ any] T // ERROR cannot use function type parameter T as RHS in type declaration -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// // It is not permitted to declare a local type whose underlying +// // type is a type parameters not declared by that type declaration. +// func _[T any]() { +// type _ T // ERROR cannot use function type parameter T as RHS in type declaration +// type _ [_ any] T // ERROR cannot use function type parameter T as RHS in type declaration +// } diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue47747.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue47747.go2 index af52056bef..6a2e787bf9 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue47747.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue47747.go2 @@ -4,15 +4,16 @@ package p -type T1[P any] P - -func (T1[_]) m() {} - -func _[P any](x *T1[P]) { - // x.m exists because x is of type *T1 where T1 is a defined type - // (even though under(T1) is a type parameter) - x.m() -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type T1[P any] P +// +// func (T1[_]) m() {} +// +// func _[P any](x *T1[P]) { +// // x.m exists because x is of type *T1 where T1 is a defined type +// // (even though under(T1) is a type parameter) +// x.m() +// } func _[P interface{ m() }](x P) { @@ -40,29 +41,31 @@ type Barer[t any] interface { Bar(t) } -type Foo1[t any] t -type Bar[t any] t - -func (l Foo1[t]) Foo(v Barer[t]) { v.Bar(t(l)) } -func (b *Bar[t]) Bar(l t) { *b = Bar[t](l) } - -func _[t any](f Fooer1[t]) t { - var b Bar[t] - f.Foo(&b) - return t(b) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type Foo1[t any] t +// type Bar[t any] t +// +// func (l Foo1[t]) Foo(v Barer[t]) { v.Bar(t(l)) } +// func (b *Bar[t]) Bar(l t) { *b = Bar[t](l) } +// +// func _[t any](f Fooer1[t]) t { +// var b Bar[t] +// f.Foo(&b) +// return t(b) +// } // Test case 2 from issue -type Fooer2[t any] interface { - Foo() -} - -type Foo2[t any] t - -func (f *Foo2[t]) Foo() {} - -func _[t any](v t) { - var f = Foo2[t](v) - _ = Fooer2[t](&f) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type Fooer2[t any] interface { +// Foo() +// } +// +// type Foo2[t any] t +// +// func (f *Foo2[t]) Foo() {} +// +// func _[t any](v t) { +// var f = Foo2[t](v) +// _ = Fooer2[t](&f) +// } diff --git a/test/typeparam/absdiff.go b/test/typeparam/absdiff.go index cad6e84c4e..f1822831b2 100644 --- a/test/typeparam/absdiff.go +++ b/test/typeparam/absdiff.go @@ -6,11 +6,6 @@ package main -import ( - "fmt" - "math" -) - type Numeric interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | @@ -43,55 +38,57 @@ type Complex interface { ~complex64 | ~complex128 } -// orderedAbs is a helper type that defines an Abs method for -// ordered numeric types. -type orderedAbs[T orderedNumeric] T - -func (a orderedAbs[T]) Abs() orderedAbs[T] { - if a < 0 { - return -a - } - return a -} - -// complexAbs is a helper type that defines an Abs method for -// complex types. -type complexAbs[T Complex] T - -func (a complexAbs[T]) Abs() complexAbs[T] { - r := float64(real(a)) - i := float64(imag(a)) - d := math.Sqrt(r*r + i*i) - return complexAbs[T](complex(d, 0)) -} - -// OrderedAbsDifference returns the absolute value of the difference -// between a and b, where a and b are of an ordered type. -func orderedAbsDifference[T orderedNumeric](a, b T) T { - return T(absDifference(orderedAbs[T](a), orderedAbs[T](b))) -} - -// ComplexAbsDifference returns the absolute value of the difference -// between a and b, where a and b are of a complex type. -func complexAbsDifference[T Complex](a, b T) T { - return T(absDifference(complexAbs[T](a), complexAbs[T](b))) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// // orderedAbs is a helper type that defines an Abs method for +// // ordered numeric types. +// type orderedAbs[T orderedNumeric] T +// +// func (a orderedAbs[T]) Abs() orderedAbs[T] { +// if a < 0 { +// return -a +// } +// return a +// } +// +// // complexAbs is a helper type that defines an Abs method for +// // complex types. +// type complexAbs[T Complex] T +// +// func (a complexAbs[T]) Abs() complexAbs[T] { +// r := float64(real(a)) +// i := float64(imag(a)) +// d := math.Sqrt(r*r + i*i) +// return complexAbs[T](complex(d, 0)) +// } +// +// // OrderedAbsDifference returns the absolute value of the difference +// // between a and b, where a and b are of an ordered type. +// func orderedAbsDifference[T orderedNumeric](a, b T) T { +// return T(absDifference(orderedAbs[T](a), orderedAbs[T](b))) +// } +// +// // ComplexAbsDifference returns the absolute value of the difference +// // between a and b, where a and b are of a complex type. +// func complexAbsDifference[T Complex](a, b T) T { +// return T(absDifference(complexAbs[T](a), complexAbs[T](b))) +// } func main() { - if got, want := orderedAbsDifference(1.0, -2.0), 3.0; got != want { - panic(fmt.Sprintf("got = %v, want = %v", got, want)) - } - if got, want := orderedAbsDifference(-1.0, 2.0), 3.0; got != want { - panic(fmt.Sprintf("got = %v, want = %v", got, want)) - } - if got, want := orderedAbsDifference(-20, 15), 35; got != want { - panic(fmt.Sprintf("got = %v, want = %v", got, want)) - } - - if got, want := complexAbsDifference(5.0+2.0i, 2.0-2.0i), 5+0i; got != want { - panic(fmt.Sprintf("got = %v, want = %v", got, want)) - } - if got, want := complexAbsDifference(2.0-2.0i, 5.0+2.0i), 5+0i; got != want { - panic(fmt.Sprintf("got = %v, want = %v", got, want)) - } + // // For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). + // if got, want := orderedAbsDifference(1.0, -2.0), 3.0; got != want { + // panic(fmt.Sprintf("got = %v, want = %v", got, want)) + // } + // if got, want := orderedAbsDifference(-1.0, 2.0), 3.0; got != want { + // panic(fmt.Sprintf("got = %v, want = %v", got, want)) + // } + // if got, want := orderedAbsDifference(-20, 15), 35; got != want { + // panic(fmt.Sprintf("got = %v, want = %v", got, want)) + // } + // + // if got, want := complexAbsDifference(5.0+2.0i, 2.0-2.0i), 5+0i; got != want { + // panic(fmt.Sprintf("got = %v, want = %v", got, want)) + // } + // if got, want := complexAbsDifference(2.0-2.0i, 5.0+2.0i), 5+0i; got != want { + // panic(fmt.Sprintf("got = %v, want = %v", got, want)) + // } } diff --git a/test/typeparam/absdiffimp.dir/a.go b/test/typeparam/absdiffimp.dir/a.go index 7b5bfbe2ac..60822fdb8b 100644 --- a/test/typeparam/absdiffimp.dir/a.go +++ b/test/typeparam/absdiffimp.dir/a.go @@ -4,10 +4,6 @@ package a -import ( - "math" -) - type Numeric interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | @@ -40,36 +36,37 @@ type Complex interface { ~complex64 | ~complex128 } -// orderedAbs is a helper type that defines an Abs method for -// ordered numeric types. -type orderedAbs[T orderedNumeric] T - -func (a orderedAbs[T]) Abs() orderedAbs[T] { - if a < 0 { - return -a - } - return a -} - -// complexAbs is a helper type that defines an Abs method for -// complex types. -type complexAbs[T Complex] T - -func (a complexAbs[T]) Abs() complexAbs[T] { - r := float64(real(a)) - i := float64(imag(a)) - d := math.Sqrt(r*r + i*i) - return complexAbs[T](complex(d, 0)) -} - -// OrderedAbsDifference returns the absolute value of the difference -// between a and b, where a and b are of an ordered type. -func OrderedAbsDifference[T orderedNumeric](a, b T) T { - return T(absDifference(orderedAbs[T](a), orderedAbs[T](b))) -} - -// ComplexAbsDifference returns the absolute value of the difference -// between a and b, where a and b are of a complex type. -func ComplexAbsDifference[T Complex](a, b T) T { - return T(absDifference(complexAbs[T](a), complexAbs[T](b))) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// // orderedAbs is a helper type that defines an Abs method for +// // ordered numeric types. +// type orderedAbs[T orderedNumeric] T +// +// func (a orderedAbs[T]) Abs() orderedAbs[T] { +// if a < 0 { +// return -a +// } +// return a +// } +// +// // complexAbs is a helper type that defines an Abs method for +// // complex types. +// type complexAbs[T Complex] T +// +// func (a complexAbs[T]) Abs() complexAbs[T] { +// r := float64(real(a)) +// i := float64(imag(a)) +// d := math.Sqrt(r*r + i*i) +// return complexAbs[T](complex(d, 0)) +// } +// +// // OrderedAbsDifference returns the absolute value of the difference +// // between a and b, where a and b are of an ordered type. +// func OrderedAbsDifference[T orderedNumeric](a, b T) T { +// return T(absDifference(orderedAbs[T](a), orderedAbs[T](b))) +// } +// +// // ComplexAbsDifference returns the absolute value of the difference +// // between a and b, where a and b are of a complex type. +// func ComplexAbsDifference[T Complex](a, b T) T { +// return T(absDifference(complexAbs[T](a), complexAbs[T](b))) +// } diff --git a/test/typeparam/absdiffimp.dir/main.go b/test/typeparam/absdiffimp.dir/main.go index 8eefdbdf38..c648013327 100644 --- a/test/typeparam/absdiffimp.dir/main.go +++ b/test/typeparam/absdiffimp.dir/main.go @@ -4,26 +4,22 @@ package main -import ( - "a" - "fmt" -) - func main() { - if got, want := a.OrderedAbsDifference(1.0, -2.0), 3.0; got != want { - panic(fmt.Sprintf("got = %v, want = %v", got, want)) - } - if got, want := a.OrderedAbsDifference(-1.0, 2.0), 3.0; got != want { - panic(fmt.Sprintf("got = %v, want = %v", got, want)) - } - if got, want := a.OrderedAbsDifference(-20, 15), 35; got != want { - panic(fmt.Sprintf("got = %v, want = %v", got, want)) - } - - if got, want := a.ComplexAbsDifference(5.0+2.0i, 2.0-2.0i), 5+0i; got != want { - panic(fmt.Sprintf("got = %v, want = %v", got, want)) - } - if got, want := a.ComplexAbsDifference(2.0-2.0i, 5.0+2.0i), 5+0i; got != want { - panic(fmt.Sprintf("got = %v, want = %v", got, want)) - } + // For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). + // if got, want := a.OrderedAbsDifference(1.0, -2.0), 3.0; got != want { + // panic(fmt.Sprintf("got = %v, want = %v", got, want)) + // } + // if got, want := a.OrderedAbsDifference(-1.0, 2.0), 3.0; got != want { + // panic(fmt.Sprintf("got = %v, want = %v", got, want)) + // } + // if got, want := a.OrderedAbsDifference(-20, 15), 35; got != want { + // panic(fmt.Sprintf("got = %v, want = %v", got, want)) + // } + // + // if got, want := a.ComplexAbsDifference(5.0+2.0i, 2.0-2.0i), 5+0i; got != want { + // panic(fmt.Sprintf("got = %v, want = %v", got, want)) + // } + // if got, want := a.ComplexAbsDifference(2.0-2.0i, 5.0+2.0i), 5+0i; got != want { + // panic(fmt.Sprintf("got = %v, want = %v", got, want)) + // } } diff --git a/test/typeparam/boundmethod.go b/test/typeparam/boundmethod.go index 22f416422d..a14eb544ce 100644 --- a/test/typeparam/boundmethod.go +++ b/test/typeparam/boundmethod.go @@ -59,12 +59,13 @@ type Ints interface { ~int32 | ~int } -type StringInt[T Ints] T - -//go:noinline -func (m StringInt[T]) String() string { - return strconv.Itoa(int(m)) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type StringInt[T Ints] T +// +// //go:noinline +// func (m StringInt[T]) String() string { +// return strconv.Itoa(int(m)) +// } type StringStruct[T Ints] struct { f T @@ -84,22 +85,23 @@ func main() { panic(fmt.Sprintf("got %s, want %s", got, want)) } - x2 := []StringInt[myint]{StringInt[myint](5), StringInt[myint](7), StringInt[myint](6)} - - // stringify on an instantiated type, whose bound method is associated with - // the generic type StringInt[T], which maps directly to T. - got2 := stringify(x2) - want2 := []string{ "5", "7", "6" } - if !reflect.DeepEqual(got2, want2) { - panic(fmt.Sprintf("got %s, want %s", got2, want2)) - } + // For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). + // x2 := []StringInt[myint]{StringInt[myint](5), StringInt[myint](7), StringInt[myint](6)} + // + // // stringify on an instantiated type, whose bound method is associated with + // // the generic type StringInt[T], which maps directly to T. + // got2 := stringify(x2) + // want2 := []string{"5", "7", "6"} + // if !reflect.DeepEqual(got2, want2) { + // panic(fmt.Sprintf("got %s, want %s", got2, want2)) + // } // stringify on an instantiated type, whose bound method is associated with // the generic type StringStruct[T], which maps to a struct containing T. x3 := []StringStruct[myint]{StringStruct[myint]{f: 11}, StringStruct[myint]{f: 10}, StringStruct[myint]{f: 9}} got3 := stringify(x3) - want3 := []string{ "11", "10", "9" } + want3 := []string{"11", "10", "9"} if !reflect.DeepEqual(got3, want3) { panic(fmt.Sprintf("got %s, want %s", got3, want3)) } diff --git a/test/typeparam/issue47708.go b/test/typeparam/issue47708.go index 261d6efb61..35d57c8a64 100644 --- a/test/typeparam/issue47708.go +++ b/test/typeparam/issue47708.go @@ -6,35 +6,32 @@ package main -import ( - "fmt" -) - type FooType[T any] interface { - Foo(BarType[T])string + Foo(BarType[T]) string } type BarType[T any] interface { - Bar(FooType[T])string -} - -type Baz[T any] T -func (l Baz[T]) Foo(v BarType[T]) string { - return v.Bar(l) -} -type Bob[T any] T -func (l Bob[T]) Bar(v FooType[T]) string { - if v,ok := v.(Baz[T]);ok{ - return fmt.Sprintf("%v%v",v,l) - } - return "" + Bar(FooType[T]) string } +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type Baz[T any] T +// func (l Baz[T]) Foo(v BarType[T]) string { +// return v.Bar(l) +// } +// type Bob[T any] T +// func (l Bob[T]) Bar(v FooType[T]) string { +// if v,ok := v.(Baz[T]);ok{ +// return fmt.Sprintf("%v%v",v,l) +// } +// return "" +// } func main() { - var baz Baz[int] = 123 - var bob Bob[int] = 456 - - if got, want := baz.Foo(bob), "123456"; got != want { - panic(fmt.Sprintf("got %s want %s", got, want)) - } + // For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). + // var baz Baz[int] = 123 + // var bob Bob[int] = 456 + // + // if got, want := baz.Foo(bob), "123456"; got != want { + // panic(fmt.Sprintf("got %s want %s", got, want)) + // } } diff --git a/test/typeparam/issue47740.go b/test/typeparam/issue47740.go index a8c6839de3..ea1168f4e6 100644 --- a/test/typeparam/issue47740.go +++ b/test/typeparam/issue47740.go @@ -12,10 +12,11 @@ type Exp[Ty any] interface { Eval() Ty } -type Lit[Ty any] Ty - -func (lit Lit[Ty]) Eval() Ty { return Ty(lit) } -func (lit Lit[Ty]) String() string { return fmt.Sprintf("(lit %v)", Ty(lit)) } +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type Lit[Ty any] Ty +// +// func (lit Lit[Ty]) Eval() Ty { return Ty(lit) } +// func (lit Lit[Ty]) String() string { return fmt.Sprintf("(lit %v)", Ty(lit)) } type Eq[Ty any] struct { a Exp[Ty] @@ -26,12 +27,14 @@ func (e Eq[Ty]) String() string { return fmt.Sprintf("(eq %v %v)", e.a, e.b) } -var ( - e0 = Eq[int]{Lit[int](128), Lit[int](64)} - e1 = Eq[bool]{Lit[bool](true), Lit[bool](true)} -) +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// var ( +// e0 = Eq[int]{Lit[int](128), Lit[int](64)} +// e1 = Eq[bool]{Lit[bool](true), Lit[bool](true)} +// ) func main() { - fmt.Printf("%v\n", e0) - fmt.Printf("%v\n", e1) + // For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). + // fmt.Printf("%v\n", e0) + // fmt.Printf("%v\n", e1) } diff --git a/test/typeparam/issue47740.out b/test/typeparam/issue47740.out index f23c310f66..e69de29bb2 100644 --- a/test/typeparam/issue47740.out +++ b/test/typeparam/issue47740.out @@ -1,2 +0,0 @@ -(eq (lit 128) (lit 64)) -(eq (lit true) (lit true)) From 12dc48fd54d4bfc0c25e2a96aa7fecfacb9087ca Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 27 Oct 2021 17:28:36 -0700 Subject: [PATCH 202/406] cmd/compile/internal/types2: export Structure function For #48538. Change-Id: I258b0c8af5801692ad238e47397dde0b4e3c44c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/359275 Trust: Robert Griesemer Trust: Dan Scales Reviewed-by: Dan Scales --- src/cmd/compile/internal/types2/builtins.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index e8de0077d4..c5c6bdf0a5 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -767,6 +767,16 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( return true } +// Structure is exported for the compiler. + +// If typ is a type parameter, Structure returns the single underlying +// type of all types in the corresponding type constraint if it exists, +// or nil otherwise. If typ is not a type parameter, Structure returns +// the underlying type. +func Structure(typ Type) Type { + return structure(typ) +} + // If typ is a type parameter, structure returns the single underlying // type of all types in the corresponding type constraint if it exists, // or nil otherwise. If typ is not a type parameter, structure returns From b2fe2ebab6e66a453a0137e37d2c639a613a852b Mon Sep 17 00:00:00 2001 From: Leonard Wang Date: Wed, 7 Jul 2021 22:33:09 +0800 Subject: [PATCH 203/406] cmd/compile: resolve the TODO of processPragmas Change-Id: Id723ecc2480aea2d8acb4d3e05db4a6c8eef9cc8 Reviewed-on: https://go-review.googlesource.com/c/go/+/333109 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky Trust: Matthew Dempsky Trust: Cherry Mui --- src/cmd/compile/internal/noder/noder.go | 3 +-- src/cmd/cover/testdata/test.go | 1 + test/linkname2.go | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/cmd/compile/internal/noder/noder.go b/src/cmd/compile/internal/noder/noder.go index fc1541f74e..b36db67a50 100644 --- a/src/cmd/compile/internal/noder/noder.go +++ b/src/cmd/compile/internal/noder/noder.go @@ -323,8 +323,7 @@ func (p *noder) processPragmas() { } n := ir.AsNode(typecheck.Lookup(l.local).Def) if n == nil || n.Op() != ir.ONAME { - // TODO(mdempsky): Change to p.errorAt before Go 1.17 release. - // base.WarnfAt(p.makeXPos(l.pos), "//go:linkname must refer to declared function or variable (will be an error in Go 1.17)") + p.errorAt(l.pos, "//go:linkname must refer to declared function or variable") continue } if n.Sym().Linkname != "" { diff --git a/src/cmd/cover/testdata/test.go b/src/cmd/cover/testdata/test.go index b794962205..703fba57a4 100644 --- a/src/cmd/cover/testdata/test.go +++ b/src/cmd/cover/testdata/test.go @@ -13,6 +13,7 @@ package main import _ "unsafe" // for go:linkname //go:linkname some_name some_name +var some_name int const anything = 1e9 // Just some unlikely value that means "we got here, don't care how often" diff --git a/test/linkname2.go b/test/linkname2.go index 43e66a5849..cb7f9be345 100644 --- a/test/linkname2.go +++ b/test/linkname2.go @@ -16,13 +16,10 @@ var x, y int //go:linkname x ok // ERROR "//go:linkname requires linkname argument or -p compiler flag" -// BAD: want error "//go:linkname must refer to declared function or variable" -// BAD: want error "//go:linkname must refer to declared function or variable" +// ERROR "//go:linkname must refer to declared function or variable" +// ERROR "//go:linkname must refer to declared function or variable" // ERROR "duplicate //go:linkname for x" -// The two BAD lines are just waiting for #42938 before we can -// re-enable the errors. - //line linkname2.go:18 //go:linkname y //go:linkname nonexist nonexist From 056dfe6ff34fd479ec5c86d9b26a03c639b3f3f7 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Thu, 28 Oct 2021 00:33:19 +0700 Subject: [PATCH 204/406] reflect: undeprecate Value.{Pointer,UnsafeAddr} Fixes #49187 Change-Id: I4d8c87af8a709f1b909dd4fae3734d422eb36900 Reviewed-on: https://go-review.googlesource.com/c/go/+/359194 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/reflect/value.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/reflect/value.go b/src/reflect/value.go index 5d9964eb9d..618d38893e 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -1934,7 +1934,7 @@ func (v Value) OverflowUint(x uint64) bool { // element of the slice. If the slice is nil the returned value // is 0. If the slice is empty but non-nil the return value is non-zero. // -// Deprecated: use uintptr(Value.UnsafePointer()) to get the equivalent result. +// It's preferred to use uintptr(Value.UnsafePointer()) to get the equivalent result. func (v Value) Pointer() uintptr { k := v.kind() switch k { @@ -2479,7 +2479,7 @@ func (v Value) Uint() uint64 { // It is for advanced clients that also import the "unsafe" package. // It panics if v is not addressable. // -// Deprecated: use uintptr(Value.Addr().UnsafePointer()) to get the equivalent result. +// It's preferred to use uintptr(Value.Addr().UnsafePointer()) to get the equivalent result. func (v Value) UnsafeAddr() uintptr { if v.typ == nil { panic(&ValueError{"reflect.Value.UnsafeAddr", Invalid}) From 5a3a9d87ed97f197aabcb868f6c0031c888d6122 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 27 Oct 2021 18:53:02 -0400 Subject: [PATCH 205/406] cmd/dist: implement //go:build parsing The bootstrap directories are built with the Go 1.4 go command, and they will retain the // +build lines until we bump the bootstrap toolchain to Go 1.17 or later. cmd/dist builds cmd/go and all its dependencies, using the assembler, compiler, and linker that were built using Go 1.4. We don't want to have to keep // +build lines in cmd/go and all its dependencies, so this CL changes cmd/dist to understand the //go:build lines. cmd/dist is a standalone Go program that must itself build with very old Go releases, so we cannot assume go/build/constraint is available. Instead, implement a trivial parser/evaluator. For #41184. Change-Id: I84e259dec3bd3daec3f82024eb3500120f53096d Reviewed-on: https://go-review.googlesource.com/c/go/+/359314 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/cmd/dist/build.go | 47 ++++---------- src/cmd/dist/buildtag.go | 133 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 34 deletions(-) create mode 100644 src/cmd/dist/buildtag.go diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index 39f016e315..d37c3f83ef 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -812,6 +812,9 @@ func runInstall(pkg string, ch chan struct{}) { importMap := make(map[string]string) for _, p := range gofiles { for _, imp := range readimports(p) { + if imp == "C" { + fatalf("%s imports C", p) + } importMap[imp] = resolveVendor(imp, dir) } } @@ -822,6 +825,9 @@ func runInstall(pkg string, ch chan struct{}) { sort.Strings(sortedImports) for _, dep := range importMap { + if dep == "C" { + fatalf("%s imports C", pkg) + } startInstall(dep) } for _, dep := range importMap { @@ -970,28 +976,8 @@ func packagefile(pkg string) string { return pathf("%s/pkg/%s_%s/%s.a", goroot, goos, goarch, pkg) } -// matchfield reports whether the field (x,y,z) matches this build. -// all the elements in the field must be satisfied. -func matchfield(f string) bool { - for _, tag := range strings.Split(f, ",") { - if !matchtag(tag) { - return false - } - } - return true -} - -// matchtag reports whether the tag (x or !x) matches this build. +// matchtag reports whether the tag matches this build. func matchtag(tag string) bool { - if tag == "" { - return false - } - if tag[0] == '!' { - if len(tag) == 1 || tag[1] == '!' { - return false - } - return !matchtag(tag[1:]) - } return tag == "gc" || tag == goos || tag == goarch || tag == "cmd_go_bootstrap" || tag == "go1.1" || (goos == "android" && tag == "linux") || (goos == "illumos" && tag == "solaris") || @@ -1032,7 +1018,7 @@ func shouldbuild(file, pkg string) bool { return false } - // Check file contents for // +build lines. + // Check file contents for //go:build lines. for _, p := range strings.Split(readfile(file), "\n") { p = strings.TrimSpace(p) if p == "" { @@ -1052,20 +1038,13 @@ func shouldbuild(file, pkg string) bool { if !strings.HasPrefix(p, "//") { break } - if !strings.Contains(p, "+build") { - continue - } - fields := strings.Fields(p[2:]) - if len(fields) < 1 || fields[0] != "+build" { - continue - } - for _, p := range fields[1:] { - if matchfield(p) { - goto fieldmatch + if strings.HasPrefix(p, "//go:build ") { + matched, err := matchexpr(p[len("//go:build "):]) + if err != nil { + errprintf("%s: %v", file, err) } + return matched } - return false - fieldmatch: } return true diff --git a/src/cmd/dist/buildtag.go b/src/cmd/dist/buildtag.go new file mode 100644 index 0000000000..24776a0aaf --- /dev/null +++ b/src/cmd/dist/buildtag.go @@ -0,0 +1,133 @@ +// Copyright 2021 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 main + +import ( + "fmt" + "strings" +) + +// exprParser is a //go:build expression parser and evaluator. +// The parser is a trivial precedence-based parser which is still +// almost overkill for these very simple expressions. +type exprParser struct { + x string + t exprToken // upcoming token +} + +// val is the value type result of parsing. +// We don't keep a parse tree, just the value of the expression. +type val bool + +// exprToken describes a single token in the input. +// Prefix operators define a prefix func that parses the +// upcoming value. Binary operators define an infix func +// that combines two values according to the operator. +// In that case, the parsing loop parses the two values. +type exprToken struct { + tok string + prec int + prefix func(*exprParser) val + infix func(val, val) val +} + +var exprTokens []exprToken + +func init() { // init to break init cycle + exprTokens = []exprToken{ + {tok: "&&", prec: 1, infix: func(x, y val) val { return x && y }}, + {tok: "||", prec: 2, infix: func(x, y val) val { return x || y }}, + {tok: "!", prec: 3, prefix: (*exprParser).not}, + {tok: "(", prec: 3, prefix: (*exprParser).paren}, + {tok: ")"}, + } +} + +// matchexpr parses and evaluates the //go:build expression x. +func matchexpr(x string) (matched bool, err error) { + defer func() { + if e := recover(); e != nil { + matched = false + err = fmt.Errorf("parsing //go:build line: %v", e) + } + }() + + p := &exprParser{x: x} + p.next() + v := p.parse(0) + if p.t.tok != "end of expression" { + panic("unexpected " + p.t.tok) + } + return bool(v), nil +} + +// parse parses an expression, including binary operators at precedence >= prec. +func (p *exprParser) parse(prec int) val { + if p.t.prefix == nil { + panic("unexpected " + p.t.tok) + } + v := p.t.prefix(p) + for p.t.prec >= prec && p.t.infix != nil { + t := p.t + p.next() + v = t.infix(v, p.parse(t.prec+1)) + } + return v +} + +// not is the prefix parser for a ! token. +func (p *exprParser) not() val { + p.next() + return !p.parse(100) +} + +// paren is the prefix parser for a ( token. +func (p *exprParser) paren() val { + p.next() + v := p.parse(0) + if p.t.tok != ")" { + panic("missing )") + } + p.next() + return v +} + +// next advances the parser to the next token, +// leaving the token in p.t. +func (p *exprParser) next() { + p.x = strings.TrimSpace(p.x) + if p.x == "" { + p.t = exprToken{tok: "end of expression"} + return + } + for _, t := range exprTokens { + if strings.HasPrefix(p.x, t.tok) { + p.x = p.x[len(t.tok):] + p.t = t + return + } + } + + i := 0 + for i < len(p.x) && validtag(p.x[i]) { + i++ + } + if i == 0 { + panic(fmt.Sprintf("syntax error near %#q", rune(p.x[i]))) + } + tag := p.x[:i] + p.x = p.x[i:] + p.t = exprToken{ + tok: "tag", + prefix: func(p *exprParser) val { + p.next() + return val(matchtag(tag)) + }, + } +} + +func validtag(c byte) bool { + return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9' || c == '.' || c == '_' +} From b8f928b05264cbd75a0d0dbd02d979847ac237f9 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 27 Oct 2021 20:21:07 -0400 Subject: [PATCH 206/406] go/build: update for //go:build lines Look for //go:build ignore, not // +build ignore, in deps_test.go. For #41184. Change-Id: Iba8617230aa620223e2bc170f18d0c54557318c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/359315 Trust: Russ Cox Trust: Josh Bleecher Snyder Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Josh Bleecher Snyder --- src/go/build/deps_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go index 64f084152a..ab85c99602 100644 --- a/src/go/build/deps_test.go +++ b/src/go/build/deps_test.go @@ -621,7 +621,7 @@ func TestDependencies(t *testing.T) { } } -var buildIgnore = []byte("\n// +build ignore") +var buildIgnore = []byte("\n//go:build ignore") func findImports(pkg string) ([]string, error) { vpkg := pkg From 2ff1074f5ac48e67ee079dafc9f0e314bc454510 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 27 Oct 2021 10:13:50 -0700 Subject: [PATCH 207/406] reflect: undeprecate Ptr, PtrTo Fixes #48665 Change-Id: Id838f7508f6e93c4546a2aeefc2db194e647db77 Reviewed-on: https://go-review.googlesource.com/c/go/+/359175 Trust: Brad Fitzpatrick Reviewed-by: Ian Lance Taylor --- src/reflect/type.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/reflect/type.go b/src/reflect/type.go index 0896949d7e..4701e06c49 100644 --- a/src/reflect/type.go +++ b/src/reflect/type.go @@ -269,8 +269,6 @@ const ( ) // Ptr is the old name for the Pointer kind. -// -// Deprecated: use the new spelling, Pointer. const Ptr = Pointer // tflag is used by an rtype to signal what extra type information is @@ -1425,9 +1423,9 @@ func TypeOf(i interface{}) Type { var ptrMap sync.Map // map[*rtype]*ptrType // PtrTo returns the pointer type with element t. -// For example, if t represents type Foo, PointerTo(t) represents *Foo. +// For example, if t represents type Foo, PtrTo(t) represents *Foo. // -// Deprecated: use PointerTo. PtrTo is the old spelling. +// PtrTo is the old spelling of PointerTo. // The two functions behave identically. func PtrTo(t Type) Type { return PointerTo(t) } From a3bb28e5ffee83c30a2c65963ef032cc2ab73a3c Mon Sep 17 00:00:00 2001 From: nimelehin Date: Tue, 19 Oct 2021 18:59:34 +0300 Subject: [PATCH 208/406] cmd/compile: allow inlining of ORANGE Updates #14768 Change-Id: I33831f616eae5eeb099033e2b9cf90fa70d6ca86 Reviewed-on: https://go-review.googlesource.com/c/go/+/356869 Run-TryBot: Alberto Donizetti TryBot-Result: Go Bot Reviewed-by: Dan Scales Trust: Dan Scales Trust: Alberto Donizetti --- src/cmd/compile/internal/inline/inl.go | 3 +-- test/fixedbugs/issue49100b.go | 27 ++++++++++++++++++++++++++ test/fixedbugs/issue49100b.out | 6 ++++++ test/inline.go | 13 +++++++++++++ test/linkname.dir/linkname1.go | 2 +- 5 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 test/fixedbugs/issue49100b.go create mode 100644 test/fixedbugs/issue49100b.out diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index 483b3d5d46..da905bd627 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -358,8 +358,7 @@ func (v *hairyVisitor) doNode(n ir.Node) bool { return true } - case ir.ORANGE, - ir.OSELECT, + case ir.OSELECT, ir.OGO, ir.ODEFER, ir.ODCLTYPE, // can't print yet diff --git a/test/fixedbugs/issue49100b.go b/test/fixedbugs/issue49100b.go new file mode 100644 index 0000000000..992ff96d54 --- /dev/null +++ b/test/fixedbugs/issue49100b.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2021 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 main + +func r(j int) { +loop: + for i, c := range "goclang" { + if i == 2 { + continue loop + } + println(string(c)) + } +} + +func main() { +loop: + for j := 0; j < 4; j++ { + r(j) + if j == 0 { + break loop + } + } +} diff --git a/test/fixedbugs/issue49100b.out b/test/fixedbugs/issue49100b.out new file mode 100644 index 0000000000..d5abb928ee --- /dev/null +++ b/test/fixedbugs/issue49100b.out @@ -0,0 +1,6 @@ +g +o +l +a +n +g diff --git a/test/inline.go b/test/inline.go index 599d5233e0..d0ebe84aa5 100644 --- a/test/inline.go +++ b/test/inline.go @@ -160,6 +160,19 @@ func switchType(x interface{}) int { // ERROR "can inline switchType" "x does no } } +func inlineRangeIntoMe(data []int) { // ERROR "can inline inlineRangeIntoMe" "data does not escape" + rangeFunc(data, 12) // ERROR "inlining call to rangeFunc" +} + +func rangeFunc(xs []int, b int) int { // ERROR "can inline rangeFunc" "xs does not escape" + for i, x := range xs { + if x == b { + return i + } + } + return -1 +} + type T struct{} func (T) meth(int, int) {} // ERROR "can inline T.meth" diff --git a/test/linkname.dir/linkname1.go b/test/linkname.dir/linkname1.go index c61a0d7d95..7d51b94802 100644 --- a/test/linkname.dir/linkname1.go +++ b/test/linkname.dir/linkname1.go @@ -1,6 +1,6 @@ package x -func indexByte(xs []byte, b byte) int { // ERROR "xs does not escape" +func indexByte(xs []byte, b byte) int { // ERROR "xs does not escape" "can inline indexByte" for i, x := range xs { if x == b { return i From 5c98bcb7d43e1dcf60d3799afc30f4d56e5e3cc4 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Thu, 28 Oct 2021 10:40:54 +0700 Subject: [PATCH 209/406] runtime: fix noopt builder CL 352057 added track argument stack slot liveness, and updated TestTracebackArgs for argument liveness. But when optimization is disabled, all arguments are considered lived. The abiSel does not consider this case and return wrong expected result. To fix this, checking if we are running in a noopt builder and return the correct expected result. Also, skipping TestTracebackArgs in quick mode, since when quick mode run the test without optimization disable. Updates #45728 Change-Id: I3737a1b1a5fa0c711fbb3218205f2f6e34f36260 Reviewed-on: https://go-review.googlesource.com/c/go/+/359196 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le Reviewed-by: Cherry Mui TryBot-Result: Go Bot --- src/runtime/traceback_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/runtime/traceback_test.go b/src/runtime/traceback_test.go index de9580ae53..0333b85c56 100644 --- a/src/runtime/traceback_test.go +++ b/src/runtime/traceback_test.go @@ -7,15 +7,23 @@ package runtime_test import ( "bytes" "internal/goexperiment" + "internal/testenv" "runtime" + "strings" "testing" ) var testTracebackArgsBuf [1000]byte func TestTracebackArgs(t *testing.T) { - abiSel := func(x, y string) string { // select expected output based on ABI - if goexperiment.RegabiArgs { + if *flagQuick { + t.Skip("-quick") + } + optimized := !strings.HasSuffix(testenv.Builder(), "-noopt") + 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 { return x } return y From a5a423e0e809e451b06771eb6a7b95cc9255f9fd Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Wed, 27 Oct 2021 09:19:50 -0400 Subject: [PATCH 210/406] go/parser: fix parsing of array or slice constraint types Now that we allow eliding 'interface' from constraint types, we need to be a bit more careful about not consuming a '[' when parsing the next expression after "type T [". We want to check if the next expression is an identifier not followed by ']', in which case we're in a generic type, but need to avoid parsing index or slice expressions. Such expressions aren't valid array lengths because these expressions are never constant, so when encountering a following '[' we can instead assume that this is a type parameter field with array or slice type constraint. Test cases are added for the related issues #49174 and #49175, along with a flag to enable tracing error tests. For #49174 For #49175 Change-Id: I0476ef20c4c134ac537118272f20caaf123ee70e Reviewed-on: https://go-review.googlesource.com/c/go/+/359134 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/parser/error_test.go | 6 ++ src/go/parser/parser.go | 81 +++++++++++++++++---------- src/go/parser/testdata/issue49174.go2 | 8 +++ src/go/parser/testdata/issue49175.go2 | 13 +++++ 4 files changed, 79 insertions(+), 29 deletions(-) create mode 100644 src/go/parser/testdata/issue49174.go2 create mode 100644 src/go/parser/testdata/issue49175.go2 diff --git a/src/go/parser/error_test.go b/src/go/parser/error_test.go index f35ba0b501..a45c897da3 100644 --- a/src/go/parser/error_test.go +++ b/src/go/parser/error_test.go @@ -23,6 +23,7 @@ package parser import ( + "flag" "go/internal/typeparams" "go/scanner" "go/token" @@ -33,6 +34,8 @@ import ( "testing" ) +var traceErrs = flag.Bool("trace_errs", false, "whether to enable tracing for error tests") + const testdata = "testdata" // getFile assumes that each filename occurs at most once @@ -192,6 +195,9 @@ func TestErrors(t *testing.T) { if !strings.HasSuffix(name, ".go2") { mode |= typeparams.DisallowParsing } + if *traceErrs { + mode |= Trace + } checkErrors(t, filepath.Join(testdata, name), nil, mode, true) } }) diff --git a/src/go/parser/parser.go b/src/go/parser/parser.go index 4f7a498780..999663b98c 100644 --- a/src/go/parser/parser.go +++ b/src/go/parser/parser.go @@ -455,10 +455,10 @@ func (p *parser) parseExprList() (list []ast.Expr) { defer un(trace(p, "ExpressionList")) } - list = append(list, p.checkExpr(p.parseExpr())) + list = append(list, p.checkExpr(p.parseExpr(nil))) for p.tok == token.COMMA { p.next() - list = append(list, p.checkExpr(p.parseExpr())) + list = append(list, p.checkExpr(p.parseExpr(nil))) } return @@ -996,7 +996,7 @@ func (p *parser) parseMethodSpec() *ast.Field { lbrack := p.pos p.next() p.exprLev++ - x := p.parseExpr() + x := p.parseExpr(nil) p.exprLev-- if name0, _ := x.(*ast.Ident); name0 != nil && p.tok != token.COMMA && p.tok != token.RBRACK { // generic method m[T any] @@ -1538,7 +1538,7 @@ func (p *parser) parseValue() ast.Expr { return p.parseLiteralValue(nil) } - x := p.checkExpr(p.parseExpr()) + x := p.checkExpr(p.parseExpr(nil)) return x } @@ -1648,12 +1648,14 @@ func (p *parser) checkExprOrType(x ast.Expr) ast.Expr { return x } -func (p *parser) parsePrimaryExpr() (x ast.Expr) { +func (p *parser) parsePrimaryExpr(x ast.Expr) ast.Expr { if p.trace { defer un(trace(p, "PrimaryExpr")) } - x = p.parseOperand() + if x == nil { + x = p.parseOperand() + } for { switch p.tok { case token.PERIOD: @@ -1689,18 +1691,18 @@ func (p *parser) parsePrimaryExpr() (x ast.Expr) { switch t.(type) { case *ast.BadExpr, *ast.Ident, *ast.SelectorExpr: if p.exprLev < 0 { - return + return x } // x is possibly a composite literal type case *ast.IndexExpr, *ast.IndexListExpr: if p.exprLev < 0 { - return + return x } // x is possibly a composite literal type case *ast.ArrayType, *ast.StructType, *ast.MapType: // x is a composite literal type default: - return + return x } if t != x { p.error(t.Pos(), "cannot parenthesize type in composite literal") @@ -1708,7 +1710,7 @@ func (p *parser) parsePrimaryExpr() (x ast.Expr) { } x = p.parseLiteralValue(x) default: - return + return x } } } @@ -1779,7 +1781,7 @@ func (p *parser) parseUnaryExpr() ast.Expr { return &ast.StarExpr{Star: pos, X: p.checkExprOrType(x)} } - return p.parsePrimaryExpr() + return p.parsePrimaryExpr(nil) } func (p *parser) tokPrec() (token.Token, int) { @@ -1790,19 +1792,21 @@ func (p *parser) tokPrec() (token.Token, int) { return tok, tok.Precedence() } -func (p *parser) parseBinaryExpr(prec1 int) ast.Expr { +func (p *parser) parseBinaryExpr(x ast.Expr, prec1 int) ast.Expr { if p.trace { defer un(trace(p, "BinaryExpr")) } - x := p.parseUnaryExpr() + if x == nil { + x = p.parseUnaryExpr() + } for { op, oprec := p.tokPrec() if oprec < prec1 { return x } pos := p.expect(op) - y := p.parseBinaryExpr(oprec + 1) + y := p.parseBinaryExpr(nil, oprec+1) x = &ast.BinaryExpr{X: p.checkExpr(x), OpPos: pos, Op: op, Y: p.checkExpr(y)} } } @@ -1810,18 +1814,18 @@ func (p *parser) parseBinaryExpr(prec1 int) ast.Expr { // The result may be a type or even a raw type ([...]int). Callers must // check the result (using checkExpr or checkExprOrType), depending on // context. -func (p *parser) parseExpr() ast.Expr { +func (p *parser) parseExpr(lhs ast.Expr) ast.Expr { if p.trace { defer un(trace(p, "Expression")) } - return p.parseBinaryExpr(token.LowestPrec + 1) + return p.parseBinaryExpr(lhs, token.LowestPrec+1) } func (p *parser) parseRhs() ast.Expr { old := p.inRhs p.inRhs = true - x := p.checkExpr(p.parseExpr()) + x := p.checkExpr(p.parseExpr(nil)) p.inRhs = old return x } @@ -1829,7 +1833,7 @@ func (p *parser) parseRhs() ast.Expr { func (p *parser) parseRhsOrType() ast.Expr { old := p.inRhs p.inRhs = true - x := p.checkExprOrType(p.parseExpr()) + x := p.checkExprOrType(p.parseExpr(nil)) p.inRhs = old return x } @@ -2539,6 +2543,10 @@ func (p *parser) parseValueSpec(doc *ast.CommentGroup, _ token.Pos, keyword toke } func (p *parser) parseGenericType(spec *ast.TypeSpec, openPos token.Pos, name0 *ast.Ident) { + if p.trace { + defer un(trace(p, "parseGenericType")) + } + list := p.parseParameterList(name0, token.RBRACK) closePos := p.expect(token.RBRACK) spec.TypeParams = &ast.FieldList{Opening: openPos, List: list, Closing: closePos} @@ -2563,19 +2571,34 @@ func (p *parser) parseTypeSpec(doc *ast.CommentGroup, _ token.Pos, _ token.Token lbrack := p.pos p.next() if p.tok == token.IDENT { - // array type or generic type [T any] - p.exprLev++ - x := p.parseExpr() - p.exprLev-- - if name0, _ := x.(*ast.Ident); p.allowGenerics() && name0 != nil && p.tok != token.RBRACK { - // generic type [T any]; + // array type or generic type: [name0... + name0 := p.parseIdent() + + if p.allowGenerics() && p.tok == token.LBRACK { + // Index or slice expressions are not valid array lengths, so we can + // parse as though we are in a generic type with array or slice + // constraint: [T [... p.parseGenericType(spec, lbrack, name0) + break } else { - // array type - // TODO(rfindley) should resolve all identifiers in x. - p.expect(token.RBRACK) - elt := p.parseType() - spec.Type = &ast.ArrayType{Lbrack: lbrack, Len: x, Elt: elt} + + // We may still have either an array type or generic type -- check if + // name0 is the entire expr. + p.exprLev++ + lhs := p.parsePrimaryExpr(name0) + x := p.parseExpr(lhs) + p.exprLev-- + + if name1, _ := x.(*ast.Ident); p.allowGenerics() && name1 != nil && p.tok != token.RBRACK { + // generic type [T any]; + p.parseGenericType(spec, lbrack, name1) + } else { + // array type + // TODO(rfindley) should resolve all identifiers in x. + p.expect(token.RBRACK) + elt := p.parseType() + spec.Type = &ast.ArrayType{Lbrack: lbrack, Len: x, Elt: elt} + } } } else { // array type diff --git a/src/go/parser/testdata/issue49174.go2 b/src/go/parser/testdata/issue49174.go2 new file mode 100644 index 0000000000..77c195083f --- /dev/null +++ b/src/go/parser/testdata/issue49174.go2 @@ -0,0 +1,8 @@ +// Copyright 2021 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 p + +func _[_ []int | int]() {} +func _[_ int | []int]() {} diff --git a/src/go/parser/testdata/issue49175.go2 b/src/go/parser/testdata/issue49175.go2 new file mode 100644 index 0000000000..a5ad30f14c --- /dev/null +++ b/src/go/parser/testdata/issue49175.go2 @@ -0,0 +1,13 @@ +// Copyright 2021 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 p + +type _[_ []t]t +type _[_ [1]t]t + +func _[_ []t]() {} +func _[_ [1]t]() {} + +type t [t /* ERROR "all type parameters must be named" */ [0]]t From 925ea2dfc4911188d47cca5c5534916e39dc1463 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Wed, 27 Oct 2021 11:14:24 -0400 Subject: [PATCH 211/406] go/types, types2, go/ast, go/parser: remove support for type lists This is a rough port of CL 354131 to go/* libraries, though in practice I just tried to reconcile any places where the phrase "type list" occurred in the source. This resulted in adjusting quite a bit more code than initially expected, including a few lingering cases in the compiler. Change-Id: Ie62a9e1aeb831b73931bc4c78bbb6ccb24f53fb0 Reviewed-on: https://go-review.googlesource.com/c/go/+/359135 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/types2/interface.go | 2 +- src/cmd/compile/internal/types2/predicates.go | 2 +- .../types2/testdata/check/typeinst2.go2 | 10 ++--- .../types2/testdata/examples/types.go2 | 4 +- .../types2/testdata/fixedbugs/issue39711.go2 | 4 +- src/cmd/gofmt/testdata/typeparams.golden | 2 +- src/cmd/gofmt/testdata/typeparams.input | 2 +- src/go/ast/ast.go | 8 +--- src/go/parser/parser.go | 12 ------ src/go/parser/resolver.go | 13 ++---- src/go/parser/short_test.go | 3 +- src/go/parser/testdata/interface.go2 | 8 +--- src/go/parser/testdata/linalg.go2 | 16 ++++---- .../parser/testdata/resolution/typeparams.go2 | 4 +- src/go/printer/nodes.go | 34 +++------------- src/go/printer/testdata/generics.golden | 10 +---- src/go/printer/testdata/generics.input | 8 +--- src/go/types/call.go | 1 + src/go/types/exprstring.go | 23 +---------- src/go/types/exprstring_test.go | 9 +---- src/go/types/interface.go | 40 +------------------ src/go/types/predicates.go | 2 +- src/go/types/testdata/check/issues.go2 | 14 +++---- src/go/types/testdata/check/typeinst2.go2 | 13 +++--- .../types/testdata/examples/constraints.go2 | 12 ------ src/go/types/testdata/examples/types.go2 | 4 +- .../types/testdata/fixedbugs/issue39711.go2 | 4 +- src/go/types/union.go | 20 ++-------- 28 files changed, 65 insertions(+), 219 deletions(-) diff --git a/src/cmd/compile/internal/types2/interface.go b/src/cmd/compile/internal/types2/interface.go index 048fcab024..96c92ccaec 100644 --- a/src/cmd/compile/internal/types2/interface.go +++ b/src/cmd/compile/internal/types2/interface.go @@ -116,7 +116,7 @@ func (check *Checker) interfaceType(ityp *Interface, iface *syntax.InterfaceType } // f.Name != nil - // We have a method with name f.Name, or a type of a type list (f.Name.Value == "type"). + // We have a method with name f.Name. name := f.Name.Value if name == "_" { if check.conf.CompilerErrorMessages { diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go index 409715ad9d..380fb6489c 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -44,7 +44,7 @@ func isNumeric(typ Type) bool { return is(typ, IsNumeric) } func isString(typ Type) bool { return is(typ, IsString) } // Note that if typ is a type parameter, isInteger(typ) || isFloat(typ) does not -// produce the expected result because a type list that contains both an integer +// produce the expected result because a type set that contains both an integer // and a floating-point type is neither (all) integers, nor (all) floats. // Use isIntegerOrFloat instead. func isIntegerOrFloat(typ Type) bool { return is(typ, IsInteger|IsFloat) } diff --git a/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 b/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 index 5529bd093d..cd56c81bb9 100644 --- a/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/typeinst2.go2 @@ -172,7 +172,7 @@ type _ interface { ~struct{f int} | ~struct{g int} | ~struct /* ERROR overlapping terms */ {f int} } -// Interface type lists can contain any type, incl. *Named types. +// Interface term lists can contain any type, incl. *Named types. // Verify that we use the underlying type to compute the operational type. type MyInt int func add1[T interface{MyInt}](x T) T { @@ -184,9 +184,9 @@ func double[T interface{MyInt|MyString}](x T) T { return x + x } -// Embedding of interfaces with type lists leads to interfaces -// with type lists that are the intersection of the embedded -// type lists. +// Embedding of interfaces with term lists leads to interfaces +// with term lists that are the intersection of the embedded +// term lists. type E0 interface { ~int | ~bool | ~string @@ -277,4 +277,4 @@ func _[T none]() { _ = gg[T] _ = hh[int] _ = hh[T] -} \ No newline at end of file +} diff --git a/src/cmd/compile/internal/types2/testdata/examples/types.go2 b/src/cmd/compile/internal/types2/testdata/examples/types.go2 index 72b74cee01..077fcfdbb7 100644 --- a/src/cmd/compile/internal/types2/testdata/examples/types.go2 +++ b/src/cmd/compile/internal/types2/testdata/examples/types.go2 @@ -276,8 +276,8 @@ func _() { // Type parameters are never const types, i.e., it's // not possible to declare a constant of type parameter type. -// (If a type list contains just a single const type, we could -// allow it, but such type lists don't make much sense in the +// (If a type set contains just a single const type, we could +// allow it, but such type sets don't make much sense in the // first place.) func _[T interface{~int|~float64}]() { // not valid diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39711.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39711.go2 index 85eb0a78fe..8f31012354 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39711.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue39711.go2 @@ -4,10 +4,10 @@ package p -// Do not report a duplicate type error for this type list. +// Do not report a duplicate type error for this term list. // (Check types after interfaces have been completed.) type _ interface { // TODO(gri) Once we have full type sets we can enable this again. - // Fow now we don't permit interfaces in type lists. + // Fow now we don't permit interfaces in term lists. // type interface{ Error() string }, interface{ String() string } } diff --git a/src/cmd/gofmt/testdata/typeparams.golden b/src/cmd/gofmt/testdata/typeparams.golden index f71bd130db..d57a2ba59b 100644 --- a/src/cmd/gofmt/testdata/typeparams.golden +++ b/src/cmd/gofmt/testdata/typeparams.golden @@ -21,7 +21,7 @@ func f[P1, P2, P3 any](x1 P1, x2 P2, x3 P3) struct{} func f[P interface{}](x P) func f[P1, P2, P3 interface { m1(P1) - type P2, P3 + ~P2 | ~P3 }](x1 P1, x2 P2, x3 P3) struct{} func f[P any](T1[P], T2[P]) T3[P] diff --git a/src/cmd/gofmt/testdata/typeparams.input b/src/cmd/gofmt/testdata/typeparams.input index 5d4c53d9f7..775cf9eb7b 100644 --- a/src/cmd/gofmt/testdata/typeparams.input +++ b/src/cmd/gofmt/testdata/typeparams.input @@ -19,7 +19,7 @@ func f[P any](x P) func f[P1, P2, P3 any](x1 P1, x2 P2, x3 P3) struct{} func f[P interface{}](x P) -func f[P1, P2, P3 interface{ m1(P1); type P2, P3 }](x1 P1, x2 P2, x3 P3) struct{} +func f[P1, P2, P3 interface{ m1(P1); ~P2|~P3 }](x1 P1, x2 P2, x3 P3) struct{} func f[P any](T1[P], T2[P]) T3[P] func (x T[P]) m() diff --git a/src/go/ast/ast.go b/src/go/ast/ast.go index 38b6de57d3..bc140473d5 100644 --- a/src/go/ast/ast.go +++ b/src/go/ast/ast.go @@ -193,14 +193,10 @@ func isDirective(c string) bool { // in a signature. // Field.Names is nil for unnamed parameters (parameter lists which only contain types) // and embedded struct fields. In the latter case, the field name is the type name. -// Field.Names contains a single name "type" for elements of interface type lists. -// Types belonging to the same type list share the same "type" identifier which also -// records the position of that keyword. -// type Field struct { Doc *CommentGroup // associated documentation; or nil - Names []*Ident // field/method/(type) parameter names, or type "type"; or nil - Type Expr // field/method/parameter type, type list type; or nil + Names []*Ident // field/method/(type) parameter names; or nil + Type Expr // field/method/parameter type; or nil Tag *BasicLit // field tag; or nil Comment *CommentGroup // line comments; or nil } diff --git a/src/go/parser/parser.go b/src/go/parser/parser.go index 999663b98c..792fe4141c 100644 --- a/src/go/parser/parser.go +++ b/src/go/parser/parser.go @@ -1128,18 +1128,6 @@ parseElements: p.expectSemi() comment := p.lineComment list = append(list, &ast.Field{Type: typ, Comment: comment}) - case p.tok == token.TYPE && p.allowGenerics(): - // TODO(rfindley): remove TypeList syntax and refactor the clauses above. - - // all types in a type list share the same field name "type" - // (since type is a keyword, a Go program cannot have that field name) - name := []*ast.Ident{{NamePos: p.pos, Name: "type"}} - p.next() - // add each type as a field named "type" - for _, typ := range p.parseTypeList() { - list = append(list, &ast.Field{Names: name, Type: typ}) - } - p.expectSemi() case p.allowGenerics(): if t := p.tryIdentOrType(); t != nil { typ := p.embeddedElem(t) diff --git a/src/go/parser/resolver.go b/src/go/parser/resolver.go index 527f1691bd..54732a7fd6 100644 --- a/src/go/parser/resolver.go +++ b/src/go/parser/resolver.go @@ -117,12 +117,6 @@ func (r *resolver) closeLabelScope() { func (r *resolver) declare(decl, data interface{}, scope *ast.Scope, kind ast.ObjKind, idents ...*ast.Ident) { for _, ident := range idents { - // "type" is used for type lists in interfaces, and is otherwise an invalid - // identifier. The 'type' identifier is also artificially duplicated in the - // type list, so could cause panics below if we were to proceed. - if ident.Name == "type" { - continue - } assert(ident.Obj == nil, "identifier already declared or resolved") obj := ast.NewObj(kind, ident.Name) // remember the corresponding declaration for redeclaration @@ -188,10 +182,9 @@ func (r *resolver) resolve(ident *ast.Ident, collectUnresolved bool) { if ident.Obj != nil { panic(fmt.Sprintf("%s: identifier %s already declared or resolved", r.handle.Position(ident.Pos()), ident.Name)) } - // '_' and 'type' should never refer to existing declarations: '_' because it - // has special handling in the spec, and 'type' because it is a keyword, and - // only valid in an interface type list. - if ident.Name == "_" || ident.Name == "type" { + // '_' should never refer to existing declarations, because it has special + // handling in the spec. + if ident.Name == "_" { return } for s := r.topScope; s != nil; s = s.Outer { diff --git a/src/go/parser/short_test.go b/src/go/parser/short_test.go index bfc6f6714b..20450bfe8e 100644 --- a/src/go/parser/short_test.go +++ b/src/go/parser/short_test.go @@ -119,8 +119,7 @@ var validWithTParamsOnly = []string{ `package p; func _(T[P] /* ERROR "missing element type" */ ) T[P]`, `package p; type _ struct{ T[P] /* ERROR "missing element type" */ }`, `package p; type _ struct{ T[struct /* ERROR "expected expression" */ {a, b, c int}] }`, - `package p; type _ interface{type /* ERROR "expected '}', found 'type'" */ int}`, - `package p; type _ interface{type /* ERROR "expected '}', found 'type'" */ int, float32; type bool; m(); type string;}`, + `package p; type _ interface{int| /* ERROR "expected ';'" */ float32; bool; m(); string;}`, `package p; type I1[T any /* ERROR "expected ']', found any" */ ] interface{}; type I2 interface{ I1[int] }`, `package p; type I1[T any /* ERROR "expected ']', found any" */ ] interface{}; type I2[T any] interface{ I1[T] }`, `package p; type _ interface { f[ /* ERROR "expected ';', found '\['" */ T any]() }`, diff --git a/src/go/parser/testdata/interface.go2 b/src/go/parser/testdata/interface.go2 index b399d75148..2ed9339c52 100644 --- a/src/go/parser/testdata/interface.go2 +++ b/src/go/parser/testdata/interface.go2 @@ -4,16 +4,13 @@ // This file contains test cases for interfaces containing // constraint elements. -// -// For now, we accept both ordinary type lists and the -// more complex constraint elements. package p type _ interface { m() - type int - type int, string + ~int + ~int|string E } @@ -31,7 +28,6 @@ type _ interface { T[int, string] | string int | ~T[string, struct{}] ~int | ~string - type bool, int, float64 } type _ interface { diff --git a/src/go/parser/testdata/linalg.go2 b/src/go/parser/testdata/linalg.go2 index fba0d02eb2..7ccb19c08d 100644 --- a/src/go/parser/testdata/linalg.go2 +++ b/src/go/parser/testdata/linalg.go2 @@ -9,10 +9,10 @@ import "math" // Numeric is type bound that matches any numeric type. // It would likely be in a constraints package in the standard library. type Numeric interface { - type int, int8, int16, int32, int64, - uint, uint8, uint16, uint32, uint64, uintptr, - float32, float64, - complex64, complex128 + ~int|~int8|~int16|~int32|~int64| + ~uint|~uint8|~uint16|~uint32|~uint64|~uintptr| + ~float32|~float64| + ~complex64|~complex128 } func DotProduct[T Numeric](s1, s2 []T) T { @@ -42,14 +42,14 @@ func AbsDifference[T NumericAbs](a, b T) T { // OrderedNumeric is a type bound that matches numeric types that support the < operator. type OrderedNumeric interface { - type int, int8, int16, int32, int64, - uint, uint8, uint16, uint32, uint64, uintptr, - float32, float64 + ~int|~int8|~int16|~int32|~int64| + ~uint|~uint8|~uint16|~uint32|~uint64|~uintptr| + ~float32|~float64 } // Complex is a type bound that matches the two complex types, which do not have a < operator. type Complex interface { - type complex64, complex128 + ~complex64|~complex128 } // OrderedAbs is a helper type that defines an Abs method for diff --git a/src/go/parser/testdata/resolution/typeparams.go2 b/src/go/parser/testdata/resolution/typeparams.go2 index 0ffecd69b5..8c243afda7 100644 --- a/src/go/parser/testdata/resolution/typeparams.go2 +++ b/src/go/parser/testdata/resolution/typeparams.go2 @@ -15,7 +15,7 @@ type Pair /* =@Pair */ [L /* =@L */, R /* =@R */ any] struct { var _ = Pair /* @Pair */ [int, string]{} type Addable /* =@Addable */ interface { - type int64, float64 + ~int64|~float64 } func Add /* =@AddDecl */[T /* =@T */ Addable /* @Addable */](l /* =@l */, r /* =@r */ T /* @T */) T /* @T */ { @@ -30,7 +30,7 @@ type Receiver /* =@Receiver */[P /* =@P */ any] struct {} // parameter below. func (r /* =@recv */ Receiver /* @Receiver */ [P]) m() P {} -func f /* =@f */[T1 /* =@T1 */ interface{type []T2 /* @T2 */}, T2 /* =@T2 */ any]( +func f /* =@f */[T1 /* =@T1 */ interface{~[]T2 /* @T2 */}, T2 /* =@T2 */ any]( x /* =@x */ T1 /* @T1 */, T1 /* =@T1_duplicate */ y, // Note that this is a bug: // the duplicate T1 should // not be allowed. diff --git a/src/go/printer/nodes.go b/src/go/printer/nodes.go index 567b2339b4..19d4ab6663 100644 --- a/src/go/printer/nodes.go +++ b/src/go/printer/nodes.go @@ -471,17 +471,9 @@ func (p *printer) fieldList(fields *ast.FieldList, isStruct, isIncomplete bool) p.expr(f.Type) } else { // interface if len(f.Names) > 0 { - // type list type or method - name := f.Names[0] // "type" or method name + name := f.Names[0] // method name p.expr(name) - if name.Name == "type" { - // type list type - p.print(blank) - p.expr(f.Type) - } else { - // method - p.signature(f.Type.(*ast.FuncType)) // don't print "func" - } + p.signature(f.Type.(*ast.FuncType)) // don't print "func" } else { // embedded interface p.expr(f.Type) @@ -568,24 +560,10 @@ func (p *printer) fieldList(fields *ast.FieldList, isStruct, isIncomplete bool) p.setComment(f.Doc) p.recordLine(&line) if name != nil { - // type list type or method - if name.Name == "type" { - // type list type - if name == prev { - // type is part of a list of types - p.print(token.COMMA, blank) - } else { - // type starts a new list of types - p.print(name, blank) - } - p.expr(f.Type) - prev = name - } else { - // method - p.expr(name) - p.signature(f.Type.(*ast.FuncType)) // don't print "func" - prev = nil - } + // method + p.expr(name) + p.signature(f.Type.(*ast.FuncType)) // don't print "func" + prev = nil } else { // embedded interface p.expr(f.Type) diff --git a/src/go/printer/testdata/generics.golden b/src/go/printer/testdata/generics.golden index 31ab7716dd..3d95eda5b2 100644 --- a/src/go/printer/testdata/generics.golden +++ b/src/go/printer/testdata/generics.golden @@ -22,7 +22,7 @@ func f[P1, P2, P3 any](x1 P1, x2 P2, x3 P3) struct{} func f[P interface{}](x P) func f[P1, P2, P3 interface { m1(P1) - type P2, P3 + ~P2 | ~P3 }](x1 P1, x2 P2, x3 P3) struct{} func f[P any](T1[P], T2[P]) T3[P] @@ -35,14 +35,6 @@ func _() { _ = []T[P]{} } -// properly format one-line type lists -// TODO(rfindley): remove support for type lists -type _ interface{ type a } - -type _ interface { - type a, b, c -} - // type constraint literals with elided interfaces func _[P ~int, Q int | string]() {} func _[P struct{ f int }, Q *P]() {} diff --git a/src/go/printer/testdata/generics.input b/src/go/printer/testdata/generics.input index 11431c5a0a..746dfdd235 100644 --- a/src/go/printer/testdata/generics.input +++ b/src/go/printer/testdata/generics.input @@ -20,7 +20,7 @@ func f[P any](x P) func f[P1, P2, P3 any](x1 P1, x2 P2, x3 P3) struct{} func f[P interface{}](x P) -func f[P1, P2, P3 interface{ m1(P1); type P2, P3 }](x1 P1, x2 P2, x3 P3) struct{} +func f[P1, P2, P3 interface{ m1(P1); ~P2|~P3 }](x1 P1, x2 P2, x3 P3) struct{} func f[P any](T1[P], T2[P]) T3[P] func (x T[P]) m() @@ -32,12 +32,6 @@ func _() { _ = []T[P]{} } -// properly format one-line type lists -// TODO(rfindley): remove support for type lists -type _ interface { type a } - -type _ interface { type a,b,c } - // type constraint literals with elided interfaces func _[P ~int, Q int | string]() {} func _[P struct{f int}, Q *P]() {} diff --git a/src/go/types/call.go b/src/go/types/call.go index 4731c69619..6894f1c182 100644 --- a/src/go/types/call.go +++ b/src/go/types/call.go @@ -141,6 +141,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind { } if t := asInterface(T); t != nil { if !t.IsMethodSet() { + // TODO(rfindley): remove the phrase "type list" from this error. check.errorf(call, _Todo, "cannot use interface %s in conversion (contains type list or is comparable)", T) break } diff --git a/src/go/types/exprstring.go b/src/go/types/exprstring.go index 06e7a9dcb4..aa4f403c1f 100644 --- a/src/go/types/exprstring.go +++ b/src/go/types/exprstring.go @@ -145,29 +145,8 @@ func WriteExpr(buf *bytes.Buffer, x ast.Expr) { writeSigExpr(buf, x) case *ast.InterfaceType: - // separate type list types from method list - // TODO(gri) we can get rid of this extra code if writeExprList does the separation - var types []ast.Expr - var methods []*ast.Field - for _, f := range x.Methods.List { - if len(f.Names) > 1 && f.Names[0].Name == "type" { - // type list type - types = append(types, f.Type) - } else { - // method or embedded interface - methods = append(methods, f) - } - } - buf.WriteString("interface{") - writeFieldList(buf, methods, "; ", true) - if len(types) > 0 { - if len(methods) > 0 { - buf.WriteString("; ") - } - buf.WriteString("type ") - writeExprList(buf, types) - } + writeFieldList(buf, x.Methods.List, "; ", true) buf.WriteByte('}') case *ast.MapType: diff --git a/src/go/types/exprstring_test.go b/src/go/types/exprstring_test.go index a67f6a978a..27cd532c97 100644 --- a/src/go/types/exprstring_test.go +++ b/src/go/types/exprstring_test.go @@ -36,15 +36,8 @@ var testExprs = []testEntry{ dup("func(int, float32) string"), dup("interface{m()}"), dup("interface{m() string; n(x int)}"), - dup("interface{type int}"), + dup("interface{~int}"), - // The following exprs do not get formatted correctly: each element in the - // type list is printed on a separate line. This is left as a placeholder - // until type lists are removed. - // TODO(rfindley): remove this once type lists are gone. - // dup("interface{type int, float64, string}"), - // dup("interface{type int; m()}"), - // dup("interface{type int, float64, string; m() string; n(x int)}"), dup("map[string]int"), dup("chan E"), dup("<-chan E"), diff --git a/src/go/types/interface.go b/src/go/types/interface.go index 3d5573373f..c170ed4a60 100644 --- a/src/go/types/interface.go +++ b/src/go/types/interface.go @@ -142,9 +142,6 @@ func (t *Interface) String() string { return TypeString(t, nil) } // Implementation func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, def *Named) { - var tlist []ast.Expr - var tname *ast.Ident // "type" name of first entry in a type list declaration - addEmbedded := func(pos token.Pos, typ Type) { ityp.embeddeds = append(ityp.embeddeds, typ) if ityp.embedPos == nil { @@ -158,41 +155,15 @@ func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, d addEmbedded(f.Type.Pos(), parseUnion(check, flattenUnion(nil, f.Type))) continue } + // f.Name != nil - // We have a method with name f.Names[0], or a type - // of a type list (name.Name == "type"). - // (The parser ensures that there's only one method - // and we don't care if a constructed AST has more.) + // We have a method with name f.Names[0]. name := f.Names[0] if name.Name == "_" { check.errorf(name, _BlankIfaceMethod, "invalid method name _") continue // ignore } - // TODO(rfindley) Remove type list handling once the parser doesn't accept type lists anymore. - if name.Name == "type" { - // Report an error for the first type list per interface - // if we don't allow type lists, but continue. - if !allowTypeLists && tlist == nil { - check.softErrorf(name, _Todo, "use generalized embedding syntax instead of a type list") - } - // For now, collect all type list entries as if it - // were a single union, where each union element is - // of the form ~T. - // TODO(rfindley) remove once we disallow type lists - op := new(ast.UnaryExpr) - op.Op = token.TILDE - op.X = f.Type - tlist = append(tlist, op) - // Report an error if we have multiple type lists in an - // interface, but only if they are permitted in the first place. - if allowTypeLists && tname != nil && tname != name { - check.errorf(name, _Todo, "cannot have multiple type lists in an interface") - } - tname = name - continue - } - typ := check.typ(f.Type) sig, _ := typ.(*Signature) if sig == nil { @@ -225,13 +196,6 @@ func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, d ityp.methods = append(ityp.methods, m) } - // type constraints - if tlist != nil { - // TODO(rfindley): this differs from types2 due to the use of Pos() below, - // which should actually be on the ~. Confirm that this position is correct. - addEmbedded(tlist[0].Pos(), parseUnion(check, tlist)) - } - // All methods and embedded elements for this interface are collected; // i.e., this interface may be used in a type set computation. ityp.complete = true diff --git a/src/go/types/predicates.go b/src/go/types/predicates.go index a5d4be9bcc..b687c151c7 100644 --- a/src/go/types/predicates.go +++ b/src/go/types/predicates.go @@ -45,7 +45,7 @@ func isNumeric(typ Type) bool { return is(typ, IsNumeric) } func isString(typ Type) bool { return is(typ, IsString) } // Note that if typ is a type parameter, isInteger(typ) || isFloat(typ) does not -// produce the expected result because a type list that contains both an integer +// produce the expected result because a type set that contains both an integer // and a floating-point type is neither (all) integers, nor (all) floats. // Use isIntegerOrFloat instead. func isIntegerOrFloat(typ Type) bool { return is(typ, IsInteger|IsFloat) } diff --git a/src/go/types/testdata/check/issues.go2 b/src/go/types/testdata/check/issues.go2 index c46a34e2eb..6a93bcc9ac 100644 --- a/src/go/types/testdata/check/issues.go2 +++ b/src/go/types/testdata/check/issues.go2 @@ -53,8 +53,8 @@ func _() { } // When a type parameter is used as an argument to instantiate a parameterized -// type with a type list constraint, all of the type argument's types in its -// bound, but at least one (!), must be in the type list of the bound of the +// type with a type set constraint, all of the type argument's types in its +// bound, but at least one (!), must be in the type set of the bound of the // corresponding parameterized type's type parameter. type T1[P interface{~uint}] struct{} @@ -152,7 +152,7 @@ type inf2 /* ERROR illegal cycle */ [T any] struct{ inf2[T] } // The implementation of conversions T(x) between integers and floating-point // numbers checks that both T and x have either integer or floating-point // type. When the type of T or x is a type parameter, the respective simple -// predicate disjunction in the implementation was wrong because if a type list +// predicate disjunction in the implementation was wrong because if a term list // contains both an integer and a floating-point type, the type parameter is // neither an integer or a floating-point number. func convert[T1, T2 interface{~int | ~uint | ~float32}](v T1) T2 { @@ -185,13 +185,13 @@ func _[T interface{}, PT interface{~*T}] (x T) PT { return &x } -// Indexing of generic types containing type parameters in their type list: +// Indexing of generic types containing type parameters in their term list: func at[T interface{ ~[]E }, E interface{}](x T, i int) E { return x[i] } // A generic type inside a function acts like a named type. Its underlying -// type is itself, its "operational type" is defined by the type list in +// type is itself, its "operational type" is defined by the term list in // the tybe bound, if any. func _[T interface{~int}](x T) { type myint int @@ -224,9 +224,9 @@ func _[T interface{ ~func() }](f T) { go f() } -// We must compare against the underlying type of type list entries +// We must compare against the underlying type of term list entries // when checking if a constraint is satisfied by a type. The under- -// lying type of each type list entry must be computed after the +// lying type of each term list entry must be computed after the // interface has been instantiated as its typelist may contain a // type parameter that was substituted with a defined type. // Test case from an (originally) failing example. diff --git a/src/go/types/testdata/check/typeinst2.go2 b/src/go/types/testdata/check/typeinst2.go2 index 88913785c8..37d32263d4 100644 --- a/src/go/types/testdata/check/typeinst2.go2 +++ b/src/go/types/testdata/check/typeinst2.go2 @@ -159,10 +159,7 @@ type _ interface { ~rune } -// Interface type lists may contain each type at most once. -// (If there are multiple lists, we assume the author intended -// for them to be all in a single list, and we report the error -// as well.) +// Type sets may contain each type at most once. type _ interface { ~int|~ /* ERROR overlapping terms ~int */ int ~int|int /* ERROR overlapping terms int */ @@ -173,7 +170,7 @@ type _ interface { ~struct{f int} | ~struct{g int} | ~ /* ERROR overlapping terms */ struct {f int} } -// Interface type lists can contain any type, incl. *Named types. +// Interface term lists can contain any type, incl. *Named types. // Verify that we use the underlying type to compute the operational type. type MyInt int func add1[T interface{MyInt}](x T) T { @@ -185,9 +182,9 @@ func double[T interface{MyInt|MyString}](x T) T { return x + x } -// Embedding of interfaces with type lists leads to interfaces -// with type lists that are the intersection of the embedded -// type lists. +// Embedding of interfaces with term lists leads to interfaces +// with term lists that are the intersection of the embedded +// term lists. type E0 interface { ~int | ~bool | ~string diff --git a/src/go/types/testdata/examples/constraints.go2 b/src/go/types/testdata/examples/constraints.go2 index ecc75c1a46..4d7f70313a 100644 --- a/src/go/types/testdata/examples/constraints.go2 +++ b/src/go/types/testdata/examples/constraints.go2 @@ -6,18 +6,6 @@ package p -type ( - // Type lists are processed as unions but an error is reported. - // TODO(gri) remove this once the parser doesn't accept type lists anymore. - _ interface{ - type /* ERROR use generalized embedding syntax instead of a type list */ int - } - _ interface{ - type /* ERROR use generalized embedding syntax instead of a type list */ int - type float32 - } -) - type MyInt int type ( diff --git a/src/go/types/testdata/examples/types.go2 b/src/go/types/testdata/examples/types.go2 index 807c03238f..367b73120c 100644 --- a/src/go/types/testdata/examples/types.go2 +++ b/src/go/types/testdata/examples/types.go2 @@ -281,8 +281,8 @@ func _() { // Type parameters are never const types, i.e., it's // not possible to declare a constant of type parameter type. -// (If a type list contains just a single const type, we could -// allow it, but such type lists don't make much sense in the +// (If a type set contains just a single const type, we could +// allow it, but such type sets don't make much sense in the // first place.) func _[T interface {~int|~float64}]() { // not valid diff --git a/src/go/types/testdata/fixedbugs/issue39711.go2 b/src/go/types/testdata/fixedbugs/issue39711.go2 index cf1f90545f..d85fa03fc4 100644 --- a/src/go/types/testdata/fixedbugs/issue39711.go2 +++ b/src/go/types/testdata/fixedbugs/issue39711.go2 @@ -4,10 +4,10 @@ package p -// Do not report a duplicate type error for this type list. +// Do not report a duplicate type error for this term list. // (Check types after interfaces have been completed.) type _ interface { // TODO(rfindley) Once we have full type sets we can enable this again. - // Fow now we don't permit interfaces in type lists. + // Fow now we don't permit interfaces in term lists. // type interface{ Error() string }, interface{ String() string } } diff --git a/src/go/types/union.go b/src/go/types/union.go index 88b2a9ff8f..c715839315 100644 --- a/src/go/types/union.go +++ b/src/go/types/union.go @@ -78,28 +78,16 @@ func parseUnion(check *Checker, tlist []ast.Expr) Type { continue } - x := tlist[i] - pos := x.Pos() - // We may not know the position of x if it was a typechecker- - // introduced ~T term for a type list entry T. Use the position - // of T instead. - // TODO(rfindley) remove this test once we don't support type lists anymore - if !pos.IsValid() { - if op, _ := x.(*ast.UnaryExpr); op != nil { - pos = op.X.Pos() - } - } - u := under(t.typ) f, _ := u.(*Interface) if t.tilde { if f != nil { - check.errorf(x, _Todo, "invalid use of ~ (%s is an interface)", t.typ) + check.errorf(tlist[i], _Todo, "invalid use of ~ (%s is an interface)", t.typ) continue // don't report another error for t } if !Identical(u, t.typ) { - check.errorf(x, _Todo, "invalid use of ~ (underlying type of %s is %s)", t.typ, u) + check.errorf(tlist[i], _Todo, "invalid use of ~ (underlying type of %s is %s)", t.typ, u) continue // don't report another error for t } } @@ -108,14 +96,14 @@ func parseUnion(check *Checker, tlist []ast.Expr) Type { // in the beginning. Embedded interfaces with tilde are excluded above. If we reach // here, we must have at least two terms in the union. if f != nil && !f.typeSet().IsTypeSet() { - check.errorf(atPos(pos), _Todo, "cannot use %s in union (interface contains methods)", t) + check.errorf(tlist[i], _Todo, "cannot use %s in union (interface contains methods)", t) continue // don't report another error for t } // Report overlapping (non-disjoint) terms such as // a|a, a|~a, ~a|~a, and ~a|A (where under(A) == a). if j := overlappingTerm(terms[:i], t); j >= 0 { - check.softErrorf(atPos(pos), _Todo, "overlapping terms %s and %s", t, terms[j]) + check.softErrorf(tlist[i], _Todo, "overlapping terms %s and %s", t, terms[j]) } } }) From 4f1c9aace00277914e080170237ae381e05683c5 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Wed, 27 Oct 2021 11:23:06 -0400 Subject: [PATCH 212/406] go/types: add debugging support for delayed actions This is a port of CL 355871 to go/types. Change-Id: I2dbc3c625c16b545a271a19606ef34ce04a4a6df Reviewed-on: https://go-review.googlesource.com/c/go/+/359136 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/check.go | 39 +++++++++++++++++++++++++++++++++---- src/go/types/decl.go | 2 +- src/go/types/instantiate.go | 2 +- src/go/types/interface.go | 2 +- src/go/types/struct.go | 2 +- src/go/types/typexpr.go | 2 -- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/go/types/check.go b/src/go/types/check.go index 3fc9c03917..2b8ef9f061 100644 --- a/src/go/types/check.go +++ b/src/go/types/check.go @@ -76,6 +76,28 @@ type dotImportKey struct { name string } +// An action describes a (delayed) action. +type action struct { + f func() // action to be executed + desc *actionDesc // action description; may be nil, requires debug to be set +} + +// If debug is set, describef sets a printf-formatted description for action a. +// Otherwise, it is a no-op. +func (a *action) describef(pos positioner, format string, args ...interface{}) { + if debug { + a.desc = &actionDesc{pos, format, args} + } +} + +// An actionDesc provides information on an action. +// For debugging only. +type actionDesc struct { + pos positioner + format string + args []interface{} +} + // A Checker maintains the state of the type checker. // It must be created with NewChecker. type Checker struct { @@ -111,7 +133,7 @@ type Checker struct { firstErr error // first error encountered methods map[*TypeName][]*Func // maps package scope type names to associated non-blank (non-interface) methods untyped map[ast.Expr]exprInfo // map of expressions without final type - delayed []func() // stack of delayed action segments; segments are processed in FIFO order + delayed []action // stack of delayed action segments; segments are processed in FIFO order objPath []Object // path of object dependencies during type inference (for cycle reporting) defTypes []*Named // defined types created during type checking, for final validation. @@ -148,8 +170,12 @@ func (check *Checker) rememberUntyped(e ast.Expr, lhs bool, mode operandMode, ty // either at the end of the current statement, or in case of a local constant // or variable declaration, before the constant or variable is in scope // (so that f still sees the scope before any new declarations). -func (check *Checker) later(f func()) { - check.delayed = append(check.delayed, f) +// later returns the pushed action so one can provide a description +// via action.describef for debugging, if desired. +func (check *Checker) later(f func()) *action { + i := len(check.delayed) + check.delayed = append(check.delayed, action{f: f}) + return &check.delayed[i] } // push pushes obj onto the object path and returns its index in the path. @@ -304,7 +330,12 @@ func (check *Checker) processDelayed(top int) { // add more actions (such as nested functions), so // this is a sufficiently bounded process. for i := top; i < len(check.delayed); i++ { - check.delayed[i]() // may append to check.delayed + a := &check.delayed[i] + if trace && a.desc != nil { + fmt.Println() + check.trace(a.desc.pos.Pos(), "-- "+a.desc.format, a.desc.args...) + } + a.f() // may append to check.delayed } assert(top <= len(check.delayed)) // stack must not have shrunk check.delayed = check.delayed[:top] diff --git a/src/go/types/decl.go b/src/go/types/decl.go index 3e97fbbccd..6982fed0b8 100644 --- a/src/go/types/decl.go +++ b/src/go/types/decl.go @@ -610,7 +610,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *Named) { if check.isImportedConstraint(rhs) && !check.allowVersion(check.pkg, 1, 18) { check.errorf(tdecl.Type, _Todo, "using type constraint %s requires go1.18 or later", rhs) } - }) + }).describef(obj, "validType(%s)", obj.Name()) alias := tdecl.Assign.IsValid() if alias && tdecl.TypeParams.NumFields() != 0 { diff --git a/src/go/types/instantiate.go b/src/go/types/instantiate.go index 2bb31b17ee..3720cb725a 100644 --- a/src/go/types/instantiate.go +++ b/src/go/types/instantiate.go @@ -65,7 +65,7 @@ func (check *Checker) instance(pos token.Pos, typ Type, targs []Type, ctxt *Cont } } tname := NewTypeName(pos, t.obj.pkg, t.obj.name, nil) - named := check.newNamed(tname, t, nil, nil, nil) // methods and tparams are set when named is resolved + named := check.newNamed(tname, t, nil, nil, nil) // underlying, tparams, and methods are set when named is resolved named.targs = NewTypeList(targs) named.resolver = func(ctxt *Context, n *Named) (*TypeParamList, Type, []*Func) { return expandNamed(ctxt, n, pos) diff --git a/src/go/types/interface.go b/src/go/types/interface.go index c170ed4a60..78813e665b 100644 --- a/src/go/types/interface.go +++ b/src/go/types/interface.go @@ -221,7 +221,7 @@ func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, d check.later(func() { computeInterfaceTypeSet(check, iface.Pos(), ityp) ityp.check = nil - }) + }).describef(iface, "compute type set for %s", ityp) } func flattenUnion(list []ast.Expr, x ast.Expr) []ast.Expr { diff --git a/src/go/types/struct.go b/src/go/types/struct.go index 24a2435ff7..442c7a66e3 100644 --- a/src/go/types/struct.go +++ b/src/go/types/struct.go @@ -155,7 +155,7 @@ func (check *Checker) structType(styp *Struct, e *ast.StructType) { check.error(embeddedPos, _InvalidPtrEmbed, "embedded field type cannot be a pointer to an interface") } } - }) + }).describef(embeddedPos, "check embedded type %s", embeddedTyp) } } diff --git a/src/go/types/typexpr.go b/src/go/types/typexpr.go index e812c3d5d5..092e355b38 100644 --- a/src/go/types/typexpr.go +++ b/src/go/types/typexpr.go @@ -210,8 +210,6 @@ func (check *Checker) typInternal(e0 ast.Expr, def *Named) (T Type) { if T != nil { // Calling under() here may lead to endless instantiations. // Test case: type T[P any] *T[P] - // TODO(gri) investigate if that's a bug or to be expected - // (see also analogous comment in Checker.instantiate). under = safeUnderlying(T) } if T == under { From 278b9b3a4c7c01929133737e960335afa18eeec3 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Wed, 27 Oct 2021 12:06:46 -0400 Subject: [PATCH 213/406] go/types: implement generic conversions This is a port of 4 CLs from types2: CL 356010, CL 357333, CL 357410, and CL 357249. These 4 CLs are all related to implementing conversions, and porting them together saved time (particularly because go/types was already threading a *reason argument in some places). Change-Id: Ic89b608d7096b61bfb9f7d71fdae2cc50b0ed70e Reviewed-on: https://go-review.googlesource.com/c/go/+/359137 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/types2/api.go | 2 +- .../compile/internal/types2/conversions.go | 4 +- src/go/types/conversions.go | 86 ++++++++--- src/go/types/operand.go | 6 +- .../types/testdata/examples/conversions.go2 | 144 ++++++++++++++++++ 5 files changed, 218 insertions(+), 24 deletions(-) create mode 100644 src/go/types/testdata/examples/conversions.go2 diff --git a/src/cmd/compile/internal/types2/api.go b/src/cmd/compile/internal/types2/api.go index f13fa95b62..83c4b02abf 100644 --- a/src/cmd/compile/internal/types2/api.go +++ b/src/cmd/compile/internal/types2/api.go @@ -438,7 +438,7 @@ func AssignableTo(V, T Type) bool { // ConvertibleTo reports whether a value of type V is convertible to a value of type T. func ConvertibleTo(V, T Type) bool { x := operand{mode: value, typ: V} - return x.convertibleTo(nil, T, nil) // check not needed for non-constant x; if check == nil, cause can be nil + return x.convertibleTo(nil, T, nil) // check not needed for non-constant x } // Implements reports whether type V implements interface T. diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index a456f89f7e..bc33b3a44b 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -178,12 +178,12 @@ func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { return true } - // "V an integer or a slice of bytes or runes and T is a string type" + // "V is an integer or a slice of bytes or runes and T is a string type" if (isInteger(V) || isBytesOrRunes(Vu)) && isString(T) { return true } - // "V a string and T is a slice of bytes or runes" + // "V is a string and T is a slice of bytes or runes" if isString(V) && isBytesOrRunes(Tu) { return true } diff --git a/src/go/types/conversions.go b/src/go/types/conversions.go index a1fcdd4fd8..fe62adbf10 100644 --- a/src/go/types/conversions.go +++ b/src/go/types/conversions.go @@ -17,7 +17,7 @@ func (check *Checker) conversion(x *operand, T Type) { constArg := x.mode == constant_ var ok bool - var reason string + var cause string switch { case constArg && isConstType(T): // constant conversion @@ -32,15 +32,16 @@ func (check *Checker) conversion(x *operand, T Type) { x.val = constant.MakeString(string(codepoint)) ok = true } - case x.convertibleTo(check, T, &reason): + case x.convertibleTo(check, T, &cause): // non-constant conversion x.mode = value ok = true } if !ok { - if reason != "" { - check.errorf(x, _InvalidConversion, "cannot convert %s to %s (%s)", x, T, reason) + // TODO(rfindley): use types2-style error reporting here. + if cause != "" { + check.errorf(x, _InvalidConversion, "cannot convert %s to %s (%s)", x, T, cause) } else { check.errorf(x, _InvalidConversion, "cannot convert %s to %s", x, T) } @@ -81,24 +82,75 @@ func (check *Checker) conversion(x *operand, T Type) { // is tricky because we'd have to run updateExprType on the argument first. // (Issue #21982.) -// convertibleTo reports whether T(x) is valid. +// convertibleTo reports whether T(x) is valid. In the failure case, *cause +// may be set to the cause for the failure. // The check parameter may be nil if convertibleTo is invoked through an // exported API call, i.e., when all methods have been type-checked. -func (x *operand) convertibleTo(check *Checker, T Type, reason *string) bool { +func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { // "x is assignable to T" - if ok, _ := x.assignableTo(check, T, nil); ok { + if ok, _ := x.assignableTo(check, T, cause); ok { return true } - // "x's type and T have identical underlying types if tags are ignored" - V := x.typ + errorf := func(format string, args ...interface{}) { + if check != nil && cause != nil { + msg := check.sprintf(format, args...) + if *cause != "" { + msg += "\n\t" + *cause + } + *cause = msg + } + } + + // TODO(gri) consider passing under(x.typ), under(T) into convertibleToImpl (optimization) + Vp, _ := under(x.typ).(*TypeParam) + Tp, _ := under(T).(*TypeParam) + + // generic cases + // (generic operands cannot be constants, so we can ignore x.val) + switch { + case Vp != nil && Tp != nil: + return Vp.is(func(V *term) bool { + return Tp.is(func(T *term) bool { + if !convertibleToImpl(check, V.typ, T.typ, cause) { + errorf("cannot convert %s (in %s) to %s (in %s)", V.typ, Vp, T.typ, Tp) + return false + } + return true + }) + }) + case Vp != nil: + return Vp.is(func(V *term) bool { + if !convertibleToImpl(check, V.typ, T, cause) { + errorf("cannot convert %s (in %s) to %s", V.typ, Vp, T) + return false + } + return true + }) + case Tp != nil: + return Tp.is(func(T *term) bool { + if !convertibleToImpl(check, x.typ, T.typ, cause) { + errorf("cannot convert %s to %s (in %s)", x.typ, T.typ, Tp) + return false + } + return true + }) + } + + // non-generic case + return convertibleToImpl(check, x.typ, T, cause) +} + +// convertibleToImpl should only be called by convertibleTo +func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { + // "V and T have identical underlying types if tags are ignored" Vu := under(V) Tu := under(T) if IdenticalIgnoreTags(Vu, Tu) { return true } - // "x's type and T are unnamed pointer types and their pointer base types + // "V and T are unnamed pointer types and their pointer base types // have identical underlying types if tags are ignored" if V, ok := V.(*Pointer); ok { if T, ok := T.(*Pointer); ok { @@ -108,22 +160,22 @@ func (x *operand) convertibleTo(check *Checker, T Type, reason *string) bool { } } - // "x's type and T are both integer or floating point types" + // "V and T are both integer or floating point types" if isIntegerOrFloat(V) && isIntegerOrFloat(T) { return true } - // "x's type and T are both complex types" + // "V and T are both complex types" if isComplex(V) && isComplex(T) { return true } - // "x is an integer or a slice of bytes or runes and T is a string type" + // "V is an integer or a slice of bytes or runes and T is a string type" if (isInteger(V) || isBytesOrRunes(Vu)) && isString(T) { return true } - // "x is a string and T is a slice of bytes or runes" + // "V is a string and T is a slice of bytes or runes" if isString(V) && isBytesOrRunes(Tu) { return true } @@ -138,7 +190,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, reason *string) bool { return true } - // "x is a slice, T is a pointer-to-array type, + // "V is a slice, T is a pointer-to-array type, // and the slice and array types have identical element types." if s := asSlice(V); s != nil { if p := asPointer(T); p != nil { @@ -147,8 +199,8 @@ func (x *operand) convertibleTo(check *Checker, T Type, reason *string) bool { if check == nil || check.allowVersion(check.pkg, 1, 17) { return true } - if reason != nil { - *reason = "conversion of slices to array pointers requires go1.17 or later" + if cause != nil { + *cause = "conversion of slices to array pointers requires go1.17 or later" } } } diff --git a/src/go/types/operand.go b/src/go/types/operand.go index a54802defc..855dac66aa 100644 --- a/src/go/types/operand.go +++ b/src/go/types/operand.go @@ -159,17 +159,14 @@ func operandString(x *operand, qf Qualifier) string { if hasType { if x.typ != Typ[Invalid] { var intro string - var tpar *TypeParam if isGeneric(x.typ) { intro = " of parameterized type " - } else if tpar = asTypeParam(x.typ); tpar != nil { - intro = " of type parameter " } else { intro = " of type " } buf.WriteString(intro) WriteType(&buf, x.typ, qf) - if tpar != nil { + if tpar := asTypeParam(x.typ); tpar != nil { buf.WriteString(" constrained by ") WriteType(&buf, tpar.bound, qf) // do not compute interface type sets here } @@ -284,6 +281,7 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er if Ti, ok := Tu.(*Interface); ok { if m, wrongType := check.missingMethod(V, Ti, true); m != nil /* Implements(V, Ti) */ { if reason != nil { + // TODO(gri) the error messages here should follow the style in Checker.typeAssertion (factor!) if wrongType != nil { if Identical(m.typ, wrongType.typ) { *reason = fmt.Sprintf("missing method %s (%s has pointer receiver)", m.name, m.name) diff --git a/src/go/types/testdata/examples/conversions.go2 b/src/go/types/testdata/examples/conversions.go2 new file mode 100644 index 0000000000..eb988ffed1 --- /dev/null +++ b/src/go/types/testdata/examples/conversions.go2 @@ -0,0 +1,144 @@ +// Copyright 2021 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 conversions + +import "unsafe" + +// "x is assignable to T" +// - tested via assignability tests + +// "x's type and T have identical underlying types if tags are ignored" + +func _[X ~int, T ~int](x X) T { return T(x) } +func _[X struct{f int "foo"}, T struct{f int "bar"}](x X) T { return T(x) } + +type Foo struct{f int "foo"} +type Bar struct{f int "bar"} +type Far struct{f float64 } + +func _[X Foo, T Bar](x X) T { return T(x) } +func _[X Foo|Bar, T Bar](x X) T { return T(x) } +func _[X Foo, T Foo|Bar](x X) T { return T(x) } +func _[X Foo, T Far](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by Foo\) to T.*cannot convert Foo \(in X\) to Far \(in T\) */ ) } + +// "x's type and T are unnamed pointer types and their pointer base types +// have identical underlying types if tags are ignored" + +func _[X ~*Foo, T ~*Bar](x X) T { return T(x) } +func _[X ~*Foo|~*Bar, T ~*Bar](x X) T { return T(x) } +func _[X ~*Foo, T ~*Foo|~*Bar](x X) T { return T(x) } +func _[X ~*Foo, T ~*Far](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by ~\*Foo\) to T.*cannot convert \*Foo \(in X\) to \*Far \(in T\) */ ) } + +// Verify that the defined types in constraints are considered for the rule above. + +type ( + B int + C int + X0 *B + T0 *C +) + +func _(x X0) T0 { return T0(x /* ERROR cannot convert */ ) } // non-generic reference +func _[X X0, T T0](x X) T { return T(x /* ERROR cannot convert */ ) } +func _[T T0](x X0) T { return T(x /* ERROR cannot convert */ ) } +func _[X X0](x X) T0 { return T0(x /* ERROR cannot convert */ ) } + +// "x's type and T are both integer or floating point types" + +func _[X Integer, T Integer](x X) T { return T(x) } +func _[X Unsigned, T Integer](x X) T { return T(x) } +func _[X Float, T Integer](x X) T { return T(x) } + +func _[X Integer, T Unsigned](x X) T { return T(x) } +func _[X Unsigned, T Unsigned](x X) T { return T(x) } +func _[X Float, T Unsigned](x X) T { return T(x) } + +func _[X Integer, T Float](x X) T { return T(x) } +func _[X Unsigned, T Float](x X) T { return T(x) } +func _[X Float, T Float](x X) T { return T(x) } + +func _[X, T Integer|Unsigned|Float](x X) T { return T(x) } +func _[X, T Integer|~string](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by Integer\|~string\) to T.*cannot convert string \(in X\) to int \(in T\) */ ) } + +// "x's type and T are both complex types" + +func _[X, T Complex](x X) T { return T(x) } +func _[X, T Float|Complex](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by Float\|Complex\) to T.*cannot convert float32 \(in X\) to complex64 \(in T\) */ ) } + +// "x is an integer or a slice of bytes or runes and T is a string type" + +type myInt int +type myString string + +func _[T ~string](x int) T { return T(x) } +func _[T ~string](x myInt) T { return T(x) } +func _[X Integer](x X) string { return string(x) } +func _[X Integer](x X) myString { return myString(x) } +func _[X Integer](x X) *string { return (*string)(x /* ERROR cannot convert x \(variable of type X constrained by Integer\) to \*string.*cannot convert int \(in X\) to \*string */ ) } + +func _[T ~string](x []byte) T { return T(x) } +func _[T ~string](x []rune) T { return T(x) } +func _[X ~[]byte, T ~string](x X) T { return T(x) } +func _[X ~[]rune, T ~string](x X) T { return T(x) } +func _[X Integer|~[]byte|~[]rune, T ~string](x X) T { return T(x) } +func _[X Integer|~[]byte|~[]rune, T ~*string](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by Integer\|~\[\]byte\|~\[\]rune\) to T.*cannot convert int \(in X\) to \*string \(in T\) */ ) } + +// "x is a string and T is a slice of bytes or runes" + +func _[T ~[]byte](x string) T { return T(x) } +func _[T ~[]rune](x string) T { return T(x) } +func _[T ~[]rune](x *string) T { return T(x /* ERROR cannot convert x \(variable of type \*string\) to T.*cannot convert \*string to \[\]rune \(in T\) */ ) } + +func _[X ~string, T ~[]byte](x X) T { return T(x) } +func _[X ~string, T ~[]rune](x X) T { return T(x) } +func _[X ~string, T ~[]byte|~[]rune](x X) T { return T(x) } +func _[X ~*string, T ~[]byte|~[]rune](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by ~\*string\) to T.*cannot convert \*string \(in X\) to \[\]byte \(in T\) */ ) } + +// package unsafe: +// "any pointer or value of underlying type uintptr can be converted into a unsafe.Pointer" + +type myUintptr uintptr + +func _[X ~uintptr](x X) unsafe.Pointer { return unsafe.Pointer(x) } +func _[T unsafe.Pointer](x myUintptr) T { return T(x) } +func _[T unsafe.Pointer](x int64) T { return T(x /* ERROR cannot convert x \(variable of type int64\) to T.*cannot convert int64 to unsafe\.Pointer \(in T\) */ ) } + +// "and vice versa" + +func _[T ~uintptr](x unsafe.Pointer) T { return T(x) } +func _[X unsafe.Pointer](x X) uintptr { return uintptr(x) } +func _[X unsafe.Pointer](x X) myUintptr { return myUintptr(x) } +func _[X unsafe.Pointer](x X) int64 { return int64(x /* ERROR cannot convert x \(variable of type X constrained by unsafe\.Pointer\) to int64.*cannot convert unsafe\.Pointer \(in X\) to int64 */ ) } + +// "x is a slice, T is a pointer-to-array type, +// and the slice and array types have identical element types." + +func _[X ~[]E, T ~*[10]E, E any](x X) T { return T(x) } +func _[X ~[]E, T ~[10]E, E any](x X) T { return T(x /* ERROR cannot convert x \(variable of type X constrained by ~\[\]E\) to T.*cannot convert \[\]E \(in X\) to \[10\]E \(in T\) */ ) } + +// ---------------------------------------------------------------------------- +// The following declarations can be replaced by the exported types of the +// constraints package once all builders support importing interfaces with +// type constraints. + +type Signed interface { + ~int | ~int8 | ~int16 | ~int32 | ~int64 +} + +type Unsigned interface { + ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr +} + +type Integer interface { + Signed | Unsigned +} + +type Float interface { + ~float32 | ~float64 +} + +type Complex interface { + ~complex64 | ~complex128 +} From 61536ec03063b4951163bd09609c86d82631fa27 Mon Sep 17 00:00:00 2001 From: Roland Shoemaker Date: Thu, 14 Oct 2021 13:02:01 -0700 Subject: [PATCH 214/406] debug/macho: fail on invalid dynamic symbol table command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fail out when loading a file that contains a dynamic symbol table command that indicates a larger number of symbols than exist in the loaded symbol table. Thanks to Burak Çarıkçı - Yunus Yıldırım (CT-Zer0 Crypttech) for reporting this issue. Fixes #48990 Fixes CVE-2021-41771 Change-Id: Ic3d6e6529241afcc959544b326b21b663262bad5 Reviewed-on: https://go-review.googlesource.com/c/go/+/355990 Reviewed-by: Julie Qiu Reviewed-by: Katie Hockman Reviewed-by: Emmanuel Odeke Run-TryBot: Roland Shoemaker TryBot-Result: Go Bot Trust: Katie Hockman --- src/debug/macho/file.go | 9 +++++++++ src/debug/macho/file_test.go | 7 +++++++ .../testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64 | 1 + 3 files changed, 17 insertions(+) create mode 100644 src/debug/macho/testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64 diff --git a/src/debug/macho/file.go b/src/debug/macho/file.go index 085b0c8219..73cfce3c76 100644 --- a/src/debug/macho/file.go +++ b/src/debug/macho/file.go @@ -345,6 +345,15 @@ func NewFile(r io.ReaderAt) (*File, error) { if err := binary.Read(b, bo, &hdr); err != nil { return nil, err } + if hdr.Iundefsym > uint32(len(f.Symtab.Syms)) { + return nil, &FormatError{offset, fmt.Sprintf( + "undefined symbols index in dynamic symbol table command is greater than symbol table length (%d > %d)", + hdr.Iundefsym, len(f.Symtab.Syms)), nil} + } else if hdr.Iundefsym+hdr.Nundefsym > uint32(len(f.Symtab.Syms)) { + return nil, &FormatError{offset, fmt.Sprintf( + "number of undefined symbols after index in dynamic symbol table command is greater than symbol table length (%d > %d)", + hdr.Iundefsym+hdr.Nundefsym, len(f.Symtab.Syms)), nil} + } dat := make([]byte, hdr.Nindirectsyms*4) if _, err := r.ReadAt(dat, int64(hdr.Indirectsymoff)); err != nil { return nil, err diff --git a/src/debug/macho/file_test.go b/src/debug/macho/file_test.go index 03915c86e2..9beeb80dd2 100644 --- a/src/debug/macho/file_test.go +++ b/src/debug/macho/file_test.go @@ -416,3 +416,10 @@ func TestTypeString(t *testing.T) { t.Errorf("got %v, want %v", TypeExec.GoString(), "macho.Exec") } } + +func TestOpenBadDysymCmd(t *testing.T) { + _, err := openObscured("testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64") + if err == nil { + t.Fatal("openObscured did not fail when opening a file with an invalid dynamic symbol table command") + } +} diff --git a/src/debug/macho/testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64 b/src/debug/macho/testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64 new file mode 100644 index 0000000000..8e0436639c --- /dev/null +++ b/src/debug/macho/testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64 @@ -0,0 +1 @@ +z/rt/gcAAAEDAACAAgAAAAsAAABoBQAAhQAAAAAAAAAZAAAASAAAAF9fUEFHRVpFUk8AAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAA2AEAAF9fVEVYVAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAcAAAAFAAAABQAAAAAAAABfX3RleHQAAAAAAAAAAAAAX19URVhUAAAAAAAAAAAAABQPAAABAAAAbQAAAAAAAAAUDwAAAgAAAAAAAAAAAAAAAAQAgAAAAAAAAAAAAAAAAF9fc3ltYm9sX3N0dWIxAABfX1RFWFQAAAAAAAAAAAAAgQ8AAAEAAAAMAAAAAAAAAIEPAAAAAAAAAAAAAAAAAAAIBACAAAAAAAYAAAAAAAAAX19zdHViX2hlbHBlcgAAAF9fVEVYVAAAAAAAAAAAAACQDwAAAQAAABgAAAAAAAAAkA8AAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABfX2NzdHJpbmcAAAAAAAAAX19URVhUAAAAAAAAAAAAAKgPAAABAAAADQAAAAAAAACoDwAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAF9fZWhfZnJhbWUAAAAAAABfX1RFWFQAAAAAAAAAAAAAuA8AAAEAAABIAAAAAAAAALgPAAADAAAAAAAAAAAAAAALAABgAAAAAAAAAAAAAAAAGQAAADgBAABfX0RBVEEAAAAAAAAAAAAAABAAAAEAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAHAAAAAwAAAAMAAAAAAAAAX19kYXRhAAAAAAAAAAAAAF9fREFUQQAAAAAAAAAAAAAAEAAAAQAAABwAAAAAAAAAABAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABfX2R5bGQAAAAAAAAAAAAAX19EQVRBAAAAAAAAAAAAACAQAAABAAAAOAAAAAAAAAAgEAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF9fbGFfc3ltYm9sX3B0cgBfX0RBVEEAAAAAAAAAAAAAWBAAAAEAAAAQAAAAAAAAAFgQAAACAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAGQAAAEgAAABfX0xJTktFRElUAAAAAAAAACAAAAEAAAAAEAAAAAAAAAAgAAAAAAAAQAEAAAAAAAAHAAAAAQAAAAAAAAAAAAAAAgAAABgAAAAAIAAACwAAAMAgAACAAAAACwAAAFAAAAAAAAAAAgAAAAIAAAAHAAAACQAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwIAAABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAIAAAAAwAAAAvdXNyL2xpYi9keWxkAAAAAAAAABsAAAAYAAAAOyS4cg5FdtQoqu6JsMEhXQUAAAC4AAAABAAAACoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQPAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAOAAAABgAAAACAAAAAAABAAAAAQAvdXNyL2xpYi9saWJnY2Nfcy4xLmR5bGliAAAAAAAAAAwAAAA4AAAAGAAAAAIAAAAEAW8AAAABAC91c3IvbGliL2xpYlN5c3RlbS5CLmR5bGliAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABqAEiJ5UiD5PBIi30ISI11EIn6g8IBweIDSAHySInR6wRIg8EISIM5AHX2SIPBCOgiAAAAicfoMgAAAPRBU0yNHafw//9BU/8lvwAAAA8fAP8lvgAAAFVIieVIjT0zAAAA6A0AAAC4AAAAAMnD/yXRAAAA/yXTAAAAAAAATI0dwQAAAOm0////TI0dvQAAAOmo////aGVsbG8sIHdvcmxkAAAAABQAAAAAAAAAAXpSAAF4EAEQDAcIkAEAACwAAAAcAAAAkv////////8XAAAAAAAAAAAEAQAAAA4QhgIEAwAAAA0GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABDAX/9/AAAIEMBf/38AAAAAAAABAAAAGBAAAAEAAAAQEAAAAQAAAAgQAAABAAAAABAAAAEAAACQDwAAAQAAAJwPAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAHgEAAFAPAAABAAAAGwAAAB4BAABkDwAAAQAAAC4AAAAPBgAAGBAAAAEAAAA2AAAADwYAABAQAAABAAAAPgAAAA8GAAAAEAAAAQAAAEoAAAADABAAAAAAAAEAAABeAAAADwYAAAgQAAABAAAAZwAAAA8BAABqDwAAAQAAAG0AAAAPAQAAFA8AAAEAAABzAAAAAQABAgAAAAAAAAAAeQAAAAEAAQIAAAAAAAAAAAkAAAAKAAAACQAAAAoAAAAgAGR5bGRfc3R1Yl9iaW5kaW5nX2hlbHBlcgBfX2R5bGRfZnVuY19sb29rdXAAX05YQXJnYwBfTlhBcmd2AF9fX3Byb2duYW1lAF9fbWhfZXhlY3V0ZV9oZWFkZXIAX2Vudmlyb24AX21haW4Ac3RhcnQAX2V4aXQAX3B1dHMAAA== \ No newline at end of file From 6f0185bf38a679f468b6a4209f15188a11662eb5 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Wed, 27 Oct 2021 12:17:21 -0400 Subject: [PATCH 215/406] go/types: factor out slice elem computation for copy built-in This is a port of CL 357413 to go/types. Some test constraints are also updated to remove 'interface', to coincide with the corresponding test data file in types2. Change-Id: I5248190501c2e4381eb7625f8d4fb269301d6e16 Reviewed-on: https://go-review.googlesource.com/c/go/+/359138 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/builtins.go | 59 ++++++++++++++++++------ src/go/types/testdata/check/builtins.go2 | 18 +++++--- 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/src/go/types/builtins.go b/src/go/types/builtins.go index 3e2c994b09..29a8339f3e 100644 --- a/src/go/types/builtins.go +++ b/src/go/types/builtins.go @@ -330,33 +330,22 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b case _Copy: // copy(x, y []T) int - var dst Type - if t := asSlice(x.typ); t != nil { - dst = t.elem - } + dst, _ := singleUnder(x.typ).(*Slice) var y operand arg(&y, 1) if y.mode == invalid { return } - var src Type - switch t := optype(y.typ).(type) { - case *Basic: - if isString(y.typ) { - src = universeByte - } - case *Slice: - src = t.elem - } + src, _ := singleUnderString(y.typ).(*Slice) if dst == nil || src == nil { check.invalidArg(x, _InvalidCopy, "copy expects slice arguments; found %s and %s", x, &y) return } - if !Identical(dst, src) { - check.invalidArg(x, _InvalidCopy, "arguments to copy %s and %s have different element types %s and %s", x, &y, dst, src) + if !Identical(dst.elem, src.elem) { + check.errorf(x, _InvalidCopy, "arguments to copy %s and %s have different element types %s and %s", x, &y, dst.elem, src.elem) return } @@ -783,6 +772,46 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b return true } +// If typ is a type parameter, single under returns the single underlying +// type of all types in the corresponding type constraint if it exists, or +// nil if it doesn't exist. If typ is not a type parameter, singleUnder +// just returns the underlying type. +func singleUnder(typ Type) Type { + var su Type + if underIs(typ, func(u Type) bool { + if su != nil && !Identical(su, u) { + return false + } + // su == nil || Identical(su, u) + su = u + return true + }) { + return su + } + return nil +} + +// singleUnderString is like singleUnder but also considers []byte and +// string as "identical". In this case, if successful, the result is always +// []byte. +func singleUnderString(typ Type) Type { + var su Type + if underIs(typ, func(u Type) bool { + if isString(u) { + u = NewSlice(universeByte) + } + if su != nil && !Identical(su, u) { + return false + } + // su == nil || Identical(su, u) + su = u + return true + }) { + return su + } + return nil +} + // hasVarSize reports if the size of type t is variable due to type parameters. func hasVarSize(t Type) bool { switch t := under(t).(type) { diff --git a/src/go/types/testdata/check/builtins.go2 b/src/go/types/testdata/check/builtins.go2 index fb912a1918..f9b6ec7926 100644 --- a/src/go/types/testdata/check/builtins.go2 +++ b/src/go/types/testdata/check/builtins.go2 @@ -51,7 +51,7 @@ func _[T any](x, y T) { copy(x /* ERROR copy expects slice arguments */ , y) } -func _[T interface{~[]byte}](x, y T) { +func _[T ~[]byte](x, y T) { copy(x, y) copy(x, "foo") copy("foo" /* ERROR expects slice arguments */ , y) @@ -66,20 +66,26 @@ func _[T interface{~[]byte}](x, y T) { copy(y /* ERROR different element types */ , x3) } -func _[T interface{~[]E}, E any](x T, y []E) { +func _[T ~[]E, E any](x T, y []E) { copy(x, y) copy(x /* ERROR different element types */ , "foo") } -func _[T interface{~string}](x []byte, y T) { +func _[T ~string](x []byte, y T) { copy(x, y) copy(y /* ERROR expects slice arguments */ , x) } -func _[T interface{~[]byte|~string}](x T, y []byte) { +func _[T ~[]byte|~string](x T, y []byte) { copy(x /* ERROR expects slice arguments */ , y) - // TODO(gri) should this be valid? - copy(y /* ERROR expects slice arguments */ , x) + copy(y, x) +} + +type L0 []int +type L1 []int + +func _[T L0 | L1](x, y T) { + copy(x, y) } // delete From 5fce1d96137e1079c393c94febfac49d1e2979b0 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 27 Oct 2021 16:07:40 -0400 Subject: [PATCH 216/406] runtime: disable TestSegv panic check on darwin, illumos, solaris CL 339990 made this test more strict, exposing pre-existing issues on these OSes. Skip for now until they can be resolved. Updates #49182 Change-Id: I3ac400dcd21b801bf4ab4eeb630e23b5c66ba563 Reviewed-on: https://go-review.googlesource.com/c/go/+/359254 Trust: Michael Pratt Run-TryBot: Michael Pratt Reviewed-by: Cherry Mui Reviewed-by: Bryan C. Mills TryBot-Result: Go Bot --- src/runtime/crash_cgo_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go index 0ccfe8580a..8485b6a1a5 100644 --- a/src/runtime/crash_cgo_test.go +++ b/src/runtime/crash_cgo_test.go @@ -625,10 +625,18 @@ func TestSegv(t *testing.T) { if !strings.Contains(got, want) { t.Errorf("did not see %q in output", want) } + // No runtime errors like "runtime: unknown pc". - nowant := "runtime: " - if strings.Contains(got, nowant) { - t.Errorf("unexpectedly saw %q in output", want) + switch runtime.GOOS { + case "darwin", "illumos", "solaris": + // TODO(golang.org/issue/49182): Skip, runtime + // throws while attempting to generate + // traceback. + default: + nowant := "runtime: " + if strings.Contains(got, nowant) { + t.Errorf("unexpectedly saw %q in output", nowant) + } } }) } From 6bd0e7fa8a2cb5c8de9d4566c900233715d8cf0e Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 27 Oct 2021 16:09:59 -0400 Subject: [PATCH 217/406] runtime: fix backward error message This was added in CL 339990. Change-Id: I4b0f97bf1a3926e37a42f77e149dcab3b7b75a63 Reviewed-on: https://go-review.googlesource.com/c/go/+/359255 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- src/runtime/crash_cgo_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go index 8485b6a1a5..c0d4569462 100644 --- a/src/runtime/crash_cgo_test.go +++ b/src/runtime/crash_cgo_test.go @@ -534,7 +534,7 @@ func TestCgoTracebackSigpanic(t *testing.T) { // No runtime errors like "runtime: unexpected return pc". nowant := "runtime: " if strings.Contains(got, nowant) { - t.Errorf("unexpectedly saw %q in output", want) + t.Errorf("unexpectedly saw %q in output", nowant) } } From 31249688487ca3a60f856ad082d4e84c4d5f79fb Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 29 Jun 2020 14:29:09 -0400 Subject: [PATCH 218/406] cmd/fix: add buildtag fix Now that Go 1.17 is out and Go 1.15 is unsupported, removing // +build lines can be done safely: in the worst case, if code is compiled using Go 1.16 the toolchain will detect the presence of a //go:build without // +build and fail the build. (It will not silently choose the wrong files.) Note that +build lines will continue to work in Go sources forever. This just provides a mechanism for users who are done with Go 1.16 to remove them easily, by running "go fix". Also update for new generics AST. For #41184. Fixes #48978. Change-Id: I11a432c319e5abd05ad68dda9ccd7a7fdcc8bbb8 Reviewed-on: https://go-review.googlesource.com/c/go/+/240611 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/cmd/fix/buildtag.go | 51 ++++++++++++++++++++++++++++++++++ src/cmd/fix/buildtag_test.go | 34 +++++++++++++++++++++++ src/cmd/fix/fix.go | 9 ++++++ src/cmd/fix/main.go | 28 ++++++++++++++++++- src/cmd/fix/main_test.go | 23 +++++++++++---- src/cmd/go/alldocs.go | 8 ++++-- src/cmd/go/internal/fix/fix.go | 30 +++++++++++++++++--- 7 files changed, 171 insertions(+), 12 deletions(-) create mode 100644 src/cmd/fix/buildtag.go create mode 100644 src/cmd/fix/buildtag_test.go diff --git a/src/cmd/fix/buildtag.go b/src/cmd/fix/buildtag.go new file mode 100644 index 0000000000..5f4fbfef16 --- /dev/null +++ b/src/cmd/fix/buildtag.go @@ -0,0 +1,51 @@ +// Copyright 2020 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 main + +import ( + "go/ast" + "strings" +) + +func init() { + register(buildtagFix) +} + +const buildtagGoVersionCutoff = 1_18 + +var buildtagFix = fix{ + name: "buildtag", + date: "2021-08-25", + f: buildtag, + desc: `Remove +build comments from modules using Go 1.18 or later`, +} + +func buildtag(f *ast.File) bool { + if goVersion < buildtagGoVersionCutoff { + return false + } + + // File is already gofmt-ed, so we know that if there are +build lines, + // they are in a comment group that starts with a //go:build line followed + // by a blank line. While we cannot delete comments from an AST and + // expect consistent output in general, this specific case - deleting only + // some lines from a comment block - does format correctly. + fixed := false + for _, g := range f.Comments { + sawGoBuild := false + for i, c := range g.List { + if strings.HasPrefix(c.Text, "//go:build ") { + sawGoBuild = true + } + if sawGoBuild && strings.HasPrefix(c.Text, "// +build ") { + g.List = g.List[:i] + fixed = true + break + } + } + } + + return fixed +} diff --git a/src/cmd/fix/buildtag_test.go b/src/cmd/fix/buildtag_test.go new file mode 100644 index 0000000000..1c6efbe9e0 --- /dev/null +++ b/src/cmd/fix/buildtag_test.go @@ -0,0 +1,34 @@ +// Copyright 2020 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 main + +func init() { + addTestCases(buildtagTests, buildtag) +} + +var buildtagTests = []testCase{ + { + Name: "buildtag.oldGo", + Version: 1_10, + In: `//go:build yes +// +build yes + +package main +`, + }, + { + Name: "buildtag.new", + Version: 1_99, + In: `//go:build yes +// +build yes + +package main +`, + Out: `//go:build yes + +package main +`, + }, +} diff --git a/src/cmd/fix/fix.go b/src/cmd/fix/fix.go index b49db37571..b9980c17b9 100644 --- a/src/cmd/fix/fix.go +++ b/src/cmd/fix/fix.go @@ -125,6 +125,9 @@ func walkBeforeAfter(x interface{}, before, after func(interface{})) { case *ast.IndexExpr: walkBeforeAfter(&n.X, before, after) walkBeforeAfter(&n.Index, before, after) + case *ast.IndexListExpr: + walkBeforeAfter(&n.X, before, after) + walkBeforeAfter(&n.Indices, before, after) case *ast.SliceExpr: walkBeforeAfter(&n.X, before, after) if n.Low != nil { @@ -156,6 +159,9 @@ func walkBeforeAfter(x interface{}, before, after func(interface{})) { case *ast.StructType: walkBeforeAfter(&n.Fields, before, after) case *ast.FuncType: + if n.TypeParams != nil { + walkBeforeAfter(&n.TypeParams, before, after) + } walkBeforeAfter(&n.Params, before, after) if n.Results != nil { walkBeforeAfter(&n.Results, before, after) @@ -231,6 +237,9 @@ func walkBeforeAfter(x interface{}, before, after func(interface{})) { walkBeforeAfter(&n.Values, before, after) walkBeforeAfter(&n.Names, before, after) case *ast.TypeSpec: + if n.TypeParams != nil { + walkBeforeAfter(&n.TypeParams, before, after) + } walkBeforeAfter(&n.Type, before, after) case *ast.BadDecl: diff --git a/src/cmd/fix/main.go b/src/cmd/fix/main.go index d055929aac..b5f7b901d6 100644 --- a/src/cmd/fix/main.go +++ b/src/cmd/fix/main.go @@ -18,6 +18,7 @@ import ( "os" "path/filepath" "sort" + "strconv" "strings" "cmd/internal/diff" @@ -36,7 +37,12 @@ var forceRewrites = flag.String("force", "", var allowed, force map[string]bool -var doDiff = flag.Bool("diff", false, "display diffs instead of rewriting files") +var ( + doDiff = flag.Bool("diff", false, "display diffs instead of rewriting files") + goVersionStr = flag.String("go", "", "go language version for files") + + goVersion int // 115 for go1.15 +) // enable for debugging fix failures const debug = false // display incorrectly reformatted source and exit @@ -63,6 +69,26 @@ func main() { flag.Usage = usage flag.Parse() + if *goVersionStr != "" { + if !strings.HasPrefix(*goVersionStr, "go") { + report(fmt.Errorf("invalid -go=%s", *goVersionStr)) + os.Exit(exitCode) + } + majorStr := (*goVersionStr)[len("go"):] + minorStr := "0" + if i := strings.Index(majorStr, "."); i >= 0 { + majorStr, minorStr = majorStr[:i], majorStr[i+len("."):] + } + major, err1 := strconv.Atoi(majorStr) + minor, err2 := strconv.Atoi(minorStr) + if err1 != nil || err2 != nil || major < 0 || major >= 100 || minor < 0 || minor >= 100 { + report(fmt.Errorf("invalid -go=%s", *goVersionStr)) + os.Exit(exitCode) + } + + goVersion = major*100 + minor + } + sort.Sort(byDate(fixes)) if *allowedRewrites != "" { diff --git a/src/cmd/fix/main_test.go b/src/cmd/fix/main_test.go index af16bcaa31..1baa95c545 100644 --- a/src/cmd/fix/main_test.go +++ b/src/cmd/fix/main_test.go @@ -14,10 +14,11 @@ import ( ) type testCase struct { - Name string - Fn func(*ast.File) bool - In string - Out string + Name string + Fn func(*ast.File) bool + Version int + In string + Out string } var testCases []testCase @@ -78,7 +79,16 @@ func TestRewrite(t *testing.T) { for _, tt := range testCases { tt := tt t.Run(tt.Name, func(t *testing.T) { - t.Parallel() + if tt.Version == 0 { + t.Parallel() + } else { + old := goVersion + goVersion = tt.Version + defer func() { + goVersion = old + }() + } + // Apply fix: should get tt.Out. out, fixed, ok := parseFixPrint(t, tt.Fn, tt.Name, tt.In, true) if !ok { @@ -91,6 +101,9 @@ func TestRewrite(t *testing.T) { return } + if tt.Out == "" { + tt.Out = tt.In + } if out != tt.Out { t.Errorf("incorrect output.\n") if !strings.HasPrefix(tt.Name, "testdata/") { diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 685ccac826..537f800944 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -464,14 +464,18 @@ // // Usage: // -// go fix [packages] +// go fix [-fix list] [packages] // // Fix runs the Go fix command on the packages named by the import paths. // +// The -fix flag sets a comma-separated list of fixes to run. +// The default is all known fixes. +// (Its value is passed to 'go tool fix -r'.) +// // For more about fix, see 'go doc cmd/fix'. // For more about specifying packages, see 'go help packages'. // -// To run fix with specific options, run 'go tool fix'. +// To run fix with other options, run 'go tool fix'. // // See also: go fmt, go vet. // diff --git a/src/cmd/go/internal/fix/fix.go b/src/cmd/go/internal/fix/fix.go index 988d45e71c..d8ba353de6 100644 --- a/src/cmd/go/internal/fix/fix.go +++ b/src/cmd/go/internal/fix/fix.go @@ -11,27 +11,39 @@ import ( "cmd/go/internal/load" "cmd/go/internal/modload" "cmd/go/internal/str" + "cmd/go/internal/work" "context" "fmt" + "go/build" "os" ) var CmdFix = &base.Command{ - Run: runFix, - UsageLine: "go fix [packages]", + UsageLine: "go fix [-fix list] [packages]", Short: "update packages to use new APIs", Long: ` Fix runs the Go fix command on the packages named by the import paths. +The -fix flag sets a comma-separated list of fixes to run. +The default is all known fixes. +(Its value is passed to 'go tool fix -r'.) + For more about fix, see 'go doc cmd/fix'. For more about specifying packages, see 'go help packages'. -To run fix with specific options, run 'go tool fix'. +To run fix with other options, run 'go tool fix'. See also: go fmt, go vet. `, } +var fixes = CmdFix.Flag.String("fix", "", "comma-separated list of fixes to apply") + +func init() { + work.AddBuildFlags(CmdFix, work.DefaultBuildFlags) + CmdFix.Run = runFix // fix cycle +} + func runFix(ctx context.Context, cmd *base.Command, args []string) { pkgs := load.PackagesAndErrors(ctx, load.PackageOpts{}, args) w := 0 @@ -58,6 +70,16 @@ func runFix(ctx context.Context, cmd *base.Command, args []string) { // the command only applies to this package, // not to packages in subdirectories. files := base.RelPaths(pkg.InternalAllGoFiles()) - base.Run(str.StringList(cfg.BuildToolexec, base.Tool("fix"), files)) + goVersion := "" + if pkg.Module != nil { + goVersion = "go" + pkg.Module.GoVersion + } else if pkg.Standard { + goVersion = build.Default.ReleaseTags[len(build.Default.ReleaseTags)-1] + } + var fixArg []string + if *fixes != "" { + fixArg = []string{"-r=" + *fixes} + } + base.Run(str.StringList(cfg.BuildToolexec, base.Tool("fix"), "-go="+goVersion, fixArg, files)) } } From 266626211e40d1f2c3a34fa4cd2023f5310cbd7d Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 3 Sep 2021 21:07:22 +0000 Subject: [PATCH 219/406] net/http: guarantee that the Transport dial functions are respected in js/wasm The net/http package has a documented contract that if DialContext, DialDLSContext, Dial or DialTLS are specified in an instance of Transport, that they will be used to set up the connection. If they are not specified, then a reasonable fallback is made (e.g. using the net package). This is ordinarily true, except for when compiling for the js/wasm target, where the browser's Fetch API is preferred in all cases (except for when it is undefined/unavailable) and therefore the dial functions are all ignored. As a result, the http.Transport implementation under js/wasm doesn't meet that contract. This PR updates the RoundTrip behaviour of http.Transport so that if DialContext, DialTLSContext, Dial or DialTLS are specified, they are used as expected. The Fetch API will be used as a fallback if they are not specified. Fixes #27495 Change-Id: I88c6eb6ffdd077827b421d606f3e60ebdafd538f GitHub-Last-Rev: 948a0ed97ec4661f03cd346335f1d3d180f4c1ae GitHub-Pull-Request: golang/go#46923 Reviewed-on: https://go-review.googlesource.com/c/go/+/330852 Reviewed-by: Damien Neil Trust: Damien Neil Trust: Carlos Amedee Run-TryBot: Damien Neil TryBot-Result: Go Bot --- AUTHORS | 1 + CONTRIBUTORS | 1 + src/net/http/roundtrip_js.go | 12 ++++++++++-- src/net/http/transport.go | 4 ++-- src/net/http/transport_default_js.go | 17 +++++++++++++++++ src/net/http/transport_default_other.go | 17 +++++++++++++++++ 6 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 src/net/http/transport_default_js.go create mode 100644 src/net/http/transport_default_other.go diff --git a/AUTHORS b/AUTHORS index 8d8d83605e..ad907967b4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1015,6 +1015,7 @@ Nathan Youngman Nathaniel Cook Naveen Kumar Sangi Neelesh Chandola +Neil Alexander Neil Lyons Netflix, Inc. Neuman Vong diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 74d4687373..706d630193 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1901,6 +1901,7 @@ Naveen Kumar Sangi Neeilan Selvalingam Neelesh Chandola Nehal J Wani +Neil Alexander Neil Lyons Neuman Vong Neven Sajko diff --git a/src/net/http/roundtrip_js.go b/src/net/http/roundtrip_js.go index 362dbcbdde..4a8595ebcf 100644 --- a/src/net/http/roundtrip_js.go +++ b/src/net/http/roundtrip_js.go @@ -41,11 +41,19 @@ const jsFetchCreds = "js.fetch:credentials" // Reference: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters const jsFetchRedirect = "js.fetch:redirect" -var useFakeNetwork = js.Global().Get("fetch").IsUndefined() +// jsFetchMissing will be true if the Fetch API is not present in +// the browser globals. +var jsFetchMissing = js.Global().Get("fetch").IsUndefined() // RoundTrip implements the RoundTripper interface using the WHATWG Fetch API. func (t *Transport) RoundTrip(req *Request) (*Response, error) { - if useFakeNetwork { + // The Transport has a documented contract that states that if the DialContext or + // DialTLSContext functions are set, they will be used to set up the connections. + // If they aren't set then the documented contract is to use Dial or DialTLS, even + // though they are deprecated. Therefore, if any of these are set, we should obey + // the contract and dial using the regular round-trip instead. Otherwise, we'll try + // to fall back on the Fetch API, unless it's not available. + if t.Dial != nil || t.DialContext != nil || t.DialTLS != nil || t.DialTLSContext != nil || jsFetchMissing { return t.roundTrip(req) } diff --git a/src/net/http/transport.go b/src/net/http/transport.go index 17f0047b59..0e60992e6c 100644 --- a/src/net/http/transport.go +++ b/src/net/http/transport.go @@ -42,10 +42,10 @@ import ( // $no_proxy) environment variables. var DefaultTransport RoundTripper = &Transport{ Proxy: ProxyFromEnvironment, - DialContext: (&net.Dialer{ + DialContext: defaultTransportDialContext(&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, - }).DialContext, + }), ForceAttemptHTTP2: true, MaxIdleConns: 100, IdleConnTimeout: 90 * time.Second, diff --git a/src/net/http/transport_default_js.go b/src/net/http/transport_default_js.go new file mode 100644 index 0000000000..c07d35ef86 --- /dev/null +++ b/src/net/http/transport_default_js.go @@ -0,0 +1,17 @@ +// Copyright 2021 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. + +//go:build js && wasm +// +build js,wasm + +package http + +import ( + "context" + "net" +) + +func defaultTransportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) { + return nil +} diff --git a/src/net/http/transport_default_other.go b/src/net/http/transport_default_other.go new file mode 100644 index 0000000000..8a2f1cc42b --- /dev/null +++ b/src/net/http/transport_default_other.go @@ -0,0 +1,17 @@ +// Copyright 2021 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. + +//go:build !(js && wasm) +// +build !js !wasm + +package http + +import ( + "context" + "net" +) + +func defaultTransportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) { + return dialer.DialContext +} From 2bc8ed8e9c5d8ae303b42bbd8c65f2c5dc38352a Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Tue, 26 Oct 2021 16:18:52 -0400 Subject: [PATCH 220/406] runtime: normalize sigprof traceback flags Each gentraceback call uses a different set of flags. Combine these into a common variable, only adjusted as necessary. The effective changes here are: * cgo traceback now has _TraceJumpStack. This is a no-op since it already passes curg. * libcall traceback now has _TraceJumpStack. This is a behavior change and will allow following stack transitions if a libcall is performed on g0. * VDSO traceback drops _TraceTrap. vdsoPC is a return address, so _TraceTrap was not necessary. Change-Id: I351b3cb8dc77df7466795d5fbf2bd8f30bba2d37 Reviewed-on: https://go-review.googlesource.com/c/go/+/358900 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- src/runtime/proc.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 990637e21a..bd7dacd440 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -4645,6 +4645,7 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) { getg().m.mallocing++ var stk [maxCPUProfStack]uintptr + flags := uint(_TraceJumpStack) n := 0 if mp.ncgo > 0 && mp.curg != nil && mp.curg.syscallpc != 0 && mp.curg.syscallsp != 0 { cgoOff := 0 @@ -4662,12 +4663,12 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) { } // Collect Go stack that leads to the cgo call. - n = gentraceback(mp.curg.syscallpc, mp.curg.syscallsp, 0, mp.curg, 0, &stk[cgoOff], len(stk)-cgoOff, nil, nil, 0) + n = gentraceback(mp.curg.syscallpc, mp.curg.syscallsp, 0, mp.curg, 0, &stk[cgoOff], len(stk)-cgoOff, nil, nil, flags) if n > 0 { n += cgoOff } } else { - n = gentraceback(pc, sp, lr, gp, 0, &stk[0], len(stk), nil, nil, _TraceTrap|_TraceJumpStack) + n = gentraceback(pc, sp, lr, gp, 0, &stk[0], len(stk), nil, nil, _TraceTrap|flags) } if n <= 0 { @@ -4677,10 +4678,10 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) { if usesLibcall() && mp.libcallg != 0 && mp.libcallpc != 0 && mp.libcallsp != 0 { // Libcall, i.e. runtime syscall on windows. // Collect Go stack that leads to the call. - n = gentraceback(mp.libcallpc, mp.libcallsp, 0, mp.libcallg.ptr(), 0, &stk[0], len(stk), nil, nil, 0) + n = gentraceback(mp.libcallpc, mp.libcallsp, 0, mp.libcallg.ptr(), 0, &stk[0], len(stk), nil, nil, flags) } if n == 0 && mp != nil && mp.vdsoSP != 0 { - n = gentraceback(mp.vdsoPC, mp.vdsoSP, 0, gp, 0, &stk[0], len(stk), nil, nil, _TraceTrap|_TraceJumpStack) + n = gentraceback(mp.vdsoPC, mp.vdsoSP, 0, gp, 0, &stk[0], len(stk), nil, nil, flags) } if n == 0 { // If all of the above has failed, account it against abstract "System" or "GC". From ed475fe53ba41c0c15b11565f8b9d00165345bc2 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 27 Oct 2021 22:59:55 -0400 Subject: [PATCH 221/406] cmd/go: update for //go:build lines cmd/go has its own //go:build evaluator, which is needed for patterns like 'all'. The code is a modified copy of some unexported routines from the go/build package. Update it by copying those again and re-modifying them. The modifications are primarily the new func eval and also ignoring errors. This CL will need to be backported to Go 1.17, or else Go 1.17 will break when faced with certain //go:build-only repos during 'go list all' or 'go mod tidy'. For #41184. Fixes #49198. Change-Id: Ie0fe3caa8d49004935ecd76d7977f767fe50e317 Reviewed-on: https://go-review.googlesource.com/c/go/+/359355 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/cmd/go/internal/imports/build.go | 234 ++++++++++++------ .../go/testdata/script/list_all_gobuild.txt | 41 +++ 2 files changed, 201 insertions(+), 74 deletions(-) create mode 100644 src/cmd/go/testdata/script/list_all_gobuild.txt diff --git a/src/cmd/go/internal/imports/build.go b/src/cmd/go/internal/imports/build.go index 50aeabc578..ff6bea6777 100644 --- a/src/cmd/go/internal/imports/build.go +++ b/src/cmd/go/internal/imports/build.go @@ -2,17 +2,51 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Copied from Go distribution src/go/build/build.go, syslist.go +// Copied from Go distribution src/go/build/build.go, syslist.go. +// That package does not export the ability to process raw file data, +// although we could fake it with an appropriate build.Context +// and a lot of unwrapping. +// More importantly, that package does not implement the tags["*"] +// special case, in which both tag and !tag are considered to be true +// for essentially all tags (except "ignore"). +// +// If we added this API to go/build directly, we wouldn't need this +// file anymore, but this API is not terribly general-purpose and we +// don't really want to commit to any public form of it, nor do we +// want to move the core parts of go/build into a top-level internal package. +// These details change very infrequently, so the copy is fine. package imports import ( "bytes" + "errors" + "fmt" + "go/build/constraint" "strings" "unicode" ) -var slashslash = []byte("//") +var ( + bSlashSlash = []byte("//") + bStarSlash = []byte("*/") + bSlashStar = []byte("/*") + bPlusBuild = []byte("+build") + + goBuildComment = []byte("//go:build") + + errGoBuildWithoutBuild = errors.New("//go:build comment without // +build comment") + errMultipleGoBuild = errors.New("multiple //go:build comments") +) + +func isGoBuildComment(line []byte) bool { + if !bytes.HasPrefix(line, goBuildComment) { + return false + } + line = bytes.TrimSpace(line) + rest := line[len(goBuildComment):] + return len(rest) == 0 || len(bytes.TrimSpace(rest)) < len(rest) +} // ShouldBuild reports whether it is okay to use this file, // The rule is that in the file's leading run of // comments @@ -34,90 +68,124 @@ var slashslash = []byte("//") // in any build. // func ShouldBuild(content []byte, tags map[string]bool) bool { - // Pass 1. Identify leading run of // comments and blank lines, + // Identify leading run of // comments and blank lines, // which must be followed by a blank line. - end := 0 - p := content - for len(p) > 0 { - line := p - if i := bytes.IndexByte(line, '\n'); i >= 0 { - line, p = line[:i], p[i+1:] - } else { - p = p[len(p):] - } - line = bytes.TrimSpace(line) - if len(line) == 0 { // Blank line - end = len(content) - len(p) - continue - } - if !bytes.HasPrefix(line, slashslash) { // Not comment line - break - } + // Also identify any //go:build comments. + content, goBuild, _, err := parseFileHeader(content) + if err != nil { + return false } - content = content[:end] - // Pass 2. Process each line in the run. - p = content - allok := true - for len(p) > 0 { - line := p - if i := bytes.IndexByte(line, '\n'); i >= 0 { - line, p = line[:i], p[i+1:] - } else { - p = p[len(p):] + // If //go:build line is present, it controls. + // Otherwise fall back to +build processing. + var shouldBuild bool + switch { + case goBuild != nil: + x, err := constraint.Parse(string(goBuild)) + if err != nil { + return false } - line = bytes.TrimSpace(line) - if !bytes.HasPrefix(line, slashslash) { - continue - } - line = bytes.TrimSpace(line[len(slashslash):]) - if len(line) > 0 && line[0] == '+' { - // Looks like a comment +line. - f := strings.Fields(string(line)) - if f[0] == "+build" { - ok := false - for _, tok := range f[1:] { - if matchTags(tok, tags) { - ok = true - } - } - if !ok { - allok = false + shouldBuild = eval(x, tags, true) + + default: + shouldBuild = true + p := content + for len(p) > 0 { + line := p + if i := bytes.IndexByte(line, '\n'); i >= 0 { + line, p = line[:i], p[i+1:] + } else { + p = p[len(p):] + } + line = bytes.TrimSpace(line) + if !bytes.HasPrefix(line, bSlashSlash) || !bytes.Contains(line, bPlusBuild) { + continue + } + text := string(line) + if !constraint.IsPlusBuild(text) { + continue + } + if x, err := constraint.Parse(text); err == nil { + if !eval(x, tags, true) { + shouldBuild = false } } } } - return allok + return shouldBuild } -// matchTags reports whether the name is one of: -// -// tag (if tags[tag] is true) -// !tag (if tags[tag] is false) -// a comma-separated list of any of these -// -func matchTags(name string, tags map[string]bool) bool { - if name == "" { - return false +func parseFileHeader(content []byte) (trimmed, goBuild []byte, sawBinaryOnly bool, err error) { + end := 0 + p := content + ended := false // found non-blank, non-// line, so stopped accepting // +build lines + inSlashStar := false // in /* */ comment + +Lines: + for len(p) > 0 { + line := p + if i := bytes.IndexByte(line, '\n'); i >= 0 { + line, p = line[:i], p[i+1:] + } else { + p = p[len(p):] + } + line = bytes.TrimSpace(line) + if len(line) == 0 && !ended { // Blank line + // Remember position of most recent blank line. + // When we find the first non-blank, non-// line, + // this "end" position marks the latest file position + // where a // +build line can appear. + // (It must appear _before_ a blank line before the non-blank, non-// line. + // Yes, that's confusing, which is part of why we moved to //go:build lines.) + // Note that ended==false here means that inSlashStar==false, + // since seeing a /* would have set ended==true. + end = len(content) - len(p) + continue Lines + } + if !bytes.HasPrefix(line, bSlashSlash) { // Not comment line + ended = true + } + + if !inSlashStar && isGoBuildComment(line) { + if goBuild != nil { + return nil, nil, false, errMultipleGoBuild + } + goBuild = line + } + + Comments: + for len(line) > 0 { + if inSlashStar { + if i := bytes.Index(line, bStarSlash); i >= 0 { + inSlashStar = false + line = bytes.TrimSpace(line[i+len(bStarSlash):]) + continue Comments + } + continue Lines + } + if bytes.HasPrefix(line, bSlashSlash) { + continue Lines + } + if bytes.HasPrefix(line, bSlashStar) { + inSlashStar = true + line = bytes.TrimSpace(line[len(bSlashStar):]) + continue Comments + } + // Found non-comment text. + break Lines + } } - if i := strings.Index(name, ","); i >= 0 { - // comma-separated list - ok1 := matchTags(name[:i], tags) - ok2 := matchTags(name[i+1:], tags) - return ok1 && ok2 - } - if strings.HasPrefix(name, "!!") { // bad syntax, reject always - return false - } - if strings.HasPrefix(name, "!") { // negation - return len(name) > 1 && matchTag(name[1:], tags, false) - } - return matchTag(name, tags, true) + + return content[:end], goBuild, sawBinaryOnly, nil } -// matchTag reports whether the tag name is valid and satisfied by tags[name]==want. -func matchTag(name string, tags map[string]bool, want bool) bool { +// matchTag reports whether the tag name is valid and tags[name] is true. +// As a special case, if tags["*"] is true and name is not empty or ignore, +// then matchTag will return prefer instead of the actual answer, +// which allows the caller to pretend in that case that most tags are +// both true and false. +func matchTag(name string, tags map[string]bool, prefer bool) bool { // Tags must be letters, digits, underscores or dots. // Unlike in Go identifiers, all digits are fine (e.g., "386"). for _, c := range name { @@ -131,7 +199,7 @@ func matchTag(name string, tags map[string]bool, want bool) bool { // if we put * in the tags map then all tags // except "ignore" are considered both present and not // (so we return true no matter how 'want' is set). - return true + return prefer } have := tags[name] @@ -144,7 +212,25 @@ func matchTag(name string, tags map[string]bool, want bool) bool { if name == "darwin" { have = have || tags["ios"] } - return have == want + return have +} + +// eval is like +// x.Eval(func(tag string) bool { return matchTag(tag, tags) }) +// except that it implements the special case for tags["*"] meaning +// all tags are both true and false at the same time. +func eval(x constraint.Expr, tags map[string]bool, prefer bool) bool { + switch x := x.(type) { + case *constraint.TagExpr: + return matchTag(x.Tag, tags, prefer) + case *constraint.NotExpr: + return !eval(x.X, tags, !prefer) + case *constraint.AndExpr: + return eval(x.X, tags, prefer) && eval(x.Y, tags, prefer) + case *constraint.OrExpr: + return eval(x.X, tags, prefer) || eval(x.Y, tags, prefer) + } + panic(fmt.Sprintf("unexpected constraint expression %T", x)) } // MatchFile returns false if the name contains a $GOOS or $GOARCH diff --git a/src/cmd/go/testdata/script/list_all_gobuild.txt b/src/cmd/go/testdata/script/list_all_gobuild.txt new file mode 100644 index 0000000000..e0a47398bb --- /dev/null +++ b/src/cmd/go/testdata/script/list_all_gobuild.txt @@ -0,0 +1,41 @@ +# go list all should work with GOOS=linux because all packages build on Linux +env GOOS=linux +go list all + +# go list all should work with GOOS=darwin, but it used to fail because +# in the absence of //go:build support, p looked like it needed q +# (p_test.go was not properly excluded), and q was Linux-only. +# +# Also testing with r and s that +build lines keep working. +env GOOS=darwin +go list all + +-- go.mod -- +go 1.17 +module m + +-- p/p.go -- +package p + +-- p/p_test.go -- +//go:build linux + +package p + +import "m/q" + +-- q/q_linux.go -- +package q + +-- r/r.go -- +package r + +-- r/r_test.go -- +// +build linux + +package r + +import "m/s" + +-- s/s_linux.go -- +package s From f229e7031a6efb2f23241b5da000c3b3203081d6 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 25 Aug 2021 12:48:26 -0400 Subject: [PATCH 222/406] all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor) When these packages are released as part of Go 1.18, Go 1.16 will no longer be supported, so we can remove the +build tags in these files. Ran go fix -fix=buildtag std cmd and then reverted the bootstrapDirs as defined in src/cmd/dist/buildtool.go, which need to continue to build with Go 1.4 for now. Also reverted src/vendor and src/cmd/vendor, which will need to be updated in their own repos first. Manual changes in runtime/pprof/mprof_test.go to adjust line numbers. For #41184. Change-Id: Ic0f93f7091295b6abc76ed5cd6e6746e1280861e Reviewed-on: https://go-review.googlesource.com/c/go/+/344955 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/archive/tar/stat_actime1.go | 1 - src/archive/tar/stat_actime2.go | 1 - src/archive/tar/stat_unix.go | 1 - src/bytes/boundary_test.go | 1 - src/cmd/api/run.go | 1 - src/cmd/go/go11.go | 1 - src/cmd/go/go_unix_test.go | 1 - src/cmd/go/internal/base/signal_notunix.go | 1 - src/cmd/go/internal/base/signal_unix.go | 1 - .../internal/filelock/filelock_fcntl.go | 1 - .../internal/filelock/filelock_other.go | 1 - .../internal/filelock/filelock_plan9.go | 1 - .../internal/filelock/filelock_test.go | 1 - .../internal/filelock/filelock_unix.go | 1 - .../internal/filelock/filelock_windows.go | 1 - .../lockedfile/lockedfile_filelock.go | 1 - .../internal/lockedfile/lockedfile_plan9.go | 1 - .../go/internal/lockedfile/lockedfile_test.go | 1 - .../go/internal/lockedfile/transform_test.go | 1 - src/cmd/go/internal/modfetch/bootstrap.go | 1 - .../go/internal/modfetch/codehost/shell.go | 1 - src/cmd/go/internal/modfetch/sumdb.go | 1 - src/cmd/go/internal/modload/stat_openfile.go | 1 - src/cmd/go/internal/modload/stat_unix.go | 1 - src/cmd/go/internal/modload/stat_windows.go | 1 - .../go/internal/robustio/robustio_flaky.go | 1 - .../go/internal/robustio/robustio_other.go | 1 - src/cmd/go/internal/test/genflags.go | 1 - src/cmd/go/internal/web/bootstrap.go | 1 - src/cmd/go/internal/web/http.go | 1 - src/cmd/go/internal/web/url_other.go | 1 - src/cmd/go/internal/web/url_other_test.go | 1 - src/cmd/go/internal/work/testgo.go | 1 - src/cmd/go/stop_other_test.go | 9 --------- src/cmd/go/stop_unix_test.go | 1 - src/cmd/nm/nm_cgo_test.go | 1 - src/cmd/pprof/readlineui.go | 3 --- src/cmd/trace/annotations_test.go | 1 - src/cmd/trace/trace_test.go | 1 - src/cmd/trace/trace_unix_test.go | 1 - src/crypto/aes/aes_gcm.go | 1 - src/crypto/aes/cipher_asm.go | 1 - src/crypto/aes/cipher_generic.go | 1 - src/crypto/aes/gcm_ppc64le.go | 1 - src/crypto/cipher/xor_generic.go | 1 - src/crypto/cipher/xor_ppc64x.go | 1 - src/crypto/ecdsa/ecdsa_noasm.go | 1 - src/crypto/ecdsa/ecdsa_s390x_test.go | 1 - .../internal/edwards25519/field/fe_amd64.go | 1 - .../edwards25519/field/fe_amd64_noasm.go | 1 - .../internal/edwards25519/field/fe_arm64.go | 1 - .../edwards25519/field/fe_arm64_noasm.go | 1 - src/crypto/elliptic/export_generate.go | 1 - src/crypto/elliptic/fuzz_test.go | 1 - src/crypto/elliptic/gen_p256_table.go | 1 - src/crypto/elliptic/p256.go | 1 - src/crypto/elliptic/p256_asm.go | 1 - src/crypto/elliptic/p256_asm_table.go | 1 - src/crypto/elliptic/p256_asm_table_test.go | 1 - src/crypto/elliptic/p256_generic.go | 1 - src/crypto/elliptic/p256_ppc64le.go | 1 - src/crypto/elliptic/p256_s390x.go | 1 - src/crypto/internal/subtle/aliasing.go | 1 - .../internal/subtle/aliasing_appengine.go | 1 - src/crypto/md5/gen.go | 1 - src/crypto/md5/md5block_decl.go | 1 - src/crypto/md5/md5block_generic.go | 1 - src/crypto/rand/eagain.go | 1 - src/crypto/rand/rand_batched.go | 1 - src/crypto/rand/rand_batched_test.go | 1 - src/crypto/rand/rand_getentropy.go | 1 - src/crypto/rand/rand_js.go | 1 - src/crypto/rand/rand_unix.go | 1 - src/crypto/sha1/fallback_test.go | 1 - src/crypto/sha1/issue15617_test.go | 2 -- src/crypto/sha1/sha1block_decl.go | 1 - src/crypto/sha1/sha1block_generic.go | 1 - src/crypto/sha256/fallback_test.go | 1 - src/crypto/sha256/sha256block_decl.go | 1 - src/crypto/sha256/sha256block_generic.go | 1 - src/crypto/sha512/fallback_test.go | 1 - src/crypto/sha512/sha512block_amd64.go | 1 - src/crypto/sha512/sha512block_decl.go | 1 - src/crypto/sha512/sha512block_generic.go | 1 - src/crypto/tls/generate_cert.go | 1 - src/crypto/tls/handshake_unix_test.go | 1 - .../x509/internal/macos/corefoundation.go | 1 - src/crypto/x509/internal/macos/security.go | 1 - src/crypto/x509/root_bsd.go | 1 - src/crypto/x509/root_darwin.go | 1 - src/crypto/x509/root_ios.go | 1 - src/crypto/x509/root_ios_gen.go | 1 - src/crypto/x509/root_js.go | 1 - src/crypto/x509/root_omit.go | 2 -- src/crypto/x509/root_omit_test.go | 2 -- src/crypto/x509/root_plan9.go | 1 - src/crypto/x509/root_unix.go | 1 - src/crypto/x509/root_unix_test.go | 1 - src/crypto/x509/x509_test_import.go | 1 - src/encoding/csv/fuzz.go | 1 - src/encoding/gob/debug.go | 1 - src/encoding/gob/decgen.go | 1 - src/encoding/gob/dump.go | 1 - src/encoding/gob/encgen.go | 1 - src/encoding/json/fuzz.go | 1 - src/go/build/gc.go | 1 - src/go/build/gccgo.go | 1 - src/go/doc/headscan.go | 1 - src/go/types/example_test.go | 1 - src/go/types/gotype.go | 1 - src/hash/crc32/crc32_otherarch.go | 1 - src/hash/crc32/gen_const_ppc64le.go | 1 - src/html/fuzz.go | 1 - src/image/color/palette/gen.go | 1 - src/image/internal/imageutil/gen.go | 1 - src/image/png/fuzz.go | 1 - src/index/suffixarray/gen.go | 1 - src/internal/abi/abi_arm64.go | 1 - src/internal/abi/abi_generic.go | 1 - src/internal/abi/abi_ppc64x.go | 2 -- src/internal/bytealg/compare_generic.go | 1 - src/internal/bytealg/compare_native.go | 1 - src/internal/bytealg/count_generic.go | 1 - src/internal/bytealg/count_native.go | 1 - src/internal/bytealg/index_generic.go | 1 - src/internal/bytealg/index_native.go | 1 - src/internal/bytealg/index_ppc64x.go | 2 -- src/internal/bytealg/indexbyte_generic.go | 1 - src/internal/bytealg/indexbyte_native.go | 1 - src/internal/cpu/cpu_arm64_android.go | 1 - src/internal/cpu/cpu_arm64_darwin.go | 1 - src/internal/cpu/cpu_arm64_freebsd.go | 1 - src/internal/cpu/cpu_arm64_hwcap.go | 1 - src/internal/cpu/cpu_arm64_linux.go | 1 - src/internal/cpu/cpu_arm64_other.go | 5 ----- src/internal/cpu/cpu_mips64x.go | 1 - src/internal/cpu/cpu_no_name.go | 1 - src/internal/cpu/cpu_ppc64x.go | 1 - src/internal/cpu/cpu_ppc64x_aix.go | 1 - src/internal/cpu/cpu_ppc64x_linux.go | 1 - src/internal/cpu/cpu_x86.go | 1 - src/internal/cpu/cpu_x86_test.go | 1 - src/internal/fuzz/minimize_test.go | 1 - src/internal/fuzz/sys_posix.go | 1 - src/internal/fuzz/sys_unimplemented.go | 1 - src/internal/fuzz/trace.go | 1 - src/internal/goarch/gengoarch.go | 1 - src/internal/goarch/zgoarch_386.go | 1 - src/internal/goarch/zgoarch_amd64.go | 1 - src/internal/goarch/zgoarch_arm.go | 1 - src/internal/goarch/zgoarch_arm64.go | 1 - src/internal/goarch/zgoarch_arm64be.go | 1 - src/internal/goarch/zgoarch_armbe.go | 1 - src/internal/goarch/zgoarch_loong64.go | 1 - src/internal/goarch/zgoarch_mips.go | 1 - src/internal/goarch/zgoarch_mips64.go | 1 - src/internal/goarch/zgoarch_mips64le.go | 1 - src/internal/goarch/zgoarch_mips64p32.go | 1 - src/internal/goarch/zgoarch_mips64p32le.go | 1 - src/internal/goarch/zgoarch_mipsle.go | 1 - src/internal/goarch/zgoarch_ppc.go | 1 - src/internal/goarch/zgoarch_ppc64.go | 1 - src/internal/goarch/zgoarch_ppc64le.go | 1 - src/internal/goarch/zgoarch_riscv.go | 1 - src/internal/goarch/zgoarch_riscv64.go | 1 - src/internal/goarch/zgoarch_s390.go | 1 - src/internal/goarch/zgoarch_s390x.go | 1 - src/internal/goarch/zgoarch_sparc.go | 1 - src/internal/goarch/zgoarch_sparc64.go | 1 - src/internal/goarch/zgoarch_wasm.go | 1 - src/internal/goos/gengoos.go | 1 - src/internal/goos/zgoos_aix.go | 1 - src/internal/goos/zgoos_android.go | 1 - src/internal/goos/zgoos_darwin.go | 1 - src/internal/goos/zgoos_dragonfly.go | 1 - src/internal/goos/zgoos_freebsd.go | 1 - src/internal/goos/zgoos_hurd.go | 1 - src/internal/goos/zgoos_illumos.go | 1 - src/internal/goos/zgoos_ios.go | 1 - src/internal/goos/zgoos_js.go | 1 - src/internal/goos/zgoos_linux.go | 1 - src/internal/goos/zgoos_netbsd.go | 1 - src/internal/goos/zgoos_openbsd.go | 1 - src/internal/goos/zgoos_plan9.go | 1 - src/internal/goos/zgoos_solaris.go | 1 - src/internal/goos/zgoos_windows.go | 1 - src/internal/goos/zgoos_zos.go | 1 - src/internal/goroot/gc.go | 1 - src/internal/goroot/gccgo.go | 1 - src/internal/poll/errno_unix.go | 1 - src/internal/poll/errno_windows.go | 1 - src/internal/poll/error_stub_test.go | 1 - src/internal/poll/export_posix_test.go | 1 - src/internal/poll/fcntl_js.go | 1 - src/internal/poll/fcntl_libc.go | 1 - src/internal/poll/fcntl_syscall.go | 1 - src/internal/poll/fd_fsync_posix.go | 1 - src/internal/poll/fd_poll_js.go | 1 - src/internal/poll/fd_poll_runtime.go | 1 - src/internal/poll/fd_posix.go | 1 - src/internal/poll/fd_posix_test.go | 1 - src/internal/poll/fd_unix.go | 1 - src/internal/poll/fd_writev_darwin.go | 1 - src/internal/poll/fd_writev_illumos.go | 1 - src/internal/poll/fd_writev_unix.go | 1 - src/internal/poll/hook_cloexec.go | 1 - src/internal/poll/hook_unix.go | 1 - src/internal/poll/iovec_illumos.go | 1 - src/internal/poll/iovec_unix.go | 1 - src/internal/poll/sendfile_bsd.go | 1 - src/internal/poll/sock_cloexec.go | 1 - src/internal/poll/sockopt.go | 1 - src/internal/poll/sockopt_unix.go | 1 - src/internal/poll/sockoptip.go | 1 - src/internal/poll/strconv.go | 1 - src/internal/poll/sys_cloexec.go | 1 - src/internal/poll/writev.go | 1 - .../syscall/execenv/execenv_default.go | 1 - .../syscall/execenv/execenv_windows.go | 1 - src/internal/syscall/unix/at.go | 1 - src/internal/syscall/unix/at_libc.go | 1 - .../syscall/unix/at_sysnum_fstatat64_linux.go | 1 - .../syscall/unix/at_sysnum_fstatat_linux.go | 1 - .../unix/at_sysnum_newfstatat_linux.go | 1 - .../syscall/unix/fcntl_linux_32bit.go | 1 - .../syscall/unix/getentropy_darwin.go | 1 - src/internal/syscall/unix/getrandom.go | 1 - src/internal/syscall/unix/nonblocking.go | 1 - src/internal/syscall/unix/nonblocking_js.go | 1 - src/internal/syscall/unix/nonblocking_libc.go | 1 - src/internal/syscall/unix/pipe2_illumos.go | 1 - .../syscall/unix/sysnum_linux_generic.go | 2 -- .../syscall/unix/sysnum_linux_mips64x.go | 1 - .../syscall/unix/sysnum_linux_mipsx.go | 1 - .../syscall/unix/sysnum_linux_ppc64x.go | 1 - src/internal/syscall/unix/writev_illumos.go | 1 - src/internal/testenv/testenv_cgo.go | 1 - src/internal/testenv/testenv_notwin.go | 1 - src/log/syslog/example_test.go | 1 - src/log/syslog/syslog.go | 1 - src/log/syslog/syslog_test.go | 1 - src/log/syslog/syslog_unix.go | 1 - src/math/cmplx/huge_test.go | 1 - src/math/dim_asm.go | 1 - src/math/dim_noasm.go | 1 - src/math/exp2_asm.go | 1 - src/math/exp2_noasm.go | 1 - src/math/exp_amd64.go | 1 - src/math/exp_asm.go | 1 - src/math/exp_noasm.go | 1 - src/math/floor_asm.go | 1 - src/math/floor_noasm.go | 1 - src/math/huge_test.go | 1 - src/math/hypot_asm.go | 1 - src/math/hypot_noasm.go | 1 - src/math/log_asm.go | 1 - src/math/log_stub.go | 1 - src/math/modf_asm.go | 1 - src/math/modf_noasm.go | 1 - src/math/rand/gen_cooked.go | 1 - src/math/sqrt_asm.go | 1 - src/math/sqrt_noasm.go | 1 - src/math/stubs.go | 1 - src/mime/type_unix.go | 1 - src/mime/type_unix_test.go | 1 - src/net/addrselect.go | 1 - src/net/addrselect_test.go | 1 - src/net/cgo_aix.go | 1 - src/net/cgo_android.go | 1 - src/net/cgo_bsd.go | 3 --- src/net/cgo_linux.go | 1 - src/net/cgo_netbsd.go | 1 - src/net/cgo_openbsd.go | 1 - src/net/cgo_resnew.go | 3 --- src/net/cgo_resold.go | 3 --- src/net/cgo_socknew.go | 3 --- src/net/cgo_sockold.go | 3 --- src/net/cgo_solaris.go | 1 - src/net/cgo_stub.go | 1 - src/net/cgo_unix.go | 3 --- src/net/cgo_unix_test.go | 3 --- src/net/cgo_windows.go | 1 - src/net/conf.go | 1 - src/net/conf_netcgo.go | 1 - src/net/conf_test.go | 1 - src/net/conn_test.go | 1 - src/net/dial_test.go | 1 - src/net/dial_unix_test.go | 1 - src/net/dnsclient_unix.go | 1 - src/net/dnsclient_unix_test.go | 1 - src/net/dnsconfig_unix.go | 1 - src/net/dnsconfig_unix_test.go | 1 - src/net/dnsname_test.go | 1 - src/net/error_posix.go | 1 - src/net/error_posix_test.go | 1 - src/net/error_test.go | 1 - src/net/error_unix.go | 1 - src/net/error_unix_test.go | 1 - src/net/external_test.go | 1 - src/net/fcntl_libc_test.go | 1 - src/net/fcntl_syscall_test.go | 1 - src/net/fd_posix.go | 1 - src/net/fd_unix.go | 1 - src/net/file_stub.go | 1 - src/net/file_test.go | 1 - src/net/file_unix.go | 1 - src/net/hook_unix.go | 1 - src/net/http/cgi/plan9_test.go | 1 - src/net/http/cgi/posix_test.go | 1 - src/net/http/h2_bundle.go | 1 - src/net/http/omithttp2.go | 1 - src/net/http/roundtrip.go | 1 - src/net/http/roundtrip_js.go | 1 - src/net/http/triv.go | 1 - src/net/interface_bsd.go | 1 - src/net/interface_bsd_test.go | 1 - src/net/interface_bsdvar.go | 1 - src/net/interface_stub.go | 1 - src/net/interface_test.go | 1 - src/net/interface_unix_test.go | 1 - src/net/internal/socktest/main_test.go | 1 - src/net/internal/socktest/main_unix_test.go | 1 - src/net/internal/socktest/switch_posix.go | 1 - src/net/internal/socktest/switch_stub.go | 1 - src/net/internal/socktest/switch_unix.go | 1 - src/net/internal/socktest/sys_cloexec.go | 1 - src/net/internal/socktest/sys_unix.go | 1 - src/net/ip_test.go | 1 - src/net/iprawsock_posix.go | 1 - src/net/iprawsock_test.go | 1 - src/net/ipsock_posix.go | 1 - src/net/listen_test.go | 1 - src/net/lookup_fake.go | 1 - src/net/lookup_test.go | 1 - src/net/lookup_unix.go | 1 - src/net/main_cloexec_test.go | 1 - src/net/main_conf_test.go | 1 - src/net/main_noconf_test.go | 1 - src/net/main_posix_test.go | 1 - src/net/main_test.go | 1 - src/net/main_unix_test.go | 1 - src/net/mockserver_test.go | 1 - src/net/net_fake.go | 1 - src/net/net_test.go | 1 - src/net/netgo_unix_test.go | 2 -- src/net/nss.go | 1 - src/net/nss_test.go | 1 - src/net/packetconn_test.go | 1 - src/net/port_unix.go | 1 - src/net/protoconn_test.go | 1 - src/net/rawconn_stub_test.go | 1 - src/net/rawconn_test.go | 1 - src/net/rawconn_unix_test.go | 1 - src/net/sendfile_stub.go | 1 - src/net/sendfile_test.go | 1 - src/net/sendfile_unix_alt.go | 1 - src/net/server_test.go | 1 - src/net/sock_bsd.go | 1 - src/net/sock_cloexec.go | 1 - src/net/sock_posix.go | 1 - src/net/sock_stub.go | 1 - src/net/sockaddr_posix.go | 1 - src/net/sockopt_bsd.go | 1 - src/net/sockopt_posix.go | 1 - src/net/sockopt_stub.go | 1 - src/net/sockoptip_bsdvar.go | 1 - src/net/sockoptip_posix.go | 1 - src/net/sockoptip_stub.go | 1 - src/net/splice_stub.go | 1 - src/net/splice_test.go | 1 - src/net/sys_cloexec.go | 1 - src/net/tcpsock_posix.go | 1 - src/net/tcpsock_test.go | 1 - src/net/tcpsock_unix_test.go | 1 - src/net/tcpsockopt_posix.go | 1 - src/net/tcpsockopt_stub.go | 1 - src/net/tcpsockopt_unix.go | 1 - src/net/timeout_test.go | 1 - src/net/udpsock_posix.go | 1 - src/net/udpsock_test.go | 1 - src/net/unixsock_posix.go | 1 - src/net/unixsock_readmsg_cloexec.go | 1 - src/net/unixsock_readmsg_cmsg_cloexec.go | 1 - src/net/unixsock_readmsg_other.go | 1 - src/net/unixsock_readmsg_test.go | 1 - src/net/unixsock_test.go | 1 - src/net/unixsock_windows_test.go | 1 - src/net/write_unix_test.go | 1 - src/net/writev_test.go | 1 - src/net/writev_unix.go | 1 - src/os/dir_unix.go | 1 - src/os/endian_big.go | 1 - src/os/endian_little.go | 1 - src/os/env_unix_test.go | 1 - src/os/error_errno.go | 1 - src/os/error_posix.go | 1 - src/os/error_unix_test.go | 1 - src/os/error_windows_test.go | 1 - src/os/exec/exec_linux_test.go | 1 - src/os/exec/exec_posix_test.go | 1 - src/os/exec/exec_unix.go | 1 - src/os/exec/exec_windows_test.go | 1 - src/os/exec/lp_js.go | 1 - src/os/exec/lp_unix.go | 1 - src/os/exec/lp_unix_test.go | 1 - src/os/exec/read3.go | 1 - src/os/exec_posix.go | 1 - src/os/exec_unix.go | 1 - src/os/exec_unix_test.go | 1 - src/os/executable_path.go | 1 - src/os/executable_plan9.go | 1 - src/os/executable_procfs.go | 1 - src/os/executable_sysctl.go | 1 - src/os/export_unix_test.go | 1 - src/os/fifo_test.go | 1 - src/os/file_posix.go | 1 - src/os/file_unix.go | 1 - src/os/os_unix_test.go | 1 - src/os/path_unix.go | 1 - src/os/pipe2_bsd.go | 1 - src/os/pipe2_illumos.go | 1 - src/os/pipe_bsd.go | 1 - src/os/pipe_test.go | 1 - src/os/rawconn.go | 1 - src/os/rawconn_test.go | 1 - src/os/readfrom_stub.go | 1 - src/os/removeall_at.go | 1 - src/os/removeall_noat.go | 1 - src/os/signal/example_unix_test.go | 1 - src/os/signal/internal/pty/pty.go | 2 -- src/os/signal/signal_cgo_test.go | 2 -- src/os/signal/signal_linux_test.go | 1 - src/os/signal/signal_test.go | 1 - src/os/signal/signal_unix.go | 1 - src/os/stat_js.go | 1 - src/os/stat_unix.go | 1 - src/os/sticky_bsd.go | 1 - src/os/sticky_notbsd.go | 8 -------- src/os/sys_bsd.go | 1 - src/os/sys_js.go | 1 - src/os/sys_unix.go | 1 - src/os/timeout_test.go | 1 - src/os/types_unix.go | 1 - src/os/user/cgo_listgroups_unix.go | 3 --- src/os/user/cgo_lookup_unix.go | 3 --- src/os/user/cgo_unix_test.go | 3 --- src/os/user/getgrouplist_darwin.go | 1 - src/os/user/getgrouplist_unix.go | 3 --- src/os/user/listgroups_stub.go | 1 - src/os/user/lookup_android.go | 1 - src/os/user/lookup_stubs.go | 1 - src/os/user/lookup_unix.go | 2 -- src/os/user/lookup_unix_test.go | 2 -- src/os/wait_unimp.go | 1 - src/os/wait_wait6.go | 1 - src/os/wait_waitid.go | 1 - src/path/filepath/example_unix_test.go | 1 - src/path/filepath/example_unix_walk_test.go | 1 - src/path/filepath/path_unix.go | 1 - src/path/filepath/symlink_unix.go | 1 - src/plugin/plugin_dlopen.go | 1 - src/plugin/plugin_stubs.go | 1 - src/plugin/plugin_test.go | 1 - src/reflect/abi_test.go | 1 - src/reflect/float32reg_generic.go | 1 - src/reflect/stubs_ppc64x.go | 1 - src/regexp/exec2_test.go | 1 - src/runtime/abi_test.go | 1 - src/runtime/asan.go | 1 - src/runtime/asan0.go | 1 - src/runtime/auxv_none.go | 1 - src/runtime/cgo/callbacks_traceback.go | 1 - src/runtime/cgo/dragonfly.go | 1 - src/runtime/cgo/freebsd.go | 1 - src/runtime/cgo/linux.go | 1 - src/runtime/cgo/mmap.go | 1 - src/runtime/cgo/netbsd.go | 1 - src/runtime/cgo/openbsd.go | 1 - src/runtime/cgo/setenv.go | 1 - src/runtime/cgo/sigaction.go | 1 - src/runtime/cgo_mmap.go | 1 - src/runtime/cgo_ppc64x.go | 1 - src/runtime/cgo_sigaction.go | 1 - src/runtime/cputicks.go | 1 - src/runtime/crash_cgo_test.go | 1 - src/runtime/crash_nonunix_test.go | 1 - src/runtime/crash_unix_test.go | 1 - src/runtime/debug/panic_test.go | 1 - src/runtime/debug_test.go | 1 - src/runtime/debugcall.go | 1 - src/runtime/debuglog_off.go | 1 - src/runtime/debuglog_on.go | 1 - src/runtime/defs1_linux.go | 1 - src/runtime/defs2_linux.go | 1 - src/runtime/defs3_linux.go | 1 - src/runtime/defs_aix.go | 1 - src/runtime/defs_aix_ppc64.go | 1 - src/runtime/defs_arm_linux.go | 1 - src/runtime/defs_darwin.go | 1 - src/runtime/defs_dragonfly.go | 1 - src/runtime/defs_freebsd.go | 1 - src/runtime/defs_linux.go | 1 - src/runtime/defs_linux_mips64x.go | 2 -- src/runtime/defs_linux_mipsx.go | 2 -- src/runtime/defs_netbsd.go | 1 - src/runtime/defs_netbsd_386.go | 1 - src/runtime/defs_netbsd_amd64.go | 1 - src/runtime/defs_netbsd_arm.go | 1 - src/runtime/defs_openbsd.go | 1 - src/runtime/defs_solaris.go | 1 - src/runtime/defs_solaris_amd64.go | 1 - src/runtime/env_posix.go | 1 - .../export_debug_regabiargs_off_test.go | 1 - .../export_debug_regabiargs_on_test.go | 1 - src/runtime/export_debug_test.go | 1 - src/runtime/export_futex_test.go | 1 - src/runtime/export_mmap_test.go | 1 - src/runtime/export_pipe2_test.go | 1 - src/runtime/export_pipe_test.go | 1 - src/runtime/export_unix_test.go | 1 - src/runtime/futex_test.go | 2 -- src/runtime/hash32.go | 1 - src/runtime/hash64.go | 1 - src/runtime/internal/atomic/atomic_386.go | 1 - src/runtime/internal/atomic/atomic_arm.go | 1 - src/runtime/internal/atomic/atomic_arm64.go | 1 - src/runtime/internal/atomic/atomic_mips64x.go | 1 - src/runtime/internal/atomic/atomic_mipsx.go | 1 - src/runtime/internal/atomic/atomic_ppc64x.go | 1 - src/runtime/internal/atomic/stubs.go | 1 - src/runtime/internal/atomic/types_64bit.go | 1 - src/runtime/internal/sys/intrinsics.go | 1 - src/runtime/internal/sys/intrinsics_stubs.go | 1 - src/runtime/lfstack_32bit.go | 1 - src/runtime/lfstack_64bit.go | 1 - src/runtime/libfuzzer.go | 1 - src/runtime/lock_futex.go | 1 - src/runtime/lock_js.go | 1 - src/runtime/lock_sema.go | 1 - src/runtime/lockrank_off.go | 1 - src/runtime/lockrank_on.go | 1 - src/runtime/mem_bsd.go | 1 - src/runtime/mem_js.go | 1 - src/runtime/mkduff.go | 1 - src/runtime/mkfastlog2table.go | 1 - src/runtime/mkpreempt.go | 1 - src/runtime/mksizeclasses.go | 1 - src/runtime/mmap.go | 9 --------- src/runtime/mpagealloc_32bit.go | 1 - src/runtime/mpagealloc_64bit.go | 1 - src/runtime/msan.go | 1 - src/runtime/msan0.go | 1 - src/runtime/nbpipe_fcntl_libc_test.go | 1 - src/runtime/nbpipe_fcntl_unix_test.go | 1 - src/runtime/nbpipe_pipe.go | 1 - src/runtime/nbpipe_pipe2.go | 1 - src/runtime/nbpipe_test.go | 1 - src/runtime/netpoll.go | 1 - src/runtime/netpoll_epoll.go | 1 - src/runtime/netpoll_fake.go | 1 - src/runtime/netpoll_kqueue.go | 1 - src/runtime/netpoll_stub.go | 1 - src/runtime/norace_linux_test.go | 1 - src/runtime/norace_test.go | 1 - src/runtime/os_aix.go | 1 - src/runtime/os_freebsd2.go | 1 - src/runtime/os_freebsd_noauxv.go | 1 - src/runtime/os_js.go | 1 - src/runtime/os_linux_arm64.go | 1 - src/runtime/os_linux_be64.go | 2 -- src/runtime/os_linux_generic.go | 1 - src/runtime/os_linux_mips64x.go | 2 -- src/runtime/os_linux_mipsx.go | 2 -- src/runtime/os_linux_noauxv.go | 1 - src/runtime/os_linux_novdso.go | 1 - src/runtime/os_linux_ppc64x.go | 2 -- src/runtime/os_linux_x86.go | 2 -- src/runtime/os_nonopenbsd.go | 1 - src/runtime/os_only_solaris.go | 1 - src/runtime/os_openbsd_libc.go | 1 - src/runtime/os_openbsd_syscall.go | 1 - src/runtime/os_openbsd_syscall1.go | 1 - src/runtime/os_openbsd_syscall2.go | 1 - src/runtime/panic32.go | 1 - src/runtime/pprof/mprof_test.go | 19 +++++++++---------- src/runtime/pprof/pprof_norusage.go | 1 - src/runtime/pprof/pprof_rusage.go | 1 - src/runtime/pprof/pprof_test.go | 1 - src/runtime/pprof/rusage_test.go | 1 - src/runtime/preempt_nonwindows.go | 1 - src/runtime/race.go | 1 - src/runtime/race/output_test.go | 1 - src/runtime/race/race.go | 1 - src/runtime/race/race_linux_test.go | 1 - src/runtime/race/race_test.go | 1 - src/runtime/race/race_unix_test.go | 2 -- src/runtime/race/race_windows_test.go | 1 - src/runtime/race/sched_test.go | 1 - src/runtime/race/syso_test.go | 1 - src/runtime/race/timer_test.go | 1 - src/runtime/race0.go | 1 - src/runtime/relax_stub.go | 1 - src/runtime/runtime_mmap_test.go | 1 - src/runtime/runtime_unix_test.go | 1 - src/runtime/semasleep_test.go | 1 - src/runtime/sigaction.go | 1 - src/runtime/signal_386.go | 1 - src/runtime/signal_aix_ppc64.go | 1 - src/runtime/signal_amd64.go | 2 -- src/runtime/signal_arm.go | 1 - src/runtime/signal_arm64.go | 1 - src/runtime/signal_linux_mips64x.go | 2 -- src/runtime/signal_linux_mipsx.go | 2 -- src/runtime/signal_linux_ppc64x.go | 2 -- src/runtime/signal_mips64x.go | 2 -- src/runtime/signal_mipsx.go | 2 -- src/runtime/signal_ppc64x.go | 2 -- src/runtime/signal_riscv64.go | 1 - src/runtime/signal_unix.go | 1 - src/runtime/signal_windows_test.go | 1 - src/runtime/sigqueue.go | 1 - src/runtime/sigqueue_note.go | 1 - src/runtime/sigtab_linux_generic.go | 1 - src/runtime/sigtab_linux_mipsx.go | 2 -- src/runtime/stubs2.go | 1 - src/runtime/stubs3.go | 1 - src/runtime/stubs_linux.go | 1 - src/runtime/stubs_mips64x.go | 1 - src/runtime/stubs_mipsx.go | 1 - src/runtime/stubs_nonlinux.go | 1 - src/runtime/stubs_ppc64.go | 1 - src/runtime/stubs_ppc64x.go | 1 - src/runtime/sys_libc.go | 1 - src/runtime/sys_mips64x.go | 1 - src/runtime/sys_mipsx.go | 1 - src/runtime/sys_nonppc64x.go | 1 - src/runtime/sys_openbsd.go | 1 - src/runtime/sys_openbsd1.go | 1 - src/runtime/sys_openbsd2.go | 1 - src/runtime/sys_openbsd3.go | 1 - src/runtime/sys_ppc64x.go | 1 - src/runtime/sys_x86.go | 1 - src/runtime/time_fake.go | 1 - src/runtime/time_nofake.go | 1 - src/runtime/timeasm.go | 2 -- src/runtime/timestub.go | 3 --- src/runtime/timestub2.go | 7 ------- src/runtime/tls_stub.go | 1 - src/runtime/vdso_elf32.go | 2 -- src/runtime/vdso_elf64.go | 2 -- src/runtime/vdso_freebsd.go | 1 - src/runtime/vdso_freebsd_x86.go | 2 -- src/runtime/vdso_in_none.go | 1 - src/runtime/vdso_linux.go | 2 -- src/runtime/vdso_linux_mips64x.go | 2 -- src/runtime/vdso_linux_ppc64x.go | 2 -- src/runtime/vlrt.go | 1 - src/runtime/wincallback.go | 1 - src/runtime/write_err.go | 1 - src/sync/pool_test.go | 1 - src/sync/runtime2.go | 1 - src/sync/runtime2_lockrank.go | 1 - src/syscall/bpf_bsd.go | 1 - src/syscall/creds_test.go | 1 - src/syscall/dirent.go | 1 - src/syscall/dirent_test.go | 1 - src/syscall/endian_big.go | 1 - src/syscall/endian_little.go | 1 - src/syscall/env_unix.go | 1 - src/syscall/exec_aix_test.go | 1 - src/syscall/exec_bsd.go | 1 - src/syscall/exec_libc.go | 1 - src/syscall/exec_libc2.go | 1 - src/syscall/exec_linux.go | 1 - src/syscall/exec_linux_test.go | 1 - src/syscall/exec_pdeathsig_test.go | 1 - src/syscall/exec_solaris_test.go | 1 - src/syscall/exec_unix.go | 1 - src/syscall/exec_unix_test.go | 1 - src/syscall/export_unix_test.go | 1 - src/syscall/flock.go | 1 - src/syscall/flock_linux_32bit.go | 1 - src/syscall/forkpipe.go | 1 - src/syscall/forkpipe2.go | 1 - src/syscall/fs_js.go | 1 - src/syscall/getdirentries_test.go | 1 - src/syscall/mkasm.go | 1 - src/syscall/mkpost.go | 1 - src/syscall/mksyscall_windows.go | 1 - src/syscall/mmap_unix_test.go | 1 - src/syscall/msan.go | 1 - src/syscall/msan0.go | 1 - src/syscall/net_js.go | 1 - src/syscall/ptrace_darwin.go | 1 - src/syscall/ptrace_ios.go | 1 - src/syscall/route_bsd.go | 1 - src/syscall/route_freebsd_32bit.go | 1 - src/syscall/route_freebsd_64bit.go | 1 - src/syscall/setuidgid_32_linux.go | 2 -- src/syscall/setuidgid_linux.go | 1 - src/syscall/sockcmsg_unix.go | 1 - src/syscall/sockcmsg_unix_other.go | 1 - src/syscall/syscall_bsd.go | 1 - src/syscall/syscall_bsd_test.go | 1 - src/syscall/syscall_freebsd_test.go | 1 - src/syscall/syscall_illumos.go | 1 - src/syscall/syscall_js.go | 1 - src/syscall/syscall_linux_mips64x.go | 2 -- src/syscall/syscall_linux_mipsx.go | 2 -- src/syscall/syscall_linux_ppc64x.go | 2 -- src/syscall/syscall_openbsd1.go | 1 - src/syscall/syscall_openbsd_libc.go | 1 - src/syscall/syscall_ptrace_test.go | 1 - src/syscall/syscall_unix.go | 1 - src/syscall/syscall_unix_test.go | 1 - src/syscall/tables_js.go | 1 - src/syscall/time_fake.go | 1 - src/syscall/time_nofake.go | 1 - src/syscall/timestruct.go | 1 - src/syscall/types_aix.go | 1 - src/syscall/types_darwin.go | 1 - src/syscall/types_dragonfly.go | 1 - src/syscall/types_freebsd.go | 1 - src/syscall/types_illumos_amd64.go | 1 - src/syscall/types_linux.go | 1 - src/syscall/types_netbsd.go | 1 - src/syscall/types_openbsd.go | 1 - src/syscall/types_solaris.go | 1 - src/syscall/zerrors_darwin_amd64.go | 1 - src/syscall/zerrors_darwin_arm64.go | 1 - src/syscall/zerrors_dragonfly_amd64.go | 1 - src/syscall/zerrors_freebsd_386.go | 1 - src/syscall/zerrors_freebsd_amd64.go | 1 - src/syscall/zerrors_freebsd_arm.go | 1 - src/syscall/zerrors_freebsd_arm64.go | 1 - src/syscall/zerrors_linux_386.go | 1 - src/syscall/zerrors_linux_amd64.go | 1 - src/syscall/zerrors_linux_arm.go | 1 - src/syscall/zerrors_linux_arm64.go | 1 - src/syscall/zerrors_linux_ppc64.go | 1 - src/syscall/zerrors_linux_ppc64le.go | 1 - src/syscall/zerrors_netbsd_386.go | 1 - src/syscall/zerrors_netbsd_amd64.go | 1 - src/syscall/zerrors_netbsd_arm.go | 1 - src/syscall/zerrors_netbsd_arm64.go | 1 - src/syscall/zerrors_openbsd_386.go | 1 - src/syscall/zerrors_openbsd_amd64.go | 1 - src/syscall/zerrors_openbsd_arm.go | 1 - src/syscall/zerrors_solaris_amd64.go | 1 - src/syscall/zsyscall_aix_ppc64.go | 1 - src/syscall/zsyscall_darwin_amd64.go | 1 - src/syscall/zsyscall_darwin_arm64.go | 1 - src/syscall/zsyscall_dragonfly_amd64.go | 1 - src/syscall/zsyscall_freebsd_386.go | 1 - src/syscall/zsyscall_freebsd_amd64.go | 1 - src/syscall/zsyscall_freebsd_arm.go | 1 - src/syscall/zsyscall_freebsd_arm64.go | 1 - src/syscall/zsyscall_linux_386.go | 1 - src/syscall/zsyscall_linux_amd64.go | 1 - src/syscall/zsyscall_linux_arm.go | 1 - src/syscall/zsyscall_linux_arm64.go | 1 - src/syscall/zsyscall_linux_mips.go | 1 - src/syscall/zsyscall_linux_mips64.go | 1 - src/syscall/zsyscall_linux_mips64le.go | 1 - src/syscall/zsyscall_linux_mipsle.go | 1 - src/syscall/zsyscall_linux_ppc64.go | 1 - src/syscall/zsyscall_linux_ppc64le.go | 1 - src/syscall/zsyscall_linux_riscv64.go | 1 - src/syscall/zsyscall_linux_s390x.go | 1 - src/syscall/zsyscall_netbsd_386.go | 1 - src/syscall/zsyscall_netbsd_amd64.go | 1 - src/syscall/zsyscall_netbsd_arm.go | 1 - src/syscall/zsyscall_netbsd_arm64.go | 1 - src/syscall/zsyscall_openbsd_386.go | 1 - src/syscall/zsyscall_openbsd_amd64.go | 1 - src/syscall/zsyscall_openbsd_arm.go | 1 - src/syscall/zsyscall_openbsd_arm64.go | 1 - src/syscall/zsyscall_openbsd_mips64.go | 1 - src/syscall/zsyscall_plan9_386.go | 1 - src/syscall/zsyscall_plan9_amd64.go | 1 - src/syscall/zsyscall_plan9_arm.go | 1 - src/syscall/zsyscall_solaris_amd64.go | 1 - src/syscall/zsysnum_darwin_amd64.go | 1 - src/syscall/zsysnum_darwin_arm64.go | 1 - src/syscall/zsysnum_dragonfly_amd64.go | 1 - src/syscall/zsysnum_freebsd_386.go | 1 - src/syscall/zsysnum_freebsd_amd64.go | 1 - src/syscall/zsysnum_freebsd_arm.go | 1 - src/syscall/zsysnum_freebsd_arm64.go | 1 - src/syscall/zsysnum_linux_386.go | 1 - src/syscall/zsysnum_linux_amd64.go | 1 - src/syscall/zsysnum_linux_arm.go | 1 - src/syscall/zsysnum_linux_arm64.go | 1 - src/syscall/zsysnum_linux_ppc64.go | 1 - src/syscall/zsysnum_linux_ppc64le.go | 1 - src/syscall/zsysnum_netbsd_386.go | 1 - src/syscall/zsysnum_netbsd_amd64.go | 1 - src/syscall/zsysnum_netbsd_arm.go | 1 - src/syscall/zsysnum_netbsd_arm64.go | 1 - src/syscall/zsysnum_openbsd_386.go | 1 - src/syscall/zsysnum_openbsd_amd64.go | 1 - src/syscall/zsysnum_openbsd_arm.go | 1 - src/syscall/zsysnum_solaris_amd64.go | 1 - src/syscall/ztypes_darwin_amd64.go | 1 - src/syscall/ztypes_darwin_arm64.go | 1 - src/syscall/ztypes_dragonfly_amd64.go | 1 - src/syscall/ztypes_freebsd_386.go | 1 - src/syscall/ztypes_freebsd_amd64.go | 1 - src/syscall/ztypes_freebsd_arm.go | 1 - src/syscall/ztypes_freebsd_arm64.go | 1 - src/syscall/ztypes_linux_386.go | 1 - src/syscall/ztypes_linux_amd64.go | 1 - src/syscall/ztypes_linux_arm.go | 1 - src/syscall/ztypes_linux_arm64.go | 1 - src/syscall/ztypes_linux_ppc64.go | 1 - src/syscall/ztypes_linux_ppc64le.go | 1 - src/syscall/ztypes_netbsd_386.go | 1 - src/syscall/ztypes_netbsd_amd64.go | 1 - src/syscall/ztypes_netbsd_arm.go | 1 - src/syscall/ztypes_netbsd_arm64.go | 1 - src/syscall/ztypes_openbsd_386.go | 1 - src/syscall/ztypes_openbsd_amd64.go | 1 - src/syscall/ztypes_solaris_amd64.go | 1 - src/testing/run_example.go | 1 - src/testing/run_example_js.go | 1 - src/time/embed.go | 1 - src/time/genzabbrs.go | 1 - src/time/sys_plan9.go | 1 - src/time/sys_unix.go | 1 - src/time/tzdata/generate_zipdata.go | 1 - src/time/zoneinfo_ios.go | 1 - src/time/zoneinfo_js.go | 1 - src/time/zoneinfo_unix.go | 1 - src/time/zoneinfo_unix_test.go | 1 - 834 files changed, 9 insertions(+), 941 deletions(-) diff --git a/src/archive/tar/stat_actime1.go b/src/archive/tar/stat_actime1.go index 4fdf2a04b3..c4c2480fee 100644 --- a/src/archive/tar/stat_actime1.go +++ b/src/archive/tar/stat_actime1.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || linux || dragonfly || openbsd || solaris -// +build aix linux dragonfly openbsd solaris package tar diff --git a/src/archive/tar/stat_actime2.go b/src/archive/tar/stat_actime2.go index 5a9a35cbb4..f76d6be220 100644 --- a/src/archive/tar/stat_actime2.go +++ b/src/archive/tar/stat_actime2.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || freebsd || netbsd -// +build darwin freebsd netbsd package tar diff --git a/src/archive/tar/stat_unix.go b/src/archive/tar/stat_unix.go index 3957349d6e..717a0b3abc 100644 --- a/src/archive/tar/stat_unix.go +++ b/src/archive/tar/stat_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || linux || darwin || dragonfly || freebsd || openbsd || netbsd || solaris -// +build aix linux darwin dragonfly freebsd openbsd netbsd solaris package tar diff --git a/src/bytes/boundary_test.go b/src/bytes/boundary_test.go index 5a47526593..8dac751866 100644 --- a/src/bytes/boundary_test.go +++ b/src/bytes/boundary_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // //go:build linux -// +build linux package bytes_test diff --git a/src/cmd/api/run.go b/src/cmd/api/run.go index 81979de191..1b94a1b883 100644 --- a/src/cmd/api/run.go +++ b/src/cmd/api/run.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // The run program is invoked via the dist tool. // To invoke manually: go tool dist test -run api --no-rebuild diff --git a/src/cmd/go/go11.go b/src/cmd/go/go11.go index a1f2727825..9faa7cba42 100644 --- a/src/cmd/go/go11.go +++ b/src/cmd/go/go11.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build go1.1 -// +build go1.1 package main diff --git a/src/cmd/go/go_unix_test.go b/src/cmd/go/go_unix_test.go index 7d5ff9bbb7..bab9494401 100644 --- a/src/cmd/go/go_unix_test.go +++ b/src/cmd/go/go_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build darwin dragonfly freebsd linux netbsd openbsd solaris package main_test diff --git a/src/cmd/go/internal/base/signal_notunix.go b/src/cmd/go/internal/base/signal_notunix.go index 5cc0b0f101..682705f9b2 100644 --- a/src/cmd/go/internal/base/signal_notunix.go +++ b/src/cmd/go/internal/base/signal_notunix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 || windows -// +build plan9 windows package base diff --git a/src/cmd/go/internal/base/signal_unix.go b/src/cmd/go/internal/base/signal_unix.go index cdc2658372..657ff38584 100644 --- a/src/cmd/go/internal/base/signal_unix.go +++ b/src/cmd/go/internal/base/signal_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || js || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js linux netbsd openbsd solaris package base diff --git a/src/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go b/src/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go index a37b2ad6d1..09354d2306 100644 --- a/src/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go +++ b/src/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || (solaris && !illumos) -// +build aix solaris,!illumos // This code implements the filelock API using POSIX 'fcntl' locks, which attach // to an (inode, process) pair rather than a file descriptor. To avoid unlocking diff --git a/src/cmd/go/internal/lockedfile/internal/filelock/filelock_other.go b/src/cmd/go/internal/lockedfile/internal/filelock/filelock_other.go index 70f5d7a688..491bec39af 100644 --- a/src/cmd/go/internal/lockedfile/internal/filelock/filelock_other.go +++ b/src/cmd/go/internal/lockedfile/internal/filelock/filelock_other.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !plan9 && !solaris && !windows -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!plan9,!solaris,!windows package filelock diff --git a/src/cmd/go/internal/lockedfile/internal/filelock/filelock_plan9.go b/src/cmd/go/internal/lockedfile/internal/filelock/filelock_plan9.go index 908afb6c8c..54b2c946e0 100644 --- a/src/cmd/go/internal/lockedfile/internal/filelock/filelock_plan9.go +++ b/src/cmd/go/internal/lockedfile/internal/filelock/filelock_plan9.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 -// +build plan9 package filelock diff --git a/src/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go b/src/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go index 640d4406f4..7bd7bd28f5 100644 --- a/src/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go +++ b/src/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js && !plan9 -// +build !js,!plan9 package filelock_test diff --git a/src/cmd/go/internal/lockedfile/internal/filelock/filelock_unix.go b/src/cmd/go/internal/lockedfile/internal/filelock/filelock_unix.go index 878a1e770d..d7778d05de 100644 --- a/src/cmd/go/internal/lockedfile/internal/filelock/filelock_unix.go +++ b/src/cmd/go/internal/lockedfile/internal/filelock/filelock_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || illumos || linux || netbsd || openbsd -// +build darwin dragonfly freebsd illumos linux netbsd openbsd package filelock diff --git a/src/cmd/go/internal/lockedfile/internal/filelock/filelock_windows.go b/src/cmd/go/internal/lockedfile/internal/filelock/filelock_windows.go index dd27ce92bd..e2ca538304 100644 --- a/src/cmd/go/internal/lockedfile/internal/filelock/filelock_windows.go +++ b/src/cmd/go/internal/lockedfile/internal/filelock/filelock_windows.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package filelock diff --git a/src/cmd/go/internal/lockedfile/lockedfile_filelock.go b/src/cmd/go/internal/lockedfile/lockedfile_filelock.go index e4923f6876..1a677a7fe4 100644 --- a/src/cmd/go/internal/lockedfile/lockedfile_filelock.go +++ b/src/cmd/go/internal/lockedfile/lockedfile_filelock.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !plan9 -// +build !plan9 package lockedfile diff --git a/src/cmd/go/internal/lockedfile/lockedfile_plan9.go b/src/cmd/go/internal/lockedfile/lockedfile_plan9.go index 979118b10a..35669388e0 100644 --- a/src/cmd/go/internal/lockedfile/lockedfile_plan9.go +++ b/src/cmd/go/internal/lockedfile/lockedfile_plan9.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 -// +build plan9 package lockedfile diff --git a/src/cmd/go/internal/lockedfile/lockedfile_test.go b/src/cmd/go/internal/lockedfile/lockedfile_test.go index 3acc6695a7..c9907db46c 100644 --- a/src/cmd/go/internal/lockedfile/lockedfile_test.go +++ b/src/cmd/go/internal/lockedfile/lockedfile_test.go @@ -4,7 +4,6 @@ // js does not support inter-process file locking. //go:build !js -// +build !js package lockedfile_test diff --git a/src/cmd/go/internal/lockedfile/transform_test.go b/src/cmd/go/internal/lockedfile/transform_test.go index b753346e7d..3c1caa334e 100644 --- a/src/cmd/go/internal/lockedfile/transform_test.go +++ b/src/cmd/go/internal/lockedfile/transform_test.go @@ -4,7 +4,6 @@ // js does not support inter-process file locking. //go:build !js -// +build !js package lockedfile_test diff --git a/src/cmd/go/internal/modfetch/bootstrap.go b/src/cmd/go/internal/modfetch/bootstrap.go index ed694581a7..e23669fb00 100644 --- a/src/cmd/go/internal/modfetch/bootstrap.go +++ b/src/cmd/go/internal/modfetch/bootstrap.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build cmd_go_bootstrap -// +build cmd_go_bootstrap package modfetch diff --git a/src/cmd/go/internal/modfetch/codehost/shell.go b/src/cmd/go/internal/modfetch/codehost/shell.go index 0e9f381966..eaa01950b9 100644 --- a/src/cmd/go/internal/modfetch/codehost/shell.go +++ b/src/cmd/go/internal/modfetch/codehost/shell.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // Interactive debugging shell for codehost.Repo implementations. diff --git a/src/cmd/go/internal/modfetch/sumdb.go b/src/cmd/go/internal/modfetch/sumdb.go index 79961b4324..492b03bd84 100644 --- a/src/cmd/go/internal/modfetch/sumdb.go +++ b/src/cmd/go/internal/modfetch/sumdb.go @@ -5,7 +5,6 @@ // Go checksum database lookup //go:build !cmd_go_bootstrap -// +build !cmd_go_bootstrap package modfetch diff --git a/src/cmd/go/internal/modload/stat_openfile.go b/src/cmd/go/internal/modload/stat_openfile.go index 368f893198..ff7c124af5 100644 --- a/src/cmd/go/internal/modload/stat_openfile.go +++ b/src/cmd/go/internal/modload/stat_openfile.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (js && wasm) || plan9 -// +build js,wasm plan9 // On plan9, per http://9p.io/magic/man2html/2/access: “Since file permissions // are checked by the server and group information is not known to the client, diff --git a/src/cmd/go/internal/modload/stat_unix.go b/src/cmd/go/internal/modload/stat_unix.go index e079d73990..8a3653ba80 100644 --- a/src/cmd/go/internal/modload/stat_unix.go +++ b/src/cmd/go/internal/modload/stat_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package modload diff --git a/src/cmd/go/internal/modload/stat_windows.go b/src/cmd/go/internal/modload/stat_windows.go index 825e60b27a..f29a99165e 100644 --- a/src/cmd/go/internal/modload/stat_windows.go +++ b/src/cmd/go/internal/modload/stat_windows.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package modload diff --git a/src/cmd/go/internal/robustio/robustio_flaky.go b/src/cmd/go/internal/robustio/robustio_flaky.go index d5c241857b..c56e36ca62 100644 --- a/src/cmd/go/internal/robustio/robustio_flaky.go +++ b/src/cmd/go/internal/robustio/robustio_flaky.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows || darwin -// +build windows darwin package robustio diff --git a/src/cmd/go/internal/robustio/robustio_other.go b/src/cmd/go/internal/robustio/robustio_other.go index 3a20cac6cf..da9a46e4fa 100644 --- a/src/cmd/go/internal/robustio/robustio_other.go +++ b/src/cmd/go/internal/robustio/robustio_other.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows && !darwin -// +build !windows,!darwin package robustio diff --git a/src/cmd/go/internal/test/genflags.go b/src/cmd/go/internal/test/genflags.go index cba366062f..10f290090c 100644 --- a/src/cmd/go/internal/test/genflags.go +++ b/src/cmd/go/internal/test/genflags.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore package main diff --git a/src/cmd/go/internal/web/bootstrap.go b/src/cmd/go/internal/web/bootstrap.go index 08686cdfcf..ab88e9e478 100644 --- a/src/cmd/go/internal/web/bootstrap.go +++ b/src/cmd/go/internal/web/bootstrap.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build cmd_go_bootstrap -// +build cmd_go_bootstrap // This code is compiled only into the bootstrap 'go' binary. // These stubs avoid importing packages with large dependency diff --git a/src/cmd/go/internal/web/http.go b/src/cmd/go/internal/web/http.go index 81f841d2c6..a92326db01 100644 --- a/src/cmd/go/internal/web/http.go +++ b/src/cmd/go/internal/web/http.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !cmd_go_bootstrap -// +build !cmd_go_bootstrap // This code is compiled into the real 'go' binary, but it is not // compiled into the binary that is built during all.bash, so as diff --git a/src/cmd/go/internal/web/url_other.go b/src/cmd/go/internal/web/url_other.go index 453af402b4..84bbd72820 100644 --- a/src/cmd/go/internal/web/url_other.go +++ b/src/cmd/go/internal/web/url_other.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows -// +build !windows package web diff --git a/src/cmd/go/internal/web/url_other_test.go b/src/cmd/go/internal/web/url_other_test.go index 4d6ed2ec7f..5c197de800 100644 --- a/src/cmd/go/internal/web/url_other_test.go +++ b/src/cmd/go/internal/web/url_other_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows -// +build !windows package web diff --git a/src/cmd/go/internal/work/testgo.go b/src/cmd/go/internal/work/testgo.go index 8b77871b23..a09b65a23c 100644 --- a/src/cmd/go/internal/work/testgo.go +++ b/src/cmd/go/internal/work/testgo.go @@ -5,7 +5,6 @@ // This file contains extra hooks for testing the go command. //go:build testgo -// +build testgo package work diff --git a/src/cmd/go/stop_other_test.go b/src/cmd/go/stop_other_test.go index e1cc6cf8ba..35c12858c1 100644 --- a/src/cmd/go/stop_other_test.go +++ b/src/cmd/go/stop_other_test.go @@ -3,15 +3,6 @@ // license that can be found in the LICENSE file. //go:build !(aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris) -// +build !aix -// +build !darwin -// +build !dragonfly -// +build !freebsd -// +build !js !wasm -// +build !linux -// +build !netbsd -// +build !openbsd -// +build !solaris package main_test diff --git a/src/cmd/go/stop_unix_test.go b/src/cmd/go/stop_unix_test.go index ac35b240f0..5939f0d40d 100644 --- a/src/cmd/go/stop_unix_test.go +++ b/src/cmd/go/stop_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package main_test diff --git a/src/cmd/nm/nm_cgo_test.go b/src/cmd/nm/nm_cgo_test.go index 1544be041a..0c826738ec 100644 --- a/src/cmd/nm/nm_cgo_test.go +++ b/src/cmd/nm/nm_cgo_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo -// +build cgo package main diff --git a/src/cmd/pprof/readlineui.go b/src/cmd/pprof/readlineui.go index f46e934e0f..7ad712cd60 100644 --- a/src/cmd/pprof/readlineui.go +++ b/src/cmd/pprof/readlineui.go @@ -6,9 +6,6 @@ // that provides the readline functionality if possible. //go:build (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows) && !appengine && !android -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows -// +build !appengine -// +build !android package main diff --git a/src/cmd/trace/annotations_test.go b/src/cmd/trace/annotations_test.go index acd5693c7d..9f1c8e3b3b 100644 --- a/src/cmd/trace/annotations_test.go +++ b/src/cmd/trace/annotations_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package main diff --git a/src/cmd/trace/trace_test.go b/src/cmd/trace/trace_test.go index 2b1a68d7f3..87fd3a3515 100644 --- a/src/cmd/trace/trace_test.go +++ b/src/cmd/trace/trace_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package main diff --git a/src/cmd/trace/trace_unix_test.go b/src/cmd/trace/trace_unix_test.go index 8dc56a8c7b..f35061ec63 100644 --- a/src/cmd/trace/trace_unix_test.go +++ b/src/cmd/trace/trace_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build darwin dragonfly freebsd linux netbsd openbsd solaris package main diff --git a/src/crypto/aes/aes_gcm.go b/src/crypto/aes/aes_gcm.go index 1de0e457a2..98fb6d8e9b 100644 --- a/src/crypto/aes/aes_gcm.go +++ b/src/crypto/aes/aes_gcm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || arm64 -// +build amd64 arm64 package aes diff --git a/src/crypto/aes/cipher_asm.go b/src/crypto/aes/cipher_asm.go index 4251805ef9..c948f1a579 100644 --- a/src/crypto/aes/cipher_asm.go +++ b/src/crypto/aes/cipher_asm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || arm64 -// +build amd64 arm64 package aes diff --git a/src/crypto/aes/cipher_generic.go b/src/crypto/aes/cipher_generic.go index 22ce3be7f3..bff21ae54b 100644 --- a/src/crypto/aes/cipher_generic.go +++ b/src/crypto/aes/cipher_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !s390x && !ppc64le && !arm64 -// +build !amd64,!s390x,!ppc64le,!arm64 package aes diff --git a/src/crypto/aes/gcm_ppc64le.go b/src/crypto/aes/gcm_ppc64le.go index 01b4e08757..cba6c8873f 100644 --- a/src/crypto/aes/gcm_ppc64le.go +++ b/src/crypto/aes/gcm_ppc64le.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64le -// +build ppc64le package aes diff --git a/src/crypto/cipher/xor_generic.go b/src/crypto/cipher/xor_generic.go index 03208402d7..43517a8e20 100644 --- a/src/crypto/cipher/xor_generic.go +++ b/src/crypto/cipher/xor_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !ppc64 && !ppc64le && !arm64 -// +build !amd64,!ppc64,!ppc64le,!arm64 package cipher diff --git a/src/crypto/cipher/xor_ppc64x.go b/src/crypto/cipher/xor_ppc64x.go index f520208a37..f81eec531d 100644 --- a/src/crypto/cipher/xor_ppc64x.go +++ b/src/crypto/cipher/xor_ppc64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64 || ppc64le -// +build ppc64 ppc64le package cipher diff --git a/src/crypto/ecdsa/ecdsa_noasm.go b/src/crypto/ecdsa/ecdsa_noasm.go index 68670a4f93..7fbca10b56 100644 --- a/src/crypto/ecdsa/ecdsa_noasm.go +++ b/src/crypto/ecdsa/ecdsa_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !s390x -// +build !s390x package ecdsa diff --git a/src/crypto/ecdsa/ecdsa_s390x_test.go b/src/crypto/ecdsa/ecdsa_s390x_test.go index f5633fb8a6..fd1dc7c060 100644 --- a/src/crypto/ecdsa/ecdsa_s390x_test.go +++ b/src/crypto/ecdsa/ecdsa_s390x_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build s390x -// +build s390x package ecdsa diff --git a/src/crypto/ed25519/internal/edwards25519/field/fe_amd64.go b/src/crypto/ed25519/internal/edwards25519/field/fe_amd64.go index 8fe583939f..363020bd6b 100644 --- a/src/crypto/ed25519/internal/edwards25519/field/fe_amd64.go +++ b/src/crypto/ed25519/internal/edwards25519/field/fe_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run fe_amd64_asm.go -out ../fe_amd64.s -stubs ../fe_amd64.go -pkg field. DO NOT EDIT. //go:build amd64 && gc && !purego -// +build amd64,gc,!purego package field diff --git a/src/crypto/ed25519/internal/edwards25519/field/fe_amd64_noasm.go b/src/crypto/ed25519/internal/edwards25519/field/fe_amd64_noasm.go index ddb6c9b8f7..9da280d1d8 100644 --- a/src/crypto/ed25519/internal/edwards25519/field/fe_amd64_noasm.go +++ b/src/crypto/ed25519/internal/edwards25519/field/fe_amd64_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 || !gc || purego -// +build !amd64 !gc purego package field diff --git a/src/crypto/ed25519/internal/edwards25519/field/fe_arm64.go b/src/crypto/ed25519/internal/edwards25519/field/fe_arm64.go index af459ef515..075fe9b925 100644 --- a/src/crypto/ed25519/internal/edwards25519/field/fe_arm64.go +++ b/src/crypto/ed25519/internal/edwards25519/field/fe_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 && gc && !purego -// +build arm64,gc,!purego package field diff --git a/src/crypto/ed25519/internal/edwards25519/field/fe_arm64_noasm.go b/src/crypto/ed25519/internal/edwards25519/field/fe_arm64_noasm.go index 234a5b2e5d..fc029ac12d 100644 --- a/src/crypto/ed25519/internal/edwards25519/field/fe_arm64_noasm.go +++ b/src/crypto/ed25519/internal/edwards25519/field/fe_arm64_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !arm64 || !gc || purego -// +build !arm64 !gc purego package field diff --git a/src/crypto/elliptic/export_generate.go b/src/crypto/elliptic/export_generate.go index 5fe3025cf8..f15b302d8c 100644 --- a/src/crypto/elliptic/export_generate.go +++ b/src/crypto/elliptic/export_generate.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build tablegen -// +build tablegen package elliptic diff --git a/src/crypto/elliptic/fuzz_test.go b/src/crypto/elliptic/fuzz_test.go index 8ff3bf3cc2..2b5ddae1d9 100644 --- a/src/crypto/elliptic/fuzz_test.go +++ b/src/crypto/elliptic/fuzz_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || arm64 || ppc64le -// +build amd64 arm64 ppc64le package elliptic diff --git a/src/crypto/elliptic/gen_p256_table.go b/src/crypto/elliptic/gen_p256_table.go index cdcddcb736..54aafa2c38 100644 --- a/src/crypto/elliptic/gen_p256_table.go +++ b/src/crypto/elliptic/gen_p256_table.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore package main diff --git a/src/crypto/elliptic/p256.go b/src/crypto/elliptic/p256.go index b2b12c8f13..7747de7a50 100644 --- a/src/crypto/elliptic/p256.go +++ b/src/crypto/elliptic/p256.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !arm64 -// +build !amd64,!arm64 package elliptic diff --git a/src/crypto/elliptic/p256_asm.go b/src/crypto/elliptic/p256_asm.go index d46b809125..ff0c1596aa 100644 --- a/src/crypto/elliptic/p256_asm.go +++ b/src/crypto/elliptic/p256_asm.go @@ -11,7 +11,6 @@ // https://eprint.iacr.org/2013/816.pdf //go:build amd64 || arm64 -// +build amd64 arm64 package elliptic diff --git a/src/crypto/elliptic/p256_asm_table.go b/src/crypto/elliptic/p256_asm_table.go index 7f81cb6b3f..ad2c6c2c51 100644 --- a/src/crypto/elliptic/p256_asm_table.go +++ b/src/crypto/elliptic/p256_asm_table.go @@ -5,7 +5,6 @@ // Generated by gen_p256_table.go. DO NOT EDIT. //go:build amd64 || arm64 -// +build amd64 arm64 package elliptic diff --git a/src/crypto/elliptic/p256_asm_table_test.go b/src/crypto/elliptic/p256_asm_table_test.go index d704dae299..6abd8cb11b 100644 --- a/src/crypto/elliptic/p256_asm_table_test.go +++ b/src/crypto/elliptic/p256_asm_table_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || arm64 -// +build amd64 arm64 package elliptic diff --git a/src/crypto/elliptic/p256_generic.go b/src/crypto/elliptic/p256_generic.go index 25762a8f76..7f8fab5398 100644 --- a/src/crypto/elliptic/p256_generic.go +++ b/src/crypto/elliptic/p256_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !s390x && !arm64 && !ppc64le -// +build !amd64,!s390x,!arm64,!ppc64le package elliptic diff --git a/src/crypto/elliptic/p256_ppc64le.go b/src/crypto/elliptic/p256_ppc64le.go index 40d9ed9d40..e9a6a067a2 100644 --- a/src/crypto/elliptic/p256_ppc64le.go +++ b/src/crypto/elliptic/p256_ppc64le.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64le -// +build ppc64le package elliptic diff --git a/src/crypto/elliptic/p256_s390x.go b/src/crypto/elliptic/p256_s390x.go index 91e613b631..735e9f57f1 100644 --- a/src/crypto/elliptic/p256_s390x.go +++ b/src/crypto/elliptic/p256_s390x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build s390x -// +build s390x package elliptic diff --git a/src/crypto/internal/subtle/aliasing.go b/src/crypto/internal/subtle/aliasing.go index 86e0f3cfe7..16e2fcab12 100644 --- a/src/crypto/internal/subtle/aliasing.go +++ b/src/crypto/internal/subtle/aliasing.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !appengine -// +build !appengine // Package subtle implements functions that are often useful in cryptographic // code but require careful thought to use correctly. diff --git a/src/crypto/internal/subtle/aliasing_appengine.go b/src/crypto/internal/subtle/aliasing_appengine.go index 35b442f7a2..90ac4b61cc 100644 --- a/src/crypto/internal/subtle/aliasing_appengine.go +++ b/src/crypto/internal/subtle/aliasing_appengine.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build appengine -// +build appengine // Package subtle implements functions that are often useful in cryptographic // code but require careful thought to use correctly. diff --git a/src/crypto/md5/gen.go b/src/crypto/md5/gen.go index 29729fad01..cd2700a5cf 100644 --- a/src/crypto/md5/gen.go +++ b/src/crypto/md5/gen.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // This program generates md5block.go // Invoke as diff --git a/src/crypto/md5/md5block_decl.go b/src/crypto/md5/md5block_decl.go index bc2d58c069..6716a0c9db 100644 --- a/src/crypto/md5/md5block_decl.go +++ b/src/crypto/md5/md5block_decl.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || 386 || arm || ppc64le || ppc64 || s390x || arm64 -// +build amd64 386 arm ppc64le ppc64 s390x arm64 package md5 diff --git a/src/crypto/md5/md5block_generic.go b/src/crypto/md5/md5block_generic.go index 23ed75304f..c929c2b84a 100644 --- a/src/crypto/md5/md5block_generic.go +++ b/src/crypto/md5/md5block_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !386 && !arm && !ppc64le && !ppc64 && !s390x && !arm64 -// +build !amd64,!386,!arm,!ppc64le,!ppc64,!s390x,!arm64 package md5 diff --git a/src/crypto/rand/eagain.go b/src/crypto/rand/eagain.go index 85d4d9d47f..f018e75931 100644 --- a/src/crypto/rand/eagain.go +++ b/src/crypto/rand/eagain.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package rand diff --git a/src/crypto/rand/rand_batched.go b/src/crypto/rand/rand_batched.go index d7c5bf3562..3e8e620382 100644 --- a/src/crypto/rand/rand_batched.go +++ b/src/crypto/rand/rand_batched.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux || freebsd || dragonfly || solaris -// +build linux freebsd dragonfly solaris package rand diff --git a/src/crypto/rand/rand_batched_test.go b/src/crypto/rand/rand_batched_test.go index 2d20922c82..28e45aa689 100644 --- a/src/crypto/rand/rand_batched_test.go +++ b/src/crypto/rand/rand_batched_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux || freebsd || dragonfly || solaris -// +build linux freebsd dragonfly solaris package rand diff --git a/src/crypto/rand/rand_getentropy.go b/src/crypto/rand/rand_getentropy.go index dd725372ad..2bf2f52032 100644 --- a/src/crypto/rand/rand_getentropy.go +++ b/src/crypto/rand/rand_getentropy.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (darwin && !ios) || openbsd -// +build darwin,!ios openbsd package rand diff --git a/src/crypto/rand/rand_js.go b/src/crypto/rand/rand_js.go index 7ddc2b6169..91e69fae5d 100644 --- a/src/crypto/rand/rand_js.go +++ b/src/crypto/rand/rand_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package rand diff --git a/src/crypto/rand/rand_unix.go b/src/crypto/rand/rand_unix.go index 81277eb6a5..40347874c5 100644 --- a/src/crypto/rand/rand_unix.go +++ b/src/crypto/rand/rand_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || plan9 || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd plan9 solaris // Unix cryptographically secure pseudorandom number // generator. diff --git a/src/crypto/sha1/fallback_test.go b/src/crypto/sha1/fallback_test.go index 4bb8b3324f..45d1f57d39 100644 --- a/src/crypto/sha1/fallback_test.go +++ b/src/crypto/sha1/fallback_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build s390x -// +build s390x package sha1 diff --git a/src/crypto/sha1/issue15617_test.go b/src/crypto/sha1/issue15617_test.go index 436f78c745..df4e28f64e 100644 --- a/src/crypto/sha1/issue15617_test.go +++ b/src/crypto/sha1/issue15617_test.go @@ -1,6 +1,4 @@ //go:build amd64 && (linux || darwin) -// +build amd64 -// +build linux darwin // Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/crypto/sha1/sha1block_decl.go b/src/crypto/sha1/sha1block_decl.go index 93054efa7c..518a4b6b67 100644 --- a/src/crypto/sha1/sha1block_decl.go +++ b/src/crypto/sha1/sha1block_decl.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm || 386 || s390x -// +build arm 386 s390x package sha1 diff --git a/src/crypto/sha1/sha1block_generic.go b/src/crypto/sha1/sha1block_generic.go index 105aa31832..ba35155d0b 100644 --- a/src/crypto/sha1/sha1block_generic.go +++ b/src/crypto/sha1/sha1block_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !386 && !arm && !s390x && !arm64 -// +build !amd64,!386,!arm,!s390x,!arm64 package sha1 diff --git a/src/crypto/sha256/fallback_test.go b/src/crypto/sha256/fallback_test.go index 7ce88cbb2a..3f561aadd6 100644 --- a/src/crypto/sha256/fallback_test.go +++ b/src/crypto/sha256/fallback_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build s390x -// +build s390x package sha256 diff --git a/src/crypto/sha256/sha256block_decl.go b/src/crypto/sha256/sha256block_decl.go index a6bb396f13..c9c1194487 100644 --- a/src/crypto/sha256/sha256block_decl.go +++ b/src/crypto/sha256/sha256block_decl.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || amd64 || s390x || ppc64le -// +build 386 amd64 s390x ppc64le package sha256 diff --git a/src/crypto/sha256/sha256block_generic.go b/src/crypto/sha256/sha256block_generic.go index 0f2bf8b231..a8878c2eee 100644 --- a/src/crypto/sha256/sha256block_generic.go +++ b/src/crypto/sha256/sha256block_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !386 && !s390x && !ppc64le && !arm64 -// +build !amd64,!386,!s390x,!ppc64le,!arm64 package sha256 diff --git a/src/crypto/sha512/fallback_test.go b/src/crypto/sha512/fallback_test.go index faf732670a..db5b13c38c 100644 --- a/src/crypto/sha512/fallback_test.go +++ b/src/crypto/sha512/fallback_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build s390x -// +build s390x package sha512 diff --git a/src/crypto/sha512/sha512block_amd64.go b/src/crypto/sha512/sha512block_amd64.go index e2386f29ab..8da3e1473f 100644 --- a/src/crypto/sha512/sha512block_amd64.go +++ b/src/crypto/sha512/sha512block_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 -// +build amd64 package sha512 diff --git a/src/crypto/sha512/sha512block_decl.go b/src/crypto/sha512/sha512block_decl.go index 6c22f44801..c6dcdf5db6 100644 --- a/src/crypto/sha512/sha512block_decl.go +++ b/src/crypto/sha512/sha512block_decl.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build s390x || ppc64le -// +build s390x ppc64le package sha512 diff --git a/src/crypto/sha512/sha512block_generic.go b/src/crypto/sha512/sha512block_generic.go index 865a7356f1..62ea237867 100644 --- a/src/crypto/sha512/sha512block_generic.go +++ b/src/crypto/sha512/sha512block_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !s390x && !ppc64le -// +build !amd64,!s390x,!ppc64le package sha512 diff --git a/src/crypto/tls/generate_cert.go b/src/crypto/tls/generate_cert.go index 7ea90f8a7b..58fdd025db 100644 --- a/src/crypto/tls/generate_cert.go +++ b/src/crypto/tls/generate_cert.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // Generate a self-signed X.509 certificate for a TLS server. Outputs to // 'cert.pem' and 'key.pem' and will overwrite existing files. diff --git a/src/crypto/tls/handshake_unix_test.go b/src/crypto/tls/handshake_unix_test.go index 19fc698676..b61e7c24ef 100644 --- a/src/crypto/tls/handshake_unix_test.go +++ b/src/crypto/tls/handshake_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package tls diff --git a/src/crypto/x509/internal/macos/corefoundation.go b/src/crypto/x509/internal/macos/corefoundation.go index fcfbc1e561..a91131ac98 100644 --- a/src/crypto/x509/internal/macos/corefoundation.go +++ b/src/crypto/x509/internal/macos/corefoundation.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin && !ios -// +build darwin,!ios // Package macOS provides cgo-less wrappers for Core Foundation and // Security.framework, similarly to how package syscall provides access to diff --git a/src/crypto/x509/internal/macos/security.go b/src/crypto/x509/internal/macos/security.go index 0f6fa42b7b..a560248e8b 100644 --- a/src/crypto/x509/internal/macos/security.go +++ b/src/crypto/x509/internal/macos/security.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin && !ios -// +build darwin,!ios package macOS diff --git a/src/crypto/x509/root_bsd.go b/src/crypto/x509/root_bsd.go index 6712ea32a6..8ac205faa9 100644 --- a/src/crypto/x509/root_bsd.go +++ b/src/crypto/x509/root_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || netbsd || openbsd -// +build dragonfly freebsd netbsd openbsd package x509 diff --git a/src/crypto/x509/root_darwin.go b/src/crypto/x509/root_darwin.go index 05593bb105..164ad9dc77 100644 --- a/src/crypto/x509/root_darwin.go +++ b/src/crypto/x509/root_darwin.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !ios -// +build !ios package x509 diff --git a/src/crypto/x509/root_ios.go b/src/crypto/x509/root_ios.go index 9bc62f8abb..c5e3fc0b72 100644 --- a/src/crypto/x509/root_ios.go +++ b/src/crypto/x509/root_ios.go @@ -2,7 +2,6 @@ // Update the version in root.go and regenerate with "go generate". //go:build ios && !x509omitbundledroots -// +build ios,!x509omitbundledroots package x509 diff --git a/src/crypto/x509/root_ios_gen.go b/src/crypto/x509/root_ios_gen.go index 3c98de5bb6..15eb1592ca 100644 --- a/src/crypto/x509/root_ios_gen.go +++ b/src/crypto/x509/root_ios_gen.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // Generates root_ios.go. // diff --git a/src/crypto/x509/root_js.go b/src/crypto/x509/root_js.go index f2c2c0af38..9593038517 100644 --- a/src/crypto/x509/root_js.go +++ b/src/crypto/x509/root_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package x509 diff --git a/src/crypto/x509/root_omit.go b/src/crypto/x509/root_omit.go index 81f2f112d0..299d74835e 100644 --- a/src/crypto/x509/root_omit.go +++ b/src/crypto/x509/root_omit.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build ((darwin && arm64) || (darwin && amd64 && ios)) && x509omitbundledroots -// +build darwin,arm64 darwin,amd64,ios -// +build x509omitbundledroots // This file provides the loadSystemRoots func when the // "x509omitbundledroots" build tag has disabled bundling a copy, diff --git a/src/crypto/x509/root_omit_test.go b/src/crypto/x509/root_omit_test.go index 158bd7f91a..1709e2ea8b 100644 --- a/src/crypto/x509/root_omit_test.go +++ b/src/crypto/x509/root_omit_test.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build ((darwin && arm64) || (darwin && amd64 && ios)) && x509omitbundledroots -// +build darwin,arm64 darwin,amd64,ios -// +build x509omitbundledroots package x509 diff --git a/src/crypto/x509/root_plan9.go b/src/crypto/x509/root_plan9.go index 2bdb2fe713..3bd06fe50d 100644 --- a/src/crypto/x509/root_plan9.go +++ b/src/crypto/x509/root_plan9.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 -// +build plan9 package x509 diff --git a/src/crypto/x509/root_unix.go b/src/crypto/x509/root_unix.go index dede825edd..aa54f891ca 100644 --- a/src/crypto/x509/root_unix.go +++ b/src/crypto/x509/root_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix dragonfly freebsd js,wasm linux netbsd openbsd solaris package x509 diff --git a/src/crypto/x509/root_unix_test.go b/src/crypto/x509/root_unix_test.go index 7118f12d74..7197a0de3b 100644 --- a/src/crypto/x509/root_unix_test.go +++ b/src/crypto/x509/root_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build dragonfly freebsd linux netbsd openbsd solaris package x509 diff --git a/src/crypto/x509/x509_test_import.go b/src/crypto/x509/x509_test_import.go index ef3ee807bf..2474e3d810 100644 --- a/src/crypto/x509/x509_test_import.go +++ b/src/crypto/x509/x509_test_import.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // This file is run by the x509 tests to ensure that a program with minimal // imports can sign certificates without errors resulting from missing hash diff --git a/src/encoding/csv/fuzz.go b/src/encoding/csv/fuzz.go index a03fa83d8c..5f5cdfcbf8 100644 --- a/src/encoding/csv/fuzz.go +++ b/src/encoding/csv/fuzz.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gofuzz -// +build gofuzz package csv diff --git a/src/encoding/gob/debug.go b/src/encoding/gob/debug.go index 5965fea921..5ceb2bfac7 100644 --- a/src/encoding/gob/debug.go +++ b/src/encoding/gob/debug.go @@ -4,7 +4,6 @@ // Delete the next line to include in the gob package. //go:build ignore -// +build ignore package gob diff --git a/src/encoding/gob/decgen.go b/src/encoding/gob/decgen.go index 994be877d9..e40816eb86 100644 --- a/src/encoding/gob/decgen.go +++ b/src/encoding/gob/decgen.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // encgen writes the helper functions for encoding. Intended to be // used with go generate; see the invocation in encode.go. diff --git a/src/encoding/gob/dump.go b/src/encoding/gob/dump.go index 8c0bbc4ff2..f4b1bebfba 100644 --- a/src/encoding/gob/dump.go +++ b/src/encoding/gob/dump.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore package main diff --git a/src/encoding/gob/encgen.go b/src/encoding/gob/encgen.go index b562da177d..e5f68786a0 100644 --- a/src/encoding/gob/encgen.go +++ b/src/encoding/gob/encgen.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // encgen writes the helper functions for encoding. Intended to be // used with go generate; see the invocation in encode.go. diff --git a/src/encoding/json/fuzz.go b/src/encoding/json/fuzz.go index d3fa2d1113..f00898a798 100644 --- a/src/encoding/json/fuzz.go +++ b/src/encoding/json/fuzz.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gofuzz -// +build gofuzz package json diff --git a/src/go/build/gc.go b/src/go/build/gc.go index e16e186e0d..434991f66e 100644 --- a/src/go/build/gc.go +++ b/src/go/build/gc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc package build diff --git a/src/go/build/gccgo.go b/src/go/build/gccgo.go index c8ec7041fb..f806729f7e 100644 --- a/src/go/build/gccgo.go +++ b/src/go/build/gccgo.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gccgo -// +build gccgo package build diff --git a/src/go/doc/headscan.go b/src/go/doc/headscan.go index df54b4bd61..320895e43a 100644 --- a/src/go/doc/headscan.go +++ b/src/go/doc/headscan.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* The headscan command extracts comment headings from package files; diff --git a/src/go/types/example_test.go b/src/go/types/example_test.go index 32a25a4117..2702567486 100644 --- a/src/go/types/example_test.go +++ b/src/go/types/example_test.go @@ -6,7 +6,6 @@ // access to compiled packages for import. // //go:build !arm && !arm64 -// +build !arm,!arm64 package types_test diff --git a/src/go/types/gotype.go b/src/go/types/gotype.go index ca1d42c14d..1126b73810 100644 --- a/src/go/types/gotype.go +++ b/src/go/types/gotype.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // Build this command explicitly: go build gotype.go diff --git a/src/hash/crc32/crc32_otherarch.go b/src/hash/crc32/crc32_otherarch.go index 936e5bf3e0..762515257d 100644 --- a/src/hash/crc32/crc32_otherarch.go +++ b/src/hash/crc32/crc32_otherarch.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !s390x && !ppc64le && !arm64 -// +build !amd64,!s390x,!ppc64le,!arm64 package crc32 diff --git a/src/hash/crc32/gen_const_ppc64le.go b/src/hash/crc32/gen_const_ppc64le.go index c98454c685..2f15a60b50 100644 --- a/src/hash/crc32/gen_const_ppc64le.go +++ b/src/hash/crc32/gen_const_ppc64le.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // Generate the constant table associated with the poly used by the // vpmsumd crc32 algorithm. diff --git a/src/html/fuzz.go b/src/html/fuzz.go index ecaf4f9069..cd70f97106 100644 --- a/src/html/fuzz.go +++ b/src/html/fuzz.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gofuzz -// +build gofuzz package html diff --git a/src/image/color/palette/gen.go b/src/image/color/palette/gen.go index 7bb257d865..be46c57020 100644 --- a/src/image/color/palette/gen.go +++ b/src/image/color/palette/gen.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore package main diff --git a/src/image/internal/imageutil/gen.go b/src/image/internal/imageutil/gen.go index 38f41303fa..65e1e30b64 100644 --- a/src/image/internal/imageutil/gen.go +++ b/src/image/internal/imageutil/gen.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore package main diff --git a/src/image/png/fuzz.go b/src/image/png/fuzz.go index 6508533f44..688b6c9936 100644 --- a/src/image/png/fuzz.go +++ b/src/image/png/fuzz.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gofuzz -// +build gofuzz package png diff --git a/src/index/suffixarray/gen.go b/src/index/suffixarray/gen.go index 3bc9b1e2ae..d6eb32e2ae 100644 --- a/src/index/suffixarray/gen.go +++ b/src/index/suffixarray/gen.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // Gen generates sais2.go by duplicating functions in sais.go // using different input types. diff --git a/src/internal/abi/abi_arm64.go b/src/internal/abi/abi_arm64.go index 7544d7506e..5c3dd6cbe2 100644 --- a/src/internal/abi/abi_arm64.go +++ b/src/internal/abi/abi_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build goexperiment.regabireflect -// +build goexperiment.regabireflect package abi diff --git a/src/internal/abi/abi_generic.go b/src/internal/abi/abi_generic.go index e8f94f805f..a36745f402 100644 --- a/src/internal/abi/abi_generic.go +++ b/src/internal/abi/abi_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !goexperiment.regabireflect && !amd64 -// +build !goexperiment.regabireflect,!amd64 package abi diff --git a/src/internal/abi/abi_ppc64x.go b/src/internal/abi/abi_ppc64x.go index e38653224a..d47271d1a1 100644 --- a/src/internal/abi/abi_ppc64x.go +++ b/src/internal/abi/abi_ppc64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build goexperiment.regabireflect && (ppc64 || ppc64le) -// +build goexperiment.regabireflect -// +build ppc64 ppc64le package abi diff --git a/src/internal/bytealg/compare_generic.go b/src/internal/bytealg/compare_generic.go index 0690d0cf31..eaea168f2d 100644 --- a/src/internal/bytealg/compare_generic.go +++ b/src/internal/bytealg/compare_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !386 && !amd64 && !s390x && !arm && !arm64 && !ppc64 && !ppc64le && !mips && !mipsle && !wasm && !mips64 && !mips64le -// +build !386,!amd64,!s390x,!arm,!arm64,!ppc64,!ppc64le,!mips,!mipsle,!wasm,!mips64,!mips64le package bytealg diff --git a/src/internal/bytealg/compare_native.go b/src/internal/bytealg/compare_native.go index baa188ff7a..21ff8fe786 100644 --- a/src/internal/bytealg/compare_native.go +++ b/src/internal/bytealg/compare_native.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || amd64 || s390x || arm || arm64 || ppc64 || ppc64le || mips || mipsle || wasm || mips64 || mips64le -// +build 386 amd64 s390x arm arm64 ppc64 ppc64le mips mipsle wasm mips64 mips64le package bytealg diff --git a/src/internal/bytealg/count_generic.go b/src/internal/bytealg/count_generic.go index 1891d29b24..932a7c584c 100644 --- a/src/internal/bytealg/count_generic.go +++ b/src/internal/bytealg/count_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !arm && !arm64 && !ppc64le && !ppc64 && !riscv64 && !s390x -// +build !amd64,!arm,!arm64,!ppc64le,!ppc64,!riscv64,!s390x package bytealg diff --git a/src/internal/bytealg/count_native.go b/src/internal/bytealg/count_native.go index a19a6f8223..90189c9fe0 100644 --- a/src/internal/bytealg/count_native.go +++ b/src/internal/bytealg/count_native.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || arm || arm64 || ppc64le || ppc64 || riscv64 || s390x -// +build amd64 arm arm64 ppc64le ppc64 riscv64 s390x package bytealg diff --git a/src/internal/bytealg/index_generic.go b/src/internal/bytealg/index_generic.go index 0a6eb90d2d..a59e32938e 100644 --- a/src/internal/bytealg/index_generic.go +++ b/src/internal/bytealg/index_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !arm64 && !s390x && !ppc64le && !ppc64 -// +build !amd64,!arm64,!s390x,!ppc64le,!ppc64 package bytealg diff --git a/src/internal/bytealg/index_native.go b/src/internal/bytealg/index_native.go index 9547a5d8e2..6e4a2f39e4 100644 --- a/src/internal/bytealg/index_native.go +++ b/src/internal/bytealg/index_native.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || arm64 || s390x || ppc64le || ppc64 -// +build amd64 arm64 s390x ppc64le ppc64 package bytealg diff --git a/src/internal/bytealg/index_ppc64x.go b/src/internal/bytealg/index_ppc64x.go index c9b2b5a59f..ab3cbe5e96 100644 --- a/src/internal/bytealg/index_ppc64x.go +++ b/src/internal/bytealg/index_ppc64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (aix || linux) && (ppc64 || ppc64le) -// +build aix linux -// +build ppc64 ppc64le package bytealg diff --git a/src/internal/bytealg/indexbyte_generic.go b/src/internal/bytealg/indexbyte_generic.go index 6ef639fafd..0a45f90384 100644 --- a/src/internal/bytealg/indexbyte_generic.go +++ b/src/internal/bytealg/indexbyte_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !386 && !amd64 && !s390x && !arm && !arm64 && !ppc64 && !ppc64le && !mips && !mipsle && !mips64 && !mips64le && !riscv64 && !wasm -// +build !386,!amd64,!s390x,!arm,!arm64,!ppc64,!ppc64le,!mips,!mipsle,!mips64,!mips64le,!riscv64,!wasm package bytealg diff --git a/src/internal/bytealg/indexbyte_native.go b/src/internal/bytealg/indexbyte_native.go index 965f38fe52..2101021e2d 100644 --- a/src/internal/bytealg/indexbyte_native.go +++ b/src/internal/bytealg/indexbyte_native.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || amd64 || s390x || arm || arm64 || ppc64 || ppc64le || mips || mipsle || mips64 || mips64le || riscv64 || wasm -// +build 386 amd64 s390x arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le riscv64 wasm package bytealg diff --git a/src/internal/cpu/cpu_arm64_android.go b/src/internal/cpu/cpu_arm64_android.go index ac6eee54b2..fbdf7baca2 100644 --- a/src/internal/cpu/cpu_arm64_android.go +++ b/src/internal/cpu/cpu_arm64_android.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 -// +build arm64 package cpu diff --git a/src/internal/cpu/cpu_arm64_darwin.go b/src/internal/cpu/cpu_arm64_darwin.go index ce1b250a18..730e14caff 100644 --- a/src/internal/cpu/cpu_arm64_darwin.go +++ b/src/internal/cpu/cpu_arm64_darwin.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 && darwin && !ios -// +build arm64,darwin,!ios package cpu diff --git a/src/internal/cpu/cpu_arm64_freebsd.go b/src/internal/cpu/cpu_arm64_freebsd.go index 8c481370da..c25e021c68 100644 --- a/src/internal/cpu/cpu_arm64_freebsd.go +++ b/src/internal/cpu/cpu_arm64_freebsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 -// +build arm64 package cpu diff --git a/src/internal/cpu/cpu_arm64_hwcap.go b/src/internal/cpu/cpu_arm64_hwcap.go index 8ac04fd8f9..0baa39f9cf 100644 --- a/src/internal/cpu/cpu_arm64_hwcap.go +++ b/src/internal/cpu/cpu_arm64_hwcap.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 && linux -// +build arm64,linux package cpu diff --git a/src/internal/cpu/cpu_arm64_linux.go b/src/internal/cpu/cpu_arm64_linux.go index c3a3f9a8e9..d746bdb063 100644 --- a/src/internal/cpu/cpu_arm64_linux.go +++ b/src/internal/cpu/cpu_arm64_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 && linux && !android -// +build arm64,linux,!android package cpu diff --git a/src/internal/cpu/cpu_arm64_other.go b/src/internal/cpu/cpu_arm64_other.go index e8b5d529a4..d313648cb7 100644 --- a/src/internal/cpu/cpu_arm64_other.go +++ b/src/internal/cpu/cpu_arm64_other.go @@ -3,11 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 && !linux && !freebsd && !android && (!darwin || ios) -// +build arm64 -// +build !linux -// +build !freebsd -// +build !android -// +build !darwin ios package cpu diff --git a/src/internal/cpu/cpu_mips64x.go b/src/internal/cpu/cpu_mips64x.go index d2f9d4499b..c452ffd8b3 100644 --- a/src/internal/cpu/cpu_mips64x.go +++ b/src/internal/cpu/cpu_mips64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build mips64 || mips64le -// +build mips64 mips64le package cpu diff --git a/src/internal/cpu/cpu_no_name.go b/src/internal/cpu/cpu_no_name.go index 8d563b536c..37de951ba6 100644 --- a/src/internal/cpu/cpu_no_name.go +++ b/src/internal/cpu/cpu_no_name.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !386 && !amd64 -// +build !386,!amd64 package cpu diff --git a/src/internal/cpu/cpu_ppc64x.go b/src/internal/cpu/cpu_ppc64x.go index 2e7fd3ebb9..83687d6ed3 100644 --- a/src/internal/cpu/cpu_ppc64x.go +++ b/src/internal/cpu/cpu_ppc64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64 || ppc64le -// +build ppc64 ppc64le package cpu diff --git a/src/internal/cpu/cpu_ppc64x_aix.go b/src/internal/cpu/cpu_ppc64x_aix.go index 3d17a9c730..d518edcf49 100644 --- a/src/internal/cpu/cpu_ppc64x_aix.go +++ b/src/internal/cpu/cpu_ppc64x_aix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64 || ppc64le -// +build ppc64 ppc64le package cpu diff --git a/src/internal/cpu/cpu_ppc64x_linux.go b/src/internal/cpu/cpu_ppc64x_linux.go index b7c7345111..7999656f01 100644 --- a/src/internal/cpu/cpu_ppc64x_linux.go +++ b/src/internal/cpu/cpu_ppc64x_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64 || ppc64le -// +build ppc64 ppc64le package cpu diff --git a/src/internal/cpu/cpu_x86.go b/src/internal/cpu/cpu_x86.go index 1582e832a4..81d5ceed61 100644 --- a/src/internal/cpu/cpu_x86.go +++ b/src/internal/cpu/cpu_x86.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || amd64 -// +build 386 amd64 package cpu diff --git a/src/internal/cpu/cpu_x86_test.go b/src/internal/cpu/cpu_x86_test.go index de1c5fb3b0..0fef065f20 100644 --- a/src/internal/cpu/cpu_x86_test.go +++ b/src/internal/cpu/cpu_x86_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || amd64 -// +build 386 amd64 package cpu_test diff --git a/src/internal/fuzz/minimize_test.go b/src/internal/fuzz/minimize_test.go index dd76baff51..13385e14d6 100644 --- a/src/internal/fuzz/minimize_test.go +++ b/src/internal/fuzz/minimize_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || linux || windows -// +build darwin linux windows package fuzz diff --git a/src/internal/fuzz/sys_posix.go b/src/internal/fuzz/sys_posix.go index ca6b1456e2..89c86c1ebb 100644 --- a/src/internal/fuzz/sys_posix.go +++ b/src/internal/fuzz/sys_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || linux -// +build darwin linux package fuzz diff --git a/src/internal/fuzz/sys_unimplemented.go b/src/internal/fuzz/sys_unimplemented.go index 827e36cf32..05954bb07f 100644 --- a/src/internal/fuzz/sys_unimplemented.go +++ b/src/internal/fuzz/sys_unimplemented.go @@ -4,7 +4,6 @@ // TODO(jayconrod): support more platforms. //go:build !darwin && !linux && !windows -// +build !darwin,!linux,!windows package fuzz diff --git a/src/internal/fuzz/trace.go b/src/internal/fuzz/trace.go index ab0aeb41bd..cab0838fab 100644 --- a/src/internal/fuzz/trace.go +++ b/src/internal/fuzz/trace.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !libfuzzer -// +build !libfuzzer package fuzz diff --git a/src/internal/goarch/gengoarch.go b/src/internal/goarch/gengoarch.go index af15518ad8..d146cc5bc9 100644 --- a/src/internal/goarch/gengoarch.go +++ b/src/internal/goarch/gengoarch.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore package main diff --git a/src/internal/goarch/zgoarch_386.go b/src/internal/goarch/zgoarch_386.go index 364367722f..4a9b0e67c4 100644 --- a/src/internal/goarch/zgoarch_386.go +++ b/src/internal/goarch/zgoarch_386.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build 386 -// +build 386 package goarch diff --git a/src/internal/goarch/zgoarch_amd64.go b/src/internal/goarch/zgoarch_amd64.go index 8169580857..7926392b77 100644 --- a/src/internal/goarch/zgoarch_amd64.go +++ b/src/internal/goarch/zgoarch_amd64.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build amd64 -// +build amd64 package goarch diff --git a/src/internal/goarch/zgoarch_arm.go b/src/internal/goarch/zgoarch_arm.go index edc69f3349..6c03b8b060 100644 --- a/src/internal/goarch/zgoarch_arm.go +++ b/src/internal/goarch/zgoarch_arm.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build arm -// +build arm package goarch diff --git a/src/internal/goarch/zgoarch_arm64.go b/src/internal/goarch/zgoarch_arm64.go index 0459376349..ad342d79c9 100644 --- a/src/internal/goarch/zgoarch_arm64.go +++ b/src/internal/goarch/zgoarch_arm64.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build arm64 -// +build arm64 package goarch diff --git a/src/internal/goarch/zgoarch_arm64be.go b/src/internal/goarch/zgoarch_arm64be.go index b9439c147e..0f26003090 100644 --- a/src/internal/goarch/zgoarch_arm64be.go +++ b/src/internal/goarch/zgoarch_arm64be.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build arm64be -// +build arm64be package goarch diff --git a/src/internal/goarch/zgoarch_armbe.go b/src/internal/goarch/zgoarch_armbe.go index bbb07603d6..6092fee751 100644 --- a/src/internal/goarch/zgoarch_armbe.go +++ b/src/internal/goarch/zgoarch_armbe.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build armbe -// +build armbe package goarch diff --git a/src/internal/goarch/zgoarch_loong64.go b/src/internal/goarch/zgoarch_loong64.go index 4d2cd70a00..21c67e1176 100644 --- a/src/internal/goarch/zgoarch_loong64.go +++ b/src/internal/goarch/zgoarch_loong64.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build loong64 -// +build loong64 package goarch diff --git a/src/internal/goarch/zgoarch_mips.go b/src/internal/goarch/zgoarch_mips.go index 25a8071727..0db1974655 100644 --- a/src/internal/goarch/zgoarch_mips.go +++ b/src/internal/goarch/zgoarch_mips.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build mips -// +build mips package goarch diff --git a/src/internal/goarch/zgoarch_mips64.go b/src/internal/goarch/zgoarch_mips64.go index 907ae30ec4..738806f0ae 100644 --- a/src/internal/goarch/zgoarch_mips64.go +++ b/src/internal/goarch/zgoarch_mips64.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build mips64 -// +build mips64 package goarch diff --git a/src/internal/goarch/zgoarch_mips64le.go b/src/internal/goarch/zgoarch_mips64le.go index 3f4c369d16..8de5beb881 100644 --- a/src/internal/goarch/zgoarch_mips64le.go +++ b/src/internal/goarch/zgoarch_mips64le.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build mips64le -// +build mips64le package goarch diff --git a/src/internal/goarch/zgoarch_mips64p32.go b/src/internal/goarch/zgoarch_mips64p32.go index d03e503c59..ea461bed70 100644 --- a/src/internal/goarch/zgoarch_mips64p32.go +++ b/src/internal/goarch/zgoarch_mips64p32.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build mips64p32 -// +build mips64p32 package goarch diff --git a/src/internal/goarch/zgoarch_mips64p32le.go b/src/internal/goarch/zgoarch_mips64p32le.go index bbaa010ada..15473ce6c7 100644 --- a/src/internal/goarch/zgoarch_mips64p32le.go +++ b/src/internal/goarch/zgoarch_mips64p32le.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build mips64p32le -// +build mips64p32le package goarch diff --git a/src/internal/goarch/zgoarch_mipsle.go b/src/internal/goarch/zgoarch_mipsle.go index b22be64d6e..4955142e87 100644 --- a/src/internal/goarch/zgoarch_mipsle.go +++ b/src/internal/goarch/zgoarch_mipsle.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build mipsle -// +build mipsle package goarch diff --git a/src/internal/goarch/zgoarch_ppc.go b/src/internal/goarch/zgoarch_ppc.go index ed50bf8275..ec01763b3c 100644 --- a/src/internal/goarch/zgoarch_ppc.go +++ b/src/internal/goarch/zgoarch_ppc.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build ppc -// +build ppc package goarch diff --git a/src/internal/goarch/zgoarch_ppc64.go b/src/internal/goarch/zgoarch_ppc64.go index 26b921d343..39be3925c8 100644 --- a/src/internal/goarch/zgoarch_ppc64.go +++ b/src/internal/goarch/zgoarch_ppc64.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build ppc64 -// +build ppc64 package goarch diff --git a/src/internal/goarch/zgoarch_ppc64le.go b/src/internal/goarch/zgoarch_ppc64le.go index de4fe0fb80..5f959e0e02 100644 --- a/src/internal/goarch/zgoarch_ppc64le.go +++ b/src/internal/goarch/zgoarch_ppc64le.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build ppc64le -// +build ppc64le package goarch diff --git a/src/internal/goarch/zgoarch_riscv.go b/src/internal/goarch/zgoarch_riscv.go index 3eff474467..8d81a14dd9 100644 --- a/src/internal/goarch/zgoarch_riscv.go +++ b/src/internal/goarch/zgoarch_riscv.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build riscv -// +build riscv package goarch diff --git a/src/internal/goarch/zgoarch_riscv64.go b/src/internal/goarch/zgoarch_riscv64.go index d99ab9dc29..1df989c2a6 100644 --- a/src/internal/goarch/zgoarch_riscv64.go +++ b/src/internal/goarch/zgoarch_riscv64.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build riscv64 -// +build riscv64 package goarch diff --git a/src/internal/goarch/zgoarch_s390.go b/src/internal/goarch/zgoarch_s390.go index 6d4ff71cc9..56815b9f43 100644 --- a/src/internal/goarch/zgoarch_s390.go +++ b/src/internal/goarch/zgoarch_s390.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build s390 -// +build s390 package goarch diff --git a/src/internal/goarch/zgoarch_s390x.go b/src/internal/goarch/zgoarch_s390x.go index 6c215060a3..e61e9bd593 100644 --- a/src/internal/goarch/zgoarch_s390x.go +++ b/src/internal/goarch/zgoarch_s390x.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build s390x -// +build s390x package goarch diff --git a/src/internal/goarch/zgoarch_sparc.go b/src/internal/goarch/zgoarch_sparc.go index 029e790fb0..ee5b746566 100644 --- a/src/internal/goarch/zgoarch_sparc.go +++ b/src/internal/goarch/zgoarch_sparc.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build sparc -// +build sparc package goarch diff --git a/src/internal/goarch/zgoarch_sparc64.go b/src/internal/goarch/zgoarch_sparc64.go index bcd7b6f7df..519aaa10c1 100644 --- a/src/internal/goarch/zgoarch_sparc64.go +++ b/src/internal/goarch/zgoarch_sparc64.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build sparc64 -// +build sparc64 package goarch diff --git a/src/internal/goarch/zgoarch_wasm.go b/src/internal/goarch/zgoarch_wasm.go index 0816c85a11..25567a1b64 100644 --- a/src/internal/goarch/zgoarch_wasm.go +++ b/src/internal/goarch/zgoarch_wasm.go @@ -1,7 +1,6 @@ // Code generated by gengoarch.go using 'go generate'. DO NOT EDIT. //go:build wasm -// +build wasm package goarch diff --git a/src/internal/goos/gengoos.go b/src/internal/goos/gengoos.go index 1860cd700d..f8ddfcc7ff 100644 --- a/src/internal/goos/gengoos.go +++ b/src/internal/goos/gengoos.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore package main diff --git a/src/internal/goos/zgoos_aix.go b/src/internal/goos/zgoos_aix.go index 063e698b82..ff861550c4 100644 --- a/src/internal/goos/zgoos_aix.go +++ b/src/internal/goos/zgoos_aix.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build aix -// +build aix package goos diff --git a/src/internal/goos/zgoos_android.go b/src/internal/goos/zgoos_android.go index e9e4864978..e8aaa12428 100644 --- a/src/internal/goos/zgoos_android.go +++ b/src/internal/goos/zgoos_android.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build android -// +build android package goos diff --git a/src/internal/goos/zgoos_darwin.go b/src/internal/goos/zgoos_darwin.go index 309d6a2717..decdd49642 100644 --- a/src/internal/goos/zgoos_darwin.go +++ b/src/internal/goos/zgoos_darwin.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build !ios && darwin -// +build !ios,darwin package goos diff --git a/src/internal/goos/zgoos_dragonfly.go b/src/internal/goos/zgoos_dragonfly.go index 4e8711b94c..2224baa230 100644 --- a/src/internal/goos/zgoos_dragonfly.go +++ b/src/internal/goos/zgoos_dragonfly.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build dragonfly -// +build dragonfly package goos diff --git a/src/internal/goos/zgoos_freebsd.go b/src/internal/goos/zgoos_freebsd.go index f312bd1608..3ee5bf998e 100644 --- a/src/internal/goos/zgoos_freebsd.go +++ b/src/internal/goos/zgoos_freebsd.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build freebsd -// +build freebsd package goos diff --git a/src/internal/goos/zgoos_hurd.go b/src/internal/goos/zgoos_hurd.go index 0f0dd28b81..8a3d34304d 100644 --- a/src/internal/goos/zgoos_hurd.go +++ b/src/internal/goos/zgoos_hurd.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build hurd -// +build hurd package goos diff --git a/src/internal/goos/zgoos_illumos.go b/src/internal/goos/zgoos_illumos.go index 17e7c53a40..fc1b9a9e22 100644 --- a/src/internal/goos/zgoos_illumos.go +++ b/src/internal/goos/zgoos_illumos.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build illumos -// +build illumos package goos diff --git a/src/internal/goos/zgoos_ios.go b/src/internal/goos/zgoos_ios.go index e4745ca413..746e769ef7 100644 --- a/src/internal/goos/zgoos_ios.go +++ b/src/internal/goos/zgoos_ios.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build ios -// +build ios package goos diff --git a/src/internal/goos/zgoos_js.go b/src/internal/goos/zgoos_js.go index bd2417e9ce..6cf2a5d9e2 100644 --- a/src/internal/goos/zgoos_js.go +++ b/src/internal/goos/zgoos_js.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build js -// +build js package goos diff --git a/src/internal/goos/zgoos_linux.go b/src/internal/goos/zgoos_linux.go index 476702f442..cb9d6e8afa 100644 --- a/src/internal/goos/zgoos_linux.go +++ b/src/internal/goos/zgoos_linux.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build !android && linux -// +build !android,linux package goos diff --git a/src/internal/goos/zgoos_netbsd.go b/src/internal/goos/zgoos_netbsd.go index 97b7564bab..8285928d35 100644 --- a/src/internal/goos/zgoos_netbsd.go +++ b/src/internal/goos/zgoos_netbsd.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build netbsd -// +build netbsd package goos diff --git a/src/internal/goos/zgoos_openbsd.go b/src/internal/goos/zgoos_openbsd.go index 384a96480d..3f739a4a2f 100644 --- a/src/internal/goos/zgoos_openbsd.go +++ b/src/internal/goos/zgoos_openbsd.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build openbsd -// +build openbsd package goos diff --git a/src/internal/goos/zgoos_plan9.go b/src/internal/goos/zgoos_plan9.go index fcc279a79e..d4c1c651f7 100644 --- a/src/internal/goos/zgoos_plan9.go +++ b/src/internal/goos/zgoos_plan9.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build plan9 -// +build plan9 package goos diff --git a/src/internal/goos/zgoos_solaris.go b/src/internal/goos/zgoos_solaris.go index 3f366cf710..69e3285ab6 100644 --- a/src/internal/goos/zgoos_solaris.go +++ b/src/internal/goos/zgoos_solaris.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build !illumos && solaris -// +build !illumos,solaris package goos diff --git a/src/internal/goos/zgoos_windows.go b/src/internal/goos/zgoos_windows.go index dfa55339d3..16158be78b 100644 --- a/src/internal/goos/zgoos_windows.go +++ b/src/internal/goos/zgoos_windows.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build windows -// +build windows package goos diff --git a/src/internal/goos/zgoos_zos.go b/src/internal/goos/zgoos_zos.go index 714f24963a..fb6165c7a1 100644 --- a/src/internal/goos/zgoos_zos.go +++ b/src/internal/goos/zgoos_zos.go @@ -1,7 +1,6 @@ // Code generated by gengoos.go using 'go generate'. DO NOT EDIT. //go:build zos -// +build zos package goos diff --git a/src/internal/goroot/gc.go b/src/internal/goroot/gc.go index 2338b78f3a..8c66cd13a8 100644 --- a/src/internal/goroot/gc.go +++ b/src/internal/goroot/gc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc package goroot diff --git a/src/internal/goroot/gccgo.go b/src/internal/goroot/gccgo.go index b1041da11d..62841222a7 100644 --- a/src/internal/goroot/gccgo.go +++ b/src/internal/goroot/gccgo.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gccgo -// +build gccgo package goroot diff --git a/src/internal/poll/errno_unix.go b/src/internal/poll/errno_unix.go index 55c548824f..c177519732 100644 --- a/src/internal/poll/errno_unix.go +++ b/src/internal/poll/errno_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package poll diff --git a/src/internal/poll/errno_windows.go b/src/internal/poll/errno_windows.go index c55f5f0df5..3679aa8c4c 100644 --- a/src/internal/poll/errno_windows.go +++ b/src/internal/poll/errno_windows.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package poll diff --git a/src/internal/poll/error_stub_test.go b/src/internal/poll/error_stub_test.go index bcc25dd666..48e095254d 100644 --- a/src/internal/poll/error_stub_test.go +++ b/src/internal/poll/error_stub_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !linux -// +build !linux package poll_test diff --git a/src/internal/poll/export_posix_test.go b/src/internal/poll/export_posix_test.go index f59c1f6dfa..3fcafac002 100644 --- a/src/internal/poll/export_posix_test.go +++ b/src/internal/poll/export_posix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows // Export guts for testing on posix. // Since testing imports os and os imports internal/poll, diff --git a/src/internal/poll/fcntl_js.go b/src/internal/poll/fcntl_js.go index 7bf0ddc792..0f42ef61a5 100644 --- a/src/internal/poll/fcntl_js.go +++ b/src/internal/poll/fcntl_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package poll diff --git a/src/internal/poll/fcntl_libc.go b/src/internal/poll/fcntl_libc.go index cc609e48ad..f503d7a336 100644 --- a/src/internal/poll/fcntl_libc.go +++ b/src/internal/poll/fcntl_libc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || solaris -// +build aix darwin solaris package poll diff --git a/src/internal/poll/fcntl_syscall.go b/src/internal/poll/fcntl_syscall.go index 8db5b66504..accff5e043 100644 --- a/src/internal/poll/fcntl_syscall.go +++ b/src/internal/poll/fcntl_syscall.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux || netbsd || openbsd -// +build dragonfly freebsd linux netbsd openbsd package poll diff --git a/src/internal/poll/fd_fsync_posix.go b/src/internal/poll/fd_fsync_posix.go index 651a5ecd8b..6f17019e73 100644 --- a/src/internal/poll/fd_fsync_posix.go +++ b/src/internal/poll/fd_fsync_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix dragonfly freebsd js,wasm linux netbsd openbsd solaris package poll diff --git a/src/internal/poll/fd_poll_js.go b/src/internal/poll/fd_poll_js.go index 760e24802e..84bfcae633 100644 --- a/src/internal/poll/fd_poll_js.go +++ b/src/internal/poll/fd_poll_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package poll diff --git a/src/internal/poll/fd_poll_runtime.go b/src/internal/poll/fd_poll_runtime.go index b072af00ea..4a4dddfd27 100644 --- a/src/internal/poll/fd_poll_runtime.go +++ b/src/internal/poll/fd_poll_runtime.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || windows || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd windows solaris package poll diff --git a/src/internal/poll/fd_posix.go b/src/internal/poll/fd_posix.go index 487f3285ee..dc1e29c6b7 100644 --- a/src/internal/poll/fd_posix.go +++ b/src/internal/poll/fd_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package poll diff --git a/src/internal/poll/fd_posix_test.go b/src/internal/poll/fd_posix_test.go index 1dcf51d419..0b7ef7a577 100644 --- a/src/internal/poll/fd_posix_test.go +++ b/src/internal/poll/fd_posix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows package poll_test diff --git a/src/internal/poll/fd_unix.go b/src/internal/poll/fd_unix.go index 5489662889..d4c32e4d41 100644 --- a/src/internal/poll/fd_unix.go +++ b/src/internal/poll/fd_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package poll diff --git a/src/internal/poll/fd_writev_darwin.go b/src/internal/poll/fd_writev_darwin.go index 805fa2ccd9..8137510c8b 100644 --- a/src/internal/poll/fd_writev_darwin.go +++ b/src/internal/poll/fd_writev_darwin.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin -// +build darwin package poll diff --git a/src/internal/poll/fd_writev_illumos.go b/src/internal/poll/fd_writev_illumos.go index a0b11ed5ae..79190c2f63 100644 --- a/src/internal/poll/fd_writev_illumos.go +++ b/src/internal/poll/fd_writev_illumos.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build illumos -// +build illumos package poll diff --git a/src/internal/poll/fd_writev_unix.go b/src/internal/poll/fd_writev_unix.go index 87f284a56a..aa96d104c8 100644 --- a/src/internal/poll/fd_writev_unix.go +++ b/src/internal/poll/fd_writev_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux || netbsd || openbsd -// +build dragonfly freebsd linux netbsd openbsd package poll diff --git a/src/internal/poll/hook_cloexec.go b/src/internal/poll/hook_cloexec.go index d519f602c1..c941cb5235 100644 --- a/src/internal/poll/hook_cloexec.go +++ b/src/internal/poll/hook_cloexec.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || illumos || linux || netbsd || openbsd -// +build dragonfly freebsd illumos linux netbsd openbsd package poll diff --git a/src/internal/poll/hook_unix.go b/src/internal/poll/hook_unix.go index c88d65cdc8..c9aa4b4ca2 100644 --- a/src/internal/poll/hook_unix.go +++ b/src/internal/poll/hook_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package poll diff --git a/src/internal/poll/iovec_illumos.go b/src/internal/poll/iovec_illumos.go index f4058b298f..00a65d7995 100644 --- a/src/internal/poll/iovec_illumos.go +++ b/src/internal/poll/iovec_illumos.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build illumos -// +build illumos package poll diff --git a/src/internal/poll/iovec_unix.go b/src/internal/poll/iovec_unix.go index 6fd5d86630..c1500840ac 100644 --- a/src/internal/poll/iovec_unix.go +++ b/src/internal/poll/iovec_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package poll diff --git a/src/internal/poll/sendfile_bsd.go b/src/internal/poll/sendfile_bsd.go index 5531e533c5..89315a8c67 100644 --- a/src/internal/poll/sendfile_bsd.go +++ b/src/internal/poll/sendfile_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd -// +build darwin dragonfly freebsd package poll diff --git a/src/internal/poll/sock_cloexec.go b/src/internal/poll/sock_cloexec.go index b3038290b9..d849fda0b0 100644 --- a/src/internal/poll/sock_cloexec.go +++ b/src/internal/poll/sock_cloexec.go @@ -6,7 +6,6 @@ // setting SetNonblock and CloseOnExec. //go:build dragonfly || freebsd || illumos || linux || netbsd || openbsd -// +build dragonfly freebsd illumos linux netbsd openbsd package poll diff --git a/src/internal/poll/sockopt.go b/src/internal/poll/sockopt.go index 4f2e2fb455..2d354700c5 100644 --- a/src/internal/poll/sockopt.go +++ b/src/internal/poll/sockopt.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows package poll diff --git a/src/internal/poll/sockopt_unix.go b/src/internal/poll/sockopt_unix.go index 4fb9600dee..54be1cc4b6 100644 --- a/src/internal/poll/sockopt_unix.go +++ b/src/internal/poll/sockopt_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package poll diff --git a/src/internal/poll/sockoptip.go b/src/internal/poll/sockoptip.go index d86c4c1f81..7fc9aeefb3 100644 --- a/src/internal/poll/sockoptip.go +++ b/src/internal/poll/sockoptip.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows package poll diff --git a/src/internal/poll/strconv.go b/src/internal/poll/strconv.go index c98332d3da..2b052fa174 100644 --- a/src/internal/poll/strconv.go +++ b/src/internal/poll/strconv.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 -// +build plan9 package poll diff --git a/src/internal/poll/sys_cloexec.go b/src/internal/poll/sys_cloexec.go index 7e6d422d62..312ed24a44 100644 --- a/src/internal/poll/sys_cloexec.go +++ b/src/internal/poll/sys_cloexec.go @@ -6,7 +6,6 @@ // setting SetNonblock and CloseOnExec. //go:build aix || darwin || (js && wasm) || (solaris && !illumos) -// +build aix darwin js,wasm solaris,!illumos package poll diff --git a/src/internal/poll/writev.go b/src/internal/poll/writev.go index 824de7569e..cd600b63d7 100644 --- a/src/internal/poll/writev.go +++ b/src/internal/poll/writev.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || illumos || linux || netbsd || openbsd -// +build darwin dragonfly freebsd illumos linux netbsd openbsd package poll diff --git a/src/internal/syscall/execenv/execenv_default.go b/src/internal/syscall/execenv/execenv_default.go index 73289f1cd0..335647c638 100644 --- a/src/internal/syscall/execenv/execenv_default.go +++ b/src/internal/syscall/execenv/execenv_default.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows -// +build !windows package execenv diff --git a/src/internal/syscall/execenv/execenv_windows.go b/src/internal/syscall/execenv/execenv_windows.go index 6c0654943e..a8aa1a644e 100644 --- a/src/internal/syscall/execenv/execenv_windows.go +++ b/src/internal/syscall/execenv/execenv_windows.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package execenv diff --git a/src/internal/syscall/unix/at.go b/src/internal/syscall/unix/at.go index 9b08864f7f..447d48e198 100644 --- a/src/internal/syscall/unix/at.go +++ b/src/internal/syscall/unix/at.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux || openbsd || netbsd || dragonfly -// +build linux openbsd netbsd dragonfly package unix diff --git a/src/internal/syscall/unix/at_libc.go b/src/internal/syscall/unix/at_libc.go index 4cc351ea27..f48d3791e3 100644 --- a/src/internal/syscall/unix/at_libc.go +++ b/src/internal/syscall/unix/at_libc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || solaris -// +build aix solaris package unix diff --git a/src/internal/syscall/unix/at_sysnum_fstatat64_linux.go b/src/internal/syscall/unix/at_sysnum_fstatat64_linux.go index 050d401bc0..445b0c3854 100644 --- a/src/internal/syscall/unix/at_sysnum_fstatat64_linux.go +++ b/src/internal/syscall/unix/at_sysnum_fstatat64_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm || mips || mipsle || 386 -// +build arm mips mipsle 386 package unix diff --git a/src/internal/syscall/unix/at_sysnum_fstatat_linux.go b/src/internal/syscall/unix/at_sysnum_fstatat_linux.go index e53a2d1b75..73a3da5bff 100644 --- a/src/internal/syscall/unix/at_sysnum_fstatat_linux.go +++ b/src/internal/syscall/unix/at_sysnum_fstatat_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 || riscv64 -// +build arm64 riscv64 package unix diff --git a/src/internal/syscall/unix/at_sysnum_newfstatat_linux.go b/src/internal/syscall/unix/at_sysnum_newfstatat_linux.go index 4cb4a5976b..76edf67522 100644 --- a/src/internal/syscall/unix/at_sysnum_newfstatat_linux.go +++ b/src/internal/syscall/unix/at_sysnum_newfstatat_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || mips64 || mips64le || ppc64 || ppc64le || s390x -// +build amd64 mips64 mips64le ppc64 ppc64le s390x package unix diff --git a/src/internal/syscall/unix/fcntl_linux_32bit.go b/src/internal/syscall/unix/fcntl_linux_32bit.go index 46a4f6b030..7b39ee72bc 100644 --- a/src/internal/syscall/unix/fcntl_linux_32bit.go +++ b/src/internal/syscall/unix/fcntl_linux_32bit.go @@ -6,7 +6,6 @@ // If you change the build tags here, see syscall/flock_linux_32bit.go. //go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) -// +build linux,386 linux,arm linux,mips linux,mipsle package unix diff --git a/src/internal/syscall/unix/getentropy_darwin.go b/src/internal/syscall/unix/getentropy_darwin.go index c75006bf8b..7bab1f27b0 100644 --- a/src/internal/syscall/unix/getentropy_darwin.go +++ b/src/internal/syscall/unix/getentropy_darwin.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin && !ios -// +build darwin,!ios package unix diff --git a/src/internal/syscall/unix/getrandom.go b/src/internal/syscall/unix/getrandom.go index d2c58c0f6f..a6659331e4 100644 --- a/src/internal/syscall/unix/getrandom.go +++ b/src/internal/syscall/unix/getrandom.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux -// +build dragonfly freebsd linux package unix diff --git a/src/internal/syscall/unix/nonblocking.go b/src/internal/syscall/unix/nonblocking.go index a22986cb8a..9e5f0fb4a2 100644 --- a/src/internal/syscall/unix/nonblocking.go +++ b/src/internal/syscall/unix/nonblocking.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux || netbsd || openbsd -// +build dragonfly freebsd linux netbsd openbsd package unix diff --git a/src/internal/syscall/unix/nonblocking_js.go b/src/internal/syscall/unix/nonblocking_js.go index a5a5080d46..8ed40f3f91 100644 --- a/src/internal/syscall/unix/nonblocking_js.go +++ b/src/internal/syscall/unix/nonblocking_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package unix diff --git a/src/internal/syscall/unix/nonblocking_libc.go b/src/internal/syscall/unix/nonblocking_libc.go index d9565efcb6..75c6e92a6e 100644 --- a/src/internal/syscall/unix/nonblocking_libc.go +++ b/src/internal/syscall/unix/nonblocking_libc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || solaris -// +build aix darwin solaris package unix diff --git a/src/internal/syscall/unix/pipe2_illumos.go b/src/internal/syscall/unix/pipe2_illumos.go index b0aac89580..c6280f85e5 100644 --- a/src/internal/syscall/unix/pipe2_illumos.go +++ b/src/internal/syscall/unix/pipe2_illumos.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build illumos -// +build illumos package unix diff --git a/src/internal/syscall/unix/sysnum_linux_generic.go b/src/internal/syscall/unix/sysnum_linux_generic.go index a76025454c..3c5394a96b 100644 --- a/src/internal/syscall/unix/sysnum_linux_generic.go +++ b/src/internal/syscall/unix/sysnum_linux_generic.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (arm64 || riscv64) -// +build linux -// +build arm64 riscv64 package unix diff --git a/src/internal/syscall/unix/sysnum_linux_mips64x.go b/src/internal/syscall/unix/sysnum_linux_mips64x.go index f353d4d73e..bca526d2b9 100644 --- a/src/internal/syscall/unix/sysnum_linux_mips64x.go +++ b/src/internal/syscall/unix/sysnum_linux_mips64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build mips64 || mips64le -// +build mips64 mips64le package unix diff --git a/src/internal/syscall/unix/sysnum_linux_mipsx.go b/src/internal/syscall/unix/sysnum_linux_mipsx.go index 4ed471532a..c86195e496 100644 --- a/src/internal/syscall/unix/sysnum_linux_mipsx.go +++ b/src/internal/syscall/unix/sysnum_linux_mipsx.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build mips || mipsle -// +build mips mipsle package unix diff --git a/src/internal/syscall/unix/sysnum_linux_ppc64x.go b/src/internal/syscall/unix/sysnum_linux_ppc64x.go index b484ffef80..a4dcf2bc9d 100644 --- a/src/internal/syscall/unix/sysnum_linux_ppc64x.go +++ b/src/internal/syscall/unix/sysnum_linux_ppc64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64 || ppc64le -// +build ppc64 ppc64le package unix diff --git a/src/internal/syscall/unix/writev_illumos.go b/src/internal/syscall/unix/writev_illumos.go index f60949f662..ee31be1302 100644 --- a/src/internal/syscall/unix/writev_illumos.go +++ b/src/internal/syscall/unix/writev_illumos.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build illumos -// +build illumos package unix diff --git a/src/internal/testenv/testenv_cgo.go b/src/internal/testenv/testenv_cgo.go index 02f08f57c7..7426a29c1a 100644 --- a/src/internal/testenv/testenv_cgo.go +++ b/src/internal/testenv/testenv_cgo.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo -// +build cgo package testenv diff --git a/src/internal/testenv/testenv_notwin.go b/src/internal/testenv/testenv_notwin.go index 846ec93856..81171fd193 100644 --- a/src/internal/testenv/testenv_notwin.go +++ b/src/internal/testenv/testenv_notwin.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows -// +build !windows package testenv diff --git a/src/log/syslog/example_test.go b/src/log/syslog/example_test.go index 993976569e..4df29c0af0 100644 --- a/src/log/syslog/example_test.go +++ b/src/log/syslog/example_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows && !plan9 -// +build !windows,!plan9 package syslog_test diff --git a/src/log/syslog/syslog.go b/src/log/syslog/syslog.go index 6abd4ad124..8c6ba72135 100644 --- a/src/log/syslog/syslog.go +++ b/src/log/syslog/syslog.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows && !plan9 -// +build !windows,!plan9 package syslog diff --git a/src/log/syslog/syslog_test.go b/src/log/syslog/syslog_test.go index 62c6250845..26530480ee 100644 --- a/src/log/syslog/syslog_test.go +++ b/src/log/syslog/syslog_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows && !plan9 && !js -// +build !windows,!plan9,!js package syslog diff --git a/src/log/syslog/syslog_unix.go b/src/log/syslog/syslog_unix.go index 2e45f0764f..f9cdcdc273 100644 --- a/src/log/syslog/syslog_unix.go +++ b/src/log/syslog/syslog_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows && !plan9 -// +build !windows,!plan9 package syslog diff --git a/src/math/cmplx/huge_test.go b/src/math/cmplx/huge_test.go index 78b42316de..e794cf281a 100644 --- a/src/math/cmplx/huge_test.go +++ b/src/math/cmplx/huge_test.go @@ -6,7 +6,6 @@ // accurate for huge arguments. //go:build !s390x -// +build !s390x package cmplx diff --git a/src/math/dim_asm.go b/src/math/dim_asm.go index 9ba742a407..f4adbd0ae5 100644 --- a/src/math/dim_asm.go +++ b/src/math/dim_asm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || arm64 || riscv64 || s390x -// +build amd64 arm64 riscv64 s390x package math diff --git a/src/math/dim_noasm.go b/src/math/dim_noasm.go index ea46577d8d..5b9e06fed3 100644 --- a/src/math/dim_noasm.go +++ b/src/math/dim_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !arm64 && !riscv64 && !s390x -// +build !amd64,!arm64,!riscv64,!s390x package math diff --git a/src/math/exp2_asm.go b/src/math/exp2_asm.go index 76d258f125..c26b2c3fab 100644 --- a/src/math/exp2_asm.go +++ b/src/math/exp2_asm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 -// +build arm64 package math diff --git a/src/math/exp2_noasm.go b/src/math/exp2_noasm.go index 1b0ac87ebf..c2b409329f 100644 --- a/src/math/exp2_noasm.go +++ b/src/math/exp2_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !arm64 -// +build !arm64 package math diff --git a/src/math/exp_amd64.go b/src/math/exp_amd64.go index 654ccce481..0f701b1d6d 100644 --- a/src/math/exp_amd64.go +++ b/src/math/exp_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 -// +build amd64 package math diff --git a/src/math/exp_asm.go b/src/math/exp_asm.go index a1673ea1dd..424442845b 100644 --- a/src/math/exp_asm.go +++ b/src/math/exp_asm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || arm64 || s390x -// +build amd64 arm64 s390x package math diff --git a/src/math/exp_noasm.go b/src/math/exp_noasm.go index b757e6e230..bd3f02412a 100644 --- a/src/math/exp_noasm.go +++ b/src/math/exp_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !arm64 && !s390x -// +build !amd64,!arm64,!s390x package math diff --git a/src/math/floor_asm.go b/src/math/floor_asm.go index 1265e5171e..fb419d6da2 100644 --- a/src/math/floor_asm.go +++ b/src/math/floor_asm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || amd64 || arm64 || ppc64 || ppc64le || s390x || wasm -// +build 386 amd64 arm64 ppc64 ppc64le s390x wasm package math diff --git a/src/math/floor_noasm.go b/src/math/floor_noasm.go index 821af21020..5641c7ea0a 100644 --- a/src/math/floor_noasm.go +++ b/src/math/floor_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !386 && !amd64 && !arm64 && !ppc64 && !ppc64le && !s390x && !wasm -// +build !386,!amd64,!arm64,!ppc64,!ppc64le,!s390x,!wasm package math diff --git a/src/math/huge_test.go b/src/math/huge_test.go index ec81a4a31d..bc28c6ff69 100644 --- a/src/math/huge_test.go +++ b/src/math/huge_test.go @@ -6,7 +6,6 @@ // accurate for huge arguments. //go:build !s390x -// +build !s390x package math_test diff --git a/src/math/hypot_asm.go b/src/math/hypot_asm.go index 9435af41cf..852691037f 100644 --- a/src/math/hypot_asm.go +++ b/src/math/hypot_asm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || amd64 -// +build 386 amd64 package math diff --git a/src/math/hypot_noasm.go b/src/math/hypot_noasm.go index bc41b136e5..8b64812a1c 100644 --- a/src/math/hypot_noasm.go +++ b/src/math/hypot_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !386 && !amd64 -// +build !386,!amd64 package math diff --git a/src/math/log_asm.go b/src/math/log_asm.go index 4d3b7ee065..848cce13b2 100644 --- a/src/math/log_asm.go +++ b/src/math/log_asm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || s390x -// +build amd64 s390x package math diff --git a/src/math/log_stub.go b/src/math/log_stub.go index e169716436..d35992bf37 100644 --- a/src/math/log_stub.go +++ b/src/math/log_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 && !s390x -// +build !amd64,!s390x package math diff --git a/src/math/modf_asm.go b/src/math/modf_asm.go index ce431a9d8d..c63be6cf36 100644 --- a/src/math/modf_asm.go +++ b/src/math/modf_asm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 || ppc64 || ppc64le -// +build arm64 ppc64 ppc64le package math diff --git a/src/math/modf_noasm.go b/src/math/modf_noasm.go index 9607a0894b..55c6a7f6e2 100644 --- a/src/math/modf_noasm.go +++ b/src/math/modf_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !arm64 && !ppc64 && !ppc64le -// +build !arm64,!ppc64,!ppc64le package math diff --git a/src/math/rand/gen_cooked.go b/src/math/rand/gen_cooked.go index 7950e09fd7..782bb6671d 100644 --- a/src/math/rand/gen_cooked.go +++ b/src/math/rand/gen_cooked.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // This program computes the value of rngCooked in rng.go, // which is used for seeding all instances of rand.Source. diff --git a/src/math/sqrt_asm.go b/src/math/sqrt_asm.go index b9102568ed..2cec1a5903 100644 --- a/src/math/sqrt_asm.go +++ b/src/math/sqrt_asm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || amd64 || arm64 || arm || mips || mipsle || ppc64 || ppc64le || s390x || riscv64 || wasm -// +build 386 amd64 arm64 arm mips mipsle ppc64 ppc64le s390x riscv64 wasm package math diff --git a/src/math/sqrt_noasm.go b/src/math/sqrt_noasm.go index 7b546b7e8c..3979622023 100644 --- a/src/math/sqrt_noasm.go +++ b/src/math/sqrt_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !386 && !amd64 && !arm64 && !arm && !mips && !mipsle && !ppc64 && !ppc64le && !s390x && !riscv64 && !wasm -// +build !386,!amd64,!arm64,!arm,!mips,!mipsle,!ppc64,!ppc64le,!s390x,!riscv64,!wasm package math diff --git a/src/math/stubs.go b/src/math/stubs.go index e1345eb841..c4350d4b87 100644 --- a/src/math/stubs.go +++ b/src/math/stubs.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !s390x -// +build !s390x // This is a large group of functions that most architectures don't // implement in assembly. diff --git a/src/mime/type_unix.go b/src/mime/type_unix.go index f954bc8a1f..3abc1fa10e 100644 --- a/src/mime/type_unix.go +++ b/src/mime/type_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package mime diff --git a/src/mime/type_unix_test.go b/src/mime/type_unix_test.go index 6e2988225c..4d109aa71a 100644 --- a/src/mime/type_unix_test.go +++ b/src/mime/type_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package mime diff --git a/src/net/addrselect.go b/src/net/addrselect.go index ae93c595af..29e4ed85ab 100644 --- a/src/net/addrselect.go +++ b/src/net/addrselect.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris // Minimal RFC 6724 address selection. diff --git a/src/net/addrselect_test.go b/src/net/addrselect_test.go index dc13917018..2894d5d846 100644 --- a/src/net/addrselect_test.go +++ b/src/net/addrselect_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/cgo_aix.go b/src/net/cgo_aix.go index a94405ecc0..f3478148b4 100644 --- a/src/net/cgo_aix.go +++ b/src/net/cgo_aix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo -// +build cgo,!netgo package net diff --git a/src/net/cgo_android.go b/src/net/cgo_android.go index 4b1a2e3e1d..5ab8b5fede 100644 --- a/src/net/cgo_android.go +++ b/src/net/cgo_android.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo -// +build cgo,!netgo package net diff --git a/src/net/cgo_bsd.go b/src/net/cgo_bsd.go index 23be72140b..1456289b06 100644 --- a/src/net/cgo_bsd.go +++ b/src/net/cgo_bsd.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo && (darwin || dragonfly || freebsd) -// +build cgo -// +build !netgo -// +build darwin dragonfly freebsd package net diff --git a/src/net/cgo_linux.go b/src/net/cgo_linux.go index 1bd6be93f7..de6e87f176 100644 --- a/src/net/cgo_linux.go +++ b/src/net/cgo_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !android && cgo && !netgo -// +build !android,cgo,!netgo package net diff --git a/src/net/cgo_netbsd.go b/src/net/cgo_netbsd.go index 3714793a52..03392e8ff3 100644 --- a/src/net/cgo_netbsd.go +++ b/src/net/cgo_netbsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo -// +build cgo,!netgo package net diff --git a/src/net/cgo_openbsd.go b/src/net/cgo_openbsd.go index 3714793a52..03392e8ff3 100644 --- a/src/net/cgo_openbsd.go +++ b/src/net/cgo_openbsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo -// +build cgo,!netgo package net diff --git a/src/net/cgo_resnew.go b/src/net/cgo_resnew.go index 154405270f..fa6e68770c 100644 --- a/src/net/cgo_resnew.go +++ b/src/net/cgo_resnew.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo && (darwin || (linux && !android) || netbsd || solaris) -// +build cgo -// +build !netgo -// +build darwin linux,!android netbsd solaris package net diff --git a/src/net/cgo_resold.go b/src/net/cgo_resold.go index c4aab33eaa..37c75527f9 100644 --- a/src/net/cgo_resold.go +++ b/src/net/cgo_resold.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo && (android || freebsd || dragonfly || openbsd) -// +build cgo -// +build !netgo -// +build android freebsd dragonfly openbsd package net diff --git a/src/net/cgo_socknew.go b/src/net/cgo_socknew.go index f9cfad9909..fbb9e10f34 100644 --- a/src/net/cgo_socknew.go +++ b/src/net/cgo_socknew.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo && (android || linux || solaris) -// +build cgo -// +build !netgo -// +build android linux solaris package net diff --git a/src/net/cgo_sockold.go b/src/net/cgo_sockold.go index 22c67252f5..4d9869de04 100644 --- a/src/net/cgo_sockold.go +++ b/src/net/cgo_sockold.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo && (aix || darwin || dragonfly || freebsd || netbsd || openbsd) -// +build cgo -// +build !netgo -// +build aix darwin dragonfly freebsd netbsd openbsd package net diff --git a/src/net/cgo_solaris.go b/src/net/cgo_solaris.go index a84f5b0d34..cde9c957fe 100644 --- a/src/net/cgo_solaris.go +++ b/src/net/cgo_solaris.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo -// +build cgo,!netgo package net diff --git a/src/net/cgo_stub.go b/src/net/cgo_stub.go index 039e4be88b..cc84ca47ae 100644 --- a/src/net/cgo_stub.go +++ b/src/net/cgo_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !cgo || netgo -// +build !cgo netgo package net diff --git a/src/net/cgo_unix.go b/src/net/cgo_unix.go index 5bf6fd84bc..6fc2c1930e 100644 --- a/src/net/cgo_unix.go +++ b/src/net/cgo_unix.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris) -// +build cgo -// +build !netgo -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/cgo_unix_test.go b/src/net/cgo_unix_test.go index 1f3d9ea207..b4da25b84c 100644 --- a/src/net/cgo_unix_test.go +++ b/src/net/cgo_unix_test.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris) -// +build cgo -// +build !netgo -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/cgo_windows.go b/src/net/cgo_windows.go index 1fd1f29787..6bb6cbbb2f 100644 --- a/src/net/cgo_windows.go +++ b/src/net/cgo_windows.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !netgo -// +build cgo,!netgo package net diff --git a/src/net/conf.go b/src/net/conf.go index 6b9569cd92..1115699ab0 100644 --- a/src/net/conf.go +++ b/src/net/conf.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/conf_netcgo.go b/src/net/conf_netcgo.go index 8f387ebc03..82d1bb643e 100644 --- a/src/net/conf_netcgo.go +++ b/src/net/conf_netcgo.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build netcgo -// +build netcgo package net diff --git a/src/net/conf_test.go b/src/net/conf_test.go index b1f2c55ea5..5ae7055086 100644 --- a/src/net/conf_test.go +++ b/src/net/conf_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/conn_test.go b/src/net/conn_test.go index 45e271c264..e3cb0c5ec7 100644 --- a/src/net/conn_test.go +++ b/src/net/conn_test.go @@ -6,7 +6,6 @@ // tag. //go:build !js -// +build !js package net diff --git a/src/net/dial_test.go b/src/net/dial_test.go index 723038c7a2..8967892197 100644 --- a/src/net/dial_test.go +++ b/src/net/dial_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/dial_unix_test.go b/src/net/dial_unix_test.go index 108b973099..1113aaca90 100644 --- a/src/net/dial_unix_test.go +++ b/src/net/dial_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/dnsclient_unix.go b/src/net/dnsclient_unix.go index 50e9bb0f20..21aa91f665 100644 --- a/src/net/dnsclient_unix.go +++ b/src/net/dnsclient_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris // DNS client: see RFC 1035. // Has to be linked into package net for Dial. diff --git a/src/net/dnsclient_unix_test.go b/src/net/dnsclient_unix_test.go index 350ad5def7..1d704d021e 100644 --- a/src/net/dnsclient_unix_test.go +++ b/src/net/dnsclient_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/dnsconfig_unix.go b/src/net/dnsconfig_unix.go index db9213a13f..5ad254cd7c 100644 --- a/src/net/dnsconfig_unix.go +++ b/src/net/dnsconfig_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris // Read system DNS config from /etc/resolv.conf diff --git a/src/net/dnsconfig_unix_test.go b/src/net/dnsconfig_unix_test.go index 0e2317c469..4d35221497 100644 --- a/src/net/dnsconfig_unix_test.go +++ b/src/net/dnsconfig_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/dnsname_test.go b/src/net/dnsname_test.go index d851bf7566..28b7c680fe 100644 --- a/src/net/dnsname_test.go +++ b/src/net/dnsname_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/error_posix.go b/src/net/error_posix.go index 50eb66fc61..10e3caa67b 100644 --- a/src/net/error_posix.go +++ b/src/net/error_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package net diff --git a/src/net/error_posix_test.go b/src/net/error_posix_test.go index ea52a45ee8..081176f771 100644 --- a/src/net/error_posix_test.go +++ b/src/net/error_posix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !plan9 -// +build !plan9 package net diff --git a/src/net/error_test.go b/src/net/error_test.go index c304390819..30f8af3aee 100644 --- a/src/net/error_test.go +++ b/src/net/error_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/error_unix.go b/src/net/error_unix.go index d0b5e2ce96..0e64b40ea1 100644 --- a/src/net/error_unix.go +++ b/src/net/error_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || js || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js linux netbsd openbsd solaris package net diff --git a/src/net/error_unix_test.go b/src/net/error_unix_test.go index 533a45e648..1334aa86b6 100644 --- a/src/net/error_unix_test.go +++ b/src/net/error_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !plan9 && !windows -// +build !plan9,!windows package net diff --git a/src/net/external_test.go b/src/net/external_test.go index b8753cc092..3a97011fe8 100644 --- a/src/net/external_test.go +++ b/src/net/external_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/fcntl_libc_test.go b/src/net/fcntl_libc_test.go index 0320d63a86..3478ce7231 100644 --- a/src/net/fcntl_libc_test.go +++ b/src/net/fcntl_libc_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || solaris -// +build aix darwin solaris package net diff --git a/src/net/fcntl_syscall_test.go b/src/net/fcntl_syscall_test.go index 0f04bb4ed6..2d1f7e22a4 100644 --- a/src/net/fcntl_syscall_test.go +++ b/src/net/fcntl_syscall_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux || netbsd || openbsd -// +build dragonfly freebsd linux netbsd openbsd package net diff --git a/src/net/fd_posix.go b/src/net/fd_posix.go index 38e5a8d61d..1887a45186 100644 --- a/src/net/fd_posix.go +++ b/src/net/fd_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows package net diff --git a/src/net/fd_unix.go b/src/net/fd_unix.go index a7bbdd26b4..1bb029d370 100644 --- a/src/net/fd_unix.go +++ b/src/net/fd_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/file_stub.go b/src/net/file_stub.go index 9f988fe899..91df926a57 100644 --- a/src/net/file_stub.go +++ b/src/net/file_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package net diff --git a/src/net/file_test.go b/src/net/file_test.go index a70ef1b312..e86c15fac7 100644 --- a/src/net/file_test.go +++ b/src/net/file_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/file_unix.go b/src/net/file_unix.go index 4520d4b839..68d7eb9ca0 100644 --- a/src/net/file_unix.go +++ b/src/net/file_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/hook_unix.go b/src/net/hook_unix.go index b9153d1947..7c36b0d6e3 100644 --- a/src/net/hook_unix.go +++ b/src/net/hook_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package net diff --git a/src/net/http/cgi/plan9_test.go b/src/net/http/cgi/plan9_test.go index f998bac6ea..b7ace3f81c 100644 --- a/src/net/http/cgi/plan9_test.go +++ b/src/net/http/cgi/plan9_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 -// +build plan9 package cgi diff --git a/src/net/http/cgi/posix_test.go b/src/net/http/cgi/posix_test.go index bc58ea94cc..49b9470d4a 100644 --- a/src/net/http/cgi/posix_test.go +++ b/src/net/http/cgi/posix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !plan9 -// +build !plan9 package cgi diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go index 29226d4065..df98232824 100644 --- a/src/net/http/h2_bundle.go +++ b/src/net/http/h2_bundle.go @@ -1,5 +1,4 @@ //go:build !nethttpomithttp2 -// +build !nethttpomithttp2 // Code generated by golang.org/x/tools/cmd/bundle. DO NOT EDIT. // $ bundle -o=h2_bundle.go -prefix=http2 -tags=!nethttpomithttp2 golang.org/x/net/http2 diff --git a/src/net/http/omithttp2.go b/src/net/http/omithttp2.go index 79599d006a..63c0e92d6a 100644 --- a/src/net/http/omithttp2.go +++ b/src/net/http/omithttp2.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build nethttpomithttp2 -// +build nethttpomithttp2 package http diff --git a/src/net/http/roundtrip.go b/src/net/http/roundtrip.go index eef7c79293..c4c5d3b6eb 100644 --- a/src/net/http/roundtrip.go +++ b/src/net/http/roundtrip.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js || !wasm -// +build !js !wasm package http diff --git a/src/net/http/roundtrip_js.go b/src/net/http/roundtrip_js.go index 4a8595ebcf..dd042e9a01 100644 --- a/src/net/http/roundtrip_js.go +++ b/src/net/http/roundtrip_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package http diff --git a/src/net/http/triv.go b/src/net/http/triv.go index 4dc62407c6..11b19ab30c 100644 --- a/src/net/http/triv.go +++ b/src/net/http/triv.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore package main diff --git a/src/net/interface_bsd.go b/src/net/interface_bsd.go index 7578b1a16a..db7bc756d8 100644 --- a/src/net/interface_bsd.go +++ b/src/net/interface_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd package net diff --git a/src/net/interface_bsd_test.go b/src/net/interface_bsd_test.go index 8d0d9c3671..ce59962f61 100644 --- a/src/net/interface_bsd_test.go +++ b/src/net/interface_bsd_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd package net diff --git a/src/net/interface_bsdvar.go b/src/net/interface_bsdvar.go index 6230e0bfee..e9bea3d379 100644 --- a/src/net/interface_bsdvar.go +++ b/src/net/interface_bsdvar.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || netbsd || openbsd -// +build dragonfly netbsd openbsd package net diff --git a/src/net/interface_stub.go b/src/net/interface_stub.go index efe67c24d3..2d4475f63e 100644 --- a/src/net/interface_stub.go +++ b/src/net/interface_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package net diff --git a/src/net/interface_test.go b/src/net/interface_test.go index 754db36e3c..f6c9868418 100644 --- a/src/net/interface_test.go +++ b/src/net/interface_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/interface_unix_test.go b/src/net/interface_unix_test.go index 0d69fa5da4..92ec13a909 100644 --- a/src/net/interface_unix_test.go +++ b/src/net/interface_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package net diff --git a/src/net/internal/socktest/main_test.go b/src/net/internal/socktest/main_test.go index 8af85d382e..c7c8d16d4c 100644 --- a/src/net/internal/socktest/main_test.go +++ b/src/net/internal/socktest/main_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js && !plan9 -// +build !js,!plan9 package socktest_test diff --git a/src/net/internal/socktest/main_unix_test.go b/src/net/internal/socktest/main_unix_test.go index 6aa8875b66..7d21f6f99f 100644 --- a/src/net/internal/socktest/main_unix_test.go +++ b/src/net/internal/socktest/main_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js && !plan9 && !windows -// +build !js,!plan9,!windows package socktest_test diff --git a/src/net/internal/socktest/switch_posix.go b/src/net/internal/socktest/switch_posix.go index cda74e8639..fcad4ceae3 100644 --- a/src/net/internal/socktest/switch_posix.go +++ b/src/net/internal/socktest/switch_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !plan9 -// +build !plan9 package socktest diff --git a/src/net/internal/socktest/switch_stub.go b/src/net/internal/socktest/switch_stub.go index 5aa2ecec08..8a2fc353f0 100644 --- a/src/net/internal/socktest/switch_stub.go +++ b/src/net/internal/socktest/switch_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 -// +build plan9 package socktest diff --git a/src/net/internal/socktest/switch_unix.go b/src/net/internal/socktest/switch_unix.go index bfe9d4dbd3..77d68f6112 100644 --- a/src/net/internal/socktest/switch_unix.go +++ b/src/net/internal/socktest/switch_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package socktest diff --git a/src/net/internal/socktest/sys_cloexec.go b/src/net/internal/socktest/sys_cloexec.go index c7f8331c2e..cc7cefbe2c 100644 --- a/src/net/internal/socktest/sys_cloexec.go +++ b/src/net/internal/socktest/sys_cloexec.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || illumos || linux || netbsd || openbsd -// +build dragonfly freebsd illumos linux netbsd openbsd package socktest diff --git a/src/net/internal/socktest/sys_unix.go b/src/net/internal/socktest/sys_unix.go index e7cc45922e..0424164ed3 100644 --- a/src/net/internal/socktest/sys_unix.go +++ b/src/net/internal/socktest/sys_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package socktest diff --git a/src/net/ip_test.go b/src/net/ip_test.go index 5bbda6024d..10e77f3bdb 100644 --- a/src/net/ip_test.go +++ b/src/net/ip_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/iprawsock_posix.go b/src/net/iprawsock_posix.go index b94eec0e18..74f977e1ef 100644 --- a/src/net/iprawsock_posix.go +++ b/src/net/iprawsock_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package net diff --git a/src/net/iprawsock_test.go b/src/net/iprawsock_test.go index a96448ee6c..ca5ab480c0 100644 --- a/src/net/iprawsock_test.go +++ b/src/net/iprawsock_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/ipsock_posix.go b/src/net/ipsock_posix.go index 50003ac446..0910f63d48 100644 --- a/src/net/ipsock_posix.go +++ b/src/net/ipsock_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package net diff --git a/src/net/listen_test.go b/src/net/listen_test.go index 50355de1ac..7aaebe8fa1 100644 --- a/src/net/listen_test.go +++ b/src/net/listen_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js && !plan9 -// +build !js,!plan9 package net diff --git a/src/net/lookup_fake.go b/src/net/lookup_fake.go index f4fcaed5cf..c27eae4ba5 100644 --- a/src/net/lookup_fake.go +++ b/src/net/lookup_fake.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package net diff --git a/src/net/lookup_test.go b/src/net/lookup_test.go index 7ca6ac16ec..7bcc5c5be8 100644 --- a/src/net/lookup_test.go +++ b/src/net/lookup_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/lookup_unix.go b/src/net/lookup_unix.go index 8030e3d99e..255a19dfdb 100644 --- a/src/net/lookup_unix.go +++ b/src/net/lookup_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/main_cloexec_test.go b/src/net/main_cloexec_test.go index 742be2fcd8..ca7fc78491 100644 --- a/src/net/main_cloexec_test.go +++ b/src/net/main_cloexec_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || illumos || linux || netbsd || openbsd -// +build dragonfly freebsd illumos linux netbsd openbsd package net diff --git a/src/net/main_conf_test.go b/src/net/main_conf_test.go index 645b267b78..41b78eda1d 100644 --- a/src/net/main_conf_test.go +++ b/src/net/main_conf_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js && !plan9 && !windows -// +build !js,!plan9,!windows package net diff --git a/src/net/main_noconf_test.go b/src/net/main_noconf_test.go index bcea630cd3..ab050fac2b 100644 --- a/src/net/main_noconf_test.go +++ b/src/net/main_noconf_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (js && wasm) || plan9 || windows -// +build js,wasm plan9 windows package net diff --git a/src/net/main_posix_test.go b/src/net/main_posix_test.go index c804c4e755..8899aa9c94 100644 --- a/src/net/main_posix_test.go +++ b/src/net/main_posix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js && !plan9 -// +build !js,!plan9 package net diff --git a/src/net/main_test.go b/src/net/main_test.go index 4f004071f0..1ee8c2efe7 100644 --- a/src/net/main_test.go +++ b/src/net/main_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/main_unix_test.go b/src/net/main_unix_test.go index c8cff2d305..2ed0615ad8 100644 --- a/src/net/main_unix_test.go +++ b/src/net/main_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/mockserver_test.go b/src/net/mockserver_test.go index b50a1e59a1..43b11a7218 100644 --- a/src/net/mockserver_test.go +++ b/src/net/mockserver_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/net_fake.go b/src/net/net_fake.go index 48419be670..d58bd82029 100644 --- a/src/net/net_fake.go +++ b/src/net/net_fake.go @@ -5,7 +5,6 @@ // Fake networking for js/wasm. It is intended to allow tests of other package to pass. //go:build js && wasm -// +build js,wasm package net diff --git a/src/net/net_test.go b/src/net/net_test.go index 6e7be4db23..35acac509b 100644 --- a/src/net/net_test.go +++ b/src/net/net_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/netgo_unix_test.go b/src/net/netgo_unix_test.go index 5551e47de7..019772aa6a 100644 --- a/src/net/netgo_unix_test.go +++ b/src/net/netgo_unix_test.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (!cgo || netgo) && (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris) -// +build !cgo netgo -// +build darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/nss.go b/src/net/nss.go index 85177cab9b..ee5568883f 100644 --- a/src/net/nss.go +++ b/src/net/nss.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/nss_test.go b/src/net/nss_test.go index 4b73886c51..c9ccc60cb7 100644 --- a/src/net/nss_test.go +++ b/src/net/nss_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/packetconn_test.go b/src/net/packetconn_test.go index aeb9845fa7..b3b1715655 100644 --- a/src/net/packetconn_test.go +++ b/src/net/packetconn_test.go @@ -6,7 +6,6 @@ // tag. //go:build !js -// +build !js package net diff --git a/src/net/port_unix.go b/src/net/port_unix.go index a9a96a2323..102722b2ca 100644 --- a/src/net/port_unix.go +++ b/src/net/port_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris // Read system port mappings from /etc/services diff --git a/src/net/protoconn_test.go b/src/net/protoconn_test.go index fc9b386256..9f7d8ee4ef 100644 --- a/src/net/protoconn_test.go +++ b/src/net/protoconn_test.go @@ -6,7 +6,6 @@ // tag. //go:build !js -// +build !js package net diff --git a/src/net/rawconn_stub_test.go b/src/net/rawconn_stub_test.go index 975aa8d956..ff3d829893 100644 --- a/src/net/rawconn_stub_test.go +++ b/src/net/rawconn_stub_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (js && wasm) || plan9 -// +build js,wasm plan9 package net diff --git a/src/net/rawconn_test.go b/src/net/rawconn_test.go index 3ef7af33b7..645d82a1a6 100644 --- a/src/net/rawconn_test.go +++ b/src/net/rawconn_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/rawconn_unix_test.go b/src/net/rawconn_unix_test.go index 75bbab8b27..e6e1ad771a 100644 --- a/src/net/rawconn_unix_test.go +++ b/src/net/rawconn_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/sendfile_stub.go b/src/net/sendfile_stub.go index c079064262..4ddae852e1 100644 --- a/src/net/sendfile_stub.go +++ b/src/net/sendfile_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || (js && wasm) || netbsd || openbsd -// +build aix js,wasm netbsd openbsd package net diff --git a/src/net/sendfile_test.go b/src/net/sendfile_test.go index 54e51fa0ab..492333d0c8 100644 --- a/src/net/sendfile_test.go +++ b/src/net/sendfile_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/sendfile_unix_alt.go b/src/net/sendfile_unix_alt.go index cd63dcc32c..8845a981f5 100644 --- a/src/net/sendfile_unix_alt.go +++ b/src/net/sendfile_unix_alt.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || solaris -// +build darwin dragonfly freebsd solaris package net diff --git a/src/net/server_test.go b/src/net/server_test.go index 7cbf152298..5192c1e0af 100644 --- a/src/net/server_test.go +++ b/src/net/server_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/sock_bsd.go b/src/net/sock_bsd.go index 4c883ada78..27daf722b5 100644 --- a/src/net/sock_bsd.go +++ b/src/net/sock_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd package net diff --git a/src/net/sock_cloexec.go b/src/net/sock_cloexec.go index 6861c4bf63..56dab31b14 100644 --- a/src/net/sock_cloexec.go +++ b/src/net/sock_cloexec.go @@ -6,7 +6,6 @@ // setting SetNonblock and CloseOnExec. //go:build dragonfly || freebsd || illumos || linux || netbsd || openbsd -// +build dragonfly freebsd illumos linux netbsd openbsd package net diff --git a/src/net/sock_posix.go b/src/net/sock_posix.go index 9b1e7880ae..98a48229c7 100644 --- a/src/net/sock_posix.go +++ b/src/net/sock_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows package net diff --git a/src/net/sock_stub.go b/src/net/sock_stub.go index d804bfaacc..4b73e575fe 100644 --- a/src/net/sock_stub.go +++ b/src/net/sock_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || (js && wasm) || solaris -// +build aix js,wasm solaris package net diff --git a/src/net/sockaddr_posix.go b/src/net/sockaddr_posix.go index 9d77cb569b..c8e91936ad 100644 --- a/src/net/sockaddr_posix.go +++ b/src/net/sockaddr_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package net diff --git a/src/net/sockopt_bsd.go b/src/net/sockopt_bsd.go index ee1f98b834..ff99811980 100644 --- a/src/net/sockopt_bsd.go +++ b/src/net/sockopt_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd package net diff --git a/src/net/sockopt_posix.go b/src/net/sockopt_posix.go index 50b9bfa0a7..645080f988 100644 --- a/src/net/sockopt_posix.go +++ b/src/net/sockopt_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows package net diff --git a/src/net/sockopt_stub.go b/src/net/sockopt_stub.go index 99b5277ed0..98e23714d9 100644 --- a/src/net/sockopt_stub.go +++ b/src/net/sockopt_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package net diff --git a/src/net/sockoptip_bsdvar.go b/src/net/sockoptip_bsdvar.go index 56022fd1a5..3e9ba1ee78 100644 --- a/src/net/sockoptip_bsdvar.go +++ b/src/net/sockoptip_bsdvar.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd netbsd openbsd solaris package net diff --git a/src/net/sockoptip_posix.go b/src/net/sockoptip_posix.go index a2143aec2c..22031df22c 100644 --- a/src/net/sockoptip_posix.go +++ b/src/net/sockoptip_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows package net diff --git a/src/net/sockoptip_stub.go b/src/net/sockoptip_stub.go index 92349d88ba..2c993eb719 100644 --- a/src/net/sockoptip_stub.go +++ b/src/net/sockoptip_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package net diff --git a/src/net/splice_stub.go b/src/net/splice_stub.go index ce2e9046a9..3cdadb11c5 100644 --- a/src/net/splice_stub.go +++ b/src/net/splice_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !linux -// +build !linux package net diff --git a/src/net/splice_test.go b/src/net/splice_test.go index be13cc924d..43e0b926f7 100644 --- a/src/net/splice_test.go +++ b/src/net/splice_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux -// +build linux package net diff --git a/src/net/sys_cloexec.go b/src/net/sys_cloexec.go index a32483e2df..26eac5585a 100644 --- a/src/net/sys_cloexec.go +++ b/src/net/sys_cloexec.go @@ -6,7 +6,6 @@ // for setting SetNonblock and CloseOnExec. //go:build aix || darwin || (solaris && !illumos) -// +build aix darwin solaris,!illumos package net diff --git a/src/net/tcpsock_posix.go b/src/net/tcpsock_posix.go index 7c4523c5ee..ed6b18b551 100644 --- a/src/net/tcpsock_posix.go +++ b/src/net/tcpsock_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package net diff --git a/src/net/tcpsock_test.go b/src/net/tcpsock_test.go index 9c9f1eae93..fdf5c330a9 100644 --- a/src/net/tcpsock_test.go +++ b/src/net/tcpsock_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/tcpsock_unix_test.go b/src/net/tcpsock_unix_test.go index 41bd229132..b1f2876d4e 100644 --- a/src/net/tcpsock_unix_test.go +++ b/src/net/tcpsock_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js && !plan9 && !windows -// +build !js,!plan9,!windows package net diff --git a/src/net/tcpsockopt_posix.go b/src/net/tcpsockopt_posix.go index d08832adc0..73754b1a0f 100644 --- a/src/net/tcpsockopt_posix.go +++ b/src/net/tcpsockopt_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows package net diff --git a/src/net/tcpsockopt_stub.go b/src/net/tcpsockopt_stub.go index 028d5fd29c..0fe91829c0 100644 --- a/src/net/tcpsockopt_stub.go +++ b/src/net/tcpsockopt_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package net diff --git a/src/net/tcpsockopt_unix.go b/src/net/tcpsockopt_unix.go index a945889e00..bdcdc40239 100644 --- a/src/net/tcpsockopt_unix.go +++ b/src/net/tcpsockopt_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || freebsd || linux || netbsd -// +build aix freebsd linux netbsd package net diff --git a/src/net/timeout_test.go b/src/net/timeout_test.go index 6c8e9cf76e..82069b347a 100644 --- a/src/net/timeout_test.go +++ b/src/net/timeout_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/udpsock_posix.go b/src/net/udpsock_posix.go index 3a333ca243..c3f7ddb77e 100644 --- a/src/net/udpsock_posix.go +++ b/src/net/udpsock_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package net diff --git a/src/net/udpsock_test.go b/src/net/udpsock_test.go index 0e8c3511c3..0f8f463100 100644 --- a/src/net/udpsock_test.go +++ b/src/net/udpsock_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/unixsock_posix.go b/src/net/unixsock_posix.go index 99a89c827b..1b69df53bf 100644 --- a/src/net/unixsock_posix.go +++ b/src/net/unixsock_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package net diff --git a/src/net/unixsock_readmsg_cloexec.go b/src/net/unixsock_readmsg_cloexec.go index 716484cc6c..fa4fd7d933 100644 --- a/src/net/unixsock_readmsg_cloexec.go +++ b/src/net/unixsock_readmsg_cloexec.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || freebsd || solaris -// +build aix darwin freebsd solaris package net diff --git a/src/net/unixsock_readmsg_cmsg_cloexec.go b/src/net/unixsock_readmsg_cmsg_cloexec.go index bb851b89c0..6b0de875ad 100644 --- a/src/net/unixsock_readmsg_cmsg_cloexec.go +++ b/src/net/unixsock_readmsg_cmsg_cloexec.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || linux || netbsd || openbsd -// +build dragonfly linux netbsd openbsd package net diff --git a/src/net/unixsock_readmsg_other.go b/src/net/unixsock_readmsg_other.go index 329076183a..b3d19fe73d 100644 --- a/src/net/unixsock_readmsg_other.go +++ b/src/net/unixsock_readmsg_other.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (js && wasm) || windows -// +build js,wasm windows package net diff --git a/src/net/unixsock_readmsg_test.go b/src/net/unixsock_readmsg_test.go index a4d2fca69c..c3bfbf9af2 100644 --- a/src/net/unixsock_readmsg_test.go +++ b/src/net/unixsock_readmsg_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/unixsock_test.go b/src/net/unixsock_test.go index 71092e88fb..a75578235f 100644 --- a/src/net/unixsock_test.go +++ b/src/net/unixsock_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js && !plan9 && !windows -// +build !js,!plan9,!windows package net diff --git a/src/net/unixsock_windows_test.go b/src/net/unixsock_windows_test.go index 29244f6471..dedd761c56 100644 --- a/src/net/unixsock_windows_test.go +++ b/src/net/unixsock_windows_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package net diff --git a/src/net/write_unix_test.go b/src/net/write_unix_test.go index f79f2d0865..23e8befa92 100644 --- a/src/net/write_unix_test.go +++ b/src/net/write_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/src/net/writev_test.go b/src/net/writev_test.go index bf40ca2023..b752295862 100644 --- a/src/net/writev_test.go +++ b/src/net/writev_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package net diff --git a/src/net/writev_unix.go b/src/net/writev_unix.go index a0fedc2f99..51ab29dc31 100644 --- a/src/net/writev_unix.go +++ b/src/net/writev_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || illumos || linux || netbsd || openbsd -// +build darwin dragonfly freebsd illumos linux netbsd openbsd package net diff --git a/src/os/dir_unix.go b/src/os/dir_unix.go index 5589c9c682..4eeb9ab86c 100644 --- a/src/os/dir_unix.go +++ b/src/os/dir_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix dragonfly freebsd js,wasm linux netbsd openbsd solaris package os diff --git a/src/os/endian_big.go b/src/os/endian_big.go index 0529dccd6f..0375e53372 100644 --- a/src/os/endian_big.go +++ b/src/os/endian_big.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // //go:build ppc64 || s390x || mips || mips64 -// +build ppc64 s390x mips mips64 package os diff --git a/src/os/endian_little.go b/src/os/endian_little.go index 6be6020f53..10643a804e 100644 --- a/src/os/endian_little.go +++ b/src/os/endian_little.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // //go:build 386 || amd64 || arm || arm64 || ppc64le || mips64le || mipsle || riscv64 || wasm -// +build 386 amd64 arm arm64 ppc64le mips64le mipsle riscv64 wasm package os diff --git a/src/os/env_unix_test.go b/src/os/env_unix_test.go index d45e1deb83..75225d8547 100644 --- a/src/os/env_unix_test.go +++ b/src/os/env_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package os_test diff --git a/src/os/error_errno.go b/src/os/error_errno.go index 580e915b73..c8140461a4 100644 --- a/src/os/error_errno.go +++ b/src/os/error_errno.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !plan9 -// +build !plan9 package os diff --git a/src/os/error_posix.go b/src/os/error_posix.go index 268b3a923a..234f4eb692 100644 --- a/src/os/error_posix.go +++ b/src/os/error_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package os diff --git a/src/os/error_unix_test.go b/src/os/error_unix_test.go index e45282a0fd..81bccebedb 100644 --- a/src/os/error_unix_test.go +++ b/src/os/error_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package os_test diff --git a/src/os/error_windows_test.go b/src/os/error_windows_test.go index aa0c14b7d4..86c8a985bb 100644 --- a/src/os/error_windows_test.go +++ b/src/os/error_windows_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package os_test diff --git a/src/os/exec/exec_linux_test.go b/src/os/exec/exec_linux_test.go index 3cfa30ee72..4a37c96e63 100644 --- a/src/os/exec/exec_linux_test.go +++ b/src/os/exec/exec_linux_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && cgo -// +build linux,cgo // On systems that use glibc, calling malloc can create a new arena, // and creating a new arena can read /sys/devices/system/cpu/online. diff --git a/src/os/exec/exec_posix_test.go b/src/os/exec/exec_posix_test.go index 7b2c0c0c11..fd7fb42d36 100644 --- a/src/os/exec/exec_posix_test.go +++ b/src/os/exec/exec_posix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package exec_test diff --git a/src/os/exec/exec_unix.go b/src/os/exec/exec_unix.go index 467c069e1c..c20f35276c 100644 --- a/src/os/exec/exec_unix.go +++ b/src/os/exec/exec_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !plan9 && !windows -// +build !plan9,!windows package exec diff --git a/src/os/exec/exec_windows_test.go b/src/os/exec/exec_windows_test.go index bd4dfb31da..8e31e47190 100644 --- a/src/os/exec/exec_windows_test.go +++ b/src/os/exec/exec_windows_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package exec_test diff --git a/src/os/exec/lp_js.go b/src/os/exec/lp_js.go index 4eac25fe6f..54ddc4d5b4 100644 --- a/src/os/exec/lp_js.go +++ b/src/os/exec/lp_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package exec diff --git a/src/os/exec/lp_unix.go b/src/os/exec/lp_unix.go index d1d246accf..38b9fc7c27 100644 --- a/src/os/exec/lp_unix.go +++ b/src/os/exec/lp_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package exec diff --git a/src/os/exec/lp_unix_test.go b/src/os/exec/lp_unix_test.go index 9fded0eb0a..52e401e580 100644 --- a/src/os/exec/lp_unix_test.go +++ b/src/os/exec/lp_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package exec diff --git a/src/os/exec/read3.go b/src/os/exec/read3.go index a8c71831d8..8aae5735c4 100644 --- a/src/os/exec/read3.go +++ b/src/os/exec/read3.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // This is a test program that verifies that it can read from // descriptor 3 and that no other descriptors are open. diff --git a/src/os/exec_posix.go b/src/os/exec_posix.go index e8736f7c54..07e2b36f62 100644 --- a/src/os/exec_posix.go +++ b/src/os/exec_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package os diff --git a/src/os/exec_unix.go b/src/os/exec_unix.go index d1bbeb7529..250c5c6402 100644 --- a/src/os/exec_unix.go +++ b/src/os/exec_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package os diff --git a/src/os/exec_unix_test.go b/src/os/exec_unix_test.go index f14b3519fb..fa332bf1ed 100644 --- a/src/os/exec_unix_test.go +++ b/src/os/exec_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package os_test diff --git a/src/os/executable_path.go b/src/os/executable_path.go index 625430ecfc..d6161bcb08 100644 --- a/src/os/executable_path.go +++ b/src/os/executable_path.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || openbsd -// +build aix openbsd package os diff --git a/src/os/executable_plan9.go b/src/os/executable_plan9.go index ad7a4410dc..8d8c83260f 100644 --- a/src/os/executable_plan9.go +++ b/src/os/executable_plan9.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 -// +build plan9 package os diff --git a/src/os/executable_procfs.go b/src/os/executable_procfs.go index 76ba0e6d08..18348eab91 100644 --- a/src/os/executable_procfs.go +++ b/src/os/executable_procfs.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux || netbsd || (js && wasm) -// +build linux netbsd js,wasm package os diff --git a/src/os/executable_sysctl.go b/src/os/executable_sysctl.go index 039448b557..3c2aeacf7d 100644 --- a/src/os/executable_sysctl.go +++ b/src/os/executable_sysctl.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build freebsd || dragonfly -// +build freebsd dragonfly package os diff --git a/src/os/export_unix_test.go b/src/os/export_unix_test.go index 10f8312831..d4eb7a4fb1 100644 --- a/src/os/export_unix_test.go +++ b/src/os/export_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package os diff --git a/src/os/fifo_test.go b/src/os/fifo_test.go index 007ed29129..de70927961 100644 --- a/src/os/fifo_test.go +++ b/src/os/fifo_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package os_test diff --git a/src/os/file_posix.go b/src/os/file_posix.go index 211f2a1798..0dc6da0908 100644 --- a/src/os/file_posix.go +++ b/src/os/file_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package os diff --git a/src/os/file_unix.go b/src/os/file_unix.go index a2531b9656..a38db18954 100644 --- a/src/os/file_unix.go +++ b/src/os/file_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package os diff --git a/src/os/os_unix_test.go b/src/os/os_unix_test.go index 9b4c0ab290..3ec3dee24b 100644 --- a/src/os/os_unix_test.go +++ b/src/os/os_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package os_test diff --git a/src/os/path_unix.go b/src/os/path_unix.go index db38359492..d1ffe2c187 100644 --- a/src/os/path_unix.go +++ b/src/os/path_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package os diff --git a/src/os/pipe2_bsd.go b/src/os/pipe2_bsd.go index bf6d081db5..7eb1350d02 100644 --- a/src/os/pipe2_bsd.go +++ b/src/os/pipe2_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || netbsd || openbsd -// +build dragonfly freebsd netbsd openbsd package os diff --git a/src/os/pipe2_illumos.go b/src/os/pipe2_illumos.go index 71b8cb8e25..354b35cc46 100644 --- a/src/os/pipe2_illumos.go +++ b/src/os/pipe2_illumos.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build illumos -// +build illumos package os diff --git a/src/os/pipe_bsd.go b/src/os/pipe_bsd.go index 097b32e7eb..554d62111a 100644 --- a/src/os/pipe_bsd.go +++ b/src/os/pipe_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || (js && wasm) || (solaris && !illumos) -// +build aix darwin js,wasm solaris,!illumos package os diff --git a/src/os/pipe_test.go b/src/os/pipe_test.go index 41a1e9c78a..ab6d1ce2b6 100644 --- a/src/os/pipe_test.go +++ b/src/os/pipe_test.go @@ -4,7 +4,6 @@ // Test broken pipes on Unix systems. //go:build !plan9 && !js -// +build !plan9,!js package os_test diff --git a/src/os/rawconn.go b/src/os/rawconn.go index ffc598b061..14a495d9c0 100644 --- a/src/os/rawconn.go +++ b/src/os/rawconn.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !plan9 -// +build !plan9 package os diff --git a/src/os/rawconn_test.go b/src/os/rawconn_test.go index 8aebaf87a6..fd2038a233 100644 --- a/src/os/rawconn_test.go +++ b/src/os/rawconn_test.go @@ -4,7 +4,6 @@ // Test use of raw connections. //go:build !plan9 && !js -// +build !plan9,!js package os_test diff --git a/src/os/readfrom_stub.go b/src/os/readfrom_stub.go index 826760f3df..8b7d5fb8f9 100644 --- a/src/os/readfrom_stub.go +++ b/src/os/readfrom_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !linux -// +build !linux package os diff --git a/src/os/removeall_at.go b/src/os/removeall_at.go index d04540bc63..da804c436f 100644 --- a/src/os/removeall_at.go +++ b/src/os/removeall_at.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package os diff --git a/src/os/removeall_noat.go b/src/os/removeall_noat.go index 853e0eddfc..a0332e8c35 100644 --- a/src/os/removeall_noat.go +++ b/src/os/removeall_noat.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris package os diff --git a/src/os/signal/example_unix_test.go b/src/os/signal/example_unix_test.go index 3f7795b8cf..b279ee9491 100644 --- a/src/os/signal/example_unix_test.go +++ b/src/os/signal/example_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package signal_test diff --git a/src/os/signal/internal/pty/pty.go b/src/os/signal/internal/pty/pty.go index 8d2eac7103..537febba55 100644 --- a/src/os/signal/internal/pty/pty.go +++ b/src/os/signal/internal/pty/pty.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (aix || darwin || dragonfly || freebsd || (linux && !android) || netbsd || openbsd) && cgo -// +build aix darwin dragonfly freebsd linux,!android netbsd openbsd -// +build cgo // Package pty is a simple pseudo-terminal package for Unix systems, // implemented by calling C functions via cgo. diff --git a/src/os/signal/signal_cgo_test.go b/src/os/signal/signal_cgo_test.go index e1e4509e2a..67bad66e0b 100644 --- a/src/os/signal/signal_cgo_test.go +++ b/src/os/signal/signal_cgo_test.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (darwin || dragonfly || freebsd || (linux && !android) || netbsd || openbsd) && cgo -// +build darwin dragonfly freebsd linux,!android netbsd openbsd -// +build cgo // Note that this test does not work on Solaris: issue #22849. // Don't run the test on Android because at least some versions of the diff --git a/src/os/signal/signal_linux_test.go b/src/os/signal/signal_linux_test.go index 7abe1ec5a0..f70f108442 100644 --- a/src/os/signal/signal_linux_test.go +++ b/src/os/signal/signal_linux_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux -// +build linux package signal diff --git a/src/os/signal/signal_test.go b/src/os/signal/signal_test.go index 649854b746..3e85d936f8 100644 --- a/src/os/signal/signal_test.go +++ b/src/os/signal/signal_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package signal diff --git a/src/os/signal/signal_unix.go b/src/os/signal/signal_unix.go index 9e241c43ac..e2e5c4ae97 100644 --- a/src/os/signal/signal_unix.go +++ b/src/os/signal/signal_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package signal diff --git a/src/os/stat_js.go b/src/os/stat_js.go index 3badf5ba57..c3e9b5b5e5 100644 --- a/src/os/stat_js.go +++ b/src/os/stat_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package os diff --git a/src/os/stat_unix.go b/src/os/stat_unix.go index 8c17805f71..eb15db5453 100644 --- a/src/os/stat_unix.go +++ b/src/os/stat_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package os diff --git a/src/os/sticky_bsd.go b/src/os/sticky_bsd.go index ab23d8111d..e71daf7c74 100644 --- a/src/os/sticky_bsd.go +++ b/src/os/sticky_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm netbsd openbsd solaris package os diff --git a/src/os/sticky_notbsd.go b/src/os/sticky_notbsd.go index 9979b43e8e..9a87fbde92 100644 --- a/src/os/sticky_notbsd.go +++ b/src/os/sticky_notbsd.go @@ -3,14 +3,6 @@ // license that can be found in the LICENSE file. //go:build !aix && !darwin && !dragonfly && !freebsd && (!js || !wasm) && !netbsd && !openbsd && !solaris -// +build !aix -// +build !darwin -// +build !dragonfly -// +build !freebsd -// +build !js !wasm -// +build !netbsd -// +build !openbsd -// +build !solaris package os diff --git a/src/os/sys_bsd.go b/src/os/sys_bsd.go index 1e245eb53a..e272c24571 100644 --- a/src/os/sys_bsd.go +++ b/src/os/sys_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || (js && wasm) || netbsd || openbsd -// +build darwin dragonfly freebsd js,wasm netbsd openbsd package os diff --git a/src/os/sys_js.go b/src/os/sys_js.go index 4d6a64e8eb..4fd0e2d7c7 100644 --- a/src/os/sys_js.go +++ b/src/os/sys_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package os diff --git a/src/os/sys_unix.go b/src/os/sys_unix.go index e316eaf06c..5ff39780e5 100644 --- a/src/os/sys_unix.go +++ b/src/os/sys_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package os diff --git a/src/os/timeout_test.go b/src/os/timeout_test.go index 6d65e420f0..2ff58110d6 100644 --- a/src/os/timeout_test.go +++ b/src/os/timeout_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js && !plan9 && !windows -// +build !js,!plan9,!windows package os_test diff --git a/src/os/types_unix.go b/src/os/types_unix.go index e9b8b8ba3a..105bb78765 100644 --- a/src/os/types_unix.go +++ b/src/os/types_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows && !plan9 -// +build !windows,!plan9 package os diff --git a/src/os/user/cgo_listgroups_unix.go b/src/os/user/cgo_listgroups_unix.go index 38aa7653b0..0d937da334 100644 --- a/src/os/user/cgo_listgroups_unix.go +++ b/src/os/user/cgo_listgroups_unix.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build (dragonfly || darwin || freebsd || (!android && linux) || netbsd || openbsd || (solaris && !illumos)) && cgo && !osusergo -// +build dragonfly darwin freebsd !android,linux netbsd openbsd solaris,!illumos -// +build cgo -// +build !osusergo package user diff --git a/src/os/user/cgo_lookup_unix.go b/src/os/user/cgo_lookup_unix.go index 5c972e77cf..523269086e 100644 --- a/src/os/user/cgo_lookup_unix.go +++ b/src/os/user/cgo_lookup_unix.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build (aix || darwin || dragonfly || freebsd || (!android && linux) || netbsd || openbsd || solaris) && cgo && !osusergo -// +build aix darwin dragonfly freebsd !android,linux netbsd openbsd solaris -// +build cgo -// +build !osusergo package user diff --git a/src/os/user/cgo_unix_test.go b/src/os/user/cgo_unix_test.go index 9ec32b3a78..6d16aa20b3 100644 --- a/src/os/user/cgo_unix_test.go +++ b/src/os/user/cgo_unix_test.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build (darwin || dragonfly || freebsd || (!android && linux) || netbsd || openbsd || solaris) && cgo && !osusergo -// +build darwin dragonfly freebsd !android,linux netbsd openbsd solaris -// +build cgo -// +build !osusergo package user diff --git a/src/os/user/getgrouplist_darwin.go b/src/os/user/getgrouplist_darwin.go index 23d12e3247..db6fb87e23 100644 --- a/src/os/user/getgrouplist_darwin.go +++ b/src/os/user/getgrouplist_darwin.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo && !osusergo -// +build cgo,!osusergo package user diff --git a/src/os/user/getgrouplist_unix.go b/src/os/user/getgrouplist_unix.go index fd66961ccf..104c2243df 100644 --- a/src/os/user/getgrouplist_unix.go +++ b/src/os/user/getgrouplist_unix.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build (dragonfly || freebsd || (!android && linux) || netbsd || openbsd || (solaris && !illumos)) && cgo && !osusergo -// +build dragonfly freebsd !android,linux netbsd openbsd solaris,!illumos -// +build cgo -// +build !osusergo package user diff --git a/src/os/user/listgroups_stub.go b/src/os/user/listgroups_stub.go index a066c6db71..4cf808b65d 100644 --- a/src/os/user/listgroups_stub.go +++ b/src/os/user/listgroups_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build android || (js && !wasm) -// +build android js,!wasm package user diff --git a/src/os/user/lookup_android.go b/src/os/user/lookup_android.go index 151aab49c2..0ae31fd818 100644 --- a/src/os/user/lookup_android.go +++ b/src/os/user/lookup_android.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build android -// +build android package user diff --git a/src/os/user/lookup_stubs.go b/src/os/user/lookup_stubs.go index efaa92923d..ce1617d250 100644 --- a/src/os/user/lookup_stubs.go +++ b/src/os/user/lookup_stubs.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (!cgo && !windows && !plan9) || android || (osusergo && !windows && !plan9) -// +build !cgo,!windows,!plan9 android osusergo,!windows,!plan9 package user diff --git a/src/os/user/lookup_unix.go b/src/os/user/lookup_unix.go index 1cabdb5b71..e25323fbad 100644 --- a/src/os/user/lookup_unix.go +++ b/src/os/user/lookup_unix.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (aix || darwin || dragonfly || freebsd || (js && wasm) || (!android && linux) || netbsd || openbsd || solaris) && (!cgo || osusergo) -// +build aix darwin dragonfly freebsd js,wasm !android,linux netbsd openbsd solaris -// +build !cgo osusergo package user diff --git a/src/os/user/lookup_unix_test.go b/src/os/user/lookup_unix_test.go index 05d23567c3..77917677fc 100644 --- a/src/os/user/lookup_unix_test.go +++ b/src/os/user/lookup_unix_test.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (aix || darwin || dragonfly || freebsd || (!android && linux) || netbsd || openbsd || solaris) && !cgo -// +build aix darwin dragonfly freebsd !android,linux netbsd openbsd solaris -// +build !cgo package user diff --git a/src/os/wait_unimp.go b/src/os/wait_unimp.go index c1f66ca155..721b9f9f7e 100644 --- a/src/os/wait_unimp.go +++ b/src/os/wait_unimp.go @@ -7,7 +7,6 @@ // failures, see issue #48789. //go:build aix || darwin || (js && wasm) || netbsd || openbsd || solaris -// +build aix darwin js,wasm netbsd openbsd solaris package os diff --git a/src/os/wait_wait6.go b/src/os/wait_wait6.go index 51193401f9..d395dac40b 100644 --- a/src/os/wait_wait6.go +++ b/src/os/wait_wait6.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd -// +build dragonfly freebsd package os diff --git a/src/os/wait_waitid.go b/src/os/wait_waitid.go index 44962c8534..c0503b209c 100644 --- a/src/os/wait_waitid.go +++ b/src/os/wait_waitid.go @@ -6,7 +6,6 @@ // waitid returns if the process is stopped, even when using WEXITED. //go:build linux -// +build linux package os diff --git a/src/path/filepath/example_unix_test.go b/src/path/filepath/example_unix_test.go index 4ce10095e6..b364cf0608 100644 --- a/src/path/filepath/example_unix_test.go +++ b/src/path/filepath/example_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows && !plan9 -// +build !windows,!plan9 package filepath_test diff --git a/src/path/filepath/example_unix_walk_test.go b/src/path/filepath/example_unix_walk_test.go index d72efcebe6..86146dba5b 100644 --- a/src/path/filepath/example_unix_walk_test.go +++ b/src/path/filepath/example_unix_walk_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows && !plan9 -// +build !windows,!plan9 package filepath_test diff --git a/src/path/filepath/path_unix.go b/src/path/filepath/path_unix.go index d4b6f967a3..dcf1d187e7 100644 --- a/src/path/filepath/path_unix.go +++ b/src/path/filepath/path_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package filepath diff --git a/src/path/filepath/symlink_unix.go b/src/path/filepath/symlink_unix.go index 657945a81a..7bfe17e2fd 100644 --- a/src/path/filepath/symlink_unix.go +++ b/src/path/filepath/symlink_unix.go @@ -1,5 +1,4 @@ //go:build !windows -// +build !windows package filepath diff --git a/src/plugin/plugin_dlopen.go b/src/plugin/plugin_dlopen.go index aa85d4831c..5fff329fc5 100644 --- a/src/plugin/plugin_dlopen.go +++ b/src/plugin/plugin_dlopen.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (linux && cgo) || (darwin && cgo) || (freebsd && cgo) -// +build linux,cgo darwin,cgo freebsd,cgo package plugin diff --git a/src/plugin/plugin_stubs.go b/src/plugin/plugin_stubs.go index 67855bed4b..2e9492e7c6 100644 --- a/src/plugin/plugin_stubs.go +++ b/src/plugin/plugin_stubs.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (!linux && !freebsd && !darwin) || !cgo -// +build !linux,!freebsd,!darwin !cgo package plugin diff --git a/src/plugin/plugin_test.go b/src/plugin/plugin_test.go index 4ce912132c..8185095f85 100644 --- a/src/plugin/plugin_test.go +++ b/src/plugin/plugin_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !linux || (linux && !arm64) -// +build !linux linux,!arm64 package plugin_test diff --git a/src/reflect/abi_test.go b/src/reflect/abi_test.go index 873febbad2..41cfd9d082 100644 --- a/src/reflect/abi_test.go +++ b/src/reflect/abi_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build goexperiment.regabireflect && goexperiment.regabiargs -// +build goexperiment.regabireflect,goexperiment.regabiargs package reflect_test diff --git a/src/reflect/float32reg_generic.go b/src/reflect/float32reg_generic.go index bfceb9ecaa..307c0bb33c 100644 --- a/src/reflect/float32reg_generic.go +++ b/src/reflect/float32reg_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !ppc64 && !ppc64le -// +build !ppc64,!ppc64le package reflect diff --git a/src/reflect/stubs_ppc64x.go b/src/reflect/stubs_ppc64x.go index dbd3f9e748..06c8bf5483 100644 --- a/src/reflect/stubs_ppc64x.go +++ b/src/reflect/stubs_ppc64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64le || ppc64 -// +build ppc64le ppc64 package reflect diff --git a/src/regexp/exec2_test.go b/src/regexp/exec2_test.go index 6444bc12f9..b6dac4a058 100644 --- a/src/regexp/exec2_test.go +++ b/src/regexp/exec2_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !race -// +build !race package regexp diff --git a/src/runtime/abi_test.go b/src/runtime/abi_test.go index f69d3a9d50..5c1f1f4067 100644 --- a/src/runtime/abi_test.go +++ b/src/runtime/abi_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build goexperiment.regabireflect -// +build goexperiment.regabireflect // 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/asan.go b/src/runtime/asan.go index 7ff5f26bfb..a22b56bb07 100644 --- a/src/runtime/asan.go +++ b/src/runtime/asan.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build asan -// +build asan package runtime diff --git a/src/runtime/asan0.go b/src/runtime/asan0.go index dad069bbe6..d5478d6bee 100644 --- a/src/runtime/asan0.go +++ b/src/runtime/asan0.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !asan -// +build !asan // Dummy ASan support API, used when not built with -asan. diff --git a/src/runtime/auxv_none.go b/src/runtime/auxv_none.go index 3178f1a154..5d473cab5c 100644 --- a/src/runtime/auxv_none.go +++ b/src/runtime/auxv_none.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !linux && !darwin && !dragonfly && !freebsd && !netbsd && !solaris -// +build !linux,!darwin,!dragonfly,!freebsd,!netbsd,!solaris package runtime diff --git a/src/runtime/cgo/callbacks_traceback.go b/src/runtime/cgo/callbacks_traceback.go index 7302c1eedf..dae31a8fcd 100644 --- a/src/runtime/cgo/callbacks_traceback.go +++ b/src/runtime/cgo/callbacks_traceback.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || linux -// +build darwin linux package cgo diff --git a/src/runtime/cgo/dragonfly.go b/src/runtime/cgo/dragonfly.go index cfa6fe86e2..36d70e34e2 100644 --- a/src/runtime/cgo/dragonfly.go +++ b/src/runtime/cgo/dragonfly.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly -// +build dragonfly package cgo diff --git a/src/runtime/cgo/freebsd.go b/src/runtime/cgo/freebsd.go index d56702ec70..2d9f6245b5 100644 --- a/src/runtime/cgo/freebsd.go +++ b/src/runtime/cgo/freebsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build freebsd -// +build freebsd package cgo diff --git a/src/runtime/cgo/linux.go b/src/runtime/cgo/linux.go index 070d531bee..1d6fe03917 100644 --- a/src/runtime/cgo/linux.go +++ b/src/runtime/cgo/linux.go @@ -6,7 +6,6 @@ // corresponding cgo->libc (nptl) wrappers for various system calls. //go:build linux -// +build linux package cgo diff --git a/src/runtime/cgo/mmap.go b/src/runtime/cgo/mmap.go index 347ae6b363..eae0a9e7cc 100644 --- a/src/runtime/cgo/mmap.go +++ b/src/runtime/cgo/mmap.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (linux && amd64) || (linux && arm64) -// +build linux,amd64 linux,arm64 package cgo diff --git a/src/runtime/cgo/netbsd.go b/src/runtime/cgo/netbsd.go index 7e17d1fcd2..8a8018b7a8 100644 --- a/src/runtime/cgo/netbsd.go +++ b/src/runtime/cgo/netbsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build netbsd -// +build netbsd package cgo diff --git a/src/runtime/cgo/openbsd.go b/src/runtime/cgo/openbsd.go index f6215613c3..872d02e334 100644 --- a/src/runtime/cgo/openbsd.go +++ b/src/runtime/cgo/openbsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build openbsd -// +build openbsd package cgo diff --git a/src/runtime/cgo/setenv.go b/src/runtime/cgo/setenv.go index e6e8040ae0..0f4780a945 100644 --- a/src/runtime/cgo/setenv.go +++ b/src/runtime/cgo/setenv.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package cgo diff --git a/src/runtime/cgo/sigaction.go b/src/runtime/cgo/sigaction.go index 692fd2675f..dc714f7ef4 100644 --- a/src/runtime/cgo/sigaction.go +++ b/src/runtime/cgo/sigaction.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (linux && amd64) || (freebsd && amd64) || (linux && arm64) || (linux && ppc64le) -// +build linux,amd64 freebsd,amd64 linux,arm64 linux,ppc64le package cgo diff --git a/src/runtime/cgo_mmap.go b/src/runtime/cgo_mmap.go index 17d26b4cc8..0cb25bdcda 100644 --- a/src/runtime/cgo_mmap.go +++ b/src/runtime/cgo_mmap.go @@ -5,7 +5,6 @@ // Support for memory sanitizer. See runtime/cgo/mmap.go. //go:build (linux && amd64) || (linux && arm64) -// +build linux,amd64 linux,arm64 package runtime diff --git a/src/runtime/cgo_ppc64x.go b/src/runtime/cgo_ppc64x.go index 4dc92ea321..97b962e40f 100644 --- a/src/runtime/cgo_ppc64x.go +++ b/src/runtime/cgo_ppc64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64 || ppc64le -// +build ppc64 ppc64le package runtime diff --git a/src/runtime/cgo_sigaction.go b/src/runtime/cgo_sigaction.go index 6099d1b746..7e8ae28275 100644 --- a/src/runtime/cgo_sigaction.go +++ b/src/runtime/cgo_sigaction.go @@ -5,7 +5,6 @@ // Support for sanitizers. See runtime/cgo/sigaction.go. //go:build (linux && amd64) || (freebsd && amd64) || (linux && arm64) || (linux && ppc64le) -// +build linux,amd64 freebsd,amd64 linux,arm64 linux,ppc64le package runtime diff --git a/src/runtime/cputicks.go b/src/runtime/cputicks.go index 7c926f4a2b..2cf3240333 100644 --- a/src/runtime/cputicks.go +++ b/src/runtime/cputicks.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !arm && !arm64 && !mips64 && !mips64le && !mips && !mipsle && !wasm -// +build !arm,!arm64,!mips64,!mips64le,!mips,!mipsle,!wasm package runtime diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go index c0d4569462..e6d1742a38 100644 --- a/src/runtime/crash_cgo_test.go +++ b/src/runtime/crash_cgo_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build cgo -// +build cgo package runtime_test diff --git a/src/runtime/crash_nonunix_test.go b/src/runtime/crash_nonunix_test.go index 5f61476f21..73c1cd3101 100644 --- a/src/runtime/crash_nonunix_test.go +++ b/src/runtime/crash_nonunix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows || plan9 || (js && wasm) -// +build windows plan9 js,wasm package runtime_test diff --git a/src/runtime/crash_unix_test.go b/src/runtime/crash_unix_test.go index 694cc3d138..0d9d22aa49 100644 --- a/src/runtime/crash_unix_test.go +++ b/src/runtime/crash_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package runtime_test diff --git a/src/runtime/debug/panic_test.go b/src/runtime/debug/panic_test.go index 65f9555f37..ec5294ce4c 100644 --- a/src/runtime/debug/panic_test.go +++ b/src/runtime/debug/panic_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build aix darwin dragonfly freebsd linux netbsd openbsd // TODO: test on Windows? diff --git a/src/runtime/debug_test.go b/src/runtime/debug_test.go index f74383457f..b5db7a55f1 100644 --- a/src/runtime/debug_test.go +++ b/src/runtime/debug_test.go @@ -10,7 +10,6 @@ // point. //go:build amd64 && linux && !race -// +build amd64,linux,!race package runtime_test diff --git a/src/runtime/debugcall.go b/src/runtime/debugcall.go index a1440f7649..005a259f28 100644 --- a/src/runtime/debugcall.go +++ b/src/runtime/debugcall.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 -// +build amd64 package runtime diff --git a/src/runtime/debuglog_off.go b/src/runtime/debuglog_off.go index dd38156999..fa3be39c70 100644 --- a/src/runtime/debuglog_off.go +++ b/src/runtime/debuglog_off.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !debuglog -// +build !debuglog package runtime diff --git a/src/runtime/debuglog_on.go b/src/runtime/debuglog_on.go index 2fcdbe70d1..b815020225 100644 --- a/src/runtime/debuglog_on.go +++ b/src/runtime/debuglog_on.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build debuglog -// +build debuglog package runtime diff --git a/src/runtime/defs1_linux.go b/src/runtime/defs1_linux.go index df9c05dd5e..709f19e599 100644 --- a/src/runtime/defs1_linux.go +++ b/src/runtime/defs1_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo -cdefs diff --git a/src/runtime/defs2_linux.go b/src/runtime/defs2_linux.go index d016db7d02..41ad73576f 100644 --- a/src/runtime/defs2_linux.go +++ b/src/runtime/defs2_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* * Input to cgo -cdefs diff --git a/src/runtime/defs3_linux.go b/src/runtime/defs3_linux.go index 0a06aa2370..99479aad06 100644 --- a/src/runtime/defs3_linux.go +++ b/src/runtime/defs3_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo -cdefs diff --git a/src/runtime/defs_aix.go b/src/runtime/defs_aix.go index 1605002ea2..b794cd5de8 100644 --- a/src/runtime/defs_aix.go +++ b/src/runtime/defs_aix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo -godefs diff --git a/src/runtime/defs_aix_ppc64.go b/src/runtime/defs_aix_ppc64.go index f84ff1160d..4e20c85841 100644 --- a/src/runtime/defs_aix_ppc64.go +++ b/src/runtime/defs_aix_ppc64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix -// +build aix package runtime diff --git a/src/runtime/defs_arm_linux.go b/src/runtime/defs_arm_linux.go index f6b6dd2c09..805735bd0e 100644 --- a/src/runtime/defs_arm_linux.go +++ b/src/runtime/defs_arm_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo. diff --git a/src/runtime/defs_darwin.go b/src/runtime/defs_darwin.go index 2d41a97b57..59b81cf713 100644 --- a/src/runtime/defs_darwin.go +++ b/src/runtime/defs_darwin.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo. diff --git a/src/runtime/defs_dragonfly.go b/src/runtime/defs_dragonfly.go index aca2bf9001..47a2e4d123 100644 --- a/src/runtime/defs_dragonfly.go +++ b/src/runtime/defs_dragonfly.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo. diff --git a/src/runtime/defs_freebsd.go b/src/runtime/defs_freebsd.go index c258759549..9ba97c8459 100644 --- a/src/runtime/defs_freebsd.go +++ b/src/runtime/defs_freebsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo. diff --git a/src/runtime/defs_linux.go b/src/runtime/defs_linux.go index 7c3167032f..fa94e388f4 100644 --- a/src/runtime/defs_linux.go +++ b/src/runtime/defs_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo -cdefs diff --git a/src/runtime/defs_linux_mips64x.go b/src/runtime/defs_linux_mips64x.go index 1743bbce41..63433cb9be 100644 --- a/src/runtime/defs_linux_mips64x.go +++ b/src/runtime/defs_linux_mips64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (mips64 || mips64le) && linux -// +build mips64 mips64le -// +build linux package runtime diff --git a/src/runtime/defs_linux_mipsx.go b/src/runtime/defs_linux_mipsx.go index e84d4979e1..ffbf5051eb 100644 --- a/src/runtime/defs_linux_mipsx.go +++ b/src/runtime/defs_linux_mipsx.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (mips || mipsle) && linux -// +build mips mipsle -// +build linux package runtime diff --git a/src/runtime/defs_netbsd.go b/src/runtime/defs_netbsd.go index 755992d18e..df8bc579f2 100644 --- a/src/runtime/defs_netbsd.go +++ b/src/runtime/defs_netbsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo. diff --git a/src/runtime/defs_netbsd_386.go b/src/runtime/defs_netbsd_386.go index 03c9c2de59..2943ea3f13 100644 --- a/src/runtime/defs_netbsd_386.go +++ b/src/runtime/defs_netbsd_386.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo. diff --git a/src/runtime/defs_netbsd_amd64.go b/src/runtime/defs_netbsd_amd64.go index 9fda1d7d22..33d80ff53c 100644 --- a/src/runtime/defs_netbsd_amd64.go +++ b/src/runtime/defs_netbsd_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo. diff --git a/src/runtime/defs_netbsd_arm.go b/src/runtime/defs_netbsd_arm.go index e7f4f6cece..74b37527df 100644 --- a/src/runtime/defs_netbsd_arm.go +++ b/src/runtime/defs_netbsd_arm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo. diff --git a/src/runtime/defs_openbsd.go b/src/runtime/defs_openbsd.go index f818dc4453..ec7d82a33c 100644 --- a/src/runtime/defs_openbsd.go +++ b/src/runtime/defs_openbsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo. diff --git a/src/runtime/defs_solaris.go b/src/runtime/defs_solaris.go index e644f9c6dd..ec16c9dcce 100644 --- a/src/runtime/defs_solaris.go +++ b/src/runtime/defs_solaris.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo. diff --git a/src/runtime/defs_solaris_amd64.go b/src/runtime/defs_solaris_amd64.go index a0b38319a5..56e4b38c5e 100644 --- a/src/runtime/defs_solaris_amd64.go +++ b/src/runtime/defs_solaris_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo. diff --git a/src/runtime/env_posix.go b/src/runtime/env_posix.go index 95517b2a95..44086c1d63 100644 --- a/src/runtime/env_posix.go +++ b/src/runtime/env_posix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows || plan9 -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows plan9 package runtime diff --git a/src/runtime/export_debug_regabiargs_off_test.go b/src/runtime/export_debug_regabiargs_off_test.go index 5009003d27..81f73925d5 100644 --- a/src/runtime/export_debug_regabiargs_off_test.go +++ b/src/runtime/export_debug_regabiargs_off_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && linux && !goexperiment.regabiargs -// +build amd64,linux,!goexperiment.regabiargs package runtime diff --git a/src/runtime/export_debug_regabiargs_on_test.go b/src/runtime/export_debug_regabiargs_on_test.go index e1b72efd0f..7d1ab6888e 100644 --- a/src/runtime/export_debug_regabiargs_on_test.go +++ b/src/runtime/export_debug_regabiargs_on_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && linux && goexperiment.regabiargs -// +build amd64,linux,goexperiment.regabiargs package runtime diff --git a/src/runtime/export_debug_test.go b/src/runtime/export_debug_test.go index a2cef02cf8..032a9b9725 100644 --- a/src/runtime/export_debug_test.go +++ b/src/runtime/export_debug_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && linux -// +build amd64,linux package runtime diff --git a/src/runtime/export_futex_test.go b/src/runtime/export_futex_test.go index 34c970d6d2..03157d8eed 100644 --- a/src/runtime/export_futex_test.go +++ b/src/runtime/export_futex_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux -// +build dragonfly freebsd linux package runtime diff --git a/src/runtime/export_mmap_test.go b/src/runtime/export_mmap_test.go index bf4a815899..f9c3229316 100644 --- a/src/runtime/export_mmap_test.go +++ b/src/runtime/export_mmap_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris // Export guts for testing. diff --git a/src/runtime/export_pipe2_test.go b/src/runtime/export_pipe2_test.go index 26d8b7d185..bdf39c60df 100644 --- a/src/runtime/export_pipe2_test.go +++ b/src/runtime/export_pipe2_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build dragonfly freebsd linux netbsd openbsd solaris package runtime diff --git a/src/runtime/export_pipe_test.go b/src/runtime/export_pipe_test.go index a0c6c0440d..0583039982 100644 --- a/src/runtime/export_pipe_test.go +++ b/src/runtime/export_pipe_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin -// +build aix darwin package runtime diff --git a/src/runtime/export_unix_test.go b/src/runtime/export_unix_test.go index 215e234286..9f046b95e0 100644 --- a/src/runtime/export_unix_test.go +++ b/src/runtime/export_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package runtime diff --git a/src/runtime/futex_test.go b/src/runtime/futex_test.go index 10a735327a..188d0c6525 100644 --- a/src/runtime/futex_test.go +++ b/src/runtime/futex_test.go @@ -7,8 +7,6 @@ // the test. //go:build (dragonfly || freebsd || linux) && !race -// +build dragonfly freebsd linux -// +build !race package runtime_test diff --git a/src/runtime/hash32.go b/src/runtime/hash32.go index 7c22c76b87..0616c7dd05 100644 --- a/src/runtime/hash32.go +++ b/src/runtime/hash32.go @@ -6,7 +6,6 @@ // wyhash: https://github.com/wangyi-fudan/wyhash/blob/ceb019b530e2c1c14d70b79bfa2bc49de7d95bc1/Modern%20Non-Cryptographic%20Hash%20Function%20and%20Pseudorandom%20Number%20Generator.pdf //go:build 386 || arm || mips || mipsle -// +build 386 arm mips mipsle package runtime diff --git a/src/runtime/hash64.go b/src/runtime/hash64.go index 5f7d00bf7f..f773eb929c 100644 --- a/src/runtime/hash64.go +++ b/src/runtime/hash64.go @@ -6,7 +6,6 @@ // wyhash: https://github.com/wangyi-fudan/wyhash //go:build amd64 || arm64 || mips64 || mips64le || ppc64 || ppc64le || riscv64 || s390x || wasm -// +build amd64 arm64 mips64 mips64le ppc64 ppc64le riscv64 s390x wasm package runtime diff --git a/src/runtime/internal/atomic/atomic_386.go b/src/runtime/internal/atomic/atomic_386.go index d4aed6b671..27a77ec37a 100644 --- a/src/runtime/internal/atomic/atomic_386.go +++ b/src/runtime/internal/atomic/atomic_386.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 -// +build 386 package atomic diff --git a/src/runtime/internal/atomic/atomic_arm.go b/src/runtime/internal/atomic/atomic_arm.go index 2e9374ca26..e2539b6c7e 100644 --- a/src/runtime/internal/atomic/atomic_arm.go +++ b/src/runtime/internal/atomic/atomic_arm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm -// +build arm package atomic diff --git a/src/runtime/internal/atomic/atomic_arm64.go b/src/runtime/internal/atomic/atomic_arm64.go index dbb1796ec0..459fb9978d 100644 --- a/src/runtime/internal/atomic/atomic_arm64.go +++ b/src/runtime/internal/atomic/atomic_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 -// +build arm64 package atomic diff --git a/src/runtime/internal/atomic/atomic_mips64x.go b/src/runtime/internal/atomic/atomic_mips64x.go index 5b407ebc7a..1e12b83801 100644 --- a/src/runtime/internal/atomic/atomic_mips64x.go +++ b/src/runtime/internal/atomic/atomic_mips64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build mips64 || mips64le -// +build mips64 mips64le package atomic diff --git a/src/runtime/internal/atomic/atomic_mipsx.go b/src/runtime/internal/atomic/atomic_mipsx.go index 80cd65b333..e552e57495 100644 --- a/src/runtime/internal/atomic/atomic_mipsx.go +++ b/src/runtime/internal/atomic/atomic_mipsx.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build mips || mipsle -// +build mips mipsle // Export some functions via linkname to assembly in sync/atomic. //go:linkname Xadd64 diff --git a/src/runtime/internal/atomic/atomic_ppc64x.go b/src/runtime/internal/atomic/atomic_ppc64x.go index 98101e3287..998d16e3f6 100644 --- a/src/runtime/internal/atomic/atomic_ppc64x.go +++ b/src/runtime/internal/atomic/atomic_ppc64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64 || ppc64le -// +build ppc64 ppc64le package atomic diff --git a/src/runtime/internal/atomic/stubs.go b/src/runtime/internal/atomic/stubs.go index e7544ba448..7df8d9c863 100644 --- a/src/runtime/internal/atomic/stubs.go +++ b/src/runtime/internal/atomic/stubs.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !wasm -// +build !wasm package atomic diff --git a/src/runtime/internal/atomic/types_64bit.go b/src/runtime/internal/atomic/types_64bit.go index 9e5ed68419..43c1ba2709 100644 --- a/src/runtime/internal/atomic/types_64bit.go +++ b/src/runtime/internal/atomic/types_64bit.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || arm64 || mips64 || mips64le || ppc64 || ppc64le || riscv64 || s390x || wasm -// +build amd64 arm64 mips64 mips64le ppc64 ppc64le riscv64 s390x wasm package atomic diff --git a/src/runtime/internal/sys/intrinsics.go b/src/runtime/internal/sys/intrinsics.go index e76d8dd064..5af49011e9 100644 --- a/src/runtime/internal/sys/intrinsics.go +++ b/src/runtime/internal/sys/intrinsics.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !386 -// +build !386 // TODO finish intrinsifying 386, deadcode the assembly, remove build tags, merge w/ intrinsics_common // TODO replace all uses of CtzXX with TrailingZerosXX; they are the same. diff --git a/src/runtime/internal/sys/intrinsics_stubs.go b/src/runtime/internal/sys/intrinsics_stubs.go index bf1494d48a..a020652f76 100644 --- a/src/runtime/internal/sys/intrinsics_stubs.go +++ b/src/runtime/internal/sys/intrinsics_stubs.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 -// +build 386 package sys diff --git a/src/runtime/lfstack_32bit.go b/src/runtime/lfstack_32bit.go index c00f0965bd..405923cc34 100644 --- a/src/runtime/lfstack_32bit.go +++ b/src/runtime/lfstack_32bit.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || arm || mips || mipsle -// +build 386 arm mips mipsle package runtime diff --git a/src/runtime/lfstack_64bit.go b/src/runtime/lfstack_64bit.go index 4812dd1156..3f0e480897 100644 --- a/src/runtime/lfstack_64bit.go +++ b/src/runtime/lfstack_64bit.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || arm64 || mips64 || mips64le || ppc64 || ppc64le || riscv64 || s390x || wasm -// +build amd64 arm64 mips64 mips64le ppc64 ppc64le riscv64 s390x wasm package runtime diff --git a/src/runtime/libfuzzer.go b/src/runtime/libfuzzer.go index 578bce0414..e7b3cdc46a 100644 --- a/src/runtime/libfuzzer.go +++ b/src/runtime/libfuzzer.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build libfuzzer -// +build libfuzzer package runtime diff --git a/src/runtime/lock_futex.go b/src/runtime/lock_futex.go index e4c8d01941..575df7a1d5 100644 --- a/src/runtime/lock_futex.go +++ b/src/runtime/lock_futex.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux -// +build dragonfly freebsd linux package runtime diff --git a/src/runtime/lock_js.go b/src/runtime/lock_js.go index 0ca3512baf..80ee50da35 100644 --- a/src/runtime/lock_js.go +++ b/src/runtime/lock_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package runtime diff --git a/src/runtime/lock_sema.go b/src/runtime/lock_sema.go index 7a6af28b56..db36df1f37 100644 --- a/src/runtime/lock_sema.go +++ b/src/runtime/lock_sema.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || netbsd || openbsd || plan9 || solaris || windows -// +build aix darwin netbsd openbsd plan9 solaris windows package runtime diff --git a/src/runtime/lockrank_off.go b/src/runtime/lockrank_off.go index f3d2c00914..daa45b542d 100644 --- a/src/runtime/lockrank_off.go +++ b/src/runtime/lockrank_off.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !goexperiment.staticlockranking -// +build !goexperiment.staticlockranking package runtime diff --git a/src/runtime/lockrank_on.go b/src/runtime/lockrank_on.go index fc8d2dc8d1..3c8c367c19 100644 --- a/src/runtime/lockrank_on.go +++ b/src/runtime/lockrank_on.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build goexperiment.staticlockranking -// +build goexperiment.staticlockranking package runtime diff --git a/src/runtime/mem_bsd.go b/src/runtime/mem_bsd.go index dcbb9a1d51..b152571792 100644 --- a/src/runtime/mem_bsd.go +++ b/src/runtime/mem_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || netbsd || openbsd || solaris -// +build dragonfly freebsd netbsd openbsd solaris package runtime diff --git a/src/runtime/mem_js.go b/src/runtime/mem_js.go index fe940360c0..4ca486ac4b 100644 --- a/src/runtime/mem_js.go +++ b/src/runtime/mem_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package runtime diff --git a/src/runtime/mkduff.go b/src/runtime/mkduff.go index f3c3d8dfb5..d05158975f 100644 --- a/src/runtime/mkduff.go +++ b/src/runtime/mkduff.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // runtime·duffzero is a Duff's device for zeroing memory. // The compiler jumps to computed addresses within diff --git a/src/runtime/mkfastlog2table.go b/src/runtime/mkfastlog2table.go index 8d78a3923a..a55f54751c 100644 --- a/src/runtime/mkfastlog2table.go +++ b/src/runtime/mkfastlog2table.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // fastlog2Table contains log2 approximations for 5 binary digits. // This is used to implement fastlog2, which is used for heap sampling. diff --git a/src/runtime/mkpreempt.go b/src/runtime/mkpreempt.go index d87446d036..acfb518d10 100644 --- a/src/runtime/mkpreempt.go +++ b/src/runtime/mkpreempt.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // mkpreempt generates the asyncPreempt functions for each // architecture. diff --git a/src/runtime/mksizeclasses.go b/src/runtime/mksizeclasses.go index b1b10e9e02..64ed844329 100644 --- a/src/runtime/mksizeclasses.go +++ b/src/runtime/mksizeclasses.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // Generate tables for small malloc size classes. // diff --git a/src/runtime/mmap.go b/src/runtime/mmap.go index 7460eb3104..3280a62e8d 100644 --- a/src/runtime/mmap.go +++ b/src/runtime/mmap.go @@ -3,15 +3,6 @@ // license that can be found in the LICENSE file. //go:build !aix && !darwin && !js && (!linux || !amd64) && (!linux || !arm64) && !openbsd && !plan9 && !solaris && !windows -// +build !aix -// +build !darwin -// +build !js -// +build !linux !amd64 -// +build !linux !arm64 -// +build !openbsd -// +build !plan9 -// +build !solaris -// +build !windows package runtime diff --git a/src/runtime/mpagealloc_32bit.go b/src/runtime/mpagealloc_32bit.go index fceb4e7a18..1d863f2fda 100644 --- a/src/runtime/mpagealloc_32bit.go +++ b/src/runtime/mpagealloc_32bit.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || arm || mips || mipsle || wasm || (ios && arm64) -// +build 386 arm mips mipsle wasm ios,arm64 // wasm is a treated as a 32-bit architecture for the purposes of the page // allocator, even though it has 64-bit pointers. This is because any wasm diff --git a/src/runtime/mpagealloc_64bit.go b/src/runtime/mpagealloc_64bit.go index 16577346a7..782628c91d 100644 --- a/src/runtime/mpagealloc_64bit.go +++ b/src/runtime/mpagealloc_64bit.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || (!ios && arm64) || mips64 || mips64le || ppc64 || ppc64le || riscv64 || s390x -// +build amd64 !ios,arm64 mips64 mips64le ppc64 ppc64le riscv64 s390x // See mpagealloc_32bit.go for why ios/arm64 is excluded here. diff --git a/src/runtime/msan.go b/src/runtime/msan.go index 25aaf94e26..902a1e9e74 100644 --- a/src/runtime/msan.go +++ b/src/runtime/msan.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build msan -// +build msan package runtime diff --git a/src/runtime/msan0.go b/src/runtime/msan0.go index b1096a6750..2f5fd2d982 100644 --- a/src/runtime/msan0.go +++ b/src/runtime/msan0.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !msan -// +build !msan // Dummy MSan support API, used when not built with -msan. diff --git a/src/runtime/nbpipe_fcntl_libc_test.go b/src/runtime/nbpipe_fcntl_libc_test.go index 076a722eb7..a9c8987438 100644 --- a/src/runtime/nbpipe_fcntl_libc_test.go +++ b/src/runtime/nbpipe_fcntl_libc_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || solaris -// +build aix darwin solaris package runtime_test diff --git a/src/runtime/nbpipe_fcntl_unix_test.go b/src/runtime/nbpipe_fcntl_unix_test.go index 6d5e4ff021..97607fa2cf 100644 --- a/src/runtime/nbpipe_fcntl_unix_test.go +++ b/src/runtime/nbpipe_fcntl_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux || netbsd || openbsd -// +build dragonfly freebsd linux netbsd openbsd package runtime_test diff --git a/src/runtime/nbpipe_pipe.go b/src/runtime/nbpipe_pipe.go index b17257e9ec..408e1ec410 100644 --- a/src/runtime/nbpipe_pipe.go +++ b/src/runtime/nbpipe_pipe.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin -// +build aix darwin package runtime diff --git a/src/runtime/nbpipe_pipe2.go b/src/runtime/nbpipe_pipe2.go index f22b2b591f..6a555bcd99 100644 --- a/src/runtime/nbpipe_pipe2.go +++ b/src/runtime/nbpipe_pipe2.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build dragonfly freebsd linux netbsd openbsd solaris package runtime diff --git a/src/runtime/nbpipe_test.go b/src/runtime/nbpipe_test.go index 1d6a9b525c..36342cfde8 100644 --- a/src/runtime/nbpipe_test.go +++ b/src/runtime/nbpipe_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package runtime_test diff --git a/src/runtime/netpoll.go b/src/runtime/netpoll.go index 1008b4422c..f60e62dec7 100644 --- a/src/runtime/netpoll.go +++ b/src/runtime/netpoll.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows package runtime diff --git a/src/runtime/netpoll_epoll.go b/src/runtime/netpoll_epoll.go index 371ac59f8e..e0fb877d50 100644 --- a/src/runtime/netpoll_epoll.go +++ b/src/runtime/netpoll_epoll.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux -// +build linux package runtime diff --git a/src/runtime/netpoll_fake.go b/src/runtime/netpoll_fake.go index 8366f28914..de1dcae7ac 100644 --- a/src/runtime/netpoll_fake.go +++ b/src/runtime/netpoll_fake.go @@ -6,7 +6,6 @@ // Should never be used, because wasm/js network connections do not honor "SetNonblock". //go:build js && wasm -// +build js,wasm package runtime diff --git a/src/runtime/netpoll_kqueue.go b/src/runtime/netpoll_kqueue.go index 80d1b0cf18..2f7f2848d2 100644 --- a/src/runtime/netpoll_kqueue.go +++ b/src/runtime/netpoll_kqueue.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd package runtime diff --git a/src/runtime/netpoll_stub.go b/src/runtime/netpoll_stub.go index 33ab8eba58..d0a63bca86 100644 --- a/src/runtime/netpoll_stub.go +++ b/src/runtime/netpoll_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 -// +build plan9 package runtime diff --git a/src/runtime/norace_linux_test.go b/src/runtime/norace_linux_test.go index b199aa633c..b188a2e88b 100644 --- a/src/runtime/norace_linux_test.go +++ b/src/runtime/norace_linux_test.go @@ -4,7 +4,6 @@ // The file contains tests that cannot run under race detector for some reason. //go:build !race -// +build !race package runtime_test diff --git a/src/runtime/norace_test.go b/src/runtime/norace_test.go index 9ad5dde382..d49f2ec0df 100644 --- a/src/runtime/norace_test.go +++ b/src/runtime/norace_test.go @@ -4,7 +4,6 @@ // The file contains tests that cannot run under race detector for some reason. //go:build !race -// +build !race package runtime_test diff --git a/src/runtime/os_aix.go b/src/runtime/os_aix.go index c21da4ddaa..aeff593d50 100644 --- a/src/runtime/os_aix.go +++ b/src/runtime/os_aix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix -// +build aix package runtime diff --git a/src/runtime/os_freebsd2.go b/src/runtime/os_freebsd2.go index 7e266dc27e..3eaedf0b8b 100644 --- a/src/runtime/os_freebsd2.go +++ b/src/runtime/os_freebsd2.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build freebsd && !amd64 -// +build freebsd,!amd64 package runtime diff --git a/src/runtime/os_freebsd_noauxv.go b/src/runtime/os_freebsd_noauxv.go index 8fe0cb6718..1d9452bda5 100644 --- a/src/runtime/os_freebsd_noauxv.go +++ b/src/runtime/os_freebsd_noauxv.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build freebsd && !arm -// +build freebsd,!arm package runtime diff --git a/src/runtime/os_js.go b/src/runtime/os_js.go index 52b64e7602..9ed916705b 100644 --- a/src/runtime/os_js.go +++ b/src/runtime/os_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package runtime diff --git a/src/runtime/os_linux_arm64.go b/src/runtime/os_linux_arm64.go index 5260f22f57..2daa56fce7 100644 --- a/src/runtime/os_linux_arm64.go +++ b/src/runtime/os_linux_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 -// +build arm64 package runtime diff --git a/src/runtime/os_linux_be64.go b/src/runtime/os_linux_be64.go index 498d7cec6d..537515fcf2 100644 --- a/src/runtime/os_linux_be64.go +++ b/src/runtime/os_linux_be64.go @@ -5,8 +5,6 @@ // The standard Linux sigset type on big-endian 64-bit machines. //go:build linux && (ppc64 || s390x) -// +build linux -// +build ppc64 s390x package runtime diff --git a/src/runtime/os_linux_generic.go b/src/runtime/os_linux_generic.go index fe1973dbde..bed9e66e15 100644 --- a/src/runtime/os_linux_generic.go +++ b/src/runtime/os_linux_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !mips && !mipsle && !mips64 && !mips64le && !s390x && !ppc64 && linux -// +build !mips,!mipsle,!mips64,!mips64le,!s390x,!ppc64,linux package runtime diff --git a/src/runtime/os_linux_mips64x.go b/src/runtime/os_linux_mips64x.go index bd76442dbd..188db01034 100644 --- a/src/runtime/os_linux_mips64x.go +++ b/src/runtime/os_linux_mips64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips64 || mips64le) -// +build linux -// +build mips64 mips64le package runtime diff --git a/src/runtime/os_linux_mipsx.go b/src/runtime/os_linux_mipsx.go index ef8b3f7d43..73016f81d9 100644 --- a/src/runtime/os_linux_mipsx.go +++ b/src/runtime/os_linux_mipsx.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips || mipsle) -// +build linux -// +build mips mipsle package runtime diff --git a/src/runtime/os_linux_noauxv.go b/src/runtime/os_linux_noauxv.go index 59b5aacaeb..7b84f713d6 100644 --- a/src/runtime/os_linux_noauxv.go +++ b/src/runtime/os_linux_noauxv.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && !arm && !arm64 && !mips && !mipsle && !mips64 && !mips64le && !s390x && !ppc64 && !ppc64le -// +build linux,!arm,!arm64,!mips,!mipsle,!mips64,!mips64le,!s390x,!ppc64,!ppc64le package runtime diff --git a/src/runtime/os_linux_novdso.go b/src/runtime/os_linux_novdso.go index 7e93d2ba83..b06716dc6a 100644 --- a/src/runtime/os_linux_novdso.go +++ b/src/runtime/os_linux_novdso.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && !386 && !amd64 && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !riscv64 -// +build linux,!386,!amd64,!arm,!arm64,!mips64,!mips64le,!ppc64,!ppc64le,!riscv64 package runtime diff --git a/src/runtime/os_linux_ppc64x.go b/src/runtime/os_linux_ppc64x.go index c093d2ec0f..25d7ccc035 100644 --- a/src/runtime/os_linux_ppc64x.go +++ b/src/runtime/os_linux_ppc64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (ppc64 || ppc64le) -// +build linux -// +build ppc64 ppc64le package runtime diff --git a/src/runtime/os_linux_x86.go b/src/runtime/os_linux_x86.go index 5667774d82..c88f61fa2e 100644 --- a/src/runtime/os_linux_x86.go +++ b/src/runtime/os_linux_x86.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (386 || amd64) -// +build linux -// +build 386 amd64 package runtime diff --git a/src/runtime/os_nonopenbsd.go b/src/runtime/os_nonopenbsd.go index 6134b6c02f..a5775961e8 100644 --- a/src/runtime/os_nonopenbsd.go +++ b/src/runtime/os_nonopenbsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !openbsd -// +build !openbsd package runtime diff --git a/src/runtime/os_only_solaris.go b/src/runtime/os_only_solaris.go index 3829683c80..0c72500674 100644 --- a/src/runtime/os_only_solaris.go +++ b/src/runtime/os_only_solaris.go @@ -5,7 +5,6 @@ // Solaris code that doesn't also apply to illumos. //go:build !illumos -// +build !illumos package runtime diff --git a/src/runtime/os_openbsd_libc.go b/src/runtime/os_openbsd_libc.go index 981e49827f..ff21eccb4b 100644 --- a/src/runtime/os_openbsd_libc.go +++ b/src/runtime/os_openbsd_libc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build openbsd && !mips64 -// +build openbsd,!mips64 package runtime diff --git a/src/runtime/os_openbsd_syscall.go b/src/runtime/os_openbsd_syscall.go index 1ddee1864e..8128c20453 100644 --- a/src/runtime/os_openbsd_syscall.go +++ b/src/runtime/os_openbsd_syscall.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build openbsd && mips64 -// +build openbsd,mips64 package runtime diff --git a/src/runtime/os_openbsd_syscall1.go b/src/runtime/os_openbsd_syscall1.go index c20ee8300e..d32894ba6a 100644 --- a/src/runtime/os_openbsd_syscall1.go +++ b/src/runtime/os_openbsd_syscall1.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build openbsd && mips64 -// +build openbsd,mips64 package runtime diff --git a/src/runtime/os_openbsd_syscall2.go b/src/runtime/os_openbsd_syscall2.go index af1997131f..99542fb2de 100644 --- a/src/runtime/os_openbsd_syscall2.go +++ b/src/runtime/os_openbsd_syscall2.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build openbsd && mips64 -// +build openbsd,mips64 package runtime diff --git a/src/runtime/panic32.go b/src/runtime/panic32.go index acbdd1ff45..fa3f2bf2f8 100644 --- a/src/runtime/panic32.go +++ b/src/runtime/panic32.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || arm || mips || mipsle -// +build 386 arm mips mipsle package runtime diff --git a/src/runtime/pprof/mprof_test.go b/src/runtime/pprof/mprof_test.go index b4680fbdee..b44b32aed2 100644 --- a/src/runtime/pprof/mprof_test.go +++ b/src/runtime/pprof/mprof_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package pprof @@ -105,31 +104,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:48 -# 0x[0-9,a-f]+ runtime/pprof\.TestMemoryProfiler\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test\.go:83 +# 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:25 -# 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\.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:31 -# 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\.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:35 -# 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\.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:56 +# 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_norusage.go b/src/runtime/pprof/pprof_norusage.go index e175dd380c..cbc5176cfa 100644 --- a/src/runtime/pprof/pprof_norusage.go +++ b/src/runtime/pprof/pprof_norusage.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !darwin && !linux -// +build !darwin,!linux package pprof diff --git a/src/runtime/pprof/pprof_rusage.go b/src/runtime/pprof/pprof_rusage.go index 269f21bc2f..46263fedd9 100644 --- a/src/runtime/pprof/pprof_rusage.go +++ b/src/runtime/pprof/pprof_rusage.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || linux -// +build darwin linux package pprof diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index 03ff55b541..06e0274e9a 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js package pprof diff --git a/src/runtime/pprof/rusage_test.go b/src/runtime/pprof/rusage_test.go index 66b1b3bbe1..b0d651e0eb 100644 --- a/src/runtime/pprof/rusage_test.go +++ b/src/runtime/pprof/rusage_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || freebsd || linux || netbsd || openbsd -// +build darwin freebsd linux netbsd openbsd package pprof diff --git a/src/runtime/preempt_nonwindows.go b/src/runtime/preempt_nonwindows.go index 365e86a611..d6a2408cb7 100644 --- a/src/runtime/preempt_nonwindows.go +++ b/src/runtime/preempt_nonwindows.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows -// +build !windows package runtime diff --git a/src/runtime/race.go b/src/runtime/race.go index 7eaa9d2b72..e019923bb5 100644 --- a/src/runtime/race.go +++ b/src/runtime/race.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build race -// +build race package runtime diff --git a/src/runtime/race/output_test.go b/src/runtime/race/output_test.go index 63fcd847dc..46cdfcd0e9 100644 --- a/src/runtime/race/output_test.go +++ b/src/runtime/race/output_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build race -// +build race package race_test diff --git a/src/runtime/race/race.go b/src/runtime/race/race.go index 84050e8771..63fa83ff14 100644 --- a/src/runtime/race/race.go +++ b/src/runtime/race/race.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (race && linux && amd64) || (race && freebsd && amd64) || (race && netbsd && amd64) || (race && darwin && amd64) || (race && windows && amd64) || (race && linux && ppc64le) || (race && linux && arm64) || (race && darwin && arm64) || (race && openbsd && amd64) -// +build race,linux,amd64 race,freebsd,amd64 race,netbsd,amd64 race,darwin,amd64 race,windows,amd64 race,linux,ppc64le race,linux,arm64 race,darwin,arm64 race,openbsd,amd64 package race diff --git a/src/runtime/race/race_linux_test.go b/src/runtime/race/race_linux_test.go index 9c0d48d6bd..e8a2d0fd8c 100644 --- a/src/runtime/race/race_linux_test.go +++ b/src/runtime/race/race_linux_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && race -// +build linux,race package race_test diff --git a/src/runtime/race/race_test.go b/src/runtime/race/race_test.go index 8c880b8570..1677e13986 100644 --- a/src/runtime/race/race_test.go +++ b/src/runtime/race/race_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build race -// +build race // This program is used to verify the race detector // by running the tests and parsing their output. diff --git a/src/runtime/race/race_unix_test.go b/src/runtime/race/race_unix_test.go index acd6e47f98..6cc0730589 100644 --- a/src/runtime/race/race_unix_test.go +++ b/src/runtime/race/race_unix_test.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build race && (darwin || freebsd || linux) -// +build race -// +build darwin freebsd linux package race_test diff --git a/src/runtime/race/race_windows_test.go b/src/runtime/race/race_windows_test.go index e490d766dd..143b483f97 100644 --- a/src/runtime/race/race_windows_test.go +++ b/src/runtime/race/race_windows_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows && race -// +build windows,race package race_test diff --git a/src/runtime/race/sched_test.go b/src/runtime/race/sched_test.go index e904ebd20d..9fe83ea11d 100644 --- a/src/runtime/race/sched_test.go +++ b/src/runtime/race/sched_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build race -// +build race package race_test diff --git a/src/runtime/race/syso_test.go b/src/runtime/race/syso_test.go index f5095737a4..2f1a91cab1 100644 --- a/src/runtime/race/syso_test.go +++ b/src/runtime/race/syso_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build race -// +build race package race diff --git a/src/runtime/race/timer_test.go b/src/runtime/race/timer_test.go index f11f8456a0..dd59005564 100644 --- a/src/runtime/race/timer_test.go +++ b/src/runtime/race/timer_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build race -// +build race package race_test diff --git a/src/runtime/race0.go b/src/runtime/race0.go index 0e431b8103..f36d4387c7 100644 --- a/src/runtime/race0.go +++ b/src/runtime/race0.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !race -// +build !race // Dummy race detection API, used when not built with -race. diff --git a/src/runtime/relax_stub.go b/src/runtime/relax_stub.go index 5b92879c20..e507702fc1 100644 --- a/src/runtime/relax_stub.go +++ b/src/runtime/relax_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows -// +build !windows package runtime diff --git a/src/runtime/runtime_mmap_test.go b/src/runtime/runtime_mmap_test.go index f71f8afa57..9323c09355 100644 --- a/src/runtime/runtime_mmap_test.go +++ b/src/runtime/runtime_mmap_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package runtime_test diff --git a/src/runtime/runtime_unix_test.go b/src/runtime/runtime_unix_test.go index 0251c676e6..642a946280 100644 --- a/src/runtime/runtime_unix_test.go +++ b/src/runtime/runtime_unix_test.go @@ -7,7 +7,6 @@ // and Close(-1) is nearly universally fast. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || plan9 -// +build aix darwin dragonfly freebsd linux netbsd openbsd plan9 package runtime_test diff --git a/src/runtime/semasleep_test.go b/src/runtime/semasleep_test.go index 905e932b7d..cf4ef18208 100644 --- a/src/runtime/semasleep_test.go +++ b/src/runtime/semasleep_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !plan9 && !windows && !js -// +build !plan9,!windows,!js package runtime_test diff --git a/src/runtime/sigaction.go b/src/runtime/sigaction.go index 30050efcc7..05f44f65db 100644 --- a/src/runtime/sigaction.go +++ b/src/runtime/sigaction.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (linux && !amd64 && !arm64 && !ppc64le) || (freebsd && !amd64) -// +build linux,!amd64,!arm64,!ppc64le freebsd,!amd64 package runtime diff --git a/src/runtime/signal_386.go b/src/runtime/signal_386.go index 69a59e6dcf..aa66032caa 100644 --- a/src/runtime/signal_386.go +++ b/src/runtime/signal_386.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux || netbsd || openbsd -// +build dragonfly freebsd linux netbsd openbsd package runtime diff --git a/src/runtime/signal_aix_ppc64.go b/src/runtime/signal_aix_ppc64.go index 5999d9dc3d..c6cb91a0a2 100644 --- a/src/runtime/signal_aix_ppc64.go +++ b/src/runtime/signal_aix_ppc64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix -// +build aix package runtime diff --git a/src/runtime/signal_amd64.go b/src/runtime/signal_amd64.go index 20490cffbf..67a21950d7 100644 --- a/src/runtime/signal_amd64.go +++ b/src/runtime/signal_amd64.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris) -// +build amd64 -// +build darwin dragonfly freebsd linux netbsd openbsd solaris package runtime diff --git a/src/runtime/signal_arm.go b/src/runtime/signal_arm.go index a0780788f8..fff302f4d4 100644 --- a/src/runtime/signal_arm.go +++ b/src/runtime/signal_arm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux || netbsd || openbsd -// +build dragonfly freebsd linux netbsd openbsd package runtime diff --git a/src/runtime/signal_arm64.go b/src/runtime/signal_arm64.go index 9d4a8b8a99..771585a8f9 100644 --- a/src/runtime/signal_arm64.go +++ b/src/runtime/signal_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || freebsd || linux || netbsd || openbsd -// +build darwin freebsd linux netbsd openbsd package runtime diff --git a/src/runtime/signal_linux_mips64x.go b/src/runtime/signal_linux_mips64x.go index e62d6a93fd..9c2a286001 100644 --- a/src/runtime/signal_linux_mips64x.go +++ b/src/runtime/signal_linux_mips64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips64 || mips64le) -// +build linux -// +build mips64 mips64le package runtime diff --git a/src/runtime/signal_linux_mipsx.go b/src/runtime/signal_linux_mipsx.go index f3969c5aac..f11bfc9b3a 100644 --- a/src/runtime/signal_linux_mipsx.go +++ b/src/runtime/signal_linux_mipsx.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips || mipsle) -// +build linux -// +build mips mipsle package runtime diff --git a/src/runtime/signal_linux_ppc64x.go b/src/runtime/signal_linux_ppc64x.go index d2eeb39ead..31754289ec 100644 --- a/src/runtime/signal_linux_ppc64x.go +++ b/src/runtime/signal_linux_ppc64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (ppc64 || ppc64le) -// +build linux -// +build ppc64 ppc64le package runtime diff --git a/src/runtime/signal_mips64x.go b/src/runtime/signal_mips64x.go index 87dfa724c4..cee1bf7a1b 100644 --- a/src/runtime/signal_mips64x.go +++ b/src/runtime/signal_mips64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (linux || openbsd) && (mips64 || mips64le) -// +build linux openbsd -// +build mips64 mips64le package runtime diff --git a/src/runtime/signal_mipsx.go b/src/runtime/signal_mipsx.go index 5067799bd6..ba92655152 100644 --- a/src/runtime/signal_mipsx.go +++ b/src/runtime/signal_mipsx.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips || mipsle) -// +build linux -// +build mips mipsle package runtime diff --git a/src/runtime/signal_ppc64x.go b/src/runtime/signal_ppc64x.go index 8a39d59957..bdd354026c 100644 --- a/src/runtime/signal_ppc64x.go +++ b/src/runtime/signal_ppc64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (aix || linux) && (ppc64 || ppc64le) -// +build aix linux -// +build ppc64 ppc64le package runtime diff --git a/src/runtime/signal_riscv64.go b/src/runtime/signal_riscv64.go index 8a24e4e36a..5eeb227aa0 100644 --- a/src/runtime/signal_riscv64.go +++ b/src/runtime/signal_riscv64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && riscv64 -// +build linux,riscv64 package runtime diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go index 8854629224..7c454437e4 100644 --- a/src/runtime/signal_unix.go +++ b/src/runtime/signal_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package runtime diff --git a/src/runtime/signal_windows_test.go b/src/runtime/signal_windows_test.go index 1b7cb9d4c4..7c88ab573e 100644 --- a/src/runtime/signal_windows_test.go +++ b/src/runtime/signal_windows_test.go @@ -1,5 +1,4 @@ //go:build windows -// +build windows package runtime_test diff --git a/src/runtime/sigqueue.go b/src/runtime/sigqueue.go index 6c91fb3fb3..7b84a0ef65 100644 --- a/src/runtime/sigqueue.go +++ b/src/runtime/sigqueue.go @@ -29,7 +29,6 @@ // nor deadlocks. //go:build !plan9 -// +build !plan9 package runtime diff --git a/src/runtime/sigqueue_note.go b/src/runtime/sigqueue_note.go index e23446bea4..fb1a517fa5 100644 --- a/src/runtime/sigqueue_note.go +++ b/src/runtime/sigqueue_note.go @@ -8,7 +8,6 @@ // those functions. These functions will never be called. //go:build !darwin && !plan9 -// +build !darwin,!plan9 package runtime diff --git a/src/runtime/sigtab_linux_generic.go b/src/runtime/sigtab_linux_generic.go index dc1debddab..fe93bbafb5 100644 --- a/src/runtime/sigtab_linux_generic.go +++ b/src/runtime/sigtab_linux_generic.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !mips && !mipsle && !mips64 && !mips64le && linux -// +build !mips,!mipsle,!mips64,!mips64le,linux package runtime diff --git a/src/runtime/sigtab_linux_mipsx.go b/src/runtime/sigtab_linux_mipsx.go index af9c7e56eb..295ced5bbb 100644 --- a/src/runtime/sigtab_linux_mipsx.go +++ b/src/runtime/sigtab_linux_mipsx.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (mips || mipsle || mips64 || mips64le) && linux -// +build mips mipsle mips64 mips64le -// +build linux package runtime diff --git a/src/runtime/stubs2.go b/src/runtime/stubs2.go index 525b324c81..9aa965454d 100644 --- a/src/runtime/stubs2.go +++ b/src/runtime/stubs2.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !aix && !darwin && !js && !openbsd && !plan9 && !solaris && !windows -// +build !aix,!darwin,!js,!openbsd,!plan9,!solaris,!windows package runtime diff --git a/src/runtime/stubs3.go b/src/runtime/stubs3.go index b895be4c70..891663b110 100644 --- a/src/runtime/stubs3.go +++ b/src/runtime/stubs3.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !aix && !darwin && !freebsd && !openbsd && !plan9 && !solaris -// +build !aix,!darwin,!freebsd,!openbsd,!plan9,!solaris package runtime diff --git a/src/runtime/stubs_linux.go b/src/runtime/stubs_linux.go index ba267009ca..06c14e2160 100644 --- a/src/runtime/stubs_linux.go +++ b/src/runtime/stubs_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux -// +build linux package runtime diff --git a/src/runtime/stubs_mips64x.go b/src/runtime/stubs_mips64x.go index 05a4d0d38d..a9ddfc0256 100644 --- a/src/runtime/stubs_mips64x.go +++ b/src/runtime/stubs_mips64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build mips64 || mips64le -// +build mips64 mips64le package runtime diff --git a/src/runtime/stubs_mipsx.go b/src/runtime/stubs_mipsx.go index 9bffb35b67..d48f9b88e8 100644 --- a/src/runtime/stubs_mipsx.go +++ b/src/runtime/stubs_mipsx.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build mips || mipsle -// +build mips mipsle package runtime diff --git a/src/runtime/stubs_nonlinux.go b/src/runtime/stubs_nonlinux.go index f9b98595fc..1a06d7cc1d 100644 --- a/src/runtime/stubs_nonlinux.go +++ b/src/runtime/stubs_nonlinux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !linux -// +build !linux package runtime diff --git a/src/runtime/stubs_ppc64.go b/src/runtime/stubs_ppc64.go index 3895973f7c..07127629d1 100644 --- a/src/runtime/stubs_ppc64.go +++ b/src/runtime/stubs_ppc64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux -// +build linux package runtime diff --git a/src/runtime/stubs_ppc64x.go b/src/runtime/stubs_ppc64x.go index 2c647ea672..95e43a5162 100644 --- a/src/runtime/stubs_ppc64x.go +++ b/src/runtime/stubs_ppc64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64le || ppc64 -// +build ppc64le ppc64 package runtime diff --git a/src/runtime/sys_libc.go b/src/runtime/sys_libc.go index b1a9f8b536..7012b4167e 100644 --- a/src/runtime/sys_libc.go +++ b/src/runtime/sys_libc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || (openbsd && !mips64) -// +build darwin openbsd,!mips64 package runtime diff --git a/src/runtime/sys_mips64x.go b/src/runtime/sys_mips64x.go index 842a4a7084..b71538409c 100644 --- a/src/runtime/sys_mips64x.go +++ b/src/runtime/sys_mips64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build mips64 || mips64le -// +build mips64 mips64le package runtime diff --git a/src/runtime/sys_mipsx.go b/src/runtime/sys_mipsx.go index 2038eb7d79..b60135f964 100644 --- a/src/runtime/sys_mipsx.go +++ b/src/runtime/sys_mipsx.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build mips || mipsle -// +build mips mipsle package runtime diff --git a/src/runtime/sys_nonppc64x.go b/src/runtime/sys_nonppc64x.go index 66821b1f76..653f1c999f 100644 --- a/src/runtime/sys_nonppc64x.go +++ b/src/runtime/sys_nonppc64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !ppc64 && !ppc64le -// +build !ppc64,!ppc64le package runtime diff --git a/src/runtime/sys_openbsd.go b/src/runtime/sys_openbsd.go index 15888619b1..9f3a25fcf8 100644 --- a/src/runtime/sys_openbsd.go +++ b/src/runtime/sys_openbsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build openbsd && !mips64 -// +build openbsd,!mips64 package runtime diff --git a/src/runtime/sys_openbsd1.go b/src/runtime/sys_openbsd1.go index b4e9f54538..4b80f60226 100644 --- a/src/runtime/sys_openbsd1.go +++ b/src/runtime/sys_openbsd1.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build openbsd && !mips64 -// +build openbsd,!mips64 package runtime diff --git a/src/runtime/sys_openbsd2.go b/src/runtime/sys_openbsd2.go index 23e0b195fd..7024cfa86d 100644 --- a/src/runtime/sys_openbsd2.go +++ b/src/runtime/sys_openbsd2.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build openbsd && !mips64 -// +build openbsd,!mips64 package runtime diff --git a/src/runtime/sys_openbsd3.go b/src/runtime/sys_openbsd3.go index a917ebde61..269bf86f10 100644 --- a/src/runtime/sys_openbsd3.go +++ b/src/runtime/sys_openbsd3.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build openbsd && !mips64 -// +build openbsd,!mips64 package runtime diff --git a/src/runtime/sys_ppc64x.go b/src/runtime/sys_ppc64x.go index 69bd99fa09..56c5c9575e 100644 --- a/src/runtime/sys_ppc64x.go +++ b/src/runtime/sys_ppc64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64 || ppc64le -// +build ppc64 ppc64le package runtime diff --git a/src/runtime/sys_x86.go b/src/runtime/sys_x86.go index 856c73a2f6..9fb36c2a66 100644 --- a/src/runtime/sys_x86.go +++ b/src/runtime/sys_x86.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 || 386 -// +build amd64 386 package runtime diff --git a/src/runtime/time_fake.go b/src/runtime/time_fake.go index c790faba3d..107f6be335 100644 --- a/src/runtime/time_fake.go +++ b/src/runtime/time_fake.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build faketime && !windows -// +build faketime,!windows // Faketime isn't currently supported on Windows. This would require // modifying syscall.Write to call syscall.faketimeWrite, diff --git a/src/runtime/time_nofake.go b/src/runtime/time_nofake.go index 5a4ceaf43d..2b85c5aa01 100644 --- a/src/runtime/time_nofake.go +++ b/src/runtime/time_nofake.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !faketime -// +build !faketime package runtime diff --git a/src/runtime/timeasm.go b/src/runtime/timeasm.go index 468ff8a0d3..0421388686 100644 --- a/src/runtime/timeasm.go +++ b/src/runtime/timeasm.go @@ -5,8 +5,6 @@ // Declarations for operating systems implementing time.now directly in assembly. //go:build !faketime && (windows || (linux && amd64)) -// +build !faketime -// +build windows linux,amd64 package runtime diff --git a/src/runtime/timestub.go b/src/runtime/timestub.go index 6f16c70b81..1d2926b43d 100644 --- a/src/runtime/timestub.go +++ b/src/runtime/timestub.go @@ -6,9 +6,6 @@ // indirectly, in terms of walltime and nanotime assembly. //go:build !faketime && !windows && !(linux && amd64) -// +build !faketime -// +build !windows -// +build !linux !amd64 package runtime diff --git a/src/runtime/timestub2.go b/src/runtime/timestub2.go index 800a2a94e0..b9a5cc6345 100644 --- a/src/runtime/timestub2.go +++ b/src/runtime/timestub2.go @@ -3,13 +3,6 @@ // license that can be found in the LICENSE file. //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !windows && !(linux && amd64) -// +build !aix -// +build !darwin -// +build !freebsd -// +build !openbsd -// +build !solaris -// +build !windows -// +build !linux !amd64 package runtime diff --git a/src/runtime/tls_stub.go b/src/runtime/tls_stub.go index 95dafd007c..7bdfc6b89a 100644 --- a/src/runtime/tls_stub.go +++ b/src/runtime/tls_stub.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (windows && !amd64) || !windows -// +build windows,!amd64 !windows package runtime diff --git a/src/runtime/vdso_elf32.go b/src/runtime/vdso_elf32.go index 456173b0f5..1b8afbedf4 100644 --- a/src/runtime/vdso_elf32.go +++ b/src/runtime/vdso_elf32.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (386 || arm) -// +build linux -// +build 386 arm package runtime diff --git a/src/runtime/vdso_elf64.go b/src/runtime/vdso_elf64.go index aecc84dcfe..d46d6f8c34 100644 --- a/src/runtime/vdso_elf64.go +++ b/src/runtime/vdso_elf64.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (amd64 || arm64 || mips64 || mips64le || ppc64 || ppc64le || riscv64) -// +build linux -// +build amd64 arm64 mips64 mips64le ppc64 ppc64le riscv64 package runtime diff --git a/src/runtime/vdso_freebsd.go b/src/runtime/vdso_freebsd.go index 7ca7b2810b..0fe21cf647 100644 --- a/src/runtime/vdso_freebsd.go +++ b/src/runtime/vdso_freebsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build freebsd -// +build freebsd package runtime diff --git a/src/runtime/vdso_freebsd_x86.go b/src/runtime/vdso_freebsd_x86.go index 23a5a8c322..5324a3d4cb 100644 --- a/src/runtime/vdso_freebsd_x86.go +++ b/src/runtime/vdso_freebsd_x86.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build freebsd && (386 || amd64) -// +build freebsd -// +build 386 amd64 package runtime diff --git a/src/runtime/vdso_in_none.go b/src/runtime/vdso_in_none.go index 3e98b08b15..618bd39b42 100644 --- a/src/runtime/vdso_in_none.go +++ b/src/runtime/vdso_in_none.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (linux && !386 && !amd64 && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !riscv64) || !linux -// +build linux,!386,!amd64,!arm,!arm64,!mips64,!mips64le,!ppc64,!ppc64le,!riscv64 !linux package runtime diff --git a/src/runtime/vdso_linux.go b/src/runtime/vdso_linux.go index 20c8db78be..cff2000767 100644 --- a/src/runtime/vdso_linux.go +++ b/src/runtime/vdso_linux.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (386 || amd64 || arm || arm64 || mips64 || mips64le || ppc64 || ppc64le || riscv64) -// +build linux -// +build 386 amd64 arm arm64 mips64 mips64le ppc64 ppc64le riscv64 package runtime diff --git a/src/runtime/vdso_linux_mips64x.go b/src/runtime/vdso_linux_mips64x.go index 395ddbba69..1444f8e524 100644 --- a/src/runtime/vdso_linux_mips64x.go +++ b/src/runtime/vdso_linux_mips64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips64 || mips64le) -// +build linux -// +build mips64 mips64le package runtime diff --git a/src/runtime/vdso_linux_ppc64x.go b/src/runtime/vdso_linux_ppc64x.go index b741dbfcdc..09c8d9d20e 100644 --- a/src/runtime/vdso_linux_ppc64x.go +++ b/src/runtime/vdso_linux_ppc64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (ppc64 || ppc64le) -// +build linux -// +build ppc64 ppc64le package runtime diff --git a/src/runtime/vlrt.go b/src/runtime/vlrt.go index 927b585a92..1dcb125aef 100644 --- a/src/runtime/vlrt.go +++ b/src/runtime/vlrt.go @@ -24,7 +24,6 @@ // THE SOFTWARE. //go:build arm || 386 || mips || mipsle -// +build arm 386 mips mipsle package runtime diff --git a/src/runtime/wincallback.go b/src/runtime/wincallback.go index 73f1e567ce..ca9965979f 100644 --- a/src/runtime/wincallback.go +++ b/src/runtime/wincallback.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // Generate Windows callback assembly file. diff --git a/src/runtime/write_err.go b/src/runtime/write_err.go index a4656fd728..81ae872e9c 100644 --- a/src/runtime/write_err.go +++ b/src/runtime/write_err.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !android -// +build !android package runtime diff --git a/src/sync/pool_test.go b/src/sync/pool_test.go index 65666daab4..f94153c8d7 100644 --- a/src/sync/pool_test.go +++ b/src/sync/pool_test.go @@ -4,7 +4,6 @@ // Pool is no-op under race detector, so all these tests do not work. //go:build !race -// +build !race package sync_test diff --git a/src/sync/runtime2.go b/src/sync/runtime2.go index c4b44893f0..9b7e9922fb 100644 --- a/src/sync/runtime2.go +++ b/src/sync/runtime2.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !goexperiment.staticlockranking -// +build !goexperiment.staticlockranking package sync diff --git a/src/sync/runtime2_lockrank.go b/src/sync/runtime2_lockrank.go index e91fdb6c1f..cdb1af41c6 100644 --- a/src/sync/runtime2_lockrank.go +++ b/src/sync/runtime2_lockrank.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build goexperiment.staticlockranking -// +build goexperiment.staticlockranking package sync diff --git a/src/syscall/bpf_bsd.go b/src/syscall/bpf_bsd.go index 452d4cf14b..735c078895 100644 --- a/src/syscall/bpf_bsd.go +++ b/src/syscall/bpf_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || netbsd || openbsd -// +build dragonfly freebsd netbsd openbsd // Berkeley packet filter for BSD variants diff --git a/src/syscall/creds_test.go b/src/syscall/creds_test.go index c1a8b516e8..1ee56fc340 100644 --- a/src/syscall/creds_test.go +++ b/src/syscall/creds_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux -// +build linux package syscall_test diff --git a/src/syscall/dirent.go b/src/syscall/dirent.go index 9e1222e81c..237ea79ad6 100644 --- a/src/syscall/dirent.go +++ b/src/syscall/dirent.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package syscall diff --git a/src/syscall/dirent_test.go b/src/syscall/dirent_test.go index 71b445ba9b..6570bf9217 100644 --- a/src/syscall/dirent_test.go +++ b/src/syscall/dirent_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package syscall_test diff --git a/src/syscall/endian_big.go b/src/syscall/endian_big.go index dc0947fa6e..8e3874eb86 100644 --- a/src/syscall/endian_big.go +++ b/src/syscall/endian_big.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // //go:build ppc64 || s390x || mips || mips64 -// +build ppc64 s390x mips mips64 package syscall diff --git a/src/syscall/endian_little.go b/src/syscall/endian_little.go index a894445f73..edfb6cf164 100644 --- a/src/syscall/endian_little.go +++ b/src/syscall/endian_little.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // //go:build 386 || amd64 || arm || arm64 || ppc64le || mips64le || mipsle || riscv64 || wasm -// +build 386 amd64 arm arm64 ppc64le mips64le mipsle riscv64 wasm package syscall diff --git a/src/syscall/env_unix.go b/src/syscall/env_unix.go index 022ef6ed73..521967c79f 100644 --- a/src/syscall/env_unix.go +++ b/src/syscall/env_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || plan9 -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris plan9 // Unix environment variables. diff --git a/src/syscall/exec_aix_test.go b/src/syscall/exec_aix_test.go index 17c7ac0664..f2d54a40bd 100644 --- a/src/syscall/exec_aix_test.go +++ b/src/syscall/exec_aix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix -// +build aix package syscall diff --git a/src/syscall/exec_bsd.go b/src/syscall/exec_bsd.go index d2e50e3dd3..148f5a91aa 100644 --- a/src/syscall/exec_bsd.go +++ b/src/syscall/exec_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || netbsd || (openbsd && mips64) -// +build dragonfly netbsd openbsd,mips64 package syscall diff --git a/src/syscall/exec_libc.go b/src/syscall/exec_libc.go index b14abd4e63..c8549c4964 100644 --- a/src/syscall/exec_libc.go +++ b/src/syscall/exec_libc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || solaris -// +build aix solaris // This file handles forkAndExecInChild function for OS using libc syscall like AIX or Solaris. diff --git a/src/syscall/exec_libc2.go b/src/syscall/exec_libc2.go index bd98109d07..b05f053bbf 100644 --- a/src/syscall/exec_libc2.go +++ b/src/syscall/exec_libc2.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || (openbsd && !mips64) -// +build darwin openbsd,!mips64 package syscall diff --git a/src/syscall/exec_linux.go b/src/syscall/exec_linux.go index e1506e1e2b..0f0dee8ea5 100644 --- a/src/syscall/exec_linux.go +++ b/src/syscall/exec_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux -// +build linux package syscall diff --git a/src/syscall/exec_linux_test.go b/src/syscall/exec_linux_test.go index 79b2633aca..80440ca4d6 100644 --- a/src/syscall/exec_linux_test.go +++ b/src/syscall/exec_linux_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux -// +build linux package syscall_test diff --git a/src/syscall/exec_pdeathsig_test.go b/src/syscall/exec_pdeathsig_test.go index 6533d3a138..96ae27b494 100644 --- a/src/syscall/exec_pdeathsig_test.go +++ b/src/syscall/exec_pdeathsig_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build freebsd || linux -// +build freebsd linux package syscall_test diff --git a/src/syscall/exec_solaris_test.go b/src/syscall/exec_solaris_test.go index f54fc8385d..90e5349bf4 100644 --- a/src/syscall/exec_solaris_test.go +++ b/src/syscall/exec_solaris_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build solaris -// +build solaris package syscall diff --git a/src/syscall/exec_unix.go b/src/syscall/exec_unix.go index 54b18dccd7..64eb5ed9f0 100644 --- a/src/syscall/exec_unix.go +++ b/src/syscall/exec_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris // Fork, exec, wait, etc. diff --git a/src/syscall/exec_unix_test.go b/src/syscall/exec_unix_test.go index 866671ba2a..55f5f7025a 100644 --- a/src/syscall/exec_unix_test.go +++ b/src/syscall/exec_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package syscall_test diff --git a/src/syscall/export_unix_test.go b/src/syscall/export_unix_test.go index 2d2c67673d..2f678d2566 100644 --- a/src/syscall/export_unix_test.go +++ b/src/syscall/export_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux || netbsd || openbsd -// +build dragonfly freebsd linux netbsd openbsd package syscall diff --git a/src/syscall/flock.go b/src/syscall/flock.go index 3b43b6aede..8cb8f16153 100644 --- a/src/syscall/flock.go +++ b/src/syscall/flock.go @@ -1,5 +1,4 @@ //go:build linux || freebsd || openbsd || netbsd || dragonfly -// +build linux freebsd openbsd netbsd dragonfly // Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/syscall/flock_linux_32bit.go b/src/syscall/flock_linux_32bit.go index 2f3277497c..76a09fc47e 100644 --- a/src/syscall/flock_linux_32bit.go +++ b/src/syscall/flock_linux_32bit.go @@ -6,7 +6,6 @@ // internal/syscall/unix/fcntl_linux_32bit.go. //go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) -// +build linux,386 linux,arm linux,mips linux,mipsle package syscall diff --git a/src/syscall/forkpipe.go b/src/syscall/forkpipe.go index 79cbdf4150..6f7d29ce67 100644 --- a/src/syscall/forkpipe.go +++ b/src/syscall/forkpipe.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || solaris -// +build aix darwin solaris package syscall diff --git a/src/syscall/forkpipe2.go b/src/syscall/forkpipe2.go index e57240c156..312244c0d8 100644 --- a/src/syscall/forkpipe2.go +++ b/src/syscall/forkpipe2.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || netbsd || openbsd -// +build dragonfly freebsd netbsd openbsd package syscall diff --git a/src/syscall/fs_js.go b/src/syscall/fs_js.go index 0170516201..84a554e8b9 100644 --- a/src/syscall/fs_js.go +++ b/src/syscall/fs_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package syscall diff --git a/src/syscall/getdirentries_test.go b/src/syscall/getdirentries_test.go index 814e656649..ddd8208c15 100644 --- a/src/syscall/getdirentries_test.go +++ b/src/syscall/getdirentries_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || freebsd || netbsd || openbsd -// +build darwin freebsd netbsd openbsd package syscall_test diff --git a/src/syscall/mkasm.go b/src/syscall/mkasm.go index e0ec46681d..dce61f322c 100644 --- a/src/syscall/mkasm.go +++ b/src/syscall/mkasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // mkasm.go generates assembly trampolines to call library routines from Go. // This program must be run after mksyscall.pl. diff --git a/src/syscall/mkpost.go b/src/syscall/mkpost.go index 94e8d92eff..4f81b81b57 100644 --- a/src/syscall/mkpost.go +++ b/src/syscall/mkpost.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // mkpost processes the output of cgo -godefs to // modify the generated types. It is used to clean up diff --git a/src/syscall/mksyscall_windows.go b/src/syscall/mksyscall_windows.go index d8e8a713c5..39517bc7f1 100644 --- a/src/syscall/mksyscall_windows.go +++ b/src/syscall/mksyscall_windows.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // mksyscall_windows wraps golang.org/x/sys/windows/mkwinsyscall. package main diff --git a/src/syscall/mmap_unix_test.go b/src/syscall/mmap_unix_test.go index e3909f1afb..3e9c08d67d 100644 --- a/src/syscall/mmap_unix_test.go +++ b/src/syscall/mmap_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build aix darwin dragonfly freebsd linux netbsd openbsd package syscall_test diff --git a/src/syscall/msan.go b/src/syscall/msan.go index 89fb75f03c..89c580799f 100644 --- a/src/syscall/msan.go +++ b/src/syscall/msan.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build msan -// +build msan package syscall diff --git a/src/syscall/msan0.go b/src/syscall/msan0.go index 85097025a0..fba8a5f716 100644 --- a/src/syscall/msan0.go +++ b/src/syscall/msan0.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !msan -// +build !msan package syscall diff --git a/src/syscall/net_js.go b/src/syscall/net_js.go index 2998c2159c..4f8258ddb3 100644 --- a/src/syscall/net_js.go +++ b/src/syscall/net_js.go @@ -6,7 +6,6 @@ // This file only exists to make the compiler happy. //go:build js && wasm -// +build js,wasm package syscall diff --git a/src/syscall/ptrace_darwin.go b/src/syscall/ptrace_darwin.go index b968c7c7f3..519e451c73 100644 --- a/src/syscall/ptrace_darwin.go +++ b/src/syscall/ptrace_darwin.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !ios -// +build !ios package syscall diff --git a/src/syscall/ptrace_ios.go b/src/syscall/ptrace_ios.go index 5209d1e0dd..fa8d000715 100644 --- a/src/syscall/ptrace_ios.go +++ b/src/syscall/ptrace_ios.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ios -// +build ios package syscall diff --git a/src/syscall/route_bsd.go b/src/syscall/route_bsd.go index e9321a4e64..8e47ff888e 100644 --- a/src/syscall/route_bsd.go +++ b/src/syscall/route_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd package syscall diff --git a/src/syscall/route_freebsd_32bit.go b/src/syscall/route_freebsd_32bit.go index 412833a37c..c70f0bb0d3 100644 --- a/src/syscall/route_freebsd_32bit.go +++ b/src/syscall/route_freebsd_32bit.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (freebsd && 386) || (freebsd && arm) -// +build freebsd,386 freebsd,arm package syscall diff --git a/src/syscall/route_freebsd_64bit.go b/src/syscall/route_freebsd_64bit.go index 5300bed471..9febdfaf35 100644 --- a/src/syscall/route_freebsd_64bit.go +++ b/src/syscall/route_freebsd_64bit.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (freebsd && amd64) || (freebsd && arm64) -// +build freebsd,amd64 freebsd,arm64 package syscall diff --git a/src/syscall/setuidgid_32_linux.go b/src/syscall/setuidgid_32_linux.go index 64897fe43c..6920f33987 100644 --- a/src/syscall/setuidgid_32_linux.go +++ b/src/syscall/setuidgid_32_linux.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (386 || arm) -// +build linux -// +build 386 arm package syscall diff --git a/src/syscall/setuidgid_linux.go b/src/syscall/setuidgid_linux.go index 3b36f66fa2..c995d258eb 100644 --- a/src/syscall/setuidgid_linux.go +++ b/src/syscall/setuidgid_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && !386 && !arm -// +build linux,!386,!arm package syscall diff --git a/src/syscall/sockcmsg_unix.go b/src/syscall/sockcmsg_unix.go index 99913b9a88..a3dcf818da 100644 --- a/src/syscall/sockcmsg_unix.go +++ b/src/syscall/sockcmsg_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris // Socket control messages diff --git a/src/syscall/sockcmsg_unix_other.go b/src/syscall/sockcmsg_unix_other.go index bd8dcfa34c..845bd9df99 100644 --- a/src/syscall/sockcmsg_unix_other.go +++ b/src/syscall/sockcmsg_unix_other.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin freebsd linux netbsd openbsd solaris package syscall diff --git a/src/syscall/syscall_bsd.go b/src/syscall/syscall_bsd.go index 40b1c07a90..ebe99ff230 100644 --- a/src/syscall/syscall_bsd.go +++ b/src/syscall/syscall_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd // BSD system call wrappers shared by *BSD based systems // including OS X (Darwin) and FreeBSD. Like the other diff --git a/src/syscall/syscall_bsd_test.go b/src/syscall/syscall_bsd_test.go index 2d8a8cbfe6..98fab1d396 100644 --- a/src/syscall/syscall_bsd_test.go +++ b/src/syscall/syscall_bsd_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || openbsd -// +build darwin dragonfly freebsd openbsd package syscall_test diff --git a/src/syscall/syscall_freebsd_test.go b/src/syscall/syscall_freebsd_test.go index 72cd133b85..f04b12b6d3 100644 --- a/src/syscall/syscall_freebsd_test.go +++ b/src/syscall/syscall_freebsd_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build freebsd -// +build freebsd package syscall_test diff --git a/src/syscall/syscall_illumos.go b/src/syscall/syscall_illumos.go index ef95fe58f7..de6b160048 100644 --- a/src/syscall/syscall_illumos.go +++ b/src/syscall/syscall_illumos.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build illumos -// +build illumos // Illumos system calls not present on Solaris. diff --git a/src/syscall/syscall_js.go b/src/syscall/syscall_js.go index ed70d62284..cd95499063 100644 --- a/src/syscall/syscall_js.go +++ b/src/syscall/syscall_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package syscall diff --git a/src/syscall/syscall_linux_mips64x.go b/src/syscall/syscall_linux_mips64x.go index fa0d2799ed..7c9dd80614 100644 --- a/src/syscall/syscall_linux_mips64x.go +++ b/src/syscall/syscall_linux_mips64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips64 || mips64le) -// +build linux -// +build mips64 mips64le package syscall diff --git a/src/syscall/syscall_linux_mipsx.go b/src/syscall/syscall_linux_mipsx.go index 568523eb27..741eeb14bb 100644 --- a/src/syscall/syscall_linux_mipsx.go +++ b/src/syscall/syscall_linux_mipsx.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips || mipsle) -// +build linux -// +build mips mipsle package syscall diff --git a/src/syscall/syscall_linux_ppc64x.go b/src/syscall/syscall_linux_ppc64x.go index 3e73f6f2a4..cc1b72e0e7 100644 --- a/src/syscall/syscall_linux_ppc64x.go +++ b/src/syscall/syscall_linux_ppc64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (ppc64 || ppc64le) -// +build linux -// +build ppc64 ppc64le package syscall diff --git a/src/syscall/syscall_openbsd1.go b/src/syscall/syscall_openbsd1.go index 15870ce1ee..bddeda637a 100644 --- a/src/syscall/syscall_openbsd1.go +++ b/src/syscall/syscall_openbsd1.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build openbsd && mips64 -// +build openbsd,mips64 package syscall diff --git a/src/syscall/syscall_openbsd_libc.go b/src/syscall/syscall_openbsd_libc.go index e67ee4e571..15b68fd0fc 100644 --- a/src/syscall/syscall_openbsd_libc.go +++ b/src/syscall/syscall_openbsd_libc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build openbsd && !mips64 -// +build openbsd,!mips64 package syscall diff --git a/src/syscall/syscall_ptrace_test.go b/src/syscall/syscall_ptrace_test.go index 45729d9e8e..5b128de779 100644 --- a/src/syscall/syscall_ptrace_test.go +++ b/src/syscall/syscall_ptrace_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package syscall_test diff --git a/src/syscall/syscall_unix.go b/src/syscall/syscall_unix.go index 101e39c7d0..9413db3832 100644 --- a/src/syscall/syscall_unix.go +++ b/src/syscall/syscall_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package syscall diff --git a/src/syscall/syscall_unix_test.go b/src/syscall/syscall_unix_test.go index af0bc856ee..7cc78c2147 100644 --- a/src/syscall/syscall_unix_test.go +++ b/src/syscall/syscall_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package syscall_test diff --git a/src/syscall/tables_js.go b/src/syscall/tables_js.go index 64d958415d..78a1e71a01 100644 --- a/src/syscall/tables_js.go +++ b/src/syscall/tables_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package syscall diff --git a/src/syscall/time_fake.go b/src/syscall/time_fake.go index cf88aeb921..b60fe60b03 100644 --- a/src/syscall/time_fake.go +++ b/src/syscall/time_fake.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build faketime -// +build faketime package syscall diff --git a/src/syscall/time_nofake.go b/src/syscall/time_nofake.go index 5eaa2daabd..231875d8c3 100644 --- a/src/syscall/time_nofake.go +++ b/src/syscall/time_nofake.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !faketime -// +build !faketime package syscall diff --git a/src/syscall/timestruct.go b/src/syscall/timestruct.go index e4f3d50f56..7cf4be45b1 100644 --- a/src/syscall/timestruct.go +++ b/src/syscall/timestruct.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package syscall diff --git a/src/syscall/types_aix.go b/src/syscall/types_aix.go index 6588d690ea..9e05af90ee 100644 --- a/src/syscall/types_aix.go +++ b/src/syscall/types_aix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo -godefs. See also mkerrors.sh and mkall.sh diff --git a/src/syscall/types_darwin.go b/src/syscall/types_darwin.go index c2a32c0782..c9404aaf1b 100644 --- a/src/syscall/types_darwin.go +++ b/src/syscall/types_darwin.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo -godefs. See also mkerrors.sh and mkall.sh diff --git a/src/syscall/types_dragonfly.go b/src/syscall/types_dragonfly.go index 9f8d5bc3dd..33420c4a92 100644 --- a/src/syscall/types_dragonfly.go +++ b/src/syscall/types_dragonfly.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo -godefs. See also mkerrors.sh and mkall.sh diff --git a/src/syscall/types_freebsd.go b/src/syscall/types_freebsd.go index d741411703..83bc7dc499 100644 --- a/src/syscall/types_freebsd.go +++ b/src/syscall/types_freebsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo -godefs. See also mkerrors.sh and mkall.sh diff --git a/src/syscall/types_illumos_amd64.go b/src/syscall/types_illumos_amd64.go index 254e3e7cfe..22c172f1f7 100644 --- a/src/syscall/types_illumos_amd64.go +++ b/src/syscall/types_illumos_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build illumos -// +build illumos // Illumos consts not present on Solaris. These are added manually rather than // auto-generated by mkerror.sh diff --git a/src/syscall/types_linux.go b/src/syscall/types_linux.go index bf76be978b..23a76edd90 100644 --- a/src/syscall/types_linux.go +++ b/src/syscall/types_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo -godefs. See also mkerrors.sh and mkall.sh diff --git a/src/syscall/types_netbsd.go b/src/syscall/types_netbsd.go index 0bd25ea3c9..e53e8c9386 100644 --- a/src/syscall/types_netbsd.go +++ b/src/syscall/types_netbsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo -godefs. See also mkerrors.sh and mkall.sh diff --git a/src/syscall/types_openbsd.go b/src/syscall/types_openbsd.go index 8b41cdca23..bfe6e9f592 100644 --- a/src/syscall/types_openbsd.go +++ b/src/syscall/types_openbsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo -godefs. See also mkerrors.sh and mkall.sh diff --git a/src/syscall/types_solaris.go b/src/syscall/types_solaris.go index 179f791481..2f56bc0601 100644 --- a/src/syscall/types_solaris.go +++ b/src/syscall/types_solaris.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore /* Input to cgo -godefs. See also mkerrors.sh and mkall.sh diff --git a/src/syscall/zerrors_darwin_amd64.go b/src/syscall/zerrors_darwin_amd64.go index 0b9897284c..ecbe89c547 100644 --- a/src/syscall/zerrors_darwin_amd64.go +++ b/src/syscall/zerrors_darwin_amd64.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m64 _const.go //go:build amd64 && darwin -// +build amd64,darwin package syscall diff --git a/src/syscall/zerrors_darwin_arm64.go b/src/syscall/zerrors_darwin_arm64.go index 5f210fd1c4..fa7cb845c3 100644 --- a/src/syscall/zerrors_darwin_arm64.go +++ b/src/syscall/zerrors_darwin_arm64.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m64 _const.go //go:build arm64 && darwin -// +build arm64,darwin package syscall diff --git a/src/syscall/zerrors_dragonfly_amd64.go b/src/syscall/zerrors_dragonfly_amd64.go index 35e2a52d25..bca2f50c96 100644 --- a/src/syscall/zerrors_dragonfly_amd64.go +++ b/src/syscall/zerrors_dragonfly_amd64.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m64 _const.go //go:build amd64 && dragonfly -// +build amd64,dragonfly package syscall diff --git a/src/syscall/zerrors_freebsd_386.go b/src/syscall/zerrors_freebsd_386.go index aec26ad778..b1441e76a3 100644 --- a/src/syscall/zerrors_freebsd_386.go +++ b/src/syscall/zerrors_freebsd_386.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m32 _const.go //go:build 386 && freebsd -// +build 386,freebsd package syscall diff --git a/src/syscall/zerrors_freebsd_amd64.go b/src/syscall/zerrors_freebsd_amd64.go index d6d13e4155..3aed004986 100644 --- a/src/syscall/zerrors_freebsd_amd64.go +++ b/src/syscall/zerrors_freebsd_amd64.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m64 _const.go //go:build amd64 && freebsd -// +build amd64,freebsd package syscall diff --git a/src/syscall/zerrors_freebsd_arm.go b/src/syscall/zerrors_freebsd_arm.go index 15c714fad8..e1f91ff86c 100644 --- a/src/syscall/zerrors_freebsd_arm.go +++ b/src/syscall/zerrors_freebsd_arm.go @@ -5,7 +5,6 @@ // cgo -godefs -- _const.go //go:build arm && freebsd -// +build arm,freebsd package syscall diff --git a/src/syscall/zerrors_freebsd_arm64.go b/src/syscall/zerrors_freebsd_arm64.go index b20ce7d823..d0cb6c8ac7 100644 --- a/src/syscall/zerrors_freebsd_arm64.go +++ b/src/syscall/zerrors_freebsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build freebsd && arm64 -// +build freebsd,arm64 // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/src/syscall/zerrors_linux_386.go b/src/syscall/zerrors_linux_386.go index fb64932ad6..5e4c867bc9 100644 --- a/src/syscall/zerrors_linux_386.go +++ b/src/syscall/zerrors_linux_386.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m32 _const.go //go:build 386 && linux -// +build 386,linux package syscall diff --git a/src/syscall/zerrors_linux_amd64.go b/src/syscall/zerrors_linux_amd64.go index 3a92bcdbb4..3ff6e498e7 100644 --- a/src/syscall/zerrors_linux_amd64.go +++ b/src/syscall/zerrors_linux_amd64.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m64 _const.go //go:build amd64 && linux -// +build amd64,linux package syscall diff --git a/src/syscall/zerrors_linux_arm.go b/src/syscall/zerrors_linux_arm.go index e013d8e7fd..35825cc9fb 100644 --- a/src/syscall/zerrors_linux_arm.go +++ b/src/syscall/zerrors_linux_arm.go @@ -5,7 +5,6 @@ // cgo -godefs -- _const.go //go:build arm && linux -// +build arm,linux package syscall diff --git a/src/syscall/zerrors_linux_arm64.go b/src/syscall/zerrors_linux_arm64.go index 1a4d33e3fd..444b8816d5 100644 --- a/src/syscall/zerrors_linux_arm64.go +++ b/src/syscall/zerrors_linux_arm64.go @@ -5,7 +5,6 @@ // cgo -godefs -- _const.go //go:build arm64 && linux -// +build arm64,linux package syscall diff --git a/src/syscall/zerrors_linux_ppc64.go b/src/syscall/zerrors_linux_ppc64.go index 1dda43be70..dd439acc58 100644 --- a/src/syscall/zerrors_linux_ppc64.go +++ b/src/syscall/zerrors_linux_ppc64.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m64 _const.go //go:build ppc64 && linux -// +build ppc64,linux package syscall diff --git a/src/syscall/zerrors_linux_ppc64le.go b/src/syscall/zerrors_linux_ppc64le.go index 6d56f1c998..b71cb0b4e7 100644 --- a/src/syscall/zerrors_linux_ppc64le.go +++ b/src/syscall/zerrors_linux_ppc64le.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m64 _const.go //go:build ppc64le && linux -// +build ppc64le,linux package syscall diff --git a/src/syscall/zerrors_netbsd_386.go b/src/syscall/zerrors_netbsd_386.go index 934e9ef073..b2fcb65782 100644 --- a/src/syscall/zerrors_netbsd_386.go +++ b/src/syscall/zerrors_netbsd_386.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m32 _const.go //go:build 386 && netbsd -// +build 386,netbsd package syscall diff --git a/src/syscall/zerrors_netbsd_amd64.go b/src/syscall/zerrors_netbsd_amd64.go index 0f5ad61a9f..dc52c3ca57 100644 --- a/src/syscall/zerrors_netbsd_amd64.go +++ b/src/syscall/zerrors_netbsd_amd64.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m64 _const.go //go:build amd64 && netbsd -// +build amd64,netbsd package syscall diff --git a/src/syscall/zerrors_netbsd_arm.go b/src/syscall/zerrors_netbsd_arm.go index 9d8678750d..3137e18a24 100644 --- a/src/syscall/zerrors_netbsd_arm.go +++ b/src/syscall/zerrors_netbsd_arm.go @@ -5,7 +5,6 @@ // cgo -godefs -- -marm _const.go //go:build arm && netbsd -// +build arm,netbsd package syscall diff --git a/src/syscall/zerrors_netbsd_arm64.go b/src/syscall/zerrors_netbsd_arm64.go index 7adb72f7ed..cc1b0088c9 100644 --- a/src/syscall/zerrors_netbsd_arm64.go +++ b/src/syscall/zerrors_netbsd_arm64.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m64 _const.go //go:build arm64 && netbsd -// +build arm64,netbsd package syscall diff --git a/src/syscall/zerrors_openbsd_386.go b/src/syscall/zerrors_openbsd_386.go index a8457c6edf..d17ecb96e5 100644 --- a/src/syscall/zerrors_openbsd_386.go +++ b/src/syscall/zerrors_openbsd_386.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m32 _const.go //go:build 386 && openbsd -// +build 386,openbsd package syscall diff --git a/src/syscall/zerrors_openbsd_amd64.go b/src/syscall/zerrors_openbsd_amd64.go index eb19537a2a..4904e7614f 100644 --- a/src/syscall/zerrors_openbsd_amd64.go +++ b/src/syscall/zerrors_openbsd_amd64.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m64 _const.go //go:build amd64 && openbsd -// +build amd64,openbsd package syscall diff --git a/src/syscall/zerrors_openbsd_arm.go b/src/syscall/zerrors_openbsd_arm.go index 89a4e6d89a..76ac9173a9 100644 --- a/src/syscall/zerrors_openbsd_arm.go +++ b/src/syscall/zerrors_openbsd_arm.go @@ -5,7 +5,6 @@ // cgo -godefs -- _const.go //go:build arm && openbsd -// +build arm,openbsd package syscall diff --git a/src/syscall/zerrors_solaris_amd64.go b/src/syscall/zerrors_solaris_amd64.go index b7dee69602..fb25dacee4 100644 --- a/src/syscall/zerrors_solaris_amd64.go +++ b/src/syscall/zerrors_solaris_amd64.go @@ -5,7 +5,6 @@ // cgo -godefs -- -m64 _const.go //go:build amd64 && solaris -// +build amd64,solaris package syscall diff --git a/src/syscall/zsyscall_aix_ppc64.go b/src/syscall/zsyscall_aix_ppc64.go index 134ae41165..94f1b4371c 100644 --- a/src/syscall/zsyscall_aix_ppc64.go +++ b/src/syscall/zsyscall_aix_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build aix && ppc64 -// +build aix,ppc64 package syscall diff --git a/src/syscall/zsyscall_darwin_amd64.go b/src/syscall/zsyscall_darwin_amd64.go index ff88fef74e..0ccdaf2d0e 100644 --- a/src/syscall/zsyscall_darwin_amd64.go +++ b/src/syscall/zsyscall_darwin_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build darwin && amd64 -// +build darwin,amd64 package syscall diff --git a/src/syscall/zsyscall_darwin_arm64.go b/src/syscall/zsyscall_darwin_arm64.go index b096b5e662..09bf34bb3c 100644 --- a/src/syscall/zsyscall_darwin_arm64.go +++ b/src/syscall/zsyscall_darwin_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build darwin && arm64 -// +build darwin,arm64 package syscall diff --git a/src/syscall/zsyscall_dragonfly_amd64.go b/src/syscall/zsyscall_dragonfly_amd64.go index aa327c0010..5d5576d76f 100644 --- a/src/syscall/zsyscall_dragonfly_amd64.go +++ b/src/syscall/zsyscall_dragonfly_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build dragonfly && amd64 -// +build dragonfly,amd64 package syscall diff --git a/src/syscall/zsyscall_freebsd_386.go b/src/syscall/zsyscall_freebsd_386.go index 7137d66f0b..ed0eb9fa15 100644 --- a/src/syscall/zsyscall_freebsd_386.go +++ b/src/syscall/zsyscall_freebsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build freebsd && 386 -// +build freebsd,386 package syscall diff --git a/src/syscall/zsyscall_freebsd_amd64.go b/src/syscall/zsyscall_freebsd_amd64.go index d721dafde2..e291a56756 100644 --- a/src/syscall/zsyscall_freebsd_amd64.go +++ b/src/syscall/zsyscall_freebsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build freebsd && amd64 -// +build freebsd,amd64 package syscall diff --git a/src/syscall/zsyscall_freebsd_arm.go b/src/syscall/zsyscall_freebsd_arm.go index d9dbea921a..7dd856fd97 100644 --- a/src/syscall/zsyscall_freebsd_arm.go +++ b/src/syscall/zsyscall_freebsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build freebsd && arm -// +build freebsd,arm package syscall diff --git a/src/syscall/zsyscall_freebsd_arm64.go b/src/syscall/zsyscall_freebsd_arm64.go index a24f0115e2..229a9a2238 100644 --- a/src/syscall/zsyscall_freebsd_arm64.go +++ b/src/syscall/zsyscall_freebsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build freebsd && arm64 -// +build freebsd,arm64 package syscall diff --git a/src/syscall/zsyscall_linux_386.go b/src/syscall/zsyscall_linux_386.go index a1394d32cb..c385dd3ca1 100644 --- a/src/syscall/zsyscall_linux_386.go +++ b/src/syscall/zsyscall_linux_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build linux && 386 -// +build linux,386 package syscall diff --git a/src/syscall/zsyscall_linux_amd64.go b/src/syscall/zsyscall_linux_amd64.go index de6047d11c..2059271324 100644 --- a/src/syscall/zsyscall_linux_amd64.go +++ b/src/syscall/zsyscall_linux_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build linux && amd64 -// +build linux,amd64 package syscall diff --git a/src/syscall/zsyscall_linux_arm.go b/src/syscall/zsyscall_linux_arm.go index 3663b2eead..50498c6eb6 100644 --- a/src/syscall/zsyscall_linux_arm.go +++ b/src/syscall/zsyscall_linux_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build linux && arm -// +build linux,arm package syscall diff --git a/src/syscall/zsyscall_linux_arm64.go b/src/syscall/zsyscall_linux_arm64.go index 19a9c0ca61..6714123f9c 100644 --- a/src/syscall/zsyscall_linux_arm64.go +++ b/src/syscall/zsyscall_linux_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build linux && arm64 -// +build linux,arm64 package syscall diff --git a/src/syscall/zsyscall_linux_mips.go b/src/syscall/zsyscall_linux_mips.go index 966b2e1f2c..c6f4878ff7 100644 --- a/src/syscall/zsyscall_linux_mips.go +++ b/src/syscall/zsyscall_linux_mips.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build linux && mips -// +build linux,mips package syscall diff --git a/src/syscall/zsyscall_linux_mips64.go b/src/syscall/zsyscall_linux_mips64.go index c6812a0515..5187c28ebb 100644 --- a/src/syscall/zsyscall_linux_mips64.go +++ b/src/syscall/zsyscall_linux_mips64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build linux && mips64 -// +build linux,mips64 package syscall diff --git a/src/syscall/zsyscall_linux_mips64le.go b/src/syscall/zsyscall_linux_mips64le.go index eaaf7dfb41..f3dacfeeda 100644 --- a/src/syscall/zsyscall_linux_mips64le.go +++ b/src/syscall/zsyscall_linux_mips64le.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build linux && mips64le -// +build linux,mips64le package syscall diff --git a/src/syscall/zsyscall_linux_mipsle.go b/src/syscall/zsyscall_linux_mipsle.go index bb159f1fe7..fbc543709f 100644 --- a/src/syscall/zsyscall_linux_mipsle.go +++ b/src/syscall/zsyscall_linux_mipsle.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build linux && mipsle -// +build linux,mipsle package syscall diff --git a/src/syscall/zsyscall_linux_ppc64.go b/src/syscall/zsyscall_linux_ppc64.go index 8a4328560a..b71dca2b37 100644 --- a/src/syscall/zsyscall_linux_ppc64.go +++ b/src/syscall/zsyscall_linux_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build linux && ppc64 -// +build linux,ppc64 package syscall diff --git a/src/syscall/zsyscall_linux_ppc64le.go b/src/syscall/zsyscall_linux_ppc64le.go index 274b55ce6b..193fbbc541 100644 --- a/src/syscall/zsyscall_linux_ppc64le.go +++ b/src/syscall/zsyscall_linux_ppc64le.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build linux && ppc64le -// +build linux,ppc64le package syscall diff --git a/src/syscall/zsyscall_linux_riscv64.go b/src/syscall/zsyscall_linux_riscv64.go index e21dc46f32..33b1e9b431 100644 --- a/src/syscall/zsyscall_linux_riscv64.go +++ b/src/syscall/zsyscall_linux_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build linux && riscv64 -// +build linux,riscv64 package syscall diff --git a/src/syscall/zsyscall_linux_s390x.go b/src/syscall/zsyscall_linux_s390x.go index fc667e7c3f..2ab78c71bf 100644 --- a/src/syscall/zsyscall_linux_s390x.go +++ b/src/syscall/zsyscall_linux_s390x.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build linux && s390x -// +build linux,s390x package syscall diff --git a/src/syscall/zsyscall_netbsd_386.go b/src/syscall/zsyscall_netbsd_386.go index 07ff5fba5f..408318181a 100644 --- a/src/syscall/zsyscall_netbsd_386.go +++ b/src/syscall/zsyscall_netbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build netbsd && 386 -// +build netbsd,386 package syscall diff --git a/src/syscall/zsyscall_netbsd_amd64.go b/src/syscall/zsyscall_netbsd_amd64.go index ffb4e059a4..2039cf6d0e 100644 --- a/src/syscall/zsyscall_netbsd_amd64.go +++ b/src/syscall/zsyscall_netbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build netbsd && amd64 -// +build netbsd,amd64 package syscall diff --git a/src/syscall/zsyscall_netbsd_arm.go b/src/syscall/zsyscall_netbsd_arm.go index 37df77e5e8..3c287ea223 100644 --- a/src/syscall/zsyscall_netbsd_arm.go +++ b/src/syscall/zsyscall_netbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build netbsd && arm -// +build netbsd,arm package syscall diff --git a/src/syscall/zsyscall_netbsd_arm64.go b/src/syscall/zsyscall_netbsd_arm64.go index c5eb57a226..1d40db9e6b 100644 --- a/src/syscall/zsyscall_netbsd_arm64.go +++ b/src/syscall/zsyscall_netbsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build netbsd && arm64 -// +build netbsd,arm64 package syscall diff --git a/src/syscall/zsyscall_openbsd_386.go b/src/syscall/zsyscall_openbsd_386.go index 1ff5c95fa1..5f95d7a9c6 100644 --- a/src/syscall/zsyscall_openbsd_386.go +++ b/src/syscall/zsyscall_openbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build openbsd && 386 -// +build openbsd,386 package syscall diff --git a/src/syscall/zsyscall_openbsd_amd64.go b/src/syscall/zsyscall_openbsd_amd64.go index 85cb195739..189bf887e6 100644 --- a/src/syscall/zsyscall_openbsd_amd64.go +++ b/src/syscall/zsyscall_openbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build openbsd && amd64 -// +build openbsd,amd64 package syscall diff --git a/src/syscall/zsyscall_openbsd_arm.go b/src/syscall/zsyscall_openbsd_arm.go index 04a2fadccd..c7513a3ac9 100644 --- a/src/syscall/zsyscall_openbsd_arm.go +++ b/src/syscall/zsyscall_openbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build openbsd && arm -// +build openbsd,arm package syscall diff --git a/src/syscall/zsyscall_openbsd_arm64.go b/src/syscall/zsyscall_openbsd_arm64.go index fa35905d1b..293b703600 100644 --- a/src/syscall/zsyscall_openbsd_arm64.go +++ b/src/syscall/zsyscall_openbsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build openbsd && arm64 -// +build openbsd,arm64 package syscall diff --git a/src/syscall/zsyscall_openbsd_mips64.go b/src/syscall/zsyscall_openbsd_mips64.go index 70fd1474fd..51904b5e29 100644 --- a/src/syscall/zsyscall_openbsd_mips64.go +++ b/src/syscall/zsyscall_openbsd_mips64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build openbsd && mips64 -// +build openbsd,mips64 package syscall diff --git a/src/syscall/zsyscall_plan9_386.go b/src/syscall/zsyscall_plan9_386.go index 8b7727b343..32fa0f0eb6 100644 --- a/src/syscall/zsyscall_plan9_386.go +++ b/src/syscall/zsyscall_plan9_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build plan9 && 386 -// +build plan9,386 package syscall diff --git a/src/syscall/zsyscall_plan9_amd64.go b/src/syscall/zsyscall_plan9_amd64.go index bed9108ea6..b3337ce811 100644 --- a/src/syscall/zsyscall_plan9_amd64.go +++ b/src/syscall/zsyscall_plan9_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build plan9 && amd64 -// +build plan9,amd64 package syscall diff --git a/src/syscall/zsyscall_plan9_arm.go b/src/syscall/zsyscall_plan9_arm.go index 7bbcf9b4b7..3705566fa3 100644 --- a/src/syscall/zsyscall_plan9_arm.go +++ b/src/syscall/zsyscall_plan9_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build plan9 && arm -// +build plan9,arm package syscall diff --git a/src/syscall/zsyscall_solaris_amd64.go b/src/syscall/zsyscall_solaris_amd64.go index 9b37dc0950..2d8cdfd280 100644 --- a/src/syscall/zsyscall_solaris_amd64.go +++ b/src/syscall/zsyscall_solaris_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build solaris && amd64 -// +build solaris,amd64 package syscall diff --git a/src/syscall/zsysnum_darwin_amd64.go b/src/syscall/zsysnum_darwin_amd64.go index f66f7d2715..08e003f292 100644 --- a/src/syscall/zsysnum_darwin_amd64.go +++ b/src/syscall/zsysnum_darwin_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build amd64 && darwin -// +build amd64,darwin package syscall diff --git a/src/syscall/zsysnum_darwin_arm64.go b/src/syscall/zsysnum_darwin_arm64.go index 6fa146368a..71309bb4d6 100644 --- a/src/syscall/zsysnum_darwin_arm64.go +++ b/src/syscall/zsysnum_darwin_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build arm64 && darwin -// +build arm64,darwin package syscall diff --git a/src/syscall/zsysnum_dragonfly_amd64.go b/src/syscall/zsysnum_dragonfly_amd64.go index e8996db0f8..03d4b06a09 100644 --- a/src/syscall/zsysnum_dragonfly_amd64.go +++ b/src/syscall/zsysnum_dragonfly_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build amd64 && dragonfly -// +build amd64,dragonfly package syscall diff --git a/src/syscall/zsysnum_freebsd_386.go b/src/syscall/zsysnum_freebsd_386.go index 1ed7e3ee8d..355b2ec303 100644 --- a/src/syscall/zsysnum_freebsd_386.go +++ b/src/syscall/zsysnum_freebsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build 386 && freebsd -// +build 386,freebsd package syscall diff --git a/src/syscall/zsysnum_freebsd_amd64.go b/src/syscall/zsysnum_freebsd_amd64.go index d72dbc944a..84c821c955 100644 --- a/src/syscall/zsysnum_freebsd_amd64.go +++ b/src/syscall/zsysnum_freebsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build amd64 && freebsd -// +build amd64,freebsd package syscall diff --git a/src/syscall/zsysnum_freebsd_arm.go b/src/syscall/zsysnum_freebsd_arm.go index 4f4dc4db79..785e7875f4 100644 --- a/src/syscall/zsysnum_freebsd_arm.go +++ b/src/syscall/zsysnum_freebsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build arm && freebsd -// +build arm,freebsd package syscall diff --git a/src/syscall/zsysnum_freebsd_arm64.go b/src/syscall/zsysnum_freebsd_arm64.go index ab1a05258e..7144a8abed 100644 --- a/src/syscall/zsysnum_freebsd_arm64.go +++ b/src/syscall/zsysnum_freebsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build arm64 && freebsd -// +build arm64,freebsd package syscall diff --git a/src/syscall/zsysnum_linux_386.go b/src/syscall/zsysnum_linux_386.go index 792f43550e..4966d2a947 100644 --- a/src/syscall/zsysnum_linux_386.go +++ b/src/syscall/zsysnum_linux_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build 386 && linux -// +build 386,linux package syscall diff --git a/src/syscall/zsysnum_linux_amd64.go b/src/syscall/zsysnum_linux_amd64.go index 9ea18d6111..576c7c36a6 100644 --- a/src/syscall/zsysnum_linux_amd64.go +++ b/src/syscall/zsysnum_linux_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build amd64 && linux -// +build amd64,linux package syscall diff --git a/src/syscall/zsysnum_linux_arm.go b/src/syscall/zsysnum_linux_arm.go index ccae9c15e3..b0da97c64b 100644 --- a/src/syscall/zsysnum_linux_arm.go +++ b/src/syscall/zsysnum_linux_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build arm && linux -// +build arm,linux package syscall diff --git a/src/syscall/zsysnum_linux_arm64.go b/src/syscall/zsysnum_linux_arm64.go index 17c54a2c83..0136d9440b 100644 --- a/src/syscall/zsysnum_linux_arm64.go +++ b/src/syscall/zsysnum_linux_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build arm64 && linux -// +build arm64,linux package syscall diff --git a/src/syscall/zsysnum_linux_ppc64.go b/src/syscall/zsysnum_linux_ppc64.go index a0d37ff1f2..cc964c23e2 100644 --- a/src/syscall/zsysnum_linux_ppc64.go +++ b/src/syscall/zsysnum_linux_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build ppc64 && linux -// +build ppc64,linux package syscall diff --git a/src/syscall/zsysnum_linux_ppc64le.go b/src/syscall/zsysnum_linux_ppc64le.go index f8f82d2043..57bfb7795f 100644 --- a/src/syscall/zsysnum_linux_ppc64le.go +++ b/src/syscall/zsysnum_linux_ppc64le.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build ppc64le && linux -// +build ppc64le,linux package syscall diff --git a/src/syscall/zsysnum_netbsd_386.go b/src/syscall/zsysnum_netbsd_386.go index fd0c329951..5696c4befe 100644 --- a/src/syscall/zsysnum_netbsd_386.go +++ b/src/syscall/zsysnum_netbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build 386 && netbsd -// +build 386,netbsd package syscall diff --git a/src/syscall/zsysnum_netbsd_amd64.go b/src/syscall/zsysnum_netbsd_amd64.go index 03f2cd3bd3..9fb85cddba 100644 --- a/src/syscall/zsysnum_netbsd_amd64.go +++ b/src/syscall/zsysnum_netbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build amd64 && netbsd -// +build amd64,netbsd package syscall diff --git a/src/syscall/zsysnum_netbsd_arm.go b/src/syscall/zsysnum_netbsd_arm.go index 7b356e7102..e0e8994641 100644 --- a/src/syscall/zsysnum_netbsd_arm.go +++ b/src/syscall/zsysnum_netbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build arm && netbsd -// +build arm,netbsd package syscall diff --git a/src/syscall/zsysnum_netbsd_arm64.go b/src/syscall/zsysnum_netbsd_arm64.go index 3f57ec4d89..9653364dae 100644 --- a/src/syscall/zsysnum_netbsd_arm64.go +++ b/src/syscall/zsysnum_netbsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build arm64 && netbsd -// +build arm64,netbsd package syscall diff --git a/src/syscall/zsysnum_openbsd_386.go b/src/syscall/zsysnum_openbsd_386.go index b289886d6c..3b12639bd7 100644 --- a/src/syscall/zsysnum_openbsd_386.go +++ b/src/syscall/zsysnum_openbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build 386 && openbsd -// +build 386,openbsd package syscall diff --git a/src/syscall/zsysnum_openbsd_amd64.go b/src/syscall/zsysnum_openbsd_amd64.go index 8cf2b68dcd..bce309dc5d 100644 --- a/src/syscall/zsysnum_openbsd_amd64.go +++ b/src/syscall/zsysnum_openbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build amd64 && openbsd -// +build amd64,openbsd package syscall diff --git a/src/syscall/zsysnum_openbsd_arm.go b/src/syscall/zsysnum_openbsd_arm.go index cc33773a05..05aed70762 100644 --- a/src/syscall/zsysnum_openbsd_arm.go +++ b/src/syscall/zsysnum_openbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build arm && openbsd -// +build arm,openbsd package syscall diff --git a/src/syscall/zsysnum_solaris_amd64.go b/src/syscall/zsysnum_solaris_amd64.go index 23c9c715b5..ea244e535e 100644 --- a/src/syscall/zsysnum_solaris_amd64.go +++ b/src/syscall/zsysnum_solaris_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && solaris -// +build amd64,solaris package syscall diff --git a/src/syscall/ztypes_darwin_amd64.go b/src/syscall/ztypes_darwin_amd64.go index 8feacc47ab..551edc7025 100644 --- a/src/syscall/ztypes_darwin_amd64.go +++ b/src/syscall/ztypes_darwin_amd64.go @@ -2,7 +2,6 @@ // cgo -godefs types_darwin.go //go:build amd64 && darwin -// +build amd64,darwin package syscall diff --git a/src/syscall/ztypes_darwin_arm64.go b/src/syscall/ztypes_darwin_arm64.go index 8079d22429..46f78a97eb 100644 --- a/src/syscall/ztypes_darwin_arm64.go +++ b/src/syscall/ztypes_darwin_arm64.go @@ -2,7 +2,6 @@ // cgo -godefs types_darwin.go //go:build arm64 && darwin -// +build arm64,darwin package syscall diff --git a/src/syscall/ztypes_dragonfly_amd64.go b/src/syscall/ztypes_dragonfly_amd64.go index a51e0038bb..ec519b72ec 100644 --- a/src/syscall/ztypes_dragonfly_amd64.go +++ b/src/syscall/ztypes_dragonfly_amd64.go @@ -2,7 +2,6 @@ // cgo -godefs types_dragonfly.go //go:build amd64 && dragonfly -// +build amd64,dragonfly package syscall diff --git a/src/syscall/ztypes_freebsd_386.go b/src/syscall/ztypes_freebsd_386.go index 1739726883..e1946dece8 100644 --- a/src/syscall/ztypes_freebsd_386.go +++ b/src/syscall/ztypes_freebsd_386.go @@ -2,7 +2,6 @@ // cgo -godefs types_freebsd.go | go run mkpost.go //go:build 386 && freebsd -// +build 386,freebsd package syscall diff --git a/src/syscall/ztypes_freebsd_amd64.go b/src/syscall/ztypes_freebsd_amd64.go index 0457d8e995..a718345d79 100644 --- a/src/syscall/ztypes_freebsd_amd64.go +++ b/src/syscall/ztypes_freebsd_amd64.go @@ -2,7 +2,6 @@ // cgo -godefs types_freebsd.go | go run mkpost.go //go:build amd64 && freebsd -// +build amd64,freebsd package syscall diff --git a/src/syscall/ztypes_freebsd_arm.go b/src/syscall/ztypes_freebsd_arm.go index 29c8380d89..9c5a066713 100644 --- a/src/syscall/ztypes_freebsd_arm.go +++ b/src/syscall/ztypes_freebsd_arm.go @@ -2,7 +2,6 @@ // cgo -godefs -- -fsigned-char types_freebsd.go //go:build arm && freebsd -// +build arm,freebsd package syscall diff --git a/src/syscall/ztypes_freebsd_arm64.go b/src/syscall/ztypes_freebsd_arm64.go index 6472db0080..3ccd9fc0dd 100644 --- a/src/syscall/ztypes_freebsd_arm64.go +++ b/src/syscall/ztypes_freebsd_arm64.go @@ -2,7 +2,6 @@ // cgo -godefs types_freebsd.go | go run mkpost.go //go:build arm64 && freebsd -// +build arm64,freebsd package syscall diff --git a/src/syscall/ztypes_linux_386.go b/src/syscall/ztypes_linux_386.go index 251a0c0b4a..a45511e847 100644 --- a/src/syscall/ztypes_linux_386.go +++ b/src/syscall/ztypes_linux_386.go @@ -2,7 +2,6 @@ // cgo -godefs types_linux.go //go:build 386 && linux -// +build 386,linux package syscall diff --git a/src/syscall/ztypes_linux_amd64.go b/src/syscall/ztypes_linux_amd64.go index 34c953fc8b..1bab13bf43 100644 --- a/src/syscall/ztypes_linux_amd64.go +++ b/src/syscall/ztypes_linux_amd64.go @@ -2,7 +2,6 @@ // cgo -godefs types_linux.go //go:build amd64 && linux -// +build amd64,linux package syscall diff --git a/src/syscall/ztypes_linux_arm.go b/src/syscall/ztypes_linux_arm.go index 4de656b491..a4d61bd19b 100644 --- a/src/syscall/ztypes_linux_arm.go +++ b/src/syscall/ztypes_linux_arm.go @@ -2,7 +2,6 @@ // cgo -godefs types_linux.go //go:build arm && linux -// +build arm,linux package syscall diff --git a/src/syscall/ztypes_linux_arm64.go b/src/syscall/ztypes_linux_arm64.go index bed9cb0851..1e469c36d2 100644 --- a/src/syscall/ztypes_linux_arm64.go +++ b/src/syscall/ztypes_linux_arm64.go @@ -2,7 +2,6 @@ // cgo -godefs -- -fsigned-char types_linux.go //go:build arm64 && linux -// +build arm64,linux package syscall diff --git a/src/syscall/ztypes_linux_ppc64.go b/src/syscall/ztypes_linux_ppc64.go index 355533fb27..c830cee966 100644 --- a/src/syscall/ztypes_linux_ppc64.go +++ b/src/syscall/ztypes_linux_ppc64.go @@ -2,7 +2,6 @@ // cgo -godefs types_linux.go //go:build ppc64 && linux -// +build ppc64,linux package syscall diff --git a/src/syscall/ztypes_linux_ppc64le.go b/src/syscall/ztypes_linux_ppc64le.go index 94e12c742c..770ddc9fe9 100644 --- a/src/syscall/ztypes_linux_ppc64le.go +++ b/src/syscall/ztypes_linux_ppc64le.go @@ -2,7 +2,6 @@ // cgo -godefs types_linux.go //go:build ppc64le && linux -// +build ppc64le,linux package syscall diff --git a/src/syscall/ztypes_netbsd_386.go b/src/syscall/ztypes_netbsd_386.go index 321460f45a..74eaa4a150 100644 --- a/src/syscall/ztypes_netbsd_386.go +++ b/src/syscall/ztypes_netbsd_386.go @@ -2,7 +2,6 @@ // cgo -godefs types_netbsd.go //go:build 386 && netbsd -// +build 386,netbsd package syscall diff --git a/src/syscall/ztypes_netbsd_amd64.go b/src/syscall/ztypes_netbsd_amd64.go index 370d717263..fc28fc9bb8 100644 --- a/src/syscall/ztypes_netbsd_amd64.go +++ b/src/syscall/ztypes_netbsd_amd64.go @@ -2,7 +2,6 @@ // cgo -godefs types_netbsd.go //go:build amd64 && netbsd -// +build amd64,netbsd package syscall diff --git a/src/syscall/ztypes_netbsd_arm.go b/src/syscall/ztypes_netbsd_arm.go index 557c634533..1f885048dd 100644 --- a/src/syscall/ztypes_netbsd_arm.go +++ b/src/syscall/ztypes_netbsd_arm.go @@ -2,7 +2,6 @@ // cgo -godefs types_netbsd.go //go:build arm && netbsd -// +build arm,netbsd package syscall diff --git a/src/syscall/ztypes_netbsd_arm64.go b/src/syscall/ztypes_netbsd_arm64.go index 19f3690341..cac74693d7 100644 --- a/src/syscall/ztypes_netbsd_arm64.go +++ b/src/syscall/ztypes_netbsd_arm64.go @@ -2,7 +2,6 @@ // cgo -godefs types_netbsd.go //go:build arm64 && netbsd -// +build arm64,netbsd package syscall diff --git a/src/syscall/ztypes_openbsd_386.go b/src/syscall/ztypes_openbsd_386.go index 222c6c7e46..f9ba685e25 100644 --- a/src/syscall/ztypes_openbsd_386.go +++ b/src/syscall/ztypes_openbsd_386.go @@ -2,7 +2,6 @@ // cgo -godefs types_openbsd.go //go:build 386 && openbsd -// +build 386,openbsd package syscall diff --git a/src/syscall/ztypes_openbsd_amd64.go b/src/syscall/ztypes_openbsd_amd64.go index 644ee9b3df..889b9551ae 100644 --- a/src/syscall/ztypes_openbsd_amd64.go +++ b/src/syscall/ztypes_openbsd_amd64.go @@ -2,7 +2,6 @@ // cgo -godefs types_openbsd.go //go:build amd64 && openbsd -// +build amd64,openbsd package syscall diff --git a/src/syscall/ztypes_solaris_amd64.go b/src/syscall/ztypes_solaris_amd64.go index 64e16b4943..d486cd002f 100644 --- a/src/syscall/ztypes_solaris_amd64.go +++ b/src/syscall/ztypes_solaris_amd64.go @@ -2,7 +2,6 @@ // cgo -godefs types_solaris.go //go:build amd64 && solaris -// +build amd64,solaris package syscall diff --git a/src/testing/run_example.go b/src/testing/run_example.go index d9e342d495..e7eab1e50e 100644 --- a/src/testing/run_example.go +++ b/src/testing/run_example.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !js -// +build !js // TODO(@musiol, @odeke-em): re-unify this entire file back into // example.go when js/wasm gets an os.Pipe implementation diff --git a/src/testing/run_example_js.go b/src/testing/run_example_js.go index d914633ba9..adef9511fb 100644 --- a/src/testing/run_example_js.go +++ b/src/testing/run_example_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js -// +build js package testing diff --git a/src/time/embed.go b/src/time/embed.go index 34490c859d..2a9821baa9 100644 --- a/src/time/embed.go +++ b/src/time/embed.go @@ -6,7 +6,6 @@ // the binary. //go:build timetzdata -// +build timetzdata package time diff --git a/src/time/genzabbrs.go b/src/time/genzabbrs.go index 9fd2f2b762..a8651bfdb8 100644 --- a/src/time/genzabbrs.go +++ b/src/time/genzabbrs.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // // usage: diff --git a/src/time/sys_plan9.go b/src/time/sys_plan9.go index 4dc55e44aa..ba37cf5424 100644 --- a/src/time/sys_plan9.go +++ b/src/time/sys_plan9.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 -// +build plan9 package time diff --git a/src/time/sys_unix.go b/src/time/sys_unix.go index 60fc090dc9..a949a6af22 100644 --- a/src/time/sys_unix.go +++ b/src/time/sys_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris package time diff --git a/src/time/tzdata/generate_zipdata.go b/src/time/tzdata/generate_zipdata.go index 0869c8458c..4f40b51c73 100644 --- a/src/time/tzdata/generate_zipdata.go +++ b/src/time/tzdata/generate_zipdata.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ignore -// +build ignore // This program generates zipdata.go from $GOROOT/lib/time/zoneinfo.zip. package main diff --git a/src/time/zoneinfo_ios.go b/src/time/zoneinfo_ios.go index 044691e130..7eccabf249 100644 --- a/src/time/zoneinfo_ios.go +++ b/src/time/zoneinfo_ios.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ios -// +build ios package time diff --git a/src/time/zoneinfo_js.go b/src/time/zoneinfo_js.go index 8245614d2e..d0aefb9088 100644 --- a/src/time/zoneinfo_js.go +++ b/src/time/zoneinfo_js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package time diff --git a/src/time/zoneinfo_unix.go b/src/time/zoneinfo_unix.go index 4ea029dbde..23f8b3cdb4 100644 --- a/src/time/zoneinfo_unix.go +++ b/src/time/zoneinfo_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || (darwin && !ios) || dragonfly || freebsd || (linux && !android) || netbsd || openbsd || solaris -// +build aix darwin,!ios dragonfly freebsd linux,!android netbsd openbsd solaris // Parse "zoneinfo" time zone file. // This is a fairly standard file format used on OS X, Linux, BSD, Sun, and others. diff --git a/src/time/zoneinfo_unix_test.go b/src/time/zoneinfo_unix_test.go index b75b374c3d..de95295cd3 100644 --- a/src/time/zoneinfo_unix_test.go +++ b/src/time/zoneinfo_unix_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || (darwin && !ios) || dragonfly || freebsd || (linux && !android) || netbsd || openbsd || solaris -// +build aix darwin,!ios dragonfly freebsd linux,!android netbsd openbsd solaris package time_test From 5e217284dc9f3b55e8c8b225dc81c1eb1004d423 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Thu, 28 Oct 2021 16:06:21 -0400 Subject: [PATCH 223/406] cmd/internal/goobj: bump version number There have a few updates to the Go object file in this cycle (e.g. FuncInfo format change, some changes in constant values), and it is not compatible with the old tools. Bump up the version number. Change-Id: Id176979b139c76ded2c50f2678eb313934326d6f Reviewed-on: https://go-review.googlesource.com/c/go/+/359483 Trust: Cherry Mui Run-TryBot: Cherry Mui Reviewed-by: Than McIntosh TryBot-Result: Go Bot --- src/cmd/internal/goobj/objfile.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/internal/goobj/objfile.go b/src/cmd/internal/goobj/objfile.go index 4dfea84539..9765058392 100644 --- a/src/cmd/internal/goobj/objfile.go +++ b/src/cmd/internal/goobj/objfile.go @@ -31,7 +31,7 @@ import ( // New object file format. // // Header struct { -// Magic [...]byte // "\x00go117ld" +// Magic [...]byte // "\x00go118ld" // Fingerprint [8]byte // Flags uint32 // Offsets [...]uint32 // byte offset of each block below @@ -215,7 +215,7 @@ type Header struct { Offsets [NBlk]uint32 } -const Magic = "\x00go117ld" +const Magic = "\x00go118ld" func (h *Header) Write(w *Writer) { w.RawString(h.Magic) From 834e36ec778c11b068a2d5354343d4668e5a9ceb Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Thu, 28 Oct 2021 16:23:51 -0400 Subject: [PATCH 224/406] net/http: restore generated // +build comment The upstream cmd/bundle tool does not yet omit it, and the longtest builders test that the generated file is not modified. For #41184. Change-Id: Ib68f532139ed1436cbaf3a756f300fe60f520cab Reviewed-on: https://go-review.googlesource.com/c/go/+/359484 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills Reviewed-by: Dmitri Shuralyov Reviewed-by: David Chase TryBot-Result: Go Bot --- src/net/http/h2_bundle.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go index df98232824..29226d4065 100644 --- a/src/net/http/h2_bundle.go +++ b/src/net/http/h2_bundle.go @@ -1,4 +1,5 @@ //go:build !nethttpomithttp2 +// +build !nethttpomithttp2 // Code generated by golang.org/x/tools/cmd/bundle. DO NOT EDIT. // $ bundle -o=h2_bundle.go -prefix=http2 -tags=!nethttpomithttp2 golang.org/x/net/http2 From e741e2fe0e51840b16bfc84d8daaba7670e7aac9 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Thu, 28 Oct 2021 15:00:33 -0400 Subject: [PATCH 225/406] cmd/go: consolidate fuzz-support checks We had been repeating conditions for specific platforms and architectures to gate fuzzing tests, but the more of those tests we add the more we will have to update if the set of supported platforms and archictures expands over time. We also ought to provide a friendlier error message when 'go test -fuzz' is used on non-supported platforms. This change adds predicates in cmd/internal/sys, which already contains similar predicates for related functionality (such as the race detector), and uses those predicates in 'go test' and TestScript. For #48495 Change-Id: If24c3997aeb4d201258e21e5b6cf4f7c08fbadd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/359481 Trust: Bryan C. Mills Trust: Katie Hockman Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Katie Hockman --- src/cmd/go/go_test.go | 12 ++++++---- src/cmd/go/internal/test/test.go | 12 +++++++--- src/cmd/go/internal/work/init.go | 15 +----------- src/cmd/go/script_test.go | 4 ++++ src/cmd/go/testdata/script/README | 2 ++ src/cmd/go/testdata/script/test_fuzz.txt | 5 ++-- .../go/testdata/script/test_fuzz_cache.txt | 7 +----- .../go/testdata/script/test_fuzz_chatty.txt | 4 +--- .../go/testdata/script/test_fuzz_cleanup.txt | 3 +-- .../go/testdata/script/test_fuzz_deadline.txt | 4 +--- .../go/testdata/script/test_fuzz_fuzztime.txt | 4 +--- .../go/testdata/script/test_fuzz_io_error.txt | 2 +- .../go/testdata/script/test_fuzz_match.txt | 3 +-- .../go/testdata/script/test_fuzz_minimize.txt | 4 +--- .../script/test_fuzz_minimize_interesting.txt | 6 +---- .../go/testdata/script/test_fuzz_multiple.txt | 4 +--- .../script/test_fuzz_mutate_crash.txt | 3 +-- .../testdata/script/test_fuzz_mutate_fail.txt | 3 +-- .../go/testdata/script/test_fuzz_mutator.txt | 3 +-- .../script/test_fuzz_non_crash_signal.txt | 4 ++-- .../go/testdata/script/test_fuzz_parallel.txt | 4 +--- src/cmd/go/testdata/script/test_fuzz_run.txt | 6 ++--- .../testdata/script/test_fuzz_seed_corpus.txt | 10 ++------ .../go/testdata/script/test_fuzz_setenv.txt | 2 +- .../testdata/script/test_fuzz_unsupported.txt | 18 +++++++++++++++ src/cmd/internal/sys/supported.go | 23 +++++++++++++++++++ src/internal/fuzz/counters_unsupported.go | 6 +++++ src/internal/fuzz/sys_unimplemented.go | 3 ++- 28 files changed, 96 insertions(+), 80 deletions(-) create mode 100644 src/cmd/go/testdata/script/test_fuzz_unsupported.txt diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 339014e94e..c13d77a1af 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -43,10 +43,12 @@ func init() { } var ( - canRace = false // whether we can run the race detector - canCgo = false // whether we can use cgo - canMSan = false // whether we can run the memory sanitizer - canASan = false // whether we can run the address sanitizer + canRace = false // whether we can run the race detector + canCgo = false // whether we can use cgo + canMSan = false // whether we can run the memory sanitizer + canASan = false // whether we can run the address sanitizer + canFuzz = false // whether we can search for new fuzz failures + fuzzInstrumented = false // whether fuzzing uses instrumentation ) var exeSuffix string = func() string { @@ -206,6 +208,8 @@ func TestMain(m *testing.M) { if isAlpineLinux() || runtime.Compiler == "gccgo" { canRace = false } + canFuzz = sys.FuzzSupported(runtime.GOOS, runtime.GOARCH) + fuzzInstrumented = sys.FuzzInstrumented(runtime.GOOS, runtime.GOARCH) } // Don't let these environment variables confuse the test. os.Setenv("GOENV", "off") diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index ea1d4ff20e..0806d29f21 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -31,9 +31,10 @@ import ( "cmd/go/internal/lockedfile" "cmd/go/internal/modload" "cmd/go/internal/search" + "cmd/go/internal/str" "cmd/go/internal/trace" "cmd/go/internal/work" - "cmd/go/internal/str" + "cmd/internal/sys" "cmd/internal/test2json" ) @@ -651,8 +652,13 @@ func runTest(ctx context.Context, cmd *base.Command, args []string) { if testO != "" && len(pkgs) != 1 { base.Fatalf("cannot use -o flag with multiple packages") } - if testFuzz != "" && len(pkgs) != 1 { - base.Fatalf("cannot use -fuzz flag with multiple packages") + if testFuzz != "" { + if !sys.FuzzSupported(cfg.Goos, cfg.Goarch) { + base.Fatalf("-fuzz flag is not supported on %s/%s", cfg.Goos, cfg.Goarch) + } + if len(pkgs) != 1 { + base.Fatalf("cannot use -fuzz flag with multiple packages") + } } if testProfile() != "" && len(pkgs) != 1 { base.Fatalf("cannot use %s flag with multiple packages", testProfile()) diff --git a/src/cmd/go/internal/work/init.go b/src/cmd/go/internal/work/init.go index b2ee00d53c..9111150233 100644 --- a/src/cmd/go/internal/work/init.go +++ b/src/cmd/go/internal/work/init.go @@ -67,20 +67,7 @@ func BuildInit() { // instrumentation is added. 'go test -fuzz' still works without coverage, // but it generates random inputs without guidance, so it's much less effective. func fuzzInstrumentFlags() []string { - // TODO: expand the set of supported platforms, with testing. Nothing about - // the instrumentation is OS specific, but only amd64 and arm64 are - // supported in the runtime. See src/runtime/libfuzzer*. - // - // Keep in sync with build constraints in - // internal/fuzz/counters_{un,}supported.go - switch cfg.Goos { - case "darwin", "freebsd", "linux", "windows": - default: - return nil - } - switch cfg.Goarch { - case "amd64", "arm64": - default: + if !sys.FuzzInstrumented(cfg.Goos, cfg.Goarch) { return nil } return []string{"-d=libfuzzer"} diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go index acb1f91b44..98c1b68ed9 100644 --- a/src/cmd/go/script_test.go +++ b/src/cmd/go/script_test.go @@ -357,6 +357,10 @@ Script: ok = canASan case "race": ok = canRace + case "fuzz": + ok = canFuzz + case "fuzz-instrumented": + ok = fuzzInstrumented case "net": ok = testenv.HasExternalNetwork() case "link": diff --git a/src/cmd/go/testdata/script/README b/src/cmd/go/testdata/script/README index 2b88e880c9..2b55fa8977 100644 --- a/src/cmd/go/testdata/script/README +++ b/src/cmd/go/testdata/script/README @@ -80,6 +80,8 @@ should only run when the condition is satisfied. The available conditions are: - Test environment details: - [short] for testing.Short() - [cgo], [msan], [asan], [race] for whether cgo, msan, asan, and the race detector can be used + - [fuzz] for whether 'go test -fuzz' can be used at all + - [fuzz-instrumented] for whether 'go test -fuzz' uses coverage-instrumented binaries - [net] for whether the external network can be used - [link] for testenv.HasLink() - [root] for os.Geteuid() == 0 diff --git a/src/cmd/go/testdata/script/test_fuzz.txt b/src/cmd/go/testdata/script/test_fuzz.txt index 4665202bf0..020012d73e 100644 --- a/src/cmd/go/testdata/script/test_fuzz.txt +++ b/src/cmd/go/testdata/script/test_fuzz.txt @@ -1,5 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip +[!fuzz] skip # Test that running a fuzz target that returns without failing or calling # f.Fuzz fails and causes a non-zero exit status. @@ -495,4 +494,4 @@ go test fuzz v1 []byte("12345") -- corpustesting/testdata/fuzz/FuzzWrongType/1 -- go test fuzz v1 -int("00000") \ No newline at end of file +int("00000") diff --git a/src/cmd/go/testdata/script/test_fuzz_cache.txt b/src/cmd/go/testdata/script/test_fuzz_cache.txt index fc1c9a1752..552966b06b 100644 --- a/src/cmd/go/testdata/script/test_fuzz_cache.txt +++ b/src/cmd/go/testdata/script/test_fuzz_cache.txt @@ -1,9 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip - -# Instrumentation not supported on other archs. -# See #14565. -[!amd64] [!arm64] skip +[!fuzz-instrumented] skip [short] skip env GOCACHE=$WORK/cache diff --git a/src/cmd/go/testdata/script/test_fuzz_chatty.txt b/src/cmd/go/testdata/script/test_fuzz_chatty.txt index 9ebd480c90..1abcbbd389 100644 --- a/src/cmd/go/testdata/script/test_fuzz_chatty.txt +++ b/src/cmd/go/testdata/script/test_fuzz_chatty.txt @@ -1,6 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip - +[!fuzz] skip [short] skip # Run chatty fuzz targets with an error. diff --git a/src/cmd/go/testdata/script/test_fuzz_cleanup.txt b/src/cmd/go/testdata/script/test_fuzz_cleanup.txt index 88625916ba..b65022bd74 100644 --- a/src/cmd/go/testdata/script/test_fuzz_cleanup.txt +++ b/src/cmd/go/testdata/script/test_fuzz_cleanup.txt @@ -1,5 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip +[!fuzz] skip [short] skip # Cleanup should run after F.Skip. diff --git a/src/cmd/go/testdata/script/test_fuzz_deadline.txt b/src/cmd/go/testdata/script/test_fuzz_deadline.txt index 12f1054f61..5ba76a3d4f 100644 --- a/src/cmd/go/testdata/script/test_fuzz_deadline.txt +++ b/src/cmd/go/testdata/script/test_fuzz_deadline.txt @@ -1,6 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip - +[!fuzz] skip [short] skip # The fuzz function should be able to detect whether -timeout diff --git a/src/cmd/go/testdata/script/test_fuzz_fuzztime.txt b/src/cmd/go/testdata/script/test_fuzz_fuzztime.txt index c3933bc7e2..56d94a4bcf 100644 --- a/src/cmd/go/testdata/script/test_fuzz_fuzztime.txt +++ b/src/cmd/go/testdata/script/test_fuzz_fuzztime.txt @@ -1,6 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip - +[!fuzz] skip [short] skip # There are no seed values, so 'go test' should finish quickly. diff --git a/src/cmd/go/testdata/script/test_fuzz_io_error.txt b/src/cmd/go/testdata/script/test_fuzz_io_error.txt index 4c7ab4c152..1a0aa6427e 100644 --- a/src/cmd/go/testdata/script/test_fuzz_io_error.txt +++ b/src/cmd/go/testdata/script/test_fuzz_io_error.txt @@ -6,7 +6,7 @@ # This is unlikely, but possible. It's difficult to simulate interruptions # due to ^C and EOF errors which are more common. We don't report those. [short] skip -[!darwin] [!linux] [!windows] skip +[!fuzz] skip # If the I/O error occurs before F.Fuzz is called, the coordinator should # stop the worker and say that. diff --git a/src/cmd/go/testdata/script/test_fuzz_match.txt b/src/cmd/go/testdata/script/test_fuzz_match.txt index 3a2ca631ad..0c0085f2c2 100644 --- a/src/cmd/go/testdata/script/test_fuzz_match.txt +++ b/src/cmd/go/testdata/script/test_fuzz_match.txt @@ -1,5 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip +[!fuzz] skip # Matches only fuzz targets to test. go test standalone_fuzz_test.go diff --git a/src/cmd/go/testdata/script/test_fuzz_minimize.txt b/src/cmd/go/testdata/script/test_fuzz_minimize.txt index 3293e878bb..462fb9a963 100644 --- a/src/cmd/go/testdata/script/test_fuzz_minimize.txt +++ b/src/cmd/go/testdata/script/test_fuzz_minimize.txt @@ -1,6 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip - +[!fuzz] skip [short] skip # We clean the fuzz cache during this test. Don't clean the user's cache. diff --git a/src/cmd/go/testdata/script/test_fuzz_minimize_interesting.txt b/src/cmd/go/testdata/script/test_fuzz_minimize_interesting.txt index 8ea4cdb8a5..e017a4cad3 100644 --- a/src/cmd/go/testdata/script/test_fuzz_minimize_interesting.txt +++ b/src/cmd/go/testdata/script/test_fuzz_minimize_interesting.txt @@ -1,8 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip - -# Instrumentation only supported on 64-bit architectures. -[!amd64] [!arm64] skip +[!fuzz-instrumented] skip # Test that when an interesting value is discovered (one that expands coverage), # the fuzzing engine minimizes it before writing it to the cache. diff --git a/src/cmd/go/testdata/script/test_fuzz_multiple.txt b/src/cmd/go/testdata/script/test_fuzz_multiple.txt index 6a7732f514..d96b2b6206 100644 --- a/src/cmd/go/testdata/script/test_fuzz_multiple.txt +++ b/src/cmd/go/testdata/script/test_fuzz_multiple.txt @@ -2,9 +2,7 @@ # enabled, and multiple package or multiple fuzz targets match. # TODO(#46312): support fuzzing multiple targets in multiple packages. -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip - +[!fuzz] skip [short] skip # With fuzzing disabled, multiple targets can be tested. diff --git a/src/cmd/go/testdata/script/test_fuzz_mutate_crash.txt b/src/cmd/go/testdata/script/test_fuzz_mutate_crash.txt index 628e003f41..4c4fa8e651 100644 --- a/src/cmd/go/testdata/script/test_fuzz_mutate_crash.txt +++ b/src/cmd/go/testdata/script/test_fuzz_mutate_crash.txt @@ -1,5 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip +[!fuzz] skip # Tests that a crash caused by a mutator-discovered input writes the bad input # to testdata, and fails+reports correctly. This tests the end-to-end behavior diff --git a/src/cmd/go/testdata/script/test_fuzz_mutate_fail.txt b/src/cmd/go/testdata/script/test_fuzz_mutate_fail.txt index 935c22a05e..b5eab17349 100644 --- a/src/cmd/go/testdata/script/test_fuzz_mutate_fail.txt +++ b/src/cmd/go/testdata/script/test_fuzz_mutate_fail.txt @@ -1,5 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip +[!fuzz] skip # Check that if a worker does not call F.Fuzz or calls F.Fail first, # 'go test' exits non-zero and no crasher is recorded. diff --git a/src/cmd/go/testdata/script/test_fuzz_mutator.txt b/src/cmd/go/testdata/script/test_fuzz_mutator.txt index 9d0738e169..76b86488ad 100644 --- a/src/cmd/go/testdata/script/test_fuzz_mutator.txt +++ b/src/cmd/go/testdata/script/test_fuzz_mutator.txt @@ -1,5 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip +[!fuzz] skip # Test basic fuzzing mutator behavior. # diff --git a/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt b/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt index 1568757de7..f1a4c6669f 100644 --- a/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt +++ b/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt @@ -1,7 +1,7 @@ # NOTE: this test is skipped on Windows, since there's no concept of signals. # When a process terminates another process, it provides an exit code. -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!freebsd] [!linux] skip +[windows] skip +[!fuzz] skip [short] skip # FuzzNonCrash sends itself a signal that does not appear to be a crash. diff --git a/src/cmd/go/testdata/script/test_fuzz_parallel.txt b/src/cmd/go/testdata/script/test_fuzz_parallel.txt index a49f30a27f..1795e0b2a5 100644 --- a/src/cmd/go/testdata/script/test_fuzz_parallel.txt +++ b/src/cmd/go/testdata/script/test_fuzz_parallel.txt @@ -1,6 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip - +[!fuzz] skip [short] skip # When running seed inputs, T.Parallel should let multiple inputs run in diff --git a/src/cmd/go/testdata/script/test_fuzz_run.txt b/src/cmd/go/testdata/script/test_fuzz_run.txt index e546d997cb..99a4413d32 100644 --- a/src/cmd/go/testdata/script/test_fuzz_run.txt +++ b/src/cmd/go/testdata/script/test_fuzz_run.txt @@ -1,6 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip - +[!fuzz] skip [short] skip env GOCACHE=$WORK/cache @@ -142,4 +140,4 @@ go test fuzz v1 string("fails") -- testdata/fuzz/FuzzFoo/thispasses -- go test fuzz v1 -string("passes") \ No newline at end of file +string("passes") diff --git a/src/cmd/go/testdata/script/test_fuzz_seed_corpus.txt b/src/cmd/go/testdata/script/test_fuzz_seed_corpus.txt index 18f634a3b6..4be9a6e385 100644 --- a/src/cmd/go/testdata/script/test_fuzz_seed_corpus.txt +++ b/src/cmd/go/testdata/script/test_fuzz_seed_corpus.txt @@ -1,10 +1,4 @@ -# TODO(jayconrod): support shared memory on more platforms. -[!darwin] [!linux] [!windows] skip - -# Instrumentation not supported on other archs. -# See #14565. -[!amd64] [!arm64] skip - +[!fuzz-instrumented] skip [short] skip env GOCACHE=$WORK/cache @@ -206,4 +200,4 @@ go test fuzz v1 int(10) -- cache-file-bytes -- go test fuzz v1 -[]byte("11111111111111111111") \ No newline at end of file +[]byte("11111111111111111111") diff --git a/src/cmd/go/testdata/script/test_fuzz_setenv.txt b/src/cmd/go/testdata/script/test_fuzz_setenv.txt index 9738697a91..2924569de1 100644 --- a/src/cmd/go/testdata/script/test_fuzz_setenv.txt +++ b/src/cmd/go/testdata/script/test_fuzz_setenv.txt @@ -1,5 +1,5 @@ +[!fuzz] skip [short] skip -[!darwin] [!linux] [!windows] skip go test -fuzz=FuzzA -fuzztime=100x fuzz_setenv_test.go diff --git a/src/cmd/go/testdata/script/test_fuzz_unsupported.txt b/src/cmd/go/testdata/script/test_fuzz_unsupported.txt new file mode 100644 index 0000000000..1ed0b8a6f7 --- /dev/null +++ b/src/cmd/go/testdata/script/test_fuzz_unsupported.txt @@ -0,0 +1,18 @@ +[fuzz] skip + +! go test -fuzz=. -fuzztime=1x +! stdout . +stderr '^-fuzz flag is not supported on '$GOOS'/'$GOARCH'$' + +-- go.mod -- +module example + +go 1.18 +-- fuzz_test.go -- +package example + +import "testing" + +func FuzzTrivial(f *testing.F) { + f.Fuzz(func(t *testing.T, _ []byte) {}) +} diff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go index 473e390587..18ca50f927 100644 --- a/src/cmd/internal/sys/supported.go +++ b/src/cmd/internal/sys/supported.go @@ -45,6 +45,29 @@ func ASanSupported(goos, goarch string) bool { } } +// FuzzSupported reports whether goos/goarch supports fuzzing +// ('go test -fuzz=.'). +func FuzzSupported(goos, goarch string) bool { + switch goos { + case "darwin", "linux", "windows": + return true + default: + return false + } +} + +// FuzzInstrumented reports whether fuzzing on goos/goarch uses coverage +// instrumentation. (FuzzInstrumented implies FuzzSupported.) +func FuzzInstrumented(goos, goarch string) bool { + switch goarch { + case "amd64", "arm64": + // TODO(#14565): support more architectures. + return FuzzSupported(goos, goarch) + default: + return false + } +} + // MustLinkExternal reports whether goos/goarch requires external linking. // (This is the opposite of internal/testenv.CanInternalLink. Keep them in sync.) func MustLinkExternal(goos, goarch string) bool { diff --git a/src/internal/fuzz/counters_unsupported.go b/src/internal/fuzz/counters_unsupported.go index 9595cb93f7..bf28157068 100644 --- a/src/internal/fuzz/counters_unsupported.go +++ b/src/internal/fuzz/counters_unsupported.go @@ -2,6 +2,12 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// TODO: expand the set of supported platforms, with testing. Nothing about +// the instrumentation is OS specific, but only amd64 and arm64 are +// supported in the runtime. See src/runtime/libfuzzer*. +// +// If you update this constraint, also update cmd/internal/sys.FuzzInstrumeted. +// //go:build !((darwin || linux || windows || freebsd) && (amd64 || arm64)) package fuzz diff --git a/src/internal/fuzz/sys_unimplemented.go b/src/internal/fuzz/sys_unimplemented.go index 05954bb07f..123a32583c 100644 --- a/src/internal/fuzz/sys_unimplemented.go +++ b/src/internal/fuzz/sys_unimplemented.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// TODO(jayconrod): support more platforms. +// If you update this constraint, also update cmd/internal/sys.FuzzSupported. +// //go:build !darwin && !linux && !windows package fuzz From b9540246ba591e0ec5cd7cc1d6d62ab911ff9328 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 27 Oct 2021 16:31:18 -0400 Subject: [PATCH 226/406] cmd/go: disallow the -fuzz flag for tests outside the main module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Normally, when fuzzing identifies a failure it saves the failing input to the package's testdata directory. However, the testdata directory for packages outside the main module is normally not writable — and when it is, writing to a testdata directory inside the module cache would corrupt the checksum for that module (and permanently alter the behavior of that version of the module globally). In the future we could consider a flag to allow failures to be saved to an alternate location, or perhaps in the build cache; or, we could suppress writes entirely and rely on the user to identify and copy the failing input from the test log. However, it's a bit late in the cycle for that big a design decision right now. For Go 1.18, we will just enforce that the package to be fuzzed resides in the main module, which is typically a writable VCS checkout. Fixes #48495 Change-Id: I8d3d56372394b1aaa94fa920399c659363fa17fa Reviewed-on: https://go-review.googlesource.com/c/go/+/359414 Trust: Bryan C. Mills Trust: Katie Hockman Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Katie Hockman --- src/cmd/go/alldocs.go | 11 ++-- src/cmd/go/internal/test/test.go | 45 ++++++++++++-- .../mod/example.com_fuzzfail_v0.1.0.txt | 20 +++++++ .../mod/example.com_fuzzfail_v0.2.0.txt | 23 ++++++++ .../go/testdata/script/test_fuzz_modcache.txt | 58 +++++++++++++++++++ 5 files changed, 147 insertions(+), 10 deletions(-) create mode 100644 src/cmd/go/testdata/mod/example.com_fuzzfail_v0.1.0.txt create mode 100644 src/cmd/go/testdata/mod/example.com_fuzzfail_v0.2.0.txt create mode 100644 src/cmd/go/testdata/script/test_fuzz_modcache.txt diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 537f800944..1b9b22a812 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -2785,11 +2785,12 @@ // // -fuzz regexp // Run the fuzz target matching the regular expression. When specified, -// the command line argument must match exactly one package, and regexp -// must match exactly one fuzz target within that package. After tests, -// benchmarks, seed corpora of other fuzz targets, and examples have -// completed, the matching target will be fuzzed. See the Fuzzing section -// of the testing package documentation for details. +// the command line argument must match exactly one package within the +// main module, and regexp must match exactly one fuzz target within +// that package. After tests, benchmarks, seed corpora of other fuzz +// targets, and examples have completed, the matching target will be +// fuzzed. See the Fuzzing section of the testing package documentation +// for details. // // -fuzztime t // Run enough iterations of the fuzz test to take t, specified as a diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index 0806d29f21..c435cc3fb2 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -36,6 +36,8 @@ import ( "cmd/go/internal/work" "cmd/internal/sys" "cmd/internal/test2json" + + "golang.org/x/mod/module" ) // Break init loop. @@ -248,11 +250,12 @@ control the execution of any test: -fuzz regexp Run the fuzz target matching the regular expression. When specified, - the command line argument must match exactly one package, and regexp - must match exactly one fuzz target within that package. After tests, - benchmarks, seed corpora of other fuzz targets, and examples have - completed, the matching target will be fuzzed. See the Fuzzing section - of the testing package documentation for details. + the command line argument must match exactly one package within the + main module, and regexp must match exactly one fuzz target within + that package. After tests, benchmarks, seed corpora of other fuzz + targets, and examples have completed, the matching target will be + fuzzed. See the Fuzzing section of the testing package documentation + for details. -fuzztime t Run enough iterations of the fuzz test to take t, specified as a @@ -659,6 +662,38 @@ func runTest(ctx context.Context, cmd *base.Command, args []string) { if len(pkgs) != 1 { base.Fatalf("cannot use -fuzz flag with multiple packages") } + + // Reject the '-fuzz' flag if the package is outside the main module. + // Otherwise, if fuzzing identifies a failure it could corrupt checksums in + // the module cache (or permanently alter the behavior of std tests for all + // users) by writing the failing input to the package's testdata directory. + // (See https://golang.org/issue/48495 and test_fuzz_modcache.txt.) + mainMods := modload.MainModules + if m := pkgs[0].Module; m != nil && m.Path != "" { + if !mainMods.Contains(m.Path) { + base.Fatalf("cannot use -fuzz flag on package outside the main module") + } + } else if pkgs[0].Standard && modload.Enabled() { + // Because packages in 'std' and 'cmd' are part of the standard library, + // they are only treated as part of a module in 'go mod' subcommands and + // 'go get'. However, we still don't want to accidentally corrupt their + // testdata during fuzzing, nor do we want to fail with surprising errors + // if GOROOT isn't writable (as is often the case for Go toolchains + // installed through package managers). + // + // If the user is requesting to fuzz a standard-library package, ensure + // that they are in the same module as that package (just like when + // fuzzing any other package). + if strings.HasPrefix(pkgs[0].ImportPath, "cmd/") { + if !mainMods.Contains("cmd") || !mainMods.InGorootSrc(module.Version{Path: "cmd"}) { + base.Fatalf("cannot use -fuzz flag on package outside the main module") + } + } else { + if !mainMods.Contains("std") || !mainMods.InGorootSrc(module.Version{Path: "std"}) { + base.Fatalf("cannot use -fuzz flag on package outside the main module") + } + } + } } if testProfile() != "" && len(pkgs) != 1 { base.Fatalf("cannot use %s flag with multiple packages", testProfile()) diff --git a/src/cmd/go/testdata/mod/example.com_fuzzfail_v0.1.0.txt b/src/cmd/go/testdata/mod/example.com_fuzzfail_v0.1.0.txt new file mode 100644 index 0000000000..af005ffb41 --- /dev/null +++ b/src/cmd/go/testdata/mod/example.com_fuzzfail_v0.1.0.txt @@ -0,0 +1,20 @@ +-- .mod -- +module example.com/fuzzfail + +go 1.18 +-- .info -- +{"Version":"v0.1.0"} +-- go.mod -- +module example.com/fuzzfail + +go 1.18 +-- fuzzfail_test.go -- +package fuzzfail + +import "testing" + +func FuzzFail(f *testing.F) { + f.Fuzz(func(t *testing.T, b []byte) { + t.Fatalf("oops: %q", b) + }) +} diff --git a/src/cmd/go/testdata/mod/example.com_fuzzfail_v0.2.0.txt b/src/cmd/go/testdata/mod/example.com_fuzzfail_v0.2.0.txt new file mode 100644 index 0000000000..ea599aa611 --- /dev/null +++ b/src/cmd/go/testdata/mod/example.com_fuzzfail_v0.2.0.txt @@ -0,0 +1,23 @@ +-- .mod -- +module example.com/fuzzfail + +go 1.18 +-- .info -- +{"Version":"v0.2.0"} +-- go.mod -- +module example.com/fuzzfail + +go 1.18 +-- fuzzfail_test.go -- +package fuzzfail + +import "testing" + +func FuzzFail(f *testing.F) { + f.Fuzz(func(t *testing.T, b []byte) { + t.Fatalf("oops: %q", b) + }) +} +-- testdata/fuzz/FuzzFail/bbb0c2d22aa1a24617301566dc7486f8b625d38024603ba62757c1124013b49a -- +go test fuzz v1 +[]byte("\x05") diff --git a/src/cmd/go/testdata/script/test_fuzz_modcache.txt b/src/cmd/go/testdata/script/test_fuzz_modcache.txt new file mode 100644 index 0000000000..c0f18ea3c0 --- /dev/null +++ b/src/cmd/go/testdata/script/test_fuzz_modcache.txt @@ -0,0 +1,58 @@ +# This test demonstrates the fuzz corpus behavior for packages outside of the main module. +# (See https://golang.org/issue/48495.) + +[short] skip + +# Set -modcacherw so that the test behaves the same regardless of whether the +# module cache is writable. (For example, on some platforms it can always be +# written if the user is running as root.) At one point, a failing fuzz test +# in a writable module cache would corrupt module checksums in the cache. +env GOFLAGS=-modcacherw + + +# When the upstream module has no test corpus, running 'go test' should succeed, +# but 'go test -fuzz=.' should error out before running the test. +# (It should NOT corrupt the module cache by writing out new fuzz inputs, +# even if the cache is writable.) + +go get -t example.com/fuzzfail@v0.1.0 +go test example.com/fuzzfail + +! go test -fuzz=. example.com/fuzzfail +! stdout . +stderr '^cannot use -fuzz flag on package outside the main module$' + +go mod verify + + +# If the module does include a test corpus, 'go test' (without '-fuzz') should +# load that corpus and run the fuzz tests against it, but 'go test -fuzz=.' +# should continue to be rejected. + +go get -t example.com/fuzzfail@v0.2.0 + +! go test example.com/fuzzfail +stdout '^\s*fuzzfail_test\.go:7: oops:' + +! go test -fuzz=. example.com/fuzzfail +! stdout . +stderr '^cannot use -fuzz flag on package outside the main module$' + +go mod verify + + +# Packages in 'std' cannot be fuzzed when the corresponding GOROOT module is not +# the main module — either the failures would not be recorded or the behavior of +# the 'std' tests would change globally. + +! go test -fuzz . encoding/json +stderr '^cannot use -fuzz flag on package outside the main module$' + +! go test -fuzz . cmd/buildid +stderr '^cannot use -fuzz flag on package outside the main module$' + + +-- go.mod -- +module example.com/m + +go 1.18 From d0751b1ad8d7a68586dc7567cee44e0ce323f26f Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Thu, 28 Oct 2021 15:57:45 -0400 Subject: [PATCH 227/406] cmd/go: test with SIGTERM in test_fuzz_non_crash_signal The test currently uses only SIGKILL (which cannot be trapped by the worker process) and SIGILL (which is handled by the Go runtime, and does pretty unambiguously indicate a crash). It is missing a third (and perhaps more likely) case: a signal like SIGTERM that is handled by the Go runtime and causes the test to terminate, but nonetheless does not indicate a crash. Change-Id: I0595a0917e977e8eb2c24ae8b706d734ce3b2f4f Reviewed-on: https://go-review.googlesource.com/c/go/+/359482 Trust: Bryan C. Mills Trust: Katie Hockman Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Katie Hockman --- .../script/test_fuzz_non_crash_signal.txt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt b/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt index f1a4c6669f..31d54bcb70 100644 --- a/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt +++ b/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt @@ -10,6 +10,15 @@ ! exists testdata ! stdout unreachable ! stderr unreachable +stdout 'fuzzing process terminated by unexpected signal; no crash will be recorded: signal: terminated' + +# FuzzKill sends itself a signal that cannot be caught by the worker process +# and does not appear to be a crash. +# We should not save a crasher. +! go test -fuzz=FuzzKill +! exists testdata +! stdout unreachable +! stderr unreachable stdout 'fuzzing process terminated by unexpected signal; no crash will be recorded: signal: killed' # FuzzCrash sends itself a signal that looks like a crash. @@ -33,6 +42,17 @@ import ( ) func FuzzNonCrash(f *testing.F) { + f.Fuzz(func(*testing.T, bool) { + pid := syscall.Getpid() + if err := syscall.Kill(pid, syscall.SIGTERM); err != nil { + panic(err) + } + // signal may not be received immediately. Wait for it. + select{} + }) +} + +func FuzzKill(f *testing.F) { f.Fuzz(func(*testing.T, bool) { pid := syscall.Getpid() if err := syscall.Kill(pid, syscall.SIGKILL); err != nil { From af05d8be3d9dd566b2ce3ff5344258314f128ff6 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 28 Oct 2021 13:51:39 -0400 Subject: [PATCH 228/406] all: manual fixups for //go:build vs // +build Update many generators, also handle files that were not part of the standard build during 'go fix' in CL 344955. Fixes #41184. Change-Id: I1edc684e8101882dcd11f75c6745c266fccfe9e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/359476 Trust: Russ Cox Run-TryBot: Russ Cox Reviewed-by: Bryan C. Mills --- src/crypto/elliptic/gen_p256_table.go | 1 - src/internal/goarch/gengoarch.go | 3 +-- src/internal/goos/gengoos.go | 1 - src/internal/syscall/windows/exec_windows_test.go | 1 - src/internal/syscall/windows/mksyscall.go | 1 - src/internal/syscall/windows/registry/export_test.go | 1 - src/internal/syscall/windows/registry/key.go | 1 - src/internal/syscall/windows/registry/mksyscall.go | 1 - src/internal/syscall/windows/registry/registry_test.go | 1 - src/internal/syscall/windows/registry/syscall.go | 1 - src/internal/syscall/windows/registry/value.go | 1 - src/internal/syscall/windows/sysdll/sysdll.go | 1 - src/runtime/asan/asan.go | 3 --- src/runtime/mkduff.go | 2 -- src/runtime/mkpreempt.go | 1 - src/runtime/msan/msan.go | 3 --- src/runtime/wincallback.go | 1 - src/syscall/js/export_test.go | 1 - src/syscall/js/func.go | 1 - src/syscall/js/js.go | 1 - src/syscall/js/js_test.go | 1 - 21 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/crypto/elliptic/gen_p256_table.go b/src/crypto/elliptic/gen_p256_table.go index 54aafa2c38..367bd4b67d 100644 --- a/src/crypto/elliptic/gen_p256_table.go +++ b/src/crypto/elliptic/gen_p256_table.go @@ -26,7 +26,6 @@ func main() { // Generated by gen_p256_table.go. DO NOT EDIT. //go:build amd64 || arm64 -// +build amd64 arm64 package elliptic diff --git a/src/internal/goarch/gengoarch.go b/src/internal/goarch/gengoarch.go index d146cc5bc9..3c706e04ad 100644 --- a/src/internal/goarch/gengoarch.go +++ b/src/internal/goarch/gengoarch.go @@ -39,8 +39,7 @@ func main() { } var buf bytes.Buffer fmt.Fprintf(&buf, "// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.\n\n") - fmt.Fprintf(&buf, "//go:build %s\n", target) - fmt.Fprintf(&buf, "// +build %s\n\n", target) // must explicitly include target for bootstrapping purposes + fmt.Fprintf(&buf, "//go:build %s\n", target) // must explicitly include target for bootstrapping purposes fmt.Fprintf(&buf, "package goarch\n\n") fmt.Fprintf(&buf, "const GOARCH = `%s`\n\n", target) for _, goarch := range goarches { diff --git a/src/internal/goos/gengoos.go b/src/internal/goos/gengoos.go index f8ddfcc7ff..1b62503fd0 100644 --- a/src/internal/goos/gengoos.go +++ b/src/internal/goos/gengoos.go @@ -51,7 +51,6 @@ func main() { var buf bytes.Buffer fmt.Fprintf(&buf, "// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.\n\n") fmt.Fprintf(&buf, "//go:build %s\n", strings.Join(tags, " && ")) - fmt.Fprintf(&buf, "// +build %s\n\n", strings.Join(tags, ",")) fmt.Fprintf(&buf, "package goos\n\n") fmt.Fprintf(&buf, "const GOOS = `%s`\n\n", target) for _, goos := range gooses { diff --git a/src/internal/syscall/windows/exec_windows_test.go b/src/internal/syscall/windows/exec_windows_test.go index 0db626636e..3311da5474 100644 --- a/src/internal/syscall/windows/exec_windows_test.go +++ b/src/internal/syscall/windows/exec_windows_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package windows_test diff --git a/src/internal/syscall/windows/mksyscall.go b/src/internal/syscall/windows/mksyscall.go index 39f745db7a..81f08c627e 100644 --- a/src/internal/syscall/windows/mksyscall.go +++ b/src/internal/syscall/windows/mksyscall.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build generate -// +build generate package windows diff --git a/src/internal/syscall/windows/registry/export_test.go b/src/internal/syscall/windows/registry/export_test.go index d02d93f287..7f1ac70e8f 100644 --- a/src/internal/syscall/windows/registry/export_test.go +++ b/src/internal/syscall/windows/registry/export_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package registry diff --git a/src/internal/syscall/windows/registry/key.go b/src/internal/syscall/windows/registry/key.go index ebe73a2e02..ba5c292c5e 100644 --- a/src/internal/syscall/windows/registry/key.go +++ b/src/internal/syscall/windows/registry/key.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows // Package registry provides access to the Windows registry. // diff --git a/src/internal/syscall/windows/registry/mksyscall.go b/src/internal/syscall/windows/registry/mksyscall.go index 0a007df7cc..0e0b4210d5 100644 --- a/src/internal/syscall/windows/registry/mksyscall.go +++ b/src/internal/syscall/windows/registry/mksyscall.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build generate -// +build generate package registry diff --git a/src/internal/syscall/windows/registry/registry_test.go b/src/internal/syscall/windows/registry/registry_test.go index 69b84e1c4c..134b5450fc 100644 --- a/src/internal/syscall/windows/registry/registry_test.go +++ b/src/internal/syscall/windows/registry/registry_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package registry_test diff --git a/src/internal/syscall/windows/registry/syscall.go b/src/internal/syscall/windows/registry/syscall.go index bb61279361..cb315adade 100644 --- a/src/internal/syscall/windows/registry/syscall.go +++ b/src/internal/syscall/windows/registry/syscall.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package registry diff --git a/src/internal/syscall/windows/registry/value.go b/src/internal/syscall/windows/registry/value.go index e1fc99c40d..025574015f 100644 --- a/src/internal/syscall/windows/registry/value.go +++ b/src/internal/syscall/windows/registry/value.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package registry diff --git a/src/internal/syscall/windows/sysdll/sysdll.go b/src/internal/syscall/windows/sysdll/sysdll.go index 61b998e4cf..e79fd19edc 100644 --- a/src/internal/syscall/windows/sysdll/sysdll.go +++ b/src/internal/syscall/windows/sysdll/sysdll.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows // Package sysdll is an internal leaf package that records and reports // which Windows DLL names are used by Go itself. These DLLs are then diff --git a/src/runtime/asan/asan.go b/src/runtime/asan/asan.go index 40ebf96824..ac71466b71 100644 --- a/src/runtime/asan/asan.go +++ b/src/runtime/asan/asan.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build asan && linux && (arm64 || amd64) -// +build asan -// +build linux -// +build arm64 amd64 package asan diff --git a/src/runtime/mkduff.go b/src/runtime/mkduff.go index d05158975f..e8a85702c6 100644 --- a/src/runtime/mkduff.go +++ b/src/runtime/mkduff.go @@ -179,7 +179,6 @@ func copyARM64(w io.Writer) { func tagsPPC64x(w io.Writer) { fmt.Fprintln(w) fmt.Fprintln(w, "//go:build ppc64 || ppc64le") - fmt.Fprintln(w, "// +build ppc64 ppc64le") fmt.Fprintln(w) } @@ -207,7 +206,6 @@ func copyPPC64x(w io.Writer) { func tagsMIPS64x(w io.Writer) { fmt.Fprintln(w) fmt.Fprintln(w, "//go:build mips64 || mips64le") - fmt.Fprintln(w, "// +build mips64 mips64le") fmt.Fprintln(w) } diff --git a/src/runtime/mkpreempt.go b/src/runtime/mkpreempt.go index acfb518d10..d662e73813 100644 --- a/src/runtime/mkpreempt.go +++ b/src/runtime/mkpreempt.go @@ -123,7 +123,6 @@ func header(arch string) { if beLe[arch] { base := arch[:len(arch)-1] fmt.Fprintf(out, "//go:build %s || %sle\n", base, base) - fmt.Fprintf(out, "// +build %s %sle\n\n", base, base) } fmt.Fprintf(out, "#include \"go_asm.h\"\n") fmt.Fprintf(out, "#include \"textflag.h\"\n\n") diff --git a/src/runtime/msan/msan.go b/src/runtime/msan/msan.go index 9908a8ec22..f1bf4e1065 100644 --- a/src/runtime/msan/msan.go +++ b/src/runtime/msan/msan.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build msan && linux && (amd64 || arm64) -// +build msan -// +build linux -// +build amd64 arm64 package msan diff --git a/src/runtime/wincallback.go b/src/runtime/wincallback.go index ca9965979f..442a984708 100644 --- a/src/runtime/wincallback.go +++ b/src/runtime/wincallback.go @@ -22,7 +22,6 @@ func genasm386Amd64() { buf.WriteString(`// Code generated by wincallback.go using 'go generate'. DO NOT EDIT. //go:build 386 || amd64 -// +build 386 amd64 // runtime·callbackasm is called by external code to // execute Go implemented callback function. It is not diff --git a/src/syscall/js/export_test.go b/src/syscall/js/export_test.go index 4bd9c5d595..fb61daea7c 100644 --- a/src/syscall/js/export_test.go +++ b/src/syscall/js/export_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package js diff --git a/src/syscall/js/func.go b/src/syscall/js/func.go index dde1e68100..77fb9e66ca 100644 --- a/src/syscall/js/func.go +++ b/src/syscall/js/func.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm package js diff --git a/src/syscall/js/js.go b/src/syscall/js/js.go index 0da0ddfa0f..d80d5d63de 100644 --- a/src/syscall/js/js.go +++ b/src/syscall/js/js.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm // Package js gives access to the WebAssembly host environment when using the js/wasm architecture. // Its API is based on JavaScript semantics. diff --git a/src/syscall/js/js_test.go b/src/syscall/js/js_test.go index 8088a897f6..fa8c782459 100644 --- a/src/syscall/js/js_test.go +++ b/src/syscall/js/js_test.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build js && wasm -// +build js,wasm // To run these tests: // From 33c392f72d16163eb0795b3d61b2196ac21e1799 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Sun, 24 Oct 2021 14:11:07 +1100 Subject: [PATCH 229/406] reflect: add FieldByIndexErr This new function, although different in signature from other reflect functions, allows the caller to avoid the panic caused by nil embedded fields in calls to FieldByIndex. Fixes #48218 Change-Id: I447f135bb789148c27ae3f2f23dcf43094f4c1de Reviewed-on: https://go-review.googlesource.com/c/go/+/357962 Trust: Rob Pike Run-TryBot: Rob Pike TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/reflect/value.go | 27 ++++++++++++++++++++++++++- src/reflect/visiblefields_test.go | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/reflect/value.go b/src/reflect/value.go index 618d38893e..90edf8e31d 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -5,6 +5,7 @@ package reflect import ( + "errors" "internal/abi" "internal/goarch" "internal/itoa" @@ -1232,7 +1233,8 @@ func (v Value) Field(i int) Value { } // FieldByIndex returns the nested field corresponding to index. -// It panics if v's Kind is not struct. +// It panics if evaluation requires stepping through a nil +// pointer or a field that is not a struct. func (v Value) FieldByIndex(index []int) Value { if len(index) == 1 { return v.Field(index[0]) @@ -1252,6 +1254,29 @@ func (v Value) FieldByIndex(index []int) Value { return v } +// FieldByIndexErr returns the nested field corresponding to index. +// It returns an error if evaluation requires stepping through a nil +// pointer, but panics if it must step through a field that +// is not a struct. +func (v Value) FieldByIndexErr(index []int) (Value, error) { + if len(index) == 1 { + return v.Field(index[0]), nil + } + v.mustBe(Struct) + for i, x := range index { + if i > 0 { + if v.Kind() == Ptr && v.typ.Elem().Kind() == Struct { + if v.IsNil() { + return Value{}, errors.New("reflect: indirection through nil pointer to embedded struct field " + v.typ.Elem().Name()) + } + v = v.Elem() + } + } + v = v.Field(x) + } + return v, nil +} + // FieldByName returns the struct field with the given name. // It returns the zero Value if no field was found. // It panics if v's Kind is not struct. diff --git a/src/reflect/visiblefields_test.go b/src/reflect/visiblefields_test.go index 915bbee867..5ae322321b 100644 --- a/src/reflect/visiblefields_test.go +++ b/src/reflect/visiblefields_test.go @@ -6,6 +6,7 @@ package reflect_test import ( . "reflect" + "strings" "testing" ) @@ -328,3 +329,21 @@ func TestFields(t *testing.T) { }) } } + +// Must not panic with nil embedded pointer. +func TestFieldByIndexErr(t *testing.T) { + type A struct { + S string + } + type B struct { + *A + } + v := ValueOf(B{}) + _, err := v.FieldByIndexErr([]int{0, 0}) + if err == nil { + t.Fatal("expected error") + } + if !strings.Contains(err.Error(), "embedded struct field A") { + t.Fatal(err) + } +} From d3d8852d8997a6429cbd498138908e537869a6ef Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Sun, 24 Oct 2021 15:44:15 +1100 Subject: [PATCH 230/406] text/template: use reflect.Value.FieldByIndexErr to avoid a crash on a nil pointer as an embedded field. Fixes #48215 Change-Id: I214faa6e3cf08cdec1c01035e4bbca0900c6a408 Reviewed-on: https://go-review.googlesource.com/c/go/+/357963 Trust: Rob Pike Run-TryBot: Rob Pike TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/text/template/exec.go | 5 ++++- src/text/template/exec_test.go | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/text/template/exec.go b/src/text/template/exec.go index 7e44497530..c42cbb2ad3 100644 --- a/src/text/template/exec.go +++ b/src/text/template/exec.go @@ -635,10 +635,13 @@ func (s *state) evalField(dot reflect.Value, fieldName string, node parse.Node, case reflect.Struct: tField, ok := receiver.Type().FieldByName(fieldName) if ok { - field := receiver.FieldByIndex(tField.Index) + field, err := receiver.FieldByIndexErr(tField.Index) if !tField.IsExported() { s.errorf("%s is an unexported field of struct type %s", fieldName, typ) } + if err != nil { + s.errorf("%v", err) + } // If it's a function, we must call it. if hasArgs { s.errorf("%s has arguments but cannot be invoked as function", fieldName) diff --git a/src/text/template/exec_test.go b/src/text/template/exec_test.go index 9c0772945e..3c40aa901e 100644 --- a/src/text/template/exec_test.go +++ b/src/text/template/exec_test.go @@ -1787,3 +1787,26 @@ func TestIssue39807(t *testing.T) { wg.Wait() } + +// Issue 48215: embedded nil pointer causes panic. +// Fixed by adding FieldByIndexErr to the reflect package. +func TestIssue48215(t *testing.T) { + type A struct { + S string + } + type B struct { + *A + } + tmpl, err := New("").Parse(`{{ .S }}`) + if err != nil { + t.Fatal(err) + } + err = tmpl.Execute(io.Discard, B{}) + // We expect an error, not a panic. + if err == nil { + t.Fatal("did not get error for nil embedded struct") + } + if !strings.Contains(err.Error(), "reflect: indirection through nil pointer to embedded struct field A") { + t.Fatal(err) + } +} From 2c7cdec2a762108ae9231b7861c3689f4d23b58c Mon Sep 17 00:00:00 2001 From: Meng Zhuo Date: Thu, 28 Oct 2021 10:04:36 +0800 Subject: [PATCH 231/406] io: remove UTF8 specified document for RuneReader RuneReader is fine with UTF16 or any other character encoding Fixes #49178 Change-Id: I08a5ac205e095349d451d3b60411eaeebc3aa563 Reviewed-on: https://go-review.googlesource.com/c/go/+/359334 Trust: Meng Zhuo Reviewed-by: Meng Zhuo Reviewed-by: Ian Lance Taylor Reviewed-by: Rob Pike Run-TryBot: Meng Zhuo TryBot-Result: Go Bot --- src/io/io.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io/io.go b/src/io/io.go index ceac7ba7f8..5635392dfb 100644 --- a/src/io/io.go +++ b/src/io/io.go @@ -279,7 +279,7 @@ type ByteWriter interface { // RuneReader is the interface that wraps the ReadRune method. // -// ReadRune reads a single UTF-8 encoded Unicode character +// ReadRune reads a single encoded Unicode character // and returns the rune and its size in bytes. If no character is // available, err will be set. type RuneReader interface { From f2885263748364a2a7f4e0d47abd5095699cd39f Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Thu, 28 Oct 2021 22:25:02 -0400 Subject: [PATCH 232/406] cmd/go: test that the reserved paths "example" and "test" are not used Proposal #37641 reserved the paths "example" and "test" for end users, so no path beginning with either of those elements may be added to the standard library. (We are unlikely to add them by accident, but this test codifies the policy accepted in the proposal.) Fixes #37641 Change-Id: I999064180336c923d4918a1176c371b8f5666f8b Reviewed-on: https://go-review.googlesource.com/c/go/+/359576 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Dmitri Shuralyov --- src/cmd/go/testdata/script/list_reserved.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/cmd/go/testdata/script/list_reserved.txt diff --git a/src/cmd/go/testdata/script/list_reserved.txt b/src/cmd/go/testdata/script/list_reserved.txt new file mode 100644 index 0000000000..b9c5361492 --- /dev/null +++ b/src/cmd/go/testdata/script/list_reserved.txt @@ -0,0 +1,7 @@ +# https://golang.org/issue/37641: the paths "example" and "test" are reserved +# for end users, and must never exist in the standard library. + +go list example/... test/... +stderr 'go: warning: "example/..." matched no packages$' +stderr 'go: warning: "test/..." matched no packages$' +! stdout . From 3aecb3a8f7e1435c76003a20068c0208fd73649a Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Thu, 8 Jul 2021 21:42:01 +0000 Subject: [PATCH 233/406] runtime: fix sweep termination condition Currently, there is a chance that the sweep termination condition could flap, causing e.g. runtime.GC to return before all sweep work has not only been drained, but also completed. CL 307915 and CL 307916 attempted to fix this problem, but it is still possible that mheap_.sweepDrained is marked before any outstanding sweepers are accounted for in mheap_.sweepers, leaving a window in which a thread could observe isSweepDone as true before it actually was (and after some time it would revert to false, then true again, depending on the number of outstanding sweepers at that point). This change fixes the sweep termination condition by merging mheap_.sweepers and mheap_.sweepDrained into a single atomic value. This value is updated such that a new potential sweeper will increment the oustanding sweeper count iff there are still outstanding spans to be swept without an outstanding sweeper to pick them up. This design simplifies the sweep termination condition into a single atomic load and comparison and ensures the condition never flaps. Updates #46500. Fixes #45315. Change-Id: I6d69aff156b8d48428c4cc8cfdbf28be346dbf04 Reviewed-on: https://go-review.googlesource.com/c/go/+/333389 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Austin Clements --- src/runtime/mcentral.go | 91 +++++++------- src/runtime/mgc.go | 12 +- src/runtime/mgcsweep.go | 214 ++++++++++++++++++++++---------- src/runtime/mheap.go | 11 +- src/runtime/pprof/mprof_test.go | 11 -- 5 files changed, 208 insertions(+), 131 deletions(-) diff --git a/src/runtime/mcentral.go b/src/runtime/mcentral.go index 6013c94c69..0a871a611e 100644 --- a/src/runtime/mcentral.go +++ b/src/runtime/mcentral.go @@ -102,59 +102,62 @@ func (c *mcentral) cacheSpan() *mspan { spanBudget := 100 var s *mspan - sl := newSweepLocker() - sg := sl.sweepGen + var sl sweepLocker // Try partial swept spans first. + sg := mheap_.sweepgen if s = c.partialSwept(sg).pop(); s != nil { goto havespan } - // Now try partial unswept spans. - for ; spanBudget >= 0; spanBudget-- { - s = c.partialUnswept(sg).pop() - if s == nil { - break - } - if s, ok := sl.tryAcquire(s); ok { - // We got ownership of the span, so let's sweep it and use it. - s.sweep(true) - sl.dispose() - goto havespan - } - // We failed to get ownership of the span, which means it's being or - // has been swept by an asynchronous sweeper that just couldn't remove it - // from the unswept list. That sweeper took ownership of the span and - // responsibility for either freeing it to the heap or putting it on the - // right swept list. Either way, we should just ignore it (and it's unsafe - // for us to do anything else). - } - // Now try full unswept spans, sweeping them and putting them into the - // right list if we fail to get a span. - for ; spanBudget >= 0; spanBudget-- { - s = c.fullUnswept(sg).pop() - if s == nil { - break - } - if s, ok := sl.tryAcquire(s); ok { - // We got ownership of the span, so let's sweep it. - s.sweep(true) - // Check if there's any free space. - freeIndex := s.nextFreeIndex() - if freeIndex != s.nelems { - s.freeindex = freeIndex - sl.dispose() + sl = sweep.active.begin() + if sl.valid { + // Now try partial unswept spans. + for ; spanBudget >= 0; spanBudget-- { + s = c.partialUnswept(sg).pop() + if s == nil { + break + } + if s, ok := sl.tryAcquire(s); ok { + // We got ownership of the span, so let's sweep it and use it. + s.sweep(true) + sweep.active.end(sl) goto havespan } - // Add it to the swept list, because sweeping didn't give us any free space. - c.fullSwept(sg).push(s.mspan) + // We failed to get ownership of the span, which means it's being or + // has been swept by an asynchronous sweeper that just couldn't remove it + // from the unswept list. That sweeper took ownership of the span and + // responsibility for either freeing it to the heap or putting it on the + // right swept list. Either way, we should just ignore it (and it's unsafe + // for us to do anything else). + } + // Now try full unswept spans, sweeping them and putting them into the + // right list if we fail to get a span. + for ; spanBudget >= 0; spanBudget-- { + s = c.fullUnswept(sg).pop() + if s == nil { + break + } + if s, ok := sl.tryAcquire(s); ok { + // We got ownership of the span, so let's sweep it. + s.sweep(true) + // Check if there's any free space. + freeIndex := s.nextFreeIndex() + if freeIndex != s.nelems { + s.freeindex = freeIndex + sweep.active.end(sl) + goto havespan + } + // Add it to the swept list, because sweeping didn't give us any free space. + c.fullSwept(sg).push(s.mspan) + } + // See comment for partial unswept spans. + } + sweep.active.end(sl) + if trace.enabled { + traceGCSweepDone() + traceDone = true } - // See comment for partial unswept spans. - } - sl.dispose() - if trace.enabled { - traceGCSweepDone() - traceDone = true } // We failed to get a span from the mcentral so get one from mheap. diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 429b907322..e7c023919c 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -154,7 +154,7 @@ func gcinit() { throw("size of Workbuf is suboptimal") } // No sweep on the first cycle. - mheap_.sweepDrained = 1 + sweep.active.state.Store(sweepDrainedMask) // Initialize GC pacer state. // Use the environment variable GOGC for the initial gcPercent value. @@ -1022,8 +1022,10 @@ func gcMarkTermination(nextTriggerRatio float64) { // Those aren't tracked in any sweep lists, so we need to // count them against sweep completion until we ensure all // those spans have been forced out. - sl := newSweepLocker() - sl.blockCompletion() + sl := sweep.active.begin() + if !sl.valid { + throw("failed to set sweep barrier") + } systemstack(func() { startTheWorldWithSema(true) }) @@ -1050,7 +1052,7 @@ func gcMarkTermination(nextTriggerRatio float64) { }) // Now that we've swept stale spans in mcaches, they don't // count against unswept spans. - sl.dispose() + sweep.active.end(sl) // Print gctrace before dropping worldsema. As soon as we drop // worldsema another cycle could start and smash the stats @@ -1457,7 +1459,7 @@ func gcSweep(mode gcMode) { lock(&mheap_.lock) mheap_.sweepgen += 2 - mheap_.sweepDrained = 0 + sweep.active.reset() mheap_.pagesSwept.Store(0) mheap_.sweepArenas = mheap_.allArenas mheap_.reclaimIndex.Store(0) diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go index 9c7f9d340d..a431d8a2af 100644 --- a/src/runtime/mgcsweep.go +++ b/src/runtime/mgcsweep.go @@ -41,6 +41,10 @@ type sweepdata struct { nbgsweep uint32 npausesweep uint32 + // active tracks outstanding sweepers and the sweep + // termination condition. + active activeSweep + // centralIndex is the current unswept span class. // It represents an index into the mcentral span // sets. Accessed and updated via its load and @@ -116,6 +120,108 @@ func (h *mheap) nextSpanForSweep() *mspan { return nil } +const sweepDrainedMask = 1 << 31 + +// activeSweep is a type that captures whether sweeping +// is done, and whether there are any outstanding sweepers. +// +// Every potential sweeper must call begin() before they look +// for work, and end() after they've finished sweeping. +type activeSweep struct { + // state is divided into two parts. + // + // The top bit (masked by sweepDrainedMask) is a boolean + // value indicating whether all the sweep work has been + // drained from the queue. + // + // The rest of the bits are a counter, indicating the + // number of outstanding concurrent sweepers. + state atomic.Uint32 +} + +// begin registers a new sweeper. Returns a sweepLocker +// for acquiring spans for sweeping. Any outstanding sweeper blocks +// sweep termination. +// +// If the sweepLocker is invalid, the caller can be sure that all +// outstanding sweep work has been drained, so there is nothing left +// to sweep. Note that there may be sweepers currently running, so +// this does not indicate that all sweeping has completed. +// +// Even if the sweepLocker is invalid, its sweepGen is always valid. +func (a *activeSweep) begin() sweepLocker { + for { + state := a.state.Load() + if state&sweepDrainedMask != 0 { + return sweepLocker{mheap_.sweepgen, false} + } + if a.state.CompareAndSwap(state, state+1) { + return sweepLocker{mheap_.sweepgen, true} + } + } +} + +// end deregisters a sweeper. Must be called once for each time +// begin is called if the sweepLocker is valid. +func (a *activeSweep) end(sl sweepLocker) { + if sl.sweepGen != mheap_.sweepgen { + throw("sweeper left outstanding across sweep generations") + } + for { + state := a.state.Load() + if (state&^sweepDrainedMask)-1 >= sweepDrainedMask { + throw("mismatched begin/end of activeSweep") + } + if a.state.CompareAndSwap(state, state-1) { + if state != sweepDrainedMask { + return + } + if debug.gcpacertrace > 0 { + print("pacer: sweep done at heap size ", gcController.heapLive>>20, "MB; allocated ", (gcController.heapLive-mheap_.sweepHeapLiveBasis)>>20, "MB during sweep; swept ", mheap_.pagesSwept.Load(), " pages at ", mheap_.sweepPagesPerByte, " pages/byte\n") + } + return + } + } +} + +// markDrained marks the active sweep cycle as having drained +// all remaining work. This is safe to be called concurrently +// with all other methods of activeSweep, though may race. +// +// Returns true if this call was the one that actually performed +// the mark. +func (a *activeSweep) markDrained() bool { + for { + state := a.state.Load() + if state&sweepDrainedMask != 0 { + return false + } + if a.state.CompareAndSwap(state, state|sweepDrainedMask) { + return true + } + } +} + +// sweepers returns the current number of active sweepers. +func (a *activeSweep) sweepers() uint32 { + return a.state.Load() &^ sweepDrainedMask +} + +// isDone returns true if all sweep work has been drained and no more +// outstanding sweepers exist. That is, when the sweep phase is +// completely done. +func (a *activeSweep) isDone() bool { + return a.state.Load() == sweepDrainedMask +} + +// reset sets up the activeSweep for the next sweep cycle. +// +// The world must be stopped. +func (a *activeSweep) reset() { + assertWorldStopped() + a.state.Store(0) +} + // finishsweep_m ensures that all spans are swept. // // The world must be stopped. This ensures there are no sweeps in @@ -134,6 +240,15 @@ func finishsweep_m() { sweep.npausesweep++ } + // Make sure there aren't any outstanding sweepers left. + // At this point, with the world stopped, it means one of two + // things. Either we were able to preempt a sweeper, or that + // a sweeper didn't call sweep.active.end when it should have. + // Both cases indicate a bug, so throw. + if sweep.active.sweepers() != 0 { + throw("active sweepers found at start of mark phase") + } + // Reset all the unswept buffers, which should be empty. // Do this in sweep termination as opposed to mark termination // so that we can catch unswept spans and reclaim blocks as @@ -183,15 +298,11 @@ func bgsweep(c chan int) { } } -// sweepLocker acquires sweep ownership of spans and blocks sweep -// completion. +// sweepLocker acquires sweep ownership of spans. type sweepLocker struct { // sweepGen is the sweep generation of the heap. sweepGen uint32 - // blocking indicates that this tracker is blocking sweep - // completion, usually as a result of acquiring sweep - // ownership of at least one span. - blocking bool + valid bool } // sweepLocked represents sweep ownership of a span. @@ -199,22 +310,16 @@ type sweepLocked struct { *mspan } -func newSweepLocker() sweepLocker { - return sweepLocker{ - sweepGen: mheap_.sweepgen, - } -} - // tryAcquire attempts to acquire sweep ownership of span s. If it // successfully acquires ownership, it blocks sweep completion. func (l *sweepLocker) tryAcquire(s *mspan) (sweepLocked, bool) { + if !l.valid { + throw("use of invalid sweepLocker") + } // Check before attempting to CAS. if atomic.Load(&s.sweepgen) != l.sweepGen-2 { return sweepLocked{}, false } - // Add ourselves to sweepers before potentially taking - // ownership. - l.blockCompletion() // Attempt to acquire sweep ownership of s. if !atomic.Cas(&s.sweepgen, l.sweepGen-2, l.sweepGen-1) { return sweepLocked{}, false @@ -222,48 +327,22 @@ func (l *sweepLocker) tryAcquire(s *mspan) (sweepLocked, bool) { return sweepLocked{s}, true } -// blockCompletion blocks sweep completion without acquiring any -// specific spans. -func (l *sweepLocker) blockCompletion() { - if !l.blocking { - atomic.Xadd(&mheap_.sweepers, +1) - l.blocking = true - } -} - -func (l *sweepLocker) dispose() { - if !l.blocking { - return - } - // Decrement the number of active sweepers and if this is the - // last one, mark sweep as complete. - l.blocking = false - if atomic.Xadd(&mheap_.sweepers, -1) == 0 && atomic.Load(&mheap_.sweepDrained) != 0 { - l.sweepIsDone() - } -} - -func (l *sweepLocker) sweepIsDone() { - if debug.gcpacertrace > 0 { - print("pacer: sweep done at heap size ", gcController.heapLive>>20, "MB; allocated ", (gcController.heapLive-mheap_.sweepHeapLiveBasis)>>20, "MB during sweep; swept ", mheap_.pagesSwept.Load(), " pages at ", mheap_.sweepPagesPerByte, " pages/byte\n") - } -} - // sweepone sweeps some unswept heap span and returns the number of pages returned // to the heap, or ^uintptr(0) if there was nothing to sweep. func sweepone() uintptr { - _g_ := getg() + gp := getg() - // increment locks to ensure that the goroutine is not preempted + // Increment locks to ensure that the goroutine is not preempted // in the middle of sweep thus leaving the span in an inconsistent state for next GC - _g_.m.locks++ - if atomic.Load(&mheap_.sweepDrained) != 0 { - _g_.m.locks-- - return ^uintptr(0) - } + gp.m.locks++ + // TODO(austin): sweepone is almost always called in a loop; // lift the sweepLocker into its callers. - sl := newSweepLocker() + sl := sweep.active.begin() + if !sl.valid { + gp.m.locks-- + return ^uintptr(0) + } // Find a span to sweep. npages := ^uintptr(0) @@ -271,7 +350,7 @@ func sweepone() uintptr { for { s := mheap_.nextSpanForSweep() if s == nil { - noMoreWork = atomic.Cas(&mheap_.sweepDrained, 0, 1) + noMoreWork = sweep.active.markDrained() break } if state := s.state.get(); state != mSpanInUse { @@ -301,8 +380,7 @@ func sweepone() uintptr { break } } - - sl.dispose() + sweep.active.end(sl) if noMoreWork { // The sweep list is empty. There may still be @@ -331,7 +409,7 @@ func sweepone() uintptr { readyForScavenger() } - _g_.m.locks-- + gp.m.locks-- return npages } @@ -342,10 +420,7 @@ func sweepone() uintptr { // GC runs; to prevent that the caller must be non-preemptible or must // somehow block GC progress. func isSweepDone() bool { - // Check that all spans have at least begun sweeping and there - // are no active sweepers. If both are true, then all spans - // have finished sweeping. - return atomic.Load(&mheap_.sweepDrained) != 0 && atomic.Load(&mheap_.sweepers) == 0 + return sweep.active.isDone() } // Returns only when span s has been swept. @@ -359,16 +434,23 @@ func (s *mspan) ensureSwept() { throw("mspan.ensureSwept: m is not locked") } - sl := newSweepLocker() - // The caller must be sure that the span is a mSpanInUse span. - if s, ok := sl.tryAcquire(s); ok { - s.sweep(false) - sl.dispose() - return + // If this operation fails, then that means that there are + // no more spans to be swept. In this case, either s has already + // been swept, or is about to be acquired for sweeping and swept. + sl := sweep.active.begin() + if sl.valid { + // The caller must be sure that the span is a mSpanInUse span. + if s, ok := sl.tryAcquire(s); ok { + s.sweep(false) + sweep.active.end(sl) + return + } + sweep.active.end(sl) } - sl.dispose() - // unfortunate condition, and we don't have efficient means to wait + // Unfortunately we can't sweep the span ourselves. Somebody else + // got to it first. We don't have efficient means to wait, but that's + // OK, it will be swept fairly soon. for { spangen := atomic.Load(&s.sweepgen) if spangen == sl.sweepGen || spangen == sl.sweepGen+3 { diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index 0e7694aab7..4f32e888b2 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -65,9 +65,7 @@ type mheap struct { lock mutex pages pageAlloc // page allocation data structure - sweepgen uint32 // sweep generation, see comment in mspan; written during STW - sweepDrained uint32 // all spans are swept or are being swept - sweepers uint32 // number of active sweepone calls + sweepgen uint32 // sweep generation, see comment in mspan; written during STW // allspans is a slice of all mspans ever created. Each mspan // appears exactly once. @@ -815,7 +813,10 @@ func (h *mheap) reclaimChunk(arenas []arenaIdx, pageIdx, n uintptr) uintptr { n0 := n var nFreed uintptr - sl := newSweepLocker() + sl := sweep.active.begin() + if !sl.valid { + return 0 + } for n > 0 { ai := arenas[pageIdx/pagesPerArena] ha := h.arenas[ai.l1()][ai.l2()] @@ -861,7 +862,7 @@ func (h *mheap) reclaimChunk(arenas []arenaIdx, pageIdx, n uintptr) uintptr { pageIdx += uintptr(len(inUse) * 8) n -= uintptr(len(inUse) * 8) } - sl.dispose() + sweep.active.end(sl) if trace.enabled { unlock(&h.lock) // Account for pages scanned but not reclaimed. diff --git a/src/runtime/pprof/mprof_test.go b/src/runtime/pprof/mprof_test.go index b44b32aed2..ab8341d32f 100644 --- a/src/runtime/pprof/mprof_test.go +++ b/src/runtime/pprof/mprof_test.go @@ -85,17 +85,6 @@ func TestMemoryProfiler(t *testing.T) { runtime.GC() // materialize stats - // TODO(mknyszek): Fix #45315 and remove this extra call. - // - // Unfortunately, it's possible for the sweep termination condition - // to flap, so with just one runtime.GC call, a freed object could be - // missed, leading this test to fail. A second call reduces the chance - // of this happening to zero, because sweeping actually has to finish - // to move on to the next GC, during which nothing will happen. - // - // See #46500 for more details. - runtime.GC() - memoryProfilerRun++ tests := []struct { From 645d07819b2224ba4d759829443f7c6442162c69 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 13 May 2021 10:44:47 -0400 Subject: [PATCH 234/406] sync: add Mutex.TryLock, RWMutex.TryLock, RWMutex.TryRLock Use of these functions is almost (but not) always a bad idea. Very rarely they are necessary, and third-party implementations (using a mutex and an atomic word, say) cannot integrate as well with the race detector as implmentations in package sync itself. Fixes #45435. Change-Id: I0128ca48ef5e0a3b09c913f0f3a7ee5c56388000 Reviewed-on: https://go-review.googlesource.com/c/go/+/319769 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/sync/mutex.go | 15 ++++++++++ src/sync/mutex_test.go | 18 ++++++++++++ src/sync/rwmutex.go | 59 ++++++++++++++++++++++++++++++++++++++++ src/sync/rwmutex_test.go | 28 +++++++++++++++++++ 4 files changed, 120 insertions(+) diff --git a/src/sync/mutex.go b/src/sync/mutex.go index 3028552f74..9dd04d9470 100644 --- a/src/sync/mutex.go +++ b/src/sync/mutex.go @@ -81,6 +81,21 @@ func (m *Mutex) Lock() { m.lockSlow() } +// TryLock tries to lock m and reports whether it succeeded. +// +// Note that while correct uses of TryLock do exist, they are rare, +// and use of TryLock is often a sign of a deeper problem +// in a particular use of mutexes. +func (m *Mutex) TryLock() bool { + if atomic.CompareAndSwapInt32(&m.state, 0, mutexLocked) { + if race.Enabled { + race.Acquire(unsafe.Pointer(m)) + } + return true + } + return false +} + func (m *Mutex) lockSlow() { var waitStartTime int64 starving := false diff --git a/src/sync/mutex_test.go b/src/sync/mutex_test.go index 98c1bf2a5f..cca0986a30 100644 --- a/src/sync/mutex_test.go +++ b/src/sync/mutex_test.go @@ -60,6 +60,12 @@ func BenchmarkContendedSemaphore(b *testing.B) { func HammerMutex(m *Mutex, loops int, cdone chan bool) { for i := 0; i < loops; i++ { + if i%3 == 0 { + if m.TryLock() { + m.Unlock() + } + continue + } m.Lock() m.Unlock() } @@ -71,7 +77,19 @@ func TestMutex(t *testing.T) { t.Logf("got mutexrate %d expected 0", n) } defer runtime.SetMutexProfileFraction(0) + m := new(Mutex) + + m.Lock() + if m.TryLock() { + t.Fatalf("TryLock succeeded with mutex locked") + } + m.Unlock() + if !m.TryLock() { + t.Fatalf("TryLock failed with mutex unlocked") + } + m.Unlock() + c := make(chan bool) for i := 0; i < 10; i++ { go HammerMutex(m, 1000, c) diff --git a/src/sync/rwmutex.go b/src/sync/rwmutex.go index 3012b5548e..f0d4c9771a 100644 --- a/src/sync/rwmutex.go +++ b/src/sync/rwmutex.go @@ -68,6 +68,34 @@ func (rw *RWMutex) RLock() { } } +// TryRLock tries to lock rw for reading and reports whether it succeeded. +// +// Note that while correct uses of TryRLock do exist, they are rare, +// and use of TryRLock is often a sign of a deeper problem +// in a particular use of mutexes. +func (rw *RWMutex) TryRLock() bool { + if race.Enabled { + _ = rw.w.state + race.Disable() + } + for { + c := atomic.LoadInt32(&rw.readerCount) + if c < 0 { + if race.Enabled { + race.Enable() + } + return false + } + if atomic.CompareAndSwapInt32(&rw.readerCount, c, c+1) { + if race.Enabled { + race.Enable() + race.Acquire(unsafe.Pointer(&rw.readerSem)) + } + return true + } + } +} + // RUnlock undoes a single RLock call; // it does not affect other simultaneous readers. // It is a run-time error if rw is not locked for reading @@ -122,6 +150,37 @@ func (rw *RWMutex) Lock() { } } +// TryLock tries to lock rw for writing and reports whether it succeeded. +// +// Note that while correct uses of TryLock do exist, they are rare, +// and use of TryLock is often a sign of a deeper problem +// in a particular use of mutexes. +func (rw *RWMutex) TryLock() bool { + if race.Enabled { + _ = rw.w.state + race.Disable() + } + if !rw.w.TryLock() { + if race.Enabled { + race.Enable() + } + return false + } + if !atomic.CompareAndSwapInt32(&rw.readerCount, 0, -rwmutexMaxReaders) { + rw.w.Unlock() + if race.Enabled { + race.Enable() + } + return false + } + if race.Enabled { + race.Enable() + race.Acquire(unsafe.Pointer(&rw.readerSem)) + race.Acquire(unsafe.Pointer(&rw.writerSem)) + } + return true +} + // Unlock unlocks rw for writing. It is a run-time error if rw is // not locked for writing on entry to Unlock. // diff --git a/src/sync/rwmutex_test.go b/src/sync/rwmutex_test.go index c98e69fd07..dfbdd9bbee 100644 --- a/src/sync/rwmutex_test.go +++ b/src/sync/rwmutex_test.go @@ -108,6 +108,34 @@ func HammerRWMutex(gomaxprocs, numReaders, num_iterations int) { } func TestRWMutex(t *testing.T) { + var m RWMutex + + m.Lock() + if m.TryLock() { + t.Fatalf("TryLock succeeded with mutex locked") + } + if m.TryRLock() { + t.Fatalf("TryRLock succeeded with mutex locked") + } + m.Unlock() + + if !m.TryLock() { + t.Fatalf("TryLock failed with mutex unlocked") + } + m.Unlock() + + if !m.TryRLock() { + t.Fatalf("TryRLock failed with mutex unlocked") + } + if !m.TryRLock() { + t.Fatalf("TryRLock failed with mutex rlocked") + } + if m.TryLock() { + t.Fatalf("TryLock succeeded with mutex rlocked") + } + m.RUnlock() + m.RUnlock() + defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(-1)) n := 1000 if testing.Short() { From a88575d662a7e8e4fbb31bf139bcffc063e2a734 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 29 Oct 2021 01:18:24 +0000 Subject: [PATCH 235/406] Revert "cmd/go: remove support for -buildmode=shared" This reverts CL 359096. Updates #47788. Reason for revert: -buildmode=shared may have actually been working in a few very specific cases. We should not remove -buildmode=shared until we have implemented an alternative to support those few cases. Change-Id: Ia962b06abacc11f6f29fc29d092773be175e32f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/359575 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Russ Cox --- doc/go1.18.html | 7 - misc/cgo/testshared/overlaydir_test.go | 78 ++ misc/cgo/testshared/shared_test.go | 1080 +++++++++++++++++ misc/cgo/testshared/testdata/dep2/dep2.go | 15 + misc/cgo/testshared/testdata/dep3/dep3.go | 22 + misc/cgo/testshared/testdata/depBase/asm.s | 10 + misc/cgo/testshared/testdata/depBase/dep.go | 37 + misc/cgo/testshared/testdata/depBase/gccgo.go | 9 + misc/cgo/testshared/testdata/depBase/stubs.go | 9 + .../testshared/testdata/division/division.go | 17 + misc/cgo/testshared/testdata/exe/exe.go | 45 + misc/cgo/testshared/testdata/exe2/exe2.go | 8 + misc/cgo/testshared/testdata/exe3/exe3.go | 7 + misc/cgo/testshared/testdata/execgo/exe.go | 8 + .../testshared/testdata/explicit/explicit.go | 9 + .../testshared/testdata/gcdata/main/main.go | 37 + misc/cgo/testshared/testdata/gcdata/p/p.go | 7 + misc/cgo/testshared/testdata/global/main.go | 71 ++ .../testshared/testdata/globallib/global.go | 17 + misc/cgo/testshared/testdata/iface/main.go | 17 + misc/cgo/testshared/testdata/iface_a/a.go | 17 + misc/cgo/testshared/testdata/iface_b/b.go | 17 + misc/cgo/testshared/testdata/iface_i/i.go | 17 + .../testshared/testdata/implicit/implicit.go | 5 + .../testdata/implicitcmd/implicitcmd.go | 10 + misc/cgo/testshared/testdata/issue25065/a.go | 20 + .../testdata/issue30768/issue30768lib/lib.go | 11 + .../testshared/testdata/issue30768/x_test.go | 22 + .../cgo/testshared/testdata/issue39777/a/a.go | 9 + .../cgo/testshared/testdata/issue39777/b/b.go | 7 + .../cgo/testshared/testdata/issue44031/a/a.go | 9 + .../cgo/testshared/testdata/issue44031/b/b.go | 17 + .../testdata/issue44031/main/main.go | 20 + .../cgo/testshared/testdata/issue47837/a/a.go | 19 + .../testdata/issue47837/main/main.go | 14 + .../testshared/testdata/trivial/trivial.go | 9 + src/cmd/dist/test.go | 9 + src/cmd/go/alldocs.go | 9 + src/cmd/go/internal/help/helpdoc.go | 5 + src/cmd/go/internal/list/list.go | 3 +- src/cmd/go/internal/work/build.go | 3 + src/cmd/go/internal/work/init.go | 31 +- .../go/testdata/script/list_linkshared.txt | 16 + src/cmd/internal/sys/supported.go | 7 + 44 files changed, 1786 insertions(+), 30 deletions(-) create mode 100644 misc/cgo/testshared/overlaydir_test.go create mode 100644 misc/cgo/testshared/shared_test.go create mode 100644 misc/cgo/testshared/testdata/dep2/dep2.go create mode 100644 misc/cgo/testshared/testdata/dep3/dep3.go create mode 100644 misc/cgo/testshared/testdata/depBase/asm.s create mode 100644 misc/cgo/testshared/testdata/depBase/dep.go create mode 100644 misc/cgo/testshared/testdata/depBase/gccgo.go create mode 100644 misc/cgo/testshared/testdata/depBase/stubs.go create mode 100644 misc/cgo/testshared/testdata/division/division.go create mode 100644 misc/cgo/testshared/testdata/exe/exe.go create mode 100644 misc/cgo/testshared/testdata/exe2/exe2.go create mode 100644 misc/cgo/testshared/testdata/exe3/exe3.go create mode 100644 misc/cgo/testshared/testdata/execgo/exe.go create mode 100644 misc/cgo/testshared/testdata/explicit/explicit.go create mode 100644 misc/cgo/testshared/testdata/gcdata/main/main.go create mode 100644 misc/cgo/testshared/testdata/gcdata/p/p.go create mode 100644 misc/cgo/testshared/testdata/global/main.go create mode 100644 misc/cgo/testshared/testdata/globallib/global.go create mode 100644 misc/cgo/testshared/testdata/iface/main.go create mode 100644 misc/cgo/testshared/testdata/iface_a/a.go create mode 100644 misc/cgo/testshared/testdata/iface_b/b.go create mode 100644 misc/cgo/testshared/testdata/iface_i/i.go create mode 100644 misc/cgo/testshared/testdata/implicit/implicit.go create mode 100644 misc/cgo/testshared/testdata/implicitcmd/implicitcmd.go create mode 100644 misc/cgo/testshared/testdata/issue25065/a.go create mode 100644 misc/cgo/testshared/testdata/issue30768/issue30768lib/lib.go create mode 100644 misc/cgo/testshared/testdata/issue30768/x_test.go create mode 100644 misc/cgo/testshared/testdata/issue39777/a/a.go create mode 100644 misc/cgo/testshared/testdata/issue39777/b/b.go create mode 100644 misc/cgo/testshared/testdata/issue44031/a/a.go create mode 100644 misc/cgo/testshared/testdata/issue44031/b/b.go create mode 100644 misc/cgo/testshared/testdata/issue44031/main/main.go create mode 100644 misc/cgo/testshared/testdata/issue47837/a/a.go create mode 100644 misc/cgo/testshared/testdata/issue47837/main/main.go create mode 100644 misc/cgo/testshared/testdata/trivial/trivial.go create mode 100644 src/cmd/go/testdata/script/list_linkshared.txt diff --git a/doc/go1.18.html b/doc/go1.18.html index 875577fd10..6fe993d51b 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -90,13 +90,6 @@ Do not send CLs removing the interior tags from such phrases. package.

-

- The go command no longer supports -linkshared - and -buildmode=shared. - (shared building and linking has never worked in module mode or - when GOROOT is not writable.) -

-

TODO: complete this section, or delete if not needed

diff --git a/misc/cgo/testshared/overlaydir_test.go b/misc/cgo/testshared/overlaydir_test.go new file mode 100644 index 0000000000..eb587a2d44 --- /dev/null +++ b/misc/cgo/testshared/overlaydir_test.go @@ -0,0 +1,78 @@ +// Copyright 2019 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 shared_test + +import ( + "io" + "os" + "path/filepath" + "strings" +) + +// overlayDir makes a minimal-overhead copy of srcRoot in which new files may be added. +// +// TODO: Once we no longer need to support the misc module in GOPATH mode, +// factor this function out into a package to reduce duplication. +func overlayDir(dstRoot, srcRoot string) error { + dstRoot = filepath.Clean(dstRoot) + if err := os.MkdirAll(dstRoot, 0777); err != nil { + return err + } + + srcRoot, err := filepath.Abs(srcRoot) + if err != nil { + return err + } + + return filepath.Walk(srcRoot, func(srcPath string, info os.FileInfo, err error) error { + if err != nil || srcPath == srcRoot { + return err + } + + suffix := strings.TrimPrefix(srcPath, srcRoot) + for len(suffix) > 0 && suffix[0] == filepath.Separator { + suffix = suffix[1:] + } + dstPath := filepath.Join(dstRoot, suffix) + + perm := info.Mode() & os.ModePerm + if info.Mode()&os.ModeSymlink != 0 { + info, err = os.Stat(srcPath) + if err != nil { + return err + } + perm = info.Mode() & os.ModePerm + } + + // Always copy directories (don't symlink them). + // If we add a file in the overlay, we don't want to add it in the original. + if info.IsDir() { + return os.MkdirAll(dstPath, perm|0200) + } + + // If the OS supports symlinks, use them instead of copying bytes. + if err := os.Symlink(srcPath, dstPath); err == nil { + return nil + } + + // Otherwise, copy the bytes. + src, err := os.Open(srcPath) + if err != nil { + return err + } + defer src.Close() + + dst, err := os.OpenFile(dstPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm) + if err != nil { + return err + } + + _, err = io.Copy(dst, src) + if closeErr := dst.Close(); err == nil { + err = closeErr + } + return err + }) +} diff --git a/misc/cgo/testshared/shared_test.go b/misc/cgo/testshared/shared_test.go new file mode 100644 index 0000000000..672811fe0e --- /dev/null +++ b/misc/cgo/testshared/shared_test.go @@ -0,0 +1,1080 @@ +// Copyright 2015 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 shared_test + +import ( + "bufio" + "bytes" + "debug/elf" + "encoding/binary" + "flag" + "fmt" + "go/build" + "io" + "log" + "os" + "os/exec" + "path/filepath" + "regexp" + "runtime" + "sort" + "strings" + "testing" + "time" +) + +var gopathInstallDir, gorootInstallDir string + +// This is the smallest set of packages we can link into a shared +// library (runtime/cgo is built implicitly). +var minpkgs = []string{"runtime", "sync/atomic"} +var soname = "libruntime,sync-atomic.so" + +var testX = flag.Bool("testx", false, "if true, pass -x to 'go' subcommands invoked by the test") +var testWork = flag.Bool("testwork", false, "if true, log and do not delete the temporary working directory") + +// run runs a command and calls t.Errorf if it fails. +func run(t *testing.T, msg string, args ...string) { + runWithEnv(t, msg, nil, args...) +} + +// runWithEnv runs a command under the given environment and calls t.Errorf if it fails. +func runWithEnv(t *testing.T, msg string, env []string, args ...string) { + c := exec.Command(args[0], args[1:]...) + if len(env) != 0 { + c.Env = append(os.Environ(), env...) + } + if output, err := c.CombinedOutput(); err != nil { + t.Errorf("executing %s (%s) failed %s:\n%s", strings.Join(args, " "), msg, err, output) + } +} + +// goCmd invokes the go tool with the installsuffix set up by TestMain. It calls +// t.Fatalf if the command fails. +func goCmd(t *testing.T, args ...string) string { + newargs := []string{args[0]} + if *testX { + newargs = append(newargs, "-x") + } + newargs = append(newargs, args[1:]...) + c := exec.Command("go", newargs...) + stderr := new(strings.Builder) + c.Stderr = stderr + + if testing.Verbose() && t == nil { + fmt.Fprintf(os.Stderr, "+ go %s\n", strings.Join(args, " ")) + c.Stderr = os.Stderr + } + output, err := c.Output() + + if err != nil { + if t != nil { + t.Helper() + t.Fatalf("executing %s failed %v:\n%s", strings.Join(c.Args, " "), err, stderr) + } else { + // Panic instead of using log.Fatalf so that deferred cleanup may run in testMain. + log.Panicf("executing %s failed %v:\n%s", strings.Join(c.Args, " "), err, stderr) + } + } + if testing.Verbose() && t != nil { + t.Logf("go %s", strings.Join(args, " ")) + if stderr.Len() > 0 { + t.Logf("%s", stderr) + } + } + return string(bytes.TrimSpace(output)) +} + +// TestMain calls testMain so that the latter can use defer (TestMain exits with os.Exit). +func testMain(m *testing.M) (int, error) { + workDir, err := os.MkdirTemp("", "shared_test") + if err != nil { + return 0, err + } + if *testWork || testing.Verbose() { + fmt.Printf("+ mkdir -p %s\n", workDir) + } + if !*testWork { + defer os.RemoveAll(workDir) + } + + // Some tests need to edit the source in GOPATH, so copy this directory to a + // temporary directory and chdir to that. + gopath := filepath.Join(workDir, "gopath") + modRoot, err := cloneTestdataModule(gopath) + if err != nil { + return 0, err + } + if testing.Verbose() { + fmt.Printf("+ export GOPATH=%s\n", gopath) + fmt.Printf("+ cd %s\n", modRoot) + } + os.Setenv("GOPATH", gopath) + // Explicitly override GOBIN as well, in case it was set through a GOENV file. + os.Setenv("GOBIN", filepath.Join(gopath, "bin")) + os.Chdir(modRoot) + os.Setenv("PWD", modRoot) + + // The test also needs to install libraries into GOROOT/pkg, so copy the + // subset of GOROOT that we need. + // + // TODO(golang.org/issue/28553): Rework -buildmode=shared so that it does not + // need to write to GOROOT. + goroot := filepath.Join(workDir, "goroot") + if err := cloneGOROOTDeps(goroot); err != nil { + return 0, err + } + if testing.Verbose() { + fmt.Fprintf(os.Stderr, "+ export GOROOT=%s\n", goroot) + } + os.Setenv("GOROOT", goroot) + + myContext := build.Default + myContext.GOROOT = goroot + myContext.GOPATH = gopath + runtimeP, err := myContext.Import("runtime", ".", build.ImportComment) + if err != nil { + return 0, fmt.Errorf("import failed: %v", err) + } + gorootInstallDir = runtimeP.PkgTargetRoot + "_dynlink" + + // All tests depend on runtime being built into a shared library. Because + // that takes a few seconds, do it here and have all tests use the version + // built here. + goCmd(nil, append([]string{"install", "-buildmode=shared"}, minpkgs...)...) + + myContext.InstallSuffix = "_dynlink" + depP, err := myContext.Import("./depBase", ".", build.ImportComment) + if err != nil { + return 0, fmt.Errorf("import failed: %v", err) + } + if depP.PkgTargetRoot == "" { + gopathInstallDir = filepath.Dir(goCmd(nil, "list", "-buildmode=shared", "-f", "{{.Target}}", "./depBase")) + } else { + gopathInstallDir = filepath.Join(depP.PkgTargetRoot, "testshared") + } + return m.Run(), nil +} + +func TestMain(m *testing.M) { + log.SetFlags(log.Lshortfile) + flag.Parse() + + exitCode, err := testMain(m) + if err != nil { + log.Fatal(err) + } + os.Exit(exitCode) +} + +// cloneTestdataModule clones the packages from src/testshared into gopath. +// It returns the directory within gopath at which the module root is located. +func cloneTestdataModule(gopath string) (string, error) { + modRoot := filepath.Join(gopath, "src", "testshared") + if err := overlayDir(modRoot, "testdata"); err != nil { + return "", err + } + if err := os.WriteFile(filepath.Join(modRoot, "go.mod"), []byte("module testshared\n"), 0644); err != nil { + return "", err + } + return modRoot, nil +} + +// cloneGOROOTDeps copies (or symlinks) the portions of GOROOT/src and +// GOROOT/pkg relevant to this test into the given directory. +// It must be run from within the testdata module. +func cloneGOROOTDeps(goroot string) error { + oldGOROOT := strings.TrimSpace(goCmd(nil, "env", "GOROOT")) + if oldGOROOT == "" { + return fmt.Errorf("go env GOROOT returned an empty string") + } + + // Before we clone GOROOT, figure out which packages we need to copy over. + listArgs := []string{ + "list", + "-deps", + "-f", "{{if and .Standard (not .ForTest)}}{{.ImportPath}}{{end}}", + } + stdDeps := goCmd(nil, append(listArgs, minpkgs...)...) + testdataDeps := goCmd(nil, append(listArgs, "-test", "./...")...) + + pkgs := append(strings.Split(strings.TrimSpace(stdDeps), "\n"), + strings.Split(strings.TrimSpace(testdataDeps), "\n")...) + sort.Strings(pkgs) + var pkgRoots []string + for _, pkg := range pkgs { + parentFound := false + for _, prev := range pkgRoots { + if strings.HasPrefix(pkg, prev) { + // We will copy in the source for pkg when we copy in prev. + parentFound = true + break + } + } + if !parentFound { + pkgRoots = append(pkgRoots, pkg) + } + } + + gorootDirs := []string{ + "pkg/tool", + "pkg/include", + } + for _, pkg := range pkgRoots { + gorootDirs = append(gorootDirs, filepath.Join("src", pkg)) + } + + for _, dir := range gorootDirs { + if testing.Verbose() { + fmt.Fprintf(os.Stderr, "+ cp -r %s %s\n", filepath.Join(oldGOROOT, dir), filepath.Join(goroot, dir)) + } + if err := overlayDir(filepath.Join(goroot, dir), filepath.Join(oldGOROOT, dir)); err != nil { + return err + } + } + + return nil +} + +// The shared library was built at the expected location. +func TestSOBuilt(t *testing.T) { + _, err := os.Stat(filepath.Join(gorootInstallDir, soname)) + if err != nil { + t.Error(err) + } +} + +func hasDynTag(f *elf.File, tag elf.DynTag) bool { + ds := f.SectionByType(elf.SHT_DYNAMIC) + if ds == nil { + return false + } + d, err := ds.Data() + if err != nil { + return false + } + for len(d) > 0 { + var t elf.DynTag + switch f.Class { + case elf.ELFCLASS32: + t = elf.DynTag(f.ByteOrder.Uint32(d[0:4])) + d = d[8:] + case elf.ELFCLASS64: + t = elf.DynTag(f.ByteOrder.Uint64(d[0:8])) + d = d[16:] + } + if t == tag { + return true + } + } + return false +} + +// The shared library does not have relocations against the text segment. +func TestNoTextrel(t *testing.T) { + sopath := filepath.Join(gorootInstallDir, soname) + f, err := elf.Open(sopath) + if err != nil { + t.Fatal("elf.Open failed: ", err) + } + defer f.Close() + if hasDynTag(f, elf.DT_TEXTREL) { + t.Errorf("%s has DT_TEXTREL set", soname) + } +} + +// The shared library does not contain symbols called ".dup" +// (See golang.org/issue/14841.) +func TestNoDupSymbols(t *testing.T) { + sopath := filepath.Join(gorootInstallDir, soname) + f, err := elf.Open(sopath) + if err != nil { + t.Fatal("elf.Open failed: ", err) + } + defer f.Close() + syms, err := f.Symbols() + if err != nil { + t.Errorf("error reading symbols %v", err) + return + } + for _, s := range syms { + if s.Name == ".dup" { + t.Fatalf("%s contains symbol called .dup", sopath) + } + } +} + +// The install command should have created a "shlibname" file for the +// listed packages (and runtime/cgo, and math on arm) indicating the +// name of the shared library containing it. +func TestShlibnameFiles(t *testing.T) { + pkgs := append([]string{}, minpkgs...) + pkgs = append(pkgs, "runtime/cgo") + if runtime.GOARCH == "arm" { + pkgs = append(pkgs, "math") + } + for _, pkg := range pkgs { + shlibnamefile := filepath.Join(gorootInstallDir, pkg+".shlibname") + contentsb, err := os.ReadFile(shlibnamefile) + if err != nil { + t.Errorf("error reading shlibnamefile for %s: %v", pkg, err) + continue + } + contents := strings.TrimSpace(string(contentsb)) + if contents != soname { + t.Errorf("shlibnamefile for %s has wrong contents: %q", pkg, contents) + } + } +} + +// Is a given offset into the file contained in a loaded segment? +func isOffsetLoaded(f *elf.File, offset uint64) bool { + for _, prog := range f.Progs { + if prog.Type == elf.PT_LOAD { + if prog.Off <= offset && offset < prog.Off+prog.Filesz { + return true + } + } + } + return false +} + +func rnd(v int32, r int32) int32 { + if r <= 0 { + return v + } + v += r - 1 + c := v % r + if c < 0 { + c += r + } + v -= c + return v +} + +func readwithpad(r io.Reader, sz int32) ([]byte, error) { + data := make([]byte, rnd(sz, 4)) + _, err := io.ReadFull(r, data) + if err != nil { + return nil, err + } + data = data[:sz] + return data, nil +} + +type note struct { + name string + tag int32 + desc string + section *elf.Section +} + +// Read all notes from f. As ELF section names are not supposed to be special, one +// looks for a particular note by scanning all SHT_NOTE sections looking for a note +// with a particular "name" and "tag". +func readNotes(f *elf.File) ([]*note, error) { + var notes []*note + for _, sect := range f.Sections { + if sect.Type != elf.SHT_NOTE { + continue + } + r := sect.Open() + for { + var namesize, descsize, tag int32 + err := binary.Read(r, f.ByteOrder, &namesize) + if err != nil { + if err == io.EOF { + break + } + return nil, fmt.Errorf("read namesize failed: %v", err) + } + err = binary.Read(r, f.ByteOrder, &descsize) + if err != nil { + return nil, fmt.Errorf("read descsize failed: %v", err) + } + err = binary.Read(r, f.ByteOrder, &tag) + if err != nil { + return nil, fmt.Errorf("read type failed: %v", err) + } + name, err := readwithpad(r, namesize) + if err != nil { + return nil, fmt.Errorf("read name failed: %v", err) + } + desc, err := readwithpad(r, descsize) + if err != nil { + return nil, fmt.Errorf("read desc failed: %v", err) + } + notes = append(notes, ¬e{name: string(name), tag: tag, desc: string(desc), section: sect}) + } + } + return notes, nil +} + +func dynStrings(t *testing.T, path string, flag elf.DynTag) []string { + t.Helper() + f, err := elf.Open(path) + if err != nil { + t.Fatalf("elf.Open(%q) failed: %v", path, err) + } + defer f.Close() + dynstrings, err := f.DynString(flag) + if err != nil { + t.Fatalf("DynString(%s) failed on %s: %v", flag, path, err) + } + return dynstrings +} + +func AssertIsLinkedToRegexp(t *testing.T, path string, re *regexp.Regexp) { + t.Helper() + for _, dynstring := range dynStrings(t, path, elf.DT_NEEDED) { + if re.MatchString(dynstring) { + return + } + } + t.Errorf("%s is not linked to anything matching %v", path, re) +} + +func AssertIsLinkedTo(t *testing.T, path, lib string) { + t.Helper() + AssertIsLinkedToRegexp(t, path, regexp.MustCompile(regexp.QuoteMeta(lib))) +} + +func AssertHasRPath(t *testing.T, path, dir string) { + t.Helper() + for _, tag := range []elf.DynTag{elf.DT_RPATH, elf.DT_RUNPATH} { + for _, dynstring := range dynStrings(t, path, tag) { + for _, rpath := range strings.Split(dynstring, ":") { + if filepath.Clean(rpath) == filepath.Clean(dir) { + return + } + } + } + } + t.Errorf("%s does not have rpath %s", path, dir) +} + +// Build a trivial program that links against the shared runtime and check it runs. +func TestTrivialExecutable(t *testing.T) { + goCmd(t, "install", "-linkshared", "./trivial") + run(t, "trivial executable", "../../bin/trivial") + AssertIsLinkedTo(t, "../../bin/trivial", soname) + AssertHasRPath(t, "../../bin/trivial", gorootInstallDir) + checkSize(t, "../../bin/trivial", 100000) // it is 19K on linux/amd64, 100K should be enough +} + +// Build a trivial program in PIE mode that links against the shared runtime and check it runs. +func TestTrivialExecutablePIE(t *testing.T) { + goCmd(t, "build", "-buildmode=pie", "-o", "trivial.pie", "-linkshared", "./trivial") + run(t, "trivial executable", "./trivial.pie") + AssertIsLinkedTo(t, "./trivial.pie", soname) + AssertHasRPath(t, "./trivial.pie", gorootInstallDir) + checkSize(t, "./trivial.pie", 100000) // it is 19K on linux/amd64, 100K should be enough +} + +// Check that the file size does not exceed a limit. +func checkSize(t *testing.T, f string, limit int64) { + fi, err := os.Stat(f) + if err != nil { + t.Fatalf("stat failed: %v", err) + } + if sz := fi.Size(); sz > limit { + t.Errorf("file too large: got %d, want <= %d", sz, limit) + } +} + +// Build a division test program and check it runs. +func TestDivisionExecutable(t *testing.T) { + goCmd(t, "install", "-linkshared", "./division") + run(t, "division executable", "../../bin/division") +} + +// Build an executable that uses cgo linked against the shared runtime and check it +// runs. +func TestCgoExecutable(t *testing.T) { + goCmd(t, "install", "-linkshared", "./execgo") + run(t, "cgo executable", "../../bin/execgo") +} + +func checkPIE(t *testing.T, name string) { + f, err := elf.Open(name) + if err != nil { + t.Fatal("elf.Open failed: ", err) + } + defer f.Close() + if f.Type != elf.ET_DYN { + t.Errorf("%s has type %v, want ET_DYN", name, f.Type) + } + if hasDynTag(f, elf.DT_TEXTREL) { + t.Errorf("%s has DT_TEXTREL set", name) + } +} + +func TestTrivialPIE(t *testing.T) { + name := "trivial_pie" + goCmd(t, "build", "-buildmode=pie", "-o="+name, "./trivial") + defer os.Remove(name) + run(t, name, "./"+name) + checkPIE(t, name) +} + +func TestCgoPIE(t *testing.T) { + name := "cgo_pie" + goCmd(t, "build", "-buildmode=pie", "-o="+name, "./execgo") + defer os.Remove(name) + run(t, name, "./"+name) + checkPIE(t, name) +} + +// Build a GOPATH package into a shared library that links against the goroot runtime +// and an executable that links against both. +func TestGopathShlib(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") + shlib := goCmd(t, "list", "-f", "{{.Shlib}}", "-buildmode=shared", "-linkshared", "./depBase") + AssertIsLinkedTo(t, shlib, soname) + goCmd(t, "install", "-linkshared", "./exe") + AssertIsLinkedTo(t, "../../bin/exe", soname) + AssertIsLinkedTo(t, "../../bin/exe", filepath.Base(shlib)) + AssertHasRPath(t, "../../bin/exe", gorootInstallDir) + AssertHasRPath(t, "../../bin/exe", filepath.Dir(gopathInstallDir)) + // And check it runs. + run(t, "executable linked to GOPATH library", "../../bin/exe") +} + +// The shared library contains a note listing the packages it contains in a section +// that is not mapped into memory. +func testPkgListNote(t *testing.T, f *elf.File, note *note) { + if note.section.Flags != 0 { + t.Errorf("package list section has flags %v, want 0", note.section.Flags) + } + if isOffsetLoaded(f, note.section.Offset) { + t.Errorf("package list section contained in PT_LOAD segment") + } + if note.desc != "testshared/depBase\n" { + t.Errorf("incorrect package list %q, want %q", note.desc, "testshared/depBase\n") + } +} + +// The shared library contains a note containing the ABI hash that is mapped into +// memory and there is a local symbol called go.link.abihashbytes that points 16 +// bytes into it. +func testABIHashNote(t *testing.T, f *elf.File, note *note) { + if note.section.Flags != elf.SHF_ALLOC { + t.Errorf("abi hash section has flags %v, want SHF_ALLOC", note.section.Flags) + } + if !isOffsetLoaded(f, note.section.Offset) { + t.Errorf("abihash section not contained in PT_LOAD segment") + } + var hashbytes elf.Symbol + symbols, err := f.Symbols() + if err != nil { + t.Errorf("error reading symbols %v", err) + return + } + for _, sym := range symbols { + if sym.Name == "go.link.abihashbytes" { + hashbytes = sym + } + } + if hashbytes.Name == "" { + t.Errorf("no symbol called go.link.abihashbytes") + return + } + if elf.ST_BIND(hashbytes.Info) != elf.STB_LOCAL { + t.Errorf("%s has incorrect binding %v, want STB_LOCAL", hashbytes.Name, elf.ST_BIND(hashbytes.Info)) + } + if f.Sections[hashbytes.Section] != note.section { + t.Errorf("%s has incorrect section %v, want %s", hashbytes.Name, f.Sections[hashbytes.Section].Name, note.section.Name) + } + if hashbytes.Value-note.section.Addr != 16 { + t.Errorf("%s has incorrect offset into section %d, want 16", hashbytes.Name, hashbytes.Value-note.section.Addr) + } +} + +// A Go shared library contains a note indicating which other Go shared libraries it +// was linked against in an unmapped section. +func testDepsNote(t *testing.T, f *elf.File, note *note) { + if note.section.Flags != 0 { + t.Errorf("package list section has flags %v, want 0", note.section.Flags) + } + if isOffsetLoaded(f, note.section.Offset) { + t.Errorf("package list section contained in PT_LOAD segment") + } + // libdepBase.so just links against the lib containing the runtime. + if note.desc != soname { + t.Errorf("incorrect dependency list %q, want %q", note.desc, soname) + } +} + +// The shared library contains notes with defined contents; see above. +func TestNotes(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") + shlib := goCmd(t, "list", "-f", "{{.Shlib}}", "-buildmode=shared", "-linkshared", "./depBase") + f, err := elf.Open(shlib) + if err != nil { + t.Fatal(err) + } + defer f.Close() + notes, err := readNotes(f) + if err != nil { + t.Fatal(err) + } + pkgListNoteFound := false + abiHashNoteFound := false + depsNoteFound := false + for _, note := range notes { + if note.name != "Go\x00\x00" { + continue + } + switch note.tag { + case 1: // ELF_NOTE_GOPKGLIST_TAG + if pkgListNoteFound { + t.Error("multiple package list notes") + } + testPkgListNote(t, f, note) + pkgListNoteFound = true + case 2: // ELF_NOTE_GOABIHASH_TAG + if abiHashNoteFound { + t.Error("multiple abi hash notes") + } + testABIHashNote(t, f, note) + abiHashNoteFound = true + case 3: // ELF_NOTE_GODEPS_TAG + if depsNoteFound { + t.Error("multiple dependency list notes") + } + testDepsNote(t, f, note) + depsNoteFound = true + } + } + if !pkgListNoteFound { + t.Error("package list note not found") + } + if !abiHashNoteFound { + t.Error("abi hash note not found") + } + if !depsNoteFound { + t.Error("deps note not found") + } +} + +// Build a GOPATH package (depBase) into a shared library that links against the goroot +// runtime, another package (dep2) that links against the first, and an +// executable that links against dep2. +func TestTwoGopathShlibs(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./dep2") + goCmd(t, "install", "-linkshared", "./exe2") + run(t, "executable linked to GOPATH library", "../../bin/exe2") +} + +func TestThreeGopathShlibs(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./dep2") + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./dep3") + goCmd(t, "install", "-linkshared", "./exe3") + run(t, "executable linked to GOPATH library", "../../bin/exe3") +} + +// If gccgo is not available or not new enough, call t.Skip. +func requireGccgo(t *testing.T) { + t.Helper() + + gccgoName := os.Getenv("GCCGO") + if gccgoName == "" { + gccgoName = "gccgo" + } + gccgoPath, err := exec.LookPath(gccgoName) + if err != nil { + t.Skip("gccgo not found") + } + cmd := exec.Command(gccgoPath, "-dumpversion") + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("%s -dumpversion failed: %v\n%s", gccgoPath, err, output) + } + if string(output) < "5" { + t.Skipf("gccgo too old (%s)", strings.TrimSpace(string(output))) + } + + gomod, err := exec.Command("go", "env", "GOMOD").Output() + if err != nil { + t.Fatalf("go env GOMOD: %v", err) + } + if len(bytes.TrimSpace(gomod)) > 0 { + t.Skipf("gccgo not supported in module mode; see golang.org/issue/30344") + } +} + +// Build a GOPATH package into a shared library with gccgo and an executable that +// links against it. +func TestGoPathShlibGccgo(t *testing.T) { + requireGccgo(t) + + libgoRE := regexp.MustCompile("libgo.so.[0-9]+") + + goCmd(t, "install", "-compiler=gccgo", "-buildmode=shared", "-linkshared", "./depBase") + + // Run 'go list' after 'go install': with gccgo, we apparently don't know the + // shlib location until after we've installed it. + shlib := goCmd(t, "list", "-compiler=gccgo", "-buildmode=shared", "-linkshared", "-f", "{{.Shlib}}", "./depBase") + + AssertIsLinkedToRegexp(t, shlib, libgoRE) + goCmd(t, "install", "-compiler=gccgo", "-linkshared", "./exe") + AssertIsLinkedToRegexp(t, "../../bin/exe", libgoRE) + AssertIsLinkedTo(t, "../../bin/exe", filepath.Base(shlib)) + AssertHasRPath(t, "../../bin/exe", filepath.Dir(shlib)) + // And check it runs. + run(t, "gccgo-built", "../../bin/exe") +} + +// The gccgo version of TestTwoGopathShlibs: build a GOPATH package into a shared +// library with gccgo, another GOPATH package that depends on the first and an +// executable that links the second library. +func TestTwoGopathShlibsGccgo(t *testing.T) { + requireGccgo(t) + + libgoRE := regexp.MustCompile("libgo.so.[0-9]+") + + goCmd(t, "install", "-compiler=gccgo", "-buildmode=shared", "-linkshared", "./depBase") + goCmd(t, "install", "-compiler=gccgo", "-buildmode=shared", "-linkshared", "./dep2") + goCmd(t, "install", "-compiler=gccgo", "-linkshared", "./exe2") + + // Run 'go list' after 'go install': with gccgo, we apparently don't know the + // shlib location until after we've installed it. + dep2 := goCmd(t, "list", "-compiler=gccgo", "-buildmode=shared", "-linkshared", "-f", "{{.Shlib}}", "./dep2") + depBase := goCmd(t, "list", "-compiler=gccgo", "-buildmode=shared", "-linkshared", "-f", "{{.Shlib}}", "./depBase") + + AssertIsLinkedToRegexp(t, depBase, libgoRE) + AssertIsLinkedToRegexp(t, dep2, libgoRE) + AssertIsLinkedTo(t, dep2, filepath.Base(depBase)) + AssertIsLinkedToRegexp(t, "../../bin/exe2", libgoRE) + AssertIsLinkedTo(t, "../../bin/exe2", filepath.Base(dep2)) + AssertIsLinkedTo(t, "../../bin/exe2", filepath.Base(depBase)) + + // And check it runs. + run(t, "gccgo-built", "../../bin/exe2") +} + +// Testing rebuilding of shared libraries when they are stale is a bit more +// complicated that it seems like it should be. First, we make everything "old": but +// only a few seconds old, or it might be older than gc (or the runtime source) and +// everything will get rebuilt. Then define a timestamp slightly newer than this +// time, which is what we set the mtime to of a file to cause it to be seen as new, +// and finally another slightly even newer one that we can compare files against to +// see if they have been rebuilt. +var oldTime = time.Now().Add(-9 * time.Second) +var nearlyNew = time.Now().Add(-6 * time.Second) +var stampTime = time.Now().Add(-3 * time.Second) + +// resetFileStamps makes "everything" (bin, src, pkg from GOPATH and the +// test-specific parts of GOROOT) appear old. +func resetFileStamps() { + chtime := func(path string, info os.FileInfo, err error) error { + return os.Chtimes(path, oldTime, oldTime) + } + reset := func(path string) { + if err := filepath.Walk(path, chtime); err != nil { + log.Panicf("resetFileStamps failed: %v", err) + } + + } + reset("../../bin") + reset("../../pkg") + reset("../../src") + reset(gorootInstallDir) +} + +// touch changes path and returns a function that changes it back. +// It also sets the time of the file, so that we can see if it is rewritten. +func touch(t *testing.T, path string) (cleanup func()) { + t.Helper() + data, err := os.ReadFile(path) + if err != nil { + t.Fatal(err) + } + old := make([]byte, len(data)) + copy(old, data) + if bytes.HasPrefix(data, []byte("!\n")) { + // Change last digit of build ID. + // (Content ID in the new content-based build IDs.) + const marker = `build id "` + i := bytes.Index(data, []byte(marker)) + if i < 0 { + t.Fatal("cannot find build id in archive") + } + j := bytes.IndexByte(data[i+len(marker):], '"') + if j < 0 { + t.Fatal("cannot find build id in archive") + } + i += len(marker) + j - 1 + if data[i] == 'a' { + data[i] = 'b' + } else { + data[i] = 'a' + } + } else { + // assume it's a text file + data = append(data, '\n') + } + + // If the file is still a symlink from an overlay, delete it so that we will + // replace it with a regular file instead of overwriting the symlinked one. + fi, err := os.Lstat(path) + if err == nil && !fi.Mode().IsRegular() { + fi, err = os.Stat(path) + if err := os.Remove(path); err != nil { + t.Fatal(err) + } + } + if err != nil { + t.Fatal(err) + } + + // If we're replacing a symlink to a read-only file, make the new file + // user-writable. + perm := fi.Mode().Perm() | 0200 + + if err := os.WriteFile(path, data, perm); err != nil { + t.Fatal(err) + } + if err := os.Chtimes(path, nearlyNew, nearlyNew); err != nil { + t.Fatal(err) + } + return func() { + if err := os.WriteFile(path, old, perm); err != nil { + t.Fatal(err) + } + } +} + +// isNew returns if the path is newer than the time stamp used by touch. +func isNew(t *testing.T, path string) bool { + t.Helper() + fi, err := os.Stat(path) + if err != nil { + t.Fatal(err) + } + return fi.ModTime().After(stampTime) +} + +// Fail unless path has been rebuilt (i.e. is newer than the time stamp used by +// isNew) +func AssertRebuilt(t *testing.T, msg, path string) { + t.Helper() + if !isNew(t, path) { + t.Errorf("%s was not rebuilt (%s)", msg, path) + } +} + +// Fail if path has been rebuilt (i.e. is newer than the time stamp used by isNew) +func AssertNotRebuilt(t *testing.T, msg, path string) { + t.Helper() + if isNew(t, path) { + t.Errorf("%s was rebuilt (%s)", msg, path) + } +} + +func TestRebuilding(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") + goCmd(t, "install", "-linkshared", "./exe") + info := strings.Fields(goCmd(t, "list", "-buildmode=shared", "-linkshared", "-f", "{{.Target}} {{.Shlib}}", "./depBase")) + if len(info) != 2 { + t.Fatalf("go list failed to report Target and/or Shlib") + } + target := info[0] + shlib := info[1] + + // If the source is newer than both the .a file and the .so, both are rebuilt. + t.Run("newsource", func(t *testing.T) { + resetFileStamps() + cleanup := touch(t, "./depBase/dep.go") + defer func() { + cleanup() + goCmd(t, "install", "-linkshared", "./exe") + }() + goCmd(t, "install", "-linkshared", "./exe") + AssertRebuilt(t, "new source", target) + AssertRebuilt(t, "new source", shlib) + }) + + // If the .a file is newer than the .so, the .so is rebuilt (but not the .a) + t.Run("newarchive", func(t *testing.T) { + resetFileStamps() + AssertNotRebuilt(t, "new .a file before build", target) + goCmd(t, "list", "-linkshared", "-f={{.ImportPath}} {{.Stale}} {{.StaleReason}} {{.Target}}", "./depBase") + AssertNotRebuilt(t, "new .a file before build", target) + cleanup := touch(t, target) + defer func() { + cleanup() + goCmd(t, "install", "-v", "-linkshared", "./exe") + }() + goCmd(t, "install", "-v", "-linkshared", "./exe") + AssertNotRebuilt(t, "new .a file", target) + AssertRebuilt(t, "new .a file", shlib) + }) +} + +func appendFile(t *testing.T, path, content string) { + t.Helper() + f, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND, 0660) + if err != nil { + t.Fatalf("os.OpenFile failed: %v", err) + } + defer func() { + err := f.Close() + if err != nil { + t.Fatalf("f.Close failed: %v", err) + } + }() + _, err = f.WriteString(content) + if err != nil { + t.Fatalf("f.WriteString failed: %v", err) + } +} + +func createFile(t *testing.T, path, content string) { + t.Helper() + f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644) + if err != nil { + t.Fatalf("os.OpenFile failed: %v", err) + } + _, err = f.WriteString(content) + if closeErr := f.Close(); err == nil { + err = closeErr + } + if err != nil { + t.Fatalf("WriteString failed: %v", err) + } +} + +func TestABIChecking(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") + goCmd(t, "install", "-linkshared", "./exe") + + // If we make an ABI-breaking change to depBase and rebuild libp.so but not exe, + // exe will abort with a complaint on startup. + // This assumes adding an exported function breaks ABI, which is not true in + // some senses but suffices for the narrow definition of ABI compatibility the + // toolchain uses today. + resetFileStamps() + + createFile(t, "./depBase/break.go", "package depBase\nfunc ABIBreak() {}\n") + defer os.Remove("./depBase/break.go") + + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") + c := exec.Command("../../bin/exe") + output, err := c.CombinedOutput() + if err == nil { + t.Fatal("executing exe did not fail after ABI break") + } + scanner := bufio.NewScanner(bytes.NewReader(output)) + foundMsg := false + const wantPrefix = "abi mismatch detected between the executable and lib" + for scanner.Scan() { + if strings.HasPrefix(scanner.Text(), wantPrefix) { + foundMsg = true + break + } + } + if err = scanner.Err(); err != nil { + t.Errorf("scanner encountered error: %v", err) + } + if !foundMsg { + t.Fatalf("exe failed, but without line %q; got output:\n%s", wantPrefix, output) + } + + // Rebuilding exe makes it work again. + goCmd(t, "install", "-linkshared", "./exe") + run(t, "rebuilt exe", "../../bin/exe") + + // If we make a change which does not break ABI (such as adding an unexported + // function) and rebuild libdepBase.so, exe still works, even if new function + // is in a file by itself. + resetFileStamps() + createFile(t, "./depBase/dep2.go", "package depBase\nfunc noABIBreak() {}\n") + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./depBase") + run(t, "after non-ABI breaking change", "../../bin/exe") +} + +// If a package 'explicit' imports a package 'implicit', building +// 'explicit' into a shared library implicitly includes implicit in +// the shared library. Building an executable that imports both +// explicit and implicit builds the code from implicit into the +// executable rather than fetching it from the shared library. The +// link still succeeds and the executable still runs though. +func TestImplicitInclusion(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./explicit") + goCmd(t, "install", "-linkshared", "./implicitcmd") + run(t, "running executable linked against library that contains same package as it", "../../bin/implicitcmd") +} + +// Tests to make sure that the type fields of empty interfaces and itab +// fields of nonempty interfaces are unique even across modules, +// so that interface equality works correctly. +func TestInterface(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./iface_a") + // Note: iface_i gets installed implicitly as a dependency of iface_a. + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./iface_b") + goCmd(t, "install", "-linkshared", "./iface") + run(t, "running type/itab uniqueness tester", "../../bin/iface") +} + +// Access a global variable from a library. +func TestGlobal(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./globallib") + goCmd(t, "install", "-linkshared", "./global") + run(t, "global executable", "../../bin/global") + AssertIsLinkedTo(t, "../../bin/global", soname) + AssertHasRPath(t, "../../bin/global", gorootInstallDir) +} + +// Run a test using -linkshared of an installed shared package. +// Issue 26400. +func TestTestInstalledShared(t *testing.T) { + goCmd(t, "test", "-linkshared", "-test.short", "sync/atomic") +} + +// Test generated pointer method with -linkshared. +// Issue 25065. +func TestGeneratedMethod(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue25065") +} + +// Test use of shared library struct with generated hash function. +// Issue 30768. +func TestGeneratedHash(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue30768/issue30768lib") + goCmd(t, "test", "-linkshared", "./issue30768") +} + +// Test that packages can be added not in dependency order (here a depends on b, and a adds +// before b). This could happen with e.g. go build -buildmode=shared std. See issue 39777. +func TestPackageOrder(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue39777/a", "./issue39777/b") +} + +// Test that GC data are generated correctly by the linker when it needs a type defined in +// a shared library. See issue 39927. +func TestGCData(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./gcdata/p") + goCmd(t, "build", "-linkshared", "./gcdata/main") + runWithEnv(t, "running gcdata/main", []string{"GODEBUG=clobberfree=1"}, "./main") +} + +// Test that we don't decode type symbols from shared libraries (which has no data, +// causing panic). See issue 44031. +func TestIssue44031(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue44031/a") + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue44031/b") + goCmd(t, "run", "-linkshared", "./issue44031/main") +} + +// Test that we use a variable from shared libraries (which implement an +// interface in shared libraries.). A weak reference is used in the itab +// in main process. It can cause unreacheble panic. See issue 47873. +func TestIssue47873(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue47837/a") + goCmd(t, "run", "-linkshared", "./issue47837/main") +} diff --git a/misc/cgo/testshared/testdata/dep2/dep2.go b/misc/cgo/testshared/testdata/dep2/dep2.go new file mode 100644 index 0000000000..94f38cf507 --- /dev/null +++ b/misc/cgo/testshared/testdata/dep2/dep2.go @@ -0,0 +1,15 @@ +package dep2 + +import "testshared/depBase" + +var W int = 1 + +var hasProg depBase.HasProg + +type Dep2 struct { + depBase.Dep +} + +func G() int { + return depBase.F() + 1 +} diff --git a/misc/cgo/testshared/testdata/dep3/dep3.go b/misc/cgo/testshared/testdata/dep3/dep3.go new file mode 100644 index 0000000000..6b02ad2ee5 --- /dev/null +++ b/misc/cgo/testshared/testdata/dep3/dep3.go @@ -0,0 +1,22 @@ +package dep3 + +// The point of this test file is that it references a type from +// depBase that is also referenced in dep2, but dep2 is loaded by the +// linker before depBase (because it is earlier in the import list). +// There was a bug in the linker where it would not correctly read out +// the type data in this case and later crash. + +import ( + "testshared/dep2" + "testshared/depBase" +) + +type Dep3 struct { + dep depBase.Dep + dep2 dep2.Dep2 +} + +func D3() int { + var x Dep3 + return x.dep.X + x.dep2.X +} diff --git a/misc/cgo/testshared/testdata/depBase/asm.s b/misc/cgo/testshared/testdata/depBase/asm.s new file mode 100644 index 0000000000..0f1111f392 --- /dev/null +++ b/misc/cgo/testshared/testdata/depBase/asm.s @@ -0,0 +1,10 @@ +// Copyright 2014 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. + +// +build gc + +#include "textflag.h" + +TEXT ·ImplementedInAsm(SB),NOSPLIT,$0-0 + RET diff --git a/misc/cgo/testshared/testdata/depBase/dep.go b/misc/cgo/testshared/testdata/depBase/dep.go new file mode 100644 index 0000000000..e7cc7c81eb --- /dev/null +++ b/misc/cgo/testshared/testdata/depBase/dep.go @@ -0,0 +1,37 @@ +// Copyright 2016 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 depBase + +import ( + "os" + "reflect" +) + +var SlicePtr interface{} = &[]int{} + +var V int = 1 + +var HasMask []string = []string{"hi"} + +type HasProg struct { + array [1024]*byte +} + +type Dep struct { + X int +} + +func (d *Dep) Method() int { + // This code below causes various go.itab.* symbols to be generated in + // the shared library. Similar code in ../exe/exe.go results in + // exercising https://golang.org/issues/17594 + reflect.TypeOf(os.Stdout).Elem() + return 10 +} + +func F() int { + defer func() {}() + return V +} diff --git a/misc/cgo/testshared/testdata/depBase/gccgo.go b/misc/cgo/testshared/testdata/depBase/gccgo.go new file mode 100644 index 0000000000..2b02a1e83b --- /dev/null +++ b/misc/cgo/testshared/testdata/depBase/gccgo.go @@ -0,0 +1,9 @@ +// Copyright 2016 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. + +// +build gccgo + +package depBase + +func ImplementedInAsm() {} diff --git a/misc/cgo/testshared/testdata/depBase/stubs.go b/misc/cgo/testshared/testdata/depBase/stubs.go new file mode 100644 index 0000000000..c77953803b --- /dev/null +++ b/misc/cgo/testshared/testdata/depBase/stubs.go @@ -0,0 +1,9 @@ +// Copyright 2016 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. + +// +build gc + +package depBase + +func ImplementedInAsm() diff --git a/misc/cgo/testshared/testdata/division/division.go b/misc/cgo/testshared/testdata/division/division.go new file mode 100644 index 0000000000..bb5fc98460 --- /dev/null +++ b/misc/cgo/testshared/testdata/division/division.go @@ -0,0 +1,17 @@ +// Copyright 2017 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 main + +//go:noinline +func div(x, y uint32) uint32 { + return x / y +} + +func main() { + a := div(97, 11) + if a != 8 { + panic("FAIL") + } +} diff --git a/misc/cgo/testshared/testdata/exe/exe.go b/misc/cgo/testshared/testdata/exe/exe.go new file mode 100644 index 0000000000..ee95f97bc9 --- /dev/null +++ b/misc/cgo/testshared/testdata/exe/exe.go @@ -0,0 +1,45 @@ +package main + +import ( + "os" + "reflect" + "runtime" + + "testshared/depBase" +) + +// Having a function declared in the main package triggered +// golang.org/issue/18250 +func DeclaredInMain() { +} + +type C struct { +} + +func F() *C { + return nil +} + +var slicePtr interface{} = &[]int{} + +func main() { + defer depBase.ImplementedInAsm() + // This code below causes various go.itab.* symbols to be generated in + // the executable. Similar code in ../depBase/dep.go results in + // exercising https://golang.org/issues/17594 + reflect.TypeOf(os.Stdout).Elem() + runtime.GC() + depBase.V = depBase.F() + 1 + + var c *C + if reflect.TypeOf(F).Out(0) != reflect.TypeOf(c) { + panic("bad reflection results, see golang.org/issue/18252") + } + + sp := reflect.New(reflect.TypeOf(slicePtr).Elem()) + s := sp.Interface() + + if reflect.TypeOf(s) != reflect.TypeOf(slicePtr) { + panic("bad reflection results, see golang.org/issue/18729") + } +} diff --git a/misc/cgo/testshared/testdata/exe2/exe2.go b/misc/cgo/testshared/testdata/exe2/exe2.go new file mode 100644 index 0000000000..433f331e36 --- /dev/null +++ b/misc/cgo/testshared/testdata/exe2/exe2.go @@ -0,0 +1,8 @@ +package main + +import "testshared/dep2" + +func main() { + d := &dep2.Dep2{} + dep2.W = dep2.G() + 1 + d.Method() +} diff --git a/misc/cgo/testshared/testdata/exe3/exe3.go b/misc/cgo/testshared/testdata/exe3/exe3.go new file mode 100644 index 0000000000..533e3a9e3d --- /dev/null +++ b/misc/cgo/testshared/testdata/exe3/exe3.go @@ -0,0 +1,7 @@ +package main + +import "testshared/dep3" + +func main() { + dep3.D3() +} diff --git a/misc/cgo/testshared/testdata/execgo/exe.go b/misc/cgo/testshared/testdata/execgo/exe.go new file mode 100644 index 0000000000..0427be8bdf --- /dev/null +++ b/misc/cgo/testshared/testdata/execgo/exe.go @@ -0,0 +1,8 @@ +package main + +/* + */ +import "C" + +func main() { +} diff --git a/misc/cgo/testshared/testdata/explicit/explicit.go b/misc/cgo/testshared/testdata/explicit/explicit.go new file mode 100644 index 0000000000..af969fcb23 --- /dev/null +++ b/misc/cgo/testshared/testdata/explicit/explicit.go @@ -0,0 +1,9 @@ +package explicit + +import ( + "testshared/implicit" +) + +func E() int { + return implicit.I() +} diff --git a/misc/cgo/testshared/testdata/gcdata/main/main.go b/misc/cgo/testshared/testdata/gcdata/main/main.go new file mode 100644 index 0000000000..394862fd94 --- /dev/null +++ b/misc/cgo/testshared/testdata/gcdata/main/main.go @@ -0,0 +1,37 @@ +// Copyright 2020 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. + +// Test that GC data is generated correctly for global +// variables with types defined in a shared library. +// See issue 39927. + +// This test run under GODEBUG=clobberfree=1. The check +// *x[i] == 12345 depends on this debug mode to clobber +// the value if the object is freed prematurely. + +package main + +import ( + "fmt" + "runtime" + "testshared/gcdata/p" +) + +var x p.T + +func main() { + for i := range x { + x[i] = new(int) + *x[i] = 12345 + } + runtime.GC() + runtime.GC() + runtime.GC() + for i := range x { + if *x[i] != 12345 { + fmt.Printf("x[%d] == %d, want 12345\n", i, *x[i]) + panic("FAIL") + } + } +} diff --git a/misc/cgo/testshared/testdata/gcdata/p/p.go b/misc/cgo/testshared/testdata/gcdata/p/p.go new file mode 100644 index 0000000000..1fee75429e --- /dev/null +++ b/misc/cgo/testshared/testdata/gcdata/p/p.go @@ -0,0 +1,7 @@ +// Copyright 2020 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 p + +type T [10]*int diff --git a/misc/cgo/testshared/testdata/global/main.go b/misc/cgo/testshared/testdata/global/main.go new file mode 100644 index 0000000000..f43e7c3fb3 --- /dev/null +++ b/misc/cgo/testshared/testdata/global/main.go @@ -0,0 +1,71 @@ +// Copyright 2017 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 main + +import ( + "testshared/globallib" +) + +//go:noinline +func testLoop() { + for i, s := range globallib.Data { + if s != int64(i) { + panic("testLoop: mismatch") + } + } +} + +//go:noinline +func ptrData() *[1<<20 + 10]int64 { + return &globallib.Data +} + +//go:noinline +func testMediumOffset() { + for i, s := range globallib.Data[1<<16-2:] { + if s != int64(i)+1<<16-2 { + panic("testMediumOffset: index mismatch") + } + } + + x := globallib.Data[1<<16-1] + if x != 1<<16-1 { + panic("testMediumOffset: direct mismatch") + } + + y := &globallib.Data[1<<16-3] + if y != &ptrData()[1<<16-3] { + panic("testMediumOffset: address mismatch") + } +} + +//go:noinline +func testLargeOffset() { + for i, s := range globallib.Data[1<<20:] { + if s != int64(i)+1<<20 { + panic("testLargeOffset: index mismatch") + } + } + + x := globallib.Data[1<<20+1] + if x != 1<<20+1 { + panic("testLargeOffset: direct mismatch") + } + + y := &globallib.Data[1<<20+2] + if y != &ptrData()[1<<20+2] { + panic("testLargeOffset: address mismatch") + } +} + +func main() { + testLoop() + + // SSA rules commonly merge offsets into addresses. These + // tests access global data in different ways to try + // and exercise different SSA rules. + testMediumOffset() + testLargeOffset() +} diff --git a/misc/cgo/testshared/testdata/globallib/global.go b/misc/cgo/testshared/testdata/globallib/global.go new file mode 100644 index 0000000000..b4372a2e9e --- /dev/null +++ b/misc/cgo/testshared/testdata/globallib/global.go @@ -0,0 +1,17 @@ +// Copyright 2017 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 globallib + +// Data is large enough to that offsets into it do not fit into +// 16-bit or 20-bit immediates. Ideally we'd also try and overrun +// 32-bit immediates, but that requires the test machine to have +// too much memory. +var Data [1<<20 + 10]int64 + +func init() { + for i := range Data { + Data[i] = int64(i) + } +} diff --git a/misc/cgo/testshared/testdata/iface/main.go b/misc/cgo/testshared/testdata/iface/main.go new file mode 100644 index 0000000000..d26ebbcc9c --- /dev/null +++ b/misc/cgo/testshared/testdata/iface/main.go @@ -0,0 +1,17 @@ +// Copyright 2017 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 main + +import "testshared/iface_a" +import "testshared/iface_b" + +func main() { + if iface_a.F() != iface_b.F() { + panic("empty interfaces not equal") + } + if iface_a.G() != iface_b.G() { + panic("non-empty interfaces not equal") + } +} diff --git a/misc/cgo/testshared/testdata/iface_a/a.go b/misc/cgo/testshared/testdata/iface_a/a.go new file mode 100644 index 0000000000..e2cef1ecda --- /dev/null +++ b/misc/cgo/testshared/testdata/iface_a/a.go @@ -0,0 +1,17 @@ +// Copyright 2017 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 iface_a + +import "testshared/iface_i" + +//go:noinline +func F() interface{} { + return (*iface_i.T)(nil) +} + +//go:noinline +func G() iface_i.I { + return (*iface_i.T)(nil) +} diff --git a/misc/cgo/testshared/testdata/iface_b/b.go b/misc/cgo/testshared/testdata/iface_b/b.go new file mode 100644 index 0000000000..dd3e027b37 --- /dev/null +++ b/misc/cgo/testshared/testdata/iface_b/b.go @@ -0,0 +1,17 @@ +// Copyright 2017 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 iface_b + +import "testshared/iface_i" + +//go:noinline +func F() interface{} { + return (*iface_i.T)(nil) +} + +//go:noinline +func G() iface_i.I { + return (*iface_i.T)(nil) +} diff --git a/misc/cgo/testshared/testdata/iface_i/i.go b/misc/cgo/testshared/testdata/iface_i/i.go new file mode 100644 index 0000000000..31c80387c7 --- /dev/null +++ b/misc/cgo/testshared/testdata/iface_i/i.go @@ -0,0 +1,17 @@ +// Copyright 2017 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 iface_i + +type I interface { + M() +} + +type T struct { +} + +func (t *T) M() { +} + +// *T implements I diff --git a/misc/cgo/testshared/testdata/implicit/implicit.go b/misc/cgo/testshared/testdata/implicit/implicit.go new file mode 100644 index 0000000000..5360188c56 --- /dev/null +++ b/misc/cgo/testshared/testdata/implicit/implicit.go @@ -0,0 +1,5 @@ +package implicit + +func I() int { + return 42 +} diff --git a/misc/cgo/testshared/testdata/implicitcmd/implicitcmd.go b/misc/cgo/testshared/testdata/implicitcmd/implicitcmd.go new file mode 100644 index 0000000000..4d4296738e --- /dev/null +++ b/misc/cgo/testshared/testdata/implicitcmd/implicitcmd.go @@ -0,0 +1,10 @@ +package main + +import ( + "testshared/explicit" + "testshared/implicit" +) + +func main() { + println(implicit.I() + explicit.E()) +} diff --git a/misc/cgo/testshared/testdata/issue25065/a.go b/misc/cgo/testshared/testdata/issue25065/a.go new file mode 100644 index 0000000000..979350ff24 --- /dev/null +++ b/misc/cgo/testshared/testdata/issue25065/a.go @@ -0,0 +1,20 @@ +// Copyright 2018 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 issue25065 has a type with a method that is +// 1) referenced in a method expression +// 2) not called +// 3) not converted to an interface +// 4) is a value method but the reference is to the pointer method +// These cases avoid the call to makefuncsym from typecheckfunc, but we +// still need to call makefuncsym somehow or the symbol will not be defined. +package issue25065 + +type T int + +func (t T) M() {} + +func F() func(*T) { + return (*T).M +} diff --git a/misc/cgo/testshared/testdata/issue30768/issue30768lib/lib.go b/misc/cgo/testshared/testdata/issue30768/issue30768lib/lib.go new file mode 100644 index 0000000000..9e45ebe683 --- /dev/null +++ b/misc/cgo/testshared/testdata/issue30768/issue30768lib/lib.go @@ -0,0 +1,11 @@ +// Copyright 2019 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 issue30768lib + +// S is a struct that requires a generated hash function. +type S struct { + A string + B int +} diff --git a/misc/cgo/testshared/testdata/issue30768/x_test.go b/misc/cgo/testshared/testdata/issue30768/x_test.go new file mode 100644 index 0000000000..1bbd139d3e --- /dev/null +++ b/misc/cgo/testshared/testdata/issue30768/x_test.go @@ -0,0 +1,22 @@ +// Copyright 2019 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 issue30768_test + +import ( + "testing" + + "testshared/issue30768/issue30768lib" +) + +type s struct { + s issue30768lib.S +} + +func Test30768(t *testing.T) { + // Calling t.Log will convert S to an empty interface, + // which will force a reference to the generated hash function, + // defined in the shared library. + t.Log(s{}) +} diff --git a/misc/cgo/testshared/testdata/issue39777/a/a.go b/misc/cgo/testshared/testdata/issue39777/a/a.go new file mode 100644 index 0000000000..c7bf835951 --- /dev/null +++ b/misc/cgo/testshared/testdata/issue39777/a/a.go @@ -0,0 +1,9 @@ +// Copyright 2020 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 a + +import "testshared/issue39777/b" + +func F() { b.F() } diff --git a/misc/cgo/testshared/testdata/issue39777/b/b.go b/misc/cgo/testshared/testdata/issue39777/b/b.go new file mode 100644 index 0000000000..4e681965e6 --- /dev/null +++ b/misc/cgo/testshared/testdata/issue39777/b/b.go @@ -0,0 +1,7 @@ +// Copyright 2020 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 b + +func F() {} diff --git a/misc/cgo/testshared/testdata/issue44031/a/a.go b/misc/cgo/testshared/testdata/issue44031/a/a.go new file mode 100644 index 0000000000..48827e682f --- /dev/null +++ b/misc/cgo/testshared/testdata/issue44031/a/a.go @@ -0,0 +1,9 @@ +// Copyright 2021 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 a + +type ATypeWithALoooooongName interface { // a long name, so the type descriptor symbol name is mangled + M() +} diff --git a/misc/cgo/testshared/testdata/issue44031/b/b.go b/misc/cgo/testshared/testdata/issue44031/b/b.go new file mode 100644 index 0000000000..ad3ebec2b9 --- /dev/null +++ b/misc/cgo/testshared/testdata/issue44031/b/b.go @@ -0,0 +1,17 @@ +// Copyright 2021 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 b + +import "testshared/issue44031/a" + +type T int + +func (T) M() {} + +var i = a.ATypeWithALoooooongName(T(0)) + +func F() { + i.M() +} diff --git a/misc/cgo/testshared/testdata/issue44031/main/main.go b/misc/cgo/testshared/testdata/issue44031/main/main.go new file mode 100644 index 0000000000..47f2e3a98e --- /dev/null +++ b/misc/cgo/testshared/testdata/issue44031/main/main.go @@ -0,0 +1,20 @@ +// Copyright 2021 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 main + +import "testshared/issue44031/b" + +type t int + +func (t) m() {} + +type i interface{ m() } // test that unexported method is correctly marked + +var v interface{} = t(0) + +func main() { + b.F() + v.(i).m() +} diff --git a/misc/cgo/testshared/testdata/issue47837/a/a.go b/misc/cgo/testshared/testdata/issue47837/a/a.go new file mode 100644 index 0000000000..68588eda2f --- /dev/null +++ b/misc/cgo/testshared/testdata/issue47837/a/a.go @@ -0,0 +1,19 @@ +// Copyright 2021 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 a + +type A interface { + M() +} + +//go:noinline +func TheFuncWithArgA(a A) { + a.M() +} + +type ImplA struct{} + +//go:noinline +func (A *ImplA) M() {} diff --git a/misc/cgo/testshared/testdata/issue47837/main/main.go b/misc/cgo/testshared/testdata/issue47837/main/main.go new file mode 100644 index 0000000000..77c6f34379 --- /dev/null +++ b/misc/cgo/testshared/testdata/issue47837/main/main.go @@ -0,0 +1,14 @@ +// Copyright 2021 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 main + +import ( + "testshared/issue47837/a" +) + +func main() { + var vara a.ImplA + a.TheFuncWithArgA(&vara) +} diff --git a/misc/cgo/testshared/testdata/trivial/trivial.go b/misc/cgo/testshared/testdata/trivial/trivial.go new file mode 100644 index 0000000000..6ade47ce36 --- /dev/null +++ b/misc/cgo/testshared/testdata/trivial/trivial.go @@ -0,0 +1,9 @@ +package main + +func main() { + // This is enough to make sure that the executable references + // a type descriptor, which was the cause of + // https://golang.org/issue/25970. + c := make(chan int) + _ = c +} diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index 87238cc74f..5935011e19 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -762,6 +762,9 @@ func (t *tester) registerTests() { if t.supportedBuildmode("c-shared") { t.registerHostTest("testcshared", "../misc/cgo/testcshared", "misc/cgo/testcshared", ".") } + if t.supportedBuildmode("shared") { + t.registerTest("testshared", "../misc/cgo/testshared", t.goTest(), t.timeout(600), ".") + } if t.supportedBuildmode("plugin") { t.registerTest("testplugin", "../misc/cgo/testplugin", t.goTest(), t.timeout(600), ".") } @@ -1044,6 +1047,12 @@ func (t *tester) supportedBuildmode(mode string) bool { return true } return false + case "shared": + switch pair { + case "linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-s390x": + return true + } + return false case "plugin": // linux-arm64 is missing because it causes the external linker // to crash, see https://golang.org/issue/17138 diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 1b9b22a812..487a8f580b 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -162,6 +162,9 @@ // flags has a similar effect. // -ldflags '[pattern=]arg list' // arguments to pass on each go tool link invocation. +// -linkshared +// build code that will be linked against shared libraries previously +// created with -buildmode=shared. // -mod mode // module download mode to use: readonly, vendor, or mod. // By default, if a vendor directory is present and the go version in go.mod @@ -779,6 +782,7 @@ // Name string // package name // Doc string // package documentation string // Target string // install path +// Shlib string // the shared library that contains this package (only set when -linkshared) // Goroot bool // is this package in the Go root? // Standard bool // is this package part of the standard Go library? // Stale bool // would 'go install' do anything for this package? @@ -1799,6 +1803,11 @@ // non-main packages are built into .a files (the default // behavior). // +// -buildmode=shared +// Combine all the listed non-main packages into a single shared +// library that will be used when building with the -linkshared +// option. Packages named main are ignored. +// // -buildmode=exe // Build the listed main packages and everything they import into // executables. Packages not named main are ignored. diff --git a/src/cmd/go/internal/help/helpdoc.go b/src/cmd/go/internal/help/helpdoc.go index 2bb3584eba..035235fe1b 100644 --- a/src/cmd/go/internal/help/helpdoc.go +++ b/src/cmd/go/internal/help/helpdoc.go @@ -726,6 +726,11 @@ are: non-main packages are built into .a files (the default behavior). + -buildmode=shared + Combine all the listed non-main packages into a single shared + library that will be used when building with the -linkshared + option. Packages named main are ignored. + -buildmode=exe Build the listed main packages and everything they import into executables. Packages not named main are ignored. diff --git a/src/cmd/go/internal/list/list.go b/src/cmd/go/internal/list/list.go index f23fbe5fea..8c85ddcf21 100644 --- a/src/cmd/go/internal/list/list.go +++ b/src/cmd/go/internal/list/list.go @@ -23,8 +23,8 @@ import ( "cmd/go/internal/load" "cmd/go/internal/modinfo" "cmd/go/internal/modload" - "cmd/go/internal/str" "cmd/go/internal/work" + "cmd/go/internal/str" ) var CmdList = &base.Command{ @@ -56,6 +56,7 @@ to -f '{{.ImportPath}}'. The struct being passed to the template is: Name string // package name Doc string // package documentation string Target string // install path + Shlib string // the shared library that contains this package (only set when -linkshared) Goroot bool // is this package in the Go root? Standard bool // is this package part of the standard Go library? Stale bool // would 'go install' do anything for this package? diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index e39ffcbd50..9d0ad27f0d 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -116,6 +116,9 @@ and test commands: flags has a similar effect. -ldflags '[pattern=]arg list' arguments to pass on each go tool link invocation. + -linkshared + build code that will be linked against shared libraries previously + created with -buildmode=shared. -mod mode module download mode to use: readonly, vendor, or mod. By default, if a vendor directory is present and the go version in go.mod diff --git a/src/cmd/go/internal/work/init.go b/src/cmd/go/internal/work/init.go index 9111150233..dc368de1c1 100644 --- a/src/cmd/go/internal/work/init.go +++ b/src/cmd/go/internal/work/init.go @@ -233,20 +233,16 @@ func buildModeInit() { } ldBuildmode = "pie" case "shared": - if cfg.Goos == "linux" { - switch cfg.Goarch { - case "386", "amd64", "arm", "arm64", "ppc64le", "s390x": - // -buildmode=shared was supported on these platforms at one point, but - // never really worked in module mode. - // Support was officially dropped as of Go 1.18. - // (See https://golang.org/issue/47788.) - base.Fatalf("-buildmode=shared no longer supported as of Go 1.18") - - // TODO(#47788): Remove supporting code for -buildmode=shared. - // (For the Go 1.18 release, we will keep most of the code around but - // disabled to avoid merge conflicts in case we need to revert quickly.) - } + pkgsFilter = pkgsNotMain + if gccgo { + codegenArg = "-fPIC" + } else { + codegenArg = "-dynlink" } + if cfg.BuildO != "" { + base.Fatalf("-buildmode=shared and -o not supported together") + } + ldBuildmode = "shared" case "plugin": pkgsFilter = oneMainPkg if gccgo { @@ -265,15 +261,6 @@ func buildModeInit() { } if cfg.BuildLinkshared { - if cfg.Goos == "linux" { - switch cfg.Goarch { - case "386", "amd64", "arm", "arm64", "ppc64le", "s390x": - base.Fatalf("-linkshared no longer supported as of Go 1.18") - // TODO(#47788): Remove supporting code for linkshared. - // (For the Go 1.18 release, we will keep most of the code around but - // disabled to avoid merge conflicts in case we need to revert quickly.) - } - } if !sys.BuildModeSupported(cfg.BuildToolchainName, "shared", cfg.Goos, cfg.Goarch) { base.Fatalf("-linkshared not supported on %s/%s\n", cfg.Goos, cfg.Goarch) } diff --git a/src/cmd/go/testdata/script/list_linkshared.txt b/src/cmd/go/testdata/script/list_linkshared.txt new file mode 100644 index 0000000000..baae1e2be8 --- /dev/null +++ b/src/cmd/go/testdata/script/list_linkshared.txt @@ -0,0 +1,16 @@ +env GO111MODULE=on + +# golang.org/issue/35759: 'go list -linkshared' +# panicked if invoked on a test-only package. + +[!buildmode:shared] skip + +go list -f '{{.ImportPath}}: {{.Target}} {{.Shlib}}' -linkshared . +stdout '^example.com: $' + +-- go.mod -- +module example.com + +go 1.14 +-- x.go -- +package x diff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go index 18ca50f927..4fa5aa495e 100644 --- a/src/cmd/internal/sys/supported.go +++ b/src/cmd/internal/sys/supported.go @@ -132,6 +132,13 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool { } return false + case "shared": + switch platform { + case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x": + return true + } + return false + case "plugin": switch platform { case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le", From d8fc7f785e84515c0a5beb8baeb3c1ca35bebf68 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Thu, 28 Oct 2021 17:52:22 +0000 Subject: [PATCH 236/406] runtime: clean up allocation zeroing Currently, the runtime zeroes allocations in several ways. First, small object spans are always zeroed if they come from mheap, and their slots are zeroed later in mallocgc if needed. Second, large object spans (objects that have their own spans) plumb the need for zeroing down into mheap. Thirdly, large objects that have no pointers have their zeroing delayed until after preemption is reenabled, but before returning in mallocgc. All of this has two consequences: 1. Spans for small objects that come from mheap are sometimes unnecessarily zeroed, even if the mallocgc call that created them doesn't need the object slot to be zeroed. 2. This is all messy and difficult to reason about. This CL simplifies this code, resolving both (1) and (2). First, it recognizes that zeroing in mheap is unnecessary for small object spans; mallocgc and its callees in mcache and mcentral, by design, are *always* able to deal with non-zeroed spans. They must, for they deal with recycled spans all the time. Once this fact is made clear, the only remaining use of zeroing in mheap is for large objects. As a result, this CL lifts mheap zeroing for large objects into mallocgc, to parallel all the other codepaths in mallocgc. This is makes the large object allocation code less surprising. Next, this CL sets the flag for the delayed zeroing explicitly in the one case where it matters, and inverts and renames the flag from isZeroed to delayZeroing. Finally, it adds a check to make sure that only pointer-free allocations take the delayed zeroing codepath, as an extra safety measure. Benchmark results: https://perf.golang.org/search?q=upload:20211028.8 Inspired by tapir.liu@gmail.com's CL 343470. Change-Id: I7e1296adc19ce8a02c8d93a0a5082aefb2673e8f Reviewed-on: https://go-review.googlesource.com/c/go/+/359477 Trust: Michael Knyszek Reviewed-by: David Chase --- src/runtime/malloc.go | 25 ++++++++++++++++++++----- src/runtime/mcache.go | 9 +++------ src/runtime/mcentral.go | 2 +- src/runtime/mheap.go | 21 +++++---------------- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index c389cb1e45..8af1d96f1a 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -980,8 +980,8 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { var x unsafe.Pointer noscan := typ == nil || typ.ptrdata == 0 // In some cases block zeroing can profitably (for latency reduction purposes) - // be delayed till preemption is possible; isZeroed tracks that state. - isZeroed := true + // be delayed till preemption is possible; delayedZeroing tracks that state. + delayedZeroing := false if size <= maxSmallSize { if noscan && size < maxTinySize { // Tiny allocator. @@ -1079,11 +1079,23 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { shouldhelpgc = true // For large allocations, keep track of zeroed state so that // bulk zeroing can be happen later in a preemptible context. - span, isZeroed = c.allocLarge(size, needzero && !noscan, noscan) + span = c.allocLarge(size, noscan) span.freeindex = 1 span.allocCount = 1 - x = unsafe.Pointer(span.base()) size = span.elemsize + x = unsafe.Pointer(span.base()) + if needzero && span.needzero != 0 { + if noscan { + delayedZeroing = true + } else { + memclrNoHeapPointers(x, size) + // We've in theory cleared almost the whole span here, + // and could take the extra step of actually clearing + // the whole thing. However, don't. Any GC bits for the + // uncleared parts will be zero, and it's just going to + // be needzero = 1 once freed anyway. + } + } } var scanSize uintptr @@ -1139,7 +1151,10 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { // Pointerfree data can be zeroed late in a context where preemption can occur. // x will keep the memory alive. - if !isZeroed && needzero { + if delayedZeroing { + if !noscan { + throw("delayed zeroing on data that may contain pointers") + } memclrNoHeapPointersChunked(size, x) // This is a possible preemption point: see #47302 } diff --git a/src/runtime/mcache.go b/src/runtime/mcache.go index 21c36ca750..52bb944cdd 100644 --- a/src/runtime/mcache.go +++ b/src/runtime/mcache.go @@ -206,10 +206,7 @@ func (c *mcache) refill(spc spanClass) { } // allocLarge allocates a span for a large object. -// The boolean result indicates whether the span is known-zeroed. -// If it did not need to be zeroed, it may not have been zeroed; -// but if it came directly from the OS, it is already zeroed. -func (c *mcache) allocLarge(size uintptr, needzero bool, noscan bool) (*mspan, bool) { +func (c *mcache) allocLarge(size uintptr, noscan bool) *mspan { if size+_PageSize < size { throw("out of memory") } @@ -224,7 +221,7 @@ func (c *mcache) allocLarge(size uintptr, needzero bool, noscan bool) (*mspan, b deductSweepCredit(npages*_PageSize, npages) spc := makeSpanClass(0, noscan) - s, isZeroed := mheap_.alloc(npages, spc, needzero) + s := mheap_.alloc(npages, spc) if s == nil { throw("out of memory") } @@ -248,7 +245,7 @@ func (c *mcache) allocLarge(size uintptr, needzero bool, noscan bool) (*mspan, b mheap_.central[spc].mcentral.fullSwept(mheap_.sweepgen).push(s) s.limit = s.base() + size heapBitsForAddr(s.base()).initSpan(s) - return s, isZeroed + return s } func (c *mcache) releaseAll() { diff --git a/src/runtime/mcentral.go b/src/runtime/mcentral.go index 0a871a611e..4ae3a883a4 100644 --- a/src/runtime/mcentral.go +++ b/src/runtime/mcentral.go @@ -241,7 +241,7 @@ func (c *mcentral) grow() *mspan { npages := uintptr(class_to_allocnpages[c.spanclass.sizeclass()]) size := uintptr(class_to_size[c.spanclass.sizeclass()]) - s, _ := mheap_.alloc(npages, c.spanclass, true) + s := mheap_.alloc(npages, c.spanclass) if s == nil { return nil } diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index 4f32e888b2..5fd036c1b3 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -894,10 +894,9 @@ func (s spanAllocType) manual() bool { // // spanclass indicates the span's size class and scannability. // -// If needzero is true, the memory for the returned span will be zeroed. -// The boolean returned indicates whether the returned span contains zeroes, -// either because this was requested, or because it was already zeroed. -func (h *mheap) alloc(npages uintptr, spanclass spanClass, needzero bool) (*mspan, bool) { +// Returns a span that has been fully initialized. span.needzero indicates +// whether the span has been zeroed. Note that it may not be. +func (h *mheap) alloc(npages uintptr, spanclass spanClass) *mspan { // Don't do any operations that lock the heap on the G stack. // It might trigger stack growth, and the stack growth code needs // to be able to allocate heap. @@ -910,17 +909,7 @@ func (h *mheap) alloc(npages uintptr, spanclass spanClass, needzero bool) (*mspa } s = h.allocSpan(npages, spanAllocHeap, spanclass) }) - - if s == nil { - return nil, false - } - isZeroed := s.needzero == 0 - if needzero && !isZeroed { - memclrNoHeapPointers(unsafe.Pointer(s.base()), s.npages<<_PageShift) - isZeroed = true - } - s.needzero = 0 - return s, isZeroed + return s } // allocManual allocates a manually-managed span of npage pages. @@ -1009,7 +998,7 @@ func (h *mheap) allocNeedsZero(base, npage uintptr) (needZero bool) { break } zeroedBase = atomic.Loaduintptr(&ha.zeroedBase) - // Sanity check zeroedBase. + // Double check basic conditions of zeroedBase. if zeroedBase <= arenaLimit && zeroedBase > arenaBase { // The zeroedBase moved into the space we were trying to // claim. That's very bad, and indicates someone allocated From 353d5b6c536c7028eba058ba27014fae0206298a Mon Sep 17 00:00:00 2001 From: Zhi Zheng Date: Mon, 5 Apr 2021 16:00:07 -0700 Subject: [PATCH 237/406] runtime: enable crash dump creation on Windows This change provides ability to create dumps on Windows that can be used by "dlv core" command. Currently only full dumps can be correctly read by Delve. Below are the steps to create and use the dumps. 1. Configure Windows OS to collect dumps before running the program. Instructions on how to do the configuration are here: https://docs.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps. In order for Delve to read the dump, set the DumpType to full dump, i.e. DumpType=2. 2. Go program only generates dumps when the environment variable GOTRACEBACK is set to crash. Run command "set GOTRACEBACK=crash" before running the program. 3. Dump files will be generated in %LOCALAPPDATA%\CrashDumps 4. Use Delve command "dlv core" to open the dump, e.g.: "dlv core a.exe a.exe.3840.dmp". Fixes #20498 Change-Id: Ib9aa82e7aea9da19594dc49348876997b24e9600 Reviewed-on: https://go-review.googlesource.com/c/go/+/307372 Run-TryBot: Alessandro Arzilli TryBot-Result: Go Bot Reviewed-by: Patrik Nyblom Trust: Alex Brainman --- src/runtime/os_windows.go | 4 ++ src/runtime/panic.go | 11 ++++++ src/runtime/signal_windows.go | 74 ++++++++++++++++++++++++----------- 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go index 648239fb36..0e17e75e3e 100644 --- a/src/runtime/os_windows.go +++ b/src/runtime/os_windows.go @@ -40,6 +40,7 @@ const ( //go:cgo_import_dynamic runtime._LoadLibraryW LoadLibraryW%1 "kernel32.dll" //go:cgo_import_dynamic runtime._LoadLibraryA LoadLibraryA%1 "kernel32.dll" //go:cgo_import_dynamic runtime._PostQueuedCompletionStatus PostQueuedCompletionStatus%4 "kernel32.dll" +//go:cgo_import_dynamic runtime._RaiseException RaiseException%4 "kernel32.dll" //go:cgo_import_dynamic runtime._ResumeThread ResumeThread%1 "kernel32.dll" //go:cgo_import_dynamic runtime._SetConsoleCtrlHandler SetConsoleCtrlHandler%2 "kernel32.dll" //go:cgo_import_dynamic runtime._SetErrorMode SetErrorMode%1 "kernel32.dll" @@ -93,6 +94,7 @@ var ( _PostQueuedCompletionStatus, _QueryPerformanceCounter, _QueryPerformanceFrequency, + _RaiseException, _ResumeThread, _SetConsoleCtrlHandler, _SetErrorMode, @@ -120,6 +122,7 @@ var ( _AddVectoredContinueHandler, _LoadLibraryExA, _LoadLibraryExW, + _WerSetFlags, _ stdFunction // Use RtlGenRandom to generate cryptographically random data. @@ -254,6 +257,7 @@ func loadOptionalSyscalls() { _AddVectoredContinueHandler = windowsFindfunc(k32, []byte("AddVectoredContinueHandler\000")) _LoadLibraryExA = windowsFindfunc(k32, []byte("LoadLibraryExA\000")) _LoadLibraryExW = windowsFindfunc(k32, []byte("LoadLibraryExW\000")) + _WerSetFlags = windowsFindfunc(k32, []byte("WerSetFlags\000")) useLoadLibraryEx = (_LoadLibraryExW != nil && _LoadLibraryExA != nil && _AddDllDirectory != nil) var advapi32dll = []byte("advapi32.dll\000") diff --git a/src/runtime/panic.go b/src/runtime/panic.go index c4f3f41ff5..58135cf8ce 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -975,6 +975,11 @@ var runningPanicDefers uint32 // panicking is incremented and decremented atomically. var panicking uint32 +// tracebackprinted is zero before gopanic() prints the traceback. After +// traceback is printed, it sets to 1 so that the subsequent exception handler +// won't print the traceback again. +var tracebackprinted uint32 + // paniclk is held while printing the panic information and stack trace, // so that two concurrent panics don't overlap their output. var paniclk mutex @@ -1018,6 +1023,9 @@ func fatalthrow() { startpanic_m() if dopanic_m(gp, pc, sp) { + // At this point, traceback has already been printed. + // Set tracebackprinted to 1 to avoid printing traceback again + tracebackprinted = 1 // crash uses a decent amount of nosplit stack and we're already // low on stack in throw, so crash on the system stack (unlike // fatalpanic). @@ -1059,6 +1067,9 @@ func fatalpanic(msgs *_panic) { }) if docrash { + // At this point, traceback has already been printed. + // Set tracebackprinted to 1 to avoid printing traceback again + tracebackprinted = 1 // By crashing outside the above systemstack call, debuggers // will not be confused when generating a backtrace. // Function crash is marked nosplit to avoid stack growth. diff --git a/src/runtime/signal_windows.go b/src/runtime/signal_windows.go index 16c36d07f1..ca4a9ea451 100644 --- a/src/runtime/signal_windows.go +++ b/src/runtime/signal_windows.go @@ -22,6 +22,30 @@ func disableWER() { stdcall1(_SetErrorMode, uintptr(errormode)|SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX) } +// enableWERNoUI re-enables Windows error reporting without fault reporting UI. +// It returns false on older Windows versions (XP and earlier) where WerSetFlags() is not supported. +// +// This is marked nosplit since it is used during crash. +// +//go:nosplit +func enableWERNoUI() bool { + if _WerSetFlags == nil { + return false + } + + // Disable Fault reporting UI + const ( + WER_FAULT_REPORTING_NO_UI = 0x0020 + ) + if stdcall1(_WerSetFlags, WER_FAULT_REPORTING_NO_UI) != 0 { + return false + } + + // re-enable Windows Error Reporting + stdcall1(_SetErrorMode, 0) + return true +} + // in sys_windows_386.s and sys_windows_amd64.s func exceptiontramp() func firstcontinuetramp() @@ -108,6 +132,7 @@ func exceptionhandler(info *exceptionrecord, r *context, gp *g) int32 { // Don't go through any more of the Windows handler chain. // Crash now. winthrow(info, r, gp) + exit(2) } // After this point, it is safe to grow the stack. @@ -196,6 +221,15 @@ func lastcontinuehandler(info *exceptionrecord, r *context, gp *g) int32 { } winthrow(info, r, gp) + + _, _, docrash := gotraceback() + if docrash { + // trigger crash dump creation + if enableWERNoUI() { + return _EXCEPTION_CONTINUE_SEARCH + } + } + exit(2) return 0 // not reached } @@ -203,11 +237,6 @@ func lastcontinuehandler(info *exceptionrecord, r *context, gp *g) int32 { func winthrow(info *exceptionrecord, r *context, gp *g) { _g_ := getg() - if panicking != 0 { // traceback already printed - exit(2) - } - panicking = 1 - // In case we're handling a g0 stack overflow, blow away the // g0 stack bounds so we have room to print the traceback. If // this somehow overflows the stack, the OS will trap it. @@ -229,18 +258,16 @@ func winthrow(info *exceptionrecord, r *context, gp *g) { _g_.m.throwing = 1 _g_.m.caughtsig.set(gp) - level, _, docrash := gotraceback() + level, _, _ := gotraceback() if level > 0 { - tracebacktrap(r.ip(), r.sp(), r.lr(), gp) - tracebackothers(gp) + // only print traceback when it hasn't been printed + if tracebackprinted == 0 { + tracebacktrap(r.ip(), r.sp(), r.lr(), gp) + tracebackothers(gp) + tracebackprinted = 1 + } dumpregs(r) } - - if docrash { - crash() - } - - exit(2) } func sigpanic() { @@ -312,14 +339,17 @@ func signame(sig uint32) string { //go:nosplit func crash() { - // TODO: This routine should do whatever is needed - // to make the Windows program abort/crash as it - // would if Go was not intercepting signals. - // On Unix the routine would remove the custom signal - // handler and then raise a signal (like SIGABRT). - // Something like that should happen here. - // It's okay to leave this empty for now: if crash returns - // the ordinary exit-after-panic happens. + // When GOTRACEBACK==crash, raise the same exception + // from kernel32.dll, so that Windows gets a chance + // to handle the exception by creating a crash dump. + + // Get the Exception code that caused the crash + gp := getg() + exceptionCode := gp.sig + + // RaiseException() here will not be handled in exceptionhandler() + // because it comes from kernel32.dll + stdcall4(_RaiseException, uintptr(unsafe.Pointer(&exceptionCode)), 0, 0, 0) } // gsignalStack is unused on Windows. From 413672fc84e0ced7531cdc7cf0e5db32061e8194 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Sun, 11 Apr 2021 18:37:52 +0000 Subject: [PATCH 238/406] runtime: detangle sweeper pacing from GC pacing The sweeper's pacing state is global, so detangle it from the GC pacer's state updates so that the GC pacer can be tested. For #44167. Change-Id: Ibcea989cd435b73c5891f777d9f95f9604e03bd1 Reviewed-on: https://go-review.googlesource.com/c/go/+/309273 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/runtime/mgc.go | 1 + src/runtime/mgcpacer.go | 35 +-------------------------------- src/runtime/mgcsweep.go | 43 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 34 deletions(-) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index e7c023919c..b2ed18fe6a 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -971,6 +971,7 @@ func gcMarkTermination(nextTriggerRatio float64) { // Update GC trigger and pacing for the next cycle. gcController.commit(nextTriggerRatio) + gcPaceSweeper(gcController.trigger) gcPaceScavenger(gcController.heapGoal, gcController.lastHeapGoal) // Update timing memstats diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 73fe6e15e4..980cb2f086 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -735,40 +735,6 @@ func (c *gcControllerState) commit(triggerRatio float64) { if gcphase != _GCoff { c.revise() } - - // Update sweep pacing. - if isSweepDone() { - mheap_.sweepPagesPerByte = 0 - } else { - // Concurrent sweep needs to sweep all of the in-use - // pages by the time the allocated heap reaches the GC - // trigger. Compute the ratio of in-use pages to sweep - // per byte allocated, accounting for the fact that - // some might already be swept. - heapLiveBasis := atomic.Load64(&c.heapLive) - heapDistance := int64(trigger) - int64(heapLiveBasis) - // Add a little margin so rounding errors and - // concurrent sweep are less likely to leave pages - // unswept when GC starts. - heapDistance -= 1024 * 1024 - if heapDistance < _PageSize { - // Avoid setting the sweep ratio extremely high - heapDistance = _PageSize - } - pagesSwept := mheap_.pagesSwept.Load() - pagesInUse := mheap_.pagesInUse.Load() - sweepDistancePages := int64(pagesInUse) - int64(pagesSwept) - if sweepDistancePages <= 0 { - mheap_.sweepPagesPerByte = 0 - } else { - mheap_.sweepPagesPerByte = float64(sweepDistancePages) / float64(heapDistance) - mheap_.sweepHeapLiveBasis = heapLiveBasis - // Write pagesSweptBasis last, since this - // signals concurrent sweeps to recompute - // their debt. - mheap_.pagesSweptBasis.Store(pagesSwept) - } - } } // effectiveGrowthRatio returns the current effective heap growth @@ -819,6 +785,7 @@ func setGCPercent(in int32) (out int32) { systemstack(func() { lock(&mheap_.lock) out = gcController.setGCPercent(in) + gcPaceSweeper(gcController.trigger) gcPaceScavenger(gcController.heapGoal, gcController.lastHeapGoal) unlock(&mheap_.lock) }) diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go index a431d8a2af..b06df32b20 100644 --- a/src/runtime/mgcsweep.go +++ b/src/runtime/mgcsweep.go @@ -830,3 +830,46 @@ func clobberfree(x unsafe.Pointer, size uintptr) { *(*uint32)(add(x, i)) = 0xdeadbeef } } + +// gcPaceSweeper updates the sweeper's pacing parameters. +// +// Must be called whenever the GC's pacing is updated. +// +// The world must be stopped, or mheap_.lock must be held. +func gcPaceSweeper(trigger uint64) { + assertWorldStoppedOrLockHeld(&mheap_.lock) + + // Update sweep pacing. + if isSweepDone() { + mheap_.sweepPagesPerByte = 0 + } else { + // Concurrent sweep needs to sweep all of the in-use + // pages by the time the allocated heap reaches the GC + // trigger. Compute the ratio of in-use pages to sweep + // per byte allocated, accounting for the fact that + // some might already be swept. + heapLiveBasis := atomic.Load64(&gcController.heapLive) + heapDistance := int64(trigger) - int64(heapLiveBasis) + // Add a little margin so rounding errors and + // concurrent sweep are less likely to leave pages + // unswept when GC starts. + heapDistance -= 1024 * 1024 + if heapDistance < _PageSize { + // Avoid setting the sweep ratio extremely high + heapDistance = _PageSize + } + pagesSwept := mheap_.pagesSwept.Load() + pagesInUse := mheap_.pagesInUse.Load() + sweepDistancePages := int64(pagesInUse) - int64(pagesSwept) + if sweepDistancePages <= 0 { + mheap_.sweepPagesPerByte = 0 + } else { + mheap_.sweepPagesPerByte = float64(sweepDistancePages) / float64(heapDistance) + mheap_.sweepHeapLiveBasis = heapLiveBasis + // Write pagesSweptBasis last, since this + // signals concurrent sweeps to recompute + // their debt. + mheap_.pagesSweptBasis.Store(pagesSwept) + } + } +} From 903f313d8b6e85c031fc5918273ff4800fa9f952 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Fri, 29 Oct 2021 17:58:42 +0000 Subject: [PATCH 239/406] runtime: fix unclosed GCSweepStart trace event CL 333389 erroneously moved traceGCSweepDone inside the sl.valid block that it introduced in mcentral.cacheSpan, when it should have left it outside that scope, because the trace event is created unconditionally at the top of the method. Fixes #49231. Change-Id: If719c05063d4f4d330a320da6dc00d1e9d8102e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/359775 Trust: Michael Knyszek Run-TryBot: Michael Knyszek Reviewed-by: Michael Pratt TryBot-Result: Go Bot --- src/runtime/mcentral.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/mcentral.go b/src/runtime/mcentral.go index 4ae3a883a4..e4bdf35071 100644 --- a/src/runtime/mcentral.go +++ b/src/runtime/mcentral.go @@ -154,10 +154,10 @@ func (c *mcentral) cacheSpan() *mspan { // See comment for partial unswept spans. } sweep.active.end(sl) - if trace.enabled { - traceGCSweepDone() - traceDone = true - } + } + if trace.enabled { + traceGCSweepDone() + traceDone = true } // We failed to get a span from the mcentral so get one from mheap. From 4a5d78ff8b7e777d70b18a61698b1ac07bbd623d Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Sun, 11 Apr 2021 18:11:48 +0000 Subject: [PATCH 240/406] runtime: move pacer time updates and state resets into methods Currently GC pacer updates are applied somewhat haphazardly via direct field access. To facilitate ease of testing, move these field updates into methods. Further CLs will move more of these updates into methods. For #44167. Change-Id: I25b10d2219ae27b356b5f236d44827546c86578d Reviewed-on: https://go-review.googlesource.com/c/go/+/309274 Trust: Michael Knyszek Run-TryBot: Michael Knyszek Reviewed-by: Michael Pratt --- src/runtime/mgc.go | 39 +++++++++++---------------------------- src/runtime/mgcpacer.go | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 29 deletions(-) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index b2ed18fe6a..cf53585dcd 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -661,7 +661,9 @@ func gcStart(trigger gcTrigger) { work.cycles++ - gcController.startCycle() + // Assists and workers can start the moment we start + // the world. + gcController.startCycle(now) work.heapGoal = gcController.heapGoal // In STW mode, disable scheduling of user Gs. This may also @@ -704,10 +706,6 @@ func gcStart(trigger gcTrigger) { // mutators. atomic.Store(&gcBlackenEnabled, 1) - // Assists and workers can start the moment we start - // the world. - gcController.markStartTime = now - // In STW mode, we could block the instant systemstack // returns, so make sure we're not preemptible. mp = acquirem() @@ -965,8 +963,7 @@ func gcMarkTermination(nextTriggerRatio float64) { throw("gc done but gcphase != _GCoff") } - // Record heapGoal and heap_inuse for scavenger. - gcController.lastHeapGoal = gcController.heapGoal + // Record heap_inuse for scavenger. memstats.last_heap_inuse = memstats.heap_inuse // Update GC trigger and pacing for the next cycle. @@ -1291,15 +1288,9 @@ func gcBgMarkWorker() { // Account for time. duration := nanotime() - startTime - switch pp.gcMarkWorkerMode { - case gcMarkWorkerDedicatedMode: - atomic.Xaddint64(&gcController.dedicatedMarkTime, duration) - atomic.Xaddint64(&gcController.dedicatedMarkWorkersNeeded, 1) - case gcMarkWorkerFractionalMode: - atomic.Xaddint64(&gcController.fractionalMarkTime, duration) + gcController.logWorkTime(pp.gcMarkWorkerMode, duration) + if pp.gcMarkWorkerMode == gcMarkWorkerFractionalMode { atomic.Xaddint64(&pp.gcFractionalMarkTime, duration) - case gcMarkWorkerIdleMode: - atomic.Xaddint64(&gcController.idleMarkTime, duration) } // Was this the last worker and did we run out @@ -1419,30 +1410,22 @@ func gcMark(startTime int64) { gcw.dispose() } - // Update the marked heap stat. - gcController.heapMarked = work.bytesMarked - // Flush scanAlloc from each mcache since we're about to modify // heapScan directly. If we were to flush this later, then scanAlloc // might have incorrect information. + // + // Note that it's not important to retain this information; we know + // exactly what heapScan is at this point via scanWork. for _, p := range allp { c := p.mcache if c == nil { continue } - gcController.heapScan += uint64(c.scanAlloc) c.scanAlloc = 0 } - // Update other GC heap size stats. This must happen after - // cachestats (which flushes local statistics to these) and - // flushallmcaches (which modifies gcController.heapLive). - gcController.heapLive = work.bytesMarked - gcController.heapScan = uint64(gcController.scanWork) - - if trace.enabled { - traceHeapAlloc() - } + // Reset controller state. + gcController.resetLive(work.bytesMarked) } // gcSweep must be called on the system stack because it acquires the heap diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 980cb2f086..503b8110b3 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -268,13 +268,14 @@ func (c *gcControllerState) init(gcPercent int32) { // startCycle resets the GC controller's state and computes estimates // for a new GC cycle. The caller must hold worldsema and the world // must be stopped. -func (c *gcControllerState) startCycle() { +func (c *gcControllerState) startCycle(markStartTime int64) { c.scanWork = 0 c.bgScanCredit = 0 c.assistTime = 0 c.dedicatedMarkTime = 0 c.fractionalMarkTime = 0 c.idleMarkTime = 0 + c.markStartTime = markStartTime // Ensure that the heap goal is at least a little larger than // the current live heap size. This may not be the case if GC @@ -441,6 +442,10 @@ func (c *gcControllerState) revise() { // userForced indicates whether the current GC cycle was forced // by the application. func (c *gcControllerState) endCycle(userForced bool) float64 { + // Record last heap goal for the scavenger. + // We'll be updating the heap goal soon. + gcController.lastHeapGoal = gcController.heapGoal + if userForced { // Forced GC means this cycle didn't start at the // trigger, so where it finished isn't good @@ -630,6 +635,40 @@ func (c *gcControllerState) findRunnableGCWorker(_p_ *p) *g { return gp } +// resetLive sets up the controller state for the next mark phase after the end +// of the previous one. Must be called after endCycle and before commit, before +// the world is started. +// +// The world must be stopped. +func (c *gcControllerState) resetLive(bytesMarked uint64) { + c.heapMarked = bytesMarked + c.heapLive = bytesMarked + c.heapScan = uint64(c.scanWork) + + // heapLive was updated, so emit a trace event. + if trace.enabled { + traceHeapAlloc() + } +} + +// logWorkTime updates mark work accounting in the controller by a duration of +// work in nanoseconds. +// +// Safe to execute at any time. +func (c *gcControllerState) logWorkTime(mode gcMarkWorkerMode, duration int64) { + switch mode { + case gcMarkWorkerDedicatedMode: + atomic.Xaddint64(&c.dedicatedMarkTime, duration) + atomic.Xaddint64(&c.dedicatedMarkWorkersNeeded, 1) + case gcMarkWorkerFractionalMode: + atomic.Xaddint64(&c.fractionalMarkTime, duration) + case gcMarkWorkerIdleMode: + atomic.Xaddint64(&c.idleMarkTime, duration) + default: + throw("logWorkTime: unknown mark worker mode") + } +} + // commit sets the trigger ratio and updates everything // derived from it: the absolute trigger, the heap goal, mark pacing, // and sweep pacing. From 8e112a7c2a814de9156f68dc8b167e4ef8c98c52 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Sun, 11 Apr 2021 18:29:03 +0000 Subject: [PATCH 241/406] runtime: move heapLive and heapScan updates into a method This change moves heapLive and heapScan updates on gcController into a method for better testability. It's also less error-prone because code that updates these fields needs to remember to emit traces and/or call gcController.revise; this method now handles those cases. For #44167. Change-Id: I3d6f2e7abb22def27c93feacff50162b0b074da2 Reviewed-on: https://go-review.googlesource.com/c/go/+/309275 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/runtime/mcache.go | 39 ++++++++++----------------------------- src/runtime/mgcpacer.go | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/runtime/mcache.go b/src/runtime/mcache.go index 52bb944cdd..86a8958b9d 100644 --- a/src/runtime/mcache.go +++ b/src/runtime/mcache.go @@ -184,24 +184,13 @@ func (c *mcache) refill(spc spanClass) { } memstats.heapStats.release() - // Update gcController.heapLive with the same assumption. - usedBytes := uintptr(s.allocCount) * s.elemsize - atomic.Xadd64(&gcController.heapLive, int64(s.npages*pageSize)-int64(usedBytes)) - + // Update heapLive with the same assumption. // While we're here, flush scanAlloc, since we have to call // revise anyway. - atomic.Xadd64(&gcController.heapScan, int64(c.scanAlloc)) + usedBytes := uintptr(s.allocCount) * s.elemsize + gcController.update(int64(s.npages*pageSize)-int64(usedBytes), int64(c.scanAlloc)) c.scanAlloc = 0 - if trace.enabled { - // gcController.heapLive changed. - traceHeapAlloc() - } - if gcBlackenEnabled != 0 { - // gcController.heapLive and heapScan changed. - gcController.revise() - } - c.alloc[spc] = s } @@ -230,15 +219,8 @@ func (c *mcache) allocLarge(size uintptr, noscan bool) *mspan { atomic.Xadduintptr(&stats.largeAllocCount, 1) memstats.heapStats.release() - // Update gcController.heapLive and revise pacing if needed. - atomic.Xadd64(&gcController.heapLive, int64(npages*pageSize)) - if trace.enabled { - // Trace that a heap alloc occurred because gcController.heapLive changed. - traceHeapAlloc() - } - if gcBlackenEnabled != 0 { - gcController.revise() - } + // Update heapLive. + gcController.update(int64(s.npages*pageSize), 0) // Put the large span in the mcentral swept list so that it's // visible to the background sweeper. @@ -250,10 +232,11 @@ func (c *mcache) allocLarge(size uintptr, noscan bool) *mspan { func (c *mcache) releaseAll() { // Take this opportunity to flush scanAlloc. - atomic.Xadd64(&gcController.heapScan, int64(c.scanAlloc)) + scanAlloc := int64(c.scanAlloc) c.scanAlloc = 0 sg := mheap_.sweepgen + dHeapLive := int64(0) for i := range c.alloc { s := c.alloc[i] if s != &emptymspan { @@ -270,7 +253,7 @@ func (c *mcache) releaseAll() { // gcController.heapLive was totally recomputed since // caching this span, so we don't do this for // stale spans. - atomic.Xadd64(&gcController.heapLive, -int64(n)*int64(s.elemsize)) + dHeapLive -= int64(n) * int64(s.elemsize) } // Release the span to the mcentral. mheap_.central[i].mcentral.uncacheSpan(s) @@ -287,10 +270,8 @@ func (c *mcache) releaseAll() { c.tinyAllocs = 0 memstats.heapStats.release() - // Updated heapScan and possible gcController.heapLive. - if gcBlackenEnabled != 0 { - gcController.revise() - } + // Updated heapScan and heapLive. + gcController.update(dHeapLive, scanAlloc) } // prepareForSweep flushes c if the system has entered a new sweep phase diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 503b8110b3..094dcc701a 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -669,6 +669,23 @@ func (c *gcControllerState) logWorkTime(mode gcMarkWorkerMode, duration int64) { } } +func (c *gcControllerState) update(dHeapLive, dHeapScan int64) { + if dHeapLive != 0 { + atomic.Xadd64(&gcController.heapLive, dHeapLive) + if trace.enabled { + // gcController.heapLive changed. + traceHeapAlloc() + } + } + if dHeapScan != 0 { + atomic.Xadd64(&gcController.heapScan, dHeapScan) + } + if gcBlackenEnabled != 0 { + // gcController.heapLive and heapScan changed. + c.revise() + } +} + // commit sets the trigger ratio and updates everything // derived from it: the absolute trigger, the heap goal, mark pacing, // and sweep pacing. From 9ac1ee2d464eff73077afda83677f155bd69c6b8 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 12 Apr 2021 22:33:54 +0000 Subject: [PATCH 242/406] runtime: track the amount of scannable allocated stack for the GC pacer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds two fields to gcControllerState: stackScan, used for pacing decisions, and scannableStackSize, which directly tracks the amount of space allocated for inuse stacks that will be scanned. scannableStackSize is not updated directly, but is instead flushed from each P when at an least 8 KiB delta has accumulated. This helps reduce issues with atomics contention for newly created goroutines. Stack growth paths are largely unaffected. StackGrowth-48 51.4ns ± 0% 51.4ns ± 0% ~ (p=0.927 n=10+10) StackGrowthDeep-48 6.14µs ± 3% 6.25µs ± 4% ~ (p=0.090 n=10+9) CreateGoroutines-48 273ns ± 1% 273ns ± 1% ~ (p=0.676 n=9+10) CreateGoroutinesParallel-48 65.5ns ± 5% 66.6ns ± 7% ~ (p=0.340 n=9+9) CreateGoroutinesCapture-48 2.06µs ± 1% 2.07µs ± 4% ~ (p=0.217 n=10+10) CreateGoroutinesSingle-48 550ns ± 3% 563ns ± 4% +2.41% (p=0.034 n=8+10) For #44167. Change-Id: Id1800d41d3a6c211b43aeb5681c57c0dc8880daf Reviewed-on: https://go-review.googlesource.com/c/go/+/309589 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/runtime/mgcpacer.go | 29 +++++++++++++++++++++++++++++ src/runtime/proc.go | 7 +++++-- src/runtime/runtime2.go | 6 ++++++ src/runtime/stack.go | 5 +++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 094dcc701a..9cc7cf99db 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -47,6 +47,10 @@ const ( // defaultHeapMinimum is the value of heapMinimum for GOGC==100. defaultHeapMinimum = 4 << 20 + + // scannableStackSizeSlack is the bytes of stack space allocated or freed + // that can accumulate on a P before updating gcController.stackSize. + scannableStackSizeSlack = 8 << 10 ) func init() { @@ -166,6 +170,18 @@ type gcControllerState struct { // Read and written atomically or with the world stopped. heapScan uint64 + // stackScan is a snapshot of scannableStackSize taken at each GC + // STW pause and is used in pacing decisions. + // + // Updated only while the world is stopped. + stackScan uint64 + + // scannableStackSize is the amount of allocated goroutine stack space in + // use by goroutines. + // + // Read and updated atomically. + scannableStackSize uint64 + // heapMarked is the number of bytes marked by the previous // GC. After mark termination, heapLive == heapMarked, but // unlike heapLive, heapMarked does not change until the @@ -276,6 +292,7 @@ func (c *gcControllerState) startCycle(markStartTime int64) { c.fractionalMarkTime = 0 c.idleMarkTime = 0 c.markStartTime = markStartTime + c.stackScan = atomic.Load64(&c.scannableStackSize) // Ensure that the heap goal is at least a little larger than // the current live heap size. This may not be the case if GC @@ -686,6 +703,18 @@ func (c *gcControllerState) update(dHeapLive, dHeapScan int64) { } } +func (c *gcControllerState) addScannableStack(pp *p, amount int64) { + if pp == nil { + atomic.Xadd64(&c.scannableStackSize, amount) + return + } + pp.scannableStackSizeDelta += amount + if pp.scannableStackSizeDelta >= scannableStackSizeSlack || pp.scannableStackSizeDelta <= -scannableStackSizeSlack { + atomic.Xadd64(&c.scannableStackSize, pp.scannableStackSizeDelta) + pp.scannableStackSizeDelta = 0 + } +} + // commit sets the trigger ratio and updates everything // derived from it: the absolute trigger, the heap goal, mark pacing, // and sweep pacing. diff --git a/src/runtime/proc.go b/src/runtime/proc.go index bd7dacd440..615f53d31f 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -3623,8 +3623,10 @@ func goexit1() { // goexit continuation on g0. func goexit0(gp *g) { _g_ := getg() + _p_ := _g_.m.p.ptr() casgstatus(gp, _Grunning, _Gdead) + gcController.addScannableStack(_p_, -int64(gp.stack.hi-gp.stack.lo)) if isSystemGoroutine(gp, false) { atomic.Xadd(&sched.ngsys, -1) } @@ -3655,7 +3657,7 @@ func goexit0(gp *g) { dropg() if GOARCH == "wasm" { // no threads yet on wasm - gfput(_g_.m.p.ptr(), gp) + gfput(_p_, gp) schedule() // never returns } @@ -3663,7 +3665,7 @@ func goexit0(gp *g) { print("invalid m->lockedInt = ", _g_.m.lockedInt, "\n") throw("internal lockOSThread error") } - gfput(_g_.m.p.ptr(), gp) + gfput(_p_, gp) if locked { // The goroutine may have locked this thread because // it put it in an unusual kernel state. Kill it @@ -4292,6 +4294,7 @@ func newproc1(fn *funcval, callergp *g, callerpc uintptr) *g { newg.tracking = true } casgstatus(newg, _Gdead, _Grunnable) + gcController.addScannableStack(_p_, int64(newg.stack.hi-newg.stack.lo)) if _p_.goidcache == _p_.goidcacheend { // Sched.goidgen is the last allocated id, diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index db1c6e307b..bfd857e8d5 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -734,6 +734,12 @@ type p struct { // Race context used while executing timer functions. timerRaceCtx uintptr + // scannableStackSizeDelta accumulates the amount of stack space held by + // live goroutines (i.e. those eligible for stack scanning). + // Flushed to gcController.scannableStackSize once scannableStackSizeSlack + // or -scannableStackSizeSlack is reached. + scannableStackSizeDelta int64 + // preempt is set to indicate that this P should be enter the // scheduler ASAP (regardless of what G is running on it). preempt bool diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 284c6b3b84..8ae9c1e698 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -852,6 +852,11 @@ func copystack(gp *g, newsize uintptr) { throw("nil stackbase") } used := old.hi - gp.sched.sp + // Add just the difference to gcController.addScannableStack. + // g0 stacks never move, so this will never account for them. + // It's also fine if we have no P, addScannableStack can deal with + // that case. + gcController.addScannableStack(getg().m.p.ptr(), int64(newsize)-int64(old.hi-old.lo)) // allocate new stack new := stackalloc(uint32(newsize)) From 9da64156a62e4661fb5b0e64a2f196f253ce0dc5 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 12 Apr 2021 22:40:36 +0000 Subject: [PATCH 243/406] runtime: track scannable globals space For #44167. Change-Id: I2cd13229d88f630451fabd113b0e5a04841e9e79 Reviewed-on: https://go-review.googlesource.com/c/go/+/309590 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/runtime/mgcpacer.go | 10 ++++++++++ src/runtime/symtab.go | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 9cc7cf99db..ad7c4bb840 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -182,6 +182,12 @@ type gcControllerState struct { // Read and updated atomically. scannableStackSize uint64 + // globalsScan is the total amount of global variable space + // that is scannable. + // + // Read and updated atomically. + globalsScan uint64 + // heapMarked is the number of bytes marked by the previous // GC. After mark termination, heapLive == heapMarked, but // unlike heapLive, heapMarked does not change until the @@ -715,6 +721,10 @@ func (c *gcControllerState) addScannableStack(pp *p, amount int64) { } } +func (c *gcControllerState) addGlobals(amount int64) { + atomic.Xadd64(&c.globalsScan, amount) +} + // commit sets the trigger ratio and updates everything // derived from it: the absolute trigger, the heap goal, mark pacing, // and sweep pacing. diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index 41161d6f90..3237a6b708 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -529,8 +529,11 @@ func modulesinit() { } *modules = append(*modules, md) if md.gcdatamask == (bitvector{}) { - md.gcdatamask = progToPointerMask((*byte)(unsafe.Pointer(md.gcdata)), md.edata-md.data) - md.gcbssmask = progToPointerMask((*byte)(unsafe.Pointer(md.gcbss)), md.ebss-md.bss) + scanDataSize := md.edata - md.data + md.gcdatamask = progToPointerMask((*byte)(unsafe.Pointer(md.gcdata)), scanDataSize) + scanBSSSize := md.ebss - md.bss + md.gcbssmask = progToPointerMask((*byte)(unsafe.Pointer(md.gcbss)), scanBSSSize) + gcController.addGlobals(int64(scanDataSize + scanBSSSize)) } } From 5ec2427357f4917d0aad40cffddeea73e580129e Mon Sep 17 00:00:00 2001 From: Michael Knyszek Date: Fri, 1 Oct 2021 15:07:45 -0400 Subject: [PATCH 244/406] runtime: pass nanotime and gomaxprocs into startCycle and endCycle explicitly This is to facilitate testing of the pacer, since otherwise this is accessing global state, which is impossible to stub out properly. For #44167. Change-Id: I52c3b51fc0ffff38e3bbe534bd66e5761c0003a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/353353 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/runtime/mgc.go | 4 ++-- src/runtime/mgcpacer.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index cf53585dcd..03711a9617 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -663,7 +663,7 @@ func gcStart(trigger gcTrigger) { // Assists and workers can start the moment we start // the world. - gcController.startCycle(now) + gcController.startCycle(now, int(gomaxprocs)) work.heapGoal = gcController.heapGoal // In STW mode, disable scheduling of user Gs. This may also @@ -889,7 +889,7 @@ top: // endCycle depends on all gcWork cache stats being flushed. // The termination algorithm above ensured that up to // allocations since the ragged barrier. - nextTriggerRatio := gcController.endCycle(work.userForced) + nextTriggerRatio := gcController.endCycle(now, int(gomaxprocs), work.userForced) // Perform mark termination. This will restart the world. gcMarkTermination(nextTriggerRatio) diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index ad7c4bb840..160383db43 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -290,7 +290,7 @@ func (c *gcControllerState) init(gcPercent int32) { // startCycle resets the GC controller's state and computes estimates // for a new GC cycle. The caller must hold worldsema and the world // must be stopped. -func (c *gcControllerState) startCycle(markStartTime int64) { +func (c *gcControllerState) startCycle(markStartTime int64, procs int) { c.scanWork = 0 c.bgScanCredit = 0 c.assistTime = 0 @@ -316,7 +316,7 @@ func (c *gcControllerState) startCycle(markStartTime int64) { // dedicated workers so that the utilization is closest to // 25%. For small GOMAXPROCS, this would introduce too much // error, so we add fractional workers in that case. - totalUtilizationGoal := float64(gomaxprocs) * gcBackgroundUtilization + totalUtilizationGoal := float64(procs) * gcBackgroundUtilization c.dedicatedMarkWorkersNeeded = int64(totalUtilizationGoal + 0.5) utilError := float64(c.dedicatedMarkWorkersNeeded)/totalUtilizationGoal - 1 const maxUtilError = 0.3 @@ -329,14 +329,14 @@ func (c *gcControllerState) startCycle(markStartTime int64) { // Too many dedicated workers. c.dedicatedMarkWorkersNeeded-- } - c.fractionalUtilizationGoal = (totalUtilizationGoal - float64(c.dedicatedMarkWorkersNeeded)) / float64(gomaxprocs) + c.fractionalUtilizationGoal = (totalUtilizationGoal - float64(c.dedicatedMarkWorkersNeeded)) / float64(procs) } else { c.fractionalUtilizationGoal = 0 } // In STW mode, we just want dedicated workers. if debug.gcstoptheworld > 0 { - c.dedicatedMarkWorkersNeeded = int64(gomaxprocs) + c.dedicatedMarkWorkersNeeded = int64(procs) c.fractionalUtilizationGoal = 0 } @@ -464,7 +464,7 @@ func (c *gcControllerState) revise() { // endCycle computes the trigger ratio for the next cycle. // userForced indicates whether the current GC cycle was forced // by the application. -func (c *gcControllerState) endCycle(userForced bool) float64 { +func (c *gcControllerState) endCycle(now int64, procs int, userForced bool) float64 { // Record last heap goal for the scavenger. // We'll be updating the heap goal soon. gcController.lastHeapGoal = gcController.heapGoal @@ -495,13 +495,13 @@ func (c *gcControllerState) endCycle(userForced bool) float64 { // heap growth is the error. goalGrowthRatio := c.effectiveGrowthRatio() actualGrowthRatio := float64(c.heapLive)/float64(c.heapMarked) - 1 - assistDuration := nanotime() - c.markStartTime + assistDuration := now - c.markStartTime // Assume background mark hit its utilization goal. utilization := gcBackgroundUtilization // Add assist utilization; avoid divide by zero. if assistDuration > 0 { - utilization += float64(c.assistTime) / float64(assistDuration*int64(gomaxprocs)) + utilization += float64(c.assistTime) / float64(assistDuration*int64(procs)) } triggerError := goalGrowthRatio - c.triggerRatio - utilization/gcGoalUtilization*(actualGrowthRatio-c.triggerRatio) From 6afdf01e5385183bea4ba2661bb4088b32626b3d Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 29 Oct 2021 12:07:55 -0400 Subject: [PATCH 245/406] cmd/go: make assertions more precise in TestScript/gcflags_patterns This fixes a rare test flake observed in https://build.golang.org/log/18e531785e7f8b3e6a6d5231787a9d8bdd4a60ea. Change-Id: I0986752f5c1abc626070b9f8ecf34c629a15cd2a Reviewed-on: https://go-review.googlesource.com/c/go/+/359735 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- .../go/testdata/script/gcflags_patterns.txt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cmd/go/testdata/script/gcflags_patterns.txt b/src/cmd/go/testdata/script/gcflags_patterns.txt index e9521c2fb2..5b81e9481a 100644 --- a/src/cmd/go/testdata/script/gcflags_patterns.txt +++ b/src/cmd/go/testdata/script/gcflags_patterns.txt @@ -7,24 +7,24 @@ env GOCACHE=$WORK/gocache # Looking for compile commands, so need a clean cache # -gcflags=-e applies to named packages, not dependencies go build -n -v -gcflags=-e z1 z2 -stderr 'compile.* -p z1.* -e' -stderr 'compile.* -p z2.* -e' +stderr 'compile.* -p z1.* -e ' +stderr 'compile.* -p z2.* -e ' stderr 'compile.* -p y' -! stderr 'compile.* -p [^z].* -e' +! stderr 'compile.* -p [^z].* -e ' # -gcflags can specify package=flags, and can be repeated; last match wins go build -n -v -gcflags=-e -gcflags=z1=-N z1 z2 -stderr 'compile.* -p z1.* -N' -! stderr 'compile.* -p z1.* -e' -! stderr 'compile.* -p z2.* -N' -stderr 'compile.* -p z2.* -e' +stderr 'compile.* -p z1.* -N ' +! stderr 'compile.* -p z1.* -e ' +! stderr 'compile.* -p z2.* -N ' +stderr 'compile.* -p z2.* -e ' stderr 'compile.* -p y' -! stderr 'compile.* -p [^z].* -e' -! stderr 'compile.* -p [^z].* -N' +! stderr 'compile.* -p [^z].* -e ' +! stderr 'compile.* -p [^z].* -N ' # -gcflags can have arbitrary spaces around the flags go build -n -v -gcflags=' z1 = -e ' z1 -stderr 'compile.* -p z1.* -e' +stderr 'compile.* -p z1.* -e ' # -gcflags='all=-e' should apply to all packages, even with go test go test -c -n -gcflags='all=-e' z1 From 459293388ceb74d9cf61c930f02325645cd0cb7d Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Thu, 28 Oct 2021 20:54:45 -0400 Subject: [PATCH 246/406] cmd/go: document that tests must not write to their source modules Fixes #28386 Updates #48495 Change-Id: I76186077c7bbe3f8f608026ee1865de83fe169b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/359574 Trust: Bryan C. Mills Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot --- src/cmd/go/alldocs.go | 6 +++++- src/cmd/go/internal/test/test.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 487a8f580b..0dcb317995 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -2951,7 +2951,11 @@ // When 'go test' runs a test binary, it does so from within the // corresponding package's source code directory. Depending on the test, // it may be necessary to do the same when invoking a generated test -// binary directly. +// binary directly. Because that directory may be located within the +// module cache, which may be read-only and is verified by checksums, the +// test must not write to it or any other directory within the module +// unless explicitly requested by the user (such as with the -fuzz flag, +// which writes failures to testdata/fuzz). // // The command-line package list, if present, must appear before any // flag not known to the go test command. Continuing the example above, diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index c435cc3fb2..cfb0a1465f 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -407,7 +407,11 @@ leave the test binary in pkg.test for use when analyzing the profiles. When 'go test' runs a test binary, it does so from within the corresponding package's source code directory. Depending on the test, it may be necessary to do the same when invoking a generated test -binary directly. +binary directly. Because that directory may be located within the +module cache, which may be read-only and is verified by checksums, the +test must not write to it or any other directory within the module +unless explicitly requested by the user (such as with the -fuzz flag, +which writes failures to testdata/fuzz). The command-line package list, if present, must appear before any flag not known to the go test command. Continuing the example above, From 5ec139fa78ac6ba3f0f715b6aa9235d36346a4a4 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Wed, 22 Sep 2021 16:49:39 -0400 Subject: [PATCH 247/406] runtime: remove unnecessary argument stores for panicIndex etc. on ARM64 If register ABI is used, no need to store the arguments to stack. I forgot them in CL 323937. Change-Id: I888af2b547a8fc97d13716bc8e8f3acd5c5bc127 Reviewed-on: https://go-review.googlesource.com/c/go/+/351609 Trust: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Go Bot Reviewed-by: David Chase --- src/runtime/asm_arm64.s | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/runtime/asm_arm64.s b/src/runtime/asm_arm64.s index 8cbd17fa75..9e9d9314ef 100644 --- a/src/runtime/asm_arm64.s +++ b/src/runtime/asm_arm64.s @@ -1383,12 +1383,16 @@ 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 @@ -1427,12 +1431,16 @@ TEXT runtime·panicSliceAcapU(SB),NOSPLIT,$0-16 #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 @@ -1489,12 +1497,16 @@ TEXT runtime·panicSlice3BU(SB),NOSPLIT,$0-16 #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 From 994049a9ad3d4230d0835ce36616a34a466f6718 Mon Sep 17 00:00:00 2001 From: Michael Knyszek Date: Fri, 1 Oct 2021 15:11:51 -0400 Subject: [PATCH 248/406] runtime: add testing framework and basic tests for GC pacer This change creates a formal exported interface for the GC pacer and creates tests for it that simulate some series of GC cycles. The tests are completely driven by the real pacer implementation, except for assists, which are idealized (though revise is called repeatedly). For #44167. Change-Id: I0112242b07e7702595ca71001d781ad6c1fddd2d Reviewed-on: https://go-review.googlesource.com/c/go/+/353354 Trust: Michael Knyszek Run-TryBot: Michael Knyszek Reviewed-by: Michael Pratt TryBot-Result: Go Bot --- src/runtime/export_test.go | 78 +++++ src/runtime/mgcpacer_test.go | 590 +++++++++++++++++++++++++++++++++++ 2 files changed, 668 insertions(+) create mode 100644 src/runtime/mgcpacer_test.go diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index 01f917bded..2cc89e7121 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -1230,3 +1230,81 @@ func GCTestPointerClass(p unsafe.Pointer) string { } const Raceenabled = raceenabled + +const ( + GCBackgroundUtilization = gcBackgroundUtilization + GCGoalUtilization = gcGoalUtilization +) + +type GCController struct { + gcControllerState +} + +func NewGCController(gcPercent int) *GCController { + // Force the controller to escape. We're going to + // do 64-bit atomics on it, and if it gets stack-allocated + // on a 32-bit architecture, it may get allocated unaligned + // space. + g := escape(new(GCController)).(*GCController) + g.init(int32(gcPercent)) + return g +} + +func (c *GCController) StartCycle(stackSize, globalsSize uint64, scannableFrac float64, gomaxprocs int) { + c.scannableStackSize = stackSize + c.globalsScan = globalsSize + c.heapLive = c.trigger + c.heapScan += uint64(float64(c.trigger-c.heapMarked) * scannableFrac) + c.startCycle(0, gomaxprocs) +} + +func (c *GCController) AssistWorkPerByte() float64 { + return c.assistWorkPerByte.Load() +} + +func (c *GCController) HeapGoal() uint64 { + return c.heapGoal +} + +func (c *GCController) HeapLive() uint64 { + return c.heapLive +} + +func (c *GCController) HeapMarked() uint64 { + return c.heapMarked +} + +func (c *GCController) Trigger() uint64 { + return c.trigger +} + +type GCControllerReviseDelta struct { + HeapLive int64 + HeapScan int64 + HeapScanWork int64 + StackScanWork int64 + GlobalsScanWork int64 +} + +func (c *GCController) Revise(d GCControllerReviseDelta) { + c.heapLive += uint64(d.HeapLive) + c.heapScan += uint64(d.HeapScan) + c.scanWork += d.HeapScanWork + d.StackScanWork + d.GlobalsScanWork + c.revise() +} + +func (c *GCController) EndCycle(bytesMarked uint64, assistTime, elapsed int64, gomaxprocs int) { + c.assistTime = assistTime + triggerRatio := c.endCycle(elapsed, gomaxprocs, false) + c.resetLive(bytesMarked) + c.commit(triggerRatio) +} + +var escapeSink interface{} + +//go:noinline +func escape(x interface{}) interface{} { + escapeSink = x + escapeSink = nil + return x +} diff --git a/src/runtime/mgcpacer_test.go b/src/runtime/mgcpacer_test.go new file mode 100644 index 0000000000..5a9f46c6d1 --- /dev/null +++ b/src/runtime/mgcpacer_test.go @@ -0,0 +1,590 @@ +// Copyright 2021 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 runtime_test + +import ( + "fmt" + "math" + "math/rand" + . "runtime" + "testing" + "time" +) + +func TestGcPacer(t *testing.T) { + t.Parallel() + + const initialHeapBytes = 256 << 10 + for _, e := range []*gcExecTest{ + { + // The most basic test case: a steady-state heap. + // Growth to an O(MiB) heap, then constant heap size, alloc/scan rates. + name: "Steady", + gcPercent: 100, + globalsBytes: 32 << 10, + nCores: 8, + allocRate: constant(33.0), + scanRate: constant(1024.0), + growthRate: constant(2.0).sum(ramp(-1.0, 12)), + scannableFrac: constant(1.0), + stackBytes: constant(8192), + length: 50, + checker: func(t *testing.T, c []gcCycleResult) { + n := len(c) + if n >= 25 { + // Make sure the pacer settles into a non-degenerate state in at least 25 GC cycles. + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[n-2].gcUtilization, 0.005) + assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.95, 1.05) + } + }, + }, + { + // This tests the GC pacer's response to a small change in allocation rate. + name: "StepAlloc", + gcPercent: 100, + globalsBytes: 32 << 10, + nCores: 8, + allocRate: constant(33.0).sum(ramp(66.0, 1).delay(50)), + scanRate: constant(1024.0), + growthRate: constant(2.0).sum(ramp(-1.0, 12)), + scannableFrac: constant(1.0), + stackBytes: constant(8192), + length: 100, + checker: func(t *testing.T, c []gcCycleResult) { + n := len(c) + if (n >= 25 && n < 50) || n >= 75 { + // Make sure the pacer settles into a non-degenerate state in at least 25 GC cycles + // and then is able to settle again after a significant jump in allocation rate. + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[n-2].gcUtilization, 0.005) + assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.95, 1.05) + } + }, + }, + { + // This tests the GC pacer's response to a large change in allocation rate. + name: "HeavyStepAlloc", + gcPercent: 100, + globalsBytes: 32 << 10, + nCores: 8, + allocRate: constant(33).sum(ramp(330, 1).delay(50)), + scanRate: constant(1024.0), + growthRate: constant(2.0).sum(ramp(-1.0, 12)), + scannableFrac: constant(1.0), + stackBytes: constant(8192), + length: 100, + checker: func(t *testing.T, c []gcCycleResult) { + n := len(c) + if (n >= 25 && n < 50) || n >= 75 { + // Make sure the pacer settles into a non-degenerate state in at least 25 GC cycles + // and then is able to settle again after a significant jump in allocation rate. + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[n-2].gcUtilization, 0.005) + assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.95, 1.05) + } + }, + }, + { + // This tests the GC pacer's response to a change in the fraction of the scannable heap. + name: "StepScannableFrac", + gcPercent: 100, + globalsBytes: 32 << 10, + nCores: 8, + allocRate: constant(128.0), + scanRate: constant(1024.0), + growthRate: constant(2.0).sum(ramp(-1.0, 12)), + scannableFrac: constant(0.2).sum(unit(0.5).delay(50)), + stackBytes: constant(8192), + length: 100, + checker: func(t *testing.T, c []gcCycleResult) { + n := len(c) + if (n >= 25 && n < 50) || n >= 75 { + // Make sure the pacer settles into a non-degenerate state in at least 25 GC cycles + // and then is able to settle again after a significant jump in allocation rate. + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[n-2].gcUtilization, 0.005) + assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.95, 1.05) + } + }, + }, + { + // This test makes sure that in the face of a varying (in this case, oscillating) allocation + // rate, the pacer does a reasonably good job of staying abreast of the changes. + name: "OscAlloc", + gcPercent: 100, + globalsBytes: 32 << 10, + nCores: 8, + allocRate: oscillate(13, 0, 8).offset(67), + scanRate: constant(1024.0), + growthRate: constant(2.0).sum(ramp(-1.0, 12)), + scannableFrac: constant(1.0), + stackBytes: constant(8192), + length: 50, + checker: func(t *testing.T, c []gcCycleResult) { + n := len(c) + if n > 12 { + // After the 12th GC, the heap will stop growing. Now, just make sure that: + // 1. Utilization isn't varying _too_ much, and + // 2. The pacer is mostly keeping up with the goal. + assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.95, 1.05) + assertInRange(t, "GC utilization", c[n-1].gcUtilization, 0.25, 0.4) + } + }, + }, + { + // This test is the same as OscAlloc, but instead of oscillating, the allocation rate is jittery. + name: "JitterAlloc", + gcPercent: 100, + globalsBytes: 32 << 10, + nCores: 8, + allocRate: random(13, 0xf).offset(132), + scanRate: constant(1024.0), + growthRate: constant(2.0).sum(ramp(-1.0, 12), random(0.01, 0xe)), + scannableFrac: constant(1.0), + stackBytes: constant(8192), + length: 50, + checker: func(t *testing.T, c []gcCycleResult) { + n := len(c) + if n > 12 { + // After the 12th GC, the heap will stop growing. Now, just make sure that: + // 1. Utilization isn't varying _too_ much, and + // 2. The pacer is mostly keeping up with the goal. + assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.95, 1.05) + assertInRange(t, "GC utilization", c[n-1].gcUtilization, 0.25, 0.4) + } + }, + }, + { + // This test is the same as JitterAlloc, but with a much higher allocation rate. + // The jitter is proportionally the same. + name: "HeavyJitterAlloc", + gcPercent: 100, + globalsBytes: 32 << 10, + nCores: 8, + allocRate: random(33.0, 0x0).offset(330), + scanRate: constant(1024.0), + growthRate: constant(2.0).sum(ramp(-1.0, 12), random(0.01, 0x152)), + scannableFrac: constant(1.0), + stackBytes: constant(8192), + length: 50, + checker: func(t *testing.T, c []gcCycleResult) { + n := len(c) + if n > 13 { + // After the 12th GC, the heap will stop growing. Now, just make sure that: + // 1. Utilization isn't varying _too_ much, and + // 2. The pacer is mostly keeping up with the goal. + // We start at the 13th here because we want to use the 12th as a reference. + assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.95, 1.05) + // Unlike the other tests, GC utilization here will vary more and tend higher. + // Just make sure it's not going too crazy. + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[n-2].gcUtilization, 0.05) + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[11].gcUtilization, 0.07) + } + }, + }, + } { + e := e + t.Run(e.name, func(t *testing.T) { + t.Parallel() + + c := NewGCController(e.gcPercent) + var bytesAllocatedBlackLast int64 + results := make([]gcCycleResult, 0, e.length) + for i := 0; i < e.length; i++ { + cycle := e.next() + c.StartCycle(cycle.stackBytes, e.globalsBytes, cycle.scannableFrac, e.nCores) + + // Update pacer incrementally as we complete scan work. + const ( + revisePeriod = 500 * time.Microsecond + rateConv = 1024 * float64(revisePeriod) / float64(time.Millisecond) + ) + var nextHeapMarked int64 + if i == 0 { + nextHeapMarked = initialHeapBytes + } else { + nextHeapMarked = int64(float64(int64(c.HeapMarked())-bytesAllocatedBlackLast) * cycle.growthRate) + } + globalsScanWorkLeft := int64(e.globalsBytes) + stackScanWorkLeft := int64(cycle.stackBytes) + heapScanWorkLeft := int64(float64(nextHeapMarked) * cycle.scannableFrac) + doWork := func(work int64) (int64, int64, int64) { + var deltas [3]int64 + + // Do globals work first, then stacks, then heap. + for i, workLeft := range []*int64{&globalsScanWorkLeft, &stackScanWorkLeft, &heapScanWorkLeft} { + if *workLeft == 0 { + continue + } + if *workLeft > work { + deltas[i] += work + *workLeft -= work + work = 0 + break + } else { + deltas[i] += *workLeft + work -= *workLeft + *workLeft = 0 + } + } + return deltas[0], deltas[1], deltas[2] + } + var ( + gcDuration int64 + assistTime int64 + bytesAllocatedBlack int64 + ) + for heapScanWorkLeft+stackScanWorkLeft+globalsScanWorkLeft > 0 { + // Simulate GC assist pacing. + // + // Note that this is an idealized view of the GC assist pacing + // mechanism. + + // From the assist ratio and the alloc and scan rates, we can idealize what + // the GC CPU utilization looks like. + // + // We start with assistRatio = (bytes of scan work) / (bytes of runway) (by definition). + // + // Over revisePeriod, we can also calculate how many bytes are scanned and + // allocated, given some GC CPU utilization u: + // + // bytesScanned = scanRate * rateConv * nCores * u + // bytesAllocated = allocRate * rateConv * nCores * (1 - u) + // + // During revisePeriod, assistRatio is kept constant, and GC assists kick in to + // maintain it. Specifically, they act to prevent too many bytes being allocated + // compared to how many bytes are scanned. It directly defines the ratio of + // bytesScanned to bytesAllocated over this period, hence: + // + // assistRatio = bytesScanned / bytesAllocated + // + // From this, we can solve for utilization, because everything else has already + // been determined: + // + // assistRatio = (scanRate * rateConv * nCores * u) / (allocRate * rateConv * nCores * (1 - u)) + // assistRatio = (scanRate * u) / (allocRate * (1 - u)) + // assistRatio * allocRate * (1-u) = scanRate * u + // assistRatio * allocRate - assistRatio * allocRate * u = scanRate * u + // assistRatio * allocRate = assistRatio * allocRate * u + scanRate * u + // assistRatio * allocRate = (assistRatio * allocRate + scanRate) * u + // u = (assistRatio * allocRate) / (assistRatio * allocRate + scanRate) + // + // Note that this may give a utilization that is _less_ than GCBackgroundUtilization, + // which isn't possible in practice because of dedicated workers. Thus, this case + // must be interpreted as GC assists not kicking in at all, and just round up. All + // downstream values will then have this accounted for. + assistRatio := c.AssistWorkPerByte() + utilization := assistRatio * cycle.allocRate / (assistRatio*cycle.allocRate + cycle.scanRate) + if utilization < GCBackgroundUtilization { + utilization = GCBackgroundUtilization + } + + // Knowing the utilization, calculate bytesScanned and bytesAllocated. + bytesScanned := int64(cycle.scanRate * rateConv * float64(e.nCores) * utilization) + bytesAllocated := int64(cycle.allocRate * rateConv * float64(e.nCores) * (1 - utilization)) + + // Subtract work from our model. + globalsScanned, stackScanned, heapScanned := doWork(bytesScanned) + + // doWork may not use all of bytesScanned. + // In this case, the GC actually ends sometime in this period. + // Let's figure out when, exactly, and adjust bytesAllocated too. + actualElapsed := revisePeriod + actualAllocated := bytesAllocated + if actualScanned := globalsScanned + stackScanned + heapScanned; actualScanned < bytesScanned { + // actualScanned = scanRate * rateConv * (t / revisePeriod) * nCores * u + // => t = actualScanned * revisePeriod / (scanRate * rateConv * nCores * u) + actualElapsed = time.Duration(float64(actualScanned) * float64(revisePeriod) / (cycle.scanRate * rateConv * float64(e.nCores) * utilization)) + actualAllocated = int64(cycle.allocRate * rateConv * float64(actualElapsed) / float64(revisePeriod) * float64(e.nCores) * (1 - utilization)) + } + + // Ask the pacer to revise. + c.Revise(GCControllerReviseDelta{ + HeapLive: actualAllocated, + HeapScan: int64(float64(actualAllocated) * cycle.scannableFrac), + HeapScanWork: heapScanned, + StackScanWork: stackScanned, + GlobalsScanWork: globalsScanned, + }) + + // Accumulate variables. + assistTime += int64(float64(actualElapsed) * float64(e.nCores) * (utilization - GCBackgroundUtilization)) + gcDuration += int64(actualElapsed) + bytesAllocatedBlack += actualAllocated + } + + // Put together the results, log them, and concatenate them. + result := gcCycleResult{ + cycle: i + 1, + heapLive: c.HeapMarked(), + heapScannable: int64(float64(int64(c.HeapMarked())-bytesAllocatedBlackLast) * cycle.scannableFrac), + heapTrigger: c.Trigger(), + heapPeak: c.HeapLive(), + heapGoal: c.HeapGoal(), + gcUtilization: float64(assistTime)/(float64(gcDuration)*float64(e.nCores)) + GCBackgroundUtilization, + } + t.Log("GC", result.String()) + results = append(results, result) + + // Run the checker for this test. + e.check(t, results) + + c.EndCycle(uint64(nextHeapMarked+bytesAllocatedBlack), assistTime, gcDuration, e.nCores) + + bytesAllocatedBlackLast = bytesAllocatedBlack + } + }) + } +} + +type gcExecTest struct { + name string + + gcPercent int + globalsBytes uint64 + nCores int + + allocRate float64Stream // > 0, KiB / cpu-ms + scanRate float64Stream // > 0, KiB / cpu-ms + growthRate float64Stream // > 0 + scannableFrac float64Stream // Clamped to [0, 1] + stackBytes float64Stream // Multiple of 2048. + length int + + checker func(*testing.T, []gcCycleResult) +} + +// minRate is an arbitrary minimum for allocRate, scanRate, and growthRate. +// These values just cannot be zero. +const minRate = 0.0001 + +func (e *gcExecTest) next() gcCycle { + return gcCycle{ + allocRate: e.allocRate.min(minRate)(), + scanRate: e.scanRate.min(minRate)(), + growthRate: e.growthRate.min(minRate)(), + scannableFrac: e.scannableFrac.limit(0, 1)(), + stackBytes: uint64(e.stackBytes.quantize(2048).min(0)()), + } +} + +func (e *gcExecTest) check(t *testing.T, results []gcCycleResult) { + t.Helper() + + // Do some basic general checks first. + n := len(results) + switch n { + case 0: + t.Fatal("no results passed to check") + return + case 1: + if results[0].cycle != 1 { + t.Error("first cycle has incorrect number") + } + default: + if results[n-1].cycle != results[n-2].cycle+1 { + t.Error("cycle numbers out of order") + } + } + if u := results[n-1].gcUtilization; u < 0 || u > 1 { + t.Fatal("GC utilization not within acceptable bounds") + } + if s := results[n-1].heapScannable; s < 0 { + t.Fatal("heapScannable is negative") + } + if e.checker == nil { + t.Fatal("test-specific checker is missing") + } + + // Run the test-specific checker. + e.checker(t, results) +} + +type gcCycle struct { + allocRate float64 + scanRate float64 + growthRate float64 + scannableFrac float64 + stackBytes uint64 +} + +type gcCycleResult struct { + cycle int + + // These come directly from the pacer, so uint64. + heapLive uint64 + heapTrigger uint64 + heapGoal uint64 + heapPeak uint64 + + // These are produced by the simulation, so int64 and + // float64 are more appropriate, so that we can check for + // bad states in the simulation. + heapScannable int64 + gcUtilization float64 +} + +func (r *gcCycleResult) goalRatio() float64 { + return float64(r.heapPeak) / float64(r.heapGoal) +} + +func (r *gcCycleResult) String() string { + return fmt.Sprintf("%d %2.1f%% %d->%d->%d (goal: %d)", r.cycle, r.gcUtilization*100, r.heapLive, r.heapTrigger, r.heapPeak, r.heapGoal) +} + +func assertInEpsilon(t *testing.T, name string, a, b, epsilon float64) { + t.Helper() + assertInRange(t, name, a, b-epsilon, b+epsilon) +} + +func assertInRange(t *testing.T, name string, a, min, max float64) { + t.Helper() + if a < min || a > max { + t.Errorf("%s not in range (%f, %f): %f", name, min, max, a) + } +} + +// float64Stream is a function that generates an infinite stream of +// float64 values when called repeatedly. +type float64Stream func() float64 + +// constant returns a stream that generates the value c. +func constant(c float64) float64Stream { + return func() float64 { + return c + } +} + +// unit returns a stream that generates a single peak with +// amplitude amp, followed by zeroes. +// +// In another manner of speaking, this is the Kronecker delta. +func unit(amp float64) float64Stream { + dropped := false + return func() float64 { + if dropped { + return 0 + } + dropped = true + return amp + } +} + +// oscillate returns a stream that oscillates sinusoidally +// with the given amplitude, phase, and period. +func oscillate(amp, phase float64, period int) float64Stream { + var cycle int + return func() float64 { + p := float64(cycle)/float64(period)*2*math.Pi + phase + cycle++ + if cycle == period { + cycle = 0 + } + return math.Sin(p) * amp + } +} + +// ramp returns a stream that moves from zero to height +// over the course of length steps. +func ramp(height float64, length int) float64Stream { + var cycle int + return func() float64 { + h := height * float64(cycle) / float64(length) + if cycle < length { + cycle++ + } + return h + } +} + +// random returns a stream that generates random numbers +// between -amp and amp. +func random(amp float64, seed int64) float64Stream { + r := rand.New(rand.NewSource(seed)) + return func() float64 { + return ((r.Float64() - 0.5) * 2) * amp + } +} + +// delay returns a new stream which is a buffered version +// of f: it returns zero for cycles steps, followed by f. +func (f float64Stream) delay(cycles int) float64Stream { + zeroes := 0 + return func() float64 { + if zeroes < cycles { + zeroes++ + return 0 + } + return f() + } +} + +// scale returns a new stream that is f, but attenuated by a +// constant factor. +func (f float64Stream) scale(amt float64) float64Stream { + return func() float64 { + return f() * amt + } +} + +// offset returns a new stream that is f but offset by amt +// at each step. +func (f float64Stream) offset(amt float64) float64Stream { + return func() float64 { + old := f() + return old + amt + } +} + +// sum returns a new stream that is the sum of all input streams +// at each step. +func (f float64Stream) sum(fs ...float64Stream) float64Stream { + return func() float64 { + sum := f() + for _, s := range fs { + sum += s() + } + return sum + } +} + +// quantize returns a new stream that rounds f to a multiple +// of mult at each step. +func (f float64Stream) quantize(mult float64) float64Stream { + return func() float64 { + r := f() / mult + if r < 0 { + return math.Ceil(r) * mult + } + return math.Floor(r) * mult + } +} + +// min returns a new stream that replaces all values produced +// by f lower than min with min. +func (f float64Stream) min(min float64) float64Stream { + return func() float64 { + return math.Max(min, f()) + } +} + +// max returns a new stream that replaces all values produced +// by f higher than max with max. +func (f float64Stream) max(max float64) float64Stream { + return func() float64 { + return math.Min(max, f()) + } +} + +// limit returns a new stream that replaces all values produced +// by f lower than min with min and higher than max with max. +func (f float64Stream) limit(min, max float64) float64Stream { + return func() float64 { + v := f() + if v < min { + v = min + } else if v > max { + v = max + } + return v + } +} From c76893d0da115a63374982196384f78fff224d55 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Fri, 8 Jan 2021 19:09:07 +0100 Subject: [PATCH 249/406] crypto/elliptic: refactor P-224 field implementation Improved readability, replaced constant time bit masked operations with named functions, added comments. The behavior of every function should be unchanged. The largest change is the logic that in p224Contract checks if the value is greater than or equal to p. Instead of a lot of error-prone masking, we run a throwaway subtraction chain and look at the final borrow bit. We could also not throw away the subtraction chain output and do a constant time select instead of another masked subtraction, but we'd still have to fix any underflows (because these are unsaturated limbs and they underflow at 2^32 instead of 2^28). That's similar but different from the carry-down chain we do elsewhere in that function (which does undeflow fixing and borrow at the same time). I thought having both variations in the same function would be confusing. Here's how it would look like. var b uint32 var outMinusP p224FieldElement for i := 0; i < len(out); i++ { outMinusP[i], b = bits.Sub32(out[i], p224P[i], b) } for i := 0; i < 3; i++ { mask := maskIfNegative(outMinusP[i]) outMinusP[i] += (1 << 28) & mask // Note we DON'T borrow here, because it happened above. } for i := 0; i < len(out); i++ { out[i] = select32(b, out[i], outMinusP[i]) } Change-Id: I00932e8f171eff7f441b45666dccfd219ecbbc50 Reviewed-on: https://go-review.googlesource.com/c/go/+/326311 Trust: Filippo Valsorda Reviewed-by: Julie Qiu --- src/crypto/elliptic/p224.go | 221 +++++++++++++------------------ src/crypto/elliptic/p224_test.go | 4 +- 2 files changed, 91 insertions(+), 134 deletions(-) diff --git a/src/crypto/elliptic/p224.go b/src/crypto/elliptic/p224.go index 8c76021464..8f3622c89c 100644 --- a/src/crypto/elliptic/p224.go +++ b/src/crypto/elliptic/p224.go @@ -10,7 +10,9 @@ package elliptic // See https://www.imperialviolet.org/2010/12/04/ecc.html ([1]) for background. import ( + "encoding/binary" "math/big" + "math/bits" ) var p224 p224Curve @@ -139,41 +141,22 @@ func (curve p224Curve) ScalarBaseMult(scalar []byte) (x, y *big.Int) { type p224FieldElement [8]uint32 // p224P is the order of the field, represented as a p224FieldElement. -var p224P = [8]uint32{1, 0, 0, 0xffff000, 0xfffffff, 0xfffffff, 0xfffffff, 0xfffffff} +var p224P = p224FieldElement{1, 0, 0, 0xffff000, 0xfffffff, 0xfffffff, 0xfffffff, 0xfffffff} // p224IsZero returns 1 if a == 0 mod p and 0 otherwise. // // a[i] < 2**29 func p224IsZero(a *p224FieldElement) uint32 { - // Since a p224FieldElement contains 224 bits there are two possible - // representations of 0: 0 and p. var minimal p224FieldElement p224Contract(&minimal, a) - var isZero, isP uint32 - for i, v := range minimal { - isZero |= v - isP |= v - p224P[i] + var acc uint32 + for _, v := range minimal { + acc |= v } + mask := ^maskIsNotZero(acc) - // If either isZero or isP is 0, then we should return 1. - isZero |= isZero >> 16 - isZero |= isZero >> 8 - isZero |= isZero >> 4 - isZero |= isZero >> 2 - isZero |= isZero >> 1 - - isP |= isP >> 16 - isP |= isP >> 8 - isP |= isP >> 4 - isP |= isP >> 2 - isP |= isP >> 1 - - // For isZero and isP, the LSB is 0 iff all the bits are zero. - result := isZero & isP - result = (^result) & 1 - - return result + return 1 & mask } // p224Add computes *out = a+b @@ -192,6 +175,12 @@ const two31m15m3 = 1<<31 - 1<<15 - 1<<3 // p224ZeroModP31 is 0 mod p where bit 31 is set in all limbs so that we can // subtract smaller amounts without underflow. See the section "Subtraction" in // [1] for reasoning. +// +// To calculate this value, start by adding 2³¹ to the lowest limb and +// subtracting 2³ from the next one to compensate. Repeat for each next limb, +// ending up with 2³¹ - 2³ in each of them, and a carry of -2³. Apply the +// reduction identity, and we need to subtract 2³ * 2⁹⁶ - 2³ = 2¹⁵ * 2⁸⁴ - 2³ so +// we subtract 2¹⁵ from the 4th limb and add 2³ to the first limb. var p224ZeroModP31 = []uint32{two31p3, two31m3, two31m3, two31m15m3, two31m3, two31m3, two31m3, two31m3} // p224Sub computes *out = a-b @@ -225,7 +214,7 @@ const bottom28Bits = 0xfffffff // a[i] < 2**29, b[i] < 2**30 (or vice versa) // out[i] < 2**29 func p224Mul(out, a, b *p224FieldElement, tmp *p224LargeFieldElement) { - for i := 0; i < 15; i++ { + for i := range tmp { tmp[i] = 0 } @@ -243,7 +232,7 @@ func p224Mul(out, a, b *p224FieldElement, tmp *p224LargeFieldElement) { // a[i] < 2**29 // out[i] < 2**29 func p224Square(out, a *p224FieldElement, tmp *p224LargeFieldElement) { - for i := 0; i < 15; i++ { + for i := range tmp { tmp[i] = 0 } @@ -253,7 +242,7 @@ func p224Square(out, a *p224FieldElement, tmp *p224LargeFieldElement) { if i == j { tmp[i+j] += r } else { - tmp[i+j] += r << 1 + tmp[i+j] += r * 2 } } } @@ -264,22 +253,33 @@ func p224Square(out, a *p224FieldElement, tmp *p224LargeFieldElement) { // ReduceLarge converts a p224LargeFieldElement to a p224FieldElement. // // in[i] < 2**62 +// out[i] < 2**29 func p224ReduceLarge(out *p224FieldElement, in *p224LargeFieldElement) { for i := 0; i < 8; i++ { in[i] += p224ZeroModP63[i] } - // Eliminate the coefficients at 2**224 and greater. + // Eliminate the coefficients at 2**224 and greater by applying the + // reduction identity. + // + // a + top * 2²²⁴ = a + top * 2⁹⁶ - top + // + // Since top here is in[8..14], both the subtraction at offset 0 and the + // addition at offset 96 (3 * 28 + 16) span multiple limbs. The subtraction + // can't underflow because of the p224ZeroModP63 addition above, while the + // addition can't overflow because of the 62 bit input bounds. for i := 14; i >= 8; i-- { in[i-8] -= in[i] in[i-5] += (in[i] & 0xffff) << 12 in[i-4] += in[i] >> 16 } in[8] = 0 - // in[0..8] < 2**64 + // in[0..7] < 2**64 + // in[9..14] discarded - // As the values become small enough, we start to store them in |out| - // and use 32-bit operations. + // Run a carry chain and light reduction. Keep [0] large so we can do the + // subtraction safely. As the values become small enough, we start to store + // them in out and use 32-bit operations. for i := 1; i < 8; i++ { in[i+1] += in[i] >> 28 out[i] = uint32(in[i] & bottom28Bits) @@ -292,6 +292,7 @@ func p224ReduceLarge(out *p224FieldElement, in *p224LargeFieldElement) { // out[4] < 2**29 // out[1,2,5..7] < 2**28 + // Carry the overflow of [0] into the short 28 bit limbs. out[0] = uint32(in[0] & bottom28Bits) out[1] += uint32((in[0] >> 28) & bottom28Bits) out[2] += uint32(in[0] >> 56) @@ -312,28 +313,23 @@ func p224Reduce(a *p224FieldElement) { top := a[7] >> 28 a[7] &= bottom28Bits - // top < 2**4 - mask := top - mask |= mask >> 2 - mask |= mask >> 1 - mask <<= 31 - mask = uint32(int32(mask) >> 31) - // Mask is all ones if top != 0, all zero otherwise - a[0] -= top a[3] += top << 12 - // We may have just made a[0] negative but, if we did, then we must - // have added something to a[3], this it's > 2**12. Therefore we can - // carry down to a[0]. + // We may have just made a[0] negative but if we did top must have been not + // zero, so a[3] is not zero, so we can carry down to a[0]. (Note that we + // don't actually check if a[0] went negative, like in p224Contract, nor we + // try to stop the carry at a[1] or a[2], because here we can afford to go + // above 28 bits, so instead we carry all the way down from a[3].) + mask := maskIsNotZero(top) a[3] -= 1 & mask a[2] += mask & (1<<28 - 1) a[1] += mask & (1<<28 - 1) a[0] += mask & (1 << 28) } -// p224Invert calculates *out = in**-1 by computing in**(2**224 - 2**96 - 1), -// i.e. Fermat's little theorem. +// p224Invert calculates *out = in**-1 by using Fermat's little theorem and +// computing in**(p-2) = in**(2**224 - 2**96 - 1). func p224Invert(out, in *p224FieldElement) { var f1, f2, f3, f4 p224FieldElement var c p224LargeFieldElement @@ -408,13 +404,14 @@ func p224Contract(out, in *p224FieldElement) { // out[0] negative then we know that out[3] is sufficiently positive // because we just added to it. for i := 0; i < 3; i++ { - mask := uint32(int32(out[i]) >> 31) + mask := maskIsNegative(out[i]) out[i] += (1 << 28) & mask out[i+1] -= 1 & mask } // We might have pushed out[3] over 2**28 so we perform another, partial, - // carry chain. + // carry chain; carry the overflow according to the reduction identity; and + // carry down in case we made out[0] negative. for i := 3; i < 7; i++ { out[i+1] += out[i] >> 28 out[i] &= bottom28Bits @@ -422,10 +419,15 @@ func p224Contract(out, in *p224FieldElement) { top = out[7] >> 28 out[7] &= bottom28Bits - // Eliminate top while maintaining the same value mod p. out[0] -= top out[3] += top << 12 + for i := 0; i < 3; i++ { + mask := maskIsNegative(out[i]) + out[i] += (1 << 28) & mask + out[i+1] -= 1 & mask + } + // There are two cases to consider for out[3]: // 1) The first time that we eliminated top, we didn't push out[3] over // 2**28. In this case, the partial carry chain didn't change any values @@ -436,60 +438,14 @@ func p224Contract(out, in *p224FieldElement) { // In both cases, out[3] cannot have overflowed when we eliminated top for // the second time. - // Again, we may just have made out[0] negative, so do the same carry down. - // As before, if we made out[0] negative then we know that out[3] is - // sufficiently positive. - for i := 0; i < 3; i++ { - mask := uint32(int32(out[i]) >> 31) - out[i] += (1 << 28) & mask - out[i+1] -= 1 & mask + // Now we need to subtract p if the value is >= p. To check, we subtract p + // with a borrow chain and look at the final borrow bit. + var b uint32 + for i := 0; i < len(out); i++ { + _, b = bits.Sub32(out[i], p224P[i], b) } + mask := ^maskIsNotZero(b) - // Now we see if the value is >= p and, if so, subtract p. - - // First we build a mask from the top four limbs, which must all be - // equal to bottom28Bits if the whole value is >= p. If top4AllOnes - // ends up with any zero bits in the bottom 28 bits, then this wasn't - // true. - top4AllOnes := uint32(0xffffffff) - for i := 4; i < 8; i++ { - top4AllOnes &= out[i] - } - top4AllOnes |= 0xf0000000 - // Now we replicate any zero bits to all the bits in top4AllOnes. - top4AllOnes &= top4AllOnes >> 16 - top4AllOnes &= top4AllOnes >> 8 - top4AllOnes &= top4AllOnes >> 4 - top4AllOnes &= top4AllOnes >> 2 - top4AllOnes &= top4AllOnes >> 1 - top4AllOnes = uint32(int32(top4AllOnes<<31) >> 31) - - // Now we test whether the bottom three limbs are non-zero. - bottom3NonZero := out[0] | out[1] | out[2] - bottom3NonZero |= bottom3NonZero >> 16 - bottom3NonZero |= bottom3NonZero >> 8 - bottom3NonZero |= bottom3NonZero >> 4 - bottom3NonZero |= bottom3NonZero >> 2 - bottom3NonZero |= bottom3NonZero >> 1 - bottom3NonZero = uint32(int32(bottom3NonZero<<31) >> 31) - - // Assuming top4AllOnes != 0, everything depends on the value of out[3]. - // If it's > 0xffff000 then the whole value is > p - // If it's = 0xffff000 and bottom3NonZero != 0, then the whole value is >= p - // If it's < 0xffff000, then the whole value is < p - n := 0xffff000 - out[3] - out3Equal := n - out3Equal |= out3Equal >> 16 - out3Equal |= out3Equal >> 8 - out3Equal |= out3Equal >> 4 - out3Equal |= out3Equal >> 2 - out3Equal |= out3Equal >> 1 - out3Equal = ^uint32(int32(out3Equal<<31) >> 31) - - // If out[3] > 0xffff000 then n's MSB will be one. - out3GT := uint32(int32(n) >> 31) - - mask := top4AllOnes & ((out3Equal & bottom3NonZero) | out3GT) out[0] -= 1 & mask out[3] -= 0xffff000 & mask out[4] -= 0xfffffff & mask @@ -501,12 +457,26 @@ func p224Contract(out, in *p224FieldElement) { // out[0..3] needs to be positive and able to absorb the -1 or the value // would have been < p, and the subtraction wouldn't have happened. for i := 0; i < 3; i++ { - mask := uint32(int32(out[i]) >> 31) + mask := maskIsNegative(out[i]) out[i] += (1 << 28) & mask out[i+1] -= 1 & mask } } +// maskIsNegative returns 0xffffffff if the most significant bit of v is set, +// and 0 otherwise. +func maskIsNegative(v uint32) uint32 { return uint32(int32(v) >> 31) } + +// maskIfNegative returns 0xffffffff if v is not zero, and 0 otherwise. +func maskIsNotZero(v uint32) uint32 { + v |= v >> 16 + v |= v >> 8 + v |= v >> 4 + v |= v >> 2 + v |= v >> 1 + return uint32(int32(v<<31) >> 31) +} + // Group element functions. // // These functions deal with group elements. The group is an elliptic curve @@ -650,14 +620,11 @@ func p224DoubleJacobian(x3, y3, z3, x1, y1, z1 *p224FieldElement) { p224Reduce(y3) } -// p224CopyConditional sets *out = *in iff the least-significant-bit of control -// is true, and it runs in constant time. +// p224CopyConditional sets *out = *in in constant time if control is not zero. func p224CopyConditional(out, in *p224FieldElement, control uint32) { - control <<= 31 - control = uint32(int32(control) >> 31) - + mask := maskIsNotZero(control) for i := 0; i < 8; i++ { - out[i] ^= (out[i] ^ in[i]) & control + out[i] ^= (out[i] ^ in[i]) & mask } } @@ -702,37 +669,27 @@ func p224ToAffine(x, y, z *p224FieldElement) (*big.Int, *big.Int) { } // get28BitsFromEnd returns the least-significant 28 bits from buf>>shift, -// where buf is interpreted as a big-endian number. -func get28BitsFromEnd(buf []byte, shift uint) (uint32, []byte) { - var ret uint32 - - for i := uint(0); i < 4; i++ { - var b byte - if l := len(buf); l > 0 { - b = buf[l-1] - // We don't remove the byte if we're about to return and we're not - // reading all of it. - if i != 3 || shift == 4 { - buf = buf[:l-1] - } - } - ret |= uint32(b) << (8 * i) >> shift +// where buf is interpreted as a big-endian number. shift must be at most +// 4 bits higher than a multiple of 8. +func get28BitsFromEnd(buf []byte, shift int) uint32 { + buf = buf[:len(buf)-shift/8] + shift = shift % 8 + if shift > 4 { + panic("misuse of get28BitsFromEnd") } + + ret := binary.BigEndian.Uint32(buf[len(buf)-4:]) + ret >>= shift ret &= bottom28Bits - return ret, buf + return ret } // p224FromBig sets *out = *in. func p224FromBig(out *p224FieldElement, in *big.Int) { - bytes := in.Bytes() - out[0], bytes = get28BitsFromEnd(bytes, 0) - out[1], bytes = get28BitsFromEnd(bytes, 4) - out[2], bytes = get28BitsFromEnd(bytes, 0) - out[3], bytes = get28BitsFromEnd(bytes, 4) - out[4], bytes = get28BitsFromEnd(bytes, 0) - out[5], bytes = get28BitsFromEnd(bytes, 4) - out[6], bytes = get28BitsFromEnd(bytes, 0) - out[7], bytes = get28BitsFromEnd(bytes, 4) + bytes := in.FillBytes(make([]byte, 224/8)) + for i := range out { + out[i] = get28BitsFromEnd(bytes, 28*i) + } } // p224ToBig returns in as a big.Int. diff --git a/src/crypto/elliptic/p224_test.go b/src/crypto/elliptic/p224_test.go index b213b273d2..3e0c78b0f9 100644 --- a/src/crypto/elliptic/p224_test.go +++ b/src/crypto/elliptic/p224_test.go @@ -261,7 +261,7 @@ func TestP224IsZero(t *testing.T) { if got := p224IsZero(&p224FieldElement{}); got != 1 { t.Errorf("p224IsZero(0) = %d, expected 1", got) } - if got := p224IsZero((*p224FieldElement)(&p224P)); got != 1 { + if got := p224IsZero(&p224P); got != 1 { t.Errorf("p224IsZero(p) = %d, expected 1", got) } if got := p224IsZero(&p224FieldElement{1}); got != 0 { @@ -294,7 +294,7 @@ func TestP224Invert(t *testing.T) { t.Errorf("p224Invert(0) = %x, expected 0", out) } - p224Invert(&out, (*p224FieldElement)(&p224P)) + p224Invert(&out, &p224P) if got := p224IsZero(&out); got != 1 { t.Errorf("p224Invert(p) = %x, expected 0", out) } From 3571ab58b8069fd945427ba49c4d8a702325bdb0 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Fri, 29 Oct 2021 17:47:32 -0400 Subject: [PATCH 250/406] go/types: make built-in to accept type sets with single underlying types This is a straightforward port of CL 357776 to go/types. Change-Id: I64220840a01f57cd7955f7d956b9aa8227473b46 Reviewed-on: https://go-review.googlesource.com/c/go/+/359874 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/builtins.go | 6 +++--- src/go/types/testdata/check/builtins.go2 | 22 +++++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/go/types/builtins.go b/src/go/types/builtins.go index 29a8339f3e..de7d7e6b5f 100644 --- a/src/go/types/builtins.go +++ b/src/go/types/builtins.go @@ -469,13 +469,13 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b } var min int // minimum number of arguments - switch optype(T).(type) { + switch singleUnder(T).(type) { case *Slice: min = 2 case *Map, *Chan: min = 1 - case *top: - check.invalidArg(arg0, _InvalidMake, "cannot make %s; type parameter has no structural type", arg0) + case nil: + check.errorf(arg0, _InvalidMake, "cannot make %s; type set has no single underlying type", arg0) return default: check.invalidArg(arg0, _InvalidMake, "cannot make %s; type must be slice, map, or channel", arg0) diff --git a/src/go/types/testdata/check/builtins.go2 b/src/go/types/testdata/check/builtins.go2 index f9b6ec7926..7cca6fd714 100644 --- a/src/go/types/testdata/check/builtins.go2 +++ b/src/go/types/testdata/check/builtins.go2 @@ -127,15 +127,18 @@ func _[T M4[K, V], K comparable, V any](m T) { // make +type myChan chan int + func _[ - S1 interface{ []int }, - S2 interface{ []int | chan int }, + S1 ~[]int, + S2 ~[]int | ~chan int, - M1 interface{ map[string]int }, - M2 interface{ map[string]int | chan int }, + M1 ~map[string]int, + M2 ~map[string]int | ~chan int, - C1 interface{ chan int }, - C2 interface{ chan int | chan string }, + C1 ~chan int, + C2 ~chan int | ~chan string, + C3 chan int | myChan, // single underlying type ]() { type S0 []int _ = make([]int, 10) @@ -145,7 +148,7 @@ func _[ _ = make /* ERROR expects 2 or 3 arguments */ (S1) _ = make(S1, 10, 20) _ = make /* ERROR expects 2 or 3 arguments */ (S1, 10, 20, 30) - _ = make(S2 /* ERROR cannot make .* no structural type */ , 10) + _ = make(S2 /* ERROR cannot make .* no single underlying type */ , 10) type M0 map[string]int _ = make(map[string]int) @@ -153,7 +156,7 @@ func _[ _ = make(M1) _ = make(M1, 10) _ = make/* ERROR expects 1 or 2 arguments */(M1, 10, 20) - _ = make(M2 /* ERROR cannot make .* no structural type */ ) + _ = make(M2 /* ERROR cannot make .* no single underlying type */ ) type C0 chan int _ = make(chan int) @@ -161,7 +164,8 @@ func _[ _ = make(C1) _ = make(C1, 10) _ = make/* ERROR expects 1 or 2 arguments */(C1, 10, 20) - _ = make(C2 /* ERROR cannot make .* no structural type */ ) + _ = make(C2 /* ERROR cannot make .* no single underlying type */ ) + _ = make(C3) } // unsafe.Alignof From 02bd226b8abb713061fcef4e53ffebc57770466b Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Fri, 29 Oct 2021 18:01:09 -0400 Subject: [PATCH 251/406] go/types: range clause to accept type sets with single underlying types This is a port of CL 357778 to go/types, adjusted to include error codes and to use the different range statement syntax in go/ast. Change-Id: Id537c195cd33a8b422a366269ca8730c2a5bccf1 Reviewed-on: https://go-review.googlesource.com/c/go/+/359875 Trust: Robert Findley Run-TryBot: Robert Findley Reviewed-by: Robert Griesemer --- src/go/types/stmt.go | 73 +++++++++------------- src/go/types/testdata/check/typeparams.go2 | 12 ++-- 2 files changed, 36 insertions(+), 49 deletions(-) diff --git a/src/go/types/stmt.go b/src/go/types/stmt.go index 92542597c5..7197310bd9 100644 --- a/src/go/types/stmt.go +++ b/src/go/types/stmt.go @@ -832,20 +832,28 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.Stmt) { // determine key/value types var key, val Type if x.mode != invalid { - // Ranging over a type parameter is permitted if it has a structural type. - typ := optype(x.typ) - if _, ok := typ.(*Chan); ok && s.Value != nil { - check.softErrorf(atPos(s.Value.Pos()), _InvalidIterVar, "range over %s permits only one iteration variable", &x) - // ok to continue - } - var msg string - key, val, msg = rangeKeyVal(typ, isVarName(s.Key), isVarName(s.Value)) - if key == nil || msg != "" { - if msg != "" { - // TODO(rFindley) should this be parenthesized, to be consistent with other qualifiers? - msg = ": " + msg + // Ranging over a type parameter is permitted if it has a single underlying type. + var cause string + u := singleUnder(x.typ) + switch t := u.(type) { + case nil: + cause = "type set has no single underlying type" + case *Chan: + if s.Value != nil { + check.softErrorf(s.Value, _InvalidIterVar, "range over %s permits only one iteration variable", &x) + // ok to continue + } + if t.dir == SendOnly { + cause = "receive from send-only channel" + } + } + key, val = rangeKeyVal(u) + if key == nil || cause != "" { + if cause == "" { + check.softErrorf(&x, _InvalidRangeExpr, "cannot range over %s", &x) + } else { + check.softErrorf(&x, _InvalidRangeExpr, "cannot range over %s (%s)", &x, cause) } - check.softErrorf(&x, _InvalidRangeExpr, "cannot range over %s%s", &x, msg) // ok to continue } } @@ -930,44 +938,23 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.Stmt) { } } -// isVarName reports whether x is a non-nil, non-blank (_) expression. -func isVarName(x ast.Expr) bool { - if x == nil { - return false - } - ident, _ := unparen(x).(*ast.Ident) - return ident == nil || ident.Name != "_" -} - // rangeKeyVal returns the key and value type produced by a range clause -// over an expression of type typ, and possibly an error message. If the -// range clause is not permitted the returned key is nil or msg is not -// empty (in that case we still may have a non-nil key type which can be -// used to reduce the chance for follow-on errors). -// The wantKey, wantVal, and hasVal flags indicate which of the iteration -// variables are used or present; this matters if we range over a generic -// type where not all keys or values are of the same type. -func rangeKeyVal(typ Type, wantKey, wantVal bool) (Type, Type, string) { +// over an expression of type typ. If the range clause is not permitted +// the results are nil. +func rangeKeyVal(typ Type) (key, val Type) { switch typ := arrayPtrDeref(typ).(type) { case *Basic: if isString(typ) { - return Typ[Int], universeRune, "" // use 'rune' name + return Typ[Int], universeRune // use 'rune' name } case *Array: - return Typ[Int], typ.elem, "" + return Typ[Int], typ.elem case *Slice: - return Typ[Int], typ.elem, "" + return Typ[Int], typ.elem case *Map: - return typ.key, typ.elem, "" + return typ.key, typ.elem case *Chan: - var msg string - if typ.dir == SendOnly { - msg = "receive from send-only channel" - } - return typ.elem, Typ[Invalid], msg - case *top: - // we have a type parameter with no structural type - return nil, nil, "no structural type" + return typ.elem, Typ[Invalid] } - return nil, nil, "" + return } diff --git a/src/go/types/testdata/check/typeparams.go2 b/src/go/types/testdata/check/typeparams.go2 index 10f84314fd..c4b0c212d2 100644 --- a/src/go/types/testdata/check/typeparams.go2 +++ b/src/go/types/testdata/check/typeparams.go2 @@ -184,7 +184,7 @@ func _[ for _, _ = range b1 {} var b2 B2 - for range b2 /* ERROR cannot range over b2 .* no structural type */ {} + for range b2 {} var c0 chan int for range c0 {} @@ -197,7 +197,7 @@ func _[ for _, _ /* ERROR permits only one iteration variable */ = range c1 {} var c2 C2 - for range c2 /* ERROR cannot range over c2 .* no structural type */ {} + for range c2 /* ERROR cannot range over c2.*no single underlying type */ {} var c3 C3 for range c3 /* ERROR receive from send-only channel */ {} @@ -213,7 +213,7 @@ func _[ for _, _ = range s1 {} var s2 S2 - for range s2 /* ERROR cannot range over s2 .* no structural type */ {} + for range s2 /* ERROR cannot range over s2.*no single underlying type */ {} var a0 []int for range a0 {} @@ -226,7 +226,7 @@ func _[ for _, _ = range a1 {} var a2 A2 - for range a2 /* ERROR cannot range over a2 .* no structural type */ {} + for range a2 /* ERROR cannot range over a2.*no single underlying type */ {} var p0 *[10]int for range p0 {} @@ -239,7 +239,7 @@ func _[ for _, _ = range p1 {} var p2 P2 - for range p2 /* ERROR cannot range over p2 .* no structural type */ {} + for range p2 /* ERROR cannot range over p2.*no single underlying type */ {} var m0 map[string]int for range m0 {} @@ -252,7 +252,7 @@ func _[ for _, _ = range m1 {} var m2 M2 - for range m2 /* ERROR cannot range over m2 .* no structural type */ {} + for range m2 /* ERROR cannot range over m2.*no single underlying type */ {} } // type inference checks From 71e6ab8f958bf346f9e0b46c4a35310615360215 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Fri, 29 Oct 2021 18:06:15 -0400 Subject: [PATCH 252/406] go/types: slice exprs to accept type sets with single underlying types This is a port of CL 357779 to go/types. A test error message was repositioned on the sliced operand. Change-Id: Ie775c128f70d9cb08a2eba54b8bc082134ec3200 Reviewed-on: https://go-review.googlesource.com/c/go/+/359876 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/index.go | 21 +++++++++++++-------- src/go/types/testdata/check/typeparams.go2 | 5 +++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/go/types/index.go b/src/go/types/index.go index 613f6292e4..24c1812039 100644 --- a/src/go/types/index.go +++ b/src/go/types/index.go @@ -207,9 +207,14 @@ func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) { valid := false length := int64(-1) // valid if >= 0 - switch typ := optype(x.typ).(type) { + switch u := singleUnder(x.typ).(type) { + case nil: + check.errorf(x, _NonSliceableOperand, "cannot slice %s: type set has no single underlying type", x) + x.mode = invalid + return + case *Basic: - if isString(typ) { + if isString(u) { if e.Slice3 { check.invalidOp(x, _InvalidSliceExpr, "3-index slice of string") x.mode = invalid @@ -221,26 +226,26 @@ func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) { } // spec: "For untyped string operands the result // is a non-constant value of type string." - if typ.kind == UntypedString { + if u.kind == UntypedString { x.typ = Typ[String] } } case *Array: valid = true - length = typ.len + length = u.len if x.mode != variable { check.invalidOp(x, _NonSliceableOperand, "cannot slice %s (value not addressable)", x) x.mode = invalid return } - x.typ = &Slice{elem: typ.elem} + x.typ = &Slice{elem: u.elem} case *Pointer: - if typ := asArray(typ.base); typ != nil { + if u := asArray(u.base); u != nil { valid = true - length = typ.len - x.typ = &Slice{elem: typ.elem} + length = u.len + x.typ = &Slice{elem: u.elem} } case *Slice: diff --git a/src/go/types/testdata/check/typeparams.go2 b/src/go/types/testdata/check/typeparams.go2 index c4b0c212d2..3694b0ed00 100644 --- a/src/go/types/testdata/check/typeparams.go2 +++ b/src/go/types/testdata/check/typeparams.go2 @@ -123,6 +123,11 @@ func _[T interface{ ~[]byte }] (x T, i, j, k int) { var _ T = x[i:j:k] } func _[T interface{ ~string }] (x T, i, j, k int) { var _ T = x[i:j] } func _[T interface{ ~string }] (x T, i, j, k int) { var _ T = x /* ERROR 3-index slice of string */ [i:j:k] } +type myByte1 []byte +type myByte2 []byte +func _[T interface{ []byte | myByte1 | myByte2 }] (x T, i, j, k int) { var _ T = x[i:j:k] } +func _[T interface{ []byte | myByte1 | []int }] (x T, i, j, k int) { var _ T = x /* ERROR no single underlying type */ [i:j:k] } + // len/cap built-ins func _[T any](x T) { _ = len(x /* ERROR invalid argument */ ) } From c812b97ec67ae2d674b5bb4e2fd29c7ab7fa08dc Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Fri, 29 Oct 2021 18:08:08 -0400 Subject: [PATCH 253/406] go/types: comp literals to accept type sets with single underlying types This is a clean port of CL 357915 to go/types. Change-Id: Idf5850a8bdcf3596c561c97bcd60539945139743 Reviewed-on: https://go-review.googlesource.com/c/go/+/359877 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/expr.go | 2 +- src/go/types/testdata/check/compliterals.go2 | 22 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/go/types/testdata/check/compliterals.go2 diff --git a/src/go/types/expr.go b/src/go/types/expr.go index 3a09dfd85f..8b26e64971 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -1223,7 +1223,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind { goto Error } - switch utyp := optype(base).(type) { + switch utyp := singleUnder(base).(type) { case *Struct: if len(e.Elts) == 0 { break diff --git a/src/go/types/testdata/check/compliterals.go2 b/src/go/types/testdata/check/compliterals.go2 new file mode 100644 index 0000000000..60eac97a3f --- /dev/null +++ b/src/go/types/testdata/check/compliterals.go2 @@ -0,0 +1,22 @@ +// Copyright 2012 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. + +// Composite literals with parameterized types + +package comp_literals + +type myStruct struct { + f int +} + +type slice[E any] []E + +func struct_literals[S struct{f int}|myStruct]() { + _ = S{} + _ = S{0} + _ = S{f: 0} + + _ = slice[int]{1, 2, 3} + _ = slice[S]{{}, {0}, {f:0}} +} From 8dfb4472318e151656f77623e8cabdca290c22fb Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Wed, 13 Oct 2021 20:48:45 -0700 Subject: [PATCH 254/406] runtime: do not add open defer entry above a started open defer entry Fix two defer bugs related to adding/removing open defer entries. The bugs relate to the way that we add and remove open defer entries from the defer chain. At the point of a panic, when we want to start processing defer entries in order during the panic process, we need to add entries to the defer chain for stack frames with open defers, since the normal fast-defer code does not add these entries. We do this by calling addOneOpenDeferFrame() at the beginning of each time around the defer loop in gopanic(). Those defer entries get sorted with other open and non-open-coded defer frames. However, the tricky part is that we also need to remove defer entries if they end not being needed because of a recover (which means we are back to executing the defer code inline at function exits). But we need to deal with multiple panics and in-process defers on the stack, so we can't just remove all open-coded defers from the the defer chain during a recover. The fix (and new invariant) is that we should not add any open-coded defers to the defer chain that are higher up the stack than an open-coded defer that is in progress. We know that open-coded defer will still be run until completed, and when it is completed, then a more outer frame will be added (if there is one). This fits with existing code in gopanic that only removes open-coded defer entries up to any defer in progress. These bugs were because of the previous inconsistency between adding and removing open defer entries, which meant that stale defer entries could be left on the list, in these unusual cases with both recursive panics plus multiple independent (non-nested) cases of panic & recover. The test for #48898 was difficult to add to defer_test.go (while keeping the failure mode), so I added as a go/test/fixedbug test instead. Fixes #43920 Updates #43941 Fixes #48898 Change-Id: I593b77033e08c33094315abf8089fbc4cab07376 Reviewed-on: https://go-review.googlesource.com/c/go/+/356011 Trust: Dan Scales Trust: Cuong Manh Le Reviewed-by: Austin Clements --- src/runtime/defer_test.go | 79 +++++++++++++++++++++++++++++++++++ src/runtime/panic.go | 55 +++++++++++++++++------- test/fixedbugs/issue48898.go | 40 ++++++++++++++++++ test/fixedbugs/issue48898.out | 1 + 4 files changed, 161 insertions(+), 14 deletions(-) create mode 100644 test/fixedbugs/issue48898.go create mode 100644 test/fixedbugs/issue48898.out diff --git a/src/runtime/defer_test.go b/src/runtime/defer_test.go index fc96144597..1d5745d60b 100644 --- a/src/runtime/defer_test.go +++ b/src/runtime/defer_test.go @@ -438,3 +438,82 @@ func expect(t *testing.T, n int, err interface{}) { t.Fatalf("have %v, want %v", err, n) } } + +func TestIssue43920(t *testing.T) { + var steps int + + defer func() { + expect(t, 1, recover()) + }() + defer func() { + defer func() { + defer func() { + expect(t, 5, recover()) + }() + defer panic(5) + func() { + panic(4) + }() + }() + defer func() { + expect(t, 3, recover()) + }() + defer panic(3) + }() + func() { + defer step(t, &steps, 1) + panic(1) + }() +} + +func step(t *testing.T, steps *int, want int) { + println("step", want) + *steps++ + if *steps != want { + t.Fatalf("have %v, want %v", *steps, want) + } +} + +func TestIssue43941(t *testing.T) { + var steps int = 7 + defer func() { + step(t, &steps, 14) + expect(t, 4, recover()) + }() + func() { + func() { + defer func() { + defer func() { + expect(t, 3, recover()) + }() + defer panic(3) + panic(2) + }() + defer func() { + expect(t, 1, recover()) + }() + defer panic(1) + }() + defer func() {}() + defer func() {}() + defer step(t, &steps, 10) + defer step(t, &steps, 9) + step(t, &steps, 8) + }() + func() { + defer step(t, &steps, 13) + defer step(t, &steps, 12) + func() { + defer step(t, &steps, 11) + panic(4) + }() + + // Code below isn't executed, + // but removing it breaks the test case. + defer func() {}() + defer panic(-1) + defer step(t, &steps, -1) + defer step(t, &steps, -1) + defer func() {}() + }() +} diff --git a/src/runtime/panic.go b/src/runtime/panic.go index 58135cf8ce..eec69dfdc6 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -560,14 +560,28 @@ func printpanics(p *_panic) { print("\n") } -// addOneOpenDeferFrame scans the stack for the first frame (if any) with -// open-coded defers and if it finds one, adds a single record to the defer chain -// for that frame. If sp is non-nil, it starts the stack scan from the frame -// specified by sp. If sp is nil, it uses the sp from the current defer record -// (which has just been finished). Hence, it continues the stack scan from the -// frame of the defer that just finished. It skips any frame that already has an -// open-coded _defer record, which would have been created from a previous -// (unrecovered) panic. +// addOneOpenDeferFrame scans the stack (in gentraceback order, from inner frames to +// outer frames) for the first frame (if any) with open-coded defers. If it finds +// one, it adds a single entry to the defer chain for that frame. The entry added +// represents all the defers in the associated open defer frame, and is sorted in +// order with respect to any non-open-coded defers. +// +// addOneOpenDeferFrame stops (possibly without adding a new entry) if it encounters +// an in-progress open defer entry. An in-progress open defer entry means there has +// been a new panic because of a defer in the associated frame. addOneOpenDeferFrame +// does not add an open defer entry past a started entry, because that started entry +// still needs to finished, and addOneOpenDeferFrame will be called when that started +// entry is completed. The defer removal loop in gopanic() similarly stops at an +// in-progress defer entry. Together, addOneOpenDeferFrame and the defer removal loop +// ensure the invariant that there is no open defer entry further up the stack than +// an in-progress defer, and also that the defer removal loop is guaranteed to remove +// all not-in-progress open defer entries from the defer chain. +// +// If sp is non-nil, addOneOpenDeferFrame starts the stack scan from the frame +// specified by sp. If sp is nil, it uses the sp from the current defer record (which +// has just been finished). Hence, it continues the stack scan from the frame of the +// defer that just finished. It skips any frame that already has a (not-in-progress) +// open-coded _defer record in the defer chain. // // Note: All entries of the defer chain (including this new open-coded entry) have // their pointers (including sp) adjusted properly if the stack moves while @@ -608,6 +622,16 @@ func addOneOpenDeferFrame(gp *g, pc uintptr, sp unsafe.Pointer) { if !d.openDefer { throw("duplicated defer entry") } + // Don't add any record past an + // in-progress defer entry. We don't + // need it, and more importantly, we + // want to keep the invariant that + // there is no open defer entry + // passed an in-progress entry (see + // header comment). + if d.started { + return false + } return true } prev = d @@ -849,12 +873,15 @@ func gopanic(e interface{}) { } atomic.Xadd(&runningPanicDefers, -1) - // Remove any remaining non-started, open-coded - // defer entries after a recover, since the - // corresponding defers will be executed normally - // (inline). Any such entry will become stale once - // we run the corresponding defers inline and exit - // the associated stack frame. + // After a recover, remove any remaining non-started, + // open-coded defer entries, since the corresponding defers + // will be executed normally (inline). Any such entry will + // become stale once we run the corresponding defers inline + // and exit the associated stack frame. We only remove up to + // the first started (in-progress) open defer entry, not + // including the current frame, since any higher entries will + // be from a higher panic in progress, and will still be + // needed. d := gp._defer var prev *_defer if !done { diff --git a/test/fixedbugs/issue48898.go b/test/fixedbugs/issue48898.go new file mode 100644 index 0000000000..c3af16480f --- /dev/null +++ b/test/fixedbugs/issue48898.go @@ -0,0 +1,40 @@ +// run + +// Copyright 2021 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 main + +func main() { + defer func() { + println(recover().(int)) + }() + func() { + func() (_ [2]int) { type _ int; return }() + func() { + defer func() { + defer func() { + recover() + }() + defer panic(3) + panic(2) + }() + defer func() { + recover() + }() + panic(1) + }() + defer func() {}() + }() + + var x = 123 + func() { + // in the original issue, this defer was not executed (which is incorrect) + defer print(x) + func() { + defer func() {}() + panic(4) + }() + }() +} diff --git a/test/fixedbugs/issue48898.out b/test/fixedbugs/issue48898.out new file mode 100644 index 0000000000..81c545efeb --- /dev/null +++ b/test/fixedbugs/issue48898.out @@ -0,0 +1 @@ +1234 From 5d6d9f5610066584374c2dfe7624fa9f251089a0 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Wed, 27 Oct 2021 19:16:27 -0700 Subject: [PATCH 255/406] cmd/compile: use Structure() to get single underlying type of typeparam. Use types2.Structure() to get single underlying type of typeparams, to handle some unusual cases where a type param is constrained to a single underlying struct or map type. Fixes #48538 Change-Id: I289fb7b31d489f7586f2b04aeb1df74e15a9f965 Reviewed-on: https://go-review.googlesource.com/c/go/+/359335 Trust: Dan Scales Run-TryBot: Dan Scales TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/noder/expr.go | 2 +- test/run.go | 1 + test/typeparam/issue48538.go | 60 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 test/typeparam/issue48538.go diff --git a/src/cmd/compile/internal/noder/expr.go b/src/cmd/compile/internal/noder/expr.go index 65568f2307..d19513a1ac 100644 --- a/src/cmd/compile/internal/noder/expr.go +++ b/src/cmd/compile/internal/noder/expr.go @@ -344,7 +344,7 @@ func (g *irgen) compLit(typ types2.Type, lit *syntax.CompositeLit) ir.Node { return typed(g.typ(typ), n) } - _, isStruct := typ.Underlying().(*types2.Struct) + _, isStruct := types2.Structure(typ).(*types2.Struct) exprs := make([]ir.Node, len(lit.ElemList)) for i, elem := range lit.ElemList { diff --git a/test/run.go b/test/run.go index 0c5da1af78..942fd032f2 100644 --- a/test/run.go +++ b/test/run.go @@ -2188,6 +2188,7 @@ var unifiedFailures = setOf( "fixedbugs/issue42284.go", // prints "T(0) does not escape", but test expects "a.I(a.T(0)) does not escape" "fixedbugs/issue7921.go", // prints "… escapes to heap", but test expects "string(…) escapes to heap" + "typeparam/issue48538.go", // assertion failure, interprets struct key as closure variable ) func setOf(keys ...string) map[string]bool { diff --git a/test/typeparam/issue48538.go b/test/typeparam/issue48538.go new file mode 100644 index 0000000000..fed9b5e9a6 --- /dev/null +++ b/test/typeparam/issue48538.go @@ -0,0 +1,60 @@ +// compile -G=3 + +// Copyright 2021 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. + +// Testing composite literal for a type param constrained to be a struct or a map. + +package p + +type C interface { + ~struct{ b1, b2 string } +} + +func f[T C]() T { + return T{ + b1: "a", + b2: "b", + } +} + +func f2[T ~struct{ b1, b2 string }]() T { + return T{ + b1: "a", + b2: "b", + } +} + +type D interface { + map[string]string | S +} + +type S map[string]string + +func g[T D]() T { + b1 := "foo" + b2 := "bar" + return T{ + b1: "a", + b2: "b", + } +} + +func g2[T map[string]string]() T { + b1 := "foo" + b2 := "bar" + return T{ + b1: "a", + b2: "b", + } +} + +func g3[T S]() T { + b1 := "foo" + b2 := "bar" + return T{ + b1: "a", + b2: "b", + } +} From e39b854a6797a7159602f0d6b351ef35ebfa01d0 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Thu, 13 May 2021 15:33:48 -0400 Subject: [PATCH 256/406] crypto/elliptic: use complete addition formulas for P-521 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complete formulas don't have exceptions for P = Q or P = 0, which makes them significantly simpler and safer to implement. Notice how the constant time IsZero checks are gone. It's not free, but still well within the performance gains of CL 315271. name old time/op new time/op delta pkg:crypto/elliptic goos:darwin goarch:amd64 ScalarBaseMult/P521-16 1.34ms ± 3% 1.63ms ± 4% +21.78% (p=0.000 n=10+10) ScalarMult/P521-16 1.35ms ± 3% 1.65ms ± 4% +22.58% (p=0.000 n=10+10) pkg:crypto/ecdsa goos:darwin goarch:amd64 Sign/P521-16 1.45ms ± 2% 1.67ms ± 1% +15.00% (p=0.000 n=10+8) Verify/P521-16 2.68ms ± 1% 3.10ms ± 2% +16.02% (p=0.000 n=10+9) GenerateKey/P521-16 1.31ms ± 4% 1.53ms ± 1% +16.89% (p=0.000 n=10+9) Change-Id: Ibd9a961e9865df68a1250aba739c190caf9a54de Reviewed-on: https://go-review.googlesource.com/c/go/+/320071 Trust: Filippo Valsorda Run-TryBot: Filippo Valsorda TryBot-Result: Go Bot Reviewed-by: Julie Qiu --- src/crypto/elliptic/p521.go | 255 ++++++++++++++++++------------------ 1 file changed, 128 insertions(+), 127 deletions(-) diff --git a/src/crypto/elliptic/p521.go b/src/crypto/elliptic/p521.go index 3d355943ec..463b9f4e39 100644 --- a/src/crypto/elliptic/p521.go +++ b/src/crypto/elliptic/p521.go @@ -11,6 +11,7 @@ import ( type p521Curve struct { *CurveParams + b *fiat.P521Element } var p521 p521Curve @@ -25,6 +26,7 @@ func initP521() { p521.Gx, _ = new(big.Int).SetString("c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66", 16) p521.Gy, _ = new(big.Int).SetString("11839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650", 16) p521.BitSize = 521 + p521.b = bigIntToFiatP521(p521.B) } func (curve p521Curve) Params() *CurveParams { @@ -34,7 +36,6 @@ func (curve p521Curve) Params() *CurveParams { func (curve p521Curve) IsOnCurve(x, y *big.Int) bool { x1 := bigIntToFiatP521(x) y1 := bigIntToFiatP521(y) - b := bigIntToFiatP521(curve.B) // TODO: precompute this value. // x³ - 3x + b. x3 := new(fiat.P521Element).Square(x1) @@ -44,7 +45,7 @@ func (curve p521Curve) IsOnCurve(x, y *big.Int) bool { threeX.Add(threeX, x1) x3.Sub(x3, threeX) - x3.Add(x3, b) + x3.Add(x3, curve.b) // y² = x³ - 3x + b y2 := new(fiat.P521Element).Square(y1) @@ -52,10 +53,20 @@ func (curve p521Curve) IsOnCurve(x, y *big.Int) bool { return x3.Equal(y2) == 1 } +// p521Point is a P-521 point in projective coordinates, where x = X/Z, y = Y/Z. type p521Point struct { x, y, z *fiat.P521Element } +// newP521Point returns a new p521Point representing the identity point. +func newP521Point() *p521Point { + return &p521Point{ + x: new(fiat.P521Element), + y: new(fiat.P521Element).One(), + z: new(fiat.P521Element), + } +} + func fiatP521ToBigInt(x *fiat.P521Element) *big.Int { xBytes := x.Bytes() for i := range xBytes[:len(xBytes)/2] { @@ -64,20 +75,16 @@ func fiatP521ToBigInt(x *fiat.P521Element) *big.Int { return new(big.Int).SetBytes(xBytes) } -// affineFromJacobian brings a point in Jacobian coordinates back to affine -// coordinates, with (0, 0) representing infinity by convention. It also goes -// back to big.Int values to match the exposed API. -func (curve p521Curve) affineFromJacobian(p *p521Point) (x, y *big.Int) { +// Affine returns p in affine coordinates, with (0, 0) representing infinity by +// convention. It also goes back to big.Int values to match the exposed API. +func (p *p521Point) Affine() (x, y *big.Int) { if p.z.IsZero() == 1 { return new(big.Int), new(big.Int) } zinv := new(fiat.P521Element).Invert(p.z) - zinvsq := new(fiat.P521Element).Mul(zinv, zinv) - - xx := new(fiat.P521Element).Mul(p.x, zinvsq) - zinvsq.Mul(zinvsq, zinv) - yy := new(fiat.P521Element).Mul(p.y, zinvsq) + xx := new(fiat.P521Element).Mul(p.x, zinv) + yy := new(fiat.P521Element).Mul(p.y, zinv) return fiatP521ToBigInt(xx), fiatP521ToBigInt(yy) } @@ -96,18 +103,14 @@ func bigIntToFiatP521(x *big.Int) *fiat.P521Element { return x1 } -// jacobianFromAffine converts (x, y) affine coordinates into (x, y, z) Jacobian +// newP521PointFromAffine converts (x, y) affine coordinates into (X, Y, Z) projective // coordinates. It also converts from big.Int to fiat, which is necessarily a // messy and variable-time operation, which we can't avoid due to the exposed API. -func (curve p521Curve) jacobianFromAffine(x, y *big.Int) *p521Point { +func newP521PointFromAffine(x, y *big.Int) *p521Point { // (0, 0) is by convention the point at infinity, which can't be represented - // in affine coordinates, but is (0, 0, 0) in Jacobian. + // in affine coordinates, but is (0, 0, 0) in projective coordinates. if x.Sign() == 0 && y.Sign() == 0 { - return &p521Point{ - x: new(fiat.P521Element), - y: new(fiat.P521Element), - z: new(fiat.P521Element), - } + return newP521Point() } return &p521Point{ x: bigIntToFiatP521(x), @@ -117,65 +120,59 @@ func (curve p521Curve) jacobianFromAffine(x, y *big.Int) *p521Point { } func (curve p521Curve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int) { - p1 := curve.jacobianFromAffine(x1, y1) - p2 := curve.jacobianFromAffine(x2, y2) - return curve.affineFromJacobian(p1.addJacobian(p1, p2)) + p1 := newP521PointFromAffine(x1, y1) + p2 := newP521PointFromAffine(x2, y2) + return p1.Add(p1, p2).Affine() } -// addJacobian sets q = p1 + p2, and returns q. The points may overlap. -func (q *p521Point) addJacobian(p1, p2 *p521Point) *p521Point { - // https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#addition-add-2007-bl - z1IsZero := p1.z.IsZero() - z2IsZero := p2.z.IsZero() +// Add sets q = p1 + p2, and returns q. The points may overlap. +func (q *p521Point) Add(p1, p2 *p521Point) *p521Point { + // Complete addition formula for a = -3 from "Complete addition formulas for + // prime order elliptic curves" (https://eprint.iacr.org/2015/1060), §A.2. - z1z1 := new(fiat.P521Element).Square(p1.z) - z2z2 := new(fiat.P521Element).Square(p2.z) - - u1 := new(fiat.P521Element).Mul(p1.x, z2z2) - u2 := new(fiat.P521Element).Mul(p2.x, z1z1) - h := new(fiat.P521Element).Sub(u2, u1) - xEqual := h.IsZero() == 1 - i := new(fiat.P521Element).Add(h, h) - i.Square(i) - j := new(fiat.P521Element).Mul(h, i) - - s1 := new(fiat.P521Element).Mul(p1.y, p2.z) - s1.Mul(s1, z2z2) - s2 := new(fiat.P521Element).Mul(p2.y, p1.z) - s2.Mul(s2, z1z1) - r := new(fiat.P521Element).Sub(s2, s1) - yEqual := r.IsZero() == 1 - if xEqual && yEqual && z1IsZero == 0 && z2IsZero == 0 { - return q.doubleJacobian(p1) - } - r.Add(r, r) - v := new(fiat.P521Element).Mul(u1, i) - - x := new(fiat.P521Element).Set(r) - x.Square(x) - x.Sub(x, j) - x.Sub(x, v) - x.Sub(x, v) - - y := new(fiat.P521Element).Set(r) - v.Sub(v, x) - y.Mul(y, v) - s1.Mul(s1, j) - s1.Add(s1, s1) - y.Sub(y, s1) - - z := new(fiat.P521Element).Add(p1.z, p2.z) - z.Square(z) - z.Sub(z, z1z1) - z.Sub(z, z2z2) - z.Mul(z, h) - - x.Select(p2.x, x, z1IsZero) - x.Select(p1.x, x, z2IsZero) - y.Select(p2.y, y, z1IsZero) - y.Select(p1.y, y, z2IsZero) - z.Select(p2.z, z, z1IsZero) - z.Select(p1.z, z, z2IsZero) + t0 := new(fiat.P521Element).Mul(p1.x, p2.x) // t0 := X1 * X2 + t1 := new(fiat.P521Element).Mul(p1.y, p2.y) // t1 := Y1 * Y2 + t2 := new(fiat.P521Element).Mul(p1.z, p2.z) // t2 := Z1 * Z2 + t3 := new(fiat.P521Element).Add(p1.x, p1.y) // t3 := X1 + Y1 + t4 := new(fiat.P521Element).Add(p2.x, p2.y) // t4 := X2 + Y2 + t3.Mul(t3, t4) // t3 := t3 * t4 + t4.Add(t0, t1) // t4 := t0 + t1 + t3.Sub(t3, t4) // t3 := t3 - t4 + t4.Add(p1.y, p1.z) // t4 := Y1 + Z1 + x := new(fiat.P521Element).Add(p2.y, p2.z) // X3 := Y2 + Z2 + t4.Mul(t4, x) // t4 := t4 * X3 + x.Add(t1, t2) // X3 := t1 + t2 + t4.Sub(t4, x) // t4 := t4 - X3 + x.Add(p1.x, p1.z) // X3 := X1 + Z1 + y := new(fiat.P521Element).Add(p2.x, p2.z) // Y3 := X2 + Z2 + x.Mul(x, y) // X3 := X3 * Y3 + y.Add(t0, t2) // Y3 := t0 + t2 + y.Sub(x, y) // Y3 := X3 - Y3 + z := new(fiat.P521Element).Mul(p521.b, t2) // Z3 := b * t2 + x.Sub(y, z) // X3 := Y3 - Z3 + z.Add(x, x) // Z3 := X3 + X3 + x.Add(x, z) // X3 := X3 + Z3 + z.Sub(t1, x) // Z3 := t1 - X3 + x.Add(t1, x) // X3 := t1 + X3 + y.Mul(p521.b, y) // Y3 := b * Y3 + t1.Add(t2, t2) // t1 := t2 + t2 + t2.Add(t1, t2) // t2 := t1 + t2 + y.Sub(y, t2) // Y3 := Y3 - t2 + y.Sub(y, t0) // Y3 := Y3 - t0 + t1.Add(y, y) // t1 := Y3 + Y3 + y.Add(t1, y) // Y3 := t1 + Y3 + t1.Add(t0, t0) // t1 := t0 + t0 + t0.Add(t1, t0) // t0 := t1 + t0 + t0.Sub(t0, t2) // t0 := t0 - t2 + t1.Mul(t4, y) // t1 := t4 * Y3 + t2.Mul(t0, y) // t2 := t0 * Y3 + y.Mul(x, z) // Y3 := X3 * Z3 + y.Add(y, t2) // Y3 := Y3 + t2 + x.Mul(t3, x) // X3 := t3 * X3 + x.Sub(x, t1) // X3 := X3 - t1 + z.Mul(t4, z) // Z3 := t4 * Z3 + t1.Mul(t3, t0) // t1 := t3 * t0 + z.Add(z, t1) // Z3 := Z3 + t1 q.x.Set(x) q.y.Set(y) @@ -184,74 +181,78 @@ func (q *p521Point) addJacobian(p1, p2 *p521Point) *p521Point { } func (curve p521Curve) Double(x1, y1 *big.Int) (*big.Int, *big.Int) { - p := curve.jacobianFromAffine(x1, y1) - return curve.affineFromJacobian(p.doubleJacobian(p)) + p := newP521PointFromAffine(x1, y1) + return p.Double(p).Affine() } -// doubleJacobian sets q = p + p, and returns q. The points may overlap. -func (q *p521Point) doubleJacobian(p *p521Point) *p521Point { - // https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b - delta := new(fiat.P521Element).Square(p.z) - gamma := new(fiat.P521Element).Square(p.y) - alpha := new(fiat.P521Element).Sub(p.x, delta) - alpha2 := new(fiat.P521Element).Add(p.x, delta) - alpha.Mul(alpha, alpha2) - alpha2.Set(alpha) - alpha.Add(alpha, alpha) - alpha.Add(alpha, alpha2) +// Double sets q = p + p, and returns q. The points may overlap. +func (q *p521Point) Double(p *p521Point) *p521Point { + // Complete addition formula for a = -3 from "Complete addition formulas for + // prime order elliptic curves" (https://eprint.iacr.org/2015/1060), §A.2. - beta := alpha2.Mul(p.x, gamma) + t0 := new(fiat.P521Element).Square(p.x) // t0 := X ^ 2 + t1 := new(fiat.P521Element).Square(p.y) // t1 := Y ^ 2 + t2 := new(fiat.P521Element).Square(p.z) // t2 := Z ^ 2 + t3 := new(fiat.P521Element).Mul(p.x, p.y) // t3 := X * Y + t3.Add(t3, t3) // t3 := t3 + t3 + z := new(fiat.P521Element).Mul(p.x, p.z) // Z3 := X * Z + z.Add(z, z) // Z3 := Z3 + Z3 + y := new(fiat.P521Element).Mul(p521.b, t2) // Y3 := b * t2 + y.Sub(y, z) // Y3 := Y3 - Z3 + x := new(fiat.P521Element).Add(y, y) // X3 := Y3 + Y3 + y.Add(x, y) // Y3 := X3 + Y3 + x.Sub(t1, y) // X3 := t1 - Y3 + y.Add(t1, y) // Y3 := t1 + Y3 + y.Mul(x, y) // Y3 := X3 * Y3 + x.Mul(x, t3) // X3 := X3 * t3 + t3.Add(t2, t2) // t3 := t2 + t2 + t2.Add(t2, t3) // t2 := t2 + t3 + z.Mul(p521.b, z) // Z3 := b * Z3 + z.Sub(z, t2) // Z3 := Z3 - t2 + z.Sub(z, t0) // Z3 := Z3 - t0 + t3.Add(z, z) // t3 := Z3 + Z3 + z.Add(z, t3) // Z3 := Z3 + t3 + t3.Add(t0, t0) // t3 := t0 + t0 + t0.Add(t3, t0) // t0 := t3 + t0 + t0.Sub(t0, t2) // t0 := t0 - t2 + t0.Mul(t0, z) // t0 := t0 * Z3 + y.Add(y, t0) // Y3 := Y3 + t0 + t0.Mul(p.y, p.z) // t0 := Y * Z + t0.Add(t0, t0) // t0 := t0 + t0 + z.Mul(t0, z) // Z3 := t0 * Z3 + x.Sub(x, z) // X3 := X3 - Z3 + z.Mul(t0, t1) // Z3 := t0 * t1 + z.Add(z, z) // Z3 := Z3 + Z3 + z.Add(z, z) // Z3 := Z3 + Z3 - q.x.Square(alpha) - beta8 := new(fiat.P521Element).Add(beta, beta) - beta8.Add(beta8, beta8) - beta8.Add(beta8, beta8) - q.x.Sub(q.x, beta8) - - q.z.Add(p.y, p.z) - q.z.Square(q.z) - q.z.Sub(q.z, gamma) - q.z.Sub(q.z, delta) - - beta.Add(beta, beta) - beta.Add(beta, beta) - beta.Sub(beta, q.x) - q.y.Mul(alpha, beta) - - gamma.Square(gamma) - gamma.Add(gamma, gamma) - gamma.Add(gamma, gamma) - gamma.Add(gamma, gamma) - - q.y.Sub(q.y, gamma) + q.x.Set(x) + q.y.Set(y) + q.z.Set(z) + return q +} +// Select sets q to p1 if cond == 1, and to p2 if cond == 0. +func (q *p521Point) Select(p1, p2 *p521Point, cond int) *p521Point { + q.x.Select(p1.x, p2.x, cond) + q.y.Select(p1.y, p2.y, cond) + q.z.Select(p1.z, p2.z, cond) return q } func (curve p521Curve) ScalarMult(Bx, By *big.Int, scalar []byte) (*big.Int, *big.Int) { - B := curve.jacobianFromAffine(Bx, By) - p, t := &p521Point{ - x: new(fiat.P521Element), - y: new(fiat.P521Element), - z: new(fiat.P521Element), - }, &p521Point{ - x: new(fiat.P521Element), - y: new(fiat.P521Element), - z: new(fiat.P521Element), - } + B := newP521PointFromAffine(Bx, By) + p, t := newP521Point(), newP521Point() for _, byte := range scalar { for bitNum := 0; bitNum < 8; bitNum++ { - p.doubleJacobian(p) + p.Double(p) + t.Add(p, B) bit := (byte >> (7 - bitNum)) & 1 - t.addJacobian(p, B) - p.x.Select(t.x, p.x, int(bit)) - p.y.Select(t.y, p.y, int(bit)) - p.z.Select(t.z, p.z, int(bit)) + p.Select(t, p, int(bit)) } } - return curve.affineFromJacobian(p) + return p.Affine() } func (curve p521Curve) ScalarBaseMult(k []byte) (*big.Int, *big.Int) { From d1dceafc290865989be713cd6e235670169b73b3 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Fri, 14 May 2021 13:03:45 -0400 Subject: [PATCH 257/406] crypto/elliptic: use a 4-bit sliding window for P-521 ScalarMult MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit name old time/op new time/op delta pkg:crypto/elliptic goos:darwin goarch:amd64 ScalarBaseMult/P521-16 1.63ms ± 4% 1.00ms ± 1% -38.69% (p=0.000 n=10+8) ScalarMult/P521-16 1.65ms ± 4% 0.99ms ± 2% -40.15% (p=0.000 n=10+10) pkg:crypto/ecdsa goos:darwin goarch:amd64 Sign/P521-16 1.67ms ± 1% 1.12ms ± 2% -32.82% (p=0.000 n=8+10) Verify/P521-16 3.10ms ± 2% 2.00ms ± 2% -35.54% (p=0.000 n=9+10) GenerateKey/P521-16 1.53ms ± 1% 0.98ms ± 2% -35.81% (p=0.000 n=9+10) Change-Id: I109e821399d71330a77d105496e227746cc3ea0d Reviewed-on: https://go-review.googlesource.com/c/go/+/320072 Trust: Filippo Valsorda Run-TryBot: Filippo Valsorda TryBot-Result: Go Bot Reviewed-by: Julie Qiu --- src/crypto/elliptic/p521.go | 40 ++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/crypto/elliptic/p521.go b/src/crypto/elliptic/p521.go index 463b9f4e39..569a58c6f3 100644 --- a/src/crypto/elliptic/p521.go +++ b/src/crypto/elliptic/p521.go @@ -6,6 +6,7 @@ package elliptic import ( "crypto/elliptic/internal/fiat" + "crypto/subtle" "math/big" ) @@ -243,13 +244,42 @@ func (curve p521Curve) ScalarMult(Bx, By *big.Int, scalar []byte) (*big.Int, *bi B := newP521PointFromAffine(Bx, By) p, t := newP521Point(), newP521Point() + // table holds the first 16 multiples of q. The explicit newP521Point calls + // get inlined, letting the allocations live on the stack. + var table = [16]*p521Point{ + newP521Point(), newP521Point(), newP521Point(), newP521Point(), + newP521Point(), newP521Point(), newP521Point(), newP521Point(), + newP521Point(), newP521Point(), newP521Point(), newP521Point(), + newP521Point(), newP521Point(), newP521Point(), newP521Point(), + } + for i := 1; i < 16; i++ { + table[i].Add(table[i-1], B) + } + + // Instead of doing the classic double-and-add chain, we do it with a + // four-bit window: we double four times, and then add [0-15]P. for _, byte := range scalar { - for bitNum := 0; bitNum < 8; bitNum++ { - p.Double(p) - t.Add(p, B) - bit := (byte >> (7 - bitNum)) & 1 - p.Select(t, p, int(bit)) + p.Double(p) + p.Double(p) + p.Double(p) + p.Double(p) + + for i := uint8(0); i < 16; i++ { + cond := subtle.ConstantTimeByteEq(byte>>4, i) + t.Select(table[i], t, cond) } + p.Add(p, t) + + p.Double(p) + p.Double(p) + p.Double(p) + p.Double(p) + + for i := uint8(0); i < 16; i++ { + cond := subtle.ConstantTimeByteEq(byte&0b1111, i) + t.Select(table[i], t, cond) + } + p.Add(p, t) } return p.Affine() From 30b5d6385e91ab557978c0024a9eb90e656623b7 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Sat, 15 May 2021 09:48:31 -0400 Subject: [PATCH 258/406] crypto/elliptic: move P-521 group logic to internal/nistec This abstracts the clunky and not constant time math/big elliptic.Curve compatibility layer away from the pure fiat-backed group logic. Change-Id: I3b7a7495034d0c569b21c442ae36958763b8b2d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/320074 Trust: Filippo Valsorda Run-TryBot: Filippo Valsorda TryBot-Result: Go Bot Reviewed-by: Julie Qiu --- src/crypto/elliptic/elliptic.go | 9 +- src/crypto/elliptic/elliptic_test.go | 35 ++ src/crypto/elliptic/internal/fiat/p521.go | 24 +- .../elliptic/internal/fiat/p521_test.go | 2 +- src/crypto/elliptic/internal/nistec/p521.go | 306 +++++++++++++++ .../elliptic/internal/nistec/p521_test.go | 44 +++ src/crypto/elliptic/p521.go | 352 ++++++------------ src/go/build/deps_test.go | 1 + 8 files changed, 520 insertions(+), 253 deletions(-) create mode 100644 src/crypto/elliptic/internal/nistec/p521.go create mode 100644 src/crypto/elliptic/internal/nistec/p521_test.go diff --git a/src/crypto/elliptic/elliptic.go b/src/crypto/elliptic/elliptic.go index f072960bfe..cdde0c4e60 100644 --- a/src/crypto/elliptic/elliptic.go +++ b/src/crypto/elliptic/elliptic.go @@ -21,9 +21,12 @@ import ( // A Curve represents a short-form Weierstrass curve with a=-3. // -// Note that the point at infinity (0, 0) is not considered on the curve, and -// although it can be returned by Add, Double, ScalarMult, or ScalarBaseMult, it -// can't be marshaled or unmarshaled, and IsOnCurve will return false for it. +// The output of Add, Double, and ScalarMult when the input is not a point on +// the curve is undefined. +// +// Note that the conventional point at infinity (0, 0) is not considered on the +// curve, although it can be returned by Add, Double, ScalarMult, or +// ScalarBaseMult (but not Unmarshal or UnmarshalCompressed). type Curve interface { // Params returns the parameters for the curve. Params() *CurveParams diff --git a/src/crypto/elliptic/elliptic_test.go b/src/crypto/elliptic/elliptic_test.go index 183861a54b..c9744b5a51 100644 --- a/src/crypto/elliptic/elliptic_test.go +++ b/src/crypto/elliptic/elliptic_test.go @@ -109,6 +109,15 @@ func testInfinity(t *testing.T, curve Curve) { if curve.IsOnCurve(x, y) { t.Errorf("IsOnCurve(∞) == true") } + + if xx, yy := Unmarshal(curve, Marshal(curve, x, y)); xx != nil || yy != nil { + t.Errorf("Unmarshal(Marshal(∞)) did not return an error") + } + // We don't test UnmarshalCompressed(MarshalCompressed(∞)) because there are + // two valid points with x = 0. + if xx, yy := Unmarshal(curve, []byte{0x00}); xx != nil || yy != nil { + t.Errorf("Unmarshal(∞) did not return an error") + } } func TestMarshal(t *testing.T) { @@ -274,3 +283,29 @@ func BenchmarkScalarMult(b *testing.B) { } }) } + +func BenchmarkMarshalUnmarshal(b *testing.B) { + benchmarkAllCurves(b, func(b *testing.B, curve Curve) { + _, x, y, _ := GenerateKey(curve, rand.Reader) + b.Run("Uncompressed", func(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + buf := Marshal(curve, x, y) + xx, yy := Unmarshal(curve, buf) + if xx.Cmp(x) != 0 || yy.Cmp(y) != 0 { + b.Error("Unmarshal output different from Marshal input") + } + } + }) + b.Run("Compressed", func(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + buf := Marshal(curve, x, y) + xx, yy := Unmarshal(curve, buf) + if xx.Cmp(x) != 0 || yy.Cmp(y) != 0 { + b.Error("Unmarshal output different from Marshal input") + } + } + }) + }) +} diff --git a/src/crypto/elliptic/internal/fiat/p521.go b/src/crypto/elliptic/internal/fiat/p521.go index dc677327e6..647c3f914f 100644 --- a/src/crypto/elliptic/internal/fiat/p521.go +++ b/src/crypto/elliptic/internal/fiat/p521.go @@ -53,28 +53,40 @@ func (e *P521Element) Set(t *P521Element) *P521Element { return e } -// Bytes returns the 66-byte little-endian encoding of e. +// Bytes returns the 66-byte big-endian encoding of e. func (e *P521Element) Bytes() []byte { - // This function must be inlined to move the allocation to the parent and - // save it from escaping to the heap. + // This function is outlined to make the allocations inline in the caller + // rather than happen on the heap. var out [66]byte - p521ToBytes(&out, &e.x) + return e.bytes(&out) +} + +func (e *P521Element) bytes(out *[66]byte) []byte { + p521ToBytes(out, &e.x) + invertEndianness(out[:]) return out[:] } -// SetBytes sets e = v, where v is a little-endian 66-byte encoding, and returns +// SetBytes sets e = v, where v is a big-endian 66-byte encoding, and returns // e. If v is not 66 bytes or it encodes a value higher than 2^521 - 1, SetBytes // returns nil and an error, and e is unchanged. func (e *P521Element) SetBytes(v []byte) (*P521Element, error) { - if len(v) != 66 || v[65] > 1 { + if len(v) != 66 || v[0] > 1 { return nil, errors.New("invalid P-521 field encoding") } var in [66]byte copy(in[:], v) + invertEndianness(in[:]) p521FromBytes(&e.x, &in) return e, nil } +func invertEndianness(v []byte) { + for i := 0; i < len(v)/2; i++ { + v[i], v[len(v)-1-i] = v[len(v)-1-i], v[i] + } +} + // Add sets e = t1 + t2, and returns e. func (e *P521Element) Add(t1, t2 *P521Element) *P521Element { p521Add(&e.x, &t1.x, &t2.x) diff --git a/src/crypto/elliptic/internal/fiat/p521_test.go b/src/crypto/elliptic/internal/fiat/p521_test.go index 661bde397e..2b374faa27 100644 --- a/src/crypto/elliptic/internal/fiat/p521_test.go +++ b/src/crypto/elliptic/internal/fiat/p521_test.go @@ -15,7 +15,7 @@ func p521Random(t *testing.T) *fiat.P521Element { if _, err := rand.Read(buf); err != nil { t.Fatal(err) } - buf[65] &= 1 + buf[0] &= 1 e, err := new(fiat.P521Element).SetBytes(buf) if err != nil { t.Fatal(err) diff --git a/src/crypto/elliptic/internal/nistec/p521.go b/src/crypto/elliptic/internal/nistec/p521.go new file mode 100644 index 0000000000..e5b4e46d4b --- /dev/null +++ b/src/crypto/elliptic/internal/nistec/p521.go @@ -0,0 +1,306 @@ +// Copyright 2021 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 nistec implements the NIST P elliptic curves from FIPS 186-4. +// +// This package uses fiat-crypto for its backend field arithmetic (not math/big) +// and exposes constant-time, heap allocation-free, byte slice-based safe APIs. +// Group operations use modern and safe complete addition formulas. The point at +// infinity is handled and encoded according to SEC 1, Version 2.0, and invalid +// curve points can't be represented. +package nistec + +import ( + "crypto/elliptic/internal/fiat" + "crypto/subtle" + "errors" +) + +var p521B, _ = new(fiat.P521Element).SetBytes([]byte{ + 0x00, 0x51, 0x95, 0x3e, 0xb9, 0x61, 0x8e, 0x1c, 0x9a, 0x1f, 0x92, 0x9a, + 0x21, 0xa0, 0xb6, 0x85, 0x40, 0xee, 0xa2, 0xda, 0x72, 0x5b, 0x99, 0xb3, + 0x15, 0xf3, 0xb8, 0xb4, 0x89, 0x91, 0x8e, 0xf1, 0x09, 0xe1, 0x56, 0x19, + 0x39, 0x51, 0xec, 0x7e, 0x93, 0x7b, 0x16, 0x52, 0xc0, 0xbd, 0x3b, 0xb1, + 0xbf, 0x07, 0x35, 0x73, 0xdf, 0x88, 0x3d, 0x2c, 0x34, 0xf1, 0xef, 0x45, + 0x1f, 0xd4, 0x6b, 0x50, 0x3f, 0x00}) + +var p521G, _ = NewP521Point().SetBytes([]byte{0x04, + 0x00, 0xc6, 0x85, 0x8e, 0x06, 0xb7, 0x04, 0x04, 0xe9, 0xcd, 0x9e, 0x3e, + 0xcb, 0x66, 0x23, 0x95, 0xb4, 0x42, 0x9c, 0x64, 0x81, 0x39, 0x05, 0x3f, + 0xb5, 0x21, 0xf8, 0x28, 0xaf, 0x60, 0x6b, 0x4d, 0x3d, 0xba, 0xa1, 0x4b, + 0x5e, 0x77, 0xef, 0xe7, 0x59, 0x28, 0xfe, 0x1d, 0xc1, 0x27, 0xa2, 0xff, + 0xa8, 0xde, 0x33, 0x48, 0xb3, 0xc1, 0x85, 0x6a, 0x42, 0x9b, 0xf9, 0x7e, + 0x7e, 0x31, 0xc2, 0xe5, 0xbd, 0x66, 0x01, 0x18, 0x39, 0x29, 0x6a, 0x78, + 0x9a, 0x3b, 0xc0, 0x04, 0x5c, 0x8a, 0x5f, 0xb4, 0x2c, 0x7d, 0x1b, 0xd9, + 0x98, 0xf5, 0x44, 0x49, 0x57, 0x9b, 0x44, 0x68, 0x17, 0xaf, 0xbd, 0x17, + 0x27, 0x3e, 0x66, 0x2c, 0x97, 0xee, 0x72, 0x99, 0x5e, 0xf4, 0x26, 0x40, + 0xc5, 0x50, 0xb9, 0x01, 0x3f, 0xad, 0x07, 0x61, 0x35, 0x3c, 0x70, 0x86, + 0xa2, 0x72, 0xc2, 0x40, 0x88, 0xbe, 0x94, 0x76, 0x9f, 0xd1, 0x66, 0x50}) + +const p521ElementLength = 66 + +// P521Point is a P-521 point. The zero value is NOT valid. +type P521Point struct { + // The point is represented in projective coordinates (X:Y:Z), + // where x = X/Z and y = Y/Z. + x, y, z *fiat.P521Element +} + +// NewP521Point returns a new P521Point representing the point at infinity point. +func NewP521Point() *P521Point { + return &P521Point{ + x: new(fiat.P521Element), + y: new(fiat.P521Element).One(), + z: new(fiat.P521Element), + } +} + +// NewP521Generator returns a new P521Point set to the canonical generator. +func NewP521Generator() *P521Point { + return NewP521Point().Set(p521G) +} + +// Set sets p = q and returns p. +func (p *P521Point) Set(q *P521Point) *P521Point { + p.x.Set(q.x) + p.y.Set(q.y) + p.z.Set(q.z) + return p +} + +// SetBytes sets p to the compressed, uncompressed, or infinity value encoded in +// b, as specified in SEC 1, Version 2.0, Section 2.3.4. If the point is not on +// the curve, it returns nil and an error, and the receiver is unchanged. +// Otherwise, it returns p. +func (p *P521Point) SetBytes(b []byte) (*P521Point, error) { + switch { + // Point at infinity. + case len(b) == 1 && b[0] == 0: + return p.Set(NewP521Point()), nil + + // Uncompressed form. + case len(b) == 1+2*p521ElementLength && b[0] == 4: + x, err := new(fiat.P521Element).SetBytes(b[1 : 1+p521ElementLength]) + if err != nil { + return nil, err + } + y, err := new(fiat.P521Element).SetBytes(b[1+p521ElementLength:]) + if err != nil { + return nil, err + } + if err := p521CheckOnCurve(x, y); err != nil { + return nil, err + } + p.x.Set(x) + p.y.Set(y) + p.z.One() + return p, nil + + // Compressed form + case len(b) == 1+p521ElementLength && b[0] == 0: + return nil, errors.New("unimplemented") // TODO(filippo) + + default: + return nil, errors.New("invalid P521 point encoding") + } +} + +func p521CheckOnCurve(x, y *fiat.P521Element) error { + // x³ - 3x + b. + x3 := new(fiat.P521Element).Square(x) + x3.Mul(x3, x) + + threeX := new(fiat.P521Element).Add(x, x) + threeX.Add(threeX, x) + + x3.Sub(x3, threeX) + x3.Add(x3, p521B) + + // y² = x³ - 3x + b + y2 := new(fiat.P521Element).Square(y) + + if x3.Equal(y2) != 1 { + return errors.New("P521 point not on curve") + } + return nil +} + +// Bytes returns the uncompressed or infinity encoding of p, as specified in +// SEC 1, Version 2.0, Section 2.3.3. Note that the encoding of the point at +// infinity is shorter than all other encodings. +func (p *P521Point) Bytes() []byte { + // This function is outlined to make the allocations inline in the caller + // rather than happen on the heap. + var out [133]byte + return p.bytes(&out) +} + +func (p *P521Point) bytes(out *[133]byte) []byte { + if p.z.IsZero() == 1 { + return append(out[:0], 0) + } + + zinv := new(fiat.P521Element).Invert(p.z) + xx := new(fiat.P521Element).Mul(p.x, zinv) + yy := new(fiat.P521Element).Mul(p.y, zinv) + + buf := append(out[:0], 4) + buf = append(buf, xx.Bytes()...) + buf = append(buf, yy.Bytes()...) + return buf +} + +// Add sets q = p1 + p2, and returns q. The points may overlap. +func (q *P521Point) Add(p1, p2 *P521Point) *P521Point { + // Complete addition formula for a = -3 from "Complete addition formulas for + // prime order elliptic curves" (https://eprint.iacr.org/2015/1060), §A.2. + + t0 := new(fiat.P521Element).Mul(p1.x, p2.x) // t0 := X1 * X2 + t1 := new(fiat.P521Element).Mul(p1.y, p2.y) // t1 := Y1 * Y2 + t2 := new(fiat.P521Element).Mul(p1.z, p2.z) // t2 := Z1 * Z2 + t3 := new(fiat.P521Element).Add(p1.x, p1.y) // t3 := X1 + Y1 + t4 := new(fiat.P521Element).Add(p2.x, p2.y) // t4 := X2 + Y2 + t3.Mul(t3, t4) // t3 := t3 * t4 + t4.Add(t0, t1) // t4 := t0 + t1 + t3.Sub(t3, t4) // t3 := t3 - t4 + t4.Add(p1.y, p1.z) // t4 := Y1 + Z1 + x3 := new(fiat.P521Element).Add(p2.y, p2.z) // X3 := Y2 + Z2 + t4.Mul(t4, x3) // t4 := t4 * X3 + x3.Add(t1, t2) // X3 := t1 + t2 + t4.Sub(t4, x3) // t4 := t4 - X3 + x3.Add(p1.x, p1.z) // X3 := X1 + Z1 + y3 := new(fiat.P521Element).Add(p2.x, p2.z) // Y3 := X2 + Z2 + x3.Mul(x3, y3) // X3 := X3 * Y3 + y3.Add(t0, t2) // Y3 := t0 + t2 + y3.Sub(x3, y3) // Y3 := X3 - Y3 + z3 := new(fiat.P521Element).Mul(p521B, t2) // Z3 := b * t2 + x3.Sub(y3, z3) // X3 := Y3 - Z3 + z3.Add(x3, x3) // Z3 := X3 + X3 + x3.Add(x3, z3) // X3 := X3 + Z3 + z3.Sub(t1, x3) // Z3 := t1 - X3 + x3.Add(t1, x3) // X3 := t1 + X3 + y3.Mul(p521B, y3) // Y3 := b * Y3 + t1.Add(t2, t2) // t1 := t2 + t2 + t2.Add(t1, t2) // t2 := t1 + t2 + y3.Sub(y3, t2) // Y3 := Y3 - t2 + y3.Sub(y3, t0) // Y3 := Y3 - t0 + t1.Add(y3, y3) // t1 := Y3 + Y3 + y3.Add(t1, y3) // Y3 := t1 + Y3 + t1.Add(t0, t0) // t1 := t0 + t0 + t0.Add(t1, t0) // t0 := t1 + t0 + t0.Sub(t0, t2) // t0 := t0 - t2 + t1.Mul(t4, y3) // t1 := t4 * Y3 + t2.Mul(t0, y3) // t2 := t0 * Y3 + y3.Mul(x3, z3) // Y3 := X3 * Z3 + y3.Add(y3, t2) // Y3 := Y3 + t2 + x3.Mul(t3, x3) // X3 := t3 * X3 + x3.Sub(x3, t1) // X3 := X3 - t1 + z3.Mul(t4, z3) // Z3 := t4 * Z3 + t1.Mul(t3, t0) // t1 := t3 * t0 + z3.Add(z3, t1) // Z3 := Z3 + t1 + + q.x.Set(x3) + q.y.Set(y3) + q.z.Set(z3) + return q +} + +// Double sets q = p + p, and returns q. The points may overlap. +func (q *P521Point) Double(p *P521Point) *P521Point { + // Complete addition formula for a = -3 from "Complete addition formulas for + // prime order elliptic curves" (https://eprint.iacr.org/2015/1060), §A.2. + + t0 := new(fiat.P521Element).Square(p.x) // t0 := X ^ 2 + t1 := new(fiat.P521Element).Square(p.y) // t1 := Y ^ 2 + t2 := new(fiat.P521Element).Square(p.z) // t2 := Z ^ 2 + t3 := new(fiat.P521Element).Mul(p.x, p.y) // t3 := X * Y + t3.Add(t3, t3) // t3 := t3 + t3 + z3 := new(fiat.P521Element).Mul(p.x, p.z) // Z3 := X * Z + z3.Add(z3, z3) // Z3 := Z3 + Z3 + y3 := new(fiat.P521Element).Mul(p521B, t2) // Y3 := b * t2 + y3.Sub(y3, z3) // Y3 := Y3 - Z3 + x3 := new(fiat.P521Element).Add(y3, y3) // X3 := Y3 + Y3 + y3.Add(x3, y3) // Y3 := X3 + Y3 + x3.Sub(t1, y3) // X3 := t1 - Y3 + y3.Add(t1, y3) // Y3 := t1 + Y3 + y3.Mul(x3, y3) // Y3 := X3 * Y3 + x3.Mul(x3, t3) // X3 := X3 * t3 + t3.Add(t2, t2) // t3 := t2 + t2 + t2.Add(t2, t3) // t2 := t2 + t3 + z3.Mul(p521B, z3) // Z3 := b * Z3 + z3.Sub(z3, t2) // Z3 := Z3 - t2 + z3.Sub(z3, t0) // Z3 := Z3 - t0 + t3.Add(z3, z3) // t3 := Z3 + Z3 + z3.Add(z3, t3) // Z3 := Z3 + t3 + t3.Add(t0, t0) // t3 := t0 + t0 + t0.Add(t3, t0) // t0 := t3 + t0 + t0.Sub(t0, t2) // t0 := t0 - t2 + t0.Mul(t0, z3) // t0 := t0 * Z3 + y3.Add(y3, t0) // Y3 := Y3 + t0 + t0.Mul(p.y, p.z) // t0 := Y * Z + t0.Add(t0, t0) // t0 := t0 + t0 + z3.Mul(t0, z3) // Z3 := t0 * Z3 + x3.Sub(x3, z3) // X3 := X3 - Z3 + z3.Mul(t0, t1) // Z3 := t0 * t1 + z3.Add(z3, z3) // Z3 := Z3 + Z3 + z3.Add(z3, z3) // Z3 := Z3 + Z3 + + q.x.Set(x3) + q.y.Set(y3) + q.z.Set(z3) + return q +} + +// Select sets q to p1 if cond == 1, and to p2 if cond == 0. +func (q *P521Point) Select(p1, p2 *P521Point, cond int) *P521Point { + q.x.Select(p1.x, p2.x, cond) + q.y.Select(p1.y, p2.y, cond) + q.z.Select(p1.z, p2.z, cond) + return q +} + +// ScalarMult sets p = scalar * q, and returns p. +func (p *P521Point) ScalarMult(q *P521Point, scalar []byte) *P521Point { + // table holds the first 16 multiples of q. The explicit newP521Point calls + // get inlined, letting the allocations live on the stack. + var table = [16]*P521Point{ + NewP521Point(), NewP521Point(), NewP521Point(), NewP521Point(), + NewP521Point(), NewP521Point(), NewP521Point(), NewP521Point(), + NewP521Point(), NewP521Point(), NewP521Point(), NewP521Point(), + NewP521Point(), NewP521Point(), NewP521Point(), NewP521Point(), + } + for i := 1; i < 16; i++ { + table[i].Add(table[i-1], q) + } + + // Instead of doing the classic double-and-add chain, we do it with a + // four-bit window: we double four times, and then add [0-15]P. + t := NewP521Point() + p.Set(NewP521Point()) + for _, byte := range scalar { + p.Double(p) + p.Double(p) + p.Double(p) + p.Double(p) + + for i := uint8(0); i < 16; i++ { + cond := subtle.ConstantTimeByteEq(byte>>4, i) + t.Select(table[i], t, cond) + } + p.Add(p, t) + + p.Double(p) + p.Double(p) + p.Double(p) + p.Double(p) + + for i := uint8(0); i < 16; i++ { + cond := subtle.ConstantTimeByteEq(byte&0b1111, i) + t.Select(table[i], t, cond) + } + p.Add(p, t) + } + + return p +} diff --git a/src/crypto/elliptic/internal/nistec/p521_test.go b/src/crypto/elliptic/internal/nistec/p521_test.go new file mode 100644 index 0000000000..e62c1cbf29 --- /dev/null +++ b/src/crypto/elliptic/internal/nistec/p521_test.go @@ -0,0 +1,44 @@ +// Copyright 2021 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 nistec_test + +import ( + "crypto/elliptic/internal/nistec" + "math/rand" + "os" + "strings" + "testing" +) + +func TestP521Allocations(t *testing.T) { + if strings.HasSuffix(os.Getenv("GO_BUILDER_NAME"), "-noopt") { + t.Skip("skipping allocations test without relevant optimizations") + } + if allocs := testing.AllocsPerRun(100, func() { + p := nistec.NewP521Generator() + scalar := make([]byte, 66) + rand.Read(scalar) + p.ScalarMult(p, scalar) + out := p.Bytes() + if _, err := p.SetBytes(out); err != nil { + t.Fatal(err) + } + }); allocs > 0 { + t.Errorf("expected zero allocations, got %0.1f", allocs) + } +} + +func BenchmarkScalarMult(b *testing.B) { + b.Run("P521", func(b *testing.B) { + scalar := make([]byte, 66) + rand.Read(scalar) + p := nistec.NewP521Generator() + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + p.ScalarMult(p, scalar) + } + }) +} diff --git a/src/crypto/elliptic/p521.go b/src/crypto/elliptic/p521.go index 569a58c6f3..4cc5f86d6d 100644 --- a/src/crypto/elliptic/p521.go +++ b/src/crypto/elliptic/p521.go @@ -5,286 +5,152 @@ package elliptic import ( - "crypto/elliptic/internal/fiat" - "crypto/subtle" + "crypto/elliptic/internal/nistec" + "crypto/rand" "math/big" ) +// p521Curve is a Curve implementation based on nistec.P521Point. +// +// It's a wrapper that exposes the big.Int-based Curve interface and encodes the +// legacy idiosyncrasies it requires, such as invalid and infinity point +// handling. +// +// To interact with the nistec package, points are encoded into and decoded from +// properly formatted byte slices. All big.Int use is limited to this package. +// Encoding and decoding is 1/1000th of the runtime of a scalar multiplication, +// so the overhead is acceptable. type p521Curve struct { - *CurveParams - b *fiat.P521Element + params *CurveParams } var p521 p521Curve -var p521Params *CurveParams +var _ Curve = p521 func initP521() { - // See FIPS 186-3, section D.2.5 - p521.CurveParams = &CurveParams{Name: "P-521"} - p521.P, _ = new(big.Int).SetString("6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151", 10) - p521.N, _ = new(big.Int).SetString("6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449", 10) - p521.B, _ = new(big.Int).SetString("051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00", 16) - p521.Gx, _ = new(big.Int).SetString("c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66", 16) - p521.Gy, _ = new(big.Int).SetString("11839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650", 16) - p521.BitSize = 521 - p521.b = bigIntToFiatP521(p521.B) + p521.params = &CurveParams{ + Name: "P-521", + BitSize: 521, + // FIPS 186-4, section D.1.2.5 + P: bigFromDecimal("68647976601306097149819007990813932172694353001433" + + "0540939446345918554318339765605212255964066145455497729631139148" + + "0858037121987999716643812574028291115057151"), + N: bigFromDecimal("68647976601306097149819007990813932172694353001433" + + "0540939446345918554318339765539424505774633321719753296399637136" + + "3321113864768612440380340372808892707005449"), + B: bigFromHex("0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8" + + "b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef" + + "451fd46b503f00"), + Gx: bigFromHex("00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f8" + + "28af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf9" + + "7e7e31c2e5bd66"), + Gy: bigFromHex("011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817" + + "afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088" + + "be94769fd16650"), + } } func (curve p521Curve) Params() *CurveParams { - return curve.CurveParams + return curve.params } func (curve p521Curve) IsOnCurve(x, y *big.Int) bool { - x1 := bigIntToFiatP521(x) - y1 := bigIntToFiatP521(y) - - // x³ - 3x + b. - x3 := new(fiat.P521Element).Square(x1) - x3.Mul(x3, x1) - - threeX := new(fiat.P521Element).Add(x1, x1) - threeX.Add(threeX, x1) - - x3.Sub(x3, threeX) - x3.Add(x3, curve.b) - - // y² = x³ - 3x + b - y2 := new(fiat.P521Element).Square(y1) - - return x3.Equal(y2) == 1 + // IsOnCurve is documented to reject (0, 0), so we don't use + // p521PointFromAffine, but let SetBytes reject the invalid Marshal output. + _, err := nistec.NewP521Point().SetBytes(Marshal(curve, x, y)) + return err == nil } -// p521Point is a P-521 point in projective coordinates, where x = X/Z, y = Y/Z. -type p521Point struct { - x, y, z *fiat.P521Element -} - -// newP521Point returns a new p521Point representing the identity point. -func newP521Point() *p521Point { - return &p521Point{ - x: new(fiat.P521Element), - y: new(fiat.P521Element).One(), - z: new(fiat.P521Element), +func p521PointFromAffine(x, y *big.Int) (p *nistec.P521Point, ok bool) { + // (0, 0) is by convention the point at infinity, which can't be represented + // in affine coordinates. Marshal incorrectly encodes it as an uncompressed + // point, which SetBytes correctly rejects. See Issue 37294. + if x.Sign() == 0 && y.Sign() == 0 { + return nistec.NewP521Point(), true } -} - -func fiatP521ToBigInt(x *fiat.P521Element) *big.Int { - xBytes := x.Bytes() - for i := range xBytes[:len(xBytes)/2] { - xBytes[i], xBytes[len(xBytes)-i-1] = xBytes[len(xBytes)-i-1], xBytes[i] + p, err := nistec.NewP521Point().SetBytes(Marshal(P521(), x, y)) + if err != nil { + return nil, false } - return new(big.Int).SetBytes(xBytes) + return p, true } -// Affine returns p in affine coordinates, with (0, 0) representing infinity by -// convention. It also goes back to big.Int values to match the exposed API. -func (p *p521Point) Affine() (x, y *big.Int) { - if p.z.IsZero() == 1 { +func p521PointToAffine(p *nistec.P521Point) (x, y *big.Int) { + out := p.Bytes() + if len(out) == 1 && out[0] == 0 { + // This is the correct encoding of the point at infinity, which + // Unmarshal does not support. See Issue 37294. return new(big.Int), new(big.Int) } - - zinv := new(fiat.P521Element).Invert(p.z) - xx := new(fiat.P521Element).Mul(p.x, zinv) - yy := new(fiat.P521Element).Mul(p.y, zinv) - - return fiatP521ToBigInt(xx), fiatP521ToBigInt(yy) + x, y = Unmarshal(P521(), out) + if x == nil { + panic("crypto/elliptic: internal error: Unmarshal rejected a valid point encoding") + } + return x, y } -func bigIntToFiatP521(x *big.Int) *fiat.P521Element { - xBytes := new(big.Int).Mod(x, p521.P).FillBytes(make([]byte, 66)) - for i := range xBytes[:len(xBytes)/2] { - xBytes[i], xBytes[len(xBytes)-i-1] = xBytes[len(xBytes)-i-1], xBytes[i] - } - x1, err := new(fiat.P521Element).SetBytes(xBytes) +// p521RandomPoint returns a random point on the curve. It's used when Add, +// Double, or ScalarMult are fed a point not on the curve, which is undefined +// behavior. Originally, we used to do the math on it anyway (which allows +// invalid curve attacks) and relied on the caller and Unmarshal to avoid this +// happening in the first place. Now, we just can't construct a nistec.P521Point +// for an invalid pair of coordinates, because that API is safer. If we panic, +// we risk introducing a DoS. If we return nil, we risk a panic. If we return +// the input, ecdsa.Verify might fail open. The safest course seems to be to +// return a valid, random point, which hopefully won't help the attacker. +func p521RandomPoint() (x, y *big.Int) { + _, x, y, err := GenerateKey(P521(), rand.Reader) if err != nil { - // The input is reduced modulo P and encoded in a fixed size bytes - // slice, this should be impossible. - panic("internal error: bigIntToFiatP521") - } - return x1 -} - -// newP521PointFromAffine converts (x, y) affine coordinates into (X, Y, Z) projective -// coordinates. It also converts from big.Int to fiat, which is necessarily a -// messy and variable-time operation, which we can't avoid due to the exposed API. -func newP521PointFromAffine(x, y *big.Int) *p521Point { - // (0, 0) is by convention the point at infinity, which can't be represented - // in affine coordinates, but is (0, 0, 0) in projective coordinates. - if x.Sign() == 0 && y.Sign() == 0 { - return newP521Point() - } - return &p521Point{ - x: bigIntToFiatP521(x), - y: bigIntToFiatP521(y), - z: new(fiat.P521Element).One(), + panic("crypto/elliptic: failed to generate random point") } + return x, y } func (curve p521Curve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int) { - p1 := newP521PointFromAffine(x1, y1) - p2 := newP521PointFromAffine(x2, y2) - return p1.Add(p1, p2).Affine() -} - -// Add sets q = p1 + p2, and returns q. The points may overlap. -func (q *p521Point) Add(p1, p2 *p521Point) *p521Point { - // Complete addition formula for a = -3 from "Complete addition formulas for - // prime order elliptic curves" (https://eprint.iacr.org/2015/1060), §A.2. - - t0 := new(fiat.P521Element).Mul(p1.x, p2.x) // t0 := X1 * X2 - t1 := new(fiat.P521Element).Mul(p1.y, p2.y) // t1 := Y1 * Y2 - t2 := new(fiat.P521Element).Mul(p1.z, p2.z) // t2 := Z1 * Z2 - t3 := new(fiat.P521Element).Add(p1.x, p1.y) // t3 := X1 + Y1 - t4 := new(fiat.P521Element).Add(p2.x, p2.y) // t4 := X2 + Y2 - t3.Mul(t3, t4) // t3 := t3 * t4 - t4.Add(t0, t1) // t4 := t0 + t1 - t3.Sub(t3, t4) // t3 := t3 - t4 - t4.Add(p1.y, p1.z) // t4 := Y1 + Z1 - x := new(fiat.P521Element).Add(p2.y, p2.z) // X3 := Y2 + Z2 - t4.Mul(t4, x) // t4 := t4 * X3 - x.Add(t1, t2) // X3 := t1 + t2 - t4.Sub(t4, x) // t4 := t4 - X3 - x.Add(p1.x, p1.z) // X3 := X1 + Z1 - y := new(fiat.P521Element).Add(p2.x, p2.z) // Y3 := X2 + Z2 - x.Mul(x, y) // X3 := X3 * Y3 - y.Add(t0, t2) // Y3 := t0 + t2 - y.Sub(x, y) // Y3 := X3 - Y3 - z := new(fiat.P521Element).Mul(p521.b, t2) // Z3 := b * t2 - x.Sub(y, z) // X3 := Y3 - Z3 - z.Add(x, x) // Z3 := X3 + X3 - x.Add(x, z) // X3 := X3 + Z3 - z.Sub(t1, x) // Z3 := t1 - X3 - x.Add(t1, x) // X3 := t1 + X3 - y.Mul(p521.b, y) // Y3 := b * Y3 - t1.Add(t2, t2) // t1 := t2 + t2 - t2.Add(t1, t2) // t2 := t1 + t2 - y.Sub(y, t2) // Y3 := Y3 - t2 - y.Sub(y, t0) // Y3 := Y3 - t0 - t1.Add(y, y) // t1 := Y3 + Y3 - y.Add(t1, y) // Y3 := t1 + Y3 - t1.Add(t0, t0) // t1 := t0 + t0 - t0.Add(t1, t0) // t0 := t1 + t0 - t0.Sub(t0, t2) // t0 := t0 - t2 - t1.Mul(t4, y) // t1 := t4 * Y3 - t2.Mul(t0, y) // t2 := t0 * Y3 - y.Mul(x, z) // Y3 := X3 * Z3 - y.Add(y, t2) // Y3 := Y3 + t2 - x.Mul(t3, x) // X3 := t3 * X3 - x.Sub(x, t1) // X3 := X3 - t1 - z.Mul(t4, z) // Z3 := t4 * Z3 - t1.Mul(t3, t0) // t1 := t3 * t0 - z.Add(z, t1) // Z3 := Z3 + t1 - - q.x.Set(x) - q.y.Set(y) - q.z.Set(z) - return q + p1, ok := p521PointFromAffine(x1, y1) + if !ok { + return p521RandomPoint() + } + p2, ok := p521PointFromAffine(x2, y2) + if !ok { + return p521RandomPoint() + } + return p521PointToAffine(p1.Add(p1, p2)) } func (curve p521Curve) Double(x1, y1 *big.Int) (*big.Int, *big.Int) { - p := newP521PointFromAffine(x1, y1) - return p.Double(p).Affine() -} - -// Double sets q = p + p, and returns q. The points may overlap. -func (q *p521Point) Double(p *p521Point) *p521Point { - // Complete addition formula for a = -3 from "Complete addition formulas for - // prime order elliptic curves" (https://eprint.iacr.org/2015/1060), §A.2. - - t0 := new(fiat.P521Element).Square(p.x) // t0 := X ^ 2 - t1 := new(fiat.P521Element).Square(p.y) // t1 := Y ^ 2 - t2 := new(fiat.P521Element).Square(p.z) // t2 := Z ^ 2 - t3 := new(fiat.P521Element).Mul(p.x, p.y) // t3 := X * Y - t3.Add(t3, t3) // t3 := t3 + t3 - z := new(fiat.P521Element).Mul(p.x, p.z) // Z3 := X * Z - z.Add(z, z) // Z3 := Z3 + Z3 - y := new(fiat.P521Element).Mul(p521.b, t2) // Y3 := b * t2 - y.Sub(y, z) // Y3 := Y3 - Z3 - x := new(fiat.P521Element).Add(y, y) // X3 := Y3 + Y3 - y.Add(x, y) // Y3 := X3 + Y3 - x.Sub(t1, y) // X3 := t1 - Y3 - y.Add(t1, y) // Y3 := t1 + Y3 - y.Mul(x, y) // Y3 := X3 * Y3 - x.Mul(x, t3) // X3 := X3 * t3 - t3.Add(t2, t2) // t3 := t2 + t2 - t2.Add(t2, t3) // t2 := t2 + t3 - z.Mul(p521.b, z) // Z3 := b * Z3 - z.Sub(z, t2) // Z3 := Z3 - t2 - z.Sub(z, t0) // Z3 := Z3 - t0 - t3.Add(z, z) // t3 := Z3 + Z3 - z.Add(z, t3) // Z3 := Z3 + t3 - t3.Add(t0, t0) // t3 := t0 + t0 - t0.Add(t3, t0) // t0 := t3 + t0 - t0.Sub(t0, t2) // t0 := t0 - t2 - t0.Mul(t0, z) // t0 := t0 * Z3 - y.Add(y, t0) // Y3 := Y3 + t0 - t0.Mul(p.y, p.z) // t0 := Y * Z - t0.Add(t0, t0) // t0 := t0 + t0 - z.Mul(t0, z) // Z3 := t0 * Z3 - x.Sub(x, z) // X3 := X3 - Z3 - z.Mul(t0, t1) // Z3 := t0 * t1 - z.Add(z, z) // Z3 := Z3 + Z3 - z.Add(z, z) // Z3 := Z3 + Z3 - - q.x.Set(x) - q.y.Set(y) - q.z.Set(z) - return q -} - -// Select sets q to p1 if cond == 1, and to p2 if cond == 0. -func (q *p521Point) Select(p1, p2 *p521Point, cond int) *p521Point { - q.x.Select(p1.x, p2.x, cond) - q.y.Select(p1.y, p2.y, cond) - q.z.Select(p1.z, p2.z, cond) - return q + p, ok := p521PointFromAffine(x1, y1) + if !ok { + return p521RandomPoint() + } + return p521PointToAffine(p.Double(p)) } func (curve p521Curve) ScalarMult(Bx, By *big.Int, scalar []byte) (*big.Int, *big.Int) { - B := newP521PointFromAffine(Bx, By) - p, t := newP521Point(), newP521Point() - - // table holds the first 16 multiples of q. The explicit newP521Point calls - // get inlined, letting the allocations live on the stack. - var table = [16]*p521Point{ - newP521Point(), newP521Point(), newP521Point(), newP521Point(), - newP521Point(), newP521Point(), newP521Point(), newP521Point(), - newP521Point(), newP521Point(), newP521Point(), newP521Point(), - newP521Point(), newP521Point(), newP521Point(), newP521Point(), + p, ok := p521PointFromAffine(Bx, By) + if !ok { + return p521RandomPoint() } - for i := 1; i < 16; i++ { - table[i].Add(table[i-1], B) - } - - // Instead of doing the classic double-and-add chain, we do it with a - // four-bit window: we double four times, and then add [0-15]P. - for _, byte := range scalar { - p.Double(p) - p.Double(p) - p.Double(p) - p.Double(p) - - for i := uint8(0); i < 16; i++ { - cond := subtle.ConstantTimeByteEq(byte>>4, i) - t.Select(table[i], t, cond) - } - p.Add(p, t) - - p.Double(p) - p.Double(p) - p.Double(p) - p.Double(p) - - for i := uint8(0); i < 16; i++ { - cond := subtle.ConstantTimeByteEq(byte&0b1111, i) - t.Select(table[i], t, cond) - } - p.Add(p, t) - } - - return p.Affine() + return p521PointToAffine(p.ScalarMult(p, scalar)) } -func (curve p521Curve) ScalarBaseMult(k []byte) (*big.Int, *big.Int) { - return curve.ScalarMult(curve.Gx, curve.Gy, k) +func (curve p521Curve) ScalarBaseMult(scalar []byte) (*big.Int, *big.Int) { + p := nistec.NewP521Generator() + return p521PointToAffine(p.ScalarMult(p, scalar)) +} + +func bigFromDecimal(s string) *big.Int { + b, ok := new(big.Int).SetString(s, 10) + if !ok { + panic("invalid encoding") + } + return b +} + +func bigFromHex(s string) *big.Int { + b, ok := new(big.Int).SetString(s, 16) + if !ok { + panic("invalid encoding") + } + return b } diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go index ab85c99602..f4a92f8be4 100644 --- a/src/go/build/deps_test.go +++ b/src/go/build/deps_test.go @@ -396,6 +396,7 @@ var depsRules = ` < crypto/subtle < crypto/internal/subtle < crypto/elliptic/internal/fiat + < crypto/elliptic/internal/nistec < crypto/ed25519/internal/edwards25519/field, golang.org/x/crypto/curve25519/internal/field < crypto/ed25519/internal/edwards25519 < crypto/cipher From f582778ee991e8a443e691f9a45c8f0600a748a0 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 6 Aug 2021 17:01:25 -0400 Subject: [PATCH 259/406] cmd/compile: emit sensible go_asm.h consts for big ints Currently, the compiler will emit any const that doesn't fit in an int64 to go_asm.h like #define const_stackPreempt constant.intVal{val:(*big.Int)(0xc000c06c40)} This happens because dumpasmhdr formats the constant.Value using the verb "%#v". Since constant.Value doesn't implement the GoString() method, this just prints the Go-syntax representation of the value. This happens to work for small integer constants, which go/constant represents directly as an int64, but not for integer constants that don't fit in an int64, which go/constant represents as a big.Int. Make these constants usable by changing the formatting verb to "%v", which will call the String() method, giving a reasonable result in all cases. Change-Id: I365eeb88c8acfc43ff377cc873432269bde3f541 Reviewed-on: https://go-review.googlesource.com/c/go/+/359954 Trust: Austin Clements Run-TryBot: Austin Clements TryBot-Result: Go Bot Reviewed-by: David Chase --- src/cmd/compile/internal/gc/export.go | 2 +- test/asmhdr.dir/main.go | 66 +++++++++++++++++++++++++++ test/asmhdr.dir/main.s | 27 +++++++++++ test/asmhdr.go | 9 ++++ 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 test/asmhdr.dir/main.go create mode 100644 test/asmhdr.dir/main.s create mode 100644 test/asmhdr.go diff --git a/src/cmd/compile/internal/gc/export.go b/src/cmd/compile/internal/gc/export.go index 2eac7d03c2..eed438705a 100644 --- a/src/cmd/compile/internal/gc/export.go +++ b/src/cmd/compile/internal/gc/export.go @@ -31,7 +31,7 @@ func dumpasmhdr() { if t == constant.Float || t == constant.Complex { break } - fmt.Fprintf(b, "#define const_%s %#v\n", n.Sym().Name, n.Val()) + fmt.Fprintf(b, "#define const_%s %v\n", n.Sym().Name, n.Val()) case ir.OTYPE: t := n.Type() diff --git a/test/asmhdr.dir/main.go b/test/asmhdr.dir/main.go new file mode 100644 index 0000000000..808b5de7bb --- /dev/null +++ b/test/asmhdr.dir/main.go @@ -0,0 +1,66 @@ +// Copyright 2021 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 main + +import "unsafe" + +const ( + smallInt = 42 + + // For bigInt, we use a value that's too big for an int64, but still + // fits in uint64. go/constant uses a different representation for + // values larger than int64, but the cmd/asm parser can't parse + // anything bigger than a uint64. + bigInt = 0xffffffffffffffff + + stringVal = "test" +) + +var ( + smallIntAsm int64 + bigIntAsm uint64 + stringAsm [len(stringVal)]byte +) + +type typ struct { + a uint64 + b [100]uint8 + c uint8 +} + +var ( + typSize uint64 + + typA, typB, typC uint64 +) + +func main() { + if smallInt != smallIntAsm { + println("smallInt", smallInt, "!=", smallIntAsm) + } + if bigInt != bigIntAsm { + println("bigInt", uint64(bigInt), "!=", bigIntAsm) + } + if stringVal != string(stringAsm[:]) { + println("stringVal", stringVal, "!=", string(stringAsm[:])) + } + + // We also include boolean consts in go_asm.h, but they're + // defined to be "true" or "false", and it's not clear how to + // use that in assembly. + + if want := unsafe.Sizeof(typ{}); want != uintptr(typSize) { + println("typSize", want, "!=", typSize) + } + if want := unsafe.Offsetof(typ{}.a); want != uintptr(typA) { + println("typA", want, "!=", typA) + } + if want := unsafe.Offsetof(typ{}.b); want != uintptr(typB) { + println("typB", want, "!=", typB) + } + if want := unsafe.Offsetof(typ{}.c); want != uintptr(typC) { + println("typC", want, "!=", typC) + } +} diff --git a/test/asmhdr.dir/main.s b/test/asmhdr.dir/main.s new file mode 100644 index 0000000000..7e2d8e7abd --- /dev/null +++ b/test/asmhdr.dir/main.s @@ -0,0 +1,27 @@ +// Copyright 2021 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. + +#include "go_asm.h" +#define RODATA 8 + +DATA ·smallIntAsm(SB)/8, $const_smallInt +GLOBL ·smallIntAsm(SB),RODATA,$8 + +DATA ·bigIntAsm(SB)/8, $const_bigInt +GLOBL ·bigIntAsm(SB),RODATA,$8 + +DATA ·stringAsm(SB)/4, $const_stringVal +GLOBL ·stringAsm(SB),RODATA,$4 + +DATA ·typSize(SB)/8, $typ__size +GLOBL ·typSize(SB),RODATA,$8 + +DATA ·typA(SB)/8, $typ_a +GLOBL ·typA(SB),RODATA,$8 + +DATA ·typB(SB)/8, $typ_b +GLOBL ·typB(SB),RODATA,$8 + +DATA ·typC(SB)/8, $typ_c +GLOBL ·typC(SB),RODATA,$8 diff --git a/test/asmhdr.go b/test/asmhdr.go new file mode 100644 index 0000000000..772f98e2cc --- /dev/null +++ b/test/asmhdr.go @@ -0,0 +1,9 @@ +// buildrundir + +// Copyright 2021 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. + +// Test the -asmhdr output of the compiler. + +package ignored From 6113dacf32db7a996bc53fa7ca0db314cd3e7378 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 17 Sep 2021 09:56:21 -0400 Subject: [PATCH 260/406] cmd/compile: make -memprofilerate work There are multiple things preventing the -memprofilerate flag from working right now: - CmdFlags.MemProfileRate has type int64, which is currently not supported by the compiler's reflection-based registerFlags. Unfortunately, rather than letting you know this, registerFlags simply ignores this field. - Nothing consumes CmdFlags.MemProfileRate anyway. startProfile instead uses a package-local memprofilerate variable that is never set to anything. Fix this by making CmdFlags.MemProfileRate an int (that's what runtime.MemProfileRate is anyway) and using it in startProfile. While we're here, prevent similar flag parsing bugs in the future by making registerFlags panic if it encounters a flag field of unsupported type. Change-Id: Ib9a1fcd8f4c5e9d7175a4fabc375f31e79774f9a Reviewed-on: https://go-review.googlesource.com/c/go/+/359955 Trust: Austin Clements Trust: Josh Bleecher Snyder Run-TryBot: Austin Clements TryBot-Result: Go Bot Reviewed-by: Josh Bleecher Snyder Reviewed-by: David Chase --- src/cmd/compile/internal/base/flag.go | 4 +++- src/cmd/compile/internal/gc/util.go | 9 +++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cmd/compile/internal/base/flag.go b/src/cmd/compile/internal/base/flag.go index 51938e8fd5..9d630ce97a 100644 --- a/src/cmd/compile/internal/base/flag.go +++ b/src/cmd/compile/internal/base/flag.go @@ -109,7 +109,7 @@ type CmdFlags struct { Live CountFlag "help:\"debug liveness analysis\"" MSan bool "help:\"build code compatible with C/C++ memory sanitizer\"" MemProfile string "help:\"write memory profile to `file`\"" - MemProfileRate int64 "help:\"set runtime.MemProfileRate to `rate`\"" + MemProfileRate int "help:\"set runtime.MemProfileRate to `rate`\"" MutexProfile string "help:\"write mutex profile to `file`\"" NoLocalImports bool "help:\"reject local (relative) imports\"" Pack bool "help:\"write to file.a instead of file.o\"" @@ -330,6 +330,8 @@ func registerFlags() { case funcType: f := v.Field(i).Interface().(func(string)) objabi.Flagfn1(name, help, f) + default: + panic(fmt.Sprintf("base.Flag.%s has unexpected type %s", f.Name, f.Type)) } } } diff --git a/src/cmd/compile/internal/gc/util.go b/src/cmd/compile/internal/gc/util.go index 4baddbc029..56fd137de2 100644 --- a/src/cmd/compile/internal/gc/util.go +++ b/src/cmd/compile/internal/gc/util.go @@ -12,10 +12,7 @@ import ( "cmd/compile/internal/base" ) -var ( - memprofilerate int64 - traceHandler func(string) -) +var traceHandler func(string) func startProfile() { if base.Flag.CPUProfile != "" { @@ -29,8 +26,8 @@ func startProfile() { base.AtExit(pprof.StopCPUProfile) } if base.Flag.MemProfile != "" { - if memprofilerate != 0 { - runtime.MemProfileRate = int(memprofilerate) + if base.Flag.MemProfileRate != 0 { + runtime.MemProfileRate = base.Flag.MemProfileRate } f, err := os.Create(base.Flag.MemProfile) if err != nil { From 0bef30d28ac0b9654e5daef0fef731d7a9495214 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Sat, 30 Oct 2021 10:50:59 -0700 Subject: [PATCH 261/406] cmd/compile/internal/syntax: fix parsing of array or slice constraint types This is a port of the idea used in CL 359134 from go/parser to syntax, with adjustments due to the slightly different structure of the two parsers, and some refactoring to simplify the logic. Fixes #49175. Change-Id: Ib4955bde708f2b08345f35523e6094c03ab3076c Reviewed-on: https://go-review.googlesource.com/c/go/+/360135 Trust: Robert Griesemer Run-TryBot: Robert Griesemer TryBot-Result: Go Bot Reviewed-by: Robert Findley --- src/cmd/compile/internal/syntax/parser.go | 82 +++++++++++-------- .../internal/syntax/testdata/typeset.go2 | 10 ++- 2 files changed, 57 insertions(+), 35 deletions(-) diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go index af5a505cdb..9f02cb6c2c 100644 --- a/src/cmd/compile/internal/syntax/parser.go +++ b/src/cmd/compile/internal/syntax/parser.go @@ -586,42 +586,54 @@ func (p *parser) typeDecl(group *Group) Decl { d.Pragma = p.takePragma() d.Name = p.name() - if p.tok == _Lbrack { - // array/slice or generic type - // name "[" ... + if p.allowGenerics() && p.tok == _Lbrack { + // d.Name "[" ... + // array/slice or type parameter list pos := p.pos() p.next() switch p.tok { - case _Rbrack: - // name "[" "]" ... - p.next() - d.Type = p.sliceType(pos) case _Name: - // array or generic type - // name "[" name ... - p.xnest++ - // TODO(gri) p.expr may consume an opening "[" when it shouldn't (issue #49175) - x := p.expr() - p.xnest-- - if name0, ok := x.(*Name); p.allowGenerics() && ok && p.tok != _Rbrack { - // generic type - // name "[" name ... - d.TParamList = p.paramList(name0, _Rbrack, true) - pos := p.pos() - if p.gotAssign() { - p.syntaxErrorAt(pos, "generic type cannot be alias") + // d.Name "[" name ... + // array or type parameter list + name := p.name() + // Index or slice expressions are never constant and thus invalid + // array length expressions. Thus, if we see a "[" following name + // we can safely assume that "[" name starts a type parameter list. + var x Expr // x != nil means x is the array length expression + if p.tok != _Lbrack { + // d.Name "[" name ... + // If we reach here, the next token is not a "[", and we need to + // parse the expression starting with name. If that expression is + // just that name, not followed by a "]" (in which case we might + // have the array length "[" name "]"), we can also safely assume + // a type parameter list. + p.xnest++ + // To parse the expression starting with name, expand the call + // sequence we would get by passing in name to parser.expr, and + // pass in name to parser.pexpr. + x = p.binaryExpr(p.pexpr(name, false), 0) + p.xnest-- + if x == name && p.tok != _Rbrack { + x = nil } + } + if x == nil { + // d.Name "[" name ... + // type parameter list + d.TParamList = p.paramList(name, _Rbrack, true) + d.Alias = p.gotAssign() d.Type = p.typeOrNil() } else { + // d.Name "[" x "]" ... // x is the array length expression - // name "[" x ... - if debug && x == nil { - panic("length expression is nil") - } d.Type = p.arrayType(pos, x) } + case _Rbrack: + // d.Name "[" "]" ... + p.next() + d.Type = p.sliceType(pos) default: - // name "[" ... + // d.Name "[" ... d.Type = p.arrayType(pos, nil) } } else { @@ -736,14 +748,16 @@ func (p *parser) expr() Expr { defer p.trace("expr")() } - return p.binaryExpr(0) + return p.binaryExpr(nil, 0) } // Expression = UnaryExpr | Expression binary_op Expression . -func (p *parser) binaryExpr(prec int) Expr { +func (p *parser) binaryExpr(x Expr, prec int) Expr { // don't trace binaryExpr - only leads to overly nested trace output - x := p.unaryExpr() + if x == nil { + x = p.unaryExpr() + } for (p.tok == _Operator || p.tok == _Star) && p.prec > prec { t := new(Operation) t.pos = p.pos() @@ -751,7 +765,7 @@ func (p *parser) binaryExpr(prec int) Expr { tprec := p.prec p.next() t.X = x - t.Y = p.binaryExpr(tprec) + t.Y = p.binaryExpr(nil, tprec) x = t } return x @@ -846,7 +860,7 @@ func (p *parser) unaryExpr() Expr { // TODO(mdempsky): We need parens here so we can report an // error for "(x) := true". It should be possible to detect // and reject that more efficiently though. - return p.pexpr(true) + return p.pexpr(nil, true) } // callStmt parses call-like statements that can be preceded by 'defer' and 'go'. @@ -860,7 +874,7 @@ func (p *parser) callStmt() *CallStmt { s.Tok = p.tok // _Defer or _Go p.next() - x := p.pexpr(p.tok == _Lparen) // keep_parens so we can report error below + x := p.pexpr(nil, p.tok == _Lparen) // keep_parens so we can report error below if t := unparen(x); t != x { p.errorAt(x.Pos(), fmt.Sprintf("expression in %s must not be parenthesized", s.Tok)) // already progressed, no need to advance @@ -976,12 +990,14 @@ func (p *parser) operand(keep_parens bool) Expr { // "]" . // TypeAssertion = "." "(" Type ")" . // Arguments = "(" [ ( ExpressionList | Type [ "," ExpressionList ] ) [ "..." ] [ "," ] ] ")" . -func (p *parser) pexpr(keep_parens bool) Expr { +func (p *parser) pexpr(x Expr, keep_parens bool) Expr { if trace { defer p.trace("pexpr")() } - x := p.operand(keep_parens) + if x == nil { + x = p.operand(keep_parens) + } loop: for { diff --git a/src/cmd/compile/internal/syntax/testdata/typeset.go2 b/src/cmd/compile/internal/syntax/testdata/typeset.go2 index 78d3fe1ae5..19b74f28ea 100644 --- a/src/cmd/compile/internal/syntax/testdata/typeset.go2 +++ b/src/cmd/compile/internal/syntax/testdata/typeset.go2 @@ -44,17 +44,23 @@ type ( _[_ t|~struct{}] t _[_ ~t|~struct{}] t - // TODO(gri) fix this (issue #49175) - // _[_ []t]t + // test cases for issue #49175 + _[_ []t]t + _[_ [1]t]t _[_ ~[]t]t + _[_ ~[1]t]t + t [ /* ERROR type parameters must be named */ t[0]]t ) // test cases for issue #49174 func _[_ t]() {} func _[_ []t]() {} +func _[_ [1]t]() {} func _[_ []t | t]() {} +func _[_ [1]t | t]() {} func _[_ t | []t]() {} func _[_ []t | []t]() {} +func _[_ [1]t | [1]t]() {} func _[_ t[t] | t[t]]() {} // Single-expression type parameter lists and those that don't start From 8e3d5f0bb324eebb92cc93264a63afa7ded9ab9a Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Wed, 27 Oct 2021 14:24:37 +1100 Subject: [PATCH 262/406] image/draw: rename and reorder some benchmarks The intention is for BenchmarkFooBar functions to map 1:1 to drawFooBar functions. Recent draw.go changes have added more drawFooBar functions and have further modified the mapping, as fallback drawFooBar functions aren't invoked as often as they used to. This commit restores the 1:1 mapping and reorganizes the BenchmarkFooBar functions in the same order as the matching drawFooBar functions appear. Also modify a TestDraw test case from vgradGreen(255) = {0, 136, 0, 255} to vgradGreen(90) = {0, 48, 0, 90}. Doing so matches the existing "The source pixel is {0, 48, 0, 90}" comment but also makes for a more interesting test case, as the source pixel is no longer fully opaque. Fully opaque is already covered by the vgradGray() test case on the next line. Also fix a "variable source" comment copy-pasto when the source image is actually uniform, not variable. Also add a func DrawMask type switch comment about interface types. Change-Id: I828e71f2ee8ec617f523c8aafb118fb7ba166876 Reviewed-on: https://go-review.googlesource.com/c/go/+/358974 Trust: Nigel Tao Trust: Brad Fitzpatrick Run-TryBot: Nigel Tao TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- src/image/draw/bench_test.go | 27 +++++++++++++-------------- src/image/draw/draw.go | 2 ++ src/image/draw/draw_test.go | 13 +++++++++---- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/image/draw/bench_test.go b/src/image/draw/bench_test.go index 2b7c6d6ac4..55d25b8596 100644 --- a/src/image/draw/bench_test.go +++ b/src/image/draw/bench_test.go @@ -190,8 +190,7 @@ func bench(b *testing.B, dcm, scm, mcm color.Model, op Op) { } } -// The BenchmarkFoo and BenchmarkFooN functions exercise a drawFoo fast-path -// function in draw.go. +// The BenchmarkFoo functions exercise a drawFoo fast-path function in draw.go. func BenchmarkFillOver(b *testing.B) { bench(b, color.RGBAModel, nil, nil, Over) @@ -233,12 +232,20 @@ func BenchmarkGlyphOver(b *testing.B) { bench(b, color.RGBAModel, nil, color.AlphaModel, Over) } -func BenchmarkRGBA1(b *testing.B) { - bench(b, color.RGBAModel, color.RGBA64Model, nil, Src) +func BenchmarkRGBAMaskOver(b *testing.B) { + bench(b, color.RGBAModel, color.RGBAModel, color.AlphaModel, Over) } -func BenchmarkRGBA2(b *testing.B) { - bench(b, color.RGBAModel, color.RGBAModel, color.AlphaModel, Over) +func BenchmarkGrayMaskOver(b *testing.B) { + bench(b, color.RGBAModel, color.GrayModel, color.AlphaModel, Over) +} + +func BenchmarkRGBA64ImageMaskOver(b *testing.B) { + bench(b, color.RGBAModel, color.RGBA64Model, color.AlphaModel, Over) +} + +func BenchmarkRGBA(b *testing.B) { + bench(b, color.RGBAModel, color.RGBA64Model, nil, Src) } func BenchmarkPalettedFill(b *testing.B) { @@ -266,11 +273,3 @@ func BenchmarkGenericSrc(b *testing.B) { func BenchmarkGenericMaskSrc(b *testing.B) { bench(b, color.RGBA64Model, color.RGBA64Model, color.AlphaModel, Src) } - -func BenchmarkRGBA64Over(b *testing.B) { - bench(b, color.RGBAModel, color.RGBA64Model, color.AlphaModel, Over) -} - -func BenchmarkGrayOver(b *testing.B) { - bench(b, color.RGBAModel, color.GrayModel, color.AlphaModel, Over) -} diff --git a/src/image/draw/draw.go b/src/image/draw/draw.go index d3c5b29097..7dd18dfdb5 100644 --- a/src/image/draw/draw.go +++ b/src/image/draw/draw.go @@ -166,6 +166,8 @@ func DrawMask(dst Image, r image.Rectangle, src image.Image, sp image.Point, mas case *image.Gray: drawGrayMaskOver(dst0, r, src0, sp, mask0, mp) return + // Case order matters. The next case (image.RGBA64Image) is an + // interface type that the concrete types above also implement. case image.RGBA64Image: drawRGBA64ImageMaskOver(dst0, r, src0, sp, mask0, mp) return diff --git a/src/image/draw/draw_test.go b/src/image/draw/draw_test.go index 75a2896631..77f1c5c2c2 100644 --- a/src/image/draw/draw_test.go +++ b/src/image/draw/draw_test.go @@ -380,7 +380,7 @@ var drawTests = []drawTest{ {"cmykAlphaSrc", vgradMagenta(), fillAlpha(192), Src, color.RGBA{145, 67, 145, 192}}, {"cmykNil", vgradMagenta(), nil, Over, color.RGBA{192, 89, 192, 255}}, {"cmykNilSrc", vgradMagenta(), nil, Src, color.RGBA{192, 89, 192, 255}}, - // Variable mask and variable source. + // Variable mask and uniform source. // At (x, y) == (8, 8): // The destination pixel is {136, 0, 0, 255}. // The source pixel is {0, 0, 255, 255}. @@ -397,9 +397,14 @@ var drawTests = []drawTest{ Over, color.RGBA{81, 0, 102, 255}}, {"genericSrcSlowest", fillBlue(255), convertToSlowestRGBA(vgradAlpha(192)), Src, color.RGBA{0, 0, 102, 102}}, - // The source pixel is {0, 48, 0, 90}. - {"rgbaVariableMaskOver", vgradGreen(255), vgradAlpha(192), Over, color.RGBA{81, 54, 0, 255}}, - // The source pixel is {136} in Gray-space, which is {136, 136, 136, 255} in RGBA-space. + // Variable mask and variable source. + // At (x, y) == (8, 8): + // The destination pixel is {136, 0, 0, 255}. + // The source pixel is: + // - {0, 48, 0, 90}. + // - {136} in Gray-space, which is {136, 136, 136, 255} in RGBA-space. + // The mask pixel's alpha is 102, or 40%. + {"rgbaVariableMaskOver", vgradGreen(90), vgradAlpha(192), Over, color.RGBA{117, 19, 0, 255}}, {"grayVariableMaskOver", vgradGray(), vgradAlpha(192), Over, color.RGBA{136, 54, 54, 255}}, } From 243c5ae019bab96caf55dd443a0ecd128f079d9c Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Sat, 30 Oct 2021 20:54:39 -0400 Subject: [PATCH 263/406] go/parser: simplify parsing of array or slice constraint types Simplify the parsing of array or slice constraint types added in CL 359134, following the port in CL 360135. Change-Id: Ia86d4b0149a222423d3b19623dd39d4aeb23857d Reviewed-on: https://go-review.googlesource.com/c/go/+/360115 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/parser/parser.go | 98 +++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 52 deletions(-) diff --git a/src/go/parser/parser.go b/src/go/parser/parser.go index 792fe4141c..8952a2bc29 100644 --- a/src/go/parser/parser.go +++ b/src/go/parser/parser.go @@ -455,10 +455,10 @@ func (p *parser) parseExprList() (list []ast.Expr) { defer un(trace(p, "ExpressionList")) } - list = append(list, p.checkExpr(p.parseExpr(nil))) + list = append(list, p.checkExpr(p.parseExpr())) for p.tok == token.COMMA { p.next() - list = append(list, p.checkExpr(p.parseExpr(nil))) + list = append(list, p.checkExpr(p.parseExpr())) } return @@ -525,23 +525,27 @@ func (p *parser) parseTypeName(ident *ast.Ident) ast.Expr { return ident } -func (p *parser) parseArrayLen() ast.Expr { +// "[" has already been consumed, and lbrack is its position. +// If len != nil it is the already consumed array length. +func (p *parser) parseArrayType(lbrack token.Pos, len ast.Expr) *ast.ArrayType { if p.trace { - defer un(trace(p, "ArrayLen")) + defer un(trace(p, "ArrayType")) } - p.exprLev++ - var len ast.Expr - // always permit ellipsis for more fault-tolerant parsing - if p.tok == token.ELLIPSIS { - len = &ast.Ellipsis{Ellipsis: p.pos} - p.next() - } else if p.tok != token.RBRACK { - len = p.parseRhs() + if len == nil { + p.exprLev++ + // always permit ellipsis for more fault-tolerant parsing + if p.tok == token.ELLIPSIS { + len = &ast.Ellipsis{Ellipsis: p.pos} + p.next() + } else if p.tok != token.RBRACK { + len = p.parseRhs() + } + p.exprLev-- } - p.exprLev-- - - return len + p.expect(token.RBRACK) + elt := p.parseType() + return &ast.ArrayType{Lbrack: lbrack, Len: len, Elt: elt} } func (p *parser) parseArrayFieldOrTypeInstance(x *ast.Ident) (*ast.Ident, ast.Expr) { @@ -996,7 +1000,7 @@ func (p *parser) parseMethodSpec() *ast.Field { lbrack := p.pos p.next() p.exprLev++ - x := p.parseExpr(nil) + x := p.parseExpr() p.exprLev-- if name0, _ := x.(*ast.Ident); name0 != nil && p.tok != token.COMMA && p.tok != token.RBRACK { // generic method m[T any] @@ -1238,10 +1242,7 @@ func (p *parser) tryIdentOrType() ast.Expr { return typ case token.LBRACK: lbrack := p.expect(token.LBRACK) - alen := p.parseArrayLen() - p.expect(token.RBRACK) - elt := p.parseType() - return &ast.ArrayType{Lbrack: lbrack, Len: alen, Elt: elt} + return p.parseArrayType(lbrack, nil) case token.STRUCT: return p.parseStructType() case token.MUL: @@ -1526,7 +1527,7 @@ func (p *parser) parseValue() ast.Expr { return p.parseLiteralValue(nil) } - x := p.checkExpr(p.parseExpr(nil)) + x := p.checkExpr(p.parseExpr()) return x } @@ -1802,18 +1803,18 @@ func (p *parser) parseBinaryExpr(x ast.Expr, prec1 int) ast.Expr { // The result may be a type or even a raw type ([...]int). Callers must // check the result (using checkExpr or checkExprOrType), depending on // context. -func (p *parser) parseExpr(lhs ast.Expr) ast.Expr { +func (p *parser) parseExpr() ast.Expr { if p.trace { defer un(trace(p, "Expression")) } - return p.parseBinaryExpr(lhs, token.LowestPrec+1) + return p.parseBinaryExpr(nil, token.LowestPrec+1) } func (p *parser) parseRhs() ast.Expr { old := p.inRhs p.inRhs = true - x := p.checkExpr(p.parseExpr(nil)) + x := p.checkExpr(p.parseExpr()) p.inRhs = old return x } @@ -1821,7 +1822,7 @@ func (p *parser) parseRhs() ast.Expr { func (p *parser) parseRhsOrType() ast.Expr { old := p.inRhs p.inRhs = true - x := p.checkExprOrType(p.parseExpr(nil)) + x := p.checkExprOrType(p.parseExpr()) p.inRhs = old return x } @@ -2554,49 +2555,42 @@ func (p *parser) parseTypeSpec(doc *ast.CommentGroup, _ token.Pos, _ token.Token ident := p.parseIdent() spec := &ast.TypeSpec{Doc: doc, Name: ident} - switch p.tok { - case token.LBRACK: + if p.tok == token.LBRACK && p.allowGenerics() { lbrack := p.pos p.next() if p.tok == token.IDENT { // array type or generic type: [name0... name0 := p.parseIdent() - if p.allowGenerics() && p.tok == token.LBRACK { - // Index or slice expressions are not valid array lengths, so we can - // parse as though we are in a generic type with array or slice - // constraint: [T [... - p.parseGenericType(spec, lbrack, name0) - break - } else { - + // Index or slice expressions are never constant and thus invalid + // array length expressions. Thus, if we see a "[" following name + // we can safely assume that "[" name starts a type parameter list. + var x ast.Expr // x != nil means x is the array length expression + if p.tok != token.LBRACK { // We may still have either an array type or generic type -- check if // name0 is the entire expr. p.exprLev++ lhs := p.parsePrimaryExpr(name0) - x := p.parseExpr(lhs) + x = p.parseBinaryExpr(lhs, token.LowestPrec+1) p.exprLev-- - - if name1, _ := x.(*ast.Ident); p.allowGenerics() && name1 != nil && p.tok != token.RBRACK { - // generic type [T any]; - p.parseGenericType(spec, lbrack, name1) - } else { - // array type - // TODO(rfindley) should resolve all identifiers in x. - p.expect(token.RBRACK) - elt := p.parseType() - spec.Type = &ast.ArrayType{Lbrack: lbrack, Len: x, Elt: elt} + if x == name0 && p.tok != token.RBRACK { + x = nil } } + + if x == nil { + // generic type [T any]; + p.parseGenericType(spec, lbrack, name0) + } else { + // array type + // TODO(rfindley) should resolve all identifiers in x. + spec.Type = p.parseArrayType(lbrack, x) + } } else { // array type - alen := p.parseArrayLen() - p.expect(token.RBRACK) - elt := p.parseType() - spec.Type = &ast.ArrayType{Lbrack: lbrack, Len: alen, Elt: elt} + spec.Type = p.parseArrayType(lbrack, nil) } - - default: + } else { // no type parameters if p.tok == token.ASSIGN { // type alias From 3fa9ee49a077a0bcb7419110da02ca54a019f2cc Mon Sep 17 00:00:00 2001 From: Alexander Melentyev Date: Sun, 31 Oct 2021 17:50:22 +0000 Subject: [PATCH 264/406] bytes: remove redundant type conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Icafb2d9fd11b23d3acaf9df07e7f90d8bcd829fa GitHub-Last-Rev: 2b766460554860510f3fec03a4b9fe2e65fad268 GitHub-Pull-Request: golang/go#49243 Reviewed-on: https://go-review.googlesource.com/c/go/+/360096 Reviewed-by: Brad Fitzpatrick Trust: Brad Fitzpatrick Trust: Martin Möhrmann --- src/bytes/bytes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go index 926f65cc8f..529d95a888 100644 --- a/src/bytes/bytes.go +++ b/src/bytes/bytes.go @@ -699,7 +699,7 @@ func ToValidUTF8(s, replacement []byte) []byte { if c < utf8.RuneSelf { i++ invalid = false - b = append(b, byte(c)) + b = append(b, c) continue } _, wid := utf8.DecodeRune(s[i:]) From fd09e88722e0af150bf8960e95e8da500ad91001 Mon Sep 17 00:00:00 2001 From: Alexander Melentyev Date: Sun, 31 Oct 2021 17:50:38 +0000 Subject: [PATCH 265/406] testing: remove redundant type conversion Change-Id: Ib6415bb09af02e9ebc0099f50bf0fd7b572f2516 GitHub-Last-Rev: ebaa849d66efa45bd8ca50a8306652d823a41678 GitHub-Pull-Request: golang/go#49244 Reviewed-on: https://go-review.googlesource.com/c/go/+/360214 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Emmanuel Odeke --- src/testing/benchmark.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go index 1ce637e137..d8ec217f66 100644 --- a/src/testing/benchmark.go +++ b/src/testing/benchmark.go @@ -45,7 +45,7 @@ func (f *durationOrCountFlag) String() string { if f.n > 0 { return fmt.Sprintf("%dx", f.n) } - return time.Duration(f.d).String() + return f.d.String() } func (f *durationOrCountFlag) Set(s string) error { From 89c527007f75884a78ffede5d493ec021e7dfcdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=B6hrmann?= Date: Sun, 31 Oct 2021 17:58:07 +0100 Subject: [PATCH 266/406] reflect: avoid stack copies of hiter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use a pointer reciever to avoid copying the hiter struct when checking if it is intialized. Found through profiling that showed reflect map iteration spending a good amount of time in duffcopy. This change will also help other MapIter methods checking hiter struct initialization like Value() and Key(). name old time/op new time/op delta MapIterNext-12 97.9ns ± 4% 83.8ns ± 2% -14.37% (p=0.000 n=10+10) Change-Id: I73ab964fa28061ee7e6d5c663a85048bd2e0274e Reviewed-on: https://go-review.googlesource.com/c/go/+/360254 Reviewed-by: Josh Bleecher Snyder Trust: Josh Bleecher Snyder Trust: Martin Möhrmann --- src/reflect/all_test.go | 10 ++++++++++ src/reflect/value.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 725be28bf0..acc09962a0 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -7568,6 +7568,16 @@ func TestMapIterNext(t *testing.T) { } } +func BenchmarkMapIterNext(b *testing.B) { + m := ValueOf(map[string]int{"a": 0, "b": 1, "c": 2, "d": 3}) + it := m.MapRange() + for i := 0; i < b.N; i++ { + for it.Next() { + } + it.Reset(m) + } +} + func TestMapIterDelete0(t *testing.T) { // Delete all elements before first iteration. m := map[string]int{"one": 1, "two": 2, "three": 3} diff --git a/src/reflect/value.go b/src/reflect/value.go index 90edf8e31d..ecf9dd7bc8 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -1665,7 +1665,7 @@ type hiter struct { checkBucket uintptr } -func (h hiter) initialized() bool { +func (h *hiter) initialized() bool { return h.t != nil } From fde4cc2a3189e2c964a0ce49de3cbe79ebedf985 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Tue, 5 Oct 2021 10:35:31 -0400 Subject: [PATCH 267/406] testing: reduce memory used by subtest names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is heavily based on CL 341336 by Joe Tsai and CL 351452 by Jay Conrod. T.Run and T.Name use a map[string]int64 to hold the next suffix to use when duplicate names are passed to T.Run. This map necessarily retains one entry per unique name. However, it's a waste of memory to retain one entry per duplicate name: when we encounter the Nth duplicate, we know that names 00 through N-1 have been used just by looking at N. We do still need to store (and check for collisions againsts) explicit names provided by the caller. For example, if the user passes in "a", then "a#01", then "a" again, we cannot deduplicate the second "a" to "a#01" — we need to instead skip ahead to "a#02". We can do so by checking the count of "a", then generating a proposed deduplicated name, then double-checking that proposed name against only the explicit names so far. This somewhat reduces memory usage for tests that spawn large numbers of duplicate subtests, but doesn't solve the problem of memory growth for fuzzing — we still have to track all of the explicit, user-provided subtest names, and in a long-running fuzz test that set alone may be unbounded. This fixes memory growth for the example described in https://golang.org/issue/44517#issuecomment-897104060, but not the one in https://golang.org/issue/44517#issuecomment-933825661. For #44517 Change-Id: Ia159ecfcf44561ba67508d3af6377c27856df31d Reviewed-on: https://go-review.googlesource.com/c/go/+/354749 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Reviewed-by: Emmanuel Odeke Reviewed-by: Jay Conrod --- src/testing/match.go | 82 ++++++++++++++++++++++++------- src/testing/match_test.go | 101 +++++++++++++++++++++++++------------- 2 files changed, 133 insertions(+), 50 deletions(-) diff --git a/src/testing/match.go b/src/testing/match.go index c6ff429fe4..d530f70c26 100644 --- a/src/testing/match.go +++ b/src/testing/match.go @@ -17,8 +17,13 @@ type matcher struct { filter filterMatch matchFunc func(pat, str string) (bool, error) - mu sync.Mutex - subNames map[string]int64 + mu sync.Mutex + + // subNames is used to deduplicate subtest names. + // Each key is the subtest name joined to the deduplicated name of the parent test. + // Each value is the count of the number of occurrences of the given subtest name + // already seen. + subNames map[string]int32 } type filterMatch interface { @@ -54,7 +59,7 @@ func newMatcher(matchString func(pat, str string) (bool, error), patterns, name return &matcher{ filter: impl, matchFunc: matchString, - subNames: map[string]int64{}, + subNames: map[string]int32{}, } } @@ -189,24 +194,67 @@ func splitRegexp(s string) filterMatch { // unique creates a unique name for the given parent and subname by affixing it // with one or more counts, if necessary. func (m *matcher) unique(parent, subname string) string { - name := fmt.Sprintf("%s/%s", parent, subname) - empty := subname == "" - for { - next, exists := m.subNames[name] - if !empty && !exists { - m.subNames[name] = 1 // next count is 1 - return name - } - // Name was already used. We increment with the count and append a - // string with the count. - m.subNames[name] = next + 1 + base := parent + "/" + subname - // Add a count to guarantee uniqueness. - name = fmt.Sprintf("%s#%02d", name, next) - empty = false + for { + n := m.subNames[base] + if n < 0 { + panic("subtest count overflow") + } + m.subNames[base] = n + 1 + + if n == 0 && subname != "" { + prefix, nn := parseSubtestNumber(base) + if len(prefix) < len(base) && nn < m.subNames[prefix] { + // This test is explicitly named like "parent/subname#NN", + // and #NN was already used for the NNth occurrence of "parent/subname". + // Loop to add a disambiguating suffix. + continue + } + return base + } + + name := fmt.Sprintf("%s#%02d", base, n) + if m.subNames[name] != 0 { + // This is the nth occurrence of base, but the name "parent/subname#NN" + // collides with the first occurrence of a subtest *explicitly* named + // "parent/subname#NN". Try the next number. + continue + } + + return name } } +// parseSubtestNumber splits a subtest name into a "#%02d"-formatted int32 +// suffix (if present), and a prefix preceding that suffix (always). +func parseSubtestNumber(s string) (prefix string, nn int32) { + i := strings.LastIndex(s, "#") + if i < 0 { + return s, 0 + } + + prefix, suffix := s[:i], s[i+1:] + if len(suffix) < 2 || (len(suffix) > 2 && suffix[0] == '0') { + // Even if suffix is numeric, it is not a possible output of a "%02" format + // string: it has either too few digits or too many leading zeroes. + return s, 0 + } + if suffix == "00" { + if !strings.HasSuffix(prefix, "/") { + // We only use "#00" as a suffix for subtests named with the empty + // string — it isn't a valid suffix if the subtest name is non-empty. + return s, 0 + } + } + + n, err := strconv.ParseInt(suffix, 10, 32) + if err != nil || n < 0 { + return s, 0 + } + return prefix, int32(n) +} + // rewrite rewrites a subname to having only printable characters and no white // space. func rewrite(s string) string { diff --git a/src/testing/match_test.go b/src/testing/match_test.go index 9ceadbb31d..206ac0b651 100644 --- a/src/testing/match_test.go +++ b/src/testing/match_test.go @@ -149,49 +149,84 @@ func TestMatcher(t *T) { } } +var namingTestCases = []struct{ name, want string }{ + // Uniqueness + {"", "x/#00"}, + {"", "x/#01"}, + {"#0", "x/#0"}, // Doesn't conflict with #00 because the number of digits differs. + {"#00", "x/#00#01"}, // Conflicts with implicit #00 (used above), so add a suffix. + {"#", "x/#"}, + {"#", "x/##01"}, + + {"t", "x/t"}, + {"t", "x/t#01"}, + {"t", "x/t#02"}, + {"t#00", "x/t#00"}, // Explicit "#00" doesn't conflict with the unsuffixed first subtest. + + {"a#01", "x/a#01"}, // user has subtest with this name. + {"a", "x/a"}, // doesn't conflict with this name. + {"a", "x/a#02"}, // This string is claimed now, so resume + {"a", "x/a#03"}, // with counting. + {"a#02", "x/a#02#01"}, // We already used a#02 once, so add a suffix. + + {"b#00", "x/b#00"}, + {"b", "x/b"}, // Implicit 0 doesn't conflict with explicit "#00". + {"b", "x/b#01"}, + {"b#9223372036854775807", "x/b#9223372036854775807"}, // MaxInt64 + {"b", "x/b#02"}, + {"b", "x/b#03"}, + + // Sanitizing + {"A:1 B:2", "x/A:1_B:2"}, + {"s\t\r\u00a0", "x/s___"}, + {"\x01", `x/\x01`}, + {"\U0010ffff", `x/\U0010ffff`}, +} + func TestNaming(t *T) { m := newMatcher(regexp.MatchString, "", "") - parent := &common{name: "x", level: 1} // top-level test. - // Rig the matcher with some preloaded values. - m.subNames["x/b"] = 1000 - - testCases := []struct { - name, want string - }{ - // Uniqueness - {"", "x/#00"}, - {"", "x/#01"}, - - {"t", "x/t"}, - {"t", "x/t#01"}, - {"t", "x/t#02"}, - - {"a#01", "x/a#01"}, // user has subtest with this name. - {"a", "x/a"}, // doesn't conflict with this name. - {"a", "x/a#01#01"}, // conflict, add disambiguating string. - {"a", "x/a#02"}, // This string is claimed now, so resume - {"a", "x/a#03"}, // with counting. - {"a#02", "x/a#02#01"}, - - {"b", "x/b#1000"}, // rigged, see above - {"b", "x/b#1001"}, - - // // Sanitizing - {"A:1 B:2", "x/A:1_B:2"}, - {"s\t\r\u00a0", "x/s___"}, - {"\x01", `x/\x01`}, - {"\U0010ffff", `x/\U0010ffff`}, - } - - for i, tc := range testCases { + for i, tc := range namingTestCases { if got, _, _ := m.fullName(parent, tc.name); got != tc.want { t.Errorf("%d:%s: got %q; want %q", i, tc.name, got, tc.want) } } } +func FuzzNaming(f *F) { + for _, tc := range namingTestCases { + f.Add(tc.name) + } + parent := &common{name: "x", level: 1} + var m *matcher + var seen map[string]string + reset := func() { + m = newMatcher(regexp.MatchString, "", "") + seen = make(map[string]string) + } + reset() + + f.Fuzz(func(t *T, subname string) { + if len(subname) > 10 { + // Long names attract the OOM killer. + t.Skip() + } + name := m.unique(parent.name, subname) + if !strings.Contains(name, "/"+subname) { + t.Errorf("name %q does not contain subname %q", name, subname) + } + if prev, ok := seen[name]; ok { + t.Errorf("name %q generated by both %q and %q", name, prev, subname) + } + if len(seen) > 1e6 { + // Free up memory. + reset() + } + seen[name] = subname + }) +} + // GoString returns a string that is more readable than the default, which makes // it easier to read test errors. func (m alternationMatch) GoString() string { From 732db407d30e9bd49d0907fd820207e6d646df9c Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Wed, 20 Oct 2021 13:40:54 -0500 Subject: [PATCH 268/406] cmd/link: make ppc64le __glink_PLTresolve position-independent This code is only generated when linking cgo internally with fixed position code. This feature of the internal linker is only supported on ppc64le/linux targets. This moves ppc64le/linux a little closer to supporting PIE when internal linking. This is more similar to the implementation suggested in the power architecture elfv2 supplement, and works with both PIE and static code. Change-Id: I0b64e1c22b9e07b5151378d2ab19ee0e50405fc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/357332 Run-TryBot: Paul Murphy TryBot-Result: Go Bot Reviewed-by: Lynn Boger Reviewed-by: Cherry Mui --- src/cmd/link/internal/ppc64/asm.go | 41 ++++++++++++++++++------------ 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/cmd/link/internal/ppc64/asm.go b/src/cmd/link/internal/ppc64/asm.go index 9507010603..62b319d196 100644 --- a/src/cmd/link/internal/ppc64/asm.go +++ b/src/cmd/link/internal/ppc64/asm.go @@ -1067,35 +1067,31 @@ func ensureglinkresolver(ctxt *ld.Link, ldr *loader.Loader) *loader.SymbolBuilde return glink } - // This is essentially the resolver from the ppc64 ELF ABI. + // This is essentially the resolver from the ppc64 ELFv2 ABI. // At entry, r12 holds the address of the symbol resolver stub // for the target routine and the argument registers hold the // arguments for the target routine. // + // PC-rel offsets are computed once the final codesize of the + // resolver is known. + // // This stub is PIC, so first get the PC of label 1 into r11. - // Other things will be relative to this. glink.AddUint32(ctxt.Arch, 0x7c0802a6) // mflr r0 glink.AddUint32(ctxt.Arch, 0x429f0005) // bcl 20,31,1f glink.AddUint32(ctxt.Arch, 0x7d6802a6) // 1: mflr r11 - glink.AddUint32(ctxt.Arch, 0x7c0803a6) // mtlf r0 + glink.AddUint32(ctxt.Arch, 0x7c0803a6) // mtlr r0 - // Compute the .plt array index from the entry point address. - // Because this is PIC, everything is relative to label 1b (in - // r11): - // r0 = ((r12 - r11) - (res_0 - r11)) / 4 = (r12 - res_0) / 4 - glink.AddUint32(ctxt.Arch, 0x3800ffd0) // li r0,-(res_0-1b)=-48 + // Compute the .plt array index from the entry point address + // into r0. This is computed relative to label 1 above. + glink.AddUint32(ctxt.Arch, 0x38000000) // li r0,-(res_0-1b) glink.AddUint32(ctxt.Arch, 0x7c006214) // add r0,r0,r12 glink.AddUint32(ctxt.Arch, 0x7c0b0050) // sub r0,r0,r11 glink.AddUint32(ctxt.Arch, 0x7800f082) // srdi r0,r0,2 - // r11 = address of the first byte of the PLT - r, _ := glink.AddRel(objabi.R_ADDRPOWER) - r.SetSym(ctxt.PLT) - r.SetSiz(8) - r.SetOff(int32(glink.Size())) - r.SetAdd(0) - glink.AddUint32(ctxt.Arch, 0x3d600000) // addis r11,0,.plt@ha - glink.AddUint32(ctxt.Arch, 0x396b0000) // addi r11,r11,.plt@l + // Load the PC-rel offset of ".plt - 1b", and add it to 1b. + // This is stored after this stub and before the resolvers. + glink.AddUint32(ctxt.Arch, 0xe98b0000) // ld r12,res_0-1b-8(r11) + glink.AddUint32(ctxt.Arch, 0x7d6b6214) // add r11,r11,r12 // Load r12 = dynamic resolver address and r11 = DSO // identifier from the first two doublewords of the PLT. @@ -1106,6 +1102,19 @@ func ensureglinkresolver(ctxt *ld.Link, ldr *loader.Loader) *loader.SymbolBuilde glink.AddUint32(ctxt.Arch, 0x7d8903a6) // mtctr r12 glink.AddUint32(ctxt.Arch, 0x4e800420) // bctr + // Store the PC-rel offset to the PLT + r, _ := glink.AddRel(objabi.R_PCREL) + r.SetSym(ctxt.PLT) + r.SetSiz(8) + r.SetOff(int32(glink.Size())) + r.SetAdd(glink.Size()) // Adjust the offset to be relative to label 1 above. + glink.AddUint64(ctxt.Arch, 0) // The offset to the PLT. + + // Resolve PC-rel offsets above now the final size of the stub is known. + res0m1b := glink.Size() - 8 // res_0 - 1b + glink.SetUint32(ctxt.Arch, 16, 0x38000000|uint32(uint16(-res0m1b))) + glink.SetUint32(ctxt.Arch, 32, 0xe98b0000|uint32(uint16(res0m1b-8))) + // The symbol resolvers must immediately follow. // res_0: From 4056934e483c51fa046f9c2d1ee35f0385b84d91 Mon Sep 17 00:00:00 2001 From: Archana R Date: Mon, 25 Oct 2021 23:57:46 -0500 Subject: [PATCH 269/406] test/codegen: updated arithmetic tests to verify on ppc64,ppc64le Updated multiple tests in test/codegen/arithmetic.go to verify on ppc64/ppc64le as well Change-Id: I79ca9f87017ea31147a4ba16f5d42ba0fcae64e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/358546 Run-TryBot: Lynn Boger TryBot-Result: Go Bot Reviewed-by: Lynn Boger Reviewed-by: Cherry Mui --- test/codegen/arithmetic.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go index 8b8c8ed64b..00841d52ae 100644 --- a/test/codegen/arithmetic.go +++ b/test/codegen/arithmetic.go @@ -86,24 +86,32 @@ func NegAddFromConstNeg(a int) int { func SubSubNegSimplify(a, b int) int { // amd64:"NEGQ" + // ppc64:"NEG" + // ppc64le:"NEG" r := (a - b) - a return r } func SubAddSimplify(a, b int) int { // amd64:-"SUBQ",-"ADDQ" + // ppc64:-"SUB",-"ADD" + // ppc64le:-"SUB",-"ADD" r := a + (b - a) return r } func SubAddNegSimplify(a, b int) int { // amd64:"NEGQ",-"ADDQ",-"SUBQ" + // ppc64:"NEG",-"ADD",-"SUB" + // ppc64le:"NEG",-"ADD",-"SUB" r := a - (b + a) return r } func AddAddSubSimplify(a, b, c int) int { // amd64:-"SUBQ" + // ppc64:-"SUB" + // ppc64le:-"SUB" r := a + (b + (c - a)) return r } @@ -159,30 +167,40 @@ func MulMemSrc(a []uint32, b []float32) { func MergeMuls1(n int) int { // amd64:"IMUL3Q\t[$]46" // 386:"IMUL3L\t[$]46" + // ppc64le:"MULLD\t[$]46" + // ppc64:"MULLD\t[$]46" return 15*n + 31*n // 46n } func MergeMuls2(n int) int { // amd64:"IMUL3Q\t[$]23","(ADDQ\t[$]29)|(LEAQ\t29)" // 386:"IMUL3L\t[$]23","ADDL\t[$]29" + // ppc64le/power9:"MADDLD",-"MULLD\t[$]23",-"ADD\t[$]29" + // ppc64le/power8:"MULLD\t[$]23","ADD\t[$]29" return 5*n + 7*(n+1) + 11*(n+2) // 23n + 29 } func MergeMuls3(a, n int) int { // amd64:"ADDQ\t[$]19",-"IMULQ\t[$]19" // 386:"ADDL\t[$]19",-"IMULL\t[$]19" + // ppc64:"ADD\t[$]19",-"MULLD\t[$]19" + // ppc64le:"ADD\t[$]19",-"MULLD\t[$]19" return a*n + 19*n // (a+19)n } func MergeMuls4(n int) int { // amd64:"IMUL3Q\t[$]14" // 386:"IMUL3L\t[$]14" + // ppc64:"MULLD\t[$]14" + // ppc64le:"MULLD\t[$]14" return 23*n - 9*n // 14n } func MergeMuls5(a, n int) int { // amd64:"ADDQ\t[$]-19",-"IMULQ\t[$]19" // 386:"ADDL\t[$]-19",-"IMULL\t[$]19" + // ppc64:"ADD\t[$]-19",-"MULLD\t[$]19" + // ppc64le:"ADD\t[$]-19",-"MULLD\t[$]19" return a*n - 19*n // (a-19)n } @@ -507,6 +525,8 @@ func MULA(a, b, c uint32) (uint32, uint32, uint32) { r1 := c*79 + a // arm:`ADD`,-`MULA`,-`MUL\s` // arm64:`ADD`,-`MADD`,-`MULW` + // ppc64:`ADD`,-`MULLD` + // ppc64le:`ADD`,-`MULLD` r2 := b*64 + c return r0, r1, r2 } @@ -522,6 +542,8 @@ func MULS(a, b, c uint32) (uint32, uint32, uint32) { r1 := a - c*79 // arm/7:`SUB`,-`MULS`,-`MUL\s` // arm64:`SUB`,-`MSUBW`,-`MULW` + // ppc64:`SUB`,-`MULLD` + // ppc64le:`SUB`,-`MULLD` r2 := c - b*64 return r0, r1, r2 } @@ -550,12 +572,20 @@ func divInt(v int64) int64 { // "(z + C) -x -> C + (z - x)" can optimize the following cases. func constantFold1(i0, j0, i1, j1, i2, j2, i3, j3 int) (int, int, int, int) { // arm64:"SUB","ADD\t[$]2" + // ppc64:"SUB","ADD\t[$]2" + // ppc64le:"SUB","ADD\t[$]2" r0 := (i0 + 3) - (j0 + 1) // arm64:"SUB","SUB\t[$]4" + // ppc64:"SUB","ADD\t[$]-4" + // ppc64le:"SUB","ADD\t[$]-4" r1 := (i1 - 3) - (j1 + 1) // arm64:"SUB","ADD\t[$]4" + // ppc64:"SUB","ADD\t[$]4" + // ppc64le:"SUB","ADD\t[$]4" r2 := (i2 + 3) - (j2 - 1) // arm64:"SUB","SUB\t[$]2" + // ppc64:"SUB","ADD\t[$]-2" + // ppc64le:"SUB","ADD\t[$]-2" r3 := (i3 - 3) - (j3 - 1) return r0, r1, r2, r3 } @@ -564,14 +594,20 @@ func constantFold1(i0, j0, i1, j1, i2, j2, i3, j3 int) (int, int, int, int) { // "(C - z) - x -> C - (z + x)" can optimize the following cases. func constantFold2(i0, j0, i1, j1 int) (int, int) { // arm64:"ADD","MOVD\t[$]2","SUB" + // ppc64le: `SUBC\tR[0-9]+,\s[$]2,\sR` + // ppc64: `SUBC\tR[0-9]+,\s[$]2,\sR` r0 := (3 - i0) - (j0 + 1) // arm64:"ADD","MOVD\t[$]4","SUB" + // ppc64le: `SUBC\tR[0-9]+,\s[$]4,\sR` + // ppc64: `SUBC\tR[0-9]+,\s[$]4,\sR` r1 := (3 - i1) - (j1 - 1) return r0, r1 } func constantFold3(i, j int) int { // arm64: "MOVD\t[$]30","MUL",-"ADD",-"LSL" + // ppc64:"MULLD\t[$]30","MULLD" + // ppc64le:"MULLD\t[$]30","MULLD" r := (5 * i) * (6 * j) return r } From 82f902ae8e2b7f7eff0cdb087e47e939cc296a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=B6hrmann?= Date: Mon, 1 Nov 2021 06:42:01 +0100 Subject: [PATCH 270/406] strings: align Clone output with string([]byte("")) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a comment how strings of length 0 are treated and that they always will result in the return of a string equal to the constant string "". The previous implementation would return a string header that uses runtime.zerobase as the backing array pointer while the string constant "" has 0 as pointer value. Using 0 has the backing array pointer is also the behaviour of string([]byte(input)) which makes the new behaviour a better drop in replacement. Change-Id: Ic5460e9494b6708edbdfa4361e878d50db54ba10 Reviewed-on: https://go-review.googlesource.com/c/go/+/360255 Trust: Martin Möhrmann Run-TryBot: Martin Möhrmann TryBot-Result: Go Bot Reviewed-by: Russ Cox --- src/strings/clone.go | 5 +++++ src/strings/clone_test.go | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/strings/clone.go b/src/strings/clone.go index 6097c6cc88..edd1497d9e 100644 --- a/src/strings/clone.go +++ b/src/strings/clone.go @@ -16,7 +16,12 @@ import ( // overuse of Clone can make programs use more memory. // Clone should typically be used only rarely, and only when // profiling indicates that it is needed. +// For strings of length zero the string "" will be returned +// and no allocation is made. func Clone(s string) string { + if len(s) == 0 { + return "" + } b := make([]byte, len(s)) copy(b, s) return *(*string)(unsafe.Pointer(&b)) diff --git a/src/strings/clone_test.go b/src/strings/clone_test.go index 5396771047..a9ba8add23 100644 --- a/src/strings/clone_test.go +++ b/src/strings/clone_test.go @@ -11,9 +11,13 @@ import ( "unsafe" ) +var emptyString string + func TestClone(t *testing.T) { var cloneTests = []string{ "", + strings.Clone(""), + strings.Repeat("a", 42)[:0], "short", strings.Repeat("a", 42), } @@ -25,9 +29,14 @@ func TestClone(t *testing.T) { inputHeader := (*reflect.StringHeader)(unsafe.Pointer(&input)) cloneHeader := (*reflect.StringHeader)(unsafe.Pointer(&clone)) - if inputHeader.Data == cloneHeader.Data { + if len(input) != 0 && cloneHeader.Data == inputHeader.Data { t.Errorf("Clone(%q) return value should not reference inputs backing memory.", input) } + + emptyHeader := (*reflect.StringHeader)(unsafe.Pointer(&emptyString)) + if len(input) == 0 && cloneHeader.Data != emptyHeader.Data { + t.Errorf("Clone(%#v) return value should be equal to empty string.", inputHeader) + } } } From d2b512160e4fc9dd69947ad9566c2dab1a135694 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Sun, 31 Oct 2021 10:37:15 -0700 Subject: [PATCH 271/406] cmd/compile/internal/types2: differently named types are not assignable When checking assignability, a value of a named type (incl. a type parameter) can never be assigned to a variable of a differently named type. Specifically, if the types are two differently named type parameters, then values of one are never assignable to variables of the other. This CL clarifies the assignabiliy rules and simplifies the implementation. Fixes #49242. Change-Id: Id72a2c9bed5cdb726855e7a707137db1009e7953 Reviewed-on: https://go-review.googlesource.com/c/go/+/360274 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/operand.go | 68 +++++++++---------- .../types2/testdata/fixedbugs/issue49242.go2 | 27 ++++++++ .../types2/testdata/spec/assignability.go2 | 46 ++++++++++--- 3 files changed, 95 insertions(+), 46 deletions(-) create mode 100644 src/cmd/compile/internal/types2/testdata/fixedbugs/issue49242.go2 diff --git a/src/cmd/compile/internal/types2/operand.go b/src/cmd/compile/internal/types2/operand.go index e4db0554f3..2f85802701 100644 --- a/src/cmd/compile/internal/types2/operand.go +++ b/src/cmd/compile/internal/types2/operand.go @@ -317,19 +317,11 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er } } - // common case: if we don't have type parameters, we're done + // optimization: if we don't have type parameters, we're done if Vp == nil && Tp == nil { return false, _IncompatibleAssign } - // determine type parameter operands with specific type terms - if Vp != nil && !Vp.hasTerms() { - Vp = nil - } - if Tp != nil && !Tp.hasTerms() { - Tp = nil - } - errorf := func(format string, args ...interface{}) { if check != nil && reason != nil { msg := check.sprintf(format, args...) @@ -340,25 +332,36 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er } } - ok := false - code := _IncompatibleAssign - switch { - case Vp != nil && Tp != nil: - x := *x // don't clobber outer x - ok = Vp.is(func(V *term) bool { - x.typ = V.typ - return Tp.is(func(T *term) bool { - ok, code = x.assignableTo(check, T.typ, reason) - if !ok { - errorf("cannot assign %s (in %s) to %s (in %s)", V.typ, Vp, T.typ, Tp) - return false - } - return true - }) + // x's type V is not a named type and T is a type parameter, and + // x is assignable to each specific type in T's type set. + if !hasName(V) && Tp != nil { + ok := false + code := _IncompatibleAssign + Tp.is(func(T *term) bool { + if T == nil { + return false // no specific types + } + ok, code = x.assignableTo(check, T.typ, reason) + if !ok { + errorf("cannot assign %s to %s (in %s)", x.typ, T.typ, Tp) + return false + } + return true }) - case Vp != nil: + return ok, code + } + + // x's type V is a type parameter and T is not a named type, + // and values x' of each specific type in V's type set are + // assignable to T. + if Vp != nil && !hasName(T) { x := *x // don't clobber outer x - ok = Vp.is(func(V *term) bool { + ok := false + code := _IncompatibleAssign + Vp.is(func(V *term) bool { + if V == nil { + return false // no specific types + } x.typ = V.typ ok, code = x.assignableTo(check, T, reason) if !ok { @@ -367,19 +370,10 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er } return true }) - case Tp != nil: - x := *x // don't clobber outer x - ok = Tp.is(func(T *term) bool { - ok, code = x.assignableTo(check, T.typ, reason) - if !ok { - errorf("cannot assign %s to %s (in %s)", x.typ, T.typ, Tp) - return false - } - return true - }) + return ok, code } - return ok, code + return false, _IncompatibleAssign } // kind2tok translates syntax.LitKinds into token.Tokens. diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49242.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49242.go2 new file mode 100644 index 0000000000..524a0cbae3 --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49242.go2 @@ -0,0 +1,27 @@ +// Copyright 2021 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 p + +func _[P int](x P) int { + return x // ERROR cannot use x .* as int value in return statement +} + +func _[P int]() int { + return P /* ERROR cannot use P\(1\) .* as int value in return statement */ (1) +} + +func _[P int](x int) P { + return x // ERROR cannot use x .* as P value in return statement +} + +func _[P, Q any](x P) Q { + return x // ERROR cannot use x .* as Q value in return statement +} + +// test case from issue +func F[G interface{ uint }]() int { + f := func(uint) int { return 0 } + return f(G /* ERROR cannot use G\(1\) .* as uint value in argument to f */ (1)) +} diff --git a/src/cmd/compile/internal/types2/testdata/spec/assignability.go2 b/src/cmd/compile/internal/types2/testdata/spec/assignability.go2 index ab8f9c08b2..fb28358bbb 100644 --- a/src/cmd/compile/internal/types2/testdata/spec/assignability.go2 +++ b/src/cmd/compile/internal/types2/testdata/spec/assignability.go2 @@ -109,20 +109,48 @@ func _[ ) var ( - _ _CC = C - _ _SC = C - _ _RC = C + _ _CC = C // ERROR cannot use C .* as _CC value + _ _SC = C // ERROR cannot use C .* as _SC value + _ _RC = C // ERROR cannot use C .* as _RC value - _ CC = _CC(nil) - _ SC = _CC(nil) - _ RC = _CC(nil) + _ CC = _CC /* ERROR cannot use _CC\(nil\) .* as CC value */ (nil) + _ SC = _CC /* ERROR cannot use _CC\(nil\) .* as SC value */ (nil) + _ RC = _CC /* ERROR cannot use _CC\(nil\) .* as RC value */ (nil) - _ CC = C - _ SC = C // ERROR cannot use C .* as SC value .* cannot assign Chan to SendChan - _ RC = C // ERROR cannot use C .* as RC value .* cannot assign Chan to RecvChan + _ CC = C // ERROR cannot use C .* as CC value + _ SC = C // ERROR cannot use C .* as SC value + _ RC = C // ERROR cannot use C .* as RC value ) } +// "x's type V is not a named type and T is a type parameter, and x is assignable to each specific type in T's type set." +func _[ + TP0 any, + TP1 ~_Chan, + TP2 ~chan int | ~chan byte, +]() { + var ( + _ TP0 = c // ERROR cannot use c .* as TP0 value + _ TP0 = C // ERROR cannot use C .* as TP0 value + _ TP1 = c + _ TP1 = C // ERROR cannot use C .* as TP1 value + _ TP2 = c // ERROR .* cannot assign chan int to chan byte + ) +} + +// "x's type V is a type parameter and T is not a named type, and values x' of each specific type in V's type set are assignable to T." +func _[ + TP0 Interface, + TP1 ~_Chan, + TP2 ~chan int | ~chan byte, +](X0 TP0, X1 TP1, X2 TP2) { + i = X0 + I = X0 + c = X1 + C = X1 // ERROR cannot use X1 .* as Chan value + c = X2 // ERROR .* cannot assign chan byte \(in TP2\) to chan int +} + // "x is the predeclared identifier nil and T is a pointer, function, slice, map, channel, or interface type" func _[TP Interface](X TP) { b = nil // ERROR cannot use untyped nil From e2e910ef30f5b54018131cd24b198ced6e8215f8 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Sun, 31 Oct 2021 12:08:32 -0700 Subject: [PATCH 272/406] cmd/compile/internal/types2: remove subscripts from type parameter names This is a port of CL 357814 from go/types to types2 with minor adjustments due to small differences in error handling code. Change-Id: I72ecc4532e8349f569cabb38006f3d8ff517bf30 Reviewed-on: https://go-review.googlesource.com/c/go/+/360276 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/api_test.go | 14 +++++----- .../compile/internal/types2/builtins_test.go | 6 ++--- src/cmd/compile/internal/types2/errors.go | 12 ++++----- .../compile/internal/types2/instantiate.go | 2 +- src/cmd/compile/internal/types2/typestring.go | 26 +++++++++++++------ 5 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/cmd/compile/internal/types2/api_test.go b/src/cmd/compile/internal/types2/api_test.go index 26652f3e74..5e111d6d87 100644 --- a/src/cmd/compile/internal/types2/api_test.go +++ b/src/cmd/compile/internal/types2/api_test.go @@ -326,25 +326,25 @@ func TestTypesInfo(t *testing.T) { {brokenPkg + `x5; func _() { var x map[string][...]int; x = map[string][...]int{"": {1,2,3}} }`, `x`, `map[string]invalid type`}, // parameterized functions - {genericPkg + `p0; func f[T any](T) {}; var _ = f[int]`, `f`, `func[generic_p0.T₁ interface{}](generic_p0.T₁)`}, + {genericPkg + `p0; func f[T any](T) {}; var _ = f[int]`, `f`, `func[generic_p0.T interface{}](generic_p0.T)`}, {genericPkg + `p1; func f[T any](T) {}; var _ = f[int]`, `f[int]`, `func(int)`}, {genericPkg + `p2; func f[T any](T) {}; func _() { f(42) }`, `f`, `func(int)`}, {genericPkg + `p3; func f[T any](T) {}; func _() { f[int](42) }`, `f[int]`, `func(int)`}, - {genericPkg + `p4; func f[T any](T) {}; func _() { f[int](42) }`, `f`, `func[generic_p4.T₁ interface{}](generic_p4.T₁)`}, + {genericPkg + `p4; func f[T any](T) {}; func _() { f[int](42) }`, `f`, `func[generic_p4.T interface{}](generic_p4.T)`}, {genericPkg + `p5; func f[T any](T) {}; func _() { f(42) }`, `f(42)`, `()`}, // type parameters {genericPkg + `t0; type t[] int; var _ t`, `t`, `generic_t0.t`}, // t[] is a syntax error that is ignored in this test in favor of t - {genericPkg + `t1; type t[P any] int; var _ t[int]`, `t`, `generic_t1.t[generic_t1.P₁ interface{}]`}, - {genericPkg + `t2; type t[P interface{}] int; var _ t[int]`, `t`, `generic_t2.t[generic_t2.P₁ interface{}]`}, - {genericPkg + `t3; type t[P, Q interface{}] int; var _ t[int, int]`, `t`, `generic_t3.t[generic_t3.P₁, generic_t3.Q₂ interface{}]`}, - {brokenPkg + `t4; type t[P, Q interface{ m() }] int; var _ t[int, int]`, `t`, `broken_t4.t[broken_t4.P₁, broken_t4.Q₂ interface{m()}]`}, + {genericPkg + `t1; type t[P any] int; var _ t[int]`, `t`, `generic_t1.t[generic_t1.P interface{}]`}, + {genericPkg + `t2; type t[P interface{}] int; var _ t[int]`, `t`, `generic_t2.t[generic_t2.P interface{}]`}, + {genericPkg + `t3; type t[P, Q interface{}] int; var _ t[int, int]`, `t`, `generic_t3.t[generic_t3.P, generic_t3.Q interface{}]`}, + {brokenPkg + `t4; type t[P, Q interface{ m() }] int; var _ t[int, int]`, `t`, `broken_t4.t[broken_t4.P, broken_t4.Q interface{m()}]`}, // instantiated types must be sanitized {genericPkg + `g0; type t[P any] int; var x struct{ f t[int] }; var _ = x.f`, `x.f`, `generic_g0.t[int]`}, // issue 45096 - {genericPkg + `issue45096; func _[T interface{ ~int8 | ~int16 | ~int32 }](x T) { _ = x < 0 }`, `0`, `generic_issue45096.T₁`}, + {genericPkg + `issue45096; func _[T interface{ ~int8 | ~int16 | ~int32 }](x T) { _ = x < 0 }`, `0`, `generic_issue45096.T`}, // issue 47895 {`package p; import "unsafe"; type S struct { f int }; var s S; var _ = unsafe.Offsetof(s.f)`, `s.f`, `int`}, diff --git a/src/cmd/compile/internal/types2/builtins_test.go b/src/cmd/compile/internal/types2/builtins_test.go index 52dbba1cb9..dd71715a27 100644 --- a/src/cmd/compile/internal/types2/builtins_test.go +++ b/src/cmd/compile/internal/types2/builtins_test.go @@ -112,15 +112,15 @@ var builtinCalls = []struct { {"Alignof", `_ = unsafe.Alignof(0)`, `invalid type`}, // constant {"Alignof", `var x struct{}; _ = unsafe.Alignof(x)`, `invalid type`}, // constant - {"Alignof", `var x P; _ = unsafe.Alignof(x)`, `func(p.P₁) uintptr`}, + {"Alignof", `var x P; _ = unsafe.Alignof(x)`, `func(p.P) uintptr`}, {"Offsetof", `var x struct{f bool}; _ = unsafe.Offsetof(x.f)`, `invalid type`}, // constant {"Offsetof", `var x struct{_ int; f bool}; _ = unsafe.Offsetof((&x).f)`, `invalid type`}, // constant - {"Offsetof", `var x struct{_ int; f P}; _ = unsafe.Offsetof((&x).f)`, `func(p.P₁) uintptr`}, + {"Offsetof", `var x struct{_ int; f P}; _ = unsafe.Offsetof((&x).f)`, `func(p.P) uintptr`}, {"Sizeof", `_ = unsafe.Sizeof(0)`, `invalid type`}, // constant {"Sizeof", `var x struct{}; _ = unsafe.Sizeof(x)`, `invalid type`}, // constant - {"Sizeof", `var x P; _ = unsafe.Sizeof(x)`, `func(p.P₁) uintptr`}, + {"Sizeof", `var x P; _ = unsafe.Sizeof(x)`, `func(p.P) uintptr`}, {"Slice", `var p *int; _ = unsafe.Slice(p, 1)`, `func(*int, int) []int`}, {"Slice", `var p *byte; var n uintptr; _ = unsafe.Slice(p, n)`, `func(*byte, uintptr) []byte`}, diff --git a/src/cmd/compile/internal/types2/errors.go b/src/cmd/compile/internal/types2/errors.go index 0c8a4a90ff..b56d11a28b 100644 --- a/src/cmd/compile/internal/types2/errors.go +++ b/src/cmd/compile/internal/types2/errors.go @@ -66,7 +66,7 @@ func (err *error_) msg(qf Qualifier) string { fmt.Fprintf(&buf, "%s: ", p.pos) } } - buf.WriteString(sprintf(qf, p.format, p.args...)) + buf.WriteString(sprintf(qf, false, p.format, p.args...)) } return buf.String() } @@ -85,7 +85,7 @@ func (err *error_) errorf(at poser, format string, args ...interface{}) { err.desc = append(err.desc, errorDesc{posFor(at), format, args}) } -func sprintf(qf Qualifier, format string, args ...interface{}) string { +func sprintf(qf Qualifier, debug bool, format string, args ...interface{}) string { for i, arg := range args { switch a := arg.(type) { case nil: @@ -101,7 +101,7 @@ func sprintf(qf Qualifier, format string, args ...interface{}) string { case Object: arg = ObjectString(a, qf) case Type: - arg = TypeString(a, qf) + arg = typeString(a, qf, debug) } args[i] = arg } @@ -146,7 +146,7 @@ func (check *Checker) markImports(pkg *Package) { } func (check *Checker) sprintf(format string, args ...interface{}) string { - return sprintf(check.qualifier, format, args...) + return sprintf(check.qualifier, false, format, args...) } func (check *Checker) report(err *error_) { @@ -160,13 +160,13 @@ func (check *Checker) trace(pos syntax.Pos, format string, args ...interface{}) fmt.Printf("%s:\t%s%s\n", pos, strings.Repeat(". ", check.indent), - check.sprintf(format, args...), + sprintf(check.qualifier, true, format, args...), ) } // dump is only needed for debugging func (check *Checker) dump(format string, args ...interface{}) { - fmt.Println(check.sprintf(format, args...)) + fmt.Println(sprintf(check.qualifier, true, format, args...)) } func (check *Checker) err(at poser, msg string, soft bool) { diff --git a/src/cmd/compile/internal/types2/instantiate.go b/src/cmd/compile/internal/types2/instantiate.go index 8228ef2c31..44cf593ffb 100644 --- a/src/cmd/compile/internal/types2/instantiate.go +++ b/src/cmd/compile/internal/types2/instantiate.go @@ -155,7 +155,7 @@ func (check *Checker) satisfies(pos syntax.Pos, targ Type, tpar *TypeParam, smap qf = check.qualifier } errorf := func(format string, args ...interface{}) error { - return errors.New(sprintf(qf, format, args...)) + return errors.New(sprintf(qf, false, format, args...)) } // No type argument with non-empty type set satisfies the empty type set. diff --git a/src/cmd/compile/internal/types2/typestring.go b/src/cmd/compile/internal/types2/typestring.go index 709499792b..56bf4124fd 100644 --- a/src/cmd/compile/internal/types2/typestring.go +++ b/src/cmd/compile/internal/types2/typestring.go @@ -43,8 +43,14 @@ func RelativeTo(pkg *Package) Qualifier { // The Qualifier controls the printing of // package-level objects, and may be nil. func TypeString(typ Type, qf Qualifier) string { + return typeString(typ, qf, false) +} + +func typeString(typ Type, qf Qualifier, debug bool) string { var buf bytes.Buffer - WriteType(&buf, typ, qf) + w := newTypeWriter(&buf, qf) + w.debug = debug + w.typ(typ) return buf.String() } @@ -64,19 +70,20 @@ func WriteSignature(buf *bytes.Buffer, sig *Signature, qf Qualifier) { } type typeWriter struct { - buf *bytes.Buffer - seen map[Type]bool - qf Qualifier - ctxt *Context // if non-nil, we are type hashing + buf *bytes.Buffer + seen map[Type]bool + qf Qualifier + ctxt *Context // if non-nil, we are type hashing + debug bool // if true, write debug annotations } func newTypeWriter(buf *bytes.Buffer, qf Qualifier) *typeWriter { - return &typeWriter{buf, make(map[Type]bool), qf, nil} + return &typeWriter{buf, make(map[Type]bool), qf, nil, false} } func newTypeHasher(buf *bytes.Buffer, ctxt *Context) *typeWriter { assert(ctxt != nil) - return &typeWriter{buf, make(map[Type]bool), nil, ctxt} + return &typeWriter{buf, make(map[Type]bool), nil, ctxt, false} } func (w *typeWriter) byte(b byte) { @@ -270,7 +277,10 @@ func (w *typeWriter) typ(typ Type) { if t.obj.pkg != nil { writePackage(w.buf, t.obj.pkg, w.qf) } - w.string(t.obj.name + subscript(t.id)) + w.string(t.obj.name) + if w.debug || w.ctxt != nil { + w.string(subscript(t.id)) + } default: // For externally defined implementations of Type. From 0ae4c7ff4a6d24ab33a0deebba74609159291b8c Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Sun, 31 Oct 2021 17:27:12 -0700 Subject: [PATCH 273/406] cmd/compile/internal/types2: fix TypeName.IsAlias for type parameter names This is a port of CL 359656 from go/types to types2. For #49213. Change-Id: Ib98f9a344c1397af92e061cafd519ea374fd60bc Reviewed-on: https://go-review.googlesource.com/c/go/+/360294 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/object.go | 2 ++ src/cmd/compile/internal/types2/object_test.go | 3 +++ .../compile/internal/types2/testdata/fixedbugs/issue45985.go2 | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/types2/object.go b/src/cmd/compile/internal/types2/object.go index affeaf61f2..c7d6709c26 100644 --- a/src/cmd/compile/internal/types2/object.go +++ b/src/cmd/compile/internal/types2/object.go @@ -315,6 +315,8 @@ func (obj *TypeName) IsAlias() bool { return obj.pkg != nil || t.name != obj.name || t == universeByte || t == universeRune case *Named: return obj != t.obj + case *TypeParam: + return obj != t.obj default: return true } diff --git a/src/cmd/compile/internal/types2/object_test.go b/src/cmd/compile/internal/types2/object_test.go index a86733a5c9..ed3c123023 100644 --- a/src/cmd/compile/internal/types2/object_test.go +++ b/src/cmd/compile/internal/types2/object_test.go @@ -33,6 +33,8 @@ func TestIsAlias(t *testing.T) { pkg := NewPackage("p", "p") t1 := NewTypeName(nopos, pkg, "t1", nil) n1 := NewNamed(t1, new(Struct), nil) + t5 := NewTypeName(nopos, pkg, "t5", nil) + NewTypeParam(t5, nil) for _, test := range []struct { name *TypeName alias bool @@ -46,6 +48,7 @@ func TestIsAlias(t *testing.T) { {NewTypeName(nopos, nil, "int32", Typ[Int32]), false}, // type name refers to basic type with same name {NewTypeName(nopos, pkg, "int32", Typ[Int32]), true}, // type name is declared in user-defined package (outside Universe) {NewTypeName(nopos, nil, "rune", Typ[Rune]), true}, // type name refers to basic type rune which is an alias already + {t5, false}, // type name refers to type parameter and vice versa } { check(test.name, test.alias) } diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45985.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45985.go2 index f25b9d2b26..ee5282d6ef 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45985.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45985.go2 @@ -5,7 +5,7 @@ package issue45985 // TODO(gri): this error should be on app[int] below. -func app[S /* ERROR "type S = S does not match" */ interface{ ~[]T }, T any](s S, e T) S { +func app[S /* ERROR "type S S does not match" */ interface{ ~[]T }, T any](s S, e T) S { return append(s, e) } From 80bedb848092c993182f79a946d54776dc251549 Mon Sep 17 00:00:00 2001 From: zhouguangyuan Date: Fri, 29 Oct 2021 15:24:28 +0800 Subject: [PATCH 274/406] go/types: fix TypeName.IsAlias for type parameter names Fixes #49213 Change-Id: I2bfc151b74b0d14efbd00e5d28584f4180126c5d Reviewed-on: https://go-review.googlesource.com/c/go/+/359656 Trust: Robert Griesemer Trust: Robert Findley Run-TryBot: Robert Griesemer Reviewed-by: Robert Griesemer TryBot-Result: Go Bot --- src/go/types/object.go | 2 ++ src/go/types/object_test.go | 3 +++ src/go/types/testdata/fixedbugs/issue45985.go2 | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/go/types/object.go b/src/go/types/object.go index 18015fc967..a8bd62a04e 100644 --- a/src/go/types/object.go +++ b/src/go/types/object.go @@ -269,6 +269,8 @@ func (obj *TypeName) IsAlias() bool { return obj.pkg != nil || t.name != obj.name || t == universeByte || t == universeRune case *Named: return obj != t.obj + case *TypeParam: + return obj != t.obj default: return true } diff --git a/src/go/types/object_test.go b/src/go/types/object_test.go index 0ff8fdd6fa..c12af64df7 100644 --- a/src/go/types/object_test.go +++ b/src/go/types/object_test.go @@ -30,6 +30,8 @@ func TestIsAlias(t *testing.T) { pkg := NewPackage("p", "p") t1 := NewTypeName(0, pkg, "t1", nil) n1 := NewNamed(t1, new(Struct), nil) + t5 := NewTypeName(0, pkg, "t5", nil) + NewTypeParam(t5, nil) for _, test := range []struct { name *TypeName alias bool @@ -43,6 +45,7 @@ func TestIsAlias(t *testing.T) { {NewTypeName(0, nil, "int32", Typ[Int32]), false}, // type name refers to basic type with same name {NewTypeName(0, pkg, "int32", Typ[Int32]), true}, // type name is declared in user-defined package (outside Universe) {NewTypeName(0, nil, "rune", Typ[Rune]), true}, // type name refers to basic type rune which is an alias already + {t5, false}, // type name refers to type parameter and vice versa } { check(test.name, test.alias) } diff --git a/src/go/types/testdata/fixedbugs/issue45985.go2 b/src/go/types/testdata/fixedbugs/issue45985.go2 index 6e42dbb633..07395911cd 100644 --- a/src/go/types/testdata/fixedbugs/issue45985.go2 +++ b/src/go/types/testdata/fixedbugs/issue45985.go2 @@ -5,7 +5,7 @@ package issue45985 // TODO(rFindley): this error should be on app[int] below. -func app[S /* ERROR "type S = S does not match" */ interface{ ~[]T }, T any](s S, e T) S { +func app[S /* ERROR "type S S does not match" */ interface{ ~[]T }, T any](s S, e T) S { return append(s, e) } From 2bcf1c0373195724161a9dc287e1dbc26404e4fa Mon Sep 17 00:00:00 2001 From: Roland Shoemaker Date: Fri, 29 Oct 2021 11:21:45 -0700 Subject: [PATCH 275/406] internal/fuzz: don't add duplicate corpus entries If a identical input is already present in the corpus, don't re-add it. This may happen when the same input produces a different coverage map, causing the coordinator to think it has found a new input. This fixes a race between reading/writing cached inputs. Fixes #48721 Change-Id: I4807602f433c2b99396d25ceaa58b827796b3555 Reviewed-on: https://go-review.googlesource.com/c/go/+/359755 Trust: Roland Shoemaker Trust: Katie Hockman Run-TryBot: Roland Shoemaker Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills Reviewed-by: Katie Hockman --- src/internal/fuzz/fuzz.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/internal/fuzz/fuzz.go b/src/internal/fuzz/fuzz.go index 5008927f0e..78319a7496 100644 --- a/src/internal/fuzz/fuzz.go +++ b/src/internal/fuzz/fuzz.go @@ -316,6 +316,23 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err // Update the coordinator's coverage mask and save the value. inputSize := len(result.entry.Data) if opts.CacheDir != "" { + // It is possible that the input that was discovered is already + // present in the corpus, but the worker produced a coverage map + // that still expanded our total coverage (this may happen due to + // flakiness in the coverage counters). In order to prevent adding + // duplicate entries to the corpus (and re-writing the file on + // disk), skip it if the on disk file already exists. + // TOOD(roland): this check is limited in that it will only be + // applied if we are using the CacheDir. Another option would be + // to iterate through the corpus and check if it is already present, + // which would catch cases where we are not caching entries. + // A slightly faster approach would be to keep some kind of map of + // entry hashes, which would allow us to avoid iterating through + // all entries. + _, err = os.Stat(result.entry.Path) + if err == nil { + continue + } err := writeToCorpus(&result.entry, opts.CacheDir) if err != nil { stop(err) From b5a5b7bfb1ba25abf8cad8b9ad9451fb6e79d941 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Fri, 29 Oct 2021 22:42:50 +0000 Subject: [PATCH 276/406] runtime: disable pacer lock held assertions in tests Fixes #49234. Change-Id: I64c1eab0dce2bbe990343b43a32858a6c9f3dcda Reviewed-on: https://go-review.googlesource.com/c/go/+/359878 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/runtime/export_test.go | 1 + src/runtime/mgcpacer.go | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index 2cc89e7121..533627fa58 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -1246,6 +1246,7 @@ func NewGCController(gcPercent int) *GCController { // on a 32-bit architecture, it may get allocated unaligned // space. g := escape(new(GCController)).(*GCController) + g.gcControllerState.test = true // Mark it as a test copy. g.init(int32(gcPercent)) return g } diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 160383db43..af43e6258f 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -269,6 +269,9 @@ type gcControllerState struct { // If this is zero, no fractional workers are needed. fractionalUtilizationGoal float64 + // test indicates that this is a test-only copy of gcControllerState. + test bool + _ cpu.CacheLinePad } @@ -737,7 +740,9 @@ func (c *gcControllerState) addGlobals(amount int64) { // // mheap_.lock must be held or the world must be stopped. func (c *gcControllerState) commit(triggerRatio float64) { - assertWorldStoppedOrLockHeld(&mheap_.lock) + if !c.test { + assertWorldStoppedOrLockHeld(&mheap_.lock) + } // Compute the next GC goal, which is when the allocated heap // has grown by GOGC/100 over the heap marked by the last @@ -842,7 +847,9 @@ func (c *gcControllerState) commit(triggerRatio float64) { // // mheap_.lock must be held or the world must be stopped. func (c *gcControllerState) effectiveGrowthRatio() float64 { - assertWorldStoppedOrLockHeld(&mheap_.lock) + if !c.test { + assertWorldStoppedOrLockHeld(&mheap_.lock) + } egogc := float64(atomic.Load64(&c.heapGoal)-c.heapMarked) / float64(c.heapMarked) if egogc < 0 { @@ -859,7 +866,9 @@ func (c *gcControllerState) effectiveGrowthRatio() float64 { // // The world must be stopped, or mheap_.lock must be held. func (c *gcControllerState) setGCPercent(in int32) int32 { - assertWorldStoppedOrLockHeld(&mheap_.lock) + if !c.test { + assertWorldStoppedOrLockHeld(&mheap_.lock) + } out := c.gcPercent if in < 0 { From 5f1bcd1bc29615b4366f6da8df958bd048ef89a8 Mon Sep 17 00:00:00 2001 From: Ruslan Andreev Date: Mon, 1 Nov 2021 18:17:49 +0000 Subject: [PATCH 277/406] sync: add PoolStarvation benchmark This benchmark simulates object starvation in order to force Ps to steal objects from other Ps. Extracted from CL 314229. Change-Id: Iee31df355ba04d80fbd91c4414e397a375e6d6d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/360256 Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: David Chase Trust: Cherry Mui --- src/sync/pool_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/sync/pool_test.go b/src/sync/pool_test.go index f94153c8d7..d991621624 100644 --- a/src/sync/pool_test.go +++ b/src/sync/pool_test.go @@ -270,6 +270,26 @@ func BenchmarkPoolOverflow(b *testing.B) { }) } +// Simulate object starvation in order to force Ps to steal objects +// from other Ps. +func BenchmarkPoolStarvation(b *testing.B) { + var p Pool + count := 100 + // Reduce number of putted objects by 33 %. It creates objects starvation + // that force P-local storage to steal objects from other Ps. + countStarved := count - int(float32(count)*0.33) + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + for b := 0; b < countStarved; b++ { + p.Put(1) + } + for b := 0; b < count; b++ { + p.Get() + } + } + }) +} + var globalSink interface{} func BenchmarkPoolSTW(b *testing.B) { From 02e5913406b2ac354695471690b79d8d4242ad8d Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 1 Nov 2021 15:00:16 -0700 Subject: [PATCH 278/406] go/types, types2: remove confusing debugging output in inference error message When type inference cannot infer type arguments it prints the list of inferred type arguments (often empty) at the end of the error message. This was meant as debugging support only. Removed for now. Eventually we should provide a better error message. Fixes #49272. Change-Id: I68d43a6ace91081009cab0f2fbad7bfbddf5e76b Reviewed-on: https://go-review.googlesource.com/c/go/+/360554 Trust: Robert Griesemer Trust: Dan Scales Run-TryBot: Robert Griesemer TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/types2/infer.go | 2 +- src/go/types/infer.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go index 156c2290f7..494e896ee9 100644 --- a/src/cmd/compile/internal/types2/infer.go +++ b/src/cmd/compile/internal/types2/infer.go @@ -218,7 +218,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type, // At least one type argument couldn't be inferred. assert(targs != nil && index >= 0 && targs[index] == nil) tpar := tparams[index] - check.errorf(pos, "cannot infer %s (%s) (%s)", tpar.obj.name, tpar.obj.pos, targs) + check.errorf(pos, "cannot infer %s (%s)", tpar.obj.name, tpar.obj.pos) return nil } diff --git a/src/go/types/infer.go b/src/go/types/infer.go index 3348c29476..43b9af348e 100644 --- a/src/go/types/infer.go +++ b/src/go/types/infer.go @@ -214,7 +214,7 @@ func (check *Checker) infer(posn positioner, tparams []*TypeParam, targs []Type, // At least one type argument couldn't be inferred. assert(index >= 0 && targs[index] == nil) tpar := tparams[index] - check.errorf(posn, _Todo, "cannot infer %s (%v) (%v)", tpar.obj.name, tpar.obj.pos, targs) + check.errorf(posn, _Todo, "cannot infer %s (%v)", tpar.obj.name, tpar.obj.pos) return nil } From 81fea0b4fd3b134d4c1d121abad171e358037ce3 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Fri, 7 May 2021 01:03:59 -0700 Subject: [PATCH 279/406] net/url: consider ForceQuery in ResolveReference Previously, when resolving references of form (https://golang.org/?hello).ResolveReference(?) we only used URL.RawQuery to determine whether or not a query part is defined. Go 1.7 introduced URL.ForceQuery as a flag for the situation where a query part is provided but empty. But we did not use it in ResolveReference. This leads to the erroneous output https://golang.org/?hello when the correct output should be https://golang.org/? This commit rectifies that error. Fixes #46033 Change-Id: I05bc0b48bf2bbf13b4ddc0dd10599ea613dc2188 Reviewed-on: https://go-review.googlesource.com/c/go/+/317930 Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Trust: Damien Neil --- src/net/url/url.go | 2 +- src/net/url/url_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/net/url/url.go b/src/net/url/url.go index d571ab2fc4..f31aa08b59 100644 --- a/src/net/url/url.go +++ b/src/net/url/url.go @@ -1083,7 +1083,7 @@ func (u *URL) ResolveReference(ref *URL) *URL { url.Path = "" return &url } - if ref.Path == "" && ref.RawQuery == "" { + if ref.Path == "" && !ref.ForceQuery && ref.RawQuery == "" { url.RawQuery = u.RawQuery if ref.Fragment == "" { url.Fragment = u.Fragment diff --git a/src/net/url/url_test.go b/src/net/url/url_test.go index 6807d58f1a..7c807d7a38 100644 --- a/src/net/url/url_test.go +++ b/src/net/url/url_test.go @@ -1244,6 +1244,9 @@ var resolveReferenceTests = []struct { {"https://a/b/c/d;p?q", "//g/d/e/f?y#s", "https://g/d/e/f?y#s"}, {"https://a/b/c/d;p#s", "?y", "https://a/b/c/d;p?y"}, {"https://a/b/c/d;p?q#s", "?y", "https://a/b/c/d;p?y"}, + + // Empty path and query but with ForceQuery (issue 46033). + {"https://a/b/c/d;p?q#s", "?", "https://a/b/c/d;p?"}, } func TestResolveReference(t *testing.T) { From a59e33224e42d60a97fa720a45e1b74eb6aaa3d0 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 2 Aug 2021 14:55:51 -0700 Subject: [PATCH 280/406] net/netip: add new IP address package Co-authored-by: Alex Willmer (GitHub @moreati) Co-authored-by: Alexander Yastrebov Co-authored-by: David Anderson (Tailscale CLA) Co-authored-by: David Crawshaw (Tailscale CLA) Co-authored-by: Dmytro Shynkevych (Tailscale CLA) Co-authored-by: Elias Naur Co-authored-by: Joe Tsai (Tailscale CLA) Co-authored-by: Jonathan Yu (GitHub @jawnsy) Co-authored-by: Josh Bleecher Snyder (Tailscale CLA) Co-authored-by: Maisem Ali (Tailscale CLA) Co-authored-by: Manuel Mendez (Go AUTHORS mmendez534@...) Co-authored-by: Matt Layher Co-authored-by: Noah Treuhaft (GitHub @nwt) Co-authored-by: Stefan Majer Co-authored-by: Terin Stock (Cloudflare CLA) Co-authored-by: Tobias Klauser Fixes #46518 Change-Id: I0041f9e1115d61fa6e95fcf32b01d9faee708712 Reviewed-on: https://go-review.googlesource.com/c/go/+/339309 Run-TryBot: Brad Fitzpatrick TryBot-Result: Go Bot Reviewed-by: Russ Cox Trust: Brad Fitzpatrick --- src/bytes/bytes.go | 2 +- src/crypto/x509/root_darwin.go | 4 +- src/go/build/deps_test.go | 16 +- src/internal/fuzz/fuzz.go | 9 +- src/internal/godebug/godebug.go | 34 + src/internal/godebug/godebug_test.go | 34 + src/internal/intern/intern.go | 178 +++ src/internal/intern/intern_test.go | 199 +++ src/net/conf.go | 3 +- src/net/http/server.go | 4 +- src/net/http/transport.go | 4 +- src/net/lookup.go | 23 + src/net/netip/export_test.go | 30 + src/net/netip/inlining_test.go | 110 ++ src/net/netip/leaf_alts.go | 43 + src/net/netip/netip.go | 1414 ++++++++++++++++++++ src/net/netip/netip_pkg_test.go | 359 +++++ src/net/netip/netip_test.go | 1798 ++++++++++++++++++++++++++ src/net/netip/slow_test.go | 190 +++ src/net/netip/uint128.go | 92 ++ src/net/netip/uint128_test.go | 89 ++ src/net/parse.go | 23 - src/net/parse_test.go | 27 - src/net/tcpsock.go | 15 + src/net/udpsock.go | 60 + src/strings/compare.go | 2 +- 26 files changed, 4694 insertions(+), 68 deletions(-) create mode 100644 src/internal/godebug/godebug.go create mode 100644 src/internal/godebug/godebug_test.go create mode 100644 src/internal/intern/intern.go create mode 100644 src/internal/intern/intern_test.go create mode 100644 src/net/netip/export_test.go create mode 100644 src/net/netip/inlining_test.go create mode 100644 src/net/netip/leaf_alts.go create mode 100644 src/net/netip/netip.go create mode 100644 src/net/netip/netip_pkg_test.go create mode 100644 src/net/netip/netip_test.go create mode 100644 src/net/netip/slow_test.go create mode 100644 src/net/netip/uint128.go create mode 100644 src/net/netip/uint128_test.go diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go index 529d95a888..9e6b68eaf4 100644 --- a/src/bytes/bytes.go +++ b/src/bytes/bytes.go @@ -21,7 +21,7 @@ func Equal(a, b []byte) bool { } // Compare returns an integer comparing two byte slices lexicographically. -// The result will be 0 if a==b, -1 if a < b, and +1 if a > b. +// The result will be 0 if a == b, -1 if a < b, and +1 if a > b. // A nil argument is equivalent to an empty slice. func Compare(a, b []byte) int { return bytealg.Compare(a, b) diff --git a/src/crypto/x509/root_darwin.go b/src/crypto/x509/root_darwin.go index 164ad9dc77..ef051efd31 100644 --- a/src/crypto/x509/root_darwin.go +++ b/src/crypto/x509/root_darwin.go @@ -10,11 +10,11 @@ import ( "bytes" macOS "crypto/x509/internal/macos" "fmt" + "internal/godebug" "os" - "strings" ) -var debugDarwinRoots = strings.Contains(os.Getenv("GODEBUG"), "x509roots=1") +var debugDarwinRoots = godebug.Get("x509roots") == "1" func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) { return nil, nil diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go index f4a92f8be4..1dd65d60d9 100644 --- a/src/go/build/deps_test.go +++ b/src/go/build/deps_test.go @@ -173,7 +173,7 @@ var depsRules = ` io/fs < embed; - unicode, fmt !< os, os/signal; + unicode, fmt !< net, os, os/signal; os/signal, STR < path/filepath @@ -187,6 +187,8 @@ var depsRules = ` OS < golang.org/x/sys/cpu; + os < internal/godebug; + # FMT is OS (which includes string routines) plus reflect and fmt. # It does not include package log, which should be avoided in core packages. strconv, unicode @@ -352,6 +354,13 @@ var depsRules = ` golang.org/x/net/lif, golang.org/x/net/route; + os, runtime, strconv, sync, unsafe, + internal/godebug + < internal/intern; + + internal/bytealg, internal/intern, internal/itoa, math/bits, sort, strconv + < net/netip; + # net is unavoidable when doing any networking, # so large dependencies must be kept out. # This is a long-looking list but most of these @@ -360,10 +369,12 @@ var depsRules = ` golang.org/x/net/dns/dnsmessage, golang.org/x/net/lif, golang.org/x/net/route, + internal/godebug, internal/nettrace, internal/poll, internal/singleflight, internal/race, + net/netip, os < net; @@ -515,7 +526,8 @@ var depsRules = ` FMT, DEBUG, flag, runtime/trace, internal/sysinfo, math/rand < testing; - FMT, crypto/sha256, encoding/json, go/ast, go/parser, go/token, math/rand, encoding/hex, crypto/sha256 + FMT, crypto/sha256, encoding/json, go/ast, go/parser, go/token, + internal/godebug, math/rand, encoding/hex, crypto/sha256 < internal/fuzz; internal/fuzz, internal/testlog, runtime/pprof, regexp diff --git a/src/internal/fuzz/fuzz.go b/src/internal/fuzz/fuzz.go index 78319a7496..2ebe2a64db 100644 --- a/src/internal/fuzz/fuzz.go +++ b/src/internal/fuzz/fuzz.go @@ -12,6 +12,7 @@ import ( "crypto/sha256" "errors" "fmt" + "internal/godebug" "io" "io/ioutil" "math/bits" @@ -1063,13 +1064,7 @@ var ( func shouldPrintDebugInfo() bool { debugInfoOnce.Do(func() { - debug := strings.Split(os.Getenv("GODEBUG"), ",") - for _, f := range debug { - if f == "fuzzdebug=1" { - debugInfo = true - break - } - } + debugInfo = godebug.Get("fuzzdebug") == "1" }) return debugInfo } diff --git a/src/internal/godebug/godebug.go b/src/internal/godebug/godebug.go new file mode 100644 index 0000000000..ac434e5fd8 --- /dev/null +++ b/src/internal/godebug/godebug.go @@ -0,0 +1,34 @@ +// Copyright 2021 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 godebug parses the GODEBUG environment variable. +package godebug + +import "os" + +// Get returns the value for the provided GODEBUG key. +func Get(key string) string { + return get(os.Getenv("GODEBUG"), key) +} + +// get returns the value part of key=value in s (a GODEBUG value). +func get(s, key string) string { + for i := 0; i < len(s)-len(key)-1; i++ { + if i > 0 && s[i-1] != ',' { + continue + } + afterKey := s[i+len(key):] + if afterKey[0] != '=' || s[i:i+len(key)] != key { + continue + } + val := afterKey[1:] + for i, b := range val { + if b == ',' { + return val[:i] + } + } + return val + } + return "" +} diff --git a/src/internal/godebug/godebug_test.go b/src/internal/godebug/godebug_test.go new file mode 100644 index 0000000000..41b9117b73 --- /dev/null +++ b/src/internal/godebug/godebug_test.go @@ -0,0 +1,34 @@ +// Copyright 2021 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 godebug + +import "testing" + +func TestGet(t *testing.T) { + tests := []struct { + godebug string + key string + want string + }{ + {"", "", ""}, + {"", "foo", ""}, + {"foo=bar", "foo", "bar"}, + {"foo=bar,after=x", "foo", "bar"}, + {"before=x,foo=bar,after=x", "foo", "bar"}, + {"before=x,foo=bar", "foo", "bar"}, + {",,,foo=bar,,,", "foo", "bar"}, + {"foodecoy=wrong,foo=bar", "foo", "bar"}, + {"foo=", "foo", ""}, + {"foo", "foo", ""}, + {",foo", "foo", ""}, + {"foo=bar,baz", "loooooooong", ""}, + } + for _, tt := range tests { + got := get(tt.godebug, tt.key) + if got != tt.want { + t.Errorf("get(%q, %q) = %q; want %q", tt.godebug, tt.key, got, tt.want) + } + } +} diff --git a/src/internal/intern/intern.go b/src/internal/intern/intern.go new file mode 100644 index 0000000000..666caa6d2f --- /dev/null +++ b/src/internal/intern/intern.go @@ -0,0 +1,178 @@ +// Copyright 2020 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 intern lets you make smaller comparable values by boxing +// a larger comparable value (such as a 16 byte string header) down +// into a globally unique 8 byte pointer. +// +// The globally unique pointers are garbage collected with weak +// references and finalizers. This package hides that. +package intern + +import ( + "internal/godebug" + "runtime" + "sync" + "unsafe" +) + +// A Value pointer is the handle to an underlying comparable value. +// See func Get for how Value pointers may be used. +type Value struct { + _ [0]func() // prevent people from accidentally using value type as comparable + cmpVal interface{} + // resurrected is guarded by mu (for all instances of Value). + // It is set true whenever v is synthesized from a uintptr. + resurrected bool +} + +// Get returns the comparable value passed to the Get func +// that returned v. +func (v *Value) Get() interface{} { return v.cmpVal } + +// key is a key in our global value map. +// It contains type-specialized fields to avoid allocations +// when converting common types to empty interfaces. +type key struct { + s string + cmpVal interface{} + // isString reports whether key contains a string. + // Without it, the zero value of key is ambiguous. + isString bool +} + +// keyFor returns a key to use with cmpVal. +func keyFor(cmpVal interface{}) key { + if s, ok := cmpVal.(string); ok { + return key{s: s, isString: true} + } + return key{cmpVal: cmpVal} +} + +// Value returns a *Value built from k. +func (k key) Value() *Value { + if k.isString { + return &Value{cmpVal: k.s} + } + return &Value{cmpVal: k.cmpVal} +} + +var ( + // mu guards valMap, a weakref map of *Value by underlying value. + // It also guards the resurrected field of all *Values. + mu sync.Mutex + valMap = map[key]uintptr{} // to uintptr(*Value) + valSafe = safeMap() // non-nil in safe+leaky mode +) + +// safeMap returns a non-nil map if we're in safe-but-leaky mode, +// as controlled by GODEBUG=intern=leaky +func safeMap() map[key]*Value { + if godebug.Get("intern") == "leaky" { + return map[key]*Value{} + } + return nil +} + +// Get returns a pointer representing the comparable value cmpVal. +// +// The returned pointer will be the same for Get(v) and Get(v2) +// if and only if v == v2, and can be used as a map key. +func Get(cmpVal interface{}) *Value { + return get(keyFor(cmpVal)) +} + +// GetByString is identical to Get, except that it is specialized for strings. +// This avoids an allocation from putting a string into an interface{} +// to pass as an argument to Get. +func GetByString(s string) *Value { + return get(key{s: s, isString: true}) +} + +// We play unsafe games that violate Go's rules (and assume a non-moving +// collector). So we quiet Go here. +// See the comment below Get for more implementation details. +//go:nocheckptr +func get(k key) *Value { + mu.Lock() + defer mu.Unlock() + + var v *Value + if valSafe != nil { + v = valSafe[k] + } else if addr, ok := valMap[k]; ok { + v = (*Value)(unsafe.Pointer(addr)) + v.resurrected = true + } + if v != nil { + return v + } + v = k.Value() + if valSafe != nil { + valSafe[k] = v + } else { + // SetFinalizer before uintptr conversion (theoretical concern; + // see https://github.com/go4org/intern/issues/13) + runtime.SetFinalizer(v, finalize) + valMap[k] = uintptr(unsafe.Pointer(v)) + } + return v +} + +func finalize(v *Value) { + mu.Lock() + defer mu.Unlock() + if v.resurrected { + // We lost the race. Somebody resurrected it while we + // were about to finalize it. Try again next round. + v.resurrected = false + runtime.SetFinalizer(v, finalize) + return + } + delete(valMap, keyFor(v.cmpVal)) +} + +// Interning is simple if you don't require that unused values be +// garbage collectable. But we do require that; we don't want to be +// DOS vector. We do this by using a uintptr to hide the pointer from +// the garbage collector, and using a finalizer to eliminate the +// pointer when no other code is using it. +// +// The obvious implementation of this is to use a +// map[interface{}]uintptr-of-*interface{}, and set up a finalizer to +// delete from the map. Unfortunately, this is racy. Because pointers +// are being created in violation of Go's unsafety rules, it's +// possible to create a pointer to a value concurrently with the GC +// concluding that the value can be collected. There are other races +// that break the equality invariant as well, but the use-after-free +// will cause a runtime crash. +// +// To make this work, the finalizer needs to know that no references +// have been unsafely created since the finalizer was set up. To do +// this, values carry a "resurrected" sentinel, which gets set +// whenever a pointer is unsafely created. If the finalizer encounters +// the sentinel, it clears the sentinel and delays collection for one +// additional GC cycle, by re-installing itself as finalizer. This +// ensures that the unsafely created pointer is visible to the GC, and +// will correctly prevent collection. +// +// This technique does mean that interned values that get reused take +// at least 3 GC cycles to fully collect (1 to clear the sentinel, 1 +// to clean up the unsafe map, 1 to be actually deleted). +// +// @ianlancetaylor commented in +// https://github.com/golang/go/issues/41303#issuecomment-717401656 +// that it is possible to implement weak references in terms of +// finalizers without unsafe. Unfortunately, the approach he outlined +// does not work here, for two reasons. First, there is no way to +// construct a strong pointer out of a weak pointer; our map stores +// weak pointers, but we must return strong pointers to callers. +// Second, and more fundamentally, we must return not just _a_ strong +// pointer to callers, but _the same_ strong pointer to callers. In +// order to return _the same_ strong pointer to callers, we must track +// it, which is exactly what we cannot do with strong pointers. +// +// See https://github.com/inetaf/netaddr/issues/53 for more +// discussion, and https://github.com/go4org/intern/issues/2 for an +// illustration of the subtleties at play. diff --git a/src/internal/intern/intern_test.go b/src/internal/intern/intern_test.go new file mode 100644 index 0000000000..d1e409ef95 --- /dev/null +++ b/src/internal/intern/intern_test.go @@ -0,0 +1,199 @@ +// Copyright 2020 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 intern + +import ( + "fmt" + "runtime" + "testing" +) + +func TestBasics(t *testing.T) { + clearMap() + foo := Get("foo") + bar := Get("bar") + empty := Get("") + nilEface := Get(nil) + i := Get(0x7777777) + foo2 := Get("foo") + bar2 := Get("bar") + empty2 := Get("") + nilEface2 := Get(nil) + i2 := Get(0x7777777) + foo3 := GetByString("foo") + empty3 := GetByString("") + + if foo.Get() != foo2.Get() { + t.Error("foo/foo2 values differ") + } + if foo.Get() != foo3.Get() { + t.Error("foo/foo3 values differ") + } + if foo.Get() != "foo" { + t.Error("foo.Get not foo") + } + if foo != foo2 { + t.Error("foo/foo2 pointers differ") + } + if foo != foo3 { + t.Error("foo/foo3 pointers differ") + } + + if bar.Get() != bar2.Get() { + t.Error("bar values differ") + } + if bar.Get() != "bar" { + t.Error("bar.Get not bar") + } + if bar != bar2 { + t.Error("bar pointers differ") + } + + if i.Get() != i.Get() { + t.Error("i values differ") + } + if i.Get() != 0x7777777 { + t.Error("i.Get not 0x7777777") + } + if i != i2 { + t.Error("i pointers differ") + } + + if empty.Get() != empty2.Get() { + t.Error("empty/empty2 values differ") + } + if empty.Get() != empty.Get() { + t.Error("empty/empty3 values differ") + } + if empty.Get() != "" { + t.Error("empty.Get not empty string") + } + if empty != empty2 { + t.Error("empty/empty2 pointers differ") + } + if empty != empty3 { + t.Error("empty/empty3 pointers differ") + } + + if nilEface.Get() != nilEface2.Get() { + t.Error("nilEface values differ") + } + if nilEface.Get() != nil { + t.Error("nilEface.Get not nil") + } + if nilEface != nilEface2 { + t.Error("nilEface pointers differ") + } + + if n := mapLen(); n != 5 { + t.Errorf("map len = %d; want 4", n) + } + + wantEmpty(t) +} + +func wantEmpty(t testing.TB) { + t.Helper() + const gcTries = 5000 + for try := 0; try < gcTries; try++ { + runtime.GC() + n := mapLen() + if n == 0 { + break + } + if try == gcTries-1 { + t.Errorf("map len = %d after (%d GC tries); want 0, contents: %v", n, gcTries, mapKeys()) + } + } +} + +func TestStress(t *testing.T) { + iters := 10000 + if testing.Short() { + iters = 1000 + } + var sink []byte + for i := 0; i < iters; i++ { + _ = Get("foo") + sink = make([]byte, 1<<20) + } + _ = sink +} + +func BenchmarkStress(b *testing.B) { + done := make(chan struct{}) + defer close(done) + go func() { + for { + select { + case <-done: + return + default: + } + runtime.GC() + } + }() + + clearMap() + v1 := Get("foo") + b.ReportAllocs() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + v2 := Get("foo") + if v1 != v2 { + b.Fatal("wrong value") + } + // And also a key we don't retain: + _ = Get("bar") + } + }) + runtime.GC() + wantEmpty(b) +} + +func mapLen() int { + mu.Lock() + defer mu.Unlock() + return len(valMap) +} + +func mapKeys() (keys []string) { + mu.Lock() + defer mu.Unlock() + for k := range valMap { + keys = append(keys, fmt.Sprint(k)) + } + return keys +} + +func clearMap() { + mu.Lock() + defer mu.Unlock() + for k := range valMap { + delete(valMap, k) + } +} + +var ( + globalString = "not a constant" + sink string +) + +func TestGetByStringAllocs(t *testing.T) { + allocs := int(testing.AllocsPerRun(100, func() { + GetByString(globalString) + })) + if allocs != 0 { + t.Errorf("GetString allocated %d objects, want 0", allocs) + } +} + +func BenchmarkGetByString(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + v := GetByString(globalString) + sink = v.Get().(string) + } +} diff --git a/src/net/conf.go b/src/net/conf.go index 1115699ab0..415caedacc 100644 --- a/src/net/conf.go +++ b/src/net/conf.go @@ -8,6 +8,7 @@ package net import ( "internal/bytealg" + "internal/godebug" "os" "runtime" "sync" @@ -286,7 +287,7 @@ func (c *conf) hostLookupOrder(r *Resolver, hostname string) (ret hostLookupOrde // cgo+2 // same, but debug level 2 // etc. func goDebugNetDNS() (dnsMode string, debugLevel int) { - goDebug := goDebugString("netdns") + goDebug := godebug.Get("netdns") parsePart := func(s string) { if s == "" { return diff --git a/src/net/http/server.go b/src/net/http/server.go index e9b0b4d9bd..91fad68694 100644 --- a/src/net/http/server.go +++ b/src/net/http/server.go @@ -13,6 +13,7 @@ import ( "crypto/tls" "errors" "fmt" + "internal/godebug" "io" "log" "math/rand" @@ -20,7 +21,6 @@ import ( "net/textproto" "net/url" urlpkg "net/url" - "os" "path" "runtime" "sort" @@ -3296,7 +3296,7 @@ func (srv *Server) onceSetNextProtoDefaults_Serve() { // configured otherwise. (by setting srv.TLSNextProto non-nil) // It must only be called via srv.nextProtoOnce (use srv.setupHTTP2_*). func (srv *Server) onceSetNextProtoDefaults() { - if omitBundledHTTP2 || strings.Contains(os.Getenv("GODEBUG"), "http2server=0") { + if omitBundledHTTP2 || godebug.Get("http2server") == "0" { return } // Enable HTTP/2 by default if the user hasn't otherwise diff --git a/src/net/http/transport.go b/src/net/http/transport.go index 0e60992e6c..05a1659136 100644 --- a/src/net/http/transport.go +++ b/src/net/http/transport.go @@ -17,6 +17,7 @@ import ( "crypto/tls" "errors" "fmt" + "internal/godebug" "io" "log" "net" @@ -24,7 +25,6 @@ import ( "net/http/internal/ascii" "net/textproto" "net/url" - "os" "reflect" "strings" "sync" @@ -360,7 +360,7 @@ func (t *Transport) hasCustomTLSDialer() bool { // It must be called via t.nextProtoOnce.Do. func (t *Transport) onceSetNextProtoDefaults() { t.tlsNextProtoWasNil = (t.TLSNextProto == nil) - if strings.Contains(os.Getenv("GODEBUG"), "http2client=0") { + if godebug.Get("http2client") == "0" { return } diff --git a/src/net/lookup.go b/src/net/lookup.go index fe573b8a27..e10c71ae75 100644 --- a/src/net/lookup.go +++ b/src/net/lookup.go @@ -8,6 +8,7 @@ import ( "context" "internal/nettrace" "internal/singleflight" + "net/netip" "sync" ) @@ -232,6 +233,28 @@ func (r *Resolver) LookupIP(ctx context.Context, network, host string) ([]IP, er return ips, nil } +// LookupNetIP looks up host using the local resolver. +// It returns a slice of that host's IP addresses of the type specified by +// network. +// The network must be one of "ip", "ip4" or "ip6". +func (r *Resolver) LookupNetIP(ctx context.Context, network, host string) ([]netip.Addr, error) { + // TODO(bradfitz): make this efficient, making the internal net package + // type throughout be netip.Addr and only converting to the net.IP slice + // version at the edge. But for now (2021-10-20), this is a wrapper around + // the old way. + ips, err := r.LookupIP(ctx, network, host) + if err != nil { + return nil, err + } + ret := make([]netip.Addr, 0, len(ips)) + for _, ip := range ips { + if a, ok := netip.AddrFromSlice(ip); ok { + ret = append(ret, a) + } + } + return ret, nil +} + // onlyValuesCtx is a context that uses an underlying context // for value lookup if the underlying context hasn't yet expired. type onlyValuesCtx struct { diff --git a/src/net/netip/export_test.go b/src/net/netip/export_test.go new file mode 100644 index 0000000000..59971fa2e4 --- /dev/null +++ b/src/net/netip/export_test.go @@ -0,0 +1,30 @@ +// Copyright 2021 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 netip + +import "internal/intern" + +var ( + Z0 = z0 + Z4 = z4 + Z6noz = z6noz +) + +type Uint128 = uint128 + +func Mk128(hi, lo uint64) Uint128 { + return uint128{hi, lo} +} + +func MkAddr(u Uint128, z *intern.Value) Addr { + return Addr{u, z} +} + +func IPv4(a, b, c, d uint8) Addr { return AddrFrom4([4]byte{a, b, c, d}) } + +var TestAppendToMarshal = testAppendToMarshal + +func (a Addr) IsZero() bool { return a.isZero() } +func (p Prefix) IsZero() bool { return p.isZero() } diff --git a/src/net/netip/inlining_test.go b/src/net/netip/inlining_test.go new file mode 100644 index 0000000000..107fe1f083 --- /dev/null +++ b/src/net/netip/inlining_test.go @@ -0,0 +1,110 @@ +// Copyright 2020 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 netip + +import ( + "internal/testenv" + "os/exec" + "path/filepath" + "regexp" + "runtime" + "strings" + "testing" +) + +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), + "build", + "--gcflags=-m", + "net/netip").CombinedOutput() + if err != nil { + t.Fatalf("go build: %v, %s", err, out) + } + got := map[string]bool{} + regexp.MustCompile(` can inline (\S+)`).ReplaceAllFunc(out, func(match []byte) []byte { + got[strings.TrimPrefix(string(match), " can inline ")] = true + return nil + }) + wantInlinable := []string{ + "(*uint128).halves", + "Addr.BitLen", + "Addr.hasZone", + "Addr.Is4", + "Addr.Is4In6", + "Addr.Is6", + "Addr.IsLoopback", + "Addr.IsMulticast", + "Addr.IsInterfaceLocalMulticast", + "Addr.IsValid", + "Addr.IsUnspecified", + "Addr.Less", + "Addr.lessOrEq", + "Addr.Unmap", + "Addr.Zone", + "Addr.v4", + "Addr.v6", + "Addr.v6u16", + "Addr.withoutZone", + "AddrPortFrom", + "AddrPort.Addr", + "AddrPort.Port", + "AddrPort.IsValid", + "Prefix.IsSingleIP", + "Prefix.Masked", + "Prefix.IsValid", + "PrefixFrom", + "Prefix.Addr", + "Prefix.Bits", + "AddrFrom4", + "IPv6LinkLocalAllNodes", + "IPv6Unspecified", + "MustParseAddr", + "MustParseAddrPort", + "MustParsePrefix", + "appendDecimal", + "appendHex", + "uint128.addOne", + "uint128.and", + "uint128.bitsClearedFrom", + "uint128.bitsSetFrom", + "uint128.isZero", + "uint128.not", + "uint128.or", + "uint128.subOne", + "uint128.xor", + } + switch runtime.GOARCH { + case "amd64", "arm64": + // These don't inline on 32-bit. + wantInlinable = append(wantInlinable, + "u64CommonPrefixLen", + "uint128.commonPrefixLen", + "Addr.Next", + "Addr.Prev", + ) + } + + for _, want := range wantInlinable { + if !got[want] { + t.Errorf("%q is no longer inlinable", want) + continue + } + delete(got, want) + } + for sym := range got { + if strings.Contains(sym, ".func") { + continue + } + t.Logf("not in expected set, but also inlinable: %q", sym) + + } +} diff --git a/src/net/netip/leaf_alts.go b/src/net/netip/leaf_alts.go new file mode 100644 index 0000000000..c51f7dfa54 --- /dev/null +++ b/src/net/netip/leaf_alts.go @@ -0,0 +1,43 @@ +// Copyright 2021 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. + +// Stuff that exists in std, but we can't use due to being a dependency +// of net, for go/build deps_test policy reasons. + +package netip + +func stringsLastIndexByte(s string, b byte) int { + for i := len(s) - 1; i >= 0; i-- { + if s[i] == b { + return i + } + } + return -1 +} + +func beUint64(b []byte) uint64 { + _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 + return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | + uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 +} + +func bePutUint64(b []byte, v uint64) { + _ = b[7] // early bounds check to guarantee safety of writes below + b[0] = byte(v >> 56) + b[1] = byte(v >> 48) + b[2] = byte(v >> 40) + b[3] = byte(v >> 32) + b[4] = byte(v >> 24) + b[5] = byte(v >> 16) + b[6] = byte(v >> 8) + b[7] = byte(v) +} + +func bePutUint32(b []byte, v uint32) { + _ = b[3] // early bounds check to guarantee safety of writes below + b[0] = byte(v >> 24) + b[1] = byte(v >> 16) + b[2] = byte(v >> 8) + b[3] = byte(v) +} diff --git a/src/net/netip/netip.go b/src/net/netip/netip.go new file mode 100644 index 0000000000..4ef3b4bb68 --- /dev/null +++ b/src/net/netip/netip.go @@ -0,0 +1,1414 @@ +// Copyright 2020 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 netip defines a IP address type that's a small value type. +// Building on that Addr type, the package also defines AddrPort (an +// IP address and a port), and Prefix (a IP address and a bit length +// prefix). +// +// Compared to the net.IP type, this package's Addr type takes less +// memory, is immutable, and is comparable (supports == and being a +// map key). +package netip + +import ( + "errors" + "math" + "strconv" + + "internal/bytealg" + "internal/intern" + "internal/itoa" +) + +// Sizes: (64-bit) +// net.IP: 24 byte slice header + {4, 16} = 28 to 40 bytes +// net.IPAddr: 40 byte slice header + {4, 16} = 44 to 56 bytes + zone length +// netip.Addr: 24 bytes (zone is per-name singleton, shared across all users) + +// Addr represents an IPv4 or IPv6 address (with or without a scoped +// addressing zone), similar to net.IP or net.IPAddr. +// +// Unlike net.IP or net.IPAddr, Addr is a comparable value +// type (it supports == and can be a map key) and is immutable. +type Addr struct { + // addr is the hi and lo bits of an IPv6 address. If z==z4, + // hi and lo contain the IPv4-mapped IPv6 address. + // + // hi and lo are constructed by interpreting a 16-byte IPv6 + // address as a big-endian 128-bit number. The most significant + // bits of that number go into hi, the rest into lo. + // + // For example, 0011:2233:4455:6677:8899:aabb:ccdd:eeff is stored as: + // addr.hi = 0x0011223344556677 + // addr.lo = 0x8899aabbccddeeff + // + // We store IPs like this, rather than as [16]byte, because it + // turns most operations on IPs into arithmetic and bit-twiddling + // operations on 64-bit registers, which is much faster than + // bytewise processing. + addr uint128 + + // z is a combination of the address family and the IPv6 zone. + // + // nil means invalid IP address (for a zero Addr). + // z4 means an IPv4 address. + // z6noz means an IPv6 address without a zone. + // + // Otherwise it's the interned zone name string. + z *intern.Value +} + +// z0, z4, and z6noz are sentinel IP.z values. +// See the IP type's field docs. +var ( + z0 = (*intern.Value)(nil) + z4 = new(intern.Value) + z6noz = new(intern.Value) +) + +// IPv6LinkLocalAllNodes returns the IPv6 link-local all nodes multicast +// address ff02::1. +func IPv6LinkLocalAllNodes() Addr { return AddrFrom16([16]byte{0: 0xff, 1: 0x02, 15: 0x01}) } + +// IPv6Unspecified returns the IPv6 unspecified address "::". +func IPv6Unspecified() Addr { return Addr{z: z6noz} } + +// AddrFrom4 returns the address of the IPv4 address given by the bytes in addr. +func AddrFrom4(addr [4]byte) Addr { + return Addr{ + addr: uint128{0, 0xffff00000000 | uint64(addr[0])<<24 | uint64(addr[1])<<16 | uint64(addr[2])<<8 | uint64(addr[3])}, + z: z4, + } +} + +// AddrFrom16 returns the IPv6 address given by the bytes in addr. +// An IPv6-mapped IPv4 address is left as an IPv6 address. +// (Use Unmap to convert them if needed.) +func AddrFrom16(addr [16]byte) Addr { + return Addr{ + addr: uint128{ + beUint64(addr[:8]), + beUint64(addr[8:]), + }, + z: z6noz, + } +} + +// ipv6Slice is like IPv6Raw, but operates on a 16-byte slice. Assumes +// slice is 16 bytes, caller must enforce this. +func ipv6Slice(addr []byte) Addr { + return Addr{ + addr: uint128{ + beUint64(addr[:8]), + beUint64(addr[8:]), + }, + z: z6noz, + } +} + +// ParseAddr parses s as an IP address, returning the result. The string +// s can be in dotted decimal ("192.0.2.1"), IPv6 ("2001:db8::68"), +// or IPv6 with a scoped addressing zone ("fe80::1cc0:3e8c:119f:c2e1%ens18"). +func ParseAddr(s string) (Addr, error) { + for i := 0; i < len(s); i++ { + switch s[i] { + case '.': + return parseIPv4(s) + case ':': + return parseIPv6(s) + case '%': + // Assume that this was trying to be an IPv6 address with + // a zone specifier, but the address is missing. + return Addr{}, parseAddrError{in: s, msg: "missing IPv6 address"} + } + } + return Addr{}, parseAddrError{in: s, msg: "unable to parse IP"} +} + +// MustParseAddr calls ParseAddr(s) and panics on error. +// It is intended for use in tests with hard-coded strings. +func MustParseAddr(s string) Addr { + ip, err := ParseAddr(s) + if err != nil { + panic(err) + } + return ip +} + +type parseAddrError struct { + in string // the string given to ParseAddr + msg string // an explanation of the parse failure + at string // optionally, the unparsed portion of in at which the error occurred. +} + +func (err parseAddrError) Error() string { + q := strconv.Quote + if err.at != "" { + return "ParseAddr(" + q(err.in) + "): " + err.msg + " (at " + q(err.at) + ")" + } + return "ParseAddr(" + q(err.in) + "): " + err.msg +} + +// parseIPv4 parses s as an IPv4 address (in form "192.168.0.1"). +func parseIPv4(s string) (ip Addr, err error) { + var fields [4]uint8 + var val, pos int + for i := 0; i < len(s); i++ { + if s[i] >= '0' && s[i] <= '9' { + val = val*10 + int(s[i]) - '0' + if val > 255 { + return Addr{}, parseAddrError{in: s, msg: "IPv4 field has value >255"} + } + } else if s[i] == '.' { + // .1.2.3 + // 1.2.3. + // 1..2.3 + if i == 0 || i == len(s)-1 || s[i-1] == '.' { + return Addr{}, parseAddrError{in: s, msg: "IPv4 field must have at least one digit", at: s[i:]} + } + // 1.2.3.4.5 + if pos == 3 { + return Addr{}, parseAddrError{in: s, msg: "IPv4 address too long"} + } + fields[pos] = uint8(val) + pos++ + val = 0 + } else { + return Addr{}, parseAddrError{in: s, msg: "unexpected character", at: s[i:]} + } + } + if pos < 3 { + return Addr{}, parseAddrError{in: s, msg: "IPv4 address too short"} + } + fields[3] = uint8(val) + return AddrFrom4(fields), nil +} + +// parseIPv6 parses s as an IPv6 address (in form "2001:db8::68"). +func parseIPv6(in string) (Addr, error) { + s := in + + // Split off the zone right from the start. Yes it's a second scan + // of the string, but trying to handle it inline makes a bunch of + // other inner loop conditionals more expensive, and it ends up + // being slower. + zone := "" + i := bytealg.IndexByteString(s, '%') + if i != -1 { + s, zone = s[:i], s[i+1:] + if zone == "" { + // Not allowed to have an empty zone if explicitly specified. + return Addr{}, parseAddrError{in: in, msg: "zone must be a non-empty string"} + } + } + + var ip [16]byte + ellipsis := -1 // position of ellipsis in ip + + // Might have leading ellipsis + if len(s) >= 2 && s[0] == ':' && s[1] == ':' { + ellipsis = 0 + s = s[2:] + // Might be only ellipsis + if len(s) == 0 { + return IPv6Unspecified().WithZone(zone), nil + } + } + + // Loop, parsing hex numbers followed by colon. + i = 0 + for i < 16 { + // Hex number. Similar to parseIPv4, inlining the hex number + // parsing yields a significant performance increase. + off := 0 + acc := uint32(0) + for ; off < len(s); off++ { + c := s[off] + if c >= '0' && c <= '9' { + acc = (acc << 4) + uint32(c-'0') + } else if c >= 'a' && c <= 'f' { + acc = (acc << 4) + uint32(c-'a'+10) + } else if c >= 'A' && c <= 'F' { + acc = (acc << 4) + uint32(c-'A'+10) + } else { + break + } + if acc > math.MaxUint16 { + // Overflow, fail. + return Addr{}, parseAddrError{in: in, msg: "IPv6 field has value >=2^16", at: s} + } + } + if off == 0 { + // No digits found, fail. + return Addr{}, parseAddrError{in: in, msg: "each colon-separated field must have at least one digit", at: s} + } + + // If followed by dot, might be in trailing IPv4. + if off < len(s) && s[off] == '.' { + if ellipsis < 0 && i != 12 { + // Not the right place. + return Addr{}, parseAddrError{in: in, msg: "embedded IPv4 address must replace the final 2 fields of the address", at: s} + } + if i+4 > 16 { + // Not enough room. + return Addr{}, parseAddrError{in: in, msg: "too many hex fields to fit an embedded IPv4 at the end of the address", at: s} + } + // TODO: could make this a bit faster by having a helper + // that parses to a [4]byte, and have both parseIPv4 and + // parseIPv6 use it. + ip4, err := parseIPv4(s) + if err != nil { + return Addr{}, parseAddrError{in: in, msg: err.Error(), at: s} + } + ip[i] = ip4.v4(0) + ip[i+1] = ip4.v4(1) + ip[i+2] = ip4.v4(2) + ip[i+3] = ip4.v4(3) + s = "" + i += 4 + break + } + + // Save this 16-bit chunk. + ip[i] = byte(acc >> 8) + ip[i+1] = byte(acc) + i += 2 + + // Stop at end of string. + s = s[off:] + if len(s) == 0 { + break + } + + // Otherwise must be followed by colon and more. + if s[0] != ':' { + return Addr{}, parseAddrError{in: in, msg: "unexpected character, want colon", at: s} + } else if len(s) == 1 { + return Addr{}, parseAddrError{in: in, msg: "colon must be followed by more characters", at: s} + } + s = s[1:] + + // Look for ellipsis. + if s[0] == ':' { + if ellipsis >= 0 { // already have one + return Addr{}, parseAddrError{in: in, msg: "multiple :: in address", at: s} + } + ellipsis = i + s = s[1:] + if len(s) == 0 { // can be at end + break + } + } + } + + // Must have used entire string. + if len(s) != 0 { + return Addr{}, parseAddrError{in: in, msg: "trailing garbage after address", at: s} + } + + // If didn't parse enough, expand ellipsis. + if i < 16 { + if ellipsis < 0 { + return Addr{}, parseAddrError{in: in, msg: "address string too short"} + } + n := 16 - i + for j := i - 1; j >= ellipsis; j-- { + ip[j+n] = ip[j] + } + for j := ellipsis + n - 1; j >= ellipsis; j-- { + ip[j] = 0 + } + } else if ellipsis >= 0 { + // Ellipsis must represent at least one 0 group. + return Addr{}, parseAddrError{in: in, msg: "the :: must expand to at least one field of zeros"} + } + return AddrFrom16(ip).WithZone(zone), nil +} + +// AddrFromSlice parses the 4- or 16-byte byte slice as an IPv4 or IPv6 address. +// Note that a net.IP can be passed directly as the []byte argument. +// If slice's length is not 4 or 16, AddrFromSlice returns Addr{}, false. +func AddrFromSlice(slice []byte) (ip Addr, ok bool) { + switch len(slice) { + case 4: + return AddrFrom4(*(*[4]byte)(slice)), true + case 16: + return ipv6Slice(slice), true + } + return Addr{}, false +} + +// v4 returns the i'th byte of ip. If ip is not an IPv4, v4 returns +// unspecified garbage. +func (ip Addr) v4(i uint8) uint8 { + return uint8(ip.addr.lo >> ((3 - i) * 8)) +} + +// v6 returns the i'th byte of ip. If ip is an IPv4 address, this +// accesses the IPv4-mapped IPv6 address form of the IP. +func (ip Addr) v6(i uint8) uint8 { + return uint8(*(ip.addr.halves()[(i/8)%2]) >> ((7 - i%8) * 8)) +} + +// v6u16 returns the i'th 16-bit word of ip. If ip is an IPv4 address, +// this accesses the IPv4-mapped IPv6 address form of the IP. +func (ip Addr) v6u16(i uint8) uint16 { + return uint16(*(ip.addr.halves()[(i/4)%2]) >> ((3 - i%4) * 16)) +} + +// isZero reports whether ip is the zero value of the IP type. +// The zero value is not a valid IP address of any type. +// +// Note that "0.0.0.0" and "::" are not the zero value. Use IsUnspecified to +// check for these values instead. +func (ip Addr) isZero() bool { + // Faster than comparing ip == Addr{}, but effectively equivalent, + // as there's no way to make an IP with a nil z from this package. + return ip.z == z0 +} + +// IsValid reports whether the Addr is an initialized address (not the zero Addr). +// +// Note that "0.0.0.0" and "::" are both valid values. +func (ip Addr) IsValid() bool { return ip.z != z0 } + +// BitLen returns the number of bits in the IP address: +// 128 for IPv6, 32 for IPv4, and 0 for the zero Addr. +// +// Note that IPv4-mapped IPv6 addresses are considered IPv6 addresses +// and therefore have bit length 128. +func (ip Addr) BitLen() int { + switch ip.z { + case z0: + return 0 + case z4: + return 32 + } + return 128 +} + +// Zone returns ip's IPv6 scoped addressing zone, if any. +func (ip Addr) Zone() string { + if ip.z == nil { + return "" + } + zone, _ := ip.z.Get().(string) + return zone +} + +// Compare returns an integer comparing two IPs. +// The result will be 0 if ip == ip2, -1 if ip < ip2, and +1 if ip > ip2. +// The definition of "less than" is the same as the Less method. +func (ip Addr) Compare(ip2 Addr) int { + f1, f2 := ip.BitLen(), ip2.BitLen() + if f1 < f2 { + return -1 + } + if f1 > f2 { + return 1 + } + hi1, hi2 := ip.addr.hi, ip2.addr.hi + if hi1 < hi2 { + return -1 + } + if hi1 > hi2 { + return 1 + } + lo1, lo2 := ip.addr.lo, ip2.addr.lo + if lo1 < lo2 { + return -1 + } + if lo1 > lo2 { + return 1 + } + if ip.Is6() { + za, zb := ip.Zone(), ip2.Zone() + if za < zb { + return -1 + } + if za > zb { + return 1 + } + } + return 0 +} + +// Less reports whether ip sorts before ip2. +// IP addresses sort first by length, then their address. +// IPv6 addresses with zones sort just after the same address without a zone. +func (ip Addr) Less(ip2 Addr) bool { return ip.Compare(ip2) == -1 } + +func (ip Addr) lessOrEq(ip2 Addr) bool { return ip.Compare(ip2) <= 0 } + +// ipZone returns the standard library net.IP from ip, as well +// as the zone. +// The optional reuse IP provides memory to reuse. +func (ip Addr) ipZone(reuse []byte) (stdIP []byte, zone string) { + base := reuse[:0] + switch { + case ip.z == z0: + return nil, "" + case ip.Is4(): + a4 := ip.As4() + return append(base, a4[:]...), "" + default: + a16 := ip.As16() + return append(base, a16[:]...), ip.Zone() + } +} + +// IPAddrParts returns the net.IPAddr representation of an Addr. +// +// The slice will be nil if ip is the zero Addr. +// The zone is the empty string if there is no zone. +func (ip Addr) IPAddrParts() (slice []byte, zone string) { + return ip.ipZone(nil) +} + +// Is4 reports whether ip is an IPv4 address. +// +// It returns false for IP4-mapped IPv6 addresses. See IP.Unmap. +func (ip Addr) Is4() bool { + return ip.z == z4 +} + +// Is4In6 reports whether ip is an IPv4-mapped IPv6 address. +func (ip Addr) Is4In6() bool { + return ip.Is6() && ip.addr.hi == 0 && ip.addr.lo>>32 == 0xffff +} + +// Is6 reports whether ip is an IPv6 address, including IPv4-mapped +// IPv6 addresses. +func (ip Addr) Is6() bool { + return ip.z != z0 && ip.z != z4 +} + +// Unmap returns ip with any IPv4-mapped IPv6 address prefix removed. +// +// That is, if ip is an IPv6 address wrapping an IPv4 adddress, it +// returns the wrapped IPv4 address. Otherwise it returns ip unmodified. +func (ip Addr) Unmap() Addr { + if ip.Is4In6() { + ip.z = z4 + } + return ip +} + +// WithZone returns an IP that's the same as ip but with the provided +// zone. If zone is empty, the zone is removed. If ip is an IPv4 +// address, WithZone is a no-op and returns ip unchanged. +func (ip Addr) WithZone(zone string) Addr { + if !ip.Is6() { + return ip + } + if zone == "" { + ip.z = z6noz + return ip + } + ip.z = intern.GetByString(zone) + return ip +} + +// withoutZone unconditionally strips the zone from IP. +// It's similar to WithZone, but small enough to be inlinable. +func (ip Addr) withoutZone() Addr { + if !ip.Is6() { + return ip + } + ip.z = z6noz + return ip +} + +// hasZone reports whether IP has an IPv6 zone. +func (ip Addr) hasZone() bool { + return ip.z != z0 && ip.z != z4 && ip.z != z6noz +} + +// IsLinkLocalUnicast reports whether ip is a link-local unicast address. +func (ip Addr) IsLinkLocalUnicast() bool { + // Dynamic Configuration of IPv4 Link-Local Addresses + // https://datatracker.ietf.org/doc/html/rfc3927#section-2.1 + if ip.Is4() { + return ip.v4(0) == 169 && ip.v4(1) == 254 + } + // IP Version 6 Addressing Architecture (2.4 Address Type Identification) + // https://datatracker.ietf.org/doc/html/rfc4291#section-2.4 + if ip.Is6() { + return ip.v6u16(0)&0xffc0 == 0xfe80 + } + return false // zero value +} + +// IsLoopback reports whether ip is a loopback address. +func (ip Addr) IsLoopback() bool { + // Requirements for Internet Hosts -- Communication Layers (3.2.1.3 Addressing) + // https://datatracker.ietf.org/doc/html/rfc1122#section-3.2.1.3 + if ip.Is4() { + return ip.v4(0) == 127 + } + // IP Version 6 Addressing Architecture (2.4 Address Type Identification) + // https://datatracker.ietf.org/doc/html/rfc4291#section-2.4 + if ip.Is6() { + return ip.addr.hi == 0 && ip.addr.lo == 1 + } + return false // zero value +} + +// IsMulticast reports whether ip is a multicast address. +func (ip Addr) IsMulticast() bool { + // Host Extensions for IP Multicasting (4. HOST GROUP ADDRESSES) + // https://datatracker.ietf.org/doc/html/rfc1112#section-4 + if ip.Is4() { + return ip.v4(0)&0xf0 == 0xe0 + } + // IP Version 6 Addressing Architecture (2.4 Address Type Identification) + // https://datatracker.ietf.org/doc/html/rfc4291#section-2.4 + if ip.Is6() { + return ip.addr.hi>>(64-8) == 0xff // ip.v6(0) == 0xff + } + return false // zero value +} + +// IsInterfaceLocalMulticast reports whether ip is an IPv6 interface-local +// multicast address. +func (ip Addr) IsInterfaceLocalMulticast() bool { + // IPv6 Addressing Architecture (2.7.1. Pre-Defined Multicast Addresses) + // https://datatracker.ietf.org/doc/html/rfc4291#section-2.7.1 + if ip.Is6() { + return ip.v6u16(0)&0xff0f == 0xff01 + } + return false // zero value +} + +// IsLinkLocalMulticast reports whether ip is a link-local multicast address. +func (ip Addr) IsLinkLocalMulticast() bool { + // IPv4 Multicast Guidelines (4. Local Network Control Block (224.0.0/24)) + // https://datatracker.ietf.org/doc/html/rfc5771#section-4 + if ip.Is4() { + return ip.v4(0) == 224 && ip.v4(1) == 0 && ip.v4(2) == 0 + } + // IPv6 Addressing Architecture (2.7.1. Pre-Defined Multicast Addresses) + // https://datatracker.ietf.org/doc/html/rfc4291#section-2.7.1 + if ip.Is6() { + return ip.v6u16(0)&0xff0f == 0xff02 + } + return false // zero value +} + +// IsGlobalUnicast reports whether ip is a global unicast address. +// +// It returns true for IPv6 addresses which fall outside of the current +// IANA-allocated 2000::/3 global unicast space, with the exception of the +// link-local address space. It also returns true even if ip is in the IPv4 +// private address space or IPv6 unique local address space. +// It returns false for the zero Addr. +// +// For reference, see RFC 1122, RFC 4291, and RFC 4632. +func (ip Addr) IsGlobalUnicast() bool { + if ip.z == z0 { + // Invalid or zero-value. + return false + } + + // Match package net's IsGlobalUnicast logic. Notably private IPv4 addresses + // and ULA IPv6 addresses are still considered "global unicast". + if ip.Is4() && (ip == AddrFrom4([4]byte{}) || ip == AddrFrom4([4]byte{255, 255, 255, 255})) { + return false + } + + return ip != IPv6Unspecified() && + !ip.IsLoopback() && + !ip.IsMulticast() && + !ip.IsLinkLocalUnicast() +} + +// IsPrivate reports whether ip is a private address, according to RFC 1918 +// (IPv4 addresses) and RFC 4193 (IPv6 addresses). That is, it reports whether +// ip is in 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, or fc00::/7. This is the +// same as net.IP.IsPrivate. +func (ip Addr) IsPrivate() bool { + // Match the stdlib's IsPrivate logic. + if ip.Is4() { + // RFC 1918 allocates 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 as + // private IPv4 address subnets. + return ip.v4(0) == 10 || + (ip.v4(0) == 172 && ip.v4(1)&0xf0 == 16) || + (ip.v4(0) == 192 && ip.v4(1) == 168) + } + + if ip.Is6() { + // RFC 4193 allocates fc00::/7 as the unique local unicast IPv6 address + // subnet. + return ip.v6(0)&0xfe == 0xfc + } + + return false // zero value +} + +// IsUnspecified reports whether ip is an unspecified address, either the IPv4 +// address "0.0.0.0" or the IPv6 address "::". +// +// Note that the zero Addr is not an unspecified address. +func (ip Addr) IsUnspecified() bool { + return ip == AddrFrom4([4]byte{}) || ip == IPv6Unspecified() +} + +// Prefix keeps only the top b bits of IP, producing a Prefix +// of the specified length. +// If ip is a zero Addr, Prefix always returns a zero Prefix and a nil error. +// Otherwise, if bits is less than zero or greater than ip.BitLen(), +// Prefix returns an error. +func (ip Addr) Prefix(b int) (Prefix, error) { + if b < 0 { + return Prefix{}, errors.New("negative Prefix bits") + } + effectiveBits := b + switch ip.z { + case z0: + return Prefix{}, nil + case z4: + if b > 32 { + return Prefix{}, errors.New("prefix length " + itoa.Itoa(b) + " too large for IPv4") + } + effectiveBits += 96 + default: + if b > 128 { + return Prefix{}, errors.New("prefix length " + itoa.Itoa(b) + " too large for IPv6") + } + } + ip.addr = ip.addr.and(mask6(effectiveBits)) + return PrefixFrom(ip, b), nil +} + +const ( + netIPv4len = 4 + netIPv6len = 16 +) + +// As16 returns the IP address in its 16-byte representation. +// IPv4 addresses are returned in their v6-mapped form. +// IPv6 addresses with zones are returned without their zone (use the +// Zone method to get it). +// The ip zero value returns all zeroes. +func (ip Addr) As16() [16]byte { + var ret [16]byte + bePutUint64(ret[:8], ip.addr.hi) + bePutUint64(ret[8:], ip.addr.lo) + return ret +} + +// As4 returns an IPv4 or IPv4-in-IPv6 address in its 4-byte representation. +// If ip is the zero Addr or an IPv6 address, As4 panics. +// Note that 0.0.0.0 is not the zero Addr. +func (ip Addr) As4() [4]byte { + if ip.z == z4 || ip.Is4In6() { + var ret [4]byte + bePutUint32(ret[:], uint32(ip.addr.lo)) + return ret + } + if ip.z == z0 { + panic("As4 called on IP zero value") + } + panic("As4 called on IPv6 address") +} + +// Next returns the address following ip. +// If there is none, it returns the zero Addr. +func (ip Addr) Next() Addr { + ip.addr = ip.addr.addOne() + if ip.Is4() { + if uint32(ip.addr.lo) == 0 { + // Overflowed. + return Addr{} + } + } else { + if ip.addr.isZero() { + // Overflowed + return Addr{} + } + } + return ip +} + +// Prev returns the IP before ip. +// If there is none, it returns the IP zero value. +func (ip Addr) Prev() Addr { + if ip.Is4() { + if uint32(ip.addr.lo) == 0 { + return Addr{} + } + } else if ip.addr.isZero() { + return Addr{} + } + ip.addr = ip.addr.subOne() + return ip +} + +// String returns the string form of the IP address ip. +// It returns one of 5 forms: +// +// - "invalid IP", if ip is the zero Addr +// - IPv4 dotted decimal ("192.0.2.1") +// - IPv6 ("2001:db8::1") +// - "::ffff:1.2.3.4" (if Is4In6) +// - IPv6 with zone ("fe80:db8::1%eth0") +// +// Note that unlike package net's IP.String method, +// IP4-mapped IPv6 addresses format with a "::ffff:" +// prefix before the dotted quad. +func (ip Addr) String() string { + switch ip.z { + case z0: + return "invalid IP" + case z4: + return ip.string4() + default: + if ip.Is4In6() { + // TODO(bradfitz): this could alloc less. + return "::ffff:" + ip.Unmap().String() + } + return ip.string6() + } +} + +// AppendTo appends a text encoding of ip, +// as generated by MarshalText, +// to b and returns the extended buffer. +func (ip Addr) AppendTo(b []byte) []byte { + switch ip.z { + case z0: + return b + case z4: + return ip.appendTo4(b) + default: + if ip.Is4In6() { + b = append(b, "::ffff:"...) + return ip.Unmap().appendTo4(b) + } + return ip.appendTo6(b) + } +} + +// digits is a string of the hex digits from 0 to f. It's used in +// appendDecimal and appendHex to format IP addresses. +const digits = "0123456789abcdef" + +// appendDecimal appends the decimal string representation of x to b. +func appendDecimal(b []byte, x uint8) []byte { + // Using this function rather than strconv.AppendUint makes IPv4 + // string building 2x faster. + + if x >= 100 { + b = append(b, digits[x/100]) + } + if x >= 10 { + b = append(b, digits[x/10%10]) + } + return append(b, digits[x%10]) +} + +// appendHex appends the hex string representation of x to b. +func appendHex(b []byte, x uint16) []byte { + // Using this function rather than strconv.AppendUint makes IPv6 + // string building 2x faster. + + if x >= 0x1000 { + b = append(b, digits[x>>12]) + } + if x >= 0x100 { + b = append(b, digits[x>>8&0xf]) + } + if x >= 0x10 { + b = append(b, digits[x>>4&0xf]) + } + return append(b, digits[x&0xf]) +} + +// appendHexPad appends the fully padded hex string representation of x to b. +func appendHexPad(b []byte, x uint16) []byte { + return append(b, digits[x>>12], digits[x>>8&0xf], digits[x>>4&0xf], digits[x&0xf]) +} + +func (ip Addr) string4() string { + const max = len("255.255.255.255") + ret := make([]byte, 0, max) + ret = ip.appendTo4(ret) + return string(ret) +} + +func (ip Addr) appendTo4(ret []byte) []byte { + ret = appendDecimal(ret, ip.v4(0)) + ret = append(ret, '.') + ret = appendDecimal(ret, ip.v4(1)) + ret = append(ret, '.') + ret = appendDecimal(ret, ip.v4(2)) + ret = append(ret, '.') + ret = appendDecimal(ret, ip.v4(3)) + return ret +} + +// string6 formats ip in IPv6 textual representation. It follows the +// guidelines in section 4 of RFC 5952 +// (https://tools.ietf.org/html/rfc5952#section-4): no unnecessary +// zeros, use :: to elide the longest run of zeros, and don't use :: +// to compact a single zero field. +func (ip Addr) string6() string { + // Use a zone with a "plausibly long" name, so that most zone-ful + // IP addresses won't require additional allocation. + // + // The compiler does a cool optimization here, where ret ends up + // stack-allocated and so the only allocation this function does + // is to construct the returned string. As such, it's okay to be a + // bit greedy here, size-wise. + const max = len("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%enp5s0") + ret := make([]byte, 0, max) + ret = ip.appendTo6(ret) + return string(ret) +} + +func (ip Addr) appendTo6(ret []byte) []byte { + zeroStart, zeroEnd := uint8(255), uint8(255) + for i := uint8(0); i < 8; i++ { + j := i + for j < 8 && ip.v6u16(j) == 0 { + j++ + } + if l := j - i; l >= 2 && l > zeroEnd-zeroStart { + zeroStart, zeroEnd = i, j + } + } + + for i := uint8(0); i < 8; i++ { + if i == zeroStart { + ret = append(ret, ':', ':') + i = zeroEnd + if i >= 8 { + break + } + } else if i > 0 { + ret = append(ret, ':') + } + + ret = appendHex(ret, ip.v6u16(i)) + } + + if ip.z != z6noz { + ret = append(ret, '%') + ret = append(ret, ip.Zone()...) + } + return ret +} + +// StringExpanded is like String but IPv6 addresses are expanded with leading +// zeroes and no "::" compression. For example, "2001:db8::1" becomes +// "2001:0db8:0000:0000:0000:0000:0000:0001". +func (ip Addr) StringExpanded() string { + switch ip.z { + case z0, z4: + return ip.String() + } + + const size = len("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") + ret := make([]byte, 0, size) + for i := uint8(0); i < 8; i++ { + if i > 0 { + ret = append(ret, ':') + } + + ret = appendHexPad(ret, ip.v6u16(i)) + } + + if ip.z != z6noz { + // The addition of a zone will cause a second allocation, but when there + // is no zone the ret slice will be stack allocated. + ret = append(ret, '%') + ret = append(ret, ip.Zone()...) + } + return string(ret) +} + +// MarshalText implements the encoding.TextMarshaler interface, +// The encoding is the same as returned by String, with one exception: +// If ip is the zero Addr, the encoding is the empty string. +func (ip Addr) MarshalText() ([]byte, error) { + switch ip.z { + case z0: + return []byte(""), nil + case z4: + max := len("255.255.255.255") + b := make([]byte, 0, max) + return ip.appendTo4(b), nil + default: + max := len("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%enp5s0") + b := make([]byte, 0, max) + if ip.Is4In6() { + b = append(b, "::ffff:"...) + return ip.Unmap().appendTo4(b), nil + } + return ip.appendTo6(b), nil + } +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +// The IP address is expected in a form accepted by ParseAddr. +// +// If text is empty, UnmarshalText sets *ip to the zero Addr and +// returns no error. +func (ip *Addr) UnmarshalText(text []byte) error { + if len(text) == 0 { + *ip = Addr{} + return nil + } + var err error + *ip, err = ParseAddr(string(text)) + return err +} + +// MarshalBinary implements the encoding.BinaryMarshaler interface. +// It returns a zero-length slice for the zero Addr, +// the 4-byte form for an IPv4 address, +// and the 16-byte form with zone appended for an IPv6 address. +func (ip Addr) MarshalBinary() ([]byte, error) { + switch ip.z { + case z0: + return nil, nil + case z4: + b := ip.As4() + return b[:], nil + default: + b16 := ip.As16() + b := b16[:] + if z := ip.Zone(); z != "" { + b = append(b, []byte(z)...) + } + return b, nil + } +} + +// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. +// It expects data in the form generated by MarshalBinary. +func (ip *Addr) UnmarshalBinary(b []byte) error { + n := len(b) + switch { + case n == 0: + *ip = Addr{} + return nil + case n == 4: + *ip = AddrFrom4(*(*[4]byte)(b)) + return nil + case n == 16: + *ip = ipv6Slice(b) + return nil + case n > 16: + *ip = ipv6Slice(b[:16]).WithZone(string(b[16:])) + return nil + } + return errors.New("unexpected slice size") +} + +// AddrPort is an IP and a port number. +type AddrPort struct { + ip Addr + port uint16 +} + +// AddrPortFrom returns an AddrPort with the provided IP and port. +// It does not allocate. +func AddrPortFrom(ip Addr, port uint16) AddrPort { return AddrPort{ip: ip, port: port} } + +// Addr returns p's IP address. +func (p AddrPort) Addr() Addr { return p.ip } + +// Port returns p's port. +func (p AddrPort) Port() uint16 { return p.port } + +// splitAddrPort splits s into an IP address string and a port +// string. It splits strings shaped like "foo:bar" or "[foo]:bar", +// without further validating the substrings. v6 indicates whether the +// ip string should parse as an IPv6 address or an IPv4 address, in +// order for s to be a valid ip:port string. +func splitAddrPort(s string) (ip, port string, v6 bool, err error) { + i := stringsLastIndexByte(s, ':') + if i == -1 { + return "", "", false, errors.New("not an ip:port") + } + + ip, port = s[:i], s[i+1:] + if len(ip) == 0 { + return "", "", false, errors.New("no IP") + } + if len(port) == 0 { + return "", "", false, errors.New("no port") + } + if ip[0] == '[' { + if len(ip) < 2 || ip[len(ip)-1] != ']' { + return "", "", false, errors.New("missing ]") + } + ip = ip[1 : len(ip)-1] + v6 = true + } + + return ip, port, v6, nil +} + +// ParseAddrPort parses s as an AddrPort. +// +// It doesn't do any name resolution: both the address and the port +// must be numeric. +func ParseAddrPort(s string) (AddrPort, error) { + var ipp AddrPort + ip, port, v6, err := splitAddrPort(s) + if err != nil { + return ipp, err + } + port16, err := strconv.ParseUint(port, 10, 16) + if err != nil { + return ipp, errors.New("invalid port " + strconv.Quote(port) + " parsing " + strconv.Quote(s)) + } + ipp.port = uint16(port16) + ipp.ip, err = ParseAddr(ip) + if err != nil { + return AddrPort{}, err + } + if v6 && ipp.ip.Is4() { + return AddrPort{}, errors.New("invalid ip:port " + strconv.Quote(s) + ", square brackets can only be used with IPv6 addresses") + } else if !v6 && ipp.ip.Is6() { + return AddrPort{}, errors.New("invalid ip:port " + strconv.Quote(s) + ", IPv6 addresses must be surrounded by square brackets") + } + return ipp, nil +} + +// MustParseAddrPort calls ParseAddrPort(s) and panics on error. +// It is intended for use in tests with hard-coded strings. +func MustParseAddrPort(s string) AddrPort { + ip, err := ParseAddrPort(s) + if err != nil { + panic(err) + } + return ip +} + +// isZero reports whether p is the zero AddrPort. +func (p AddrPort) isZero() bool { return p == AddrPort{} } + +// IsValid reports whether p.IP() is valid. +// All ports are valid, including zero. +func (p AddrPort) IsValid() bool { return p.ip.IsValid() } + +func (p AddrPort) String() string { + switch p.ip.z { + case z0: + return "invalid AddrPort" + case z4: + a := p.ip.As4() + buf := make([]byte, 0, 21) + for i := range a { + buf = strconv.AppendUint(buf, uint64(a[i]), 10) + buf = append(buf, "...:"[i]) + } + buf = strconv.AppendUint(buf, uint64(p.port), 10) + return string(buf) + default: + // TODO: this could be more efficient allocation-wise: + return joinHostPort(p.ip.String(), itoa.Itoa(int(p.port))) + } +} + +func joinHostPort(host, port string) string { + // We assume that host is a literal IPv6 address if host has + // colons. + if bytealg.IndexByteString(host, ':') >= 0 { + return "[" + host + "]:" + port + } + return host + ":" + port +} + +// AppendTo appends a text encoding of p, +// as generated by MarshalText, +// to b and returns the extended buffer. +func (p AddrPort) AppendTo(b []byte) []byte { + switch p.ip.z { + case z0: + return b + case z4: + b = p.ip.appendTo4(b) + default: + b = append(b, '[') + b = p.ip.appendTo6(b) + b = append(b, ']') + } + b = append(b, ':') + b = strconv.AppendInt(b, int64(p.port), 10) + return b +} + +// MarshalText implements the encoding.TextMarshaler interface. The +// encoding is the same as returned by String, with one exception: if +// p.Addr() is the zero Addr, the encoding is the empty string. +func (p AddrPort) MarshalText() ([]byte, error) { + var max int + switch p.ip.z { + case z0: + case z4: + max = len("255.255.255.255:65535") + default: + max = len("[ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%enp5s0]:65535") + } + b := make([]byte, 0, max) + b = p.AppendTo(b) + return b, nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler +// interface. The AddrPort is expected in a form +// generated by MarshalText or accepted by ParseAddrPort. +func (p *AddrPort) UnmarshalText(text []byte) error { + if len(text) == 0 { + *p = AddrPort{} + return nil + } + var err error + *p, err = ParseAddrPort(string(text)) + return err +} + +// Prefix is an IP address prefix (CIDR) representing an IP network. +// +// The first Bits() of Addr() are specified. The remaining bits match any address. +// The range of Bits() is [0,32] for IPv4 or [0,128] for IPv6. +type Prefix struct { + ip Addr + + // bits is logically a uint8 (storing [0,128]) but also + // encodes an "invalid" bit, currently represented by the + // invalidPrefixBits sentinel value. It could be packed into + // the uint8 more with more comlicated expressions in the + // accessors, but the extra byte (in padding anyway) doesn't + // hurt and simplifies code below. + bits int16 +} + +// invalidPrefixBits is the Prefix.bits value used when PrefixFrom is +// outside the range of a uint8. It's returned as the int -1 in the +// public API. +const invalidPrefixBits = -1 + +// PrefixFrom returns an Prefix with the provided IP address and bit +// prefix length. +// +// It does not allocate. Unlike Addr.Prefix, PrefixFrom does not mask +// off the host bits of ip. +// +// If bits is less than zero or greater than ip.BitLen, Prefix.Bits +// will return an invalid value -1. +func PrefixFrom(ip Addr, bits int) Prefix { + if bits < 0 || bits > ip.BitLen() { + bits = invalidPrefixBits + } + b16 := int16(bits) + return Prefix{ + ip: ip.withoutZone(), + bits: b16, + } +} + +// Addr returns p's IP address. +func (p Prefix) Addr() Addr { return p.ip } + +// Bits returns p's prefix length. +// +// It reports -1 if invalid. +func (p Prefix) Bits() int { return int(p.bits) } + +// IsValid reports whether whether p.Bits() has a valid range for p.IP(). +// If p.Addr() is the zero Addr, IsValid returns false. +// Note that if p is the zero Prefix, then p.IsValid() == false. +func (p Prefix) IsValid() bool { return !p.ip.isZero() && p.bits >= 0 && int(p.bits) <= p.ip.BitLen() } + +func (p Prefix) isZero() bool { return p == Prefix{} } + +// IsSingleIP reports whether p contains exactly one IP. +func (p Prefix) IsSingleIP() bool { return p.bits != 0 && int(p.bits) == p.ip.BitLen() } + +// ParsePrefix parses s as an IP address prefix. +// The string can be in the form "192.168.1.0/24" or "2001::db8::/32", +// the CIDR notation defined in RFC 4632 and RFC 4291. +// +// Note that masked address bits are not zeroed. Use Masked for that. +func ParsePrefix(s string) (Prefix, error) { + i := stringsLastIndexByte(s, '/') + if i < 0 { + return Prefix{}, errors.New("netip.ParsePrefix(" + strconv.Quote(s) + "): no '/'") + } + ip, err := ParseAddr(s[:i]) + if err != nil { + return Prefix{}, errors.New("netip.ParsePrefix(" + strconv.Quote(s) + "): " + err.Error()) + } + bitsStr := s[i+1:] + bits, err := strconv.Atoi(bitsStr) + if err != nil { + return Prefix{}, errors.New("netip.ParsePrefix(" + strconv.Quote(s) + ": bad bits after slash: " + strconv.Quote(bitsStr)) + } + maxBits := 32 + if ip.Is6() { + maxBits = 128 + } + if bits < 0 || bits > maxBits { + return Prefix{}, errors.New("netip.ParsePrefix(" + strconv.Quote(s) + ": prefix length out of range") + } + return PrefixFrom(ip, bits), nil +} + +// MustParsePrefix calls ParsePrefix(s) and panics on error. +// It is intended for use in tests with hard-coded strings. +func MustParsePrefix(s string) Prefix { + ip, err := ParsePrefix(s) + if err != nil { + panic(err) + } + return ip +} + +// Masked returns p in its canonical form, with all but the high +// p.Bits() bits of p.Addr() masked off. +// +// If p is zero or otherwise invalid, Masked returns the zero Prefix. +func (p Prefix) Masked() Prefix { + if m, err := p.ip.Prefix(int(p.bits)); err == nil { + return m + } + return Prefix{} +} + +// Contains reports whether the network p includes ip. +// +// An IPv4 address will not match an IPv6 prefix. +// A v6-mapped IPv6 address will not match an IPv4 prefix. +// A zero-value IP will not match any prefix. +// If ip has an IPv6 zone, Contains returns false, +// because Prefixes strip zones. +func (p Prefix) Contains(ip Addr) bool { + if !p.IsValid() || ip.hasZone() { + return false + } + if f1, f2 := p.ip.BitLen(), ip.BitLen(); f1 == 0 || f2 == 0 || f1 != f2 { + return false + } + if ip.Is4() { + // xor the IP addresses together; mismatched bits are now ones. + // Shift away the number of bits we don't care about. + // Shifts in Go are more efficient if the compiler can prove + // that the shift amount is smaller than the width of the shifted type (64 here). + // We know that p.bits is in the range 0..32 because p is Valid; + // the compiler doesn't know that, so mask with 63 to help it. + // Now truncate to 32 bits, because this is IPv4. + // If all the bits we care about are equal, the result will be zero. + return uint32((ip.addr.lo^p.ip.addr.lo)>>((32-p.bits)&63)) == 0 + } else { + // xor the IP addresses together. + // Mask away the bits we don't care about. + // If all the bits we care about are equal, the result will be zero. + return ip.addr.xor(p.ip.addr).and(mask6(int(p.bits))).isZero() + } +} + +// Overlaps reports whether p and o contain any IP addresses in common. +// +// If p and o are of different address families or either have a zero +// IP, it reports false. Like the Contains method, a prefix with a +// v6-mapped IPv4 IP is still treated as an IPv6 mask. +func (p Prefix) Overlaps(o Prefix) bool { + if !p.IsValid() || !o.IsValid() { + return false + } + if p == o { + return true + } + if p.ip.Is4() != o.ip.Is4() { + return false + } + var minBits int16 + if p.bits < o.bits { + minBits = p.bits + } else { + minBits = o.bits + } + if minBits == 0 { + return true + } + // One of these Prefix calls might look redundant, but we don't require + // that p and o values are normalized (via Prefix.Masked) first, + // so the Prefix call on the one that's already minBits serves to zero + // out any remaining bits in IP. + var err error + if p, err = p.ip.Prefix(int(minBits)); err != nil { + return false + } + if o, err = o.ip.Prefix(int(minBits)); err != nil { + return false + } + return p.ip == o.ip +} + +// AppendTo appends a text encoding of p, +// as generated by MarshalText, +// to b and returns the extended buffer. +func (p Prefix) AppendTo(b []byte) []byte { + if p.isZero() { + return b + } + if !p.IsValid() { + return append(b, "invalid Prefix"...) + } + + // p.ip is non-nil, because p is valid. + if p.ip.z == z4 { + b = p.ip.appendTo4(b) + } else { + b = p.ip.appendTo6(b) + } + + b = append(b, '/') + b = appendDecimal(b, uint8(p.bits)) + return b +} + +// MarshalText implements the encoding.TextMarshaler interface, +// The encoding is the same as returned by String, with one exception: +// If p is the zero value, the encoding is the empty string. +func (p Prefix) MarshalText() ([]byte, error) { + var max int + switch p.ip.z { + case z0: + case z4: + max = len("255.255.255.255/32") + default: + max = len("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%enp5s0/128") + } + b := make([]byte, 0, max) + b = p.AppendTo(b) + return b, nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +// The IP address is expected in a form accepted by ParsePrefix +// or generated by MarshalText. +func (p *Prefix) UnmarshalText(text []byte) error { + if len(text) == 0 { + *p = Prefix{} + return nil + } + var err error + *p, err = ParsePrefix(string(text)) + return err +} + +// String returns the CIDR notation of p: "/". +func (p Prefix) String() string { + if !p.IsValid() { + return "invalid Prefix" + } + return p.ip.String() + "/" + itoa.Itoa(int(p.bits)) +} diff --git a/src/net/netip/netip_pkg_test.go b/src/net/netip/netip_pkg_test.go new file mode 100644 index 0000000000..f5cd9ee86d --- /dev/null +++ b/src/net/netip/netip_pkg_test.go @@ -0,0 +1,359 @@ +// Copyright 2020 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 netip + +import ( + "bytes" + "encoding" + "encoding/json" + "strings" + "testing" +) + +var ( + mustPrefix = MustParsePrefix + mustIP = MustParseAddr +) + +func TestPrefixValid(t *testing.T) { + v4 := MustParseAddr("1.2.3.4") + v6 := MustParseAddr("::1") + tests := []struct { + ipp Prefix + want bool + }{ + {Prefix{v4, -2}, false}, + {Prefix{v4, -1}, false}, + {Prefix{v4, 0}, true}, + {Prefix{v4, 32}, true}, + {Prefix{v4, 33}, false}, + + {Prefix{v6, -2}, false}, + {Prefix{v6, -1}, false}, + {Prefix{v6, 0}, true}, + {Prefix{v6, 32}, true}, + {Prefix{v6, 128}, true}, + {Prefix{v6, 129}, false}, + + {Prefix{Addr{}, -2}, false}, + {Prefix{Addr{}, -1}, false}, + {Prefix{Addr{}, 0}, false}, + {Prefix{Addr{}, 32}, false}, + {Prefix{Addr{}, 128}, false}, + } + for _, tt := range tests { + got := tt.ipp.IsValid() + if got != tt.want { + t.Errorf("(%v).IsValid() = %v want %v", tt.ipp, got, tt.want) + } + } +} + +var nextPrevTests = []struct { + ip Addr + next Addr + prev Addr +}{ + {mustIP("10.0.0.1"), mustIP("10.0.0.2"), mustIP("10.0.0.0")}, + {mustIP("10.0.0.255"), mustIP("10.0.1.0"), mustIP("10.0.0.254")}, + {mustIP("127.0.0.1"), mustIP("127.0.0.2"), mustIP("127.0.0.0")}, + {mustIP("254.255.255.255"), mustIP("255.0.0.0"), mustIP("254.255.255.254")}, + {mustIP("255.255.255.255"), Addr{}, mustIP("255.255.255.254")}, + {mustIP("0.0.0.0"), mustIP("0.0.0.1"), Addr{}}, + {mustIP("::"), mustIP("::1"), Addr{}}, + {mustIP("::%x"), mustIP("::1%x"), Addr{}}, + {mustIP("::1"), mustIP("::2"), mustIP("::")}, + {mustIP("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"), Addr{}, mustIP("ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe")}, +} + +func TestIPNextPrev(t *testing.T) { + doNextPrev(t) + + for _, ip := range []Addr{ + mustIP("0.0.0.0"), + mustIP("::"), + } { + got := ip.Prev() + if !got.isZero() { + t.Errorf("IP(%v).Prev = %v; want zero", ip, got) + } + } + + var allFF [16]byte + for i := range allFF { + allFF[i] = 0xff + } + + for _, ip := range []Addr{ + mustIP("255.255.255.255"), + AddrFrom16(allFF), + } { + got := ip.Next() + if !got.isZero() { + t.Errorf("IP(%v).Next = %v; want zero", ip, got) + } + } +} + +func BenchmarkIPNextPrev(b *testing.B) { + for i := 0; i < b.N; i++ { + doNextPrev(b) + } +} + +func doNextPrev(t testing.TB) { + for _, tt := range nextPrevTests { + gnext, gprev := tt.ip.Next(), tt.ip.Prev() + if gnext != tt.next { + t.Errorf("IP(%v).Next = %v; want %v", tt.ip, gnext, tt.next) + } + if gprev != tt.prev { + t.Errorf("IP(%v).Prev = %v; want %v", tt.ip, gprev, tt.prev) + } + if !tt.ip.Next().isZero() && tt.ip.Next().Prev() != tt.ip { + t.Errorf("IP(%v).Next.Prev = %v; want %v", tt.ip, tt.ip.Next().Prev(), tt.ip) + } + if !tt.ip.Prev().isZero() && tt.ip.Prev().Next() != tt.ip { + t.Errorf("IP(%v).Prev.Next = %v; want %v", tt.ip, tt.ip.Prev().Next(), tt.ip) + } + } +} + +func TestIPBitLen(t *testing.T) { + tests := []struct { + ip Addr + want int + }{ + {Addr{}, 0}, + {mustIP("0.0.0.0"), 32}, + {mustIP("10.0.0.1"), 32}, + {mustIP("::"), 128}, + {mustIP("fed0::1"), 128}, + {mustIP("::ffff:10.0.0.1"), 128}, + } + for _, tt := range tests { + got := tt.ip.BitLen() + if got != tt.want { + t.Errorf("BitLen(%v) = %d; want %d", tt.ip, got, tt.want) + } + } +} + +func TestPrefixContains(t *testing.T) { + tests := []struct { + ipp Prefix + ip Addr + want bool + }{ + {mustPrefix("9.8.7.6/0"), mustIP("9.8.7.6"), true}, + {mustPrefix("9.8.7.6/16"), mustIP("9.8.7.6"), true}, + {mustPrefix("9.8.7.6/16"), mustIP("9.8.6.4"), true}, + {mustPrefix("9.8.7.6/16"), mustIP("9.9.7.6"), false}, + {mustPrefix("9.8.7.6/32"), mustIP("9.8.7.6"), true}, + {mustPrefix("9.8.7.6/32"), mustIP("9.8.7.7"), false}, + {mustPrefix("9.8.7.6/32"), mustIP("9.8.7.7"), false}, + {mustPrefix("::1/0"), mustIP("::1"), true}, + {mustPrefix("::1/0"), mustIP("::2"), true}, + {mustPrefix("::1/127"), mustIP("::1"), true}, + {mustPrefix("::1/127"), mustIP("::2"), false}, + {mustPrefix("::1/128"), mustIP("::1"), true}, + {mustPrefix("::1/127"), mustIP("::2"), false}, + // zones support + {mustPrefix("::1%a/128"), mustIP("::1"), true}, // prefix zones are stripped... + {mustPrefix("::1%a/128"), mustIP("::1%a"), false}, // but ip zones are not + // invalid IP + {mustPrefix("::1/0"), Addr{}, false}, + {mustPrefix("1.2.3.4/0"), Addr{}, false}, + // invalid Prefix + {Prefix{mustIP("::1"), 129}, mustIP("::1"), false}, + {Prefix{mustIP("1.2.3.4"), 33}, mustIP("1.2.3.4"), false}, + {Prefix{Addr{}, 0}, mustIP("1.2.3.4"), false}, + {Prefix{Addr{}, 32}, mustIP("1.2.3.4"), false}, + {Prefix{Addr{}, 128}, mustIP("::1"), false}, + // wrong IP family + {mustPrefix("::1/0"), mustIP("1.2.3.4"), false}, + {mustPrefix("1.2.3.4/0"), mustIP("::1"), false}, + } + for _, tt := range tests { + got := tt.ipp.Contains(tt.ip) + if got != tt.want { + t.Errorf("(%v).Contains(%v) = %v want %v", tt.ipp, tt.ip, got, tt.want) + } + } +} + +func TestParseIPError(t *testing.T) { + tests := []struct { + ip string + errstr string + }{ + { + ip: "localhost", + }, + { + ip: "500.0.0.1", + errstr: "field has value >255", + }, + { + ip: "::gggg%eth0", + errstr: "must have at least one digit", + }, + { + ip: "fe80::1cc0:3e8c:119f:c2e1%", + errstr: "zone must be a non-empty string", + }, + { + ip: "%eth0", + errstr: "missing IPv6 address", + }, + } + for _, test := range tests { + t.Run(test.ip, func(t *testing.T) { + _, err := ParseAddr(test.ip) + if err == nil { + t.Fatal("no error") + } + if _, ok := err.(parseAddrError); !ok { + t.Errorf("error type is %T, want parseIPError", err) + } + if test.errstr == "" { + test.errstr = "unable to parse IP" + } + if got := err.Error(); !strings.Contains(got, test.errstr) { + t.Errorf("error is missing substring %q: %s", test.errstr, got) + } + }) + } +} + +func TestParseAddrPort(t *testing.T) { + tests := []struct { + in string + want AddrPort + wantErr bool + }{ + {in: "1.2.3.4:1234", want: AddrPort{mustIP("1.2.3.4"), 1234}}, + {in: "1.1.1.1:123456", wantErr: true}, + {in: "1.1.1.1:-123", wantErr: true}, + {in: "[::1]:1234", want: AddrPort{mustIP("::1"), 1234}}, + {in: "[1.2.3.4]:1234", wantErr: true}, + {in: "fe80::1:1234", wantErr: true}, + {in: ":0", wantErr: true}, // if we need to parse this form, there should be a separate function that explicitly allows it + } + for _, test := range tests { + t.Run(test.in, func(t *testing.T) { + got, err := ParseAddrPort(test.in) + if err != nil { + if test.wantErr { + return + } + t.Fatal(err) + } + if got != test.want { + t.Errorf("got %v; want %v", got, test.want) + } + if got.String() != test.in { + t.Errorf("String = %q; want %q", got.String(), test.in) + } + }) + + t.Run(test.in+"/AppendTo", func(t *testing.T) { + got, err := ParseAddrPort(test.in) + if err == nil { + testAppendToMarshal(t, got) + } + }) + + // TextMarshal and TextUnmarshal mostly behave like + // ParseAddrPort and String. Divergent behavior are handled in + // TestAddrPortMarshalUnmarshal. + t.Run(test.in+"/Marshal", func(t *testing.T) { + var got AddrPort + jsin := `"` + test.in + `"` + err := json.Unmarshal([]byte(jsin), &got) + if err != nil { + if test.wantErr { + return + } + t.Fatal(err) + } + if got != test.want { + t.Errorf("got %v; want %v", got, test.want) + } + gotb, err := json.Marshal(got) + if err != nil { + t.Fatal(err) + } + if string(gotb) != jsin { + t.Errorf("Marshal = %q; want %q", string(gotb), jsin) + } + }) + } +} + +func TestAddrPortMarshalUnmarshal(t *testing.T) { + tests := []struct { + in string + want AddrPort + }{ + {"", AddrPort{}}, + } + + for _, test := range tests { + t.Run(test.in, func(t *testing.T) { + orig := `"` + test.in + `"` + + var ipp AddrPort + if err := json.Unmarshal([]byte(orig), &ipp); err != nil { + t.Fatalf("failed to unmarshal: %v", err) + } + + ippb, err := json.Marshal(ipp) + if err != nil { + t.Fatalf("failed to marshal: %v", err) + } + + back := string(ippb) + if orig != back { + t.Errorf("Marshal = %q; want %q", back, orig) + } + + testAppendToMarshal(t, ipp) + }) + } +} + +type appendMarshaler interface { + encoding.TextMarshaler + AppendTo([]byte) []byte +} + +// testAppendToMarshal tests that x's AppendTo and MarshalText methods yield the same results. +// x's MarshalText method must not return an error. +func testAppendToMarshal(t *testing.T, x appendMarshaler) { + t.Helper() + m, err := x.MarshalText() + if err != nil { + t.Fatalf("(%v).MarshalText: %v", x, err) + } + a := make([]byte, 0, len(m)) + a = x.AppendTo(a) + if !bytes.Equal(m, a) { + t.Errorf("(%v).MarshalText = %q, (%v).AppendTo = %q", x, m, x, a) + } +} + +func TestIPv6Accessor(t *testing.T) { + var a [16]byte + for i := range a { + a[i] = uint8(i) + 1 + } + ip := AddrFrom16(a) + for i := range a { + if got, want := ip.v6(uint8(i)), uint8(i)+1; got != want { + t.Errorf("v6(%v) = %v; want %v", i, got, want) + } + } +} diff --git a/src/net/netip/netip_test.go b/src/net/netip/netip_test.go new file mode 100644 index 0000000000..5d935c8fd3 --- /dev/null +++ b/src/net/netip/netip_test.go @@ -0,0 +1,1798 @@ +// Copyright 2020 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 netip_test + +import ( + "bytes" + "encoding/json" + "flag" + "fmt" + "internal/intern" + "net" + . "net/netip" + "reflect" + "sort" + "strings" + "testing" +) + +var long = flag.Bool("long", false, "run long tests") + +type uint128 = Uint128 + +var ( + mustPrefix = MustParsePrefix + mustIP = MustParseAddr +) + +func TestParseAddr(t *testing.T) { + var validIPs = []struct { + in string + ip Addr // output of ParseAddr() + str string // output of String(). If "", use in. + }{ + // Basic zero IPv4 address. + { + in: "0.0.0.0", + ip: MkAddr(Mk128(0, 0xffff00000000), Z4), + }, + // Basic non-zero IPv4 address. + { + in: "192.168.140.255", + ip: MkAddr(Mk128(0, 0xffffc0a88cff), Z4), + }, + // IPv4 address in windows-style "print all the digits" form. + { + in: "010.000.015.001", + ip: MkAddr(Mk128(0, 0xffff0a000f01), Z4), + str: "10.0.15.1", + }, + // IPv4 address with a silly amount of leading zeros. + { + in: "000001.00000002.00000003.000000004", + ip: MkAddr(Mk128(0, 0xffff01020304), Z4), + str: "1.2.3.4", + }, + // Basic zero IPv6 address. + { + in: "::", + ip: MkAddr(Mk128(0, 0), Z6noz), + }, + // Localhost IPv6. + { + in: "::1", + ip: MkAddr(Mk128(0, 1), Z6noz), + }, + // Fully expanded IPv6 address. + { + in: "fd7a:115c:a1e0:ab12:4843:cd96:626b:430b", + ip: MkAddr(Mk128(0xfd7a115ca1e0ab12, 0x4843cd96626b430b), Z6noz), + }, + // IPv6 with elided fields in the middle. + { + in: "fd7a:115c::626b:430b", + ip: MkAddr(Mk128(0xfd7a115c00000000, 0x00000000626b430b), Z6noz), + }, + // IPv6 with elided fields at the end. + { + in: "fd7a:115c:a1e0:ab12:4843:cd96::", + ip: MkAddr(Mk128(0xfd7a115ca1e0ab12, 0x4843cd9600000000), Z6noz), + }, + // IPv6 with single elided field at the end. + { + in: "fd7a:115c:a1e0:ab12:4843:cd96:626b::", + ip: MkAddr(Mk128(0xfd7a115ca1e0ab12, 0x4843cd96626b0000), Z6noz), + str: "fd7a:115c:a1e0:ab12:4843:cd96:626b:0", + }, + // IPv6 with single elided field in the middle. + { + in: "fd7a:115c:a1e0::4843:cd96:626b:430b", + ip: MkAddr(Mk128(0xfd7a115ca1e00000, 0x4843cd96626b430b), Z6noz), + str: "fd7a:115c:a1e0:0:4843:cd96:626b:430b", + }, + // IPv6 with the trailing 32 bits written as IPv4 dotted decimal. (4in6) + { + in: "::ffff:192.168.140.255", + ip: MkAddr(Mk128(0, 0x0000ffffc0a88cff), Z6noz), + str: "::ffff:192.168.140.255", + }, + // IPv6 with a zone specifier. + { + in: "fd7a:115c:a1e0:ab12:4843:cd96:626b:430b%eth0", + ip: MkAddr(Mk128(0xfd7a115ca1e0ab12, 0x4843cd96626b430b), intern.Get("eth0")), + }, + // IPv6 with dotted decimal and zone specifier. + { + in: "1:2::ffff:192.168.140.255%eth1", + ip: MkAddr(Mk128(0x0001000200000000, 0x0000ffffc0a88cff), intern.Get("eth1")), + str: "1:2::ffff:c0a8:8cff%eth1", + }, + // IPv6 with capital letters. + { + in: "FD9E:1A04:F01D::1", + ip: MkAddr(Mk128(0xfd9e1a04f01d0000, 0x1), Z6noz), + str: "fd9e:1a04:f01d::1", + }, + } + + for _, test := range validIPs { + t.Run(test.in, func(t *testing.T) { + got, err := ParseAddr(test.in) + if err != nil { + t.Fatal(err) + } + if got != test.ip { + t.Errorf("ParseAddr(%q) got %#v, want %#v", test.in, got, test.ip) + } + + // Check that ParseAddr is a pure function. + got2, err := ParseAddr(test.in) + if err != nil { + t.Fatal(err) + } + if got != got2 { + t.Errorf("ParseAddr(%q) got 2 different results: %#v, %#v", test.in, got, got2) + } + + // Check that ParseAddr(ip.String()) is the identity function. + s := got.String() + got3, err := ParseAddr(s) + if err != nil { + t.Fatal(err) + } + if got != got3 { + t.Errorf("ParseAddr(%q) != ParseAddr(ParseIP(%q).String()). Got %#v, want %#v", test.in, test.in, got3, got) + } + + // Check that the slow-but-readable parser produces the same result. + slow, err := parseIPSlow(test.in) + if err != nil { + t.Fatal(err) + } + if got != slow { + t.Errorf("ParseAddr(%q) = %#v, parseIPSlow(%q) = %#v", test.in, got, test.in, slow) + } + + // Check that the parsed IP formats as expected. + s = got.String() + wants := test.str + if wants == "" { + wants = test.in + } + if s != wants { + t.Errorf("ParseAddr(%q).String() got %q, want %q", test.in, s, wants) + } + + // Check that AppendTo matches MarshalText. + TestAppendToMarshal(t, got) + + // Check that MarshalText/UnmarshalText work similarly to + // ParseAddr/String (see TestIPMarshalUnmarshal for + // marshal-specific behavior that's not common with + // ParseAddr/String). + js := `"` + test.in + `"` + var jsgot Addr + if err := json.Unmarshal([]byte(js), &jsgot); err != nil { + t.Fatal(err) + } + if jsgot != got { + t.Errorf("json.Unmarshal(%q) = %#v, want %#v", test.in, jsgot, got) + } + jsb, err := json.Marshal(jsgot) + if err != nil { + t.Fatal(err) + } + jswant := `"` + wants + `"` + jsback := string(jsb) + if jsback != jswant { + t.Errorf("Marshal(Unmarshal(%q)) = %s, want %s", test.in, jsback, jswant) + } + }) + } + + var invalidIPs = []string{ + // Empty string + "", + // Garbage non-IP + "bad", + // Single number. Some parsers accept this as an IPv4 address in + // big-endian uint32 form, but we don't. + "1234", + // IPv4 with a zone specifier + "1.2.3.4%eth0", + // IPv4 field must have at least one digit + ".1.2.3", + "1.2.3.", + "1..2.3", + // IPv4 address too long + "1.2.3.4.5", + // IPv4 in dotted octal form + "0300.0250.0214.0377", + // IPv4 in dotted hex form + "0xc0.0xa8.0x8c.0xff", + // IPv4 in class B form + "192.168.12345", + // IPv4 in class B form, with a small enough number to be + // parseable as a regular dotted decimal field. + "127.0.1", + // IPv4 in class A form + "192.1234567", + // IPv4 in class A form, with a small enough number to be + // parseable as a regular dotted decimal field. + "127.1", + // IPv4 field has value >255 + "192.168.300.1", + // IPv4 with too many fields + "192.168.0.1.5.6", + // IPv6 with not enough fields + "1:2:3:4:5:6:7", + // IPv6 with too many fields + "1:2:3:4:5:6:7:8:9", + // IPv6 with 8 fields and a :: expander + "1:2:3:4::5:6:7:8", + // IPv6 with a field bigger than 2b + "fe801::1", + // IPv6 with non-hex values in field + "fe80:tail:scal:e::", + // IPv6 with a zone delimiter but no zone. + "fe80::1%", + // IPv6 (without ellipsis) with too many fields for trailing embedded IPv4. + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:192.168.140.255", + // IPv6 (with ellipsis) with too many fields for trailing embedded IPv4. + "ffff::ffff:ffff:ffff:ffff:ffff:ffff:192.168.140.255", + // IPv6 with invalid embedded IPv4. + "::ffff:192.168.140.bad", + // IPv6 with multiple ellipsis ::. + "fe80::1::1", + // IPv6 with invalid non hex/colon character. + "fe80:1?:1", + // IPv6 with truncated bytes after single colon. + "fe80:", + } + + for _, s := range invalidIPs { + t.Run(s, func(t *testing.T) { + got, err := ParseAddr(s) + if err == nil { + t.Errorf("ParseAddr(%q) = %#v, want error", s, got) + } + + slow, err := parseIPSlow(s) + if err == nil { + t.Errorf("parseIPSlow(%q) = %#v, want error", s, slow) + } + + std := net.ParseIP(s) + if std != nil { + t.Errorf("net.ParseIP(%q) = %#v, want error", s, std) + } + + if s == "" { + // Don't test unmarshaling of "" here, do it in + // IPMarshalUnmarshal. + return + } + var jsgot Addr + js := []byte(`"` + s + `"`) + if err := json.Unmarshal(js, &jsgot); err == nil { + t.Errorf("json.Unmarshal(%q) = %#v, want error", s, jsgot) + } + }) + } +} + +func TestIPv4Constructors(t *testing.T) { + if AddrFrom4([4]byte{1, 2, 3, 4}) != MustParseAddr("1.2.3.4") { + t.Errorf("don't match") + } +} + +func TestAddrMarshalUnmarshalBinary(t *testing.T) { + tests := []struct { + ip string + wantSize int + }{ + {"", 0}, // zero IP + {"1.2.3.4", 4}, + {"fd7a:115c:a1e0:ab12:4843:cd96:626b:430b", 16}, + {"::ffff:c000:0280", 16}, + {"::ffff:c000:0280%eth0", 20}, + } + for _, tc := range tests { + var ip Addr + if len(tc.ip) > 0 { + ip = mustIP(tc.ip) + } + b, err := ip.MarshalBinary() + if err != nil { + t.Fatal(err) + } + if len(b) != tc.wantSize { + t.Fatalf("%q encoded to size %d; want %d", tc.ip, len(b), tc.wantSize) + } + var ip2 Addr + if err := ip2.UnmarshalBinary(b); err != nil { + t.Fatal(err) + } + if ip != ip2 { + t.Fatalf("got %v; want %v", ip2, ip) + } + } + + // Cannot unmarshal from unexpected IP length. + for _, l := range []int{3, 5} { + var ip2 Addr + if err := ip2.UnmarshalBinary(bytes.Repeat([]byte{1}, l)); err == nil { + t.Fatalf("unmarshaled from unexpected IP length %d", l) + } + } +} + +func TestAddrMarshalUnmarshal(t *testing.T) { + // This only tests the cases where Marshal/Unmarshal diverges from + // the behavior of ParseAddr/String. For the rest of the test cases, + // see TestParseAddr above. + orig := `""` + var ip Addr + if err := json.Unmarshal([]byte(orig), &ip); err != nil { + t.Fatalf("Unmarshal(%q) got error %v", orig, err) + } + if ip != (Addr{}) { + t.Errorf("Unmarshal(%q) is not the zero Addr", orig) + } + + jsb, err := json.Marshal(ip) + if err != nil { + t.Fatalf("Marshal(%v) got error %v", ip, err) + } + back := string(jsb) + if back != orig { + t.Errorf("Marshal(Unmarshal(%q)) got %q, want %q", orig, back, orig) + } +} + +func TestAddrFrom16(t *testing.T) { + tests := []struct { + name string + in [16]byte + want Addr + }{ + { + name: "v6-raw", + in: [...]byte{15: 1}, + want: MkAddr(Mk128(0, 1), Z6noz), + }, + { + name: "v4-raw", + in: [...]byte{10: 0xff, 11: 0xff, 12: 1, 13: 2, 14: 3, 15: 4}, + want: MkAddr(Mk128(0, 0xffff01020304), Z6noz), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := AddrFrom16(tt.in) + if got != tt.want { + t.Errorf("got %#v; want %#v", got, tt.want) + } + }) + } +} + +func TestIPProperties(t *testing.T) { + var ( + nilIP Addr + + unicast4 = mustIP("192.0.2.1") + unicast6 = mustIP("2001:db8::1") + unicastZone6 = mustIP("2001:db8::1%eth0") + unicast6Unassigned = mustIP("4000::1") // not in 2000::/3. + + multicast4 = mustIP("224.0.0.1") + multicast6 = mustIP("ff02::1") + multicastZone6 = mustIP("ff02::1%eth0") + + llu4 = mustIP("169.254.0.1") + llu6 = mustIP("fe80::1") + llu6Last = mustIP("febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff") + lluZone6 = mustIP("fe80::1%eth0") + + loopback4 = mustIP("127.0.0.1") + loopback6 = mustIP("::1") + + ilm6 = mustIP("ff01::1") + ilmZone6 = mustIP("ff01::1%eth0") + + private4a = mustIP("10.0.0.1") + private4b = mustIP("172.16.0.1") + private4c = mustIP("192.168.1.1") + private6 = mustIP("fd00::1") + + unspecified4 = AddrFrom4([4]byte{}) + unspecified6 = IPv6Unspecified() + ) + + tests := []struct { + name string + ip Addr + globalUnicast bool + interfaceLocalMulticast bool + linkLocalMulticast bool + linkLocalUnicast bool + loopback bool + multicast bool + private bool + unspecified bool + }{ + { + name: "nil", + ip: nilIP, + }, + { + name: "unicast v4Addr", + ip: unicast4, + globalUnicast: true, + }, + { + name: "unicast v6Addr", + ip: unicast6, + globalUnicast: true, + }, + { + name: "unicast v6AddrZone", + ip: unicastZone6, + globalUnicast: true, + }, + { + name: "unicast v6Addr unassigned", + ip: unicast6Unassigned, + globalUnicast: true, + }, + { + name: "multicast v4Addr", + ip: multicast4, + linkLocalMulticast: true, + multicast: true, + }, + { + name: "multicast v6Addr", + ip: multicast6, + linkLocalMulticast: true, + multicast: true, + }, + { + name: "multicast v6AddrZone", + ip: multicastZone6, + linkLocalMulticast: true, + multicast: true, + }, + { + name: "link-local unicast v4Addr", + ip: llu4, + linkLocalUnicast: true, + }, + { + name: "link-local unicast v6Addr", + ip: llu6, + linkLocalUnicast: true, + }, + { + name: "link-local unicast v6Addr upper bound", + ip: llu6Last, + linkLocalUnicast: true, + }, + { + name: "link-local unicast v6AddrZone", + ip: lluZone6, + linkLocalUnicast: true, + }, + { + name: "loopback v4Addr", + ip: loopback4, + loopback: true, + }, + { + name: "loopback v6Addr", + ip: loopback6, + loopback: true, + }, + { + name: "interface-local multicast v6Addr", + ip: ilm6, + interfaceLocalMulticast: true, + multicast: true, + }, + { + name: "interface-local multicast v6AddrZone", + ip: ilmZone6, + interfaceLocalMulticast: true, + multicast: true, + }, + { + name: "private v4Addr 10/8", + ip: private4a, + globalUnicast: true, + private: true, + }, + { + name: "private v4Addr 172.16/12", + ip: private4b, + globalUnicast: true, + private: true, + }, + { + name: "private v4Addr 192.168/16", + ip: private4c, + globalUnicast: true, + private: true, + }, + { + name: "private v6Addr", + ip: private6, + globalUnicast: true, + private: true, + }, + { + name: "unspecified v4Addr", + ip: unspecified4, + unspecified: true, + }, + { + name: "unspecified v6Addr", + ip: unspecified6, + unspecified: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gu := tt.ip.IsGlobalUnicast() + if gu != tt.globalUnicast { + t.Errorf("IsGlobalUnicast(%v) = %v; want %v", tt.ip, gu, tt.globalUnicast) + } + + ilm := tt.ip.IsInterfaceLocalMulticast() + if ilm != tt.interfaceLocalMulticast { + t.Errorf("IsInterfaceLocalMulticast(%v) = %v; want %v", tt.ip, ilm, tt.interfaceLocalMulticast) + } + + llu := tt.ip.IsLinkLocalUnicast() + if llu != tt.linkLocalUnicast { + t.Errorf("IsLinkLocalUnicast(%v) = %v; want %v", tt.ip, llu, tt.linkLocalUnicast) + } + + llm := tt.ip.IsLinkLocalMulticast() + if llm != tt.linkLocalMulticast { + t.Errorf("IsLinkLocalMulticast(%v) = %v; want %v", tt.ip, llm, tt.linkLocalMulticast) + } + + lo := tt.ip.IsLoopback() + if lo != tt.loopback { + t.Errorf("IsLoopback(%v) = %v; want %v", tt.ip, lo, tt.loopback) + } + + multicast := tt.ip.IsMulticast() + if multicast != tt.multicast { + t.Errorf("IsMulticast(%v) = %v; want %v", tt.ip, multicast, tt.multicast) + } + + private := tt.ip.IsPrivate() + if private != tt.private { + t.Errorf("IsPrivate(%v) = %v; want %v", tt.ip, private, tt.private) + } + + unspecified := tt.ip.IsUnspecified() + if unspecified != tt.unspecified { + t.Errorf("IsUnspecified(%v) = %v; want %v", tt.ip, unspecified, tt.unspecified) + } + }) + } +} + +func TestAddrWellKnown(t *testing.T) { + tests := []struct { + name string + ip Addr + std net.IP + }{ + { + name: "IPv6 link-local all nodes", + ip: IPv6LinkLocalAllNodes(), + std: net.IPv6linklocalallnodes, + }, + { + name: "IPv6 unspecified", + ip: IPv6Unspecified(), + std: net.IPv6unspecified, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + want := tt.std.String() + got := tt.ip.String() + + if got != want { + t.Fatalf("got %s, want %s", got, want) + } + }) + } +} + +func TestLessCompare(t *testing.T) { + tests := []struct { + a, b Addr + want bool + }{ + {Addr{}, Addr{}, false}, + {Addr{}, mustIP("1.2.3.4"), true}, + {mustIP("1.2.3.4"), Addr{}, false}, + + {mustIP("1.2.3.4"), mustIP("0102:0304::0"), true}, + {mustIP("0102:0304::0"), mustIP("1.2.3.4"), false}, + {mustIP("1.2.3.4"), mustIP("1.2.3.4"), false}, + + {mustIP("::1"), mustIP("::2"), true}, + {mustIP("::1"), mustIP("::1%foo"), true}, + {mustIP("::1%foo"), mustIP("::2"), true}, + {mustIP("::2"), mustIP("::3"), true}, + + {mustIP("::"), mustIP("0.0.0.0"), false}, + {mustIP("0.0.0.0"), mustIP("::"), true}, + + {mustIP("::1%a"), mustIP("::1%b"), true}, + {mustIP("::1%a"), mustIP("::1%a"), false}, + {mustIP("::1%b"), mustIP("::1%a"), false}, + } + for _, tt := range tests { + got := tt.a.Less(tt.b) + if got != tt.want { + t.Errorf("Less(%q, %q) = %v; want %v", tt.a, tt.b, got, tt.want) + } + cmp := tt.a.Compare(tt.b) + if got && cmp != -1 { + t.Errorf("Less(%q, %q) = true, but Compare = %v (not -1)", tt.a, tt.b, cmp) + } + if cmp < -1 || cmp > 1 { + t.Errorf("bogus Compare return value %v", cmp) + } + if cmp == 0 && tt.a != tt.b { + t.Errorf("Compare(%q, %q) = 0; but not equal", tt.a, tt.b) + } + if cmp == 1 && !tt.b.Less(tt.a) { + t.Errorf("Compare(%q, %q) = 1; but b.Less(a) isn't true", tt.a, tt.b) + } + + // Also check inverse. + if got == tt.want && got { + got2 := tt.b.Less(tt.a) + if got2 { + t.Errorf("Less(%q, %q) was correctly %v, but so was Less(%q, %q)", tt.a, tt.b, got, tt.b, tt.a) + } + } + } + + // And just sort. + values := []Addr{ + mustIP("::1"), + mustIP("::2"), + Addr{}, + mustIP("1.2.3.4"), + mustIP("8.8.8.8"), + mustIP("::1%foo"), + } + sort.Slice(values, func(i, j int) bool { return values[i].Less(values[j]) }) + got := fmt.Sprintf("%s", values) + want := `[invalid IP 1.2.3.4 8.8.8.8 ::1 ::1%foo ::2]` + if got != want { + t.Errorf("unexpected sort\n got: %s\nwant: %s\n", got, want) + } +} + +func TestIPStringExpanded(t *testing.T) { + tests := []struct { + ip Addr + s string + }{ + { + ip: Addr{}, + s: "invalid IP", + }, + { + ip: mustIP("192.0.2.1"), + s: "192.0.2.1", + }, + { + ip: mustIP("::ffff:192.0.2.1"), + s: "0000:0000:0000:0000:0000:ffff:c000:0201", + }, + { + ip: mustIP("2001:db8::1"), + s: "2001:0db8:0000:0000:0000:0000:0000:0001", + }, + { + ip: mustIP("2001:db8::1%eth0"), + s: "2001:0db8:0000:0000:0000:0000:0000:0001%eth0", + }, + } + + for _, tt := range tests { + t.Run(tt.ip.String(), func(t *testing.T) { + want := tt.s + got := tt.ip.StringExpanded() + + if got != want { + t.Fatalf("got %s, want %s", got, want) + } + }) + } +} + +func TestPrefixMasking(t *testing.T) { + type subtest struct { + ip Addr + bits uint8 + p Prefix + ok bool + } + + // makeIPv6 produces a set of IPv6 subtests with an optional zone identifier. + makeIPv6 := func(zone string) []subtest { + if zone != "" { + zone = "%" + zone + } + + return []subtest{ + { + ip: mustIP(fmt.Sprintf("2001:db8::1%s", zone)), + bits: 255, + }, + { + ip: mustIP(fmt.Sprintf("2001:db8::1%s", zone)), + bits: 32, + p: mustPrefix(fmt.Sprintf("2001:db8::%s/32", zone)), + ok: true, + }, + { + ip: mustIP(fmt.Sprintf("fe80::dead:beef:dead:beef%s", zone)), + bits: 96, + p: mustPrefix(fmt.Sprintf("fe80::dead:beef:0:0%s/96", zone)), + ok: true, + }, + { + ip: mustIP(fmt.Sprintf("aaaa::%s", zone)), + bits: 4, + p: mustPrefix(fmt.Sprintf("a000::%s/4", zone)), + ok: true, + }, + { + ip: mustIP(fmt.Sprintf("::%s", zone)), + bits: 63, + p: mustPrefix(fmt.Sprintf("::%s/63", zone)), + ok: true, + }, + } + } + + tests := []struct { + family string + subtests []subtest + }{ + { + family: "nil", + subtests: []subtest{ + { + bits: 255, + ok: true, + }, + { + bits: 16, + ok: true, + }, + }, + }, + { + family: "IPv4", + subtests: []subtest{ + { + ip: mustIP("192.0.2.0"), + bits: 255, + }, + { + ip: mustIP("192.0.2.0"), + bits: 16, + p: mustPrefix("192.0.0.0/16"), + ok: true, + }, + { + ip: mustIP("255.255.255.255"), + bits: 20, + p: mustPrefix("255.255.240.0/20"), + ok: true, + }, + { + // Partially masking one byte that contains both + // 1s and 0s on either side of the mask limit. + ip: mustIP("100.98.156.66"), + bits: 10, + p: mustPrefix("100.64.0.0/10"), + ok: true, + }, + }, + }, + { + family: "IPv6", + subtests: makeIPv6(""), + }, + { + family: "IPv6 zone", + subtests: makeIPv6("eth0"), + }, + } + + for _, tt := range tests { + t.Run(tt.family, func(t *testing.T) { + for _, st := range tt.subtests { + t.Run(st.p.String(), func(t *testing.T) { + // Ensure st.ip is not mutated. + orig := st.ip.String() + + p, err := st.ip.Prefix(int(st.bits)) + if st.ok && err != nil { + t.Fatalf("failed to produce prefix: %v", err) + } + if !st.ok && err == nil { + t.Fatal("expected an error, but none occurred") + } + if err != nil { + t.Logf("err: %v", err) + return + } + + if !reflect.DeepEqual(p, st.p) { + t.Errorf("prefix = %q, want %q", p, st.p) + } + + if got := st.ip.String(); got != orig { + t.Errorf("IP was mutated: %q, want %q", got, orig) + } + }) + } + }) + } +} + +func TestPrefixMarshalUnmarshal(t *testing.T) { + tests := []string{ + "", + "1.2.3.4/32", + "0.0.0.0/0", + "::/0", + "::1/128", + "::ffff:c000:1234/128", + "2001:db8::/32", + } + + for _, s := range tests { + t.Run(s, func(t *testing.T) { + // Ensure that JSON (and by extension, text) marshaling is + // sane by entering quoted input. + orig := `"` + s + `"` + + var p Prefix + if err := json.Unmarshal([]byte(orig), &p); err != nil { + t.Fatalf("failed to unmarshal: %v", err) + } + + pb, err := json.Marshal(p) + if err != nil { + t.Fatalf("failed to marshal: %v", err) + } + + back := string(pb) + if orig != back { + t.Errorf("Marshal = %q; want %q", back, orig) + } + }) + } +} + +func TestPrefixMarshalUnmarshalZone(t *testing.T) { + orig := `"fe80::1cc0:3e8c:119f:c2e1%ens18/128"` + unzoned := `"fe80::1cc0:3e8c:119f:c2e1/128"` + + var p Prefix + if err := json.Unmarshal([]byte(orig), &p); err != nil { + t.Fatalf("failed to unmarshal: %v", err) + } + + pb, err := json.Marshal(p) + if err != nil { + t.Fatalf("failed to marshal: %v", err) + } + + back := string(pb) + if back != unzoned { + t.Errorf("Marshal = %q; want %q", back, unzoned) + } +} + +func TestPrefixUnmarshalTextNonZero(t *testing.T) { + ip := mustPrefix("fe80::/64") + if err := ip.UnmarshalText([]byte("xxx")); err == nil { + t.Fatal("unmarshaled into non-empty Prefix") + } +} + +func TestIs4AndIs6(t *testing.T) { + tests := []struct { + ip Addr + is4 bool + is6 bool + }{ + {Addr{}, false, false}, + {mustIP("1.2.3.4"), true, false}, + {mustIP("127.0.0.2"), true, false}, + {mustIP("::1"), false, true}, + {mustIP("::ffff:192.0.2.128"), false, true}, + {mustIP("::fffe:c000:0280"), false, true}, + {mustIP("::1%eth0"), false, true}, + } + for _, tt := range tests { + got4 := tt.ip.Is4() + if got4 != tt.is4 { + t.Errorf("Is4(%q) = %v; want %v", tt.ip, got4, tt.is4) + } + + got6 := tt.ip.Is6() + if got6 != tt.is6 { + t.Errorf("Is6(%q) = %v; want %v", tt.ip, got6, tt.is6) + } + } +} + +func TestIs4In6(t *testing.T) { + tests := []struct { + ip Addr + want bool + wantUnmap Addr + }{ + {Addr{}, false, Addr{}}, + {mustIP("::ffff:c000:0280"), true, mustIP("192.0.2.128")}, + {mustIP("::ffff:192.0.2.128"), true, mustIP("192.0.2.128")}, + {mustIP("::ffff:192.0.2.128%eth0"), true, mustIP("192.0.2.128")}, + {mustIP("::fffe:c000:0280"), false, mustIP("::fffe:c000:0280")}, + {mustIP("::ffff:127.001.002.003"), true, mustIP("127.1.2.3")}, + {mustIP("::ffff:7f01:0203"), true, mustIP("127.1.2.3")}, + {mustIP("0:0:0:0:0000:ffff:127.1.2.3"), true, mustIP("127.1.2.3")}, + {mustIP("0:0:0:0:000000:ffff:127.1.2.3"), true, mustIP("127.1.2.3")}, + {mustIP("0:0:0:0::ffff:127.1.2.3"), true, mustIP("127.1.2.3")}, + {mustIP("::1"), false, mustIP("::1")}, + {mustIP("1.2.3.4"), false, mustIP("1.2.3.4")}, + } + for _, tt := range tests { + got := tt.ip.Is4In6() + if got != tt.want { + t.Errorf("Is4In6(%q) = %v; want %v", tt.ip, got, tt.want) + } + u := tt.ip.Unmap() + if u != tt.wantUnmap { + t.Errorf("Unmap(%q) = %v; want %v", tt.ip, u, tt.wantUnmap) + } + } +} + +func TestPrefixMasked(t *testing.T) { + tests := []struct { + prefix Prefix + masked Prefix + }{ + { + prefix: mustPrefix("192.168.0.255/24"), + masked: mustPrefix("192.168.0.0/24"), + }, + { + prefix: mustPrefix("2100::/3"), + masked: mustPrefix("2000::/3"), + }, + { + prefix: PrefixFrom(mustIP("2000::"), 129), + masked: Prefix{}, + }, + { + prefix: PrefixFrom(mustIP("1.2.3.4"), 33), + masked: Prefix{}, + }, + } + for _, test := range tests { + t.Run(test.prefix.String(), func(t *testing.T) { + got := test.prefix.Masked() + if got != test.masked { + t.Errorf("Masked=%s, want %s", got, test.masked) + } + }) + } +} + +func TestPrefix(t *testing.T) { + tests := []struct { + prefix string + ip Addr + bits int + str string + contains []Addr + notContains []Addr + }{ + { + prefix: "192.168.0.0/24", + ip: mustIP("192.168.0.0"), + bits: 24, + contains: mustIPs("192.168.0.1", "192.168.0.55"), + notContains: mustIPs("192.168.1.1", "1.1.1.1"), + }, + { + prefix: "192.168.1.1/32", + ip: mustIP("192.168.1.1"), + bits: 32, + contains: mustIPs("192.168.1.1"), + notContains: mustIPs("192.168.1.2"), + }, + { + prefix: "100.64.0.0/10", // CGNAT range; prefix not multiple of 8 + ip: mustIP("100.64.0.0"), + bits: 10, + contains: mustIPs("100.64.0.0", "100.64.0.1", "100.81.251.94", "100.100.100.100", "100.127.255.254", "100.127.255.255"), + notContains: mustIPs("100.63.255.255", "100.128.0.0"), + }, + { + prefix: "2001:db8::/96", + ip: mustIP("2001:db8::"), + bits: 96, + contains: mustIPs("2001:db8::aaaa:bbbb", "2001:db8::1"), + notContains: mustIPs("2001:db8::1:aaaa:bbbb", "2001:db9::"), + }, + { + prefix: "0.0.0.0/0", + ip: mustIP("0.0.0.0"), + bits: 0, + contains: mustIPs("192.168.0.1", "1.1.1.1"), + notContains: append(mustIPs("2001:db8::1"), Addr{}), + }, + { + prefix: "::/0", + ip: mustIP("::"), + bits: 0, + contains: mustIPs("::1", "2001:db8::1"), + notContains: mustIPs("192.0.2.1"), + }, + { + prefix: "2000::/3", + ip: mustIP("2000::"), + bits: 3, + contains: mustIPs("2001:db8::1"), + notContains: mustIPs("fe80::1"), + }, + { + prefix: "::%0/00/80", + ip: mustIP("::"), + bits: 80, + str: "::/80", + contains: mustIPs("::"), + notContains: mustIPs("ff::%0/00", "ff::%1/23", "::%0/00", "::%1/23"), + }, + } + for _, test := range tests { + t.Run(test.prefix, func(t *testing.T) { + prefix, err := ParsePrefix(test.prefix) + if err != nil { + t.Fatal(err) + } + if prefix.Addr() != test.ip { + t.Errorf("IP=%s, want %s", prefix.Addr(), test.ip) + } + if prefix.Bits() != test.bits { + t.Errorf("bits=%d, want %d", prefix.Bits(), test.bits) + } + for _, ip := range test.contains { + if !prefix.Contains(ip) { + t.Errorf("does not contain %s", ip) + } + } + for _, ip := range test.notContains { + if prefix.Contains(ip) { + t.Errorf("contains %s", ip) + } + } + want := test.str + if want == "" { + want = test.prefix + } + if got := prefix.String(); got != want { + t.Errorf("prefix.String()=%q, want %q", got, want) + } + + TestAppendToMarshal(t, prefix) + }) + } +} + +func TestPrefixFromInvalidBits(t *testing.T) { + v4 := MustParseAddr("1.2.3.4") + v6 := MustParseAddr("66::66") + tests := []struct { + ip Addr + in, want int + }{ + {v4, 0, 0}, + {v6, 0, 0}, + {v4, 1, 1}, + {v4, 33, -1}, + {v6, 33, 33}, + {v6, 127, 127}, + {v6, 128, 128}, + {v4, 254, -1}, + {v4, 255, -1}, + {v4, -1, -1}, + {v6, -1, -1}, + {v4, -5, -1}, + {v6, -5, -1}, + } + for _, tt := range tests { + p := PrefixFrom(tt.ip, tt.in) + if got := p.Bits(); got != tt.want { + t.Errorf("for (%v, %v), Bits out = %v; want %v", tt.ip, tt.in, got, tt.want) + } + } +} + +func TestParsePrefixAllocs(t *testing.T) { + tests := []struct { + ip string + slash string + }{ + {"192.168.1.0", "/24"}, + {"aaaa:bbbb:cccc::", "/24"}, + } + for _, test := range tests { + prefix := test.ip + test.slash + t.Run(prefix, func(t *testing.T) { + ipAllocs := int(testing.AllocsPerRun(5, func() { + ParseAddr(test.ip) + })) + prefixAllocs := int(testing.AllocsPerRun(5, func() { + ParsePrefix(prefix) + })) + if got := prefixAllocs - ipAllocs; got != 0 { + t.Errorf("allocs=%d, want 0", got) + } + }) + } +} + +func TestParsePrefixError(t *testing.T) { + tests := []struct { + prefix string + errstr string + }{ + { + prefix: "192.168.0.0", + errstr: "no '/'", + }, + { + prefix: "1.257.1.1/24", + errstr: "value >255", + }, + { + prefix: "1.1.1.0/q", + errstr: "bad bits", + }, + { + prefix: "1.1.1.0/-1", + errstr: "out of range", + }, + { + prefix: "1.1.1.0/33", + errstr: "out of range", + }, + { + prefix: "2001::/129", + errstr: "out of range", + }, + } + for _, test := range tests { + t.Run(test.prefix, func(t *testing.T) { + _, err := ParsePrefix(test.prefix) + if err == nil { + t.Fatal("no error") + } + if got := err.Error(); !strings.Contains(got, test.errstr) { + t.Errorf("error is missing substring %q: %s", test.errstr, got) + } + }) + } +} + +func TestPrefixIsSingleIP(t *testing.T) { + tests := []struct { + ipp Prefix + want bool + }{ + {ipp: mustPrefix("127.0.0.1/32"), want: true}, + {ipp: mustPrefix("127.0.0.1/31"), want: false}, + {ipp: mustPrefix("127.0.0.1/0"), want: false}, + {ipp: mustPrefix("::1/128"), want: true}, + {ipp: mustPrefix("::1/127"), want: false}, + {ipp: mustPrefix("::1/0"), want: false}, + {ipp: Prefix{}, want: false}, + } + for _, tt := range tests { + got := tt.ipp.IsSingleIP() + if got != tt.want { + t.Errorf("IsSingleIP(%v) = %v want %v", tt.ipp, got, tt.want) + } + } +} + +func mustIPs(strs ...string) []Addr { + var res []Addr + for _, s := range strs { + res = append(res, mustIP(s)) + } + return res +} + +func BenchmarkBinaryMarshalRoundTrip(b *testing.B) { + b.ReportAllocs() + tests := []struct { + name string + ip string + }{ + {"ipv4", "1.2.3.4"}, + {"ipv6", "2001:db8::1"}, + {"ipv6+zone", "2001:db8::1%eth0"}, + } + for _, tc := range tests { + b.Run(tc.name, func(b *testing.B) { + ip := mustIP(tc.ip) + for i := 0; i < b.N; i++ { + bt, err := ip.MarshalBinary() + if err != nil { + b.Fatal(err) + } + var ip2 Addr + if err := ip2.UnmarshalBinary(bt); err != nil { + b.Fatal(err) + } + } + }) + } +} + +func BenchmarkStdIPv4(b *testing.B) { + b.ReportAllocs() + ips := []net.IP{} + for i := 0; i < b.N; i++ { + ip := net.IPv4(8, 8, 8, 8) + ips = ips[:0] + for i := 0; i < 100; i++ { + ips = append(ips, ip) + } + } +} + +func BenchmarkIPv4(b *testing.B) { + b.ReportAllocs() + ips := []Addr{} + for i := 0; i < b.N; i++ { + ip := IPv4(8, 8, 8, 8) + ips = ips[:0] + for i := 0; i < 100; i++ { + ips = append(ips, ip) + } + } +} + +// ip4i was one of the possible representations of IP that came up in +// discussions, inlining IPv4 addresses, but having an "overflow" +// interface for IPv6 or IPv6 + zone. This is here for benchmarking. +type ip4i struct { + ip4 [4]byte + flags1 byte + flags2 byte + flags3 byte + flags4 byte + ipv6 interface{} +} + +func newip4i_v4(a, b, c, d byte) ip4i { + return ip4i{ip4: [4]byte{a, b, c, d}} +} + +// BenchmarkIPv4_inline benchmarks the candidate representation, ip4i. +func BenchmarkIPv4_inline(b *testing.B) { + b.ReportAllocs() + ips := []ip4i{} + for i := 0; i < b.N; i++ { + ip := newip4i_v4(8, 8, 8, 8) + ips = ips[:0] + for i := 0; i < 100; i++ { + ips = append(ips, ip) + } + } +} + +func BenchmarkStdIPv6(b *testing.B) { + b.ReportAllocs() + ips := []net.IP{} + for i := 0; i < b.N; i++ { + ip := net.ParseIP("2001:db8::1") + ips = ips[:0] + for i := 0; i < 100; i++ { + ips = append(ips, ip) + } + } +} + +func BenchmarkIPv6(b *testing.B) { + b.ReportAllocs() + ips := []Addr{} + for i := 0; i < b.N; i++ { + ip := mustIP("2001:db8::1") + ips = ips[:0] + for i := 0; i < 100; i++ { + ips = append(ips, ip) + } + } +} + +func BenchmarkIPv4Contains(b *testing.B) { + b.ReportAllocs() + prefix := PrefixFrom(IPv4(192, 168, 1, 0), 24) + ip := IPv4(192, 168, 1, 1) + for i := 0; i < b.N; i++ { + prefix.Contains(ip) + } +} + +func BenchmarkIPv6Contains(b *testing.B) { + b.ReportAllocs() + prefix := MustParsePrefix("::1/128") + ip := MustParseAddr("::1") + for i := 0; i < b.N; i++ { + prefix.Contains(ip) + } +} + +var parseBenchInputs = []struct { + name string + ip string +}{ + {"v4", "192.168.1.1"}, + {"v6", "fd7a:115c:a1e0:ab12:4843:cd96:626b:430b"}, + {"v6_ellipsis", "fd7a:115c::626b:430b"}, + {"v6_v4", "::ffff:192.168.140.255"}, + {"v6_zone", "1:2::ffff:192.168.140.255%eth1"}, +} + +func BenchmarkParseAddr(b *testing.B) { + sinkInternValue = intern.Get("eth1") // Pin to not benchmark the intern package + for _, test := range parseBenchInputs { + b.Run(test.name, func(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + sinkIP, _ = ParseAddr(test.ip) + } + }) + } +} + +func BenchmarkStdParseIP(b *testing.B) { + for _, test := range parseBenchInputs { + b.Run(test.name, func(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + sinkStdIP = net.ParseIP(test.ip) + } + }) + } +} + +func BenchmarkIPString(b *testing.B) { + for _, test := range parseBenchInputs { + ip := MustParseAddr(test.ip) + b.Run(test.name, func(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + sinkString = ip.String() + } + }) + } +} + +func BenchmarkIPStringExpanded(b *testing.B) { + for _, test := range parseBenchInputs { + ip := MustParseAddr(test.ip) + b.Run(test.name, func(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + sinkString = ip.StringExpanded() + } + }) + } +} + +func BenchmarkIPMarshalText(b *testing.B) { + b.ReportAllocs() + ip := MustParseAddr("66.55.44.33") + for i := 0; i < b.N; i++ { + sinkBytes, _ = ip.MarshalText() + } +} + +func BenchmarkAddrPortString(b *testing.B) { + for _, test := range parseBenchInputs { + ip := MustParseAddr(test.ip) + ipp := AddrPortFrom(ip, 60000) + b.Run(test.name, func(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + sinkString = ipp.String() + } + }) + } +} + +func BenchmarkAddrPortMarshalText(b *testing.B) { + for _, test := range parseBenchInputs { + ip := MustParseAddr(test.ip) + ipp := AddrPortFrom(ip, 60000) + b.Run(test.name, func(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + sinkBytes, _ = ipp.MarshalText() + } + }) + } +} + +func BenchmarkPrefixMasking(b *testing.B) { + tests := []struct { + name string + ip Addr + bits int + }{ + { + name: "IPv4 /32", + ip: IPv4(192, 0, 2, 0), + bits: 32, + }, + { + name: "IPv4 /17", + ip: IPv4(192, 0, 2, 0), + bits: 17, + }, + { + name: "IPv4 /0", + ip: IPv4(192, 0, 2, 0), + bits: 0, + }, + { + name: "IPv6 /128", + ip: mustIP("2001:db8::1"), + bits: 128, + }, + { + name: "IPv6 /65", + ip: mustIP("2001:db8::1"), + bits: 65, + }, + { + name: "IPv6 /0", + ip: mustIP("2001:db8::1"), + bits: 0, + }, + { + name: "IPv6 zone /128", + ip: mustIP("2001:db8::1%eth0"), + bits: 128, + }, + { + name: "IPv6 zone /65", + ip: mustIP("2001:db8::1%eth0"), + bits: 65, + }, + { + name: "IPv6 zone /0", + ip: mustIP("2001:db8::1%eth0"), + bits: 0, + }, + } + + for _, tt := range tests { + b.Run(tt.name, func(b *testing.B) { + b.ReportAllocs() + + for i := 0; i < b.N; i++ { + sinkPrefix, _ = tt.ip.Prefix(tt.bits) + } + }) + } +} + +func BenchmarkPrefixMarshalText(b *testing.B) { + b.ReportAllocs() + ipp := MustParsePrefix("66.55.44.33/22") + for i := 0; i < b.N; i++ { + sinkBytes, _ = ipp.MarshalText() + } +} + +func BenchmarkParseAddrPort(b *testing.B) { + for _, test := range parseBenchInputs { + var ipp string + if strings.HasPrefix(test.name, "v6") { + ipp = fmt.Sprintf("[%s]:1234", test.ip) + } else { + ipp = fmt.Sprintf("%s:1234", test.ip) + } + b.Run(test.name, func(b *testing.B) { + b.ReportAllocs() + + for i := 0; i < b.N; i++ { + sinkAddrPort, _ = ParseAddrPort(ipp) + } + }) + } +} + +func TestAs4(t *testing.T) { + tests := []struct { + ip Addr + want [4]byte + wantPanic bool + }{ + { + ip: mustIP("1.2.3.4"), + want: [4]byte{1, 2, 3, 4}, + }, + { + ip: AddrFrom16(mustIP("1.2.3.4").As16()), // IPv4-in-IPv6 + want: [4]byte{1, 2, 3, 4}, + }, + { + ip: mustIP("0.0.0.0"), + want: [4]byte{0, 0, 0, 0}, + }, + { + ip: Addr{}, + wantPanic: true, + }, + { + ip: mustIP("::1"), + wantPanic: true, + }, + } + as4 := func(ip Addr) (v [4]byte, gotPanic bool) { + defer func() { + if recover() != nil { + gotPanic = true + return + } + }() + v = ip.As4() + return + } + for i, tt := range tests { + got, gotPanic := as4(tt.ip) + if gotPanic != tt.wantPanic { + t.Errorf("%d. panic on %v = %v; want %v", i, tt.ip, gotPanic, tt.wantPanic) + continue + } + if got != tt.want { + t.Errorf("%d. %v = %v; want %v", i, tt.ip, got, tt.want) + } + } +} + +func TestPrefixOverlaps(t *testing.T) { + pfx := mustPrefix + tests := []struct { + a, b Prefix + want bool + }{ + {Prefix{}, pfx("1.2.0.0/16"), false}, // first zero + {pfx("1.2.0.0/16"), Prefix{}, false}, // second zero + {pfx("::0/3"), pfx("0.0.0.0/3"), false}, // different families + + {pfx("1.2.0.0/16"), pfx("1.2.0.0/16"), true}, // equal + + {pfx("1.2.0.0/16"), pfx("1.2.3.0/24"), true}, + {pfx("1.2.3.0/24"), pfx("1.2.0.0/16"), true}, + + {pfx("1.2.0.0/16"), pfx("1.2.3.0/32"), true}, + {pfx("1.2.3.0/32"), pfx("1.2.0.0/16"), true}, + + // Match /0 either order + {pfx("1.2.3.0/32"), pfx("0.0.0.0/0"), true}, + {pfx("0.0.0.0/0"), pfx("1.2.3.0/32"), true}, + + {pfx("1.2.3.0/32"), pfx("5.5.5.5/0"), true}, // normalization not required; /0 means true + + // IPv6 overlapping + {pfx("5::1/128"), pfx("5::0/8"), true}, + {pfx("5::0/8"), pfx("5::1/128"), true}, + + // IPv6 not overlapping + {pfx("1::1/128"), pfx("2::2/128"), false}, + {pfx("0100::0/8"), pfx("::1/128"), false}, + + // v6-mapped v4 should not overlap with IPv4. + {PrefixFrom(AddrFrom16(mustIP("1.2.0.0").As16()), 16), pfx("1.2.3.0/24"), false}, + + // Invalid prefixes + {PrefixFrom(mustIP("1.2.3.4"), 33), pfx("1.2.3.0/24"), false}, + {PrefixFrom(mustIP("2000::"), 129), pfx("2000::/64"), false}, + } + for i, tt := range tests { + if got := tt.a.Overlaps(tt.b); got != tt.want { + t.Errorf("%d. (%v).Overlaps(%v) = %v; want %v", i, tt.a, tt.b, got, tt.want) + } + // Overlaps is commutative + if got := tt.b.Overlaps(tt.a); got != tt.want { + t.Errorf("%d. (%v).Overlaps(%v) = %v; want %v", i, tt.b, tt.a, got, tt.want) + } + } +} + +// Sink variables are here to force the compiler to not elide +// seemingly useless work in benchmarks and allocation tests. If you +// were to just `_ = foo()` within a test function, the compiler could +// correctly deduce that foo() does nothing and doesn't need to be +// called. By writing results to a global variable, we hide that fact +// from the compiler and force it to keep the code under test. +var ( + sinkIP Addr + sinkStdIP net.IP + sinkAddrPort AddrPort + sinkPrefix Prefix + sinkPrefixSlice []Prefix + sinkInternValue *intern.Value + sinkIP16 [16]byte + sinkIP4 [4]byte + sinkBool bool + sinkString string + sinkBytes []byte + sinkUDPAddr = &net.UDPAddr{IP: make(net.IP, 0, 16)} +) + +func TestNoAllocs(t *testing.T) { + // Wrappers that panic on error, to prove that our alloc-free + // methods are returning successfully. + panicIP := func(ip Addr, err error) Addr { + if err != nil { + panic(err) + } + return ip + } + panicPfx := func(pfx Prefix, err error) Prefix { + if err != nil { + panic(err) + } + return pfx + } + panicIPP := func(ipp AddrPort, err error) AddrPort { + if err != nil { + panic(err) + } + return ipp + } + test := func(name string, f func()) { + t.Run(name, func(t *testing.T) { + n := testing.AllocsPerRun(1000, f) + if n != 0 { + t.Fatalf("allocs = %d; want 0", int(n)) + } + }) + } + + // IP constructors + test("IPv4", func() { sinkIP = IPv4(1, 2, 3, 4) }) + test("AddrFrom4", func() { sinkIP = AddrFrom4([4]byte{1, 2, 3, 4}) }) + test("AddrFrom16", func() { sinkIP = AddrFrom16([16]byte{}) }) + test("ParseAddr/4", func() { sinkIP = panicIP(ParseAddr("1.2.3.4")) }) + test("ParseAddr/6", func() { sinkIP = panicIP(ParseAddr("::1")) }) + test("MustParseAddr", func() { sinkIP = MustParseAddr("1.2.3.4") }) + test("IPv6LinkLocalAllNodes", func() { sinkIP = IPv6LinkLocalAllNodes() }) + test("IPv6Unspecified", func() { sinkIP = IPv6Unspecified() }) + + // IP methods + test("IP.IsZero", func() { sinkBool = MustParseAddr("1.2.3.4").IsZero() }) + test("IP.BitLen", func() { sinkBool = MustParseAddr("1.2.3.4").BitLen() == 8 }) + test("IP.Zone/4", func() { sinkBool = MustParseAddr("1.2.3.4").Zone() == "" }) + test("IP.Zone/6", func() { sinkBool = MustParseAddr("fe80::1").Zone() == "" }) + test("IP.Zone/6zone", func() { sinkBool = MustParseAddr("fe80::1%zone").Zone() == "" }) + test("IP.Compare", func() { + a := MustParseAddr("1.2.3.4") + b := MustParseAddr("2.3.4.5") + sinkBool = a.Compare(b) == 0 + }) + test("IP.Less", func() { + a := MustParseAddr("1.2.3.4") + b := MustParseAddr("2.3.4.5") + sinkBool = a.Less(b) + }) + test("IP.Is4", func() { sinkBool = MustParseAddr("1.2.3.4").Is4() }) + test("IP.Is6", func() { sinkBool = MustParseAddr("fe80::1").Is6() }) + test("IP.Is4In6", func() { sinkBool = MustParseAddr("fe80::1").Is4In6() }) + test("IP.Unmap", func() { sinkIP = MustParseAddr("ffff::2.3.4.5").Unmap() }) + test("IP.WithZone", func() { sinkIP = MustParseAddr("fe80::1").WithZone("") }) + test("IP.IsGlobalUnicast", func() { sinkBool = MustParseAddr("2001:db8::1").IsGlobalUnicast() }) + test("IP.IsInterfaceLocalMulticast", func() { sinkBool = MustParseAddr("fe80::1").IsInterfaceLocalMulticast() }) + test("IP.IsLinkLocalMulticast", func() { sinkBool = MustParseAddr("fe80::1").IsLinkLocalMulticast() }) + test("IP.IsLinkLocalUnicast", func() { sinkBool = MustParseAddr("fe80::1").IsLinkLocalUnicast() }) + test("IP.IsLoopback", func() { sinkBool = MustParseAddr("fe80::1").IsLoopback() }) + test("IP.IsMulticast", func() { sinkBool = MustParseAddr("fe80::1").IsMulticast() }) + test("IP.IsPrivate", func() { sinkBool = MustParseAddr("fd00::1").IsPrivate() }) + test("IP.IsUnspecified", func() { sinkBool = IPv6Unspecified().IsUnspecified() }) + test("IP.Prefix/4", func() { sinkPrefix = panicPfx(MustParseAddr("1.2.3.4").Prefix(20)) }) + test("IP.Prefix/6", func() { sinkPrefix = panicPfx(MustParseAddr("fe80::1").Prefix(64)) }) + test("IP.As16", func() { sinkIP16 = MustParseAddr("1.2.3.4").As16() }) + test("IP.As4", func() { sinkIP4 = MustParseAddr("1.2.3.4").As4() }) + test("IP.Next", func() { sinkIP = MustParseAddr("1.2.3.4").Next() }) + test("IP.Prev", func() { sinkIP = MustParseAddr("1.2.3.4").Prev() }) + + // AddrPort constructors + test("AddrPortFrom", func() { sinkAddrPort = AddrPortFrom(IPv4(1, 2, 3, 4), 22) }) + test("ParseAddrPort", func() { sinkAddrPort = panicIPP(ParseAddrPort("[::1]:1234")) }) + test("MustParseAddrPort", func() { sinkAddrPort = MustParseAddrPort("[::1]:1234") }) + + // Prefix constructors + test("PrefixFrom", func() { sinkPrefix = PrefixFrom(IPv4(1, 2, 3, 4), 32) }) + test("ParsePrefix/4", func() { sinkPrefix = panicPfx(ParsePrefix("1.2.3.4/20")) }) + test("ParsePrefix/6", func() { sinkPrefix = panicPfx(ParsePrefix("fe80::1/64")) }) + test("MustParsePrefix", func() { sinkPrefix = MustParsePrefix("1.2.3.4/20") }) + + // Prefix methods + test("Prefix.Contains", func() { sinkBool = MustParsePrefix("1.2.3.0/24").Contains(MustParseAddr("1.2.3.4")) }) + test("Prefix.Overlaps", func() { + a, b := MustParsePrefix("1.2.3.0/24"), MustParsePrefix("1.2.0.0/16") + sinkBool = a.Overlaps(b) + }) + test("Prefix.IsZero", func() { sinkBool = MustParsePrefix("1.2.0.0/16").IsZero() }) + test("Prefix.IsSingleIP", func() { sinkBool = MustParsePrefix("1.2.3.4/32").IsSingleIP() }) + test("IPPRefix.Masked", func() { sinkPrefix = MustParsePrefix("1.2.3.4/16").Masked() }) +} + +func TestPrefixString(t *testing.T) { + tests := []struct { + ipp Prefix + want string + }{ + {Prefix{}, "invalid Prefix"}, + {PrefixFrom(Addr{}, 8), "invalid Prefix"}, + {PrefixFrom(MustParseAddr("1.2.3.4"), 88), "invalid Prefix"}, + } + + for _, tt := range tests { + if got := tt.ipp.String(); got != tt.want { + t.Errorf("(%#v).String() = %q want %q", tt.ipp, got, tt.want) + } + } +} + +func TestInvalidAddrPortString(t *testing.T) { + tests := []struct { + ipp AddrPort + want string + }{ + {AddrPort{}, "invalid AddrPort"}, + {AddrPortFrom(Addr{}, 80), "invalid AddrPort"}, + } + + for _, tt := range tests { + if got := tt.ipp.String(); got != tt.want { + t.Errorf("(%#v).String() = %q want %q", tt.ipp, got, tt.want) + } + } +} diff --git a/src/net/netip/slow_test.go b/src/net/netip/slow_test.go new file mode 100644 index 0000000000..5b46a39a83 --- /dev/null +++ b/src/net/netip/slow_test.go @@ -0,0 +1,190 @@ +// Copyright 2020 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 netip_test + +import ( + "fmt" + . "net/netip" + "strconv" + "strings" +) + +// zeros is a slice of eight stringified zeros. It's used in +// parseIPSlow to construct slices of specific amounts of zero fields, +// from 1 to 8. +var zeros = []string{"0", "0", "0", "0", "0", "0", "0", "0"} + +// parseIPSlow is like ParseIP, but aims for readability above +// speed. It's the reference implementation for correctness checking +// and against which we measure optimized parsers. +// +// parseIPSlow understands the following forms of IP addresses: +// - Regular IPv4: 1.2.3.4 +// - IPv4 with many leading zeros: 0000001.0000002.0000003.0000004 +// - Regular IPv6: 1111:2222:3333:4444:5555:6666:7777:8888 +// - IPv6 with many leading zeros: 00000001:0000002:0000003:0000004:0000005:0000006:0000007:0000008 +// - IPv6 with zero blocks elided: 1111:2222::7777:8888 +// - IPv6 with trailing 32 bits expressed as IPv4: 1111:2222:3333:4444:5555:6666:77.77.88.88 +// +// It does not process the following IP address forms, which have been +// varyingly accepted by some programs due to an under-specification +// of the shapes of IPv4 addresses: +// +// - IPv4 as a single 32-bit uint: 4660 (same as "1.2.3.4") +// - IPv4 with octal numbers: 0300.0250.0.01 (same as "192.168.0.1") +// - IPv4 with hex numbers: 0xc0.0xa8.0x0.0x1 (same as "192.168.0.1") +// - IPv4 in "class-B style": 1.2.52 (same as "1.2.3.4") +// - IPv4 in "class-A style": 1.564 (same as "1.2.3.4") +func parseIPSlow(s string) (Addr, error) { + // Identify and strip out the zone, if any. There should be 0 or 1 + // '%' in the string. + var zone string + fs := strings.Split(s, "%") + switch len(fs) { + case 1: + // No zone, that's fine. + case 2: + s, zone = fs[0], fs[1] + if zone == "" { + return Addr{}, fmt.Errorf("netaddr.ParseIP(%q): no zone after zone specifier", s) + } + default: + return Addr{}, fmt.Errorf("netaddr.ParseIP(%q): too many zone specifiers", s) // TODO: less specific? + } + + // IPv4 by itself is easy to do in a helper. + if strings.Count(s, ":") == 0 { + if zone != "" { + return Addr{}, fmt.Errorf("netaddr.ParseIP(%q): IPv4 addresses cannot have a zone", s) + } + return parseIPv4Slow(s) + } + + normal, err := normalizeIPv6Slow(s) + if err != nil { + return Addr{}, err + } + + // At this point, we've normalized the address back into 8 hex + // fields of 16 bits each. Parse that. + fs = strings.Split(normal, ":") + if len(fs) != 8 { + return Addr{}, fmt.Errorf("netaddr.ParseIP(%q): wrong size address", s) + } + var ret [16]byte + for i, f := range fs { + a, b, err := parseWord(f) + if err != nil { + return Addr{}, err + } + ret[i*2] = a + ret[i*2+1] = b + } + + return AddrFrom16(ret).WithZone(zone), nil +} + +// normalizeIPv6Slow expands s, which is assumed to be an IPv6 +// address, to its canonical text form. +// +// The canonical form of an IPv6 address is 8 colon-separated fields, +// where each field should be a hex value from 0 to ffff. This +// function does not verify the contents of each field. +// +// This function performs two transformations: +// - The last 32 bits of an IPv6 address may be represented in +// IPv4-style dotted quad form, as in 1:2:3:4:5:6:7.8.9.10. That +// address is transformed to its hex equivalent, +// e.g. 1:2:3:4:5:6:708:90a. +// - An address may contain one "::", which expands into as many +// 16-bit blocks of zeros as needed to make the address its correct +// full size. For example, fe80::1:2 expands to fe80:0:0:0:0:0:1:2. +// +// Both short forms may be present in a single address, +// e.g. fe80::1.2.3.4. +func normalizeIPv6Slow(orig string) (string, error) { + s := orig + + // Find and convert an IPv4 address in the final field, if any. + i := strings.LastIndex(s, ":") + if i == -1 { + return "", fmt.Errorf("netaddr.ParseIP(%q): invalid IP address", orig) + } + if strings.Contains(s[i+1:], ".") { + ip, err := parseIPv4Slow(s[i+1:]) + if err != nil { + return "", err + } + a4 := ip.As4() + s = fmt.Sprintf("%s:%02x%02x:%02x%02x", s[:i], a4[0], a4[1], a4[2], a4[3]) + } + + // Find and expand a ::, if any. + fs := strings.Split(s, "::") + switch len(fs) { + case 1: + // No ::, nothing to do. + case 2: + lhs, rhs := fs[0], fs[1] + // Found a ::, figure out how many zero blocks need to be + // inserted. + nblocks := strings.Count(lhs, ":") + strings.Count(rhs, ":") + if lhs != "" { + nblocks++ + } + if rhs != "" { + nblocks++ + } + if nblocks > 7 { + return "", fmt.Errorf("netaddr.ParseIP(%q): address too long", orig) + } + fs = nil + // Either side of the :: can be empty. We don't want empty + // fields to feature in the final normalized address. + if lhs != "" { + fs = append(fs, lhs) + } + fs = append(fs, zeros[:8-nblocks]...) + if rhs != "" { + fs = append(fs, rhs) + } + s = strings.Join(fs, ":") + default: + // Too many :: + return "", fmt.Errorf("netaddr.ParseIP(%q): invalid IP address", orig) + } + + return s, nil +} + +// parseIPv4Slow parses and returns an IPv4 address in dotted quad +// form, e.g. "192.168.0.1". It is slow but easy to read, and the +// reference implementation against which we compare faster +// implementations for correctness. +func parseIPv4Slow(s string) (Addr, error) { + fs := strings.Split(s, ".") + if len(fs) != 4 { + return Addr{}, fmt.Errorf("netaddr.ParseIP(%q): invalid IP address", s) + } + var ret [4]byte + for i := range ret { + val, err := strconv.ParseUint(fs[i], 10, 8) + if err != nil { + return Addr{}, err + } + ret[i] = uint8(val) + } + return AddrFrom4([4]byte{ret[0], ret[1], ret[2], ret[3]}), nil +} + +// parseWord converts a 16-bit hex string into its corresponding +// two-byte value. +func parseWord(s string) (byte, byte, error) { + ret, err := strconv.ParseUint(s, 16, 16) + if err != nil { + return 0, 0, err + } + return uint8(ret >> 8), uint8(ret), nil +} diff --git a/src/net/netip/uint128.go b/src/net/netip/uint128.go new file mode 100644 index 0000000000..738939d7de --- /dev/null +++ b/src/net/netip/uint128.go @@ -0,0 +1,92 @@ +// Copyright 2020 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 netip + +import "math/bits" + +// uint128 represents a uint128 using two uint64s. +// +// When the methods below mention a bit number, bit 0 is the most +// significant bit (in hi) and bit 127 is the lowest (lo&1). +type uint128 struct { + hi uint64 + lo uint64 +} + +// mask6 returns a uint128 bitmask with the topmost n bits of a +// 128-bit number. +func mask6(n int) uint128 { + return uint128{^(^uint64(0) >> n), ^uint64(0) << (128 - n)} +} + +// isZero reports whether u == 0. +// +// It's faster than u == (uint128{}) because the compiler (as of Go +// 1.15/1.16b1) doesn't do this trick and instead inserts a branch in +// its eq alg's generated code. +func (u uint128) isZero() bool { return u.hi|u.lo == 0 } + +// and returns the bitwise AND of u and m (u&m). +func (u uint128) and(m uint128) uint128 { + return uint128{u.hi & m.hi, u.lo & m.lo} +} + +// xor returns the bitwise XOR of u and m (u^m). +func (u uint128) xor(m uint128) uint128 { + return uint128{u.hi ^ m.hi, u.lo ^ m.lo} +} + +// or returns the bitwise OR of u and m (u|m). +func (u uint128) or(m uint128) uint128 { + return uint128{u.hi | m.hi, u.lo | m.lo} +} + +// not returns the bitwise NOT of u. +func (u uint128) not() uint128 { + return uint128{^u.hi, ^u.lo} +} + +// subOne returns u - 1. +func (u uint128) subOne() uint128 { + lo, borrow := bits.Sub64(u.lo, 1, 0) + return uint128{u.hi - borrow, lo} +} + +// addOne returns u + 1. +func (u uint128) addOne() uint128 { + lo, carry := bits.Add64(u.lo, 1, 0) + return uint128{u.hi + carry, lo} +} + +func u64CommonPrefixLen(a, b uint64) uint8 { + return uint8(bits.LeadingZeros64(a ^ b)) +} + +func (u uint128) commonPrefixLen(v uint128) (n uint8) { + if n = u64CommonPrefixLen(u.hi, v.hi); n == 64 { + n += u64CommonPrefixLen(u.lo, v.lo) + } + return +} + +// halves returns the two uint64 halves of the uint128. +// +// Logically, think of it as returning two uint64s. +// It only returns pointers for inlining reasons on 32-bit platforms. +func (u *uint128) halves() [2]*uint64 { + return [2]*uint64{&u.hi, &u.lo} +} + +// bitsSetFrom returns a copy of u with the given bit +// and all subsequent ones set. +func (u uint128) bitsSetFrom(bit uint8) uint128 { + return u.or(mask6(int(bit)).not()) +} + +// bitsClearedFrom returns a copy of u with the given bit +// and all subsequent ones cleared. +func (u uint128) bitsClearedFrom(bit uint8) uint128 { + return u.and(mask6(int(bit))) +} diff --git a/src/net/netip/uint128_test.go b/src/net/netip/uint128_test.go new file mode 100644 index 0000000000..dd1ae0ec79 --- /dev/null +++ b/src/net/netip/uint128_test.go @@ -0,0 +1,89 @@ +// Copyright 2020 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 netip + +import ( + "testing" +) + +func TestUint128AddSub(t *testing.T) { + const add1 = 1 + const sub1 = -1 + tests := []struct { + in uint128 + op int // +1 or -1 to add vs subtract + want uint128 + }{ + {uint128{0, 0}, add1, uint128{0, 1}}, + {uint128{0, 1}, add1, uint128{0, 2}}, + {uint128{1, 0}, add1, uint128{1, 1}}, + {uint128{0, ^uint64(0)}, add1, uint128{1, 0}}, + {uint128{^uint64(0), ^uint64(0)}, add1, uint128{0, 0}}, + + {uint128{0, 0}, sub1, uint128{^uint64(0), ^uint64(0)}}, + {uint128{0, 1}, sub1, uint128{0, 0}}, + {uint128{0, 2}, sub1, uint128{0, 1}}, + {uint128{1, 0}, sub1, uint128{0, ^uint64(0)}}, + {uint128{1, 1}, sub1, uint128{1, 0}}, + } + for _, tt := range tests { + var got uint128 + switch tt.op { + case add1: + got = tt.in.addOne() + case sub1: + got = tt.in.subOne() + default: + panic("bogus op") + } + if got != tt.want { + t.Errorf("%v add %d = %v; want %v", tt.in, tt.op, got, tt.want) + } + } +} + +func TestBitsSetFrom(t *testing.T) { + tests := []struct { + bit uint8 + want uint128 + }{ + {0, uint128{^uint64(0), ^uint64(0)}}, + {1, uint128{^uint64(0) >> 1, ^uint64(0)}}, + {63, uint128{1, ^uint64(0)}}, + {64, uint128{0, ^uint64(0)}}, + {65, uint128{0, ^uint64(0) >> 1}}, + {127, uint128{0, 1}}, + {128, uint128{0, 0}}, + } + for _, tt := range tests { + var zero uint128 + got := zero.bitsSetFrom(tt.bit) + if got != tt.want { + t.Errorf("0.bitsSetFrom(%d) = %064b want %064b", tt.bit, got, tt.want) + } + } +} + +func TestBitsClearedFrom(t *testing.T) { + tests := []struct { + bit uint8 + want uint128 + }{ + {0, uint128{0, 0}}, + {1, uint128{1 << 63, 0}}, + {63, uint128{^uint64(0) &^ 1, 0}}, + {64, uint128{^uint64(0), 0}}, + {65, uint128{^uint64(0), 1 << 63}}, + {127, uint128{^uint64(0), ^uint64(0) &^ 1}}, + {128, uint128{^uint64(0), ^uint64(0)}}, + } + for _, tt := range tests { + ones := uint128{^uint64(0), ^uint64(0)} + got := ones.bitsClearedFrom(tt.bit) + if got != tt.want { + t.Errorf("ones.bitsClearedFrom(%d) = %064b want %064b", tt.bit, got, tt.want) + } + } +} diff --git a/src/net/parse.go b/src/net/parse.go index 0d7cce12e6..ee2890fe2c 100644 --- a/src/net/parse.go +++ b/src/net/parse.go @@ -341,26 +341,3 @@ func readFull(r io.Reader) (all []byte, err error) { } } } - -// goDebugString returns the value of the named GODEBUG key. -// GODEBUG is of the form "key=val,key2=val2" -func goDebugString(key string) string { - s := os.Getenv("GODEBUG") - for i := 0; i < len(s)-len(key)-1; i++ { - if i > 0 && s[i-1] != ',' { - continue - } - afterKey := s[i+len(key):] - if afterKey[0] != '=' || s[i:i+len(key)] != key { - continue - } - val := afterKey[1:] - for i, b := range val { - if b == ',' { - return val[:i] - } - } - return val - } - return "" -} diff --git a/src/net/parse_test.go b/src/net/parse_test.go index c5f8bfd198..97716d769a 100644 --- a/src/net/parse_test.go +++ b/src/net/parse_test.go @@ -51,33 +51,6 @@ func TestReadLine(t *testing.T) { } } -func TestGoDebugString(t *testing.T) { - defer os.Setenv("GODEBUG", os.Getenv("GODEBUG")) - tests := []struct { - godebug string - key string - want string - }{ - {"", "foo", ""}, - {"foo=", "foo", ""}, - {"foo=bar", "foo", "bar"}, - {"foo=bar,", "foo", "bar"}, - {"foo,foo=bar,", "foo", "bar"}, - {"foo1=bar,foo=bar,", "foo", "bar"}, - {"foo=bar,foo=bar,", "foo", "bar"}, - {"foo=", "foo", ""}, - {"foo", "foo", ""}, - {",foo", "foo", ""}, - {"foo=bar,baz", "loooooooong", ""}, - } - for _, tt := range tests { - os.Setenv("GODEBUG", tt.godebug) - if got := goDebugString(tt.key); got != tt.want { - t.Errorf("for %q, goDebugString(%q) = %q; want %q", tt.godebug, tt.key, got, tt.want) - } - } -} - func TestDtoi(t *testing.T) { for _, tt := range []struct { in string diff --git a/src/net/tcpsock.go b/src/net/tcpsock.go index 19a90143f3..fddb018aab 100644 --- a/src/net/tcpsock.go +++ b/src/net/tcpsock.go @@ -8,6 +8,7 @@ import ( "context" "internal/itoa" "io" + "net/netip" "os" "syscall" "time" @@ -23,6 +24,20 @@ type TCPAddr struct { Zone string // IPv6 scoped addressing zone } +// AddrPort returns the TCPAddr a as a netip.AddrPort. +// +// If a.Port does not fit in a uint16, it's silently truncated. +// +// If a is nil, a zero value is returned. +func (a *TCPAddr) AddrPort() netip.AddrPort { + if a == nil { + return netip.AddrPort{} + } + na, _ := netip.AddrFromSlice(a.IP) + na = na.WithZone(a.Zone) + return netip.AddrPortFrom(na, uint16(a.Port)) +} + // Network returns the address's network name, "tcp". func (a *TCPAddr) Network() string { return "tcp" } diff --git a/src/net/udpsock.go b/src/net/udpsock.go index 70f2ce226a..95ffa85939 100644 --- a/src/net/udpsock.go +++ b/src/net/udpsock.go @@ -7,6 +7,7 @@ package net import ( "context" "internal/itoa" + "net/netip" "syscall" ) @@ -26,6 +27,20 @@ type UDPAddr struct { Zone string // IPv6 scoped addressing zone } +// AddrPort returns the UDPAddr a as a netip.AddrPort. +// +// If a.Port does not fit in a uint16, it's silently truncated. +// +// If a is nil, a zero value is returned. +func (a *UDPAddr) AddrPort() netip.AddrPort { + if a == nil { + return netip.AddrPort{} + } + na, _ := netip.AddrFromSlice(a.IP) + na = na.WithZone(a.Zone) + return netip.AddrPortFrom(na, uint16(a.Port)) +} + // Network returns the address's network name, "udp". func (a *UDPAddr) Network() string { return "udp" } @@ -84,6 +99,21 @@ func ResolveUDPAddr(network, address string) (*UDPAddr, error) { return addrs.forResolve(network, address).(*UDPAddr), nil } +// UDPAddrFromAddrPort returns addr as a UDPAddr. +// +// If addr is not valid, it returns nil. +func UDPAddrFromAddrPort(addr netip.AddrPort) *UDPAddr { + if !addr.IsValid() { + return nil + } + ip16 := addr.Addr().As16() + return &UDPAddr{ + IP: IP(ip16[:]), + Zone: addr.Addr().Zone(), + Port: int(addr.Port()), + } +} + // UDPConn is the implementation of the Conn and PacketConn interfaces // for UDP network connections. type UDPConn struct { @@ -148,6 +178,18 @@ func (c *UDPConn) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *UDPAddr, return } +// ReadMsgUDPAddrPort is like ReadMsgUDP but returns an netip.AddrPort instead of a UDPAddr. +func (c *UDPConn) ReadMsgUDPAddrPort(b, oob []byte) (n, oobn, flags int, addr netip.AddrPort, err error) { + // TODO(bradfitz): make this efficient, making the internal net package + // type throughout be netip.Addr and only converting to the net.IP slice + // version at the edge. But for now (2021-10-20), this is a wrapper around + // the old way. + var ua *UDPAddr + n, oobn, flags, ua, err = c.ReadMsgUDP(b, oob) + addr = ua.AddrPort() + return +} + // WriteToUDP acts like WriteTo but takes a UDPAddr. func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (int, error) { if !c.ok() { @@ -160,6 +202,15 @@ func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (int, error) { return n, err } +// WriteToUDPAddrPort acts like WriteTo but takes a netip.AddrPort. +func (c *UDPConn) WriteToUDPAddrPort(b []byte, addr netip.AddrPort) (int, error) { + // TODO(bradfitz): make this efficient, making the internal net package + // type throughout be netip.Addr and only converting to the net.IP slice + // version at the edge. But for now (2021-10-20), this is a wrapper around + // the old way. + return c.WriteToUDP(b, UDPAddrFromAddrPort(addr)) +} + // WriteTo implements the PacketConn WriteTo method. func (c *UDPConn) WriteTo(b []byte, addr Addr) (int, error) { if !c.ok() { @@ -195,6 +246,15 @@ func (c *UDPConn) WriteMsgUDP(b, oob []byte, addr *UDPAddr) (n, oobn int, err er return } +// WriteMsgUDPAddrPort is like WriteMsgUDP but takes a netip.AddrPort instead of a UDPAddr. +func (c *UDPConn) WriteMsgUDPAddrPort(b, oob []byte, addr netip.AddrPort) (n, oobn int, err error) { + // TODO(bradfitz): make this efficient, making the internal net package + // type throughout be netip.Addr and only converting to the net.IP slice + // version at the edge. But for now (2021-10-20), this is a wrapper around + // the old way. + return c.WriteMsgUDP(b, oob, UDPAddrFromAddrPort(addr)) +} + func newUDPConn(fd *netFD) *UDPConn { return &UDPConn{conn{fd}} } // DialUDP acts like Dial for UDP networks. diff --git a/src/strings/compare.go b/src/strings/compare.go index 1fe6b8d89a..2bd4a243db 100644 --- a/src/strings/compare.go +++ b/src/strings/compare.go @@ -5,7 +5,7 @@ package strings // Compare returns an integer comparing two strings lexicographically. -// The result will be 0 if a==b, -1 if a < b, and +1 if a > b. +// The result will be 0 if a == b, -1 if a < b, and +1 if a > b. // // Compare is included only for symmetry with package bytes. // It is usually clearer and always faster to use the built-in From a45457df82263c292e2c66c152a12b5df0f27f15 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Mon, 1 Nov 2021 02:04:13 +0700 Subject: [PATCH 281/406] cmd/compile: fix panic when refer to method of imported instantiated type In case of reference to method call of an imported fully-instantiated type, nameNode.Func will be nil causes checkFetchBody panic. To fix this, make sure checkFetchBody is only called when Func is not nil. Fixes #49246 Change-Id: I32e9208385a86d4600d8ebf6f5efd8fca571ea16 Reviewed-on: https://go-review.googlesource.com/c/go/+/360056 Trust: Cuong Manh Le Trust: Dan Scales Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/noder/stencil.go | 15 +++++++++++++-- test/typeparam/issue49246.dir/a.go | 20 ++++++++++++++++++++ test/typeparam/issue49246.dir/b.go | 9 +++++++++ test/typeparam/issue49246.go | 7 +++++++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 test/typeparam/issue49246.dir/a.go create mode 100644 test/typeparam/issue49246.dir/b.go create mode 100644 test/typeparam/issue49246.go diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 56010a356e..74281bc479 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -624,7 +624,7 @@ func (g *genInst) getDictOrSubdict(declInfo *instInfo, n ir.Node, nameNode *ir.N // yet. If so, it imports the body. func checkFetchBody(nameNode *ir.Name) { if nameNode.Func.Body == nil && nameNode.Func.Inl != nil { - // If there is no body yet but Func.Inl exists, then we can can + // If there is no body yet but Func.Inl exists, then we can // import the whole generic body. assert(nameNode.Func.Inl.Cost == 1 && nameNode.Sym().Pkg != types.LocalPkg) typecheck.ImportBody(nameNode.Func) @@ -638,7 +638,18 @@ func checkFetchBody(nameNode *ir.Name) { // with the type arguments shapes. If the instantiated function is not already // cached, then it calls genericSubst to create the new instantiation. func (g *genInst) getInstantiation(nameNode *ir.Name, shapes []*types.Type, isMeth bool) *instInfo { - checkFetchBody(nameNode) + if nameNode.Func == nil { + // If nameNode.Func is nil, this must be a reference to a method of + // an imported instantiated type. We will have already called + // g.instantiateMethods() on the fully-instantiated type, so + // g.instInfoMap[sym] will be non-nil below. + rcvr := nameNode.Type().Recv() + if rcvr == nil || !deref(rcvr.Type).IsFullyInstantiated() { + base.FatalfAt(nameNode.Pos(), "Unexpected function instantiation %v with no body", nameNode) + } + } else { + checkFetchBody(nameNode) + } // Convert any non-shape type arguments to their shape, so we can reduce the // number of instantiations we have to generate. You can actually have a mix diff --git a/test/typeparam/issue49246.dir/a.go b/test/typeparam/issue49246.dir/a.go new file mode 100644 index 0000000000..97459ee748 --- /dev/null +++ b/test/typeparam/issue49246.dir/a.go @@ -0,0 +1,20 @@ +// Copyright 2021 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 a + +type R[T any] struct{ v T } + +func (r R[T]) Self() R[T] { return R[T]{} } + +type Fn[T any] func() R[T] + +func X() (r R[int]) { return r.Self() } + +func Y[T any](a Fn[T]) Fn[int] { + return func() (r R[int]) { + // No crash: return R[int]{} + return r.Self() + } +} diff --git a/test/typeparam/issue49246.dir/b.go b/test/typeparam/issue49246.dir/b.go new file mode 100644 index 0000000000..5141b72fd4 --- /dev/null +++ b/test/typeparam/issue49246.dir/b.go @@ -0,0 +1,9 @@ +// Copyright 2021 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 b + +import "./a" + +func Crash() { a.Y(a.X)() } diff --git a/test/typeparam/issue49246.go b/test/typeparam/issue49246.go new file mode 100644 index 0000000000..87b4ff46c1 --- /dev/null +++ b/test/typeparam/issue49246.go @@ -0,0 +1,7 @@ +// compiledir -G=3 + +// Copyright 2021 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 ignored From 926856542fd01ae2f8c05466338a139f2fdfee85 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 1 Nov 2021 17:28:19 -0700 Subject: [PATCH 282/406] syscall,internal/poll: copy arrays by assignment instead of looping golang.org/x/sys contains similar code and also needs updating. Change-Id: Id00177397639075d4792eb253829d8042941b70c Reviewed-on: https://go-review.googlesource.com/c/go/+/360602 Trust: Josh Bleecher Snyder Trust: Brad Fitzpatrick Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- src/internal/poll/fd_windows.go | 8 ++------ src/syscall/syscall_aix.go | 16 ++++------------ src/syscall/syscall_bsd.go | 24 ++++++------------------ src/syscall/syscall_linux.go | 24 ++++++------------------ src/syscall/syscall_solaris.go | 16 ++++------------ src/syscall/syscall_windows.go | 16 ++++------------ 6 files changed, 26 insertions(+), 78 deletions(-) diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go index 48fcdf306c..d883cd1ecc 100644 --- a/src/internal/poll/fd_windows.go +++ b/src/internal/poll/fd_windows.go @@ -1102,9 +1102,7 @@ func sockaddrToRaw(sa syscall.Sockaddr) (unsafe.Pointer, int32, error) { p := (*[2]byte)(unsafe.Pointer(&raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - raw.Addr[i] = sa.Addr[i] - } + raw.Addr = sa.Addr return unsafe.Pointer(&raw), int32(unsafe.Sizeof(raw)), nil case *syscall.SockaddrInet6: var raw syscall.RawSockaddrInet6 @@ -1113,9 +1111,7 @@ func sockaddrToRaw(sa syscall.Sockaddr) (unsafe.Pointer, int32, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - raw.Addr[i] = sa.Addr[i] - } + raw.Addr = sa.Addr return unsafe.Pointer(&raw), int32(unsafe.Sizeof(raw)), nil default: return nil, 0, syscall.EWINDOWS diff --git a/src/syscall/syscall_aix.go b/src/syscall/syscall_aix.go index 20e77ac875..f3b160cae4 100644 --- a/src/syscall/syscall_aix.go +++ b/src/syscall/syscall_aix.go @@ -255,9 +255,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil } @@ -270,9 +268,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil } @@ -443,9 +439,7 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -453,9 +447,7 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet6) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, EAFNOSUPPORT diff --git a/src/syscall/syscall_bsd.go b/src/syscall/syscall_bsd.go index ebe99ff230..8945661300 100644 --- a/src/syscall/syscall_bsd.go +++ b/src/syscall/syscall_bsd.go @@ -167,9 +167,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } @@ -183,9 +181,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } @@ -214,9 +210,7 @@ func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) { sa.raw.Nlen = sa.Nlen sa.raw.Alen = sa.Alen sa.raw.Slen = sa.Slen - for i := 0; i < len(sa.raw.Data); i++ { - sa.raw.Data[i] = sa.Data[i] - } + sa.raw.Data = sa.Data return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil } @@ -232,9 +226,7 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { sa.Nlen = pp.Nlen sa.Alen = pp.Alen sa.Slen = pp.Slen - for i := 0; i < len(sa.Data); i++ { - sa.Data[i] = pp.Data[i] - } + sa.Data = pp.Data return sa, nil case AF_UNIX: @@ -266,9 +258,7 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -277,9 +267,7 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, EAFNOSUPPORT diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go index f02fa45a89..1c6033bbab 100644 --- a/src/syscall/syscall_linux.go +++ b/src/syscall/syscall_linux.go @@ -393,9 +393,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil } @@ -408,9 +406,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil } @@ -461,9 +457,7 @@ func (sa *SockaddrLinklayer) sockaddr() (unsafe.Pointer, _Socklen, error) { sa.raw.Hatype = sa.Hatype sa.raw.Pkttype = sa.Pkttype sa.raw.Halen = sa.Halen - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrLinklayer, nil } @@ -502,9 +496,7 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { sa.Hatype = pp.Hatype sa.Pkttype = pp.Pkttype sa.Halen = pp.Halen - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_UNIX: @@ -537,9 +529,7 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -548,9 +538,7 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, EAFNOSUPPORT diff --git a/src/syscall/syscall_solaris.go b/src/syscall/syscall_solaris.go index dedfbd03c0..13616fca9d 100644 --- a/src/syscall/syscall_solaris.go +++ b/src/syscall/syscall_solaris.go @@ -69,9 +69,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil } @@ -84,9 +82,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil } @@ -304,9 +300,7 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -315,9 +309,7 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, EAFNOSUPPORT diff --git a/src/syscall/syscall_windows.go b/src/syscall/syscall_windows.go index d4e51e541d..a8a78b9ef8 100644 --- a/src/syscall/syscall_windows.go +++ b/src/syscall/syscall_windows.go @@ -738,9 +738,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, int32, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), int32(unsafe.Sizeof(sa.raw)), nil } @@ -760,9 +758,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, int32, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), int32(unsafe.Sizeof(sa.raw)), nil } @@ -835,9 +831,7 @@ func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -846,9 +840,7 @@ func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, EAFNOSUPPORT From 65f34786336201d99291e45d1631339b20c09e06 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 1 Nov 2021 17:27:09 -0700 Subject: [PATCH 283/406] encoding: simplify some code Change-Id: I63aac663da4ce7bdd198d385f87929c74f6a5cf8 Reviewed-on: https://go-review.googlesource.com/c/go/+/360601 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- src/encoding/ascii85/ascii85.go | 4 +--- src/encoding/base32/base32.go | 4 +--- src/encoding/base64/base64.go | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/encoding/ascii85/ascii85.go b/src/encoding/ascii85/ascii85.go index d42eb0ab00..f1f7af863c 100644 --- a/src/encoding/ascii85/ascii85.go +++ b/src/encoding/ascii85/ascii85.go @@ -142,9 +142,7 @@ func (e *encoder) Write(p []byte) (n int, err error) { } // Trailing fringe. - for i := 0; i < len(p); i++ { - e.buf[i] = p[i] - } + copy(e.buf[:], p) e.nbuf = len(p) n += len(p) return diff --git a/src/encoding/base32/base32.go b/src/encoding/base32/base32.go index 2f7d3637e5..3feea9ba47 100644 --- a/src/encoding/base32/base32.go +++ b/src/encoding/base32/base32.go @@ -221,9 +221,7 @@ func (e *encoder) Write(p []byte) (n int, err error) { } // Trailing fringe. - for i := 0; i < len(p); i++ { - e.buf[i] = p[i] - } + copy(e.buf[:], p) e.nbuf = len(p) n += len(p) return diff --git a/src/encoding/base64/base64.go b/src/encoding/base64/base64.go index 0c33f8e5f8..4a3e590649 100644 --- a/src/encoding/base64/base64.go +++ b/src/encoding/base64/base64.go @@ -229,9 +229,7 @@ func (e *encoder) Write(p []byte) (n int, err error) { } // Trailing fringe. - for i := 0; i < len(p); i++ { - e.buf[i] = p[i] - } + copy(e.buf[:], p) e.nbuf = len(p) n += len(p) return From b0472aa990dfa9fb4ffe49b5af6f3d744d81ba6e Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 1 Nov 2021 14:05:14 -0700 Subject: [PATCH 284/406] net: add BenchmarkReadWriteMsgUDPAddrPort The main item of interest here is the allocs. BenchmarkReadWriteMsgUDPAddrPort-8 195920 6450 ns/op 176 B/op 5 allocs/op Change-Id: I358bd18888ce254b6c6d5d5c920e6d22ce5a2ef4 Reviewed-on: https://go-review.googlesource.com/c/go/+/360595 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- src/net/udpsock_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/net/udpsock_test.go b/src/net/udpsock_test.go index 0f8f463100..74e449c888 100644 --- a/src/net/udpsock_test.go +++ b/src/net/udpsock_test.go @@ -474,6 +474,27 @@ func TestUDPReadTimeout(t *testing.T) { } } +func BenchmarkReadWriteMsgUDPAddrPort(b *testing.B) { + conn, err := ListenUDP("udp4", &UDPAddr{IP: IPv4(127, 0, 0, 1)}) + if err != nil { + b.Fatal(err) + } + addr := conn.LocalAddr().(*UDPAddr).AddrPort() + buf := make([]byte, 8) + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + _, _, err := conn.WriteMsgUDPAddrPort(buf, nil, addr) + if err != nil { + b.Fatal(err) + } + _, _, _, _, err = conn.ReadMsgUDPAddrPort(buf, nil) + if err != nil { + b.Fatal(err) + } + } +} + func BenchmarkWriteToReadFromUDP(b *testing.B) { conn, err := ListenUDP("udp4", &UDPAddr{IP: IPv4(127, 0, 0, 1)}) if err != nil { From 3c61cb3dcd888fdef1c7456be144a1c4a44272a7 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 1 Nov 2021 12:44:43 -0700 Subject: [PATCH 285/406] net: optimize ReadMsgUDPAddrPort MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of implementing ReadMsgUDPAddrPort in terms of ReadMsgUDP, do it the other way around. This keeps the code minimal while still avoiding allocs. We could also rearrange ReadMsgUDP to be mid-stack inlined to avoid allocating the *UDPAddr, but anyone who's trying to eliminate allocs should use ReadMsgUDPAddrPort instead anyway, because ReadMsgUDP will always allocate at least once (the IP slice). name old time/op new time/op delta ReadWriteMsgUDPAddrPort-8 5.26µs ± 3% 5.29µs ± 6% ~ (p=0.429 n=12+13) name old alloc/op new alloc/op delta ReadWriteMsgUDPAddrPort-8 176B ± 0% 128B ± 0% -27.27% (p=0.000 n=15+15) name old allocs/op new allocs/op delta ReadWriteMsgUDPAddrPort-8 5.00 ± 0% 4.00 ± 0% -20.00% (p=0.000 n=15+15) Change-Id: I15228cb4ec4f13f2f390407b6c62c44c228e7201 Reviewed-on: https://go-review.googlesource.com/c/go/+/360596 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- src/net/udpsock.go | 24 ++++++++++-------------- src/net/udpsock_plan9.go | 5 +++-- src/net/udpsock_posix.go | 9 ++++++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/net/udpsock.go b/src/net/udpsock.go index 95ffa85939..8c97ca7537 100644 --- a/src/net/udpsock.go +++ b/src/net/udpsock.go @@ -168,25 +168,21 @@ func (c *UDPConn) ReadFrom(b []byte) (int, Addr, error) { // The packages golang.org/x/net/ipv4 and golang.org/x/net/ipv6 can be // used to manipulate IP-level socket options in oob. func (c *UDPConn) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *UDPAddr, err error) { - if !c.ok() { - return 0, 0, 0, nil, syscall.EINVAL - } - n, oobn, flags, addr, err = c.readMsg(b, oob) - if err != nil { - err = &OpError{Op: "read", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err} - } + var ap netip.AddrPort + n, oobn, flags, ap, err = c.ReadMsgUDPAddrPort(b, oob) + addr = UDPAddrFromAddrPort(ap) return } // ReadMsgUDPAddrPort is like ReadMsgUDP but returns an netip.AddrPort instead of a UDPAddr. func (c *UDPConn) ReadMsgUDPAddrPort(b, oob []byte) (n, oobn, flags int, addr netip.AddrPort, err error) { - // TODO(bradfitz): make this efficient, making the internal net package - // type throughout be netip.Addr and only converting to the net.IP slice - // version at the edge. But for now (2021-10-20), this is a wrapper around - // the old way. - var ua *UDPAddr - n, oobn, flags, ua, err = c.ReadMsgUDP(b, oob) - addr = ua.AddrPort() + if !c.ok() { + return 0, 0, 0, netip.AddrPort{}, syscall.EINVAL + } + n, oobn, flags, addr, err = c.readMsg(b, oob) + if err != nil { + err = &OpError{Op: "read", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err} + } return } diff --git a/src/net/udpsock_plan9.go b/src/net/udpsock_plan9.go index 1df293d1db..c18af2356d 100644 --- a/src/net/udpsock_plan9.go +++ b/src/net/udpsock_plan9.go @@ -7,6 +7,7 @@ package net import ( "context" "errors" + "net/netip" "os" "syscall" ) @@ -28,8 +29,8 @@ func (c *UDPConn) readFrom(b []byte, addr *UDPAddr) (int, *UDPAddr, error) { return n, addr, nil } -func (c *UDPConn) readMsg(b, oob []byte) (n, oobn, flags int, addr *UDPAddr, err error) { - return 0, 0, 0, nil, syscall.EPLAN9 +func (c *UDPConn) readMsg(b, oob []byte) (n, oobn, flags int, addr netip.AddrPort, err error) { + return 0, 0, 0, netip.AddrPort{}, syscall.EPLAN9 } func (c *UDPConn) writeTo(b []byte, addr *UDPAddr) (int, error) { diff --git a/src/net/udpsock_posix.go b/src/net/udpsock_posix.go index c3f7ddb77e..b20025140f 100644 --- a/src/net/udpsock_posix.go +++ b/src/net/udpsock_posix.go @@ -8,6 +8,7 @@ package net import ( "context" + "net/netip" "syscall" ) @@ -68,14 +69,16 @@ func (c *UDPConn) readFrom(b []byte, addr *UDPAddr) (int, *UDPAddr, error) { return n, addr, err } -func (c *UDPConn) readMsg(b, oob []byte) (n, oobn, flags int, addr *UDPAddr, err error) { +func (c *UDPConn) readMsg(b, oob []byte) (n, oobn, flags int, addr netip.AddrPort, err error) { var sa syscall.Sockaddr n, oobn, flags, sa, err = c.fd.readMsg(b, oob, 0) switch sa := sa.(type) { case *syscall.SockaddrInet4: - addr = &UDPAddr{IP: sa.Addr[0:], Port: sa.Port} + ip := netip.AddrFrom4(sa.Addr) + addr = netip.AddrPortFrom(ip, uint16(sa.Port)) case *syscall.SockaddrInet6: - addr = &UDPAddr{IP: sa.Addr[0:], Port: sa.Port, Zone: zoneCache.name(int(sa.ZoneId))} + ip := netip.AddrFrom16(sa.Addr).WithZone(zoneCache.name(int(sa.ZoneId))) + addr = netip.AddrPortFrom(ip, uint16(sa.Port)) } return } From 6f1e9a9c21aec8531db40dbf61ad10fe77d7bee5 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 1 Nov 2021 13:34:08 -0700 Subject: [PATCH 286/406] net: optimize WriteMsgUDPAddrPort MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is one step towards optimizing WriteMsgUDPAddrPort. Further steps remain, namely to avoid the syscall.Sockaddr interface, as we do for UDPConn.WriteToUDP and UDPConn.ReadFromUDP. A previous change optimized ReadMsgUDPAddrPort by having ReadMsgUDP call ReadMsgUDPAddrPort rather than the other way around. This change does not implement WriteMsgUDP in terms of WriteMsgUDPAddrPort, because a few layers deep, on posix platforms only (in ipToSockaddrInet4 and ipToSockaddrInet6), is special handling of zero-length IP addresses and IPv4zero. It treats IP(nil) as equivalent to 0.0.0.0 or ::, and 0.0.0.0 as equivalent to :: in an IPv6 context. Based on the comments, I suspect that this treatment was intended for the Listen* API, not the Write* API, but it affects both, and I am nervous about changing the behavior for Write*. The netip package doesn't have a way to represent a "zero-length IP address" as distinct from an invalid IP address (which is a good thing), so to implement WriteMsgUDP using WriteMsgUDPAddrPort, we would have to duplicate this special handling at the start of WriteMsgUDP. But this handling depends on whether the UDPConn is an IPv4 or an IPv6 conn, which is also platform-specific information. As a result, every attempt I made to implement WriteMsgUDP using WriteMsgUDPAddrPort while preserving behavior ended up being considerably worse than copy/paste/modify. This does mean that WriteMsgUDP and WriteMsgUDPAddrPort will have different behavior in these cases. name old time/op new time/op delta ReadWriteMsgUDPAddrPort-8 5.29µs ± 6% 5.02µs ± 7% -5.14% (p=0.000 n=13+15) name old alloc/op new alloc/op delta ReadWriteMsgUDPAddrPort-8 128B ± 0% 64B ± 0% -50.00% (p=0.000 n=15+15) name old allocs/op new allocs/op delta ReadWriteMsgUDPAddrPort-8 4.00 ± 0% 2.00 ± 0% -50.00% (p=0.000 n=15+15) Change-Id: Ia78eb49734f4301d7772dfdbb5a87e4d303a9f7a Reviewed-on: https://go-review.googlesource.com/c/go/+/360597 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- src/net/ipsock_posix.go | 30 ++++++++++++++++++++++++++++++ src/net/udpsock.go | 20 +++++++++++++++----- src/net/udpsock_plan9.go | 4 ++++ src/net/udpsock_posix.go | 28 ++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 5 deletions(-) diff --git a/src/net/ipsock_posix.go b/src/net/ipsock_posix.go index 0910f63d48..e433e8a91c 100644 --- a/src/net/ipsock_posix.go +++ b/src/net/ipsock_posix.go @@ -9,6 +9,7 @@ package net import ( "context" "internal/poll" + "net/netip" "runtime" "syscall" ) @@ -196,3 +197,32 @@ func ipToSockaddr(family int, ip IP, port int, zone string) (syscall.Sockaddr, e } return nil, &AddrError{Err: "invalid address family", Addr: ip.String()} } + +func addrPortToSockaddrInet4(ap netip.AddrPort) (syscall.SockaddrInet4, error) { + // ipToSockaddrInet4 has special handling here for zero length slices. + // We do not, because netip has no concept of a generic zero IP address. + addr := ap.Addr() + if !addr.Is4() { + return syscall.SockaddrInet4{}, &AddrError{Err: "non-IPv4 address", Addr: addr.String()} + } + sa := syscall.SockaddrInet4{ + Addr: addr.As4(), + Port: int(ap.Port()), + } + return sa, nil +} + +func addrPortToSockaddrInet6(ap netip.AddrPort) (syscall.SockaddrInet6, error) { + // ipToSockaddrInet6 has special handling here for zero length slices. + // We do not, because netip has no concept of a generic zero IP address. + addr := ap.Addr() + if !addr.Is6() { + return syscall.SockaddrInet6{}, &AddrError{Err: "non-IPv6 address", Addr: addr.String()} + } + sa := syscall.SockaddrInet6{ + Addr: addr.As16(), + Port: int(ap.Port()), + ZoneId: uint32(zoneCache.index(addr.Zone())), + } + return sa, nil +} diff --git a/src/net/udpsock.go b/src/net/udpsock.go index 8c97ca7537..0d563fd4f5 100644 --- a/src/net/udpsock.go +++ b/src/net/udpsock.go @@ -114,6 +114,13 @@ func UDPAddrFromAddrPort(addr netip.AddrPort) *UDPAddr { } } +// An addrPortUDPAddr is a netip.AddrPort-based UDP address that satisfies the Addr interface. +type addrPortUDPAddr struct { + netip.AddrPort +} + +func (addrPortUDPAddr) Network() string { return "udp" } + // UDPConn is the implementation of the Conn and PacketConn interfaces // for UDP network connections. type UDPConn struct { @@ -244,11 +251,14 @@ func (c *UDPConn) WriteMsgUDP(b, oob []byte, addr *UDPAddr) (n, oobn int, err er // WriteMsgUDPAddrPort is like WriteMsgUDP but takes a netip.AddrPort instead of a UDPAddr. func (c *UDPConn) WriteMsgUDPAddrPort(b, oob []byte, addr netip.AddrPort) (n, oobn int, err error) { - // TODO(bradfitz): make this efficient, making the internal net package - // type throughout be netip.Addr and only converting to the net.IP slice - // version at the edge. But for now (2021-10-20), this is a wrapper around - // the old way. - return c.WriteMsgUDP(b, oob, UDPAddrFromAddrPort(addr)) + if !c.ok() { + return 0, 0, syscall.EINVAL + } + n, oobn, err = c.writeMsgAddrPort(b, oob, addr) + if err != nil { + err = &OpError{Op: "write", Net: c.fd.net, Source: c.fd.laddr, Addr: addrPortUDPAddr{addr}, Err: err} + } + return } func newUDPConn(fd *netFD) *UDPConn { return &UDPConn{conn{fd}} } diff --git a/src/net/udpsock_plan9.go b/src/net/udpsock_plan9.go index c18af2356d..ac5afa2281 100644 --- a/src/net/udpsock_plan9.go +++ b/src/net/udpsock_plan9.go @@ -57,6 +57,10 @@ func (c *UDPConn) writeMsg(b, oob []byte, addr *UDPAddr) (n, oobn int, err error return 0, 0, syscall.EPLAN9 } +func (c *UDPConn) writeMsgAddrPort(b, oob []byte, addr netip.AddrPort) (n, oobn int, err error) { + return 0, 0, syscall.EPLAN9 +} + func (sd *sysDialer) dialUDP(ctx context.Context, laddr, raddr *UDPAddr) (*UDPConn, error) { fd, err := dialPlan9(ctx, sd.network, laddr, raddr) if err != nil { diff --git a/src/net/udpsock_posix.go b/src/net/udpsock_posix.go index b20025140f..646687d148 100644 --- a/src/net/udpsock_posix.go +++ b/src/net/udpsock_posix.go @@ -123,6 +123,34 @@ func (c *UDPConn) writeMsg(b, oob []byte, addr *UDPAddr) (n, oobn int, err error return c.fd.writeMsg(b, oob, sa) } +func (c *UDPConn) writeMsgAddrPort(b, oob []byte, addr netip.AddrPort) (n, oobn int, err error) { + if c.fd.isConnected && addr.IsValid() { + return 0, 0, ErrWriteToConnected + } + if !c.fd.isConnected && !addr.IsValid() { + return 0, 0, errMissingAddress + } + + switch c.fd.family { + case syscall.AF_INET: + sa, err := addrPortToSockaddrInet4(addr) + if err != nil { + return 0, 0, err + } + // TODO: Implement writeMsgInet4 to avoid allocation converting sa to an interface. + return c.fd.writeMsg(b, oob, &sa) + case syscall.AF_INET6: + sa, err := addrPortToSockaddrInet6(addr) + if err != nil { + return 0, 0, err + } + // TODO: Implement writeMsgInet6 to avoid allocation converting sa to an interface. + return c.fd.writeMsg(b, oob, &sa) + default: + return 0, 0, &AddrError{Err: "invalid address family", Addr: addr.Addr().String()} + } +} + func (sd *sysDialer) dialUDP(ctx context.Context, laddr, raddr *UDPAddr) (*UDPConn, error) { fd, err := internetSocket(ctx, sd.network, laddr, raddr, syscall.SOCK_DGRAM, 0, "dial", sd.Dialer.Control) if err != nil { From 6f327f7b889b81549d551ce6963067267578bd70 Mon Sep 17 00:00:00 2001 From: fanzha02 Date: Tue, 5 Jan 2021 17:52:43 +0800 Subject: [PATCH 287/406] runtime, syscall: add calls to asan functions Add explicit address sanitizer instrumentation to the runtime and syscall packages. The compiler does not instrument the runtime package. It does instrument the syscall package, but we need to add a couple of cases that it can't see. Refer to the implementation of the asan malloc runtime library, this patch also allocates extra memory as the redzone, around the returned memory region, and marks the redzone as unaddressable to detect the overflows or underflows. Updates #44853. Change-Id: I2753d1cc1296935a66bf521e31ce91e35fcdf798 Reviewed-on: https://go-review.googlesource.com/c/go/+/298614 Run-TryBot: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Trust: fannie zhang --- src/runtime/cgo_sigaction.go | 7 +++++- src/runtime/iface.go | 7 ++++++ src/runtime/malloc.go | 44 +++++++++++++++++++++++++++++++++- src/runtime/map.go | 12 ++++++++++ src/runtime/mbarrier.go | 8 +++++++ src/runtime/mgcsweep.go | 5 +++- src/runtime/mheap.go | 6 +++++ src/runtime/mprof.go | 6 +++++ src/runtime/proc.go | 6 +++++ src/runtime/select.go | 16 +++++++++++++ src/runtime/slice.go | 10 ++++++++ src/runtime/stack.go | 6 +++++ src/runtime/string.go | 9 +++++++ src/runtime/traceback.go | 6 +++++ src/syscall/asan.go | 23 ++++++++++++++++++ src/syscall/asan0.go | 20 ++++++++++++++++ src/syscall/syscall_unix.go | 6 +++++ src/syscall/syscall_windows.go | 6 +++++ 18 files changed, 200 insertions(+), 3 deletions(-) create mode 100644 src/syscall/asan.go create mode 100644 src/syscall/asan0.go diff --git a/src/runtime/cgo_sigaction.go b/src/runtime/cgo_sigaction.go index 7e8ae28275..a2e12f0f0e 100644 --- a/src/runtime/cgo_sigaction.go +++ b/src/runtime/cgo_sigaction.go @@ -27,7 +27,9 @@ func sigaction(sig uint32, new, old *sigactiont) { if msanenabled && new != nil { msanwrite(unsafe.Pointer(new), unsafe.Sizeof(*new)) } - + if asanenabled && new != nil { + asanwrite(unsafe.Pointer(new), unsafe.Sizeof(*new)) + } if _cgo_sigaction == nil || inForkedChild { sysSigaction(sig, new, old) } else { @@ -79,6 +81,9 @@ func sigaction(sig uint32, new, old *sigactiont) { if msanenabled && old != nil { msanread(unsafe.Pointer(old), unsafe.Sizeof(*old)) } + if asanenabled && old != nil { + asanread(unsafe.Pointer(old), unsafe.Sizeof(*old)) + } } // callCgoSigaction calls the sigaction function in the runtime/cgo package diff --git a/src/runtime/iface.go b/src/runtime/iface.go index 3d1d9d6ba1..e2bec10948 100644 --- a/src/runtime/iface.go +++ b/src/runtime/iface.go @@ -325,6 +325,9 @@ func convT(t *_type, v unsafe.Pointer) unsafe.Pointer { if msanenabled { msanread(v, t.size) } + if asanenabled { + asanread(v, t.size) + } x := mallocgc(t.size, t, true) typedmemmove(t, x, v) return x @@ -337,6 +340,10 @@ func convTnoptr(t *_type, v unsafe.Pointer) unsafe.Pointer { if msanenabled { msanread(v, t.size) } + if asanenabled { + asanread(v, t.size) + } + x := mallocgc(t.size, t, false) memmove(x, v, t.size) return x diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 8af1d96f1a..e267e2df23 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -908,6 +908,14 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { if size == 0 { return unsafe.Pointer(&zerobase) } + userSize := size + if asanenabled { + // Refer to ASAN runtime library, the malloc() function allocates extra memory, + // the redzone, around the user requested memory region. And the redzones are marked + // as unaddressable. We perform the same operations in Go to detect the overflows or + // underflows. + size += computeRZlog(size) + } if debug.malloc { if debug.sbrk != 0 { @@ -971,7 +979,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { mp.mallocing = 1 shouldhelpgc := false - dataSize := size + dataSize := userSize c := getMCache(mp) if c == nil { throw("mallocgc called without a P or outside bootstrapping") @@ -1138,6 +1146,17 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { msanmalloc(x, size) } + if asanenabled { + // We should only read/write the memory with the size asked by the user. + // The rest of the allocated memory should be poisoned, so that we can report + // errors when accessing poisoned memory. + // The allocated memory is larger than required userSize, it will also include + // redzone and some other padding bytes. + rzBeg := unsafe.Add(x, userSize) + asanpoison(rzBeg, size-userSize) + asanunpoison(x, userSize) + } + if rate := MemProfileRate; rate > 0 { // Note cache c only valid while m acquired; see #47302 if rate != 1 && size < c.nextSample { @@ -1514,3 +1533,26 @@ type notInHeap struct{} func (p *notInHeap) add(bytes uintptr) *notInHeap { return (*notInHeap)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + bytes)) } + +// computeRZlog computes the size of the redzone. +// Refer to the implementation of the compiler-rt. +func computeRZlog(userSize uintptr) uintptr { + switch { + case userSize <= (64 - 16): + return 16 << 0 + case userSize <= (128 - 32): + return 16 << 1 + case userSize <= (512 - 64): + return 16 << 2 + case userSize <= (4096 - 128): + return 16 << 3 + case userSize <= (1<<14)-256: + return 16 << 4 + case userSize <= (1<<15)-512: + return 16 << 5 + case userSize <= (1<<16)-1024: + return 16 << 6 + default: + return 16 << 7 + } +} diff --git a/src/runtime/map.go b/src/runtime/map.go index 985c297cd4..e91b25eaec 100644 --- a/src/runtime/map.go +++ b/src/runtime/map.go @@ -402,6 +402,9 @@ func mapaccess1(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer { if msanenabled && h != nil { msanread(key, t.key.size) } + if asanenabled && h != nil { + asanread(key, t.key.size) + } if h == nil || h.count == 0 { if t.hashMightPanic() { t.hasher(key, 0) // see issue 23734 @@ -460,6 +463,9 @@ func mapaccess2(t *maptype, h *hmap, key unsafe.Pointer) (unsafe.Pointer, bool) if msanenabled && h != nil { msanread(key, t.key.size) } + if asanenabled && h != nil { + asanread(key, t.key.size) + } if h == nil || h.count == 0 { if t.hashMightPanic() { t.hasher(key, 0) // see issue 23734 @@ -582,6 +588,9 @@ func mapassign(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer { if msanenabled { msanread(key, t.key.size) } + if asanenabled { + asanread(key, t.key.size) + } if h.flags&hashWriting != 0 { throw("concurrent map writes") } @@ -693,6 +702,9 @@ func mapdelete(t *maptype, h *hmap, key unsafe.Pointer) { if msanenabled && h != nil { msanread(key, t.key.size) } + if asanenabled && h != nil { + asanread(key, t.key.size) + } if h == nil || h.count == 0 { if t.hashMightPanic() { t.hasher(key, 0) // see issue 23734 diff --git a/src/runtime/mbarrier.go b/src/runtime/mbarrier.go index 3fd1cca42c..0f8b2af5fa 100644 --- a/src/runtime/mbarrier.go +++ b/src/runtime/mbarrier.go @@ -184,6 +184,10 @@ func reflect_typedmemmove(typ *_type, dst, src unsafe.Pointer) { msanwrite(dst, typ.size) msanread(src, typ.size) } + if asanenabled { + asanwrite(dst, typ.size) + asanread(src, typ.size) + } typedmemmove(typ, dst, src) } @@ -262,6 +266,10 @@ func typedslicecopy(typ *_type, dstPtr unsafe.Pointer, dstLen int, srcPtr unsafe msanwrite(dstPtr, uintptr(n)*typ.size) msanread(srcPtr, uintptr(n)*typ.size) } + if asanenabled { + asanwrite(dstPtr, uintptr(n)*typ.size) + asanread(srcPtr, uintptr(n)*typ.size) + } if writeBarrier.cgo { cgoCheckSliceCopy(typ, dstPtr, srcPtr, n) diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go index b06df32b20..fdbec30cf1 100644 --- a/src/runtime/mgcsweep.go +++ b/src/runtime/mgcsweep.go @@ -563,7 +563,7 @@ func (sl *sweepLocked) sweep(preserve bool) bool { spanHasNoSpecials(s) } - if debug.allocfreetrace != 0 || debug.clobberfree != 0 || raceenabled || msanenabled { + if debug.allocfreetrace != 0 || debug.clobberfree != 0 || raceenabled || msanenabled || asanenabled { // Find all newly freed objects. This doesn't have to // efficient; allocfreetrace has massive overhead. mbits := s.markBitsForBase() @@ -583,6 +583,9 @@ func (sl *sweepLocked) sweep(preserve bool) bool { if msanenabled { msanfree(unsafe.Pointer(x), size) } + if asanenabled { + asanpoison(unsafe.Pointer(x), size) + } } mbits.advance() abits.advance() diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index 5fd036c1b3..057ab06b1d 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -1419,6 +1419,12 @@ func (h *mheap) freeSpan(s *mspan) { bytes := s.npages << _PageShift msanfree(base, bytes) } + if asanenabled { + // Tell asan that this entire span is no longer in use. + base := unsafe.Pointer(s.base()) + bytes := s.npages << _PageShift + asanpoison(base, bytes) + } h.freeSpanLocked(s, spanAllocHeap) unlock(&h.lock) }) diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go index 0e6043cf2a..b4de8f53a9 100644 --- a/src/runtime/mprof.go +++ b/src/runtime/mprof.go @@ -627,6 +627,9 @@ func record(r *MemProfileRecord, b *bucket) { if msanenabled { msanwrite(unsafe.Pointer(&r.Stack0[0]), unsafe.Sizeof(r.Stack0)) } + if asanenabled { + asanwrite(unsafe.Pointer(&r.Stack0[0]), unsafe.Sizeof(r.Stack0)) + } copy(r.Stack0[:], b.stk()) for i := int(b.nstk); i < len(r.Stack0); i++ { r.Stack0[i] = 0 @@ -680,6 +683,9 @@ func BlockProfile(p []BlockProfileRecord) (n int, ok bool) { if msanenabled { msanwrite(unsafe.Pointer(&r.Stack0[0]), unsafe.Sizeof(r.Stack0)) } + if asanenabled { + asanwrite(unsafe.Pointer(&r.Stack0[0]), unsafe.Sizeof(r.Stack0)) + } i := copy(r.Stack0[:], b.stk()) for ; i < len(r.Stack0); i++ { r.Stack0[i] = 0 diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 615f53d31f..bf5fa8e4fc 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -2233,6 +2233,9 @@ func newm1(mp *m) { if msanenabled { msanwrite(unsafe.Pointer(&ts), unsafe.Sizeof(ts)) } + if asanenabled { + asanwrite(unsafe.Pointer(&ts), unsafe.Sizeof(ts)) + } execLock.rlock() // Prevent process clone. asmcgocall(_cgo_thread_start, unsafe.Pointer(&ts)) execLock.runlock() @@ -4435,6 +4438,9 @@ retry: if msanenabled { msanmalloc(unsafe.Pointer(gp.stack.lo), gp.stack.hi-gp.stack.lo) } + if asanenabled { + asanunpoison(unsafe.Pointer(gp.stack.lo), gp.stack.hi-gp.stack.lo) + } } return gp } diff --git a/src/runtime/select.go b/src/runtime/select.go index ee1f95ffa9..e18b2f14c0 100644 --- a/src/runtime/select.go +++ b/src/runtime/select.go @@ -406,6 +406,13 @@ func selectgo(cas0 *scase, order0 *uint16, pc0 *uintptr, nsends, nrecvs int, blo msanwrite(cas.elem, c.elemtype.size) } } + if asanenabled { + if casi < nsends { + asanread(cas.elem, c.elemtype.size) + } else if cas.elem != nil { + asanwrite(cas.elem, c.elemtype.size) + } + } selunlock(scases, lockorder) goto retc @@ -421,6 +428,9 @@ bufrecv: if msanenabled && cas.elem != nil { msanwrite(cas.elem, c.elemtype.size) } + if asanenabled && cas.elem != nil { + asanwrite(cas.elem, c.elemtype.size) + } recvOK = true qp = chanbuf(c, c.recvx) if cas.elem != nil { @@ -444,6 +454,9 @@ bufsend: if msanenabled { msanread(cas.elem, c.elemtype.size) } + if asanenabled { + asanread(cas.elem, c.elemtype.size) + } typedmemmove(c.elemtype, chanbuf(c, c.sendx), cas.elem) c.sendx++ if c.sendx == c.dataqsiz { @@ -482,6 +495,9 @@ send: if msanenabled { msanread(cas.elem, c.elemtype.size) } + if asanenabled { + asanread(cas.elem, c.elemtype.size) + } send(c, sg, cas.elem, func() { selunlock(scases, lockorder) }, 2) if debugSelect { print("syncsend: cas0=", cas0, " c=", c, "\n") diff --git a/src/runtime/slice.go b/src/runtime/slice.go index aab8a598c5..ac0b7d5fef 100644 --- a/src/runtime/slice.go +++ b/src/runtime/slice.go @@ -76,6 +76,9 @@ func makeslicecopy(et *_type, tolen int, fromlen int, from unsafe.Pointer) unsaf if msanenabled { msanread(from, copymem) } + if asanenabled { + asanread(from, copymem) + } memmove(to, from, copymem) @@ -168,6 +171,9 @@ func growslice(et *_type, old slice, cap int) slice { if msanenabled { msanread(old.array, uintptr(old.len*int(et.size))) } + if asanenabled { + asanread(old.array, uintptr(old.len*int(et.size))) + } if cap < old.cap { panic(errorString("growslice: cap out of range")) @@ -311,6 +317,10 @@ func slicecopy(toPtr unsafe.Pointer, toLen int, fromPtr unsafe.Pointer, fromLen msanread(fromPtr, size) msanwrite(toPtr, size) } + if asanenabled { + asanread(fromPtr, size) + asanwrite(toPtr, size) + } if size == 1 { // common case worth about 2x to do here // TODO: is this still worth it with new memmove impl? diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 8ae9c1e698..52d21e4ee4 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -424,6 +424,9 @@ func stackalloc(n uint32) stack { if msanenabled { msanmalloc(v, uintptr(n)) } + if asanenabled { + asanunpoison(v, uintptr(n)) + } if stackDebug >= 1 { print(" allocated ", v, "\n") } @@ -461,6 +464,9 @@ func stackfree(stk stack) { if msanenabled { msanfree(v, n) } + if asanenabled { + asanpoison(v, n) + } if n < _FixedStack<<_NumStackOrders && n < _StackCacheSize { order := uint8(0) n2 := n diff --git a/src/runtime/string.go b/src/runtime/string.go index d6990dab9a..980a9866e6 100644 --- a/src/runtime/string.go +++ b/src/runtime/string.go @@ -94,6 +94,9 @@ func slicebytetostring(buf *tmpBuf, ptr *byte, n int) (str string) { if msanenabled { msanread(unsafe.Pointer(ptr), uintptr(n)) } + if asanenabled { + asanread(unsafe.Pointer(ptr), uintptr(n)) + } if n == 1 { p := unsafe.Pointer(&staticuint64s[*ptr]) if goarch.BigEndian { @@ -158,6 +161,9 @@ func slicebytetostringtmp(ptr *byte, n int) (str string) { if msanenabled && n > 0 { msanread(unsafe.Pointer(ptr), uintptr(n)) } + if asanenabled && n > 0 { + asanread(unsafe.Pointer(ptr), uintptr(n)) + } stringStructOf(&str).str = unsafe.Pointer(ptr) stringStructOf(&str).len = n return @@ -209,6 +215,9 @@ func slicerunetostring(buf *tmpBuf, a []rune) string { if msanenabled && len(a) > 0 { msanread(unsafe.Pointer(&a[0]), uintptr(len(a))*unsafe.Sizeof(a[0])) } + if asanenabled && len(a) > 0 { + asanread(unsafe.Pointer(&a[0]), uintptr(len(a))*unsafe.Sizeof(a[0])) + } var dum [4]byte size1 := 0 for _, r := range a { diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 5de1abce9a..36627a6735 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -1390,6 +1390,9 @@ func callCgoSymbolizer(arg *cgoSymbolizerArg) { if msanenabled { msanwrite(unsafe.Pointer(arg), unsafe.Sizeof(cgoSymbolizerArg{})) } + if asanenabled { + asanwrite(unsafe.Pointer(arg), unsafe.Sizeof(cgoSymbolizerArg{})) + } call(cgoSymbolizer, noescape(unsafe.Pointer(arg))) } @@ -1412,5 +1415,8 @@ func cgoContextPCs(ctxt uintptr, buf []uintptr) { if msanenabled { msanwrite(unsafe.Pointer(&arg), unsafe.Sizeof(arg)) } + if asanenabled { + asanwrite(unsafe.Pointer(&arg), unsafe.Sizeof(arg)) + } call(cgoTraceback, noescape(unsafe.Pointer(&arg))) } diff --git a/src/syscall/asan.go b/src/syscall/asan.go new file mode 100644 index 0000000000..3199130211 --- /dev/null +++ b/src/syscall/asan.go @@ -0,0 +1,23 @@ +// Copyright 2021 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. + +//go:build asan +// +build asan + +package syscall + +import ( + "runtime" + "unsafe" +) + +const asanenabled = true + +func asanRead(addr unsafe.Pointer, len int) { + runtime.ASanRead(addr, len) +} + +func asanWrite(addr unsafe.Pointer, len int) { + runtime.ASanWrite(addr, len) +} diff --git a/src/syscall/asan0.go b/src/syscall/asan0.go new file mode 100644 index 0000000000..7b69f4a64b --- /dev/null +++ b/src/syscall/asan0.go @@ -0,0 +1,20 @@ +// Copyright 2020 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. + +//go:build !asan +// +build !asan + +package syscall + +import ( + "unsafe" +) + +const asanenabled = false + +func asanRead(addr unsafe.Pointer, len int) { +} + +func asanWrite(addr unsafe.Pointer, len int) { +} diff --git a/src/syscall/syscall_unix.go b/src/syscall/syscall_unix.go index 9413db3832..5a91a023e1 100644 --- a/src/syscall/syscall_unix.go +++ b/src/syscall/syscall_unix.go @@ -197,6 +197,9 @@ func Read(fd int, p []byte) (n int, err error) { if msanenabled && n > 0 { msanWrite(unsafe.Pointer(&p[0]), n) } + if asanenabled && n > 0 { + asanWrite(unsafe.Pointer(&p[0]), n) + } return } @@ -218,6 +221,9 @@ func Write(fd int, p []byte) (n int, err error) { if msanenabled && n > 0 { msanRead(unsafe.Pointer(&p[0]), n) } + if asanenabled && n > 0 { + asanRead(unsafe.Pointer(&p[0]), n) + } return } diff --git a/src/syscall/syscall_windows.go b/src/syscall/syscall_windows.go index a8a78b9ef8..0456074d47 100644 --- a/src/syscall/syscall_windows.go +++ b/src/syscall/syscall_windows.go @@ -394,6 +394,9 @@ func Read(fd Handle, p []byte) (n int, err error) { if msanenabled && done > 0 { msanWrite(unsafe.Pointer(&p[0]), int(done)) } + if asanenabled && done > 0 { + asanWrite(unsafe.Pointer(&p[0]), int(done)) + } return int(done), nil } @@ -412,6 +415,9 @@ func Write(fd Handle, p []byte) (n int, err error) { if msanenabled && done > 0 { msanRead(unsafe.Pointer(&p[0]), int(done)) } + if asanenabled && done > 0 { + asanRead(unsafe.Pointer(&p[0]), int(done)) + } return int(done), nil } From a97c527ac491cc13f6778010a2a81c84642ea1ca Mon Sep 17 00:00:00 2001 From: Rhys Hiltner Date: Wed, 29 Sep 2021 17:35:27 -0700 Subject: [PATCH 288/406] runtime: add padding to Linux kernel structures Go exchanges siginfo and sigevent structures with the kernel. They contain unions, but Go's use is limited to the first few fields. Pad out the rest so the size Go sees is the same as what the Linux kernel sees. This is a follow-up to CL 342052 which added the sigevent struct without padding, and to CL 353136 which added the padding but with an assertion that confused several type-checkers. It updates the siginfo struct as well so there are no bad examples in the defs_linux_*.go files. Reviewed-on: https://go-review.googlesource.com/c/go/+/353136 Change-Id: I9610632ff0ec43eba91f560536f5441fa907b36f Reviewed-on: https://go-review.googlesource.com/c/go/+/360094 Run-TryBot: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Reviewed-by: Michael Pratt --- src/runtime/defs_linux_386.go | 20 ++++++++++++++++++-- src/runtime/defs_linux_amd64.go | 20 ++++++++++++++++++-- src/runtime/defs_linux_arm.go | 20 ++++++++++++++++++-- src/runtime/defs_linux_arm64.go | 20 ++++++++++++++++++-- src/runtime/defs_linux_mips64x.go | 20 ++++++++++++++++++-- src/runtime/defs_linux_mipsx.go | 20 ++++++++++++++++++-- src/runtime/defs_linux_ppc64.go | 20 ++++++++++++++++++-- src/runtime/defs_linux_ppc64le.go | 20 ++++++++++++++++++-- src/runtime/defs_linux_riscv64.go | 20 ++++++++++++++++++-- src/runtime/defs_linux_s390x.go | 20 ++++++++++++++++++-- src/runtime/export_linux_test.go | 5 +++++ src/runtime/os_linux.go | 16 ++++++++++------ src/runtime/runtime_linux_test.go | 11 +++++++++++ 13 files changed, 206 insertions(+), 26 deletions(-) diff --git a/src/runtime/defs_linux_386.go b/src/runtime/defs_linux_386.go index d8b546cb4c..24fb58bbf8 100644 --- a/src/runtime/defs_linux_386.go +++ b/src/runtime/defs_linux_386.go @@ -3,6 +3,8 @@ package runtime +import "unsafe" + const ( _EINTR = 0x4 _EAGAIN = 0xb @@ -166,7 +168,7 @@ type sigactiont struct { sa_mask uint64 } -type siginfo struct { +type siginfoFields struct { si_signo int32 si_errno int32 si_code int32 @@ -174,6 +176,13 @@ type siginfo struct { si_addr uint32 } +type siginfo struct { + siginfoFields + + // Pad struct to the max size in the kernel. + _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte +} + type stackt struct { ss_sp *byte ss_flags int32 @@ -229,7 +238,7 @@ type itimerval struct { it_value timeval } -type sigevent struct { +type sigeventFields struct { value uintptr signo int32 notify int32 @@ -237,6 +246,13 @@ type sigevent struct { sigev_notify_thread_id int32 } +type sigevent struct { + sigeventFields + + // Pad struct to the max size in the kernel. + _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte +} + type epollevent struct { events uint32 data [8]byte // to match amd64 diff --git a/src/runtime/defs_linux_amd64.go b/src/runtime/defs_linux_amd64.go index 6afb67f77f..36da22f8ce 100644 --- a/src/runtime/defs_linux_amd64.go +++ b/src/runtime/defs_linux_amd64.go @@ -3,6 +3,8 @@ package runtime +import "unsafe" + const ( _EINTR = 0x4 _EAGAIN = 0xb @@ -128,7 +130,7 @@ type sigactiont struct { sa_mask uint64 } -type siginfo struct { +type siginfoFields struct { si_signo int32 si_errno int32 si_code int32 @@ -136,6 +138,13 @@ type siginfo struct { si_addr uint64 } +type siginfo struct { + siginfoFields + + // Pad struct to the max size in the kernel. + _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte +} + type itimerspec struct { it_interval timespec it_value timespec @@ -146,7 +155,7 @@ type itimerval struct { it_value timeval } -type sigevent struct { +type sigeventFields struct { value uintptr signo int32 notify int32 @@ -154,6 +163,13 @@ type sigevent struct { sigev_notify_thread_id int32 } +type sigevent struct { + sigeventFields + + // Pad struct to the max size in the kernel. + _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte +} + type epollevent struct { events uint32 data [8]byte // unaligned uintptr diff --git a/src/runtime/defs_linux_arm.go b/src/runtime/defs_linux_arm.go index ec24d76326..13d06969e3 100644 --- a/src/runtime/defs_linux_arm.go +++ b/src/runtime/defs_linux_arm.go @@ -4,6 +4,8 @@ package runtime +import "unsafe" + // Constants const ( _EINTR = 0x4 @@ -169,7 +171,7 @@ type itimerval struct { it_value timeval } -type sigevent struct { +type sigeventFields struct { value uintptr signo int32 notify int32 @@ -177,7 +179,14 @@ type sigevent struct { sigev_notify_thread_id int32 } -type siginfo struct { +type sigevent struct { + sigeventFields + + // Pad struct to the max size in the kernel. + _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte +} + +type siginfoFields struct { si_signo int32 si_errno int32 si_code int32 @@ -185,6 +194,13 @@ type siginfo struct { si_addr uint32 } +type siginfo struct { + siginfoFields + + // Pad struct to the max size in the kernel. + _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte +} + type sigactiont struct { sa_handler uintptr sa_flags uint32 diff --git a/src/runtime/defs_linux_arm64.go b/src/runtime/defs_linux_arm64.go index f9f175004b..f9ee9cbc35 100644 --- a/src/runtime/defs_linux_arm64.go +++ b/src/runtime/defs_linux_arm64.go @@ -3,6 +3,8 @@ package runtime +import "unsafe" + const ( _EINTR = 0x4 _EAGAIN = 0xb @@ -128,7 +130,7 @@ type sigactiont struct { sa_mask uint64 } -type siginfo struct { +type siginfoFields struct { si_signo int32 si_errno int32 si_code int32 @@ -136,6 +138,13 @@ type siginfo struct { si_addr uint64 } +type siginfo struct { + siginfoFields + + // Pad struct to the max size in the kernel. + _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte +} + type itimerspec struct { it_interval timespec it_value timespec @@ -146,7 +155,7 @@ type itimerval struct { it_value timeval } -type sigevent struct { +type sigeventFields struct { value uintptr signo int32 notify int32 @@ -154,6 +163,13 @@ type sigevent struct { sigev_notify_thread_id int32 } +type sigevent struct { + sigeventFields + + // Pad struct to the max size in the kernel. + _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte +} + type epollevent struct { events uint32 _pad uint32 diff --git a/src/runtime/defs_linux_mips64x.go b/src/runtime/defs_linux_mips64x.go index 63433cb9be..2601082ee1 100644 --- a/src/runtime/defs_linux_mips64x.go +++ b/src/runtime/defs_linux_mips64x.go @@ -6,6 +6,8 @@ package runtime +import "unsafe" + const ( _EINTR = 0x4 _EAGAIN = 0xb @@ -134,7 +136,7 @@ type sigactiont struct { sa_restorer uintptr } -type siginfo struct { +type siginfoFields struct { si_signo int32 si_code int32 si_errno int32 @@ -143,6 +145,13 @@ type siginfo struct { si_addr uint64 } +type siginfo struct { + siginfoFields + + // Pad struct to the max size in the kernel. + _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte +} + type itimerspec struct { it_interval timespec it_value timespec @@ -153,7 +162,7 @@ type itimerval struct { it_value timeval } -type sigevent struct { +type sigeventFields struct { value uintptr signo int32 notify int32 @@ -161,6 +170,13 @@ type sigevent struct { sigev_notify_thread_id int32 } +type sigevent struct { + sigeventFields + + // Pad struct to the max size in the kernel. + _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte +} + type epollevent struct { events uint32 pad_cgo_0 [4]byte diff --git a/src/runtime/defs_linux_mipsx.go b/src/runtime/defs_linux_mipsx.go index ffbf5051eb..37651ef7e4 100644 --- a/src/runtime/defs_linux_mipsx.go +++ b/src/runtime/defs_linux_mipsx.go @@ -6,6 +6,8 @@ package runtime +import "unsafe" + const ( _EINTR = 0x4 _EAGAIN = 0xb @@ -129,7 +131,7 @@ type sigactiont struct { sa_restorer uintptr } -type siginfo struct { +type siginfoFields struct { si_signo int32 si_code int32 si_errno int32 @@ -137,6 +139,13 @@ type siginfo struct { si_addr uint32 } +type siginfo struct { + siginfoFields + + // Pad struct to the max size in the kernel. + _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte +} + type itimerspec struct { it_interval timespec it_value timespec @@ -147,7 +156,7 @@ type itimerval struct { it_value timeval } -type sigevent struct { +type sigeventFields struct { value uintptr signo int32 notify int32 @@ -155,6 +164,13 @@ type sigevent struct { sigev_notify_thread_id int32 } +type sigevent struct { + sigeventFields + + // Pad struct to the max size in the kernel. + _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte +} + type epollevent struct { events uint32 pad_cgo_0 [4]byte diff --git a/src/runtime/defs_linux_ppc64.go b/src/runtime/defs_linux_ppc64.go index e0775e2974..c7aa7234c1 100644 --- a/src/runtime/defs_linux_ppc64.go +++ b/src/runtime/defs_linux_ppc64.go @@ -3,6 +3,8 @@ package runtime +import "unsafe" + const ( _EINTR = 0x4 _EAGAIN = 0xb @@ -129,7 +131,7 @@ type sigactiont struct { sa_mask uint64 } -type siginfo struct { +type siginfoFields struct { si_signo int32 si_errno int32 si_code int32 @@ -137,6 +139,13 @@ type siginfo struct { si_addr uint64 } +type siginfo struct { + siginfoFields + + // Pad struct to the max size in the kernel. + _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte +} + type itimerspec struct { it_interval timespec it_value timespec @@ -147,7 +156,7 @@ type itimerval struct { it_value timeval } -type sigevent struct { +type sigeventFields struct { value uintptr signo int32 notify int32 @@ -155,6 +164,13 @@ type sigevent struct { sigev_notify_thread_id int32 } +type sigevent struct { + sigeventFields + + // Pad struct to the max size in the kernel. + _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte +} + type epollevent struct { events uint32 pad_cgo_0 [4]byte diff --git a/src/runtime/defs_linux_ppc64le.go b/src/runtime/defs_linux_ppc64le.go index e0775e2974..c7aa7234c1 100644 --- a/src/runtime/defs_linux_ppc64le.go +++ b/src/runtime/defs_linux_ppc64le.go @@ -3,6 +3,8 @@ package runtime +import "unsafe" + const ( _EINTR = 0x4 _EAGAIN = 0xb @@ -129,7 +131,7 @@ type sigactiont struct { sa_mask uint64 } -type siginfo struct { +type siginfoFields struct { si_signo int32 si_errno int32 si_code int32 @@ -137,6 +139,13 @@ type siginfo struct { si_addr uint64 } +type siginfo struct { + siginfoFields + + // Pad struct to the max size in the kernel. + _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte +} + type itimerspec struct { it_interval timespec it_value timespec @@ -147,7 +156,7 @@ type itimerval struct { it_value timeval } -type sigevent struct { +type sigeventFields struct { value uintptr signo int32 notify int32 @@ -155,6 +164,13 @@ type sigevent struct { sigev_notify_thread_id int32 } +type sigevent struct { + sigeventFields + + // Pad struct to the max size in the kernel. + _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte +} + type epollevent struct { events uint32 pad_cgo_0 [4]byte diff --git a/src/runtime/defs_linux_riscv64.go b/src/runtime/defs_linux_riscv64.go index 1052213a4c..332720a8c8 100644 --- a/src/runtime/defs_linux_riscv64.go +++ b/src/runtime/defs_linux_riscv64.go @@ -4,6 +4,8 @@ package runtime +import "unsafe" + const ( _EINTR = 0x4 _EAGAIN = 0xb @@ -126,7 +128,7 @@ type sigactiont struct { sa_mask uint64 } -type siginfo struct { +type siginfoFields struct { si_signo int32 si_errno int32 si_code int32 @@ -134,6 +136,13 @@ type siginfo struct { si_addr uint64 } +type siginfo struct { + siginfoFields + + // Pad struct to the max size in the kernel. + _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte +} + type itimerspec struct { it_interval timespec it_value timespec @@ -144,7 +153,7 @@ type itimerval struct { it_value timeval } -type sigevent struct { +type sigeventFields struct { value uintptr signo int32 notify int32 @@ -152,6 +161,13 @@ type sigevent struct { sigev_notify_thread_id int32 } +type sigevent struct { + sigeventFields + + // Pad struct to the max size in the kernel. + _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte +} + type epollevent struct { events uint32 pad_cgo_0 [4]byte diff --git a/src/runtime/defs_linux_s390x.go b/src/runtime/defs_linux_s390x.go index b072955d4a..740d8100c5 100644 --- a/src/runtime/defs_linux_s390x.go +++ b/src/runtime/defs_linux_s390x.go @@ -4,6 +4,8 @@ package runtime +import "unsafe" + const ( _EINTR = 0x4 _EAGAIN = 0xb @@ -125,7 +127,7 @@ type sigactiont struct { sa_mask uint64 } -type siginfo struct { +type siginfoFields struct { si_signo int32 si_errno int32 si_code int32 @@ -133,6 +135,13 @@ type siginfo struct { si_addr uint64 } +type siginfo struct { + siginfoFields + + // Pad struct to the max size in the kernel. + _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte +} + type itimerspec struct { it_interval timespec it_value timespec @@ -143,7 +152,7 @@ type itimerval struct { it_value timeval } -type sigevent struct { +type sigeventFields struct { value uintptr signo int32 notify int32 @@ -151,6 +160,13 @@ type sigevent struct { sigev_notify_thread_id int32 } +type sigevent struct { + sigeventFields + + // Pad struct to the max size in the kernel. + _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte +} + type epollevent struct { events uint32 pad_cgo_0 [4]byte diff --git a/src/runtime/export_linux_test.go b/src/runtime/export_linux_test.go index b7c901f238..dea94a934c 100644 --- a/src/runtime/export_linux_test.go +++ b/src/runtime/export_linux_test.go @@ -8,11 +8,16 @@ package runtime import "unsafe" +const SiginfoMaxSize = _si_max_size +const SigeventMaxSize = _sigev_max_size + var NewOSProc0 = newosproc0 var Mincore = mincore var Add = add type EpollEvent epollevent +type Siginfo siginfo +type Sigevent sigevent func Epollctl(epfd, op, fd int32, ev unsafe.Pointer) int32 { return epollctl(epfd, op, fd, (*epollevent)(ev)) diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index 06773c2193..32a1e1b4f7 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -440,6 +440,11 @@ func pipe() (r, w int32, errno int32) func pipe2(flags int32) (r, w int32, errno int32) func setNonblock(fd int32) +const ( + _si_max_size = 128 + _sigev_max_size = 64 +) + //go:nosplit //go:nowritebarrierrec func setsig(i uint32, fn uintptr) { @@ -636,12 +641,11 @@ func setThreadCPUProfiler(hz int32) { spec.it_interval.setNsec(1e9 / int64(hz)) var timerid int32 - sevp := &sigevent{ - notify: _SIGEV_THREAD_ID, - signo: _SIGPROF, - sigev_notify_thread_id: int32(mp.procid), - } - ret := timer_create(_CLOCK_THREAD_CPUTIME_ID, sevp, &timerid) + var sevp sigevent + sevp.notify = _SIGEV_THREAD_ID + sevp.signo = _SIGPROF + sevp.sigev_notify_thread_id = int32(mp.procid) + ret := timer_create(_CLOCK_THREAD_CPUTIME_ID, &sevp, &timerid) if ret != 0 { // If we cannot create a timer for this M, leave profileTimerValid false // to fall back to the process-wide setitimer profiler. diff --git a/src/runtime/runtime_linux_test.go b/src/runtime/runtime_linux_test.go index cd59368cb2..a753aeea58 100644 --- a/src/runtime/runtime_linux_test.go +++ b/src/runtime/runtime_linux_test.go @@ -61,3 +61,14 @@ func TestEpollctlErrorSign(t *testing.T) { t.Errorf("epollctl = %v, want %v", v, -EBADF) } } + +func TestKernelStructSize(t *testing.T) { + // Check that the Go definitions of structures exchanged with the kernel are + // the same size as what the kernel defines. + if have, want := unsafe.Sizeof(Siginfo{}), uintptr(SiginfoMaxSize); have != want { + t.Errorf("Go's siginfo struct is %d bytes long; kernel expects %d", have, want) + } + if have, want := unsafe.Sizeof(Sigevent{}), uintptr(SigeventMaxSize); have != want { + t.Errorf("Go's sigevent struct is %d bytes long; kernel expects %d", have, want) + } +} From 4633b2db4bec605d7920295322d19f895ae89964 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 1 Nov 2021 20:25:48 -0700 Subject: [PATCH 289/406] cmd/go, internal/cpu: use internal/godebug in tests Change-Id: Ifdf67e778e88ee70780428aa5479d2e091752a3a Reviewed-on: https://go-review.googlesource.com/c/go/+/360605 Run-TryBot: Brad Fitzpatrick Trust: Brad Fitzpatrick TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/cmd/go/go_test.go | 11 ++++++----- src/internal/cpu/cpu_test.go | 3 ++- src/internal/cpu/cpu_x86_test.go | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index c13d77a1af..d8bed1dac0 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -13,6 +13,7 @@ import ( "flag" "fmt" "go/format" + "internal/godebug" "internal/race" "internal/testenv" "io" @@ -2281,7 +2282,7 @@ func TestUpxCompression(t *testing.T) { func TestCacheListStale(t *testing.T) { tooSlow(t) - if strings.Contains(os.Getenv("GODEBUG"), "gocacheverify") { + if godebug.Get("gocacheverify") == "1" { t.Skip("GODEBUG gocacheverify") } tg := testgo(t) @@ -2304,7 +2305,7 @@ func TestCacheListStale(t *testing.T) { func TestCacheCoverage(t *testing.T) { tooSlow(t) - if strings.Contains(os.Getenv("GODEBUG"), "gocacheverify") { + if godebug.Get("gocacheverify") == "1" { t.Skip("GODEBUG gocacheverify") } @@ -2336,7 +2337,7 @@ func TestIssue22588(t *testing.T) { func TestIssue22531(t *testing.T) { tooSlow(t) - if strings.Contains(os.Getenv("GODEBUG"), "gocacheverify") { + if godebug.Get("gocacheverify") == "1" { t.Skip("GODEBUG gocacheverify") } tg := testgo(t) @@ -2365,7 +2366,7 @@ func TestIssue22531(t *testing.T) { func TestIssue22596(t *testing.T) { tooSlow(t) - if strings.Contains(os.Getenv("GODEBUG"), "gocacheverify") { + if godebug.Get("gocacheverify") == "1" { t.Skip("GODEBUG gocacheverify") } tg := testgo(t) @@ -2395,7 +2396,7 @@ func TestIssue22596(t *testing.T) { func TestTestCache(t *testing.T) { tooSlow(t) - if strings.Contains(os.Getenv("GODEBUG"), "gocacheverify") { + if godebug.Get("gocacheverify") == "1" { t.Skip("GODEBUG gocacheverify") } tg := testgo(t) diff --git a/src/internal/cpu/cpu_test.go b/src/internal/cpu/cpu_test.go index 06ad20800f..8c21256b34 100644 --- a/src/internal/cpu/cpu_test.go +++ b/src/internal/cpu/cpu_test.go @@ -6,6 +6,7 @@ package cpu_test import ( . "internal/cpu" + "internal/godebug" "internal/testenv" "os" "os/exec" @@ -52,7 +53,7 @@ func TestDisableAllCapabilities(t *testing.T) { func TestAllCapabilitiesDisabled(t *testing.T) { MustHaveDebugOptionsSupport(t) - if os.Getenv("GODEBUG") != "cpu.all=off" { + if godebug.Get("cpu.all") != "off" { t.Skipf("skipping test: GODEBUG=cpu.all=off not set") } diff --git a/src/internal/cpu/cpu_x86_test.go b/src/internal/cpu/cpu_x86_test.go index 0fef065f20..c8be210055 100644 --- a/src/internal/cpu/cpu_x86_test.go +++ b/src/internal/cpu/cpu_x86_test.go @@ -8,7 +8,7 @@ package cpu_test import ( . "internal/cpu" - "os" + "internal/godebug" "testing" ) @@ -25,7 +25,7 @@ func TestDisableSSE3(t *testing.T) { func TestSSE3DebugOption(t *testing.T) { MustHaveDebugOptionsSupport(t) - if os.Getenv("GODEBUG") != "cpu.sse3=off" { + if godebug.Get("cpu.sse3") != "off" { t.Skipf("skipping test: GODEBUG=cpu.sse3=off not set") } From c1ea3395a6fdb2b66e6f445358ca40b78882adce Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 1 Nov 2021 22:25:55 -0700 Subject: [PATCH 290/406] doc/go1.18: add net/netip Updates #46518 Change-Id: Iefc2fec93becc7b36ba2b933ae79f7c9424317fc Reviewed-on: https://go-review.googlesource.com/c/go/+/360634 Reviewed-by: Ian Lance Taylor Trust: Brad Fitzpatrick --- doc/go1.18.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/doc/go1.18.html b/doc/go1.18.html index 6fe993d51b..82fe6f4520 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -123,10 +123,33 @@ Do not send CLs removing the interior tags from such phrases.

Core library

+

TODO

TODO: complete this section

+

New net/netip package

+

+ The new net/netip + package defines a new IP address type, Addr + that's a small, comparable, value type. Compared to the existing + net.IP type, the netip.Addr type takes less + memory, is immutable, and is comparable so it supports == + and can be used as a map key. +

+

+ In addition to Addr, the package defines + AddrPort, representing + an IP and port, and + Prefix, representing + a network CIDR prefix. +

+

+ The net package now has methods to send and receive UDP packets + using netip.Addr values instead of the relatively heavy + *net.UDPAddr values. +

+

Minor changes to the library

From 3ee426aefa519b0b2f814a834f5026481c187946 Mon Sep 17 00:00:00 2001 From: fanzha02 Date: Tue, 5 Jan 2021 17:52:43 +0800 Subject: [PATCH 291/406] cmd/dist: add asan tests in misc/cgo/testsanitizers package Add asan tests to check the use of Go with -asan option. Currenly, the address sanitizer in Go only checks for error memory access to heap objects. TODO: Enable check for error memory access to global objects. Updates #44853. Change-Id: I83579f229f117b5684a369fc8f365f4dea140648 Reviewed-on: https://go-review.googlesource.com/c/go/+/298615 Trust: fannie zhang Run-TryBot: fannie zhang Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- misc/cgo/testsanitizers/asan_test.go | 66 +++++++++++++++++++ misc/cgo/testsanitizers/cc_test.go | 14 ++++ .../cgo/testsanitizers/testdata/asan1_fail.go | 28 ++++++++ .../cgo/testsanitizers/testdata/asan2_fail.go | 34 ++++++++++ .../cgo/testsanitizers/testdata/asan3_fail.go | 23 +++++++ .../cgo/testsanitizers/testdata/asan4_fail.go | 22 +++++++ .../testdata/asan_useAfterReturn.go | 26 ++++++++ src/cmd/internal/sys/supported.go | 1 + 8 files changed, 214 insertions(+) create mode 100644 misc/cgo/testsanitizers/asan_test.go create mode 100644 misc/cgo/testsanitizers/testdata/asan1_fail.go create mode 100644 misc/cgo/testsanitizers/testdata/asan2_fail.go create mode 100644 misc/cgo/testsanitizers/testdata/asan3_fail.go create mode 100644 misc/cgo/testsanitizers/testdata/asan4_fail.go create mode 100644 misc/cgo/testsanitizers/testdata/asan_useAfterReturn.go diff --git a/misc/cgo/testsanitizers/asan_test.go b/misc/cgo/testsanitizers/asan_test.go new file mode 100644 index 0000000000..dbcce2fe28 --- /dev/null +++ b/misc/cgo/testsanitizers/asan_test.go @@ -0,0 +1,66 @@ +// Copyright 2021 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 sanitizers_test + +import ( + "strings" + "testing" +) + +func TestASAN(t *testing.T) { + goos, err := goEnv("GOOS") + if err != nil { + t.Fatal(err) + } + goarch, err := goEnv("GOARCH") + if err != nil { + t.Fatal(err) + } + // The asan tests require support for the -asan option. + if !aSanSupported(goos, goarch) { + t.Skipf("skipping on %s/%s; -asan option is not supported.", goos, goarch) + } + + t.Parallel() + requireOvercommit(t) + config := configure("address") + config.skipIfCSanitizerBroken(t) + + mustRun(t, config.goCmd("build", "std")) + + cases := []struct { + src string + memoryAccessError string + }{ + {src: "asan1_fail.go", memoryAccessError: "heap-use-after-free"}, + {src: "asan2_fail.go", memoryAccessError: "heap-buffer-overflow"}, + {src: "asan3_fail.go", memoryAccessError: "use-after-poison"}, + {src: "asan4_fail.go", memoryAccessError: "use-after-poison"}, + {src: "asan_useAfterReturn.go"}, + } + for _, tc := range cases { + tc := tc + name := strings.TrimSuffix(tc.src, ".go") + t.Run(name, func(t *testing.T) { + t.Parallel() + + dir := newTempDir(t) + defer dir.RemoveAll(t) + + outPath := dir.Join(name) + mustRun(t, config.goCmd("build", "-o", outPath, srcPath(tc.src))) + + cmd := hangProneCmd(outPath) + if tc.memoryAccessError != "" { + out, err := cmd.CombinedOutput() + if err != nil && strings.Contains(string(out), tc.memoryAccessError) { + return + } + t.Fatalf("%#q exited without expected memory access error\n%s; got failure\n%s", strings.Join(cmd.Args, " "), tc.memoryAccessError, out) + } + mustRun(t, cmd) + }) + } +} diff --git a/misc/cgo/testsanitizers/cc_test.go b/misc/cgo/testsanitizers/cc_test.go index 7af30ab557..b776afa3e6 100644 --- a/misc/cgo/testsanitizers/cc_test.go +++ b/misc/cgo/testsanitizers/cc_test.go @@ -267,6 +267,9 @@ func configure(sanitizer string) *config { c.ldFlags = append(c.ldFlags, "-fPIC", "-static-libtsan") } + case "address": + c.goFlags = append(c.goFlags, "-asan") + default: panic(fmt.Sprintf("unrecognized sanitizer: %q", sanitizer)) } @@ -450,3 +453,14 @@ func mSanSupported(goos, goarch string) bool { return false } } + +// aSanSupported is a copy of the function cmd/internal/sys.ASanSupported, +// because the internal pacakage can't be used here. +func aSanSupported(goos, goarch string) bool { + switch goos { + case "linux": + return goarch == "amd64" || goarch == "arm64" + default: + return false + } +} diff --git a/misc/cgo/testsanitizers/testdata/asan1_fail.go b/misc/cgo/testsanitizers/testdata/asan1_fail.go new file mode 100644 index 0000000000..e60db76981 --- /dev/null +++ b/misc/cgo/testsanitizers/testdata/asan1_fail.go @@ -0,0 +1,28 @@ +// Copyright 2021 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 main + +/* +#include +#include + +int *p; +int* test() { + p = (int *)malloc(2 * sizeof(int)); + free(p); + return p; +} +*/ +import "C" +import "fmt" + +func main() { + // C passes Go an invalid pointer. + a := C.test() + // Use after free + *a = 2 + // We shouldn't get here; asan should stop us first. + fmt.Println(*a) +} diff --git a/misc/cgo/testsanitizers/testdata/asan2_fail.go b/misc/cgo/testsanitizers/testdata/asan2_fail.go new file mode 100644 index 0000000000..e35670c440 --- /dev/null +++ b/misc/cgo/testsanitizers/testdata/asan2_fail.go @@ -0,0 +1,34 @@ +// Copyright 2021 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 main + +/* +#include +#include + +int *p; +int* f() { + int i; + p = (int *)malloc(5*sizeof(int)); + for (i = 0; i < 5; i++) { + p[i] = i+10; + } + return p; +} +*/ +import "C" +import ( + "fmt" + "unsafe" +) + +func main() { + a := C.f() + q5 := (*C.int)(unsafe.Add(unsafe.Pointer(a), 4*5)) + // Access to C pointer out of bounds. + *q5 = 100 + // We shouldn't get here; asan should stop us first. + fmt.Printf("q5: %d, %x\n", *q5, q5) +} diff --git a/misc/cgo/testsanitizers/testdata/asan3_fail.go b/misc/cgo/testsanitizers/testdata/asan3_fail.go new file mode 100644 index 0000000000..9f6d26dd89 --- /dev/null +++ b/misc/cgo/testsanitizers/testdata/asan3_fail.go @@ -0,0 +1,23 @@ +// Copyright 2021 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 main + +/* +#include +#include + +void test(int *a) { + // Access Go pointer out of bounds. + int c = a[5]; // BOOM + // We shouldn't get here; asan should stop us first. + printf("a[5]=%d\n", c); +} +*/ +import "C" + +func main() { + cIntSlice := []C.int{200, 201, 203, 203, 204} + C.test(&cIntSlice[0]) +} diff --git a/misc/cgo/testsanitizers/testdata/asan4_fail.go b/misc/cgo/testsanitizers/testdata/asan4_fail.go new file mode 100644 index 0000000000..12098458ae --- /dev/null +++ b/misc/cgo/testsanitizers/testdata/asan4_fail.go @@ -0,0 +1,22 @@ +// Copyright 2021 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 main + +/* +#include +#include + +void test(int* a) { + // Access Go pointer out of bounds. + a[3] = 300; // BOOM + // We shouldn't get here; asan should stop us first. + printf("a[3]=%d\n", a[3]); +}*/ +import "C" + +func main() { + var cIntArray [2]C.int + C.test(&cIntArray[0]) // cIntArray is moved to heap. +} diff --git a/misc/cgo/testsanitizers/testdata/asan_useAfterReturn.go b/misc/cgo/testsanitizers/testdata/asan_useAfterReturn.go new file mode 100644 index 0000000000..3d3d5a6ab1 --- /dev/null +++ b/misc/cgo/testsanitizers/testdata/asan_useAfterReturn.go @@ -0,0 +1,26 @@ +// Copyright 2021 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 main + +// The -fsanitize=address option of C compier can detect stack-use-after-return bugs. +// In the following program, the local variable 'local' was moved to heap by the Go +// compiler because foo() is returning the reference to 'local', and return stack of +// foo() will be invalid. Thus for main() to use the reference to 'local', the 'local' +// must be available even after foo() has finished. Therefore, Go has no such issue. + +import "fmt" + +var ptr *int + +func main() { + foo() + fmt.Printf("ptr=%x, %v", *ptr, ptr) +} + +func foo() { + var local int + local = 1 + ptr = &local // local is moved to heap. +} diff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go index 4fa5aa495e..de2a3fd140 100644 --- a/src/cmd/internal/sys/supported.go +++ b/src/cmd/internal/sys/supported.go @@ -36,6 +36,7 @@ func MSanSupported(goos, goarch string) bool { // ASanSupported reports whether goos/goarch supports the address // sanitizer option. +// There is a copy of this function in misc/cgo/testsanitizers/cc_test.go. func ASanSupported(goos, goarch string) bool { switch goos { case "linux": From 088bb4bf4ad851a7f9a0d409e2f64c483cb7121a Mon Sep 17 00:00:00 2001 From: Leonard Wang Date: Sat, 30 Oct 2021 22:26:56 +0800 Subject: [PATCH 292/406] A+C: add Leonard Wang (individual CLA) Change-Id: I9fa687804c7f0f1d5a987b95ab1c3110468d1b65 Reviewed-on: https://go-review.googlesource.com/c/go/+/360054 Reviewed-by: Meng Zhuo Reviewed-by: Ian Lance Taylor Trust: Meng Zhuo Run-TryBot: Meng Zhuo TryBot-Result: Go Bot --- AUTHORS | 1 + CONTRIBUTORS | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index ad907967b4..8d7e196732 100644 --- a/AUTHORS +++ b/AUTHORS @@ -817,6 +817,7 @@ Lehner Florian Leigh McCulloch Leo Antunes Leon Klingele +Leonard Wang Leonel Quinteros Lev Shamardin Lewin Bormann diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 706d630193..a548cb0e2f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1569,7 +1569,7 @@ Leigh McCulloch Leo Antunes Leo Rudberg Leon Klingele -Leonard Wang +Leonard Wang Leonardo Comelli Leonel Quinteros Lev Shamardin From 4d7bf41bebc7ad4f71150b8b57fca12aff6da144 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 1 Nov 2021 19:39:18 +0000 Subject: [PATCH 293/406] syscall: remove GOMAXPROCS change in TestExecHelper TestExec and TestExecHelper check for a workaround of a particular OS bug on darwin that's triggered more often via asynchronous preemption. As part of this, the test sets up 100 CPU-bound goroutines, and sets GOMAXPROCS to 50, sleeping for a little bit before calling Exec. Thus far, this is fine because the scheduler runs the Execing goroutine in a timely manner. However, CL 309869 will reduce the minimum heap size, causing a GC to happen during the test. On a 16 CPU machine, with GOMAXPROCS at 50, and 100 CPU-bound goroutines, both the OS scheduler and the Go scheduler are severly oversaturated. As a result, the test often (not always, but often) runs out for the full lifetime of those 100 goroutines, which run for about 1 second. The minimum heap size reduction is not necessary to trigger this; an additional call to runtime.GC in the helper is also sufficient to trigger this delay. The delay on its own isn't great, since it adds a whole second to all.bash on its own. However, it also seems correlated with other subprocess tests in the syscall package, namely TestPassFD and TestFcntlFlock. These tests fail in a fairly superficial way: the file descriptor for the temporary directories they make gets clobbered, is closed, or becomes stale. Change-Id: I213dd5e38967d19a8b317e6d4c5024b57f9e3fed Reviewed-on: https://go-review.googlesource.com/c/go/+/360574 Trust: Michael Knyszek Run-TryBot: Michael Knyszek Reviewed-by: Ian Lance Taylor --- src/syscall/exec_unix_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/syscall/exec_unix_test.go b/src/syscall/exec_unix_test.go index 55f5f7025a..b7ae77552b 100644 --- a/src/syscall/exec_unix_test.go +++ b/src/syscall/exec_unix_test.go @@ -13,7 +13,6 @@ import ( "os" "os/exec" "os/signal" - "runtime" "syscall" "testing" "time" @@ -327,7 +326,6 @@ func TestExecHelper(t *testing.T) { // We don't have to worry about restoring these values. // We are in a child process that only runs this test, // and we are going to call syscall.Exec anyhow. - runtime.GOMAXPROCS(50) os.Setenv("GO_WANT_HELPER_PROCESS", "3") stop := time.Now().Add(time.Second) From da7173a2ed637c803b8ff59d0c948e7c7d056c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisend=C3=B6rfer?= Date: Mon, 20 Sep 2021 16:09:47 +0200 Subject: [PATCH 294/406] runtime: fix missing pprof labels Use gp.m.curg instead of the gp when recording cpu profiler stack traces. This ensures profiler labels are captured when systemstack or similar is executing on behalf of the current goroutine. After this there are still rare cases of samples containing the labelHog function, so more work might be needed. This patch should fix ~99% of the problem. Fixes #48577. Change-Id: I27132110e3d09721ec3b3ef417122bc70d8f3279 Reviewed-on: https://go-review.googlesource.com/c/go/+/351751 Reviewed-by: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Trust: Michael Knyszek --- src/runtime/cpuprof.go | 11 +----- src/runtime/pprof/pprof_test.go | 67 +++++++++++++++++++++++++++++++++ src/runtime/proc.go | 9 ++++- 3 files changed, 76 insertions(+), 11 deletions(-) diff --git a/src/runtime/cpuprof.go b/src/runtime/cpuprof.go index c81ab710c2..6076564716 100644 --- a/src/runtime/cpuprof.go +++ b/src/runtime/cpuprof.go @@ -89,7 +89,7 @@ func SetCPUProfileRate(hz int) { // held at the time of the signal, nor can it use substantial amounts // of stack. //go:nowritebarrierrec -func (p *cpuProfile) add(gp *g, stk []uintptr) { +func (p *cpuProfile) add(tagPtr *unsafe.Pointer, stk []uintptr) { // Simple cas-lock to coordinate with setcpuprofilerate. for !atomic.Cas(&prof.signalLock, 0, 1) { osyield() @@ -104,15 +104,6 @@ func (p *cpuProfile) add(gp *g, stk []uintptr) { // because otherwise its write barrier behavior may not // be correct. See the long comment there before // changing the argument here. - // - // Note: it can happen on Windows, where we are calling - // p.add with a gp that is not the current g, that gp is nil, - // meaning we interrupted a system thread with no g. - // Avoid faulting in that case. - var tagPtr *unsafe.Pointer - if gp != nil { - tagPtr = &gp.labels - } cpuprof.log.write(tagPtr, nanotime(), hdr[:], stk) } diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index 06e0274e9a..da006cbe45 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -1361,6 +1361,73 @@ func TestLabelRace(t *testing.T) { }) } +func TestLabelSystemstack(t *testing.T) { + // See http://golang.org/cl/351751. + prof := testCPUProfile(t, stackContainsLabeled, []string{"runtime.systemstack;key=value"}, avoidFunctions(), func(dur time.Duration) { + Do(context.Background(), Labels("key", "value"), func(context.Context) { + var wg sync.WaitGroup + stop := make(chan struct{}) + for i := 0; i < runtime.GOMAXPROCS(0); i++ { + wg.Add(1) + go func() { + defer wg.Done() + labelHog(stop) + }() + } + + time.Sleep(dur) + close(stop) + wg.Wait() + }) + }) + + var withLabel, withoutLabel int64 + for _, s := range prof.Sample { + var systemstack, labelHog bool + for _, loc := range s.Location { + for _, l := range loc.Line { + switch l.Function.Name { + case "runtime.systemstack": + systemstack = true + case "runtime/pprof.labelHog": + labelHog = true + } + } + } + + if systemstack && labelHog { + if s.Label != nil && contains(s.Label["key"], "value") { + withLabel += s.Value[0] + } else { + withoutLabel += s.Value[0] + } + } + } + + // ratio on 2019 Intel MBP before/after CL 351751 for n=30 runs: + // before: mean=0.013 stddev=0.013 min=0.000 max=0.039 + // after : mean=0.996 stddev=0.007 min=0.967 max=1.000 + // + // TODO: Figure out why some samples still contain labelHog without labels. + // Once fixed this test case can be simplified to just check that all samples + // containing labelHog() have the label, and no other samples do. + ratio := float64(withLabel) / float64((withLabel + withoutLabel)) + if ratio < 0.9 { + t.Fatalf("only %.1f%% of labelHog(systemstack()) samples have label", ratio*100) + } +} + +func labelHog(stop chan struct{}) { + for i := 0; ; i++ { + select { + case <-stop: + return + default: + fmt.Fprintf(io.Discard, "%d", i) + } + } +} + // Check that there is no deadlock when the program receives SIGPROF while in // 64bit atomics' critical section. Used to happen on mips{,le}. See #20146. func TestAtomicLoadStore64(t *testing.T) { diff --git a/src/runtime/proc.go b/src/runtime/proc.go index bf5fa8e4fc..268d5ff398 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -4711,7 +4711,14 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) { } if prof.hz != 0 { - cpuprof.add(gp, stk[:n]) + // Note: it can happen on Windows that we interrupted a system thread + // with no g, so gp could nil. The other nil checks are done out of + // caution, but not expected to be nil in practice. + var tagPtr *unsafe.Pointer + if gp != nil && gp.m != nil && gp.m.curg != nil { + tagPtr = &gp.m.curg.labels + } + cpuprof.add(tagPtr, stk[:n]) } getg().m.mallocing-- } From c3cb1ecc36512a00492f27fa3ba19e5dad6194f1 Mon Sep 17 00:00:00 2001 From: Amelia Downs Date: Mon, 27 Sep 2021 16:54:39 -0400 Subject: [PATCH 295/406] internal/fuzz: minimize bytes to be human readable Try to replace every byte with one of the following printable characters: "012789ABCXYZabcxyz !\"#$%&'()*+,.". Fixes #48129 Change-Id: Ie58f6bbc3431d50d9f0a3f608ba63e854ac6ce79 Reviewed-on: https://go-review.googlesource.com/c/go/+/352614 Reviewed-by: Katie Hockman Reviewed-by: Amelia Downs Trust: Katie Hockman Trust: Julie Qiu Run-TryBot: Katie Hockman TryBot-Result: Go Bot --- src/internal/fuzz/minimize.go | 19 ++++++++++++++ src/internal/fuzz/minimize_test.go | 41 +++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/internal/fuzz/minimize.go b/src/internal/fuzz/minimize.go index 974df369ee..c6e4559665 100644 --- a/src/internal/fuzz/minimize.go +++ b/src/internal/fuzz/minimize.go @@ -79,6 +79,25 @@ func minimizeBytes(v []byte, try func(interface{}) bool, shouldStop func() bool) j = len(v) } } + + // Then, try to make it more simplified and human-readable by trying to replace each + // byte with a printable character. + printableChars := []byte("012789ABCXYZabcxyz !\"#$%&'()*+,.") + for i, b := range v { + if shouldStop() { + return + } + + for _, pc := range printableChars { + v[i] = pc + if try(v) { + // Successful. Move on to the next byte in v. + break + } + // Unsuccessful. Revert v[i] back to original value. + v[i] = b + } + } } func minimizeInteger(v uint, try func(interface{}) bool, shouldStop func() bool) { diff --git a/src/internal/fuzz/minimize_test.go b/src/internal/fuzz/minimize_test.go index 13385e14d6..dc153d0de4 100644 --- a/src/internal/fuzz/minimize_test.go +++ b/src/internal/fuzz/minimize_test.go @@ -13,6 +13,8 @@ import ( "fmt" "reflect" "testing" + "unicode" + "unicode/utf8" ) func TestMinimizeInput(t *testing.T) { @@ -54,7 +56,7 @@ func TestMinimizeInput(t *testing.T) { return fmt.Errorf("bad %v", e.Values[0]) }, input: []interface{}{[]byte{1, 2, 3, 4, 5}}, - expected: []interface{}{[]byte{2, 3}}, + expected: []interface{}{[]byte("00")}, }, { name: "set_of_bytes", @@ -71,6 +73,18 @@ func TestMinimizeInput(t *testing.T) { input: []interface{}{[]byte{0, 1, 2, 3, 4, 5}}, expected: []interface{}{[]byte{0, 4, 5}}, }, + { + name: "non_ascii_bytes", + fn: func(e CorpusEntry) error { + b := e.Values[0].([]byte) + if len(b) == 3 { + return fmt.Errorf("bad %v", e.Values[0]) + } + return nil + }, + input: []interface{}{[]byte("ท")}, // ท is 3 bytes + expected: []interface{}{[]byte("000")}, + }, { name: "ones_string", fn: func(e CorpusEntry) error { @@ -89,6 +103,31 @@ func TestMinimizeInput(t *testing.T) { input: []interface{}{"001010001000000000000000000"}, expected: []interface{}{"111"}, }, + { + name: "string_length", + fn: func(e CorpusEntry) error { + b := e.Values[0].(string) + if len(b) == 5 { + return fmt.Errorf("bad %v", e.Values[0]) + } + return nil + }, + input: []interface{}{"zzzzz"}, + expected: []interface{}{"00000"}, + }, + { + name: "string_with_letter", + fn: func(e CorpusEntry) error { + b := e.Values[0].(string) + r, _ := utf8.DecodeRune([]byte(b)) + if unicode.IsLetter(r) { + return fmt.Errorf("bad %v", e.Values[0]) + } + return nil + }, + input: []interface{}{"ZZZZZ"}, + expected: []interface{}{"A"}, + }, { name: "int", fn: func(e CorpusEntry) error { From d39c8739662835b2f92894a8550bbcd59f83557f Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 1 Nov 2021 12:14:25 -0700 Subject: [PATCH 296/406] cmd/compile/internal/types2: fix conversions of constants to type parameter When converting a constant to a type parameter, the result is never constant (type parameters are not constant types), but we still need to verfy that the constant is representable by each specific type in the type set of the type parameter. Fixes #49247. Change-Id: I460983c7070b33baadce25dd23210e10930cfb2c Reviewed-on: https://go-review.googlesource.com/c/go/+/360396 Trust: Robert Griesemer Reviewed-by: Robert Findley --- .../compile/internal/types2/conversions.go | 39 ++++++++++++++----- src/cmd/compile/internal/types2/expr.go | 1 + src/cmd/compile/internal/types2/predicates.go | 6 +++ .../types2/testdata/fixedbugs/issue49247.go2 | 20 ++++++++++ .../types2/testdata/spec/conversions.go2 | 21 ++++++++++ 5 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 src/cmd/compile/internal/types2/testdata/fixedbugs/issue49247.go2 diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index bc33b3a44b..0e26a73cf8 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -16,26 +16,45 @@ import ( func (check *Checker) conversion(x *operand, T Type) { constArg := x.mode == constant_ - var ok bool - var cause string - switch { - case constArg && isConstType(T): - // constant conversion (T cannot be a type parameter) + constConvertibleTo := func(T Type, val *constant.Value) bool { switch t := asBasic(T); { - case representableConst(x.val, check, t, &x.val): - ok = true + case representableConst(x.val, check, t, val): + return true case isInteger(x.typ) && isString(t): codepoint := unicode.ReplacementChar if i, ok := constant.Uint64Val(x.val); ok && i <= unicode.MaxRune { codepoint = rune(i) } - x.val = constant.MakeString(string(codepoint)) - ok = true + if val != nil { + *val = constant.MakeString(string(codepoint)) + } + return true } + return false + } + + var ok bool + var cause string + switch { + case constArg && isConstType(T): + // constant conversion + ok = constConvertibleTo(T, &x.val) + case constArg && isTypeParam(T): + // x is convertible to T if it is convertible + // to each specific type in the type set of T. + // If T's type set is empty, or if it doesn't + // have specific types, constant x cannot be + // converted. + ok = under(T).(*TypeParam).underIs(func(u Type) bool { + // t is nil if there are no specific type terms + // TODO(gri) add a cause in case of failure + return u != nil && constConvertibleTo(u, nil) + }) + x.mode = value // type parameters are not constants case x.convertibleTo(check, T, &cause): // non-constant conversion - x.mode = value ok = true + x.mode = value } if !ok { diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index ae7b205e53..eb5ec9f3fb 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -743,6 +743,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const return nil, nil, _InvalidUntypedConversion } case *TypeParam: + // TODO(gri) review this code - doesn't look quite right ok := t.underIs(func(t Type) bool { target, _, _ := check.implicitTypeAndValue(x, t) return target != nil diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go index 380fb6489c..6d93a8a227 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -80,6 +80,12 @@ func IsInterface(typ Type) bool { return asInterface(typ) != nil } +// isTypeParam reports whether typ is a type parameter. +func isTypeParam(typ Type) bool { + _, ok := under(typ).(*TypeParam) + return ok +} + // Comparable reports whether values of type T are comparable. func Comparable(T Type) bool { return comparable(T, nil) diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49247.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49247.go2 new file mode 100644 index 0000000000..3f25e0ee35 --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49247.go2 @@ -0,0 +1,20 @@ +// Copyright 2021 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 p + +type integer interface { + ~int | ~int8 | ~int16 | ~int32 | ~int64 | + ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr +} + +func Add1024[T integer](s []T) { + for i, v := range s { + s[i] = v + 1024 // ERROR cannot convert 1024 \(untyped int constant\) to T + } +} + +func f[T interface{ int8 }]() { + println(T(1024 /* ERROR cannot convert 1024 \(untyped int value\) to T */)) +} diff --git a/src/cmd/compile/internal/types2/testdata/spec/conversions.go2 b/src/cmd/compile/internal/types2/testdata/spec/conversions.go2 index 0acd2762a1..942d9c0f6f 100644 --- a/src/cmd/compile/internal/types2/testdata/spec/conversions.go2 +++ b/src/cmd/compile/internal/types2/testdata/spec/conversions.go2 @@ -6,6 +6,27 @@ package conversions import "unsafe" +// constant conversions + +func _[T ~byte]() T { return 255 } +func _[T ~byte]() T { return 256 /* ERROR cannot use 256 .* as T value */ } + +func _[T ~byte]() { + const _ = T /* ERROR T\(0\) .* is not constant */ (0) + var _ T = 255 + var _ T = 256 // ERROR cannot use 256 .* as T value +} + +func _[T ~string]() T { return T('a') } +func _[T ~int | ~string]() T { return T('a') } +func _[T ~byte | ~int | ~string]() T { return T(256 /* ERROR cannot convert 256 .* to T */ ) } + +// implicit conversions never convert to string +func _[T ~string]() { + var _ string = 0 // ERROR cannot use .* as string value + var _ T = 0 // ERROR cannot use .* as T value +} + // "x is assignable to T" // - tested via assignability tests From 599de4b2c348738a5d6d2f5d475c74ac835e091a Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 1 Nov 2021 13:41:32 -0700 Subject: [PATCH 297/406] cmd/compile/internal/types2: adjust printing of type parameter in error For constraint type inference failures where the type parameter doesn't match the constraint, print the type parameter rather than its type name object. This provides more flexibility for improving the error message down the road. Change-Id: I188871d6f26a16cd96e59770966a1ec65607b128 Reviewed-on: https://go-review.googlesource.com/c/go/+/360514 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/infer.go | 7 ++++--- .../internal/types2/testdata/fixedbugs/issue45985.go2 | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go index 494e896ee9..24c461f1c3 100644 --- a/src/cmd/compile/internal/types2/infer.go +++ b/src/cmd/compile/internal/types2/infer.go @@ -378,7 +378,6 @@ func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type, // If a constraint has a structural type, unify the corresponding type parameter with it. for _, tpar := range tparams { - typ := tpar sbound := structure(tpar) if sbound != nil { // If the structural type is the underlying type of a single @@ -386,8 +385,10 @@ func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type, if named, _ := tpar.singleType().(*Named); named != nil { sbound = named } - if !u.unify(typ, sbound) { - check.errorf(tpar.obj, "%s does not match %s", tpar.obj, sbound) + if !u.unify(tpar, sbound) { + // TODO(gri) improve error message by providing the type arguments + // which we know already + check.errorf(tpar.obj, "%s does not match %s", tpar, sbound) return nil, 0 } } diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45985.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45985.go2 index ee5282d6ef..9963d2ee00 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45985.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45985.go2 @@ -5,7 +5,7 @@ package issue45985 // TODO(gri): this error should be on app[int] below. -func app[S /* ERROR "type S S does not match" */ interface{ ~[]T }, T any](s S, e T) S { +func app[S /* ERROR "S does not match" */ interface{ ~[]T }, T any](s S, e T) S { return append(s, e) } From f801da7855d3a82cc415279262e6b1ca7df39e5f Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 1 Nov 2021 16:05:14 -0700 Subject: [PATCH 298/406] cmd/compile/internal/types2: fix indexing of generic types Correctly track if the index expression is addressable. Rewrote code slightly. Fixes #49275. Change-Id: Ic54edd0213a091173ff5403ab0e3e1f1fca0e361 Reviewed-on: https://go-review.googlesource.com/c/go/+/360603 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/index.go | 89 ++++++++++--------- .../types2/testdata/check/typeparams.go2 | 8 ++ 2 files changed, 54 insertions(+), 43 deletions(-) diff --git a/src/cmd/compile/internal/types2/index.go b/src/cmd/compile/internal/types2/index.go index 23e433ac6a..bb7033e957 100644 --- a/src/cmd/compile/internal/types2/index.go +++ b/src/cmd/compile/internal/types2/index.go @@ -101,77 +101,80 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo case *TypeParam: // TODO(gri) report detailed failure cause for better error messages - var tkey, telem Type // tkey != nil if we have maps + var key, elem Type // key != nil: we must have all maps + mode := variable // non-maps result mode + // TODO(gri) factor out closure and use it for non-typeparam cases as well if typ.underIs(func(u Type) bool { - var key, elem Type - alen := int64(-1) // valid if >= 0 + l := int64(-1) // valid if >= 0 + var k, e Type // k is only set for maps switch t := u.(type) { case *Basic: - if !isString(t) { - return false + if isString(t) { + e = universeByte + mode = value } - elem = universeByte case *Array: - elem = t.elem - alen = t.len - case *Pointer: - a, _ := under(t.base).(*Array) - if a == nil { - return false + l = t.len + e = t.elem + if x.mode != variable { + mode = value + } + case *Pointer: + if t := asArray(t.base); t != nil { + l = t.len + e = t.elem } - elem = a.elem - alen = a.len case *Slice: - elem = t.elem + e = t.elem case *Map: - key = t.key - elem = t.elem - default: + k = t.key + e = t.elem + } + if e == nil { return false } - assert(elem != nil) - if telem == nil { + if elem == nil { // first type - tkey, telem = key, elem - length = alen - } else { - // all map keys must be identical (incl. all nil) - if !Identical(key, tkey) { - return false - } - // all element types must be identical - if !Identical(elem, telem) { - return false - } - tkey, telem = key, elem - // track the minimal length for arrays - if alen >= 0 && alen < length { - length = alen - } + length = l + key, elem = k, e + return true + } + // all map keys must be identical (incl. all nil) + // (that is, we cannot mix maps with other types) + if !Identical(key, k) { + return false + } + // all element types must be identical + if !Identical(elem, e) { + return false + } + // track the minimal length for arrays, if any + if l >= 0 && l < length { + length = l } return true }) { // For maps, the index expression must be assignable to the map key type. - if tkey != nil { + if key != nil { index := check.singleIndex(e) if index == nil { x.mode = invalid return false } - var key operand - check.expr(&key, index) - check.assignment(&key, tkey, "map index") + var k operand + check.expr(&k, index) + check.assignment(&k, key, "map index") // ok to continue even if indexing failed - map element type is known x.mode = mapindex - x.typ = telem + x.typ = elem x.expr = e return false } // no maps valid = true - x.mode = variable - x.typ = telem + x.mode = mode + x.typ = elem } } diff --git a/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 b/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 index 11adb21d95..a1bf6c262f 100644 --- a/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 +++ b/src/cmd/compile/internal/types2/testdata/check/typeparams.go2 @@ -114,6 +114,14 @@ func _[T interface{ [10]int }](x T, i int) { _ = x[i]; _ = x[9]; _ = x[10 /* ERR func _[T interface{ [10]byte | string }](x T, i int) { _ = x[i]; _ = x[9]; _ = x[10 /* ERROR out of bounds */ ] } func _[T interface{ [10]int | *[20]int | []int }](x T, i int) { _ = x[i]; _ = x[9]; _ = x[10 /* ERROR out of bounds */ ] } +// indexing with strings and non-variable arrays (assignment not permitted) +func _[T string](x T) { _ = x[0]; x /* ERROR cannot assign */ [0] = 0 } +func _[T []byte | string](x T) { x /* ERROR cannot assign */ [0] = 0 } +func _[T [10]byte]() { f := func() (x T) { return }; f /* ERROR cannot assign */ ()[0] = 0 } +func _[T [10]byte]() { f := func() (x *T) { return }; f /* ERROR cannot index */ ()[0] = 0 } +func _[T [10]byte]() { f := func() (x *T) { return }; (*f())[0] = 0 } +func _[T *[10]byte]() { f := func() (x T) { return }; f()[0] = 0 } + // slicing func _[T interface{ ~[10]E }, E any] (x T, i, j, k int) { var _ []E = x[i:j] } From c6a0b6f2de9a778b03a29c656531617a606761f0 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Tue, 2 Nov 2021 15:38:47 +0000 Subject: [PATCH 299/406] Revert "runtime: fix missing pprof labels" This reverts CL 351751. Reason for revert: new test is failing on many builders. Change-Id: I066211c9f25607ca9eb5299aedea2ecc5069e34f Reviewed-on: https://go-review.googlesource.com/c/go/+/360757 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/runtime/cpuprof.go | 11 +++++- src/runtime/pprof/pprof_test.go | 67 --------------------------------- src/runtime/proc.go | 9 +---- 3 files changed, 11 insertions(+), 76 deletions(-) diff --git a/src/runtime/cpuprof.go b/src/runtime/cpuprof.go index 6076564716..c81ab710c2 100644 --- a/src/runtime/cpuprof.go +++ b/src/runtime/cpuprof.go @@ -89,7 +89,7 @@ func SetCPUProfileRate(hz int) { // held at the time of the signal, nor can it use substantial amounts // of stack. //go:nowritebarrierrec -func (p *cpuProfile) add(tagPtr *unsafe.Pointer, stk []uintptr) { +func (p *cpuProfile) add(gp *g, stk []uintptr) { // Simple cas-lock to coordinate with setcpuprofilerate. for !atomic.Cas(&prof.signalLock, 0, 1) { osyield() @@ -104,6 +104,15 @@ func (p *cpuProfile) add(tagPtr *unsafe.Pointer, stk []uintptr) { // because otherwise its write barrier behavior may not // be correct. See the long comment there before // changing the argument here. + // + // Note: it can happen on Windows, where we are calling + // p.add with a gp that is not the current g, that gp is nil, + // meaning we interrupted a system thread with no g. + // Avoid faulting in that case. + var tagPtr *unsafe.Pointer + if gp != nil { + tagPtr = &gp.labels + } cpuprof.log.write(tagPtr, nanotime(), hdr[:], stk) } diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index da006cbe45..06e0274e9a 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -1361,73 +1361,6 @@ func TestLabelRace(t *testing.T) { }) } -func TestLabelSystemstack(t *testing.T) { - // See http://golang.org/cl/351751. - prof := testCPUProfile(t, stackContainsLabeled, []string{"runtime.systemstack;key=value"}, avoidFunctions(), func(dur time.Duration) { - Do(context.Background(), Labels("key", "value"), func(context.Context) { - var wg sync.WaitGroup - stop := make(chan struct{}) - for i := 0; i < runtime.GOMAXPROCS(0); i++ { - wg.Add(1) - go func() { - defer wg.Done() - labelHog(stop) - }() - } - - time.Sleep(dur) - close(stop) - wg.Wait() - }) - }) - - var withLabel, withoutLabel int64 - for _, s := range prof.Sample { - var systemstack, labelHog bool - for _, loc := range s.Location { - for _, l := range loc.Line { - switch l.Function.Name { - case "runtime.systemstack": - systemstack = true - case "runtime/pprof.labelHog": - labelHog = true - } - } - } - - if systemstack && labelHog { - if s.Label != nil && contains(s.Label["key"], "value") { - withLabel += s.Value[0] - } else { - withoutLabel += s.Value[0] - } - } - } - - // ratio on 2019 Intel MBP before/after CL 351751 for n=30 runs: - // before: mean=0.013 stddev=0.013 min=0.000 max=0.039 - // after : mean=0.996 stddev=0.007 min=0.967 max=1.000 - // - // TODO: Figure out why some samples still contain labelHog without labels. - // Once fixed this test case can be simplified to just check that all samples - // containing labelHog() have the label, and no other samples do. - ratio := float64(withLabel) / float64((withLabel + withoutLabel)) - if ratio < 0.9 { - t.Fatalf("only %.1f%% of labelHog(systemstack()) samples have label", ratio*100) - } -} - -func labelHog(stop chan struct{}) { - for i := 0; ; i++ { - select { - case <-stop: - return - default: - fmt.Fprintf(io.Discard, "%d", i) - } - } -} - // Check that there is no deadlock when the program receives SIGPROF while in // 64bit atomics' critical section. Used to happen on mips{,le}. See #20146. func TestAtomicLoadStore64(t *testing.T) { diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 268d5ff398..bf5fa8e4fc 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -4711,14 +4711,7 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) { } if prof.hz != 0 { - // Note: it can happen on Windows that we interrupted a system thread - // with no g, so gp could nil. The other nil checks are done out of - // caution, but not expected to be nil in practice. - var tagPtr *unsafe.Pointer - if gp != nil && gp.m != nil && gp.m.curg != nil { - tagPtr = &gp.m.curg.labels - } - cpuprof.add(tagPtr, stk[:n]) + cpuprof.add(gp, stk[:n]) } getg().m.mallocing-- } From f2ff1c6074b1591c231f8f6b3394f9700cac7fad Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sun, 31 Oct 2021 00:20:13 +0700 Subject: [PATCH 300/406] cmd/compile: fix rewriting slice literal call argument When seeing Key:Value expression in slice literal, the compiler only needs to emit tmp var for the Value, not the whole expression. Fixes #49240 Change-Id: I7bda3c796a93c0fa1974f7c5930f38025dfa665c Reviewed-on: https://go-review.googlesource.com/c/go/+/360055 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Cherry Mui Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/escape/call.go | 6 +++++- test/fixedbugs/issue49240.go | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/issue49240.go diff --git a/src/cmd/compile/internal/escape/call.go b/src/cmd/compile/internal/escape/call.go index 9e5abed591..63e790a786 100644 --- a/src/cmd/compile/internal/escape/call.go +++ b/src/cmd/compile/internal/escape/call.go @@ -337,7 +337,11 @@ func (e *escape) rewriteArgument(argp *ir.Node, init *ir.Nodes, call ir.Node, fn if arg := *argp; arg.Op() == ir.OSLICELIT { list := arg.(*ir.CompLitExpr).List for i := range list { - visit(arg.Pos(), &list[i]) + el := &list[i] + if list[i].Op() == ir.OKEY { + el = &list[i].(*ir.KeyExpr).Value + } + visit(arg.Pos(), el) } } else { visit(call.Pos(), argp) diff --git a/test/fixedbugs/issue49240.go b/test/fixedbugs/issue49240.go new file mode 100644 index 0000000000..26929fe1a2 --- /dev/null +++ b/test/fixedbugs/issue49240.go @@ -0,0 +1,11 @@ +// compile + +// Copyright 2021 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 p + +func f() { + go copy([]int{1: 0}, []int{}) +} From 58fb05a24a756a9a4386faff977e6495cdccb12f Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 2 Nov 2021 10:19:24 +0700 Subject: [PATCH 301/406] cmd/compile: explain special treatment when rewrite slice literal args Followup discussion in CL 360055. Change-Id: I36212c2a497b152d01ed86d244d5f57bd34a64a6 Reviewed-on: https://go-review.googlesource.com/c/go/+/360614 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le Reviewed-by: Cherry Mui TryBot-Result: Go Bot --- src/cmd/compile/internal/escape/call.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/escape/call.go b/src/cmd/compile/internal/escape/call.go index 63e790a786..d1215afca8 100644 --- a/src/cmd/compile/internal/escape/call.go +++ b/src/cmd/compile/internal/escape/call.go @@ -333,7 +333,24 @@ func (e *escape) rewriteArgument(argp *ir.Node, init *ir.Nodes, call ir.Node, fn } } - // Peel away any slice lits. + // Peel away any slice literals for better escape analyze + // them. For example: + // + // go F([]int{a, b}) + // + // If F doesn't escape its arguments, then the slice can + // be allocated on the new goroutine's stack. + // + // For variadic functions, the compiler has already rewritten: + // + // f(a, b, c) + // + // to: + // + // f([]T{a, b, c}...) + // + // So we need to look into slice elements to handle uintptr(ptr) + // arguments to syscall-like functions correctly. if arg := *argp; arg.Op() == ir.OSLICELIT { list := arg.(*ir.CompLitExpr).List for i := range list { From 8c8baad927b2fd0bca589bacab658fe0f7eb5dac Mon Sep 17 00:00:00 2001 From: vpachkov Date: Sun, 31 Oct 2021 11:06:27 +0000 Subject: [PATCH 302/406] runtime: check amd64 microarchitecture level at startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make Go runtime throw if it's been compiled to assume instruction set extensions that aren't available on the CPU. Updates #48506 Change-Id: Ic4d6696e1cd6b28d389a86fe64e8175ea3ca135a GitHub-Last-Rev: ba338377f549344b416fbd519576e95ce5d523be GitHub-Pull-Request: golang/go#48514 Reviewed-on: https://go-review.googlesource.com/c/go/+/351191 Run-TryBot: Martin Möhrmann TryBot-Result: Go Bot Reviewed-by: Martin Möhrmann Reviewed-by: Keith Randall Trust: Martin Möhrmann --- src/runtime/asm_amd64.s | 137 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 135 insertions(+), 2 deletions(-) diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s index 3ab6060ec0..0f0e5be21a 100644 --- a/src/runtime/asm_amd64.s +++ b/src/runtime/asm_amd64.s @@ -78,6 +78,87 @@ GLOBL _rt0_amd64_lib_argc<>(SB),NOPTR, $8 DATA _rt0_amd64_lib_argv<>(SB)/8, $0 GLOBL _rt0_amd64_lib_argv<>(SB),NOPTR, $8 +#ifdef GOAMD64_v2 +DATA bad_cpu_msg<>+0x00(SB)/84, $"This program can only be run on AMD64 processors with v2 microarchitecture support.\n" +#endif + +#ifdef GOAMD64_v3 +DATA bad_cpu_msg<>+0x00(SB)/84, $"This program can only be run on AMD64 processors with v3 microarchitecture support.\n" +#endif + +#ifdef GOAMD64_v4 +DATA bad_cpu_msg<>+0x00(SB)/84, $"This program can only be run on AMD64 processors with v4 microarchitecture support.\n" +#endif + +GLOBL bad_cpu_msg<>(SB), RODATA, $84 + +// Define a list of AMD64 microarchitecture level features +// https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels + + // SSE3 SSSE3 CMPXCHNG16 SSE4.1 SSE4.2 POPCNT +#define V2_FEATURES_CX (1 << 0 | 1 << 9 | 1 << 13 | 1 << 19 | 1 << 20 | 1 << 23) + // LAHF/SAHF +#define V2_EXT_FEATURES_CX (1 << 0) + // FMA MOVBE OSXSAVE AVX F16C +#define V3_FEATURES_CX (V2_FEATURES_CX | 1 << 12 | 1 << 22 | 1 << 27 | 1 << 28 | 1 << 29) + // ABM (FOR LZNCT) +#define V3_EXT_FEATURES_CX (V2_EXT_FEATURES_CX | 1 << 5) + // BMI1 AVX2 BMI2 +#define V3_EXT_FEATURES_BX (1 << 3 | 1 << 5 | 1 << 8) + // XMM YMM +#define V3_OS_SUPPORT_AX (1 << 1 | 1 << 2) + +#define V4_FEATURES_CX V3_FEATURES_CX + +#define V4_EXT_FEATURES_CX V3_EXT_FEATURES_CX + // AVX512F AVX512DQ AVX512CD AVX512BW AVX512VL +#define V4_EXT_FEATURES_BX (V3_EXT_FEATURES_BX | 1 << 16 | 1 << 17 | 1 << 28 | 1 << 30 | 1 << 31) + // OPMASK ZMM +#define V4_OS_SUPPORT_AX (V3_OS_SUPPORT_AX | 1 << 5 | (1 << 6 | 1 << 7)) + +#ifdef GOAMD64_v2 +#define NEED_MAX_CPUID 0x80000001 +#define NEED_FEATURES_CX V2_FEATURES_CX +#define NEED_EXT_FEATURES_CX V2_EXT_FEATURES_CX +#endif + +#ifdef GOAMD64_v3 +#define NEED_MAX_CPUID 0x80000001 +#define NEED_FEATURES_CX V3_FEATURES_CX +#define NEED_EXT_FEATURES_CX V3_EXT_FEATURES_CX +#define NEED_EXT_FEATURES_BX V3_EXT_FEATURES_BX +#define NEED_OS_SUPPORT_AX V3_OS_SUPPORT_AX +#endif + +#ifdef GOAMD64_v4 +#define NEED_MAX_CPUID 0x80000001 +#define NEED_FEATURES_CX V4_FEATURES_CX +#define NEED_EXT_FEATURES_CX V4_EXT_FEATURES_CX +#define NEED_EXT_FEATURES_BX V4_EXT_FEATURES_BX + +// Downgrading v4 OS checks on Darwin for now, see CL 285572. +#ifdef GOOS_darwin +#define NEED_OS_SUPPORT_AX V3_OS_SUPPORT_AX +#else +#define NEED_OS_SUPPORT_AX V4_OS_SUPPORT_AX +#endif + +#endif + +#ifdef GOAMD64_v1 +#define SKIP_GOAMD64_CHECK +#endif + +#ifndef GOAMD64_v1 +#ifndef GOAMD64_v2 +#ifndef GOAMD64_v3 +#ifndef GOAMD64_v4 +#define SKIP_GOAMD64_CHECK +#endif +#endif +#endif +#endif + TEXT runtime·rt0_go(SB),NOSPLIT|TOPFRAME,$0 // copy arguments forward on an even stack MOVQ DI, AX // argc @@ -99,10 +180,24 @@ TEXT runtime·rt0_go(SB),NOSPLIT|TOPFRAME,$0 // find out information about the processor we're on MOVL $0, AX CPUID - MOVL AX, SI CMPL AX, $0 +#ifdef SKIP_GOAMD64_CHECK JE nocpuinfo +#else + JNE has_cpuinfo +bad_cpu: // show that the program requires a certain microarchitecture level. + MOVQ $2, 0(SP) + MOVQ $bad_cpu_msg<>(SB), AX + MOVQ AX, 8(SP) + MOVQ $84, 16(SP) + CALL runtime·write(SB) + MOVQ $1, 0(SP) + CALL runtime·exit(SB) + CALL runtime·abort(SB) +#endif + +has_cpuinfo: CMPL BX, $0x756E6547 // "Genu" JNE notintel CMPL DX, $0x49656E69 // "ineI" @@ -110,13 +205,51 @@ TEXT runtime·rt0_go(SB),NOSPLIT|TOPFRAME,$0 CMPL CX, $0x6C65746E // "ntel" JNE notintel MOVB $1, runtime·isIntel(SB) -notintel: +notintel: // Load EAX=1 cpuid flags MOVL $1, AX CPUID MOVL AX, runtime·processorVersionInfo(SB) +#ifdef NEED_FEATURES_CX + ANDL $NEED_FEATURES_CX, CX + CMPL CX, $NEED_FEATURES_CX + JNE bad_cpu +#endif + +#ifdef NEED_MAX_CPUID + MOVL $0x80000000, AX + CPUID + CMPL AX, $NEED_MAX_CPUID + JL bad_cpu +#endif + +#ifdef NEED_EXT_FEATURES_BX + MOVL $7, AX + MOVL $0, CX + CPUID + ANDL $NEED_EXT_FEATURES_BX, BX + CMPL BX, $NEED_EXT_FEATURES_BX + JNE bad_cpu +#endif + +#ifdef NEED_EXT_FEATURES_CX + MOVL $0x80000001, AX + CPUID + ANDL $NEED_EXT_FEATURES_CX, CX + CMPL CX, $NEED_EXT_FEATURES_CX + JNE bad_cpu +#endif + +#ifdef NEED_OS_SUPPORT_AX + XORL CX, CX + XGETBV + ANDL $NEED_OS_SUPPORT_AX, AX + CMPL AX, $NEED_OS_SUPPORT_AX + JNE bad_cpu +#endif + nocpuinfo: // if there is an _cgo_init, call it. MOVQ _cgo_init(SB), AX From c406380fa984d14a1f104fd2502d832565b45eb2 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Mon, 1 Nov 2021 14:46:35 -0400 Subject: [PATCH 303/406] go/types: better error messages for empty type sets This is a clean port of CL 358175 to go/types. Change-Id: If1b4e51d1579fd168e651d79d031335ff09ca128 Reviewed-on: https://go-review.googlesource.com/c/go/+/360474 Trust: Robert Findley Run-TryBot: Robert Findley Reviewed-by: Robert Griesemer --- src/go/types/instantiate.go | 32 +++++++++++++------ src/go/types/testdata/check/typeinst2.go2 | 28 +++++++++++++--- .../types/testdata/fixedbugs/issue47411.go2 | 2 +- src/go/types/typeset.go | 2 +- 4 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/go/types/instantiate.go b/src/go/types/instantiate.go index 3720cb725a..8d8d281842 100644 --- a/src/go/types/instantiate.go +++ b/src/go/types/instantiate.go @@ -134,8 +134,16 @@ func (check *Checker) verify(pos token.Pos, tparams []*TypeParam, targs []Type) // TODO(gri) This should be a method of interfaces or type sets. func (check *Checker) satisfies(pos token.Pos, targ Type, tpar *TypeParam, smap substMap) error { iface := tpar.iface() + + // Every type argument satisfies interface{}. if iface.Empty() { - return nil // no type bound + return nil + } + + // A type argument that is a type parameter with an empty type set satisfies any constraint. + // (The empty set is a subset of any set.) + if targ := asTypeParam(targ); targ != nil && targ.iface().typeSet().IsEmpty() { + return nil } // TODO(rfindley): it would be great if users could pass in a qualifier here, @@ -149,6 +157,11 @@ func (check *Checker) satisfies(pos token.Pos, targ Type, tpar *TypeParam, smap return errors.New(sprintf(nil, qf, false, format, args...)) } + // No type argument with non-empty type set satisfies the empty type set. + if iface.typeSet().IsEmpty() { + return errorf("%s does not satisfy %s (constraint type set is empty)", targ, tpar.bound) + } + // The type parameter bound is parameterized with the same type parameters // as the instantiated type; before we can use it for bounds checking we // need to instantiate it with the type arguments with which we instantiate @@ -190,28 +203,27 @@ func (check *Checker) satisfies(pos token.Pos, targ Type, tpar *TypeParam, smap } } - // targ's underlying type must also be one of the interface types listed, if any + // targ must also be in the set of types of iface, if any. + // Constraints with empty type sets were already excluded above. if !iface.typeSet().hasTerms() { return nil // nothing to do } - // If targ is itself a type parameter, each of its possible types, but at least one, must be in the - // list of iface types (i.e., the targ type list must be a non-empty subset of the iface types). + // If targ is itself a type parameter, each of its possible types must be in the set + // of iface types (i.e., the targ type set must be a subset of the iface type set). + // Type arguments with empty type sets were already excluded above. if targ := asTypeParam(targ); targ != nil { targBound := targ.iface() - if !targBound.typeSet().hasTerms() { - return errorf("%s does not satisfy %s (%s has no type constraints)", targ, tpar.bound, targ) - } if !targBound.typeSet().subsetOf(iface.typeSet()) { - // TODO(gri) need better error message + // TODO(gri) report which type is missing return errorf("%s does not satisfy %s", targ, tpar.bound) } return nil } - // Otherwise, targ's type or underlying type must also be one of the interface types listed, if any. + // Otherwise, targ's type must be included in the iface type set. if !iface.typeSet().includes(targ) { - // TODO(gri) better error message + // TODO(gri) report which type is missing return errorf("%s does not satisfy %s", targ, tpar.bound) } diff --git a/src/go/types/testdata/check/typeinst2.go2 b/src/go/types/testdata/check/typeinst2.go2 index 37d32263d4..ebcc300675 100644 --- a/src/go/types/testdata/check/typeinst2.go2 +++ b/src/go/types/testdata/check/typeinst2.go2 @@ -226,10 +226,10 @@ type I012 interface { } func f012[T I012]() {} -var _ = f012[int /* ERROR does not satisfy I012 */ ] -var _ = f012[bool /* ERROR does not satisfy I012 */ ] -var _ = f012[string /* ERROR does not satisfy I012 */ ] -var _ = f012[float64 /* ERROR does not satisfy I012 */ ] +var _ = f012[int /* ERROR does not satisfy I012.*type set is empty */ ] +var _ = f012[bool /* ERROR does not satisfy I012.*type set is empty */ ] +var _ = f012[string /* ERROR does not satisfy I012.*type set is empty */ ] +var _ = f012[float64 /* ERROR does not satisfy I012.*type set is empty */ ] type I12 interface { E1 @@ -256,3 +256,23 @@ var _ = f0_[float64 /* ERROR does not satisfy I0_ */ ] // Using a function instance as a type is an error. var _ f0 // ERROR not a type var _ f0 /* ERROR not a type */ [int] + +// Empty type sets can only be satisfied by empty type sets. +type none interface { + // force an empty type set + int + string +} + +func ff[T none]() {} +func gg[T any]() {} +func hh[T ~int]() {} + +func _[T none]() { + _ = ff[int /* ERROR int does not satisfy none \(constraint type set is empty\) */ ] + _ = ff[T] // pathological but ok because T's type set is empty, too + _ = gg[int] + _ = gg[T] + _ = hh[int] + _ = hh[T] +} diff --git a/src/go/types/testdata/fixedbugs/issue47411.go2 b/src/go/types/testdata/fixedbugs/issue47411.go2 index 2fc26d9e85..fde704bb41 100644 --- a/src/go/types/testdata/fixedbugs/issue47411.go2 +++ b/src/go/types/testdata/fixedbugs/issue47411.go2 @@ -19,7 +19,7 @@ func _[P comparable, _ = f[R /* ERROR R has no constraints */ ] _ = g[int] - _ = g[P /* ERROR P has no type constraints */ ] + _ = g[P /* ERROR P does not satisfy interface{interface{comparable; ~int\|~string} */ ] _ = g[Q] _ = g[func /* ERROR does not satisfy comparable */()] _ = g[R /* ERROR R has no constraints */ ] diff --git a/src/go/types/typeset.go b/src/go/types/typeset.go index a1893d0588..d6c4e5cd8c 100644 --- a/src/go/types/typeset.go +++ b/src/go/types/typeset.go @@ -99,7 +99,7 @@ func (s *_TypeSet) String() string { // ---------------------------------------------------------------------------- // Implementation -func (s *_TypeSet) hasTerms() bool { return !s.terms.isAll() } +func (s *_TypeSet) hasTerms() bool { return !s.terms.isEmpty() && !s.terms.isAll() } func (s *_TypeSet) structuralType() Type { return s.terms.structuralType() } func (s *_TypeSet) includes(t Type) bool { return s.terms.includes(t) } func (s1 *_TypeSet) subsetOf(s2 *_TypeSet) bool { return s1.terms.subsetOf(s2.terms) } From af8aafd570bca4f78b434e7633bf33b6e186931c Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Mon, 1 Nov 2021 15:03:53 -0400 Subject: [PATCH 304/406] go/types: clarify is/underIs semantics and implementation This is a port of CL 358594 to go/types. Some code in conversions.go had to be trivially reorganized to align with types2 -- I'm not sure how go/types diverged from the base. Change-Id: I40ce247bbb3b9d0e87ce88c50e440c12774c0745 Reviewed-on: https://go-review.googlesource.com/c/go/+/360475 Trust: Robert Findley Run-TryBot: Robert Findley Reviewed-by: Robert Griesemer --- src/go/types/builtins.go | 5 +++- src/go/types/conversions.go | 18 ++++++++++----- src/go/types/expr.go | 2 ++ src/go/types/infer.go | 2 +- src/go/types/operand.go | 3 +++ src/go/types/typeparam.go | 11 +++++++++ src/go/types/typeset.go | 46 +++++++++++++++++++------------------ 7 files changed, 57 insertions(+), 30 deletions(-) diff --git a/src/go/types/builtins.go b/src/go/types/builtins.go index de7d7e6b5f..87c26775a6 100644 --- a/src/go/types/builtins.go +++ b/src/go/types/builtins.go @@ -843,7 +843,10 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x Type) Type { // Test if t satisfies the requirements for the argument // type and collect possible result types at the same time. var terms []*Term - if !tp.iface().typeSet().is(func(t *term) bool { + if !tp.is(func(t *term) bool { + if t == nil { + return false + } if r := f(t.typ); r != nil { terms = append(terms, NewTerm(t.tilde, r)) return true diff --git a/src/go/types/conversions.go b/src/go/types/conversions.go index fe62adbf10..8c8b63e23a 100644 --- a/src/go/types/conversions.go +++ b/src/go/types/conversions.go @@ -20,7 +20,7 @@ func (check *Checker) conversion(x *operand, T Type) { var cause string switch { case constArg && isConstType(T): - // constant conversion + // constant conversion (T cannot be a type parameter) switch t := asBasic(T); { case representableConst(x.val, check, t, &x.val): ok = true @@ -92,6 +92,16 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { return true } + // determine type parameter operands with specific type terms + Vp, _ := under(x.typ).(*TypeParam) + Tp, _ := under(T).(*TypeParam) + if Vp != nil && !Vp.hasTerms() { + Vp = nil + } + if Tp != nil && !Tp.hasTerms() { + Tp = nil + } + errorf := func(format string, args ...interface{}) { if check != nil && cause != nil { msg := check.sprintf(format, args...) @@ -102,11 +112,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { } } - // TODO(gri) consider passing under(x.typ), under(T) into convertibleToImpl (optimization) - Vp, _ := under(x.typ).(*TypeParam) - Tp, _ := under(T).(*TypeParam) - - // generic cases + // generic cases with specific type terms // (generic operands cannot be constants, so we can ignore x.val) switch { case Vp != nil && Tp != nil: diff --git a/src/go/types/expr.go b/src/go/types/expr.go index 8b26e64971..ef5958ba3f 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -142,6 +142,8 @@ var op2str2 = [...]string{ token.SHL: "shift", } +// If typ is a type parameter, underIs returns the result of typ.underIs(f). +// Otherwise, underIs returns the result of f(under(typ)). func underIs(typ Type, f func(Type) bool) bool { u := under(typ) if tpar, _ := u.(*TypeParam); tpar != nil { diff --git a/src/go/types/infer.go b/src/go/types/infer.go index 43b9af348e..9302bd7f57 100644 --- a/src/go/types/infer.go +++ b/src/go/types/infer.go @@ -315,7 +315,7 @@ func (w *tpWalker) isParameterized(typ Type) (res bool) { } } return tset.is(func(t *term) bool { - return w.isParameterized(t.typ) + return t != nil && w.isParameterized(t.typ) }) case *Map: diff --git a/src/go/types/operand.go b/src/go/types/operand.go index 855dac66aa..ef7d764201 100644 --- a/src/go/types/operand.go +++ b/src/go/types/operand.go @@ -258,6 +258,9 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er if t, _ := under(T).(*TypeParam); t != nil { return t.is(func(t *term) bool { // TODO(gri) this could probably be more efficient + if t == nil { + return false + } if t.tilde { // TODO(gri) We need to check assignability // for the underlying type of x. diff --git a/src/go/types/typeparam.go b/src/go/types/typeparam.go index af36266f11..791e9db8f8 100644 --- a/src/go/types/typeparam.go +++ b/src/go/types/typeparam.go @@ -123,10 +123,21 @@ func (t *TypeParam) structuralType() Type { return t.iface().typeSet().structuralType() } +// hasTerms reports whether the type parameter constraint has specific type terms. +func (t *TypeParam) hasTerms() bool { + return t.iface().typeSet().hasTerms() +} + +// is calls f with the specific type terms of t's constraint and reports whether +// all calls to f returned true. If there are no specific terms, is +// returns the result of f(nil). func (t *TypeParam) is(f func(*term) bool) bool { return t.iface().typeSet().is(f) } +// underIs calls f with the underlying types of the specific type terms +// of t's constraint and reports whether all calls to f returned true. +// If there are no specific terms, underIs returns the result of f(nil). func (t *TypeParam) underIs(f func(Type) bool) bool { return t.iface().typeSet().underIs(f) } diff --git a/src/go/types/typeset.go b/src/go/types/typeset.go index d6c4e5cd8c..215b48488f 100644 --- a/src/go/types/typeset.go +++ b/src/go/types/typeset.go @@ -37,7 +37,7 @@ func (s *_TypeSet) IsComparable() bool { return s.comparable } return s.is(func(t *term) bool { - return Comparable(t.typ) + return t != nil && Comparable(t.typ) }) } @@ -99,27 +99,29 @@ func (s *_TypeSet) String() string { // ---------------------------------------------------------------------------- // Implementation -func (s *_TypeSet) hasTerms() bool { return !s.terms.isEmpty() && !s.terms.isAll() } -func (s *_TypeSet) structuralType() Type { return s.terms.structuralType() } -func (s *_TypeSet) includes(t Type) bool { return s.terms.includes(t) } +// hasTerms reports whether the type set has specific type terms. +func (s *_TypeSet) hasTerms() bool { return !s.terms.isEmpty() && !s.terms.isAll() } + +// structuralType returns the single type in s if there is exactly one; otherwise the result is nil. +func (s *_TypeSet) structuralType() Type { return s.terms.structuralType() } + +// includes reports whether t ∈ s. +func (s *_TypeSet) includes(t Type) bool { return s.terms.includes(t) } + +// subsetOf reports whether s1 ⊆ s2. func (s1 *_TypeSet) subsetOf(s2 *_TypeSet) bool { return s1.terms.subsetOf(s2.terms) } // TODO(gri) TypeSet.is and TypeSet.underIs should probably also go into termlist.go -var topTerm = term{false, theTop} - +// is calls f with the specific type terms of s and reports whether +// all calls to f returned true. If there are no specific terms, is +// returns the result of f(nil). func (s *_TypeSet) is(f func(*term) bool) bool { - if len(s.terms) == 0 { - return false + if !s.hasTerms() { + return f(nil) } for _, t := range s.terms { - // Terms represent the top term with a nil type. - // The rest of the type checker uses the top type - // instead. Convert. - // TODO(gri) investigate if we can do without this - if t.typ == nil { - t = &topTerm - } + assert(t.typ != nil) if !f(t) { return false } @@ -127,17 +129,17 @@ func (s *_TypeSet) is(f func(*term) bool) bool { return true } +// underIs calls f with the underlying types of the specific type terms +// of s and reports whether all calls to f returned true. If there are +// no specific terms, is returns the result of f(nil). func (s *_TypeSet) underIs(f func(Type) bool) bool { - if len(s.terms) == 0 { - return false + if !s.hasTerms() { + return f(nil) } for _, t := range s.terms { - // see corresponding comment in TypeSet.is + assert(t.typ != nil) + // x == under(x) for ~x terms u := t.typ - if u == nil { - u = theTop - } - // t == under(t) for ~t terms if !t.tilde { u = under(u) } From 62b29b035948c08041e4218d0b176d057c8a6f6f Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Mon, 1 Nov 2021 15:11:31 -0400 Subject: [PATCH 305/406] go/types: generalize assignability to generic types This is a port of CL 357917 to go/types. Some error messages in assignability.go2 had to be adjusted. I left a TODO to investigate whether we should align error messages. Change-Id: Ia323ffe18bc08e82de62044f35b8b0f3edd7dc08 Reviewed-on: https://go-review.googlesource.com/c/go/+/360476 Trust: Robert Findley Run-TryBot: Robert Findley Reviewed-by: Robert Griesemer --- src/go/types/check_test.go | 1 + src/go/types/operand.go | 107 ++++++-- src/go/types/testdata/spec/assignability.go2 | 236 ++++++++++++++++++ .../{examples => spec}/conversions.go2 | 0 4 files changed, 318 insertions(+), 26 deletions(-) create mode 100644 src/go/types/testdata/spec/assignability.go2 rename src/go/types/testdata/{examples => spec}/conversions.go2 (100%) diff --git a/src/go/types/check_test.go b/src/go/types/check_test.go index e6176738d1..75b26e34bd 100644 --- a/src/go/types/check_test.go +++ b/src/go/types/check_test.go @@ -359,6 +359,7 @@ func TestIssue47243_TypedRHS(t *testing.T) { } func TestCheck(t *testing.T) { DefPredeclaredTestFuncs(); testDirFiles(t, "testdata/check", false) } +func TestSpec(t *testing.T) { DefPredeclaredTestFuncs(); testDirFiles(t, "testdata/spec", false) } func TestExamples(t *testing.T) { testDirFiles(t, "testdata/examples", false) } func TestFixedbugs(t *testing.T) { testDirFiles(t, "testdata/fixedbugs", false) } diff --git a/src/go/types/operand.go b/src/go/types/operand.go index ef7d764201..0ba3c4bafc 100644 --- a/src/go/types/operand.go +++ b/src/go/types/operand.go @@ -234,53 +234,46 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er V := x.typ - const debugAssignableTo = false - if debugAssignableTo && check != nil { - check.dump("V = %s", V) - check.dump("T = %s", T) - } - // x's type is identical to T if Identical(V, T) { return true, 0 } - Vu := optype(V) - Tu := optype(T) - - if debugAssignableTo && check != nil { - check.dump("Vu = %s", Vu) - check.dump("Tu = %s", Tu) - } + Vu := under(V) + Tu := under(T) + Vp, _ := Vu.(*TypeParam) + Tp, _ := Tu.(*TypeParam) // x is an untyped value representable by a value of type T. if isUntyped(Vu) { - if t, _ := under(T).(*TypeParam); t != nil { - return t.is(func(t *term) bool { - // TODO(gri) this could probably be more efficient + assert(Vp == nil) + if Tp != nil { + // T is a type parameter: x is assignable to T if it is + // representable by each specific type in the type set of T. + return Tp.is(func(t *term) bool { if t == nil { return false } - if t.tilde { - // TODO(gri) We need to check assignability - // for the underlying type of x. - } - ok, _ := x.assignableTo(check, t.typ, reason) - return ok + // A term may be a tilde term but the underlying + // type of an untyped value doesn't change so we + // don't need to do anything special. + newType, _, _ := check.implicitTypeAndValue(x, t.typ) + return newType != nil }), _IncompatibleAssign } - newType, _, _ := check.implicitTypeAndValue(x, Tu) + newType, _, _ := check.implicitTypeAndValue(x, T) return newType != nil, _IncompatibleAssign } // Vu is typed // x's type V and T have identical underlying types // and at least one of V or T is not a named type - if Identical(Vu, Tu) && (!isNamed(V) || !isNamed(T)) { + // and neither is a type parameter. + if Identical(Vu, Tu) && (!isNamed(V) || !isNamed(T)) && Vp == nil && Tp == nil { return true, 0 } - // T is an interface type and x implements T + // T is an interface type and x implements T and T is not a type parameter if Ti, ok := Tu.(*Interface); ok { if m, wrongType := check.missingMethod(V, Ti, true); m != nil /* Implements(V, Ti) */ { if reason != nil { @@ -310,5 +303,67 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er } } - return false, _IncompatibleAssign + // common case: if we don't have type parameters, we're done + if Vp == nil && Tp == nil { + return false, _IncompatibleAssign + } + + // determine type parameter operands with specific type terms + if Vp != nil && !Vp.hasTerms() { + Vp = nil + } + if Tp != nil && !Tp.hasTerms() { + Tp = nil + } + + errorf := func(format string, args ...interface{}) { + if check != nil && reason != nil { + msg := check.sprintf(format, args...) + if *reason != "" { + msg += "\n\t" + *reason + } + *reason = msg + } + } + + ok := false + code := _IncompatibleAssign + switch { + case Vp != nil && Tp != nil: + x := *x // don't clobber outer x + ok = Vp.is(func(V *term) bool { + x.typ = V.typ + return Tp.is(func(T *term) bool { + ok, code = x.assignableTo(check, T.typ, reason) + if !ok { + errorf("cannot assign %s (in %s) to %s (in %s)", V.typ, Vp, T.typ, Tp) + return false + } + return true + }) + }) + case Vp != nil: + x := *x // don't clobber outer x + ok = Vp.is(func(V *term) bool { + x.typ = V.typ + ok, code = x.assignableTo(check, T, reason) + if !ok { + errorf("cannot assign %s (in %s) to %s", V.typ, Vp, T) + return false + } + return true + }) + case Tp != nil: + x := *x // don't clobber outer x + ok = Tp.is(func(T *term) bool { + ok, code = x.assignableTo(check, T.typ, reason) + if !ok { + errorf("cannot assign %s to %s (in %s)", x.typ, T.typ, Tp) + return false + } + return true + }) + } + + return ok, code } diff --git a/src/go/types/testdata/spec/assignability.go2 b/src/go/types/testdata/spec/assignability.go2 new file mode 100644 index 0000000000..4c6774b811 --- /dev/null +++ b/src/go/types/testdata/spec/assignability.go2 @@ -0,0 +1,236 @@ +// Copyright 2021 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 assignability + +// See the end of this package for the declarations +// of the types and variables used in these tests. + +// "x's type is identical to T" +func _[TP any](X TP) { + b = b + a = a + l = l + s = s + p = p + f = f + i = i + m = m + c = c + d = d + + B = B + A = A + L = L + S = S + P = P + F = F + I = I + M = M + C = C + D = D + X = X +} + +// "x's type V and T have identical underlying types and at least one +// of V or T is not a defined type and neither is a type parameter" +func _[TP1, TP2 Interface](X1 TP1, X2 TP2) { + b = B // ERROR cannot use B .* as int value + a = A + l = L + s = S + p = P + f = F + i = I + m = M + c = C + d = D + + B = b // ERROR cannot use b .* as Basic value + A = a + L = l + S = s + P = p + F = f + I = i + M = m + C = c + D = d + X1 = i // ERROR cannot use i .* as TP1 value + X1 = X2 // ERROR cannot use X2 .* as TP1 value +} + +// "T is an interface type and x implements T and T is not a type parameter" +func _[TP Interface](X TP) { + i = d // ERROR missing method m + i = D + i = X + X = i // ERROR cannot use i .* as TP value +} + +// "x is a bidirectional channel value, T is a channel type, x's type V and T have identical element types, and at least one of V or T is not a defined type" +type ( + _SendChan = chan<- int + _RecvChan = <-chan int + + SendChan _SendChan + RecvChan _RecvChan +) + +func _[ + _CC ~_Chan, + _SC ~_SendChan, + _RC ~_RecvChan, + + CC Chan, + SC SendChan, + RC RecvChan, +]() { + var ( + _ _SendChan = c + _ _RecvChan = c + _ _Chan = c + + _ _SendChan = C + _ _RecvChan = C + _ _Chan = C + + _ SendChan = c + _ RecvChan = c + _ Chan = c + + _ SendChan = C // ERROR cannot use C .* as SendChan value + _ RecvChan = C // ERROR cannot use C .* as RecvChan value + _ Chan = C + _ Chan = make /* ERROR cannot use make\(chan Basic\) .* as Chan value */ (chan Basic) + ) + + var ( + _ _CC = C + _ _SC = C + _ _RC = C + + _ CC = _CC(nil) + _ SC = _CC(nil) + _ RC = _CC(nil) + + _ CC = C + _ SC = C // ERROR cannot use C .* as SC value .* cannot assign Chan to SendChan + _ RC = C // ERROR cannot use C .* as RC value .* cannot assign Chan to RecvChan + ) +} + +// "x is the predeclared identifier nil and T is a pointer, function, slice, map, channel, or interface type" +// TODO(rfindley) error messages about untyped nil diverge from types2 here. +// Consider aligning them. +func _[TP Interface](X TP) { + b = nil // ERROR cannot use.*untyped nil + a = nil // ERROR cannot use.*untyped nil + l = nil + s = nil // ERROR cannot use.*untyped nil + p = nil + f = nil + i = nil + m = nil + c = nil + d = nil // ERROR cannot use.*untyped nil + + B = nil // ERROR cannot use.*untyped nil + A = nil // ERROR cannot use.*untyped nil + L = nil + S = nil // ERROR cannot use.*untyped nil + P = nil + F = nil + I = nil + M = nil + C = nil + D = nil // ERROR cannot use.*untyped nil + X = nil // ERROR cannot use.*untyped nil +} + +// "x is an untyped constant representable by a value of type T" +func _[ + Int8 ~int8, + Int16 ~int16, + Int32 ~int32, + Int64 ~int64, + Int8_16 ~int8 | ~int16, +]( + i8 Int8, + i16 Int16, + i32 Int32, + i64 Int64, + i8_16 Int8_16, +) { + b = 42 + b = 42.0 + // etc. + + i8 = -1 << 7 + i8 = 1<<7 - 1 + i16 = -1 << 15 + i16 = 1<<15 - 1 + i32 = -1 << 31 + i32 = 1<<31 - 1 + i64 = -1 << 63 + i64 = 1<<63 - 1 + + i8_16 = -1 << 7 + i8_16 = 1<<7 - 1 + i8_16 = - /* ERROR cannot use .* as Int8_16 */ 1 << 15 + i8_16 = 1 /* ERROR cannot use .* as Int8_16 */ <<15 - 1 +} + +// proto-types for tests + +type ( + _Basic = int + _Array = [10]int + _Slice = []int + _Struct = struct{ f int } + _Pointer = *int + _Func = func(x int) string + _Interface = interface{ m() int } + _Map = map[string]int + _Chan = chan int + + Basic _Basic + Array _Array + Slice _Slice + Struct _Struct + Pointer _Pointer + Func _Func + Interface _Interface + Map _Map + Chan _Chan + Defined _Struct +) + +func (Defined) m() int + +// proto-variables for tests + +var ( + b _Basic + a _Array + l _Slice + s _Struct + p _Pointer + f _Func + i _Interface + m _Map + c _Chan + d _Struct + + B Basic + A Array + L Slice + S Struct + P Pointer + F Func + I Interface + M Map + C Chan + D Defined +) diff --git a/src/go/types/testdata/examples/conversions.go2 b/src/go/types/testdata/spec/conversions.go2 similarity index 100% rename from src/go/types/testdata/examples/conversions.go2 rename to src/go/types/testdata/spec/conversions.go2 From 4e7dd9fc08fb5aa86773b65d865719d96f67f49d Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Tue, 19 Oct 2021 11:17:53 -0500 Subject: [PATCH 306/406] bytes: test for page boundary crosses on sep of Index Improve TestIndexNearPageBoundary to verify needles ending on a page boundary don't cause a segfault. Change-Id: I2edb13db63a71dc9955e266f6b97026ee13bf76e Reviewed-on: https://go-review.googlesource.com/c/go/+/356889 Reviewed-by: Cherry Mui Trust: Lynn Boger --- src/bytes/boundary_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/bytes/boundary_test.go b/src/bytes/boundary_test.go index 8dac751866..f9855fcb05 100644 --- a/src/bytes/boundary_test.go +++ b/src/bytes/boundary_test.go @@ -65,7 +65,11 @@ func TestIndexByteNearPageBoundary(t *testing.T) { func TestIndexNearPageBoundary(t *testing.T) { t.Parallel() - var q [64]byte + q := dangerousSlice(t) + if len(q) > 64 { + // Only worry about when we're near the end of a page. + q = q[len(q)-64:] + } b := dangerousSlice(t) if len(b) > 256 { // Only worry about when we're near the end of a page. @@ -81,4 +85,16 @@ func TestIndexNearPageBoundary(t *testing.T) { } q[j-1] = 0 } + + // Test differing alignments and sizes of q which always end on a page boundary. + q[len(q)-1] = 1 // difference is only found on the last byte + for j := 0; j < len(q); j++ { + for i := range b { + idx := Index(b[i:], q[j:]) + if idx != -1 { + t.Fatalf("Index(b[%d:], q[%d:])=%d, want -1\n", i, j, idx) + } + } + } + q[len(q)-1] = 0 } From 7548327374844719bf90cce199e7fa4b43b94e2b Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 2 Nov 2021 10:14:29 -0700 Subject: [PATCH 307/406] comd/compile/internal/types2: add missing nil check in const conversion Follow-up on CL 360396. Fixes #49296. Change-Id: Ie08f86ae884da4cfd5db557cbf4f721a237dc39f Reviewed-on: https://go-review.googlesource.com/c/go/+/360796 Trust: Robert Griesemer Reviewed-by: Robert Findley --- .../compile/internal/types2/conversions.go | 2 ++ .../types2/testdata/fixedbugs/issue49296.go2 | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/cmd/compile/internal/types2/testdata/fixedbugs/issue49296.go2 diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index 0e26a73cf8..4d0ed79c38 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -18,6 +18,8 @@ func (check *Checker) conversion(x *operand, T Type) { constConvertibleTo := func(T Type, val *constant.Value) bool { switch t := asBasic(T); { + case t == nil: + // nothing to do case representableConst(x.val, check, t, val): return true case isInteger(x.typ) && isString(t): diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49296.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49296.go2 new file mode 100644 index 0000000000..8f52acc8a4 --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue49296.go2 @@ -0,0 +1,20 @@ +// Copyright 2021 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 p + +func _[ + T0 any, + T1 []int, + T2 ~float64 | ~complex128 | chan int, +]() { + _ = T0(nil /* ERROR cannot convert untyped nil to T0 */ ) + _ = T1(1 /* ERROR cannot convert 1 .* to T1 */ ) + _ = T2(2 /* ERROR cannot convert 2 .* to T2 */ ) +} + +// test case from issue +func f[T interface{[]int}]() { + _ = T(1 /* ERROR cannot convert */ ) +} From 4ec52e363e93baa859cbdec23f997a489cfeca11 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Wed, 20 Oct 2021 13:17:07 -0700 Subject: [PATCH 308/406] go/types: add check that code is monomorphizable This CL adds a check to ensure that generic Go code doesn't involve any unbounded recursive instantiation, which are incompatible with an implementation that uses static instantiation (i.e., monomorphization or compile-time dictionary construction). Updates #48098. Change-Id: I9d051f0f9369ab881592a361a5d0e2a716788a6b Reviewed-on: https://go-review.googlesource.com/c/go/+/357449 Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Robert Griesemer Trust: Matthew Dempsky --- src/go/types/call.go | 2 + src/go/types/check.go | 6 + src/go/types/errorcodes.go | 7 + src/go/types/mono.go | 331 ++++++++++++++++++ src/go/types/mono_test.go | 92 +++++ src/go/types/signature.go | 1 + .../types/testdata/fixedbugs/issue48974.go2 | 2 +- src/go/types/typexpr.go | 2 + 8 files changed, 442 insertions(+), 1 deletion(-) create mode 100644 src/go/types/mono.go create mode 100644 src/go/types/mono_test.go diff --git a/src/go/types/call.go b/src/go/types/call.go index 6894f1c182..36086891b5 100644 --- a/src/go/types/call.go +++ b/src/go/types/call.go @@ -91,6 +91,8 @@ func (check *Checker) instantiateSignature(pos token.Pos, typ *Signature, targs pos = posList[i] } check.softErrorf(atPos(pos), _Todo, err.Error()) + } else { + check.mono.recordInstance(check.pkg, pos, tparams, targs, posList) } return inst diff --git a/src/go/types/check.go b/src/go/types/check.go index 2b8ef9f061..3a0e4a6a23 100644 --- a/src/go/types/check.go +++ b/src/go/types/check.go @@ -129,6 +129,7 @@ type Checker struct { imports []*PkgName // list of imported packages dotImportMap map[dotImportKey]*PkgName // maps dot-imported objects to the package they were dot-imported through recvTParamMap map[*ast.Ident]*TypeParam // maps blank receiver type parameters to their type + mono monoGraph // graph for detecting non-monomorphizable instantiation loops firstErr error // first error encountered methods map[*TypeName][]*Func // maps package scope type names to associated non-blank (non-interface) methods @@ -306,6 +307,11 @@ func (check *Checker) checkFiles(files []*ast.File) (err error) { check.recordUntyped() + if check.firstErr == nil { + // TODO(mdempsky): Ensure monomorph is safe when errors exist. + check.monomorph() + } + check.pkg.complete = true // no longer needed - release memory diff --git a/src/go/types/errorcodes.go b/src/go/types/errorcodes.go index 49c6a74c20..88dd0fda2f 100644 --- a/src/go/types/errorcodes.go +++ b/src/go/types/errorcodes.go @@ -1301,6 +1301,13 @@ const ( // var _ = unsafe.Slice(&x, uint64(1) << 63) _InvalidUnsafeSlice + // _InvalidInstanceCycle occurs when an invalid cycle is detected + // within the instantiation graph. + // + // Example: + // func f[T any]() { f[*T]() } + _InvalidInstanceCycle + // _Todo is a placeholder for error codes that have not been decided. // TODO(rFindley) remove this error code after deciding on errors for generics code. _Todo diff --git a/src/go/types/mono.go b/src/go/types/mono.go new file mode 100644 index 0000000000..fb1127e959 --- /dev/null +++ b/src/go/types/mono.go @@ -0,0 +1,331 @@ +// Copyright 2021 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 + +import ( + "go/token" +) + +// This file implements a check to validate that a Go package doesn't +// have unbounded recursive instantiation, which is not compatible +// with compilers using static instantiation (such as +// monomorphization). +// +// It implements a sort of "type flow" analysis by detecting which +// type parameters are instantiated with other type parameters (or +// types derived thereof). A package cannot be statically instantiated +// if the graph has any cycles involving at least one derived type. +// +// Concretely, we construct a directed, weighted graph. Vertices are +// used to represent type parameters as well as some defined +// types. Edges are used to represent how types depend on each other: +// +// * Everywhere a type-parameterized function or type is instantiated, +// we add edges to each type parameter from the vertices (if any) +// representing each type parameter or defined type referenced by +// the type argument. If the type argument is just the referenced +// type itself, then the edge has weight 0, otherwise 1. +// +// * For every defined type declared within a type-parameterized +// function or method, we add an edge of weight 1 to the defined +// type from each ambient type parameter. +// +// For example, given: +// +// func f[A, B any]() { +// type T int +// f[T, map[A]B]() +// } +// +// we construct vertices representing types A, B, and T. Because of +// declaration "type T int", we construct edges T<-A and T<-B with +// weight 1; and because of instantiation "f[T, map[A]B]" we construct +// edges A<-T with weight 0, and B<-A and B<-B with weight 1. +// +// Finally, we look for any positive-weight cycles. Zero-weight cycles +// are allowed because static instantiation will reach a fixed point. + +type monoGraph struct { + vertices []monoVertex + edges []monoEdge + + // canon maps method receiver type parameters to their respective + // receiver type's type parameters. + canon map[*TypeParam]*TypeParam + + // nameIdx maps a defined type or (canonical) type parameter to its + // vertex index. + nameIdx map[*TypeName]int +} + +type monoVertex struct { + weight int // weight of heaviest known path to this vertex + pre int // previous edge (if any) in the above path + len int // length of the above path + + // obj is the defined type or type parameter represented by this + // vertex. + obj *TypeName +} + +type monoEdge struct { + dst int + src int + weight int + + // report emits an error describing why this edge exists. + // + // TODO(mdempsky): Avoid requiring a function closure for each edge. + report func(check *Checker) +} + +func (check *Checker) monomorph() { + // We detect unbounded instantiation cycles using a variant of + // Bellman-Ford's algorithm. Namely, instead of always running |V| + // iterations, we run until we either reach a fixed point or we've + // found a path of length |V|. This allows us to terminate earlier + // when there are no cycles, which should be the common case. + + again := true + for again { + again = false + + for i, edge := range check.mono.edges { + src := &check.mono.vertices[edge.src] + dst := &check.mono.vertices[edge.dst] + + // N.B., we're looking for the greatest weight paths, unlike + // typical Bellman-Ford. + w := src.weight + edge.weight + if w <= dst.weight { + continue + } + + dst.pre = i + dst.len = src.len + 1 + if dst.len == len(check.mono.vertices) { + check.reportInstanceLoop(edge.dst) + return + } + + dst.weight = w + again = true + } + } +} + +func (check *Checker) reportInstanceLoop(v int) { + var stack []int + seen := make([]bool, len(check.mono.vertices)) + + // We have a path that contains a cycle and ends at v, but v may + // only be reachable from the cycle, not on the cycle itself. We + // start by walking backwards along the path until we find a vertex + // that appears twice. + for !seen[v] { + stack = append(stack, v) + seen[v] = true + v = check.mono.edges[check.mono.vertices[v].pre].src + } + + // Trim any vertices we visited before visiting v the first + // time. Since v is the first vertex we found within the cycle, any + // vertices we visited earlier cannot be part of the cycle. + for stack[0] != v { + stack = stack[1:] + } + + // TODO(mdempsky): Pivot stack so we report the cycle from the top? + + obj := check.mono.vertices[v].obj + check.errorf(obj, _InvalidInstanceCycle, "instantiation cycle:") + + for _, v := range stack { + edge := check.mono.edges[check.mono.vertices[v].pre] + edge.report(check) + } +} + +// recordCanon records that tpar is the canonical type parameter +// corresponding to method type parameter mpar. +func (w *monoGraph) recordCanon(mpar, tpar *TypeParam) { + if w.canon == nil { + w.canon = make(map[*TypeParam]*TypeParam) + } + w.canon[mpar] = tpar +} + +// recordInstance records that the given type parameters were +// instantiated with the corresponding type arguments. +func (w *monoGraph) recordInstance(pkg *Package, pos token.Pos, tparams []*TypeParam, targs []Type, posList []token.Pos) { + for i, tpar := range tparams { + pos := pos + if i < len(posList) { + pos = posList[i] + } + w.assign(pkg, pos, tpar, targs[i]) + } +} + +// assign records that tpar was instantiated as targ at pos. +func (w *monoGraph) assign(pkg *Package, pos token.Pos, tpar *TypeParam, targ Type) { + // Go generics do not have an analog to C++`s template-templates, + // where a template parameter can itself be an instantiable + // template. So any instantiation cycles must occur within a single + // package. Accordingly, we can ignore instantiations of imported + // type parameters. + // + // TODO(mdempsky): Push this check up into recordInstance? All type + // parameters in a list will appear in the same package. + if tpar.Obj().Pkg() != pkg { + return + } + + // flow adds an edge from vertex src representing that typ flows to tpar. + flow := func(src int, typ Type) { + weight := 1 + if typ == targ { + weight = 0 + } + + w.addEdge(w.typeParamVertex(tpar), src, weight, func(check *Checker) { + qf := RelativeTo(check.pkg) + check.errorf(atPos(pos), _InvalidInstanceCycle, "\t%s instantiated as %s", tpar.Obj().Name(), TypeString(targ, qf)) // secondary error, \t indented + }) + } + + // Recursively walk the type argument to find any defined types or + // type parameters. + var do func(typ Type) + do = func(typ Type) { + switch typ := typ.(type) { + default: + panic("unexpected type") + + case *TypeParam: + assert(typ.Obj().Pkg() == pkg) + flow(w.typeParamVertex(typ), typ) + + case *Named: + if src := w.localNamedVertex(pkg, typ.Origin()); src >= 0 { + flow(src, typ) + } + + targs := typ.TypeArgs() + for i := 0; i < targs.Len(); i++ { + do(targs.At(i)) + } + + case *Array: + do(typ.Elem()) + case *Basic: + // ok + case *Chan: + do(typ.Elem()) + case *Map: + do(typ.Key()) + do(typ.Elem()) + case *Pointer: + do(typ.Elem()) + case *Slice: + do(typ.Elem()) + + case *Interface: + for i := 0; i < typ.NumMethods(); i++ { + do(typ.Method(i).Type()) + } + case *Signature: + tuple := func(tup *Tuple) { + for i := 0; i < tup.Len(); i++ { + do(tup.At(i).Type()) + } + } + tuple(typ.Params()) + tuple(typ.Results()) + case *Struct: + for i := 0; i < typ.NumFields(); i++ { + do(typ.Field(i).Type()) + } + } + } + do(targ) +} + +// localNamedVertex returns the index of the vertex representing +// named, or -1 if named doesn't need representation. +func (w *monoGraph) localNamedVertex(pkg *Package, named *Named) int { + obj := named.Obj() + if obj.Pkg() != pkg { + return -1 // imported type + } + + root := pkg.Scope() + if obj.Parent() == root { + return -1 // package scope, no ambient type parameters + } + + if idx, ok := w.nameIdx[obj]; ok { + return idx + } + + idx := -1 + + // Walk the type definition's scope to find any ambient type + // parameters that it's implicitly parameterized by. + for scope := obj.Parent(); scope != root; scope = scope.Parent() { + for _, elem := range scope.elems { + if elem, ok := elem.(*TypeName); ok && !elem.IsAlias() && elem.Pos() < obj.Pos() { + if tpar, ok := elem.Type().(*TypeParam); ok { + if idx < 0 { + idx = len(w.vertices) + w.vertices = append(w.vertices, monoVertex{obj: obj}) + } + + w.addEdge(idx, w.typeParamVertex(tpar), 1, func(check *Checker) { + check.errorf(obj, _InvalidInstanceCycle, "\t%s implicitly parameterized by %s", obj.Name(), elem.Name()) + }) + } + } + } + } + + if w.nameIdx == nil { + w.nameIdx = make(map[*TypeName]int) + } + w.nameIdx[obj] = idx + return idx +} + +// typeParamVertex returns the index of the vertex representing tpar. +func (w *monoGraph) typeParamVertex(tpar *TypeParam) int { + if x, ok := w.canon[tpar]; ok { + tpar = x + } + + obj := tpar.Obj() + + if idx, ok := w.nameIdx[obj]; ok { + return idx + } + + if w.nameIdx == nil { + w.nameIdx = make(map[*TypeName]int) + } + + idx := len(w.vertices) + w.vertices = append(w.vertices, monoVertex{obj: obj}) + w.nameIdx[obj] = idx + return idx +} + +func (w *monoGraph) addEdge(dst, src, weight int, report func(check *Checker)) { + // TODO(mdempsky): Deduplicate redundant edges? + w.edges = append(w.edges, monoEdge{ + dst: dst, + src: src, + weight: weight, + report: report, + }) +} diff --git a/src/go/types/mono_test.go b/src/go/types/mono_test.go new file mode 100644 index 0000000000..c4c5282427 --- /dev/null +++ b/src/go/types/mono_test.go @@ -0,0 +1,92 @@ +// Copyright 2021 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 ( + "bytes" + "errors" + "fmt" + "go/ast" + "go/importer" + "go/parser" + "go/token" + "go/types" + "strings" + "testing" +) + +func checkMono(t *testing.T, body string) error { + fset := token.NewFileSet() + file, err := parser.ParseFile(fset, "x.go", "package x; import `unsafe`; var _ unsafe.Pointer;\n"+body, 0) + if err != nil { + t.Fatal(err) + } + files := []*ast.File{file} + + var buf bytes.Buffer + conf := types.Config{ + Error: func(err error) { fmt.Fprintln(&buf, err) }, + Importer: importer.Default(), + } + conf.Check("x", fset, files, nil) + if buf.Len() == 0 { + return nil + } + return errors.New(strings.TrimRight(buf.String(), "\n")) +} + +func TestMonoGood(t *testing.T) { + for i, good := range goods { + if err := checkMono(t, good); err != nil { + t.Errorf("%d: unexpected failure: %v", i, err) + } + } +} + +func TestMonoBad(t *testing.T) { + for i, bad := range bads { + if err := checkMono(t, bad); err == nil { + t.Errorf("%d: unexpected success", i) + } else { + t.Log(err) + } + } +} + +var goods = []string{ + "func F[T any](x T) { F(x) }", + "func F[T, U, V any]() { F[U, V, T](); F[V, T, U]() }", + "type Ring[A, B, C any] struct { L *Ring[B, C, A]; R *Ring[C, A, B] }", + "func F[T any]() { type U[T any] [unsafe.Sizeof(F[*T])]byte }", + "func F[T any]() { type U[T any] [unsafe.Sizeof(F[*T])]byte; var _ U[int] }", + "type U[T any] [unsafe.Sizeof(F[*T])]byte; func F[T any]() { var _ U[U[int]] }", + "func F[T any]() { type A = int; F[A]() }", +} + +// TODO(mdempsky): Validate specific error messages and positioning. + +var bads = []string{ + "func F[T any](x T) { F(&x) }", + "func F[T any]() { F[*T]() }", + "func F[T any]() { F[[]T]() }", + "func F[T any]() { F[[1]T]() }", + "func F[T any]() { F[chan T]() }", + "func F[T any]() { F[map[*T]int]() }", + "func F[T any]() { F[map[error]T]() }", + "func F[T any]() { F[func(T)]() }", + "func F[T any]() { F[func() T]() }", + "func F[T any]() { F[struct{ t T }]() }", + "func F[T any]() { F[interface{ t() T }]() }", + "type U[_ any] int; func F[T any]() { F[U[T]]() }", + "func F[T any]() { type U int; F[U]() }", + "func F[T any]() { type U int; F[*U]() }", + "type U[T any] int; func (U[T]) m() { var _ U[*T] }", + "type U[T any] int; func (*U[T]) m() { var _ U[*T] }", + "type U[T any] [unsafe.Sizeof(F[*T])]byte; func F[T any]() { var _ U[T] }", + "func F[A, B, C, D, E any]() { F[B, C, D, E, *A]() }", + "type U[_ any] int; const X = unsafe.Sizeof(func() { type A[T any] U[A[*T]] })", + "func F[T any]() { type A = *T; F[A]() }", + "type A[T any] struct { _ A[*T] }", +} diff --git a/src/go/types/signature.go b/src/go/types/signature.go index c83bf09032..ad69c95d12 100644 --- a/src/go/types/signature.go +++ b/src/go/types/signature.go @@ -148,6 +148,7 @@ func (check *Checker) funcType(sig *Signature, recvPar *ast.FieldList, ftyp *ast list := make([]Type, sig.RecvTypeParams().Len()) for i, t := range sig.RecvTypeParams().list() { list[i] = t + check.mono.recordCanon(t, recvTParams[i]) } smap := makeSubstMap(recvTParams, list) for i, tpar := range sig.RecvTypeParams().list() { diff --git a/src/go/types/testdata/fixedbugs/issue48974.go2 b/src/go/types/testdata/fixedbugs/issue48974.go2 index ca4b6d9321..d8ff7c8cf4 100644 --- a/src/go/types/testdata/fixedbugs/issue48974.go2 +++ b/src/go/types/testdata/fixedbugs/issue48974.go2 @@ -8,7 +8,7 @@ type Fooer interface { Foo() } -type Fooable[F Fooer] struct { +type Fooable[F /* ERROR instantiation cycle */ Fooer] struct { ptr F } diff --git a/src/go/types/typexpr.go b/src/go/types/typexpr.go index 092e355b38..3636c8556a 100644 --- a/src/go/types/typexpr.go +++ b/src/go/types/typexpr.go @@ -457,6 +457,8 @@ func (check *Checker) instantiatedType(x ast.Expr, targsx []ast.Expr, def *Named pos = posList[i] } check.softErrorf(atPos(pos), _Todo, err.Error()) + } else { + check.mono.recordInstance(check.pkg, x.Pos(), inst.tparams.list(), inst.targs.list(), posList) } } From 629ffebd451613b32e6b9578ff4c807791197b38 Mon Sep 17 00:00:00 2001 From: Roland Shoemaker Date: Mon, 1 Nov 2021 10:28:52 -0700 Subject: [PATCH 309/406] cmd/go: disallow profile flags when using -fuzz Disallow the usage of coverprofile, blockprofile, cpuprofile, memprofile, mutexprofile, and trace when fuzzing, since these currently do not work as the user would expect. Fixes #48178 Change-Id: Ibe6dfaef9b28a91c60c26fcad38c33a2a959d869 Reviewed-on: https://go-review.googlesource.com/c/go/+/360395 Trust: Roland Shoemaker Trust: Katie Hockman Run-TryBot: Bryan C. Mills Reviewed-by: Bryan C. Mills Reviewed-by: Katie Hockman TryBot-Result: Go Bot --- src/cmd/go/internal/test/test.go | 6 +++ .../script/test_fuzz_profile_flags.txt | 38 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/cmd/go/testdata/script/test_fuzz_profile_flags.txt diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index cfb0a1465f..7dca6b531c 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -666,6 +666,12 @@ func runTest(ctx context.Context, cmd *base.Command, args []string) { if len(pkgs) != 1 { base.Fatalf("cannot use -fuzz flag with multiple packages") } + if testCoverProfile != "" { + base.Fatalf("cannot use -coverprofile flag with -fuzz flag") + } + if profileFlag := testProfile(); profileFlag != "" { + base.Fatalf("cannot use %s flag with -fuzz flag", profileFlag) + } // Reject the '-fuzz' flag if the package is outside the main module. // Otherwise, if fuzzing identifies a failure it could corrupt checksums in diff --git a/src/cmd/go/testdata/script/test_fuzz_profile_flags.txt b/src/cmd/go/testdata/script/test_fuzz_profile_flags.txt new file mode 100644 index 0000000000..5434c723ad --- /dev/null +++ b/src/cmd/go/testdata/script/test_fuzz_profile_flags.txt @@ -0,0 +1,38 @@ +[!fuzz] skip + +! go test -fuzz=FuzzTrivial -coverprofile=prof +! stdout . +stderr '^cannot use -coverprofile flag with -fuzz flag$' + +! go test -fuzz=FuzzTrivial -blockprofile=prof +! stdout . +stderr '^cannot use -blockprofile flag with -fuzz flag$' + +! go test -fuzz=FuzzTrivial -cpuprofile=prof +! stdout . +stderr '^cannot use -cpuprofile flag with -fuzz flag$' + +! go test -fuzz=FuzzTrivial -memprofile=prof +! stdout . +stderr '^cannot use -memprofile flag with -fuzz flag$' + +! go test -fuzz=FuzzTrivial -mutexprofile=prof +! stdout . +stderr '^cannot use -mutexprofile flag with -fuzz flag$' + +! go test -fuzz=FuzzTrivial -trace=prof +! stdout . +stderr '^cannot use -trace flag with -fuzz flag$' + +-- go.mod -- +module example + +go 1.18 +-- fuzz_test.go -- +package example + +import "testing" + +func FuzzTrivial(f *testing.F) { + f.Fuzz(func(t *testing.T, _ []byte) {}) +} From f7a95d2c17c2b2506034d519b68a267c944f6450 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 6 Oct 2021 12:40:35 -0700 Subject: [PATCH 310/406] debug/gosym: bulk allocate Syms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit name old time/op new time/op delta 115/NewLineTable-8 80.7ns ± 1% 81.7ns ± 3% ~ (p=0.408 n=10+8) 115/NewTable-8 76.3µs ± 2% 63.3µs ± 3% -17.03% (p=0.000 n=9+9) 115/LineToPC-8 56.8µs ± 2% 56.8µs ± 3% ~ (p=0.905 n=10+9) 115/PCToLine-8 252ns ± 1% 256ns ± 5% ~ (p=0.183 n=10+10) name old alloc/op new alloc/op delta 115/NewLineTable-8 384B ± 0% 384B ± 0% ~ (all equal) 115/NewTable-8 164kB ± 0% 172kB ± 0% +4.97% (p=0.000 n=10+10) 115/LineToPC-8 0.00B 0.00B ~ (all equal) 115/PCToLine-8 0.00B 0.00B ~ (all equal) name old allocs/op new allocs/op delta 115/NewLineTable-8 3.00 ± 0% 3.00 ± 0% ~ (all equal) 115/NewTable-8 1.04k ± 0% 0.01k ± 0% -98.75% (p=0.000 n=10+10) 115/LineToPC-8 0.00 0.00 ~ (all equal) 115/PCToLine-8 0.00 0.00 ~ (all equal) Change-Id: Ibfe6c0cb86737dee8209cb1f58f5b796aa7b30aa Reviewed-on: https://go-review.googlesource.com/c/go/+/353134 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- src/debug/gosym/pclntab.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/debug/gosym/pclntab.go b/src/debug/gosym/pclntab.go index 134cb3d194..a687c406b2 100644 --- a/src/debug/gosym/pclntab.go +++ b/src/debug/gosym/pclntab.go @@ -297,6 +297,7 @@ func (t *LineTable) go12Funcs() []Func { ft := t.funcTab() funcs := make([]Func, ft.Count()) + syms := make([]Sym, len(funcs)) for i := range funcs { f := &funcs[i] f.Entry = ft.pc(i) @@ -304,13 +305,14 @@ func (t *LineTable) go12Funcs() []Func { info := t.funcData(uint32(i)) f.LineTable = t f.FrameSize = int(info.deferreturn()) - f.Sym = &Sym{ + syms[i] = Sym{ Value: f.Entry, Type: 'T', Name: t.funcName(info.nameoff()), GoType: 0, Func: f, } + f.Sym = &syms[i] } return funcs } From 79c5240799e02feeacfdde3472f22b4b0401f3c7 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Sat, 30 Oct 2021 14:39:29 -0700 Subject: [PATCH 311/406] cmd/compile: mark type descriptors as always dupok The types of the two interfaces should be equal, but they aren't. We end up with multiple descriptors for a type when we need type descriptors to be unique. Fixes #49241 Change-Id: I8a6c70da541c6088a92a01392bc83b61cc130eba Reviewed-on: https://go-review.googlesource.com/c/go/+/360134 Trust: Keith Randall Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky --- .../compile/internal/reflectdata/reflect.go | 9 +++----- test/typeparam/issue49241.dir/a.go | 13 ++++++++++++ test/typeparam/issue49241.dir/b.go | 17 +++++++++++++++ test/typeparam/issue49241.dir/c.go | 17 +++++++++++++++ test/typeparam/issue49241.dir/main.go | 21 +++++++++++++++++++ test/typeparam/issue49241.go | 7 +++++++ 6 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 test/typeparam/issue49241.dir/a.go create mode 100644 test/typeparam/issue49241.dir/b.go create mode 100644 test/typeparam/issue49241.dir/c.go create mode 100644 test/typeparam/issue49241.dir/main.go create mode 100644 test/typeparam/issue49241.go diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index ce41b8c934..d396c249e4 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -959,11 +959,6 @@ func writeType(t *types.Type) *obj.LSym { base.Fatalf("unresolved defined type: %v", tbase) } - dupok := 0 - if tbase.Sym() == nil || tbase.HasShape() { // TODO(mdempsky): Probably need DUPOK for instantiated types too. - dupok = obj.DUPOK - } - if !NeedEmit(tbase) { if i := typecheck.BaseTypeIndex(t); i >= 0 { lsym.Pkg = tbase.Sym().Pkg.Prefix @@ -1196,7 +1191,9 @@ func writeType(t *types.Type) *obj.LSym { } ot = dextratypeData(lsym, ot, t) - objw.Global(lsym, int32(ot), int16(dupok|obj.RODATA)) + objw.Global(lsym, int32(ot), int16(obj.DUPOK|obj.RODATA)) + // Note: DUPOK is required to ensure that we don't end up with more + // than one type descriptor for a given type. // The linker will leave a table of all the typelinks for // types in the binary, so the runtime can find them. diff --git a/test/typeparam/issue49241.dir/a.go b/test/typeparam/issue49241.dir/a.go new file mode 100644 index 0000000000..34c99657d4 --- /dev/null +++ b/test/typeparam/issue49241.dir/a.go @@ -0,0 +1,13 @@ +// Copyright 2021 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 a + +type T[P any] struct { + x P +} + +type U struct { + a,b int +} diff --git a/test/typeparam/issue49241.dir/b.go b/test/typeparam/issue49241.dir/b.go new file mode 100644 index 0000000000..45c1afbaf1 --- /dev/null +++ b/test/typeparam/issue49241.dir/b.go @@ -0,0 +1,17 @@ +// Copyright 2021 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 b + +import "a" + +//go:noinline +func F() interface {} { + return a.T[int]{} +} + +//go:noinline +func G() interface{} { + return struct{X,Y a.U}{} +} diff --git a/test/typeparam/issue49241.dir/c.go b/test/typeparam/issue49241.dir/c.go new file mode 100644 index 0000000000..ea3bab2954 --- /dev/null +++ b/test/typeparam/issue49241.dir/c.go @@ -0,0 +1,17 @@ +// Copyright 2021 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 c + +import "a" + +//go:noinline +func F() interface {} { + return a.T[int]{} +} + +//go:noinline +func G() interface{} { + return struct{X,Y a.U}{} +} diff --git a/test/typeparam/issue49241.dir/main.go b/test/typeparam/issue49241.dir/main.go new file mode 100644 index 0000000000..7c8a8b1acd --- /dev/null +++ b/test/typeparam/issue49241.dir/main.go @@ -0,0 +1,21 @@ +// Copyright 2021 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 main + +import ( + "b" + "c" +) + +func main() { + if b.G() != c.G() { + println(b.G(), c.G()) + panic("bad") + } + if b.F() != c.F() { + println(b.F(), c.F()) + panic("bad") + } +} diff --git a/test/typeparam/issue49241.go b/test/typeparam/issue49241.go new file mode 100644 index 0000000000..76930e5e4f --- /dev/null +++ b/test/typeparam/issue49241.go @@ -0,0 +1,7 @@ +// rundir -G=3 + +// Copyright 2021 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 ignored From 0b37bd9b3f7556d31061c6007afca59ffe2642d3 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 1 Nov 2021 14:07:30 -0700 Subject: [PATCH 312/406] net: add BenchmarkWriteToReadFromUDPAddrPort The main item of interest is the allocs. BenchmarkWriteToReadFromUDPAddrPort-8 237735 5152 ns/op 68 B/op 3 allocs/op Change-Id: I5cb3f2e1ebbb02acc51039c2266e99b90d388a99 Reviewed-on: https://go-review.googlesource.com/c/go/+/360598 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- src/net/udpsock_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/net/udpsock_test.go b/src/net/udpsock_test.go index 74e449c888..371d9af511 100644 --- a/src/net/udpsock_test.go +++ b/src/net/udpsock_test.go @@ -479,6 +479,7 @@ func BenchmarkReadWriteMsgUDPAddrPort(b *testing.B) { if err != nil { b.Fatal(err) } + defer conn.Close() addr := conn.LocalAddr().(*UDPAddr).AddrPort() buf := make([]byte, 8) b.ResetTimer() @@ -500,6 +501,7 @@ func BenchmarkWriteToReadFromUDP(b *testing.B) { if err != nil { b.Fatal(err) } + defer conn.Close() addr := conn.LocalAddr() buf := make([]byte, 8) b.ResetTimer() @@ -515,3 +517,25 @@ func BenchmarkWriteToReadFromUDP(b *testing.B) { } } } + +func BenchmarkWriteToReadFromUDPAddrPort(b *testing.B) { + conn, err := ListenUDP("udp4", &UDPAddr{IP: IPv4(127, 0, 0, 1)}) + if err != nil { + b.Fatal(err) + } + defer conn.Close() + addr := conn.LocalAddr().(*UDPAddr).AddrPort() + buf := make([]byte, 8) + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + _, err := conn.WriteToUDPAddrPort(buf, addr) + if err != nil { + b.Fatal(err) + } + _, _, err = conn.ReadFromUDP(buf) // TODO: create and use ReadFromUDPAddrPort + if err != nil { + b.Fatal(err) + } + } +} From 433ba582f7c72636066ec92679a325b7ee15297c Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 1 Nov 2021 13:23:39 -0700 Subject: [PATCH 313/406] net: optimize WriteToUDPAddrPort MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See the recent change optimizing WriteMsgUDPAddrPort for an explanation of why this change includes copy/paste/modify instead of implementing WriteToUDP using WriteToUDPAddrPort. name old time/op new time/op delta WriteToReadFromUDPAddrPort-8 5.02µs ± 3% 4.71µs ± 2% -6.31% (p=0.000 n=15+14) name old alloc/op new alloc/op delta WriteToReadFromUDPAddrPort-8 68.0B ± 0% 4.0B ± 0% -94.12% (p=0.000 n=15+15) name old allocs/op new allocs/op delta WriteToReadFromUDPAddrPort-8 3.00 ± 0% 1.00 ± 0% -66.67% (p=0.000 n=15+15) Change-Id: I301715e774de07eb6ccb4e329ccf2e554609abc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/360599 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- src/net/udpsock.go | 13 ++++++++----- src/net/udpsock_plan9.go | 4 ++++ src/net/udpsock_posix.go | 26 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/net/udpsock.go b/src/net/udpsock.go index 0d563fd4f5..a829789a1b 100644 --- a/src/net/udpsock.go +++ b/src/net/udpsock.go @@ -207,11 +207,14 @@ func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (int, error) { // WriteToUDPAddrPort acts like WriteTo but takes a netip.AddrPort. func (c *UDPConn) WriteToUDPAddrPort(b []byte, addr netip.AddrPort) (int, error) { - // TODO(bradfitz): make this efficient, making the internal net package - // type throughout be netip.Addr and only converting to the net.IP slice - // version at the edge. But for now (2021-10-20), this is a wrapper around - // the old way. - return c.WriteToUDP(b, UDPAddrFromAddrPort(addr)) + if !c.ok() { + return 0, syscall.EINVAL + } + n, err := c.writeToAddrPort(b, addr) + if err != nil { + err = &OpError{Op: "write", Net: c.fd.net, Source: c.fd.laddr, Addr: addrPortUDPAddr{addr}, Err: err} + } + return n, err } // WriteTo implements the PacketConn WriteTo method. diff --git a/src/net/udpsock_plan9.go b/src/net/udpsock_plan9.go index ac5afa2281..dfb81a8d0c 100644 --- a/src/net/udpsock_plan9.go +++ b/src/net/udpsock_plan9.go @@ -53,6 +53,10 @@ func (c *UDPConn) writeTo(b []byte, addr *UDPAddr) (int, error) { return len(b), nil } +func (c *UDPConn) writeToAddrPort(b []byte, addr netip.AddrPort) (int, error) { + return c.writeTo(b, UDPAddrFromAddrPort(addr)) // TODO: optimize instead of allocating +} + func (c *UDPConn) writeMsg(b, oob []byte, addr *UDPAddr) (n, oobn int, err error) { return 0, 0, syscall.EPLAN9 } diff --git a/src/net/udpsock_posix.go b/src/net/udpsock_posix.go index 646687d148..718d11e60f 100644 --- a/src/net/udpsock_posix.go +++ b/src/net/udpsock_posix.go @@ -109,6 +109,32 @@ func (c *UDPConn) writeTo(b []byte, addr *UDPAddr) (int, error) { } } +func (c *UDPConn) writeToAddrPort(b []byte, addr netip.AddrPort) (int, error) { + if c.fd.isConnected { + return 0, ErrWriteToConnected + } + if !addr.IsValid() { + return 0, errMissingAddress + } + + switch c.fd.family { + case syscall.AF_INET: + sa, err := addrPortToSockaddrInet4(addr) + if err != nil { + return 0, err + } + return c.fd.writeToInet4(b, sa) + case syscall.AF_INET6: + sa, err := addrPortToSockaddrInet6(addr) + if err != nil { + return 0, err + } + return c.fd.writeToInet6(b, sa) + default: + return 0, &AddrError{Err: "invalid address family", Addr: addr.Addr().String()} + } +} + func (c *UDPConn) writeMsg(b, oob []byte, addr *UDPAddr) (n, oobn int, err error) { if c.fd.isConnected && addr != nil { return 0, 0, ErrWriteToConnected From c702f91b38f98c98a12b9933dce42dbd500e21fd Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 1 Nov 2021 13:45:21 -0700 Subject: [PATCH 314/406] net: add ReadFromUDPAddrPort MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is now possible to do completely allocation-free UDP. This is implemented completely separately from ReadFromUDP because ReadFromUDP exists in a delicate balance to allow mid-stack inlining. After performance-sensitive callers have migrated to ReadFromUDPAddrPort, we may be able to simplify ReadFromUDP to call ReadFromUDPAddrPort. name old time/op new time/op delta WriteToReadFromUDPAddrPort-8 4.71µs ± 2% 4.81µs ± 5% +2.18% (p=0.000 n=14+14) name old alloc/op new alloc/op delta WriteToReadFromUDPAddrPort-8 4.00B ± 0% 0.00B -100.00% (p=0.000 n=15+15) name old allocs/op new allocs/op delta WriteToReadFromUDPAddrPort-8 1.00 ± 0% 0.00 -100.00% (p=0.000 n=15+15) Change-Id: I37f5ad9416a1d4333ed48d83474b2cf933b2a1be Reviewed-on: https://go-review.googlesource.com/c/go/+/360600 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- src/net/udpsock.go | 12 ++++++++++++ src/net/udpsock_plan9.go | 19 +++++++++++++++++++ src/net/udpsock_posix.go | 25 +++++++++++++++++++++++++ src/net/udpsock_test.go | 2 +- 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/net/udpsock.go b/src/net/udpsock.go index a829789a1b..622b1f83fb 100644 --- a/src/net/udpsock.go +++ b/src/net/udpsock.go @@ -167,6 +167,18 @@ func (c *UDPConn) ReadFrom(b []byte) (int, Addr, error) { return n, addr, err } +// ReadFromUDPAddrPort acts like ReadFrom but returns a netip.AddrPort. +func (c *UDPConn) ReadFromUDPAddrPort(b []byte) (n int, addr netip.AddrPort, err error) { + if !c.ok() { + return 0, netip.AddrPort{}, syscall.EINVAL + } + n, addr, err = c.readFromAddrPort(b) + if err != nil { + err = &OpError{Op: "read", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err} + } + return n, addr, err +} + // ReadMsgUDP reads a message from c, copying the payload into b and // the associated out-of-band data into oob. It returns the number of // bytes copied into b, the number of bytes copied into oob, the flags diff --git a/src/net/udpsock_plan9.go b/src/net/udpsock_plan9.go index dfb81a8d0c..732a3b07ee 100644 --- a/src/net/udpsock_plan9.go +++ b/src/net/udpsock_plan9.go @@ -29,6 +29,25 @@ func (c *UDPConn) readFrom(b []byte, addr *UDPAddr) (int, *UDPAddr, error) { return n, addr, nil } +func (c *UDPConn) readFromAddrPort(b []byte) (int, netip.AddrPort, error) { + // TODO: optimize. The equivalent code on posix is alloc-free. + buf := make([]byte, udpHeaderSize+len(b)) + m, err := c.fd.Read(buf) + if err != nil { + return 0, netip.AddrPort{}, err + } + if m < udpHeaderSize { + return 0, netip.AddrPort{}, errors.New("short read reading UDP header") + } + buf = buf[:m] + + h, buf := unmarshalUDPHeader(buf) + n := copy(b, buf) + ip, _ := netip.AddrFromSlice(h.raddr) + addr := netip.AddrPortFrom(ip, h.rport) + return n, addr, nil +} + func (c *UDPConn) readMsg(b, oob []byte) (n, oobn, flags int, addr netip.AddrPort, err error) { return 0, 0, 0, netip.AddrPort{}, syscall.EPLAN9 } diff --git a/src/net/udpsock_posix.go b/src/net/udpsock_posix.go index 718d11e60f..c93994f836 100644 --- a/src/net/udpsock_posix.go +++ b/src/net/udpsock_posix.go @@ -69,6 +69,31 @@ func (c *UDPConn) readFrom(b []byte, addr *UDPAddr) (int, *UDPAddr, error) { return n, addr, err } +func (c *UDPConn) readFromAddrPort(b []byte) (n int, addr netip.AddrPort, err error) { + var ip netip.Addr + var port int + switch c.fd.family { + case syscall.AF_INET: + var from syscall.SockaddrInet4 + n, err = c.fd.readFromInet4(b, &from) + if err == nil { + ip = netip.AddrFrom4(from.Addr) + port = from.Port + } + case syscall.AF_INET6: + var from syscall.SockaddrInet6 + n, err = c.fd.readFromInet6(b, &from) + if err == nil { + ip = netip.AddrFrom16(from.Addr).WithZone(zoneCache.name(int(from.ZoneId))) + port = from.Port + } + } + if err == nil { + addr = netip.AddrPortFrom(ip, uint16(port)) + } + return n, addr, err +} + func (c *UDPConn) readMsg(b, oob []byte) (n, oobn, flags int, addr netip.AddrPort, err error) { var sa syscall.Sockaddr n, oobn, flags, sa, err = c.fd.readMsg(b, oob, 0) diff --git a/src/net/udpsock_test.go b/src/net/udpsock_test.go index 371d9af511..7eef6f64af 100644 --- a/src/net/udpsock_test.go +++ b/src/net/udpsock_test.go @@ -533,7 +533,7 @@ func BenchmarkWriteToReadFromUDPAddrPort(b *testing.B) { if err != nil { b.Fatal(err) } - _, _, err = conn.ReadFromUDP(buf) // TODO: create and use ReadFromUDPAddrPort + _, _, err = conn.ReadFromUDPAddrPort(buf) if err != nil { b.Fatal(err) } From 80a7968842895a5c05efa6464ce49b62413436c1 Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Tue, 2 Nov 2021 13:44:05 -0400 Subject: [PATCH 315/406] cmd/compile/internal/abi: fix some typos in comments Fix a few types in the header comment for 'ComputePadding'. Change-Id: If38911e6dcbec571845ae44eef30fd6c33f589cb Reviewed-on: https://go-review.googlesource.com/c/go/+/360814 Trust: Than McIntosh Run-TryBot: Than McIntosh TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Reviewed-by: Cherry Mui --- src/cmd/compile/internal/abi/abiutils.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd/compile/internal/abi/abiutils.go b/src/cmd/compile/internal/abi/abiutils.go index 4da4e9ca3a..74c8707b29 100644 --- a/src/cmd/compile/internal/abi/abiutils.go +++ b/src/cmd/compile/internal/abi/abiutils.go @@ -780,11 +780,11 @@ func (state *assignState) assignParamOrReturn(pt *types.Type, n types.Object, is } // ComputePadding returns a list of "post element" padding values in -// the case where we have a structure being passed in registers. Give -// a param assignment corresponding to a struct, it returns a list of -// contaning padding values for each field, e.g. the Kth element in +// the case where we have a structure being passed in registers. Given +// a param assignment corresponding to a struct, it returns a list +// containing padding values for each field, e.g. the Kth element in // the list is the amount of padding between field K and the following -// field. For things that are not struct (or structs without padding) +// field. For things that are not structs (or structs without padding) // it returns a list of zeros. Example: // // type small struct { @@ -796,8 +796,8 @@ func (state *assignState) assignParamOrReturn(pt *types.Type, n types.Object, is // // For this struct we would return a list [0, 1, 0, 0], meaning that // we have one byte of padding after the second field, and no bytes of -// padding after any of the other fields. Input parameter "storage" -// is with enough capacity to accommodate padding elements for +// padding after any of the other fields. Input parameter "storage" is +// a slice with enough capacity to accommodate padding elements for // the architected register set in question. func (pa *ABIParamAssignment) ComputePadding(storage []uint64) []uint64 { nr := len(pa.Registers) From 1011e26b9cec8b5e7b0b827805b2fe079904521a Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Tue, 2 Nov 2021 11:52:36 -0700 Subject: [PATCH 316/406] net/http: deflake TestServerKeepAlivesEnabled_h{1,2} This test assumes that two successive TCP connections will use different source ports. This does not appear to be a universally safe assumption. Rewrite the test to use httptrace to detect connection reuse instead. Fixes #46707 Change-Id: Iebfbdfdeb77a1e6663a0c654dc847cc270c5d54d Reviewed-on: https://go-review.googlesource.com/c/go/+/360854 Trust: Damien Neil Run-TryBot: Damien Neil TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/net/http/serve_test.go | 42 ++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go index 6394da3bb7..a98d6c313f 100644 --- a/src/net/http/serve_test.go +++ b/src/net/http/serve_test.go @@ -23,6 +23,7 @@ import ( "net" . "net/http" "net/http/httptest" + "net/http/httptrace" "net/http/httputil" "net/http/internal" "net/http/internal/testcert" @@ -5689,22 +5690,37 @@ func testServerKeepAlivesEnabled(t *testing.T, h2 bool) { } // Not parallel: messes with global variable. (http2goAwayTimeout) defer afterTest(t) - cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) { - fmt.Fprintf(w, "%v", r.RemoteAddr) - })) + cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) {})) defer cst.close() srv := cst.ts.Config srv.SetKeepAlivesEnabled(false) - a := cst.getURL(cst.ts.URL) - if !waitCondition(2*time.Second, 10*time.Millisecond, srv.ExportAllConnsIdle) { - t.Fatalf("test server has active conns") - } - b := cst.getURL(cst.ts.URL) - if a == b { - t.Errorf("got same connection between first and second requests") - } - if !waitCondition(2*time.Second, 10*time.Millisecond, srv.ExportAllConnsIdle) { - t.Fatalf("test server has active conns") + for try := 0; try < 2; try++ { + if !waitCondition(2*time.Second, 10*time.Millisecond, srv.ExportAllConnsIdle) { + t.Fatalf("request %v: test server has active conns", try) + } + conns := 0 + var info httptrace.GotConnInfo + ctx := httptrace.WithClientTrace(context.Background(), &httptrace.ClientTrace{ + GotConn: func(v httptrace.GotConnInfo) { + conns++ + info = v + }, + }) + req, err := NewRequestWithContext(ctx, "GET", cst.ts.URL, nil) + if err != nil { + t.Fatal(err) + } + res, err := cst.c.Do(req) + if err != nil { + t.Fatal(err) + } + res.Body.Close() + if conns != 1 { + t.Fatalf("request %v: got %v conns, want 1", try, conns) + } + if info.Reused || info.WasIdle { + t.Fatalf("request %v: Reused=%v (want false), WasIdle=%v (want false)", try, info.Reused, info.WasIdle) + } } } From c45c32b1cd6ba635fda3add12f48766fd6aef5d8 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Tue, 2 Nov 2021 11:23:34 -0700 Subject: [PATCH 317/406] go/types: avoid closure allocations in mono check This CL replaces monoEdge's "report" field with fields "pos" and "typ", and pushes the logic for formatting them into the report loop. This avoids needing to allocate a function closure for each edge. Also tweak a test case so the two type parameters involved in the cycle aren't both "T" so they're easier to understand. Change-Id: I9d392ad1d99a4c5e89da4613084e885149ebad07 Reviewed-on: https://go-review.googlesource.com/c/go/+/360815 Trust: Matthew Dempsky Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/mono.go | 42 +++++++++++++++++++++------------------ src/go/types/mono_test.go | 2 +- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/go/types/mono.go b/src/go/types/mono.go index fb1127e959..d4d884393b 100644 --- a/src/go/types/mono.go +++ b/src/go/types/mono.go @@ -71,14 +71,11 @@ type monoVertex struct { } type monoEdge struct { - dst int - src int - weight int + dst, src int + weight int - // report emits an error describing why this edge exists. - // - // TODO(mdempsky): Avoid requiring a function closure for each edge. - report func(check *Checker) + pos token.Pos + typ Type } func (check *Checker) monomorph() { @@ -139,12 +136,22 @@ func (check *Checker) reportInstanceLoop(v int) { // TODO(mdempsky): Pivot stack so we report the cycle from the top? - obj := check.mono.vertices[v].obj - check.errorf(obj, _InvalidInstanceCycle, "instantiation cycle:") + obj0 := check.mono.vertices[v].obj + check.errorf(obj0, _InvalidInstanceCycle, "instantiation cycle:") + qf := RelativeTo(check.pkg) for _, v := range stack { edge := check.mono.edges[check.mono.vertices[v].pre] - edge.report(check) + obj := check.mono.vertices[edge.dst].obj + + switch obj.Type().(type) { + default: + panic("unexpected type") + case *Named: + check.errorf(atPos(edge.pos), _InvalidInstanceCycle, "\t%s implicitly parameterized by %s", obj.Name(), TypeString(edge.typ, qf)) // secondary error, \t indented + case *TypeParam: + check.errorf(atPos(edge.pos), _InvalidInstanceCycle, "\t%s instantiated as %s", obj.Name(), TypeString(edge.typ, qf)) // secondary error, \t indented + } } } @@ -190,10 +197,7 @@ func (w *monoGraph) assign(pkg *Package, pos token.Pos, tpar *TypeParam, targ Ty weight = 0 } - w.addEdge(w.typeParamVertex(tpar), src, weight, func(check *Checker) { - qf := RelativeTo(check.pkg) - check.errorf(atPos(pos), _InvalidInstanceCycle, "\t%s instantiated as %s", tpar.Obj().Name(), TypeString(targ, qf)) // secondary error, \t indented - }) + w.addEdge(w.typeParamVertex(tpar), src, weight, pos, targ) } // Recursively walk the type argument to find any defined types or @@ -283,9 +287,7 @@ func (w *monoGraph) localNamedVertex(pkg *Package, named *Named) int { w.vertices = append(w.vertices, monoVertex{obj: obj}) } - w.addEdge(idx, w.typeParamVertex(tpar), 1, func(check *Checker) { - check.errorf(obj, _InvalidInstanceCycle, "\t%s implicitly parameterized by %s", obj.Name(), elem.Name()) - }) + w.addEdge(idx, w.typeParamVertex(tpar), 1, obj.Pos(), tpar) } } } @@ -320,12 +322,14 @@ func (w *monoGraph) typeParamVertex(tpar *TypeParam) int { return idx } -func (w *monoGraph) addEdge(dst, src, weight int, report func(check *Checker)) { +func (w *monoGraph) addEdge(dst, src, weight int, pos token.Pos, typ Type) { // TODO(mdempsky): Deduplicate redundant edges? w.edges = append(w.edges, monoEdge{ dst: dst, src: src, weight: weight, - report: report, + + pos: pos, + typ: typ, }) } diff --git a/src/go/types/mono_test.go b/src/go/types/mono_test.go index c4c5282427..5df3d493f8 100644 --- a/src/go/types/mono_test.go +++ b/src/go/types/mono_test.go @@ -84,7 +84,7 @@ var bads = []string{ "func F[T any]() { type U int; F[*U]() }", "type U[T any] int; func (U[T]) m() { var _ U[*T] }", "type U[T any] int; func (*U[T]) m() { var _ U[*T] }", - "type U[T any] [unsafe.Sizeof(F[*T])]byte; func F[T any]() { var _ U[T] }", + "type U[T1 any] [unsafe.Sizeof(F[*T1])]byte; func F[T2 any]() { var _ U[T2] }", "func F[A, B, C, D, E any]() { F[B, C, D, E, *A]() }", "type U[_ any] int; const X = unsafe.Sizeof(func() { type A[T any] U[A[*T]] })", "func F[T any]() { type A = *T; F[A]() }", From 7c9510ef3ec4b1008b599c9c8a0ec9adaba4b663 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 1 Nov 2021 22:35:29 +0000 Subject: [PATCH 318/406] syscall: fix finalizer fd close bugs in TestFcntlFlock and TestPassFD Currently, the syscall test suite takes very little time to run. It stands to reason that pretty much every time, zero GCs execute. With CL 309869, this changes because the minimum heap size is lowered, triggering two bugs in the test suite. One bug is in TestFcntlFlock, where a raw FD is wrapped in an os.File whose last reference is passed into a Cmd. That FD is then closed by a defer syscall.Close, instead of the os.File's Close, so the finalizer may fire *after* that FD has already been reused by another test. The second bug is in the child helper process of TestPassFD, where there's a small window in which a temp file's FD is encoded for an out-of-band unix domain socket message to the parent, but not yet sent. The point of encoding is also the last reference that FD's os.File, so a finalizer may run at any time. While it's safe for the finalizer to run after the FD is sent, if it runs before, the send will fail, since unix domain sockets require that any sent FDs are valid. Change-Id: I2d1bd7e6db6efcc6763273217fd85cb5b9764274 Reviewed-on: https://go-review.googlesource.com/c/go/+/360575 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/syscall/syscall_unix_test.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/syscall/syscall_unix_test.go b/src/syscall/syscall_unix_test.go index 7cc78c2147..e4af0ba4a5 100644 --- a/src/syscall/syscall_unix_test.go +++ b/src/syscall/syscall_unix_test.go @@ -84,16 +84,24 @@ func TestFcntlFlock(t *testing.T) { if err != nil { t.Fatalf("Open failed: %v", err) } - defer syscall.Close(fd) - if err := syscall.Ftruncate(fd, 1<<20); err != nil { + // f takes ownership of fd, and will close it. + // + // N.B. This defer is also necessary to keep f alive + // while we use its fd, preventing its finalizer from + // executing. + f := os.NewFile(uintptr(fd), name) + defer f.Close() + + if err := syscall.Ftruncate(int(f.Fd()), 1<<20); err != nil { t.Fatalf("Ftruncate(1<<20) failed: %v", err) } - if err := syscall.FcntlFlock(uintptr(fd), syscall.F_SETLK, &flock); err != nil { + if err := syscall.FcntlFlock(f.Fd(), syscall.F_SETLK, &flock); err != nil { t.Fatalf("FcntlFlock(F_SETLK) failed: %v", err) } + cmd := exec.Command(os.Args[0], "-test.run=^TestFcntlFlock$") cmd.Env = append(os.Environ(), "GO_WANT_HELPER_PROCESS=1") - cmd.ExtraFiles = []*os.File{os.NewFile(uintptr(fd), name)} + cmd.ExtraFiles = []*os.File{f} out, err := cmd.CombinedOutput() if len(out) > 0 || err != nil { t.Fatalf("child process: %q, %v", out, err) @@ -251,6 +259,10 @@ func passFDChild() { fmt.Printf("TempFile: %v", err) return } + // N.B. This defer is also necessary to keep f alive + // while we use its fd, preventing its finalizer from + // executing. + defer f.Close() f.Write([]byte("Hello from child process!\n")) f.Seek(0, io.SeekStart) From b29182b54ac343bbc58a30357d9df908f1c3b727 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Mon, 1 Nov 2021 15:27:13 -0400 Subject: [PATCH 319/406] go/types: clean up asT converters (step 1 of 2) This is a port of CL 358597 to go/types. A comment was missing in the base of applyTypeFunc, which had been there since the initial check-in of types2; somehow it was not in go/types. Change-Id: If08efd92d782dd3099b26254ae6e311c6cea8c3b Reviewed-on: https://go-review.googlesource.com/c/go/+/360477 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/assignments.go | 2 +- src/go/types/builtins.go | 24 +++++--- src/go/types/call.go | 8 +-- src/go/types/conversions.go | 24 +++++--- src/go/types/expr.go | 8 ++- src/go/types/index.go | 6 +- src/go/types/infer.go | 4 +- src/go/types/lookup.go | 8 +-- src/go/types/predicates.go | 10 +-- src/go/types/sizeof_test.go | 1 - src/go/types/sizes.go | 2 +- src/go/types/subst.go | 2 +- src/go/types/testdata/check/issues.go2 | 7 +++ src/go/types/type.go | 85 +++++++------------------- src/go/types/typestring.go | 5 +- src/go/types/typexpr.go | 4 +- 16 files changed, 83 insertions(+), 117 deletions(-) diff --git a/src/go/types/assignments.go b/src/go/types/assignments.go index 2810133a1f..cfdb0eb14a 100644 --- a/src/go/types/assignments.go +++ b/src/go/types/assignments.go @@ -71,7 +71,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) { } // A generic (non-instantiated) function value cannot be assigned to a variable. - if sig := asSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { + if sig := toSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { check.errorf(x, _Todo, "cannot use generic function %s without instantiation in %s", x, context) } diff --git a/src/go/types/builtins.go b/src/go/types/builtins.go index 87c26775a6..e6fb6ef4ff 100644 --- a/src/go/types/builtins.go +++ b/src/go/types/builtins.go @@ -83,7 +83,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b // of S and the respective parameter passing rules apply." S := x.typ var T Type - if s := asSlice(S); s != nil { + if s, _ := singleUnder(S).(*Slice); s != nil { T = s.elem } else { check.invalidArg(x, _InvalidAppend, "%s is not a slice", x) @@ -296,8 +296,10 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b } // the argument types must be of floating-point type - f := func(x Type) Type { - if t := asBasic(x); t != nil { + // (applyTypeFunc never calls f with a type parameter) + f := func(typ Type) Type { + assert(asTypeParam(typ) == nil) + if t := toBasic(typ); t != nil { switch t.kind { case Float32: return Typ[Complex64] @@ -418,8 +420,10 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b } // the argument must be of complex type - f := func(x Type) Type { - if t := asBasic(x); t != nil { + // (applyTypeFunc never calls f with a type parameter) + f := func(typ Type) Type { + assert(asTypeParam(typ) == nil) + if t := toBasic(typ); t != nil { switch t.kind { case Complex64: return Typ[Float32] @@ -709,7 +713,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b return } - typ := asPointer(x.typ) + typ := toPointer(x.typ) if typ == nil { check.invalidArg(x, _InvalidUnsafeSlice, "%s is not a pointer", x) return @@ -825,7 +829,7 @@ func hasVarSize(t Type) bool { } case *TypeParam: return true - case *Named, *Union, *top: + case *Named, *Union: unreachable() } return false @@ -856,8 +860,8 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x Type) Type { return nil } - // Construct a suitable new type parameter for the sum type. The - // type param is placed in the current package so export/import + // Construct a suitable new type parameter for the result type. + // The type parameter is placed in the current package so export/import // works as expected. tpar := NewTypeName(token.NoPos, check.pkg, "", nil) ptyp := check.newTypeParam(tpar, NewInterfaceType(nil, []Type{NewUnion(terms)})) // assigns type to tpar as a side-effect @@ -889,7 +893,7 @@ func makeSig(res Type, args ...Type) *Signature { // otherwise it returns typ. func arrayPtrDeref(typ Type) Type { if p, ok := typ.(*Pointer); ok { - if a := asArray(p.base); a != nil { + if a := toArray(p.base); a != nil { return a } } diff --git a/src/go/types/call.go b/src/go/types/call.go index 36086891b5..a4e834271f 100644 --- a/src/go/types/call.go +++ b/src/go/types/call.go @@ -141,10 +141,9 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind { check.errorf(call.Args[0], _BadDotDotDotSyntax, "invalid use of ... in conversion to %s", T) break } - if t := asInterface(T); t != nil { + if t := toInterface(T); t != nil { if !t.IsMethodSet() { - // TODO(rfindley): remove the phrase "type list" from this error. - check.errorf(call, _Todo, "cannot use interface %s in conversion (contains type list or is comparable)", T) + check.errorf(call, _Todo, "cannot use interface %s in conversion (contains specific type constraints or is comparable)", T) break } } @@ -175,7 +174,8 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind { // signature may be generic cgocall := x.mode == cgofunc - sig := asSignature(x.typ) + // a type parameter may be "called" if all types have the same signature + sig, _ := singleUnder(x.typ).(*Signature) if sig == nil { check.invalidOp(x, _InvalidCall, "cannot call non-function %s", x) x.mode = invalid diff --git a/src/go/types/conversions.go b/src/go/types/conversions.go index 8c8b63e23a..c3fc04e406 100644 --- a/src/go/types/conversions.go +++ b/src/go/types/conversions.go @@ -21,7 +21,7 @@ func (check *Checker) conversion(x *operand, T Type) { switch { case constArg && isConstType(T): // constant conversion (T cannot be a type parameter) - switch t := asBasic(T); { + switch t := toBasic(T); { case representableConst(x.val, check, t, &x.val): ok = true case isInteger(x.typ) && isString(t): @@ -198,9 +198,9 @@ func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { // "V is a slice, T is a pointer-to-array type, // and the slice and array types have identical element types." - if s := asSlice(V); s != nil { - if p := asPointer(T); p != nil { - if a := asArray(p.Elem()); a != nil { + if s := toSlice(V); s != nil { + if p := toPointer(T); p != nil { + if a := toArray(p.Elem()); a != nil { if Identical(s.Elem(), a.Elem()) { if check == nil || check.allowVersion(check.pkg, 1, 17) { return true @@ -216,27 +216,31 @@ func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { return false } +// Helper predicates for convertibleToImpl. The types provided to convertibleToImpl +// may be type parameters but they won't have specific type terms. Thus it is ok to +// use the toT convenience converters in the predicates below. + func isUintptr(typ Type) bool { - t := asBasic(typ) + t := toBasic(typ) return t != nil && t.kind == Uintptr } func isUnsafePointer(typ Type) bool { - // TODO(gri): Is this asBasic(typ) instead of typ.(*Basic) correct? + // TODO(gri): Is this toBasic(typ) instead of typ.(*Basic) correct? // (The former calls under(), while the latter doesn't.) // The spec does not say so, but gc claims it is. See also // issue 6326. - t := asBasic(typ) + t := toBasic(typ) return t != nil && t.kind == UnsafePointer } func isPointer(typ Type) bool { - return asPointer(typ) != nil + return toPointer(typ) != nil } func isBytesOrRunes(typ Type) bool { - if s := asSlice(typ); s != nil { - t := asBasic(s.elem) + if s := toSlice(typ); s != nil { + t := toBasic(s.elem) return t != nil && (t.kind == Byte || t.kind == Rune) } return false diff --git a/src/go/types/expr.go b/src/go/types/expr.go index ef5958ba3f..266f896f6e 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -100,8 +100,10 @@ func (check *Checker) overflow(x *operand, op token.Token, opPos token.Pos) { // Typed constants must be representable in // their type after each constant operation. + // x.typ cannot be a type parameter (type + // parameters cannot be constant types). if isTyped(x.typ) { - check.representable(x, asBasic(x.typ)) + check.representable(x, toBasic(x.typ)) return } @@ -554,7 +556,7 @@ func (check *Checker) updateExprType(x ast.Expr, typ Type, final bool) { // If the new type is not final and still untyped, just // update the recorded type. if !final && isUntyped(typ) { - old.typ = asBasic(typ) + old.typ = toBasic(typ) check.untyped[x] = old return } @@ -1353,7 +1355,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind { duplicate := false // if the key is of interface type, the type is also significant when checking for duplicates xkey := keyVal(x.val) - if asInterface(utyp.key) != nil { + if toInterface(utyp.key) != nil { for _, vtyp := range visited[xkey] { if Identical(vtyp, x.typ) { duplicate = true diff --git a/src/go/types/index.go b/src/go/types/index.go index 24c1812039..9f723bcf67 100644 --- a/src/go/types/index.go +++ b/src/go/types/index.go @@ -35,7 +35,7 @@ func (check *Checker) indexExpr(x *operand, e *typeparams.IndexExpr) (isFuncInst return false case value: - if sig := asSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { + if sig := toSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { // function instantiation return true } @@ -72,7 +72,7 @@ func (check *Checker) indexExpr(x *operand, e *typeparams.IndexExpr) (isFuncInst x.typ = typ.elem case *Pointer: - if typ := asArray(typ.base); typ != nil { + if typ := toArray(typ.base); typ != nil { valid = true length = typ.len x.mode = variable @@ -242,7 +242,7 @@ func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) { x.typ = &Slice{elem: u.elem} case *Pointer: - if u := asArray(u.base); u != nil { + if u := toArray(u.base); u != nil { valid = true length = u.len x.typ = &Slice{elem: u.elem} diff --git a/src/go/types/infer.go b/src/go/types/infer.go index 9302bd7f57..cea0780721 100644 --- a/src/go/types/infer.go +++ b/src/go/types/infer.go @@ -270,7 +270,7 @@ func (w *tpWalker) isParameterized(typ Type) (res bool) { }() switch t := typ.(type) { - case nil, *top, *Basic: // TODO(gri) should nil be handled here? + case nil, *Basic: // TODO(gri) should nil be handled here? break case *Array: @@ -499,7 +499,7 @@ func (w *cycleFinder) typ(typ Type) { defer delete(w.seen, typ) switch t := typ.(type) { - case *Basic, *top: + case *Basic: // nothing to do case *Array: diff --git a/src/go/types/lookup.go b/src/go/types/lookup.go index afb1215af2..506cc69384 100644 --- a/src/go/types/lookup.go +++ b/src/go/types/lookup.go @@ -302,7 +302,7 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method, return } - if ityp := asInterface(V); ityp != nil { + if ityp := toInterface(V); ityp != nil { // TODO(gri) the methods are sorted - could do this more efficiently for _, m := range T.typeSet().methods { _, f := ityp.typeSet().LookupMethod(m.pkg, m.name) @@ -400,7 +400,7 @@ func (check *Checker) assertableTo(V *Interface, T Type) (method, wrongType *Fun // no static check is required if T is an interface // spec: "If T is an interface type, x.(T) asserts that the // dynamic type of x implements the interface T." - if asInterface(T) != nil && !forceStrict { + if toInterface(T) != nil && !forceStrict { return } return check.missingMethod(T, V, false) @@ -418,8 +418,8 @@ func deref(typ Type) (Type, bool) { // derefStructPtr dereferences typ if it is a (named or unnamed) pointer to a // (named or unnamed) struct and returns its base. Otherwise it returns typ. func derefStructPtr(typ Type) Type { - if p := asPointer(typ); p != nil { - if asStruct(p.base) != nil { + if p := toPointer(typ); p != nil { + if toStruct(p.base) != nil { return p.base } } diff --git a/src/go/types/predicates.go b/src/go/types/predicates.go index b687c151c7..d4ce97a16b 100644 --- a/src/go/types/predicates.go +++ b/src/go/types/predicates.go @@ -58,7 +58,7 @@ func isNumericOrString(typ Type) bool { return is(typ, IsNumeric|IsString) } // are not fully set up. func isTyped(typ Type) bool { // isTyped is called with types that are not fully - // set up. Must not call asBasic()! + // set up. Must not call toBasic()! t, _ := typ.(*Basic) return t == nil || t.info&IsUntyped == 0 } @@ -72,13 +72,13 @@ func isOrdered(typ Type) bool { return is(typ, IsOrdered) } func isConstType(typ Type) bool { // Type parameters are never const types. - t, _ := under(typ).(*Basic) + t := toBasic(typ) return t != nil && t.info&IsConstType != 0 } // IsInterface reports whether typ is an interface type. func IsInterface(typ Type) bool { - return asInterface(typ) != nil + return toInterface(typ) != nil } // Comparable reports whether values of type T are comparable. @@ -341,10 +341,6 @@ func identical(x, y Type, cmpTags bool, p *ifacePair) bool { case *TypeParam: // nothing to do (x and y being equal is caught in the very beginning of this function) - case *top: - // Either both types are theTop in which case the initial x == y check - // will have caught them. Otherwise they are not identical. - case nil: // avoid a crash in case of nil type diff --git a/src/go/types/sizeof_test.go b/src/go/types/sizeof_test.go index 0e3c0064a0..5b7ee8bb78 100644 --- a/src/go/types/sizeof_test.go +++ b/src/go/types/sizeof_test.go @@ -33,7 +33,6 @@ func TestSizeof(t *testing.T) { {Named{}, 68, 128}, {TypeParam{}, 28, 48}, {term{}, 12, 24}, - {top{}, 0, 0}, // Objects {PkgName{}, 48, 88}, diff --git a/src/go/types/sizes.go b/src/go/types/sizes.go index 4c85bfe057..0f65c5830c 100644 --- a/src/go/types/sizes.go +++ b/src/go/types/sizes.go @@ -243,7 +243,7 @@ func (conf *Config) offsetsof(T *Struct) []int64 { func (conf *Config) offsetof(typ Type, index []int) int64 { var o int64 for _, i := range index { - s := asStruct(typ) + s := toStruct(typ) o += conf.offsetsof(s)[i] typ = s.fields[i].typ } diff --git a/src/go/types/subst.go b/src/go/types/subst.go index e539ab54e6..f0b79f60c6 100644 --- a/src/go/types/subst.go +++ b/src/go/types/subst.go @@ -74,7 +74,7 @@ func (subst *subster) typ(typ Type) Type { // Call typOrNil if it's possible that typ is nil. panic("nil typ") - case *Basic, *top: + case *Basic: // nothing to do case *Array: diff --git a/src/go/types/testdata/check/issues.go2 b/src/go/types/testdata/check/issues.go2 index 6a93bcc9ac..b7bba5d3b1 100644 --- a/src/go/types/testdata/check/issues.go2 +++ b/src/go/types/testdata/check/issues.go2 @@ -224,6 +224,13 @@ func _[T interface{ ~func() }](f T) { go f() } +type F1 func() +type F2 func() +func _[T interface{ func()|F1|F2 }](f T) { + f() + go f() +} + // We must compare against the underlying type of term list entries // when checking if a constraint is satisfied by a type. The under- // lying type of each term list entry must be computed after the diff --git a/src/go/types/type.go b/src/go/types/type.go index 502c9b2d52..011babdcb9 100644 --- a/src/go/types/type.go +++ b/src/go/types/type.go @@ -9,26 +9,13 @@ package types type Type interface { // Underlying returns the underlying type of a type // w/o following forwarding chains. Only used by - // client packages (here for backward-compatibility). + // client packages. Underlying() Type // String returns a string representation of a type. String() string } -// top represents the top of the type lattice. -// It is the underlying type of a type parameter that -// can be satisfied by any type (ignoring methods), -// because its type constraint contains no restrictions -// besides methods. -type top struct{} - -// theTop is the singleton top type. -var theTop = &top{} - -func (t *top) Underlying() Type { return t } -func (t *top) String() string { return TypeString(t, nil) } - // under returns the true expanded underlying type. // If it doesn't exist, the result is Typ[Invalid]. // under must only be called when a type is known @@ -40,77 +27,47 @@ func under(t Type) Type { return t } -// optype returns a type's operational type. Except for -// type parameters, the operational type is the same -// as the underlying type (as returned by under). For -// Type parameters, the operational type is the structural -// type, if any; otherwise it's the top type. -// The result is never the incoming type parameter. -func optype(typ Type) Type { - if t := asTypeParam(typ); t != nil { - // TODO(gri) review accuracy of this comment - // If the optype is typ, return the top type as we have - // no information. It also prevents infinite recursion - // via the asTypeParam converter function. This can happen - // for a type parameter list of the form: - // (type T interface { type T }). - // See also issue #39680. - if u := t.structuralType(); u != nil { - assert(u != typ) // "naked" type parameters cannot be embedded - return under(u) // optype should always return an underlying type - } - return theTop - } - return under(typ) -} +// Convenience converters -// Converters -// -// A converter must only be called when a type is -// known to be fully set up. A converter returns -// a type's operational type (see comment for optype) -// or nil if the type argument is not of the -// respective type. - -func asBasic(t Type) *Basic { - op, _ := optype(t).(*Basic) +func toBasic(t Type) *Basic { + op, _ := under(t).(*Basic) return op } -func asArray(t Type) *Array { - op, _ := optype(t).(*Array) +func toArray(t Type) *Array { + op, _ := under(t).(*Array) return op } -func asSlice(t Type) *Slice { - op, _ := optype(t).(*Slice) +func toSlice(t Type) *Slice { + op, _ := under(t).(*Slice) return op } -func asStruct(t Type) *Struct { - op, _ := optype(t).(*Struct) +func toStruct(t Type) *Struct { + op, _ := under(t).(*Struct) return op } -func asPointer(t Type) *Pointer { - op, _ := optype(t).(*Pointer) +func toPointer(t Type) *Pointer { + op, _ := under(t).(*Pointer) return op } -func asSignature(t Type) *Signature { - op, _ := optype(t).(*Signature) +func toSignature(t Type) *Signature { + op, _ := under(t).(*Signature) return op } -// If the argument to asInterface, asNamed, or asTypeParam is of the respective type -// (possibly after expanding an instance type), these methods return that type. +func toInterface(t Type) *Interface { + op, _ := under(t).(*Interface) + return op +} + +// If the argument to asNamed, or asTypeParam is of the respective type +// (possibly after expanding resolving a *Named type), these methods return that type. // Otherwise the result is nil. -func asInterface(t Type) *Interface { - op, _ := optype(t).(*Interface) - return op -} - func asNamed(t Type) *Named { e, _ := t.(*Named) if e != nil { diff --git a/src/go/types/typestring.go b/src/go/types/typestring.go index 9154ebc406..1e36db82ea 100644 --- a/src/go/types/typestring.go +++ b/src/go/types/typestring.go @@ -283,9 +283,6 @@ func (w *typeWriter) typ(typ Type) { w.string(subscript(t.id)) } - case *top: - w.error("⊤") - default: // For externally defined implementations of Type. // Note: In this case cycles won't be caught. @@ -369,7 +366,7 @@ func (w *typeWriter) tuple(tup *Tuple, variadic bool) { } else { // special case: // append(s, "foo"...) leads to signature func([]byte, string...) - if t := asBasic(typ); t == nil || t.kind != String { + if t := toBasic(typ); t == nil || t.kind != String { w.error("expected string type") continue } diff --git a/src/go/types/typexpr.go b/src/go/types/typexpr.go index 3636c8556a..ad6eab9c79 100644 --- a/src/go/types/typexpr.go +++ b/src/go/types/typexpr.go @@ -141,11 +141,11 @@ func (check *Checker) typ(e ast.Expr) Type { // constraint interface. func (check *Checker) varType(e ast.Expr) Type { typ := check.definedType(e, nil) - // We don't want to call under() (via asInterface) or complete interfaces while we + // We don't want to call under() (via toInterface) or complete interfaces while we // are in the middle of type-checking parameter declarations that might belong to // interface methods. Delay this check to the end of type-checking. check.later(func() { - if t := asInterface(typ); t != nil { + if t := toInterface(typ); t != nil { tset := computeInterfaceTypeSet(check, e.Pos(), t) // TODO(gri) is this the correct position? if !tset.IsMethodSet() { if tset.comparable { From b24687394b55a93449e2be4e6892ead58ea9a10f Mon Sep 17 00:00:00 2001 From: Jason7602 Date: Tue, 14 Sep 2021 21:38:19 +0800 Subject: [PATCH 320/406] archive/zip: don't panic on (*Reader).Open Previously, opening a zip with (*Reader).Open could result in a panic if the zip contained a file whose name was exclusively made up of slash characters or ".." path elements. Open could also panic if passed the empty string directly as an argument. Now, any files in the zip whose name could not be made valid for fs.FS.Open will be skipped, and no longer added to the fs.FS file list, although they are still accessible through (*Reader).File. Note that it was already the case that a file could be accessible from (*Reader).Open with a name different from the one in (*Reader).File, as the former is the cleaned name, while the latter is the original one. Finally, made the actual panic site robust as a defense-in-depth measure. Fixes CVE-2021-41772 Fixes #48085 Co-authored-by: Filippo Valsorda Change-Id: I6271a3f2892e7746f52e213b8eba9a1bba974678 Reviewed-on: https://go-review.googlesource.com/c/go/+/349770 Run-TryBot: Filippo Valsorda Reviewed-by: Katie Hockman Reviewed-by: Filippo Valsorda Trust: Katie Hockman Trust: Julie Qiu --- src/archive/zip/reader.go | 10 ++- src/archive/zip/reader_test.go | 128 +++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+), 2 deletions(-) diff --git a/src/archive/zip/reader.go b/src/archive/zip/reader.go index c91a8d00e6..e40a2c656b 100644 --- a/src/archive/zip/reader.go +++ b/src/archive/zip/reader.go @@ -741,6 +741,9 @@ func (r *Reader) initFileList() { for _, file := range r.File { isDir := len(file.Name) > 0 && file.Name[len(file.Name)-1] == '/' name := toValidName(file.Name) + if name == "" { + continue + } for dir := path.Dir(name); dir != "."; dir = path.Dir(dir) { dirs[dir] = true } @@ -782,8 +785,11 @@ func fileEntryLess(x, y string) bool { func (r *Reader) Open(name string) (fs.File, error) { r.initFileList() + if !fs.ValidPath(name) { + return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrInvalid} + } e := r.openLookup(name) - if e == nil || !fs.ValidPath(name) { + if e == nil { return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist} } if e.isDir { @@ -797,7 +803,7 @@ func (r *Reader) Open(name string) (fs.File, error) { } func split(name string) (dir, elem string, isDir bool) { - if name[len(name)-1] == '/' { + if len(name) > 0 && name[len(name)-1] == '/' { isDir = true name = name[:len(name)-1] } diff --git a/src/archive/zip/reader_test.go b/src/archive/zip/reader_test.go index afb03ace24..a54915316c 100644 --- a/src/archive/zip/reader_test.go +++ b/src/archive/zip/reader_test.go @@ -13,6 +13,7 @@ import ( "io/fs" "os" "path/filepath" + "reflect" "regexp" "strings" "testing" @@ -1202,6 +1203,15 @@ func TestCVE202127919(t *testing.T) { if err != nil { t.Errorf("Error reading file: %v", err) } + if len(r.File) != 1 { + t.Fatalf("No entries in the file list") + } + if r.File[0].Name != "../test.txt" { + t.Errorf("Unexpected entry name: %s", r.File[0].Name) + } + if _, err := r.File[0].Open(); err != nil { + t.Errorf("Error opening file: %v", err) + } } func TestReadDataDescriptor(t *testing.T) { @@ -1402,3 +1412,121 @@ func TestCVE202139293(t *testing.T) { t.Fatalf("unexpected error, got: %v, want: %v", err, ErrFormat) } } + +func TestCVE202141772(t *testing.T) { + // Archive contains a file whose name is exclusively made up of '/', '\' + // characters, or "../", "..\" paths, which would previously cause a panic. + // + // Length Method Size Cmpr Date Time CRC-32 Name + // -------- ------ ------- ---- ---------- ----- -------- ---- + // 0 Stored 0 0% 08-05-2021 18:32 00000000 / + // 0 Stored 0 0% 09-14-2021 12:59 00000000 // + // 0 Stored 0 0% 09-14-2021 12:59 00000000 \ + // 11 Stored 11 0% 09-14-2021 13:04 0d4a1185 /test.txt + // -------- ------- --- ------- + // 11 11 0% 4 files + data := []byte{ + 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x08, + 0x00, 0x00, 0x06, 0x94, 0x05, 0x53, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2f, 0x50, + 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x78, 0x67, 0x2e, 0x53, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x2f, 0x2f, 0x50, + 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x78, 0x67, 0x2e, 0x53, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x5c, 0x50, 0x4b, + 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x91, 0x68, 0x2e, 0x53, 0x85, 0x11, 0x4a, 0x0d, + 0x0b, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x2f, 0x74, 0x65, 0x73, + 0x74, 0x2e, 0x74, 0x78, 0x74, 0x68, 0x65, 0x6c, + 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, + 0x50, 0x4b, 0x01, 0x02, 0x14, 0x03, 0x0a, 0x00, + 0x00, 0x08, 0x00, 0x00, 0x06, 0x94, 0x05, 0x53, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + 0xed, 0x41, 0x00, 0x00, 0x00, 0x00, 0x2f, 0x50, + 0x4b, 0x01, 0x02, 0x3f, 0x00, 0x0a, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x78, 0x67, 0x2e, 0x53, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x24, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x1f, 0x00, 0x00, 0x00, 0x2f, 0x2f, 0x0a, + 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x18, 0x00, 0x93, 0x98, 0x25, 0x57, 0x25, + 0xa9, 0xd7, 0x01, 0x93, 0x98, 0x25, 0x57, 0x25, + 0xa9, 0xd7, 0x01, 0x93, 0x98, 0x25, 0x57, 0x25, + 0xa9, 0xd7, 0x01, 0x50, 0x4b, 0x01, 0x02, 0x3f, + 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, + 0x67, 0x2e, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x20, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, + 0x00, 0x5c, 0x0a, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x93, 0x98, + 0x25, 0x57, 0x25, 0xa9, 0xd7, 0x01, 0x93, 0x98, + 0x25, 0x57, 0x25, 0xa9, 0xd7, 0x01, 0x93, 0x98, + 0x25, 0x57, 0x25, 0xa9, 0xd7, 0x01, 0x50, 0x4b, + 0x01, 0x02, 0x3f, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x91, 0x68, 0x2e, 0x53, 0x85, 0x11, + 0x4a, 0x0d, 0x0b, 0x00, 0x00, 0x00, 0x0b, 0x00, + 0x00, 0x00, 0x09, 0x00, 0x24, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x5e, 0x00, 0x00, 0x00, 0x2f, 0x74, 0x65, 0x73, + 0x74, 0x2e, 0x74, 0x78, 0x74, 0x0a, 0x00, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, + 0x00, 0xa9, 0x80, 0x51, 0x01, 0x26, 0xa9, 0xd7, + 0x01, 0x31, 0xd1, 0x57, 0x01, 0x26, 0xa9, 0xd7, + 0x01, 0xdf, 0x48, 0x85, 0xf9, 0x25, 0xa9, 0xd7, + 0x01, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x04, 0x00, 0x31, 0x01, 0x00, + 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, + } + r, err := NewReader(bytes.NewReader([]byte(data)), int64(len(data))) + if err != nil { + t.Fatalf("Error reading the archive: %v", err) + } + entryNames := []string{`/`, `//`, `\`, `/test.txt`} + var names []string + for _, f := range r.File { + names = append(names, f.Name) + if _, err := f.Open(); err != nil { + t.Errorf("Error opening %q: %v", f.Name, err) + } + if _, err := r.Open(f.Name); err == nil { + t.Errorf("Opening %q with fs.FS API succeeded", f.Name) + } + } + if !reflect.DeepEqual(names, entryNames) { + t.Errorf("Unexpected file entries: %q", names) + } + if _, err := r.Open(""); err == nil { + t.Errorf("Opening %q with fs.FS API succeeded", "") + } + if _, err := r.Open("test.txt"); err != nil { + t.Errorf("Error opening %q with fs.FS API: %v", "test.txt", err) + } + dirEntries, err := fs.ReadDir(r, ".") + if err != nil { + t.Fatalf("Error reading the root directory: %v", err) + } + if len(dirEntries) != 1 || dirEntries[0].Name() != "test.txt" { + t.Errorf("Unexpected directory entries") + for _, dirEntry := range dirEntries { + _, err := r.Open(dirEntry.Name()) + t.Logf("%q (Open error: %v)", dirEntry.Name(), err) + } + t.FailNow() + } + info, err := dirEntries[0].Info() + if err != nil { + t.Fatalf("Error reading info entry: %v", err) + } + if name := info.Name(); name != "test.txt" { + t.Errorf("Inconsistent name in info entry: %v", name) + } +} From 79024cf33d0cea53a0c75f428d79a9f971f12b5b Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 2 Nov 2021 11:05:03 -0700 Subject: [PATCH 321/406] errors: improve wording in As doc comment "so" didn't have an antecedent. Change-Id: I27f7b334decea7bc34bfa3f3f2d3a79874c6fe90 Reviewed-on: https://go-review.googlesource.com/c/go/+/360797 Trust: Josh Bleecher Snyder Reviewed-by: Ian Lance Taylor --- src/errors/wrap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/errors/wrap.go b/src/errors/wrap.go index b73d5a8ce2..ab3cdb86d3 100644 --- a/src/errors/wrap.go +++ b/src/errors/wrap.go @@ -59,7 +59,7 @@ func Is(err, target error) bool { } } -// As finds the first error in err's chain that matches target, and if so, sets +// As finds the first error in err's chain that matches target, and if one is found, sets // target to that error value and returns true. Otherwise, it returns false. // // The chain consists of err itself followed by the sequence of errors obtained by From 1012bc810fcd3076015edf947785e54ec6b1d766 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 2 Nov 2021 11:20:10 -0400 Subject: [PATCH 322/406] go/types: clean up asT converters (step 2 of 2) This is a clean port of CL 358774 to go/types. Change-Id: Icba54336de2b8de7c2002d2a44cac856907178c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/360754 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/assignments.go | 2 +- src/go/types/builtins.go | 8 ++++---- src/go/types/call.go | 2 +- src/go/types/conversions.go | 20 ++++++++++---------- src/go/types/expr.go | 6 +++--- src/go/types/index.go | 6 +++--- src/go/types/lookup.go | 8 ++++---- src/go/types/predicates.go | 6 +++--- src/go/types/sizes.go | 2 +- src/go/types/type.go | 14 +++++++------- src/go/types/typestring.go | 2 +- src/go/types/typexpr.go | 2 +- 12 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/go/types/assignments.go b/src/go/types/assignments.go index cfdb0eb14a..2810133a1f 100644 --- a/src/go/types/assignments.go +++ b/src/go/types/assignments.go @@ -71,7 +71,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) { } // A generic (non-instantiated) function value cannot be assigned to a variable. - if sig := toSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { + if sig := asSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { check.errorf(x, _Todo, "cannot use generic function %s without instantiation in %s", x, context) } diff --git a/src/go/types/builtins.go b/src/go/types/builtins.go index e6fb6ef4ff..ceb2adcaae 100644 --- a/src/go/types/builtins.go +++ b/src/go/types/builtins.go @@ -299,7 +299,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b // (applyTypeFunc never calls f with a type parameter) f := func(typ Type) Type { assert(asTypeParam(typ) == nil) - if t := toBasic(typ); t != nil { + if t := asBasic(typ); t != nil { switch t.kind { case Float32: return Typ[Complex64] @@ -423,7 +423,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b // (applyTypeFunc never calls f with a type parameter) f := func(typ Type) Type { assert(asTypeParam(typ) == nil) - if t := toBasic(typ); t != nil { + if t := asBasic(typ); t != nil { switch t.kind { case Complex64: return Typ[Float32] @@ -713,7 +713,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b return } - typ := toPointer(x.typ) + typ := asPointer(x.typ) if typ == nil { check.invalidArg(x, _InvalidUnsafeSlice, "%s is not a pointer", x) return @@ -893,7 +893,7 @@ func makeSig(res Type, args ...Type) *Signature { // otherwise it returns typ. func arrayPtrDeref(typ Type) Type { if p, ok := typ.(*Pointer); ok { - if a := toArray(p.base); a != nil { + if a := asArray(p.base); a != nil { return a } } diff --git a/src/go/types/call.go b/src/go/types/call.go index a4e834271f..64c7658a60 100644 --- a/src/go/types/call.go +++ b/src/go/types/call.go @@ -141,7 +141,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind { check.errorf(call.Args[0], _BadDotDotDotSyntax, "invalid use of ... in conversion to %s", T) break } - if t := toInterface(T); t != nil { + if t := asInterface(T); t != nil { if !t.IsMethodSet() { check.errorf(call, _Todo, "cannot use interface %s in conversion (contains specific type constraints or is comparable)", T) break diff --git a/src/go/types/conversions.go b/src/go/types/conversions.go index c3fc04e406..f8af12b68f 100644 --- a/src/go/types/conversions.go +++ b/src/go/types/conversions.go @@ -21,7 +21,7 @@ func (check *Checker) conversion(x *operand, T Type) { switch { case constArg && isConstType(T): // constant conversion (T cannot be a type parameter) - switch t := toBasic(T); { + switch t := asBasic(T); { case representableConst(x.val, check, t, &x.val): ok = true case isInteger(x.typ) && isString(t): @@ -198,9 +198,9 @@ func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { // "V is a slice, T is a pointer-to-array type, // and the slice and array types have identical element types." - if s := toSlice(V); s != nil { - if p := toPointer(T); p != nil { - if a := toArray(p.Elem()); a != nil { + if s := asSlice(V); s != nil { + if p := asPointer(T); p != nil { + if a := asArray(p.Elem()); a != nil { if Identical(s.Elem(), a.Elem()) { if check == nil || check.allowVersion(check.pkg, 1, 17) { return true @@ -221,26 +221,26 @@ func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { // use the toT convenience converters in the predicates below. func isUintptr(typ Type) bool { - t := toBasic(typ) + t := asBasic(typ) return t != nil && t.kind == Uintptr } func isUnsafePointer(typ Type) bool { - // TODO(gri): Is this toBasic(typ) instead of typ.(*Basic) correct? + // TODO(gri): Is this asBasic(typ) instead of typ.(*Basic) correct? // (The former calls under(), while the latter doesn't.) // The spec does not say so, but gc claims it is. See also // issue 6326. - t := toBasic(typ) + t := asBasic(typ) return t != nil && t.kind == UnsafePointer } func isPointer(typ Type) bool { - return toPointer(typ) != nil + return asPointer(typ) != nil } func isBytesOrRunes(typ Type) bool { - if s := toSlice(typ); s != nil { - t := toBasic(s.elem) + if s := asSlice(typ); s != nil { + t := asBasic(s.elem) return t != nil && (t.kind == Byte || t.kind == Rune) } return false diff --git a/src/go/types/expr.go b/src/go/types/expr.go index 266f896f6e..103053e6b7 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -103,7 +103,7 @@ func (check *Checker) overflow(x *operand, op token.Token, opPos token.Pos) { // x.typ cannot be a type parameter (type // parameters cannot be constant types). if isTyped(x.typ) { - check.representable(x, toBasic(x.typ)) + check.representable(x, asBasic(x.typ)) return } @@ -556,7 +556,7 @@ func (check *Checker) updateExprType(x ast.Expr, typ Type, final bool) { // If the new type is not final and still untyped, just // update the recorded type. if !final && isUntyped(typ) { - old.typ = toBasic(typ) + old.typ = asBasic(typ) check.untyped[x] = old return } @@ -1355,7 +1355,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind { duplicate := false // if the key is of interface type, the type is also significant when checking for duplicates xkey := keyVal(x.val) - if toInterface(utyp.key) != nil { + if asInterface(utyp.key) != nil { for _, vtyp := range visited[xkey] { if Identical(vtyp, x.typ) { duplicate = true diff --git a/src/go/types/index.go b/src/go/types/index.go index 9f723bcf67..24c1812039 100644 --- a/src/go/types/index.go +++ b/src/go/types/index.go @@ -35,7 +35,7 @@ func (check *Checker) indexExpr(x *operand, e *typeparams.IndexExpr) (isFuncInst return false case value: - if sig := toSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { + if sig := asSignature(x.typ); sig != nil && sig.TypeParams().Len() > 0 { // function instantiation return true } @@ -72,7 +72,7 @@ func (check *Checker) indexExpr(x *operand, e *typeparams.IndexExpr) (isFuncInst x.typ = typ.elem case *Pointer: - if typ := toArray(typ.base); typ != nil { + if typ := asArray(typ.base); typ != nil { valid = true length = typ.len x.mode = variable @@ -242,7 +242,7 @@ func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) { x.typ = &Slice{elem: u.elem} case *Pointer: - if u := toArray(u.base); u != nil { + if u := asArray(u.base); u != nil { valid = true length = u.len x.typ = &Slice{elem: u.elem} diff --git a/src/go/types/lookup.go b/src/go/types/lookup.go index 506cc69384..afb1215af2 100644 --- a/src/go/types/lookup.go +++ b/src/go/types/lookup.go @@ -302,7 +302,7 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method, return } - if ityp := toInterface(V); ityp != nil { + if ityp := asInterface(V); ityp != nil { // TODO(gri) the methods are sorted - could do this more efficiently for _, m := range T.typeSet().methods { _, f := ityp.typeSet().LookupMethod(m.pkg, m.name) @@ -400,7 +400,7 @@ func (check *Checker) assertableTo(V *Interface, T Type) (method, wrongType *Fun // no static check is required if T is an interface // spec: "If T is an interface type, x.(T) asserts that the // dynamic type of x implements the interface T." - if toInterface(T) != nil && !forceStrict { + if asInterface(T) != nil && !forceStrict { return } return check.missingMethod(T, V, false) @@ -418,8 +418,8 @@ func deref(typ Type) (Type, bool) { // derefStructPtr dereferences typ if it is a (named or unnamed) pointer to a // (named or unnamed) struct and returns its base. Otherwise it returns typ. func derefStructPtr(typ Type) Type { - if p := toPointer(typ); p != nil { - if toStruct(p.base) != nil { + if p := asPointer(typ); p != nil { + if asStruct(p.base) != nil { return p.base } } diff --git a/src/go/types/predicates.go b/src/go/types/predicates.go index d4ce97a16b..b802682e8f 100644 --- a/src/go/types/predicates.go +++ b/src/go/types/predicates.go @@ -58,7 +58,7 @@ func isNumericOrString(typ Type) bool { return is(typ, IsNumeric|IsString) } // are not fully set up. func isTyped(typ Type) bool { // isTyped is called with types that are not fully - // set up. Must not call toBasic()! + // set up. Must not call asBasic()! t, _ := typ.(*Basic) return t == nil || t.info&IsUntyped == 0 } @@ -72,13 +72,13 @@ func isOrdered(typ Type) bool { return is(typ, IsOrdered) } func isConstType(typ Type) bool { // Type parameters are never const types. - t := toBasic(typ) + t := asBasic(typ) return t != nil && t.info&IsConstType != 0 } // IsInterface reports whether typ is an interface type. func IsInterface(typ Type) bool { - return toInterface(typ) != nil + return asInterface(typ) != nil } // Comparable reports whether values of type T are comparable. diff --git a/src/go/types/sizes.go b/src/go/types/sizes.go index 0f65c5830c..4c85bfe057 100644 --- a/src/go/types/sizes.go +++ b/src/go/types/sizes.go @@ -243,7 +243,7 @@ func (conf *Config) offsetsof(T *Struct) []int64 { func (conf *Config) offsetof(typ Type, index []int) int64 { var o int64 for _, i := range index { - s := toStruct(typ) + s := asStruct(typ) o += conf.offsetsof(s)[i] typ = s.fields[i].typ } diff --git a/src/go/types/type.go b/src/go/types/type.go index 011babdcb9..4247f52c31 100644 --- a/src/go/types/type.go +++ b/src/go/types/type.go @@ -29,37 +29,37 @@ func under(t Type) Type { // Convenience converters -func toBasic(t Type) *Basic { +func asBasic(t Type) *Basic { op, _ := under(t).(*Basic) return op } -func toArray(t Type) *Array { +func asArray(t Type) *Array { op, _ := under(t).(*Array) return op } -func toSlice(t Type) *Slice { +func asSlice(t Type) *Slice { op, _ := under(t).(*Slice) return op } -func toStruct(t Type) *Struct { +func asStruct(t Type) *Struct { op, _ := under(t).(*Struct) return op } -func toPointer(t Type) *Pointer { +func asPointer(t Type) *Pointer { op, _ := under(t).(*Pointer) return op } -func toSignature(t Type) *Signature { +func asSignature(t Type) *Signature { op, _ := under(t).(*Signature) return op } -func toInterface(t Type) *Interface { +func asInterface(t Type) *Interface { op, _ := under(t).(*Interface) return op } diff --git a/src/go/types/typestring.go b/src/go/types/typestring.go index 1e36db82ea..40a8ff475d 100644 --- a/src/go/types/typestring.go +++ b/src/go/types/typestring.go @@ -366,7 +366,7 @@ func (w *typeWriter) tuple(tup *Tuple, variadic bool) { } else { // special case: // append(s, "foo"...) leads to signature func([]byte, string...) - if t := toBasic(typ); t == nil || t.kind != String { + if t := asBasic(typ); t == nil || t.kind != String { w.error("expected string type") continue } diff --git a/src/go/types/typexpr.go b/src/go/types/typexpr.go index ad6eab9c79..e1d942a5c6 100644 --- a/src/go/types/typexpr.go +++ b/src/go/types/typexpr.go @@ -145,7 +145,7 @@ func (check *Checker) varType(e ast.Expr) Type { // are in the middle of type-checking parameter declarations that might belong to // interface methods. Delay this check to the end of type-checking. check.later(func() { - if t := toInterface(typ); t != nil { + if t := asInterface(typ); t != nil { tset := computeInterfaceTypeSet(check, e.Pos(), t) // TODO(gri) is this the correct position? if !tset.IsMethodSet() { if tset.comparable { From 60fd3ed2b167e4bb823600ea6862758a222a48c2 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 2 Nov 2021 11:23:19 -0400 Subject: [PATCH 323/406] go/types: rename isNamed predicate to hasName This is a clean port of CL 358621 to go/types. Change-Id: I4e858b1b70cff69b6e0e76bb8a58a70ff54990c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/360755 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/operand.go | 9 ++++----- src/go/types/predicates.go | 7 ++++--- src/go/types/testdata/spec/assignability.go2 | 8 +++++--- src/go/types/unify.go | 8 ++++---- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/go/types/operand.go b/src/go/types/operand.go index 0ba3c4bafc..a71449083f 100644 --- a/src/go/types/operand.go +++ b/src/go/types/operand.go @@ -267,9 +267,8 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er // Vu is typed // x's type V and T have identical underlying types - // and at least one of V or T is not a named type - // and neither is a type parameter. - if Identical(Vu, Tu) && (!isNamed(V) || !isNamed(T)) && Vp == nil && Tp == nil { + // and at least one of V or T is not a named type. + if Identical(Vu, Tu) && (!hasName(V) || !hasName(T)) { return true, 0 } @@ -296,10 +295,10 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er // x is a bidirectional channel value, T is a channel // type, x's type V and T have identical element types, - // and at least one of V or T is not a named type + // and at least one of V or T is not a named type. if Vc, ok := Vu.(*Chan); ok && Vc.dir == SendRecv { if Tc, ok := Tu.(*Chan); ok && Identical(Vc.elem, Tc.elem) { - return !isNamed(V) || !isNamed(T), _InvalidChanAssign + return !hasName(V) || !hasName(T), _InvalidChanAssign } } diff --git a/src/go/types/predicates.go b/src/go/types/predicates.go index b802682e8f..2f74397d41 100644 --- a/src/go/types/predicates.go +++ b/src/go/types/predicates.go @@ -8,9 +8,10 @@ package types import "go/token" -// isNamed reports whether typ has a name. -// isNamed may be called with types that are not fully set up. -func isNamed(typ Type) bool { +// hasName reports whether typ has a name. This includes +// predeclared types, defined types, and type parameters. +// hasName may be called with types that are not fully set up. +func hasName(typ Type) bool { switch typ.(type) { case *Basic, *Named, *TypeParam: return true diff --git a/src/go/types/testdata/spec/assignability.go2 b/src/go/types/testdata/spec/assignability.go2 index 4c6774b811..8ec878bf39 100644 --- a/src/go/types/testdata/spec/assignability.go2 +++ b/src/go/types/testdata/spec/assignability.go2 @@ -33,8 +33,9 @@ func _[TP any](X TP) { X = X } -// "x's type V and T have identical underlying types and at least one -// of V or T is not a defined type and neither is a type parameter" +// "x's type V and T have identical underlying types +// and at least one of V or T is not a named type." +// (here a named type is a type with a name) func _[TP1, TP2 Interface](X1 TP1, X2 TP2) { b = B // ERROR cannot use B .* as int value a = A @@ -69,7 +70,8 @@ func _[TP Interface](X TP) { X = i // ERROR cannot use i .* as TP value } -// "x is a bidirectional channel value, T is a channel type, x's type V and T have identical element types, and at least one of V or T is not a defined type" +// "x is a bidirectional channel value, T is a channel type, x's type V and T have identical element types, and at least one of V or T is not a named type" +// (here a named type is a type with a name) type ( _SendChan = chan<- int _RecvChan = <-chan int diff --git a/src/go/types/unify.go b/src/go/types/unify.go index 99c9c9e614..d3b86008ef 100644 --- a/src/go/types/unify.go +++ b/src/go/types/unify.go @@ -235,13 +235,13 @@ func (u *unifier) nify(x, y Type, p *ifacePair) bool { // If exact unification is known to fail because we attempt to // match a type name against an unnamed type literal, consider // the underlying type of the named type. - // (Subtle: We use isNamed to include any type with a name (incl. - // basic types and type parameters. We use asNamed() because we only + // (Subtle: We use hasName to include any type with a name (incl. + // basic types and type parameters. We use asNamed because we only // want *Named types.) switch { - case !isNamed(x) && y != nil && asNamed(y) != nil: + case !hasName(x) && y != nil && asNamed(y) != nil: return u.nify(x, under(y), p) - case x != nil && asNamed(x) != nil && !isNamed(y): + case x != nil && asNamed(x) != nil && !hasName(y): return u.nify(under(x), y, p) } } From 80065cf2f6cdf56616c87036af91afa7f2fb2913 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 2 Nov 2021 11:34:11 -0400 Subject: [PATCH 324/406] go/types: implement singleType and structure (type) This is a clean port of CL 359015 to go/types. Change-Id: Iea4e3bfe0a4ae0e5a9052cb6e66c01405bd57c3d Reviewed-on: https://go-review.googlesource.com/c/go/+/360756 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/builtins.go | 26 ++++++++++---------- src/go/types/call.go | 2 +- src/go/types/expr.go | 2 +- src/go/types/index.go | 2 +- src/go/types/infer.go | 13 +++++++--- src/go/types/stmt.go | 2 +- src/go/types/termlist.go | 4 +-- src/go/types/termlist_test.go | 6 ++--- src/go/types/testdata/examples/inference.go2 | 23 +++++++++++++++++ src/go/types/typeparam.go | 6 ++--- src/go/types/typeset.go | 4 +-- 11 files changed, 59 insertions(+), 31 deletions(-) diff --git a/src/go/types/builtins.go b/src/go/types/builtins.go index ceb2adcaae..aefac786ca 100644 --- a/src/go/types/builtins.go +++ b/src/go/types/builtins.go @@ -83,7 +83,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b // of S and the respective parameter passing rules apply." S := x.typ var T Type - if s, _ := singleUnder(S).(*Slice); s != nil { + if s, _ := structure(S).(*Slice); s != nil { T = s.elem } else { check.invalidArg(x, _InvalidAppend, "%s is not a slice", x) @@ -332,14 +332,14 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b case _Copy: // copy(x, y []T) int - dst, _ := singleUnder(x.typ).(*Slice) + dst, _ := structure(x.typ).(*Slice) var y operand arg(&y, 1) if y.mode == invalid { return } - src, _ := singleUnderString(y.typ).(*Slice) + src, _ := structureString(y.typ).(*Slice) if dst == nil || src == nil { check.invalidArg(x, _InvalidCopy, "copy expects slice arguments; found %s and %s", x, &y) @@ -473,7 +473,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b } var min int // minimum number of arguments - switch singleUnder(T).(type) { + switch structure(T).(type) { case *Slice: min = 2 case *Map, *Chan: @@ -776,11 +776,11 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b return true } -// If typ is a type parameter, single under returns the single underlying -// type of all types in the corresponding type constraint if it exists, or -// nil if it doesn't exist. If typ is not a type parameter, singleUnder -// just returns the underlying type. -func singleUnder(typ Type) Type { +// If typ is a type parameter, structure returns the single underlying +// type of all types in the corresponding type constraint if it exists, +// or nil otherwise. If typ is not a type parameter, structure returns +// the underlying type. +func structure(typ Type) Type { var su Type if underIs(typ, func(u Type) bool { if su != nil && !Identical(su, u) { @@ -795,10 +795,10 @@ func singleUnder(typ Type) Type { return nil } -// singleUnderString is like singleUnder but also considers []byte and -// string as "identical". In this case, if successful, the result is always -// []byte. -func singleUnderString(typ Type) Type { +// structureString is like structure but also considers []byte and +// string as "identical". In this case, if successful, the result +// is always []byte. +func structureString(typ Type) Type { var su Type if underIs(typ, func(u Type) bool { if isString(u) { diff --git a/src/go/types/call.go b/src/go/types/call.go index 64c7658a60..a7024f5f9c 100644 --- a/src/go/types/call.go +++ b/src/go/types/call.go @@ -175,7 +175,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind { cgocall := x.mode == cgofunc // a type parameter may be "called" if all types have the same signature - sig, _ := singleUnder(x.typ).(*Signature) + sig, _ := structure(x.typ).(*Signature) if sig == nil { check.invalidOp(x, _InvalidCall, "cannot call non-function %s", x) x.mode = invalid diff --git a/src/go/types/expr.go b/src/go/types/expr.go index 103053e6b7..612f0da210 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -1227,7 +1227,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind { goto Error } - switch utyp := singleUnder(base).(type) { + switch utyp := structure(base).(type) { case *Struct: if len(e.Elts) == 0 { break diff --git a/src/go/types/index.go b/src/go/types/index.go index 24c1812039..807cf58980 100644 --- a/src/go/types/index.go +++ b/src/go/types/index.go @@ -207,7 +207,7 @@ func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) { valid := false length := int64(-1) // valid if >= 0 - switch u := singleUnder(x.typ).(type) { + switch u := structure(x.typ).(type) { case nil: check.errorf(x, _NonSliceableOperand, "cannot slice %s: type set has no single underlying type", x) x.mode = invalid diff --git a/src/go/types/infer.go b/src/go/types/infer.go index cea0780721..61f7eaf91e 100644 --- a/src/go/types/infer.go +++ b/src/go/types/infer.go @@ -358,7 +358,7 @@ func (w *tpWalker) isParameterizedTypeList(list []Type) bool { func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type, index int) { assert(len(tparams) >= len(targs) && len(targs) > 0) - // Setup bidirectional unification between those structural bounds + // Setup bidirectional unification between constraints // and the corresponding type arguments (which may be nil!). u := newUnifier(false) u.x.init(tparams) @@ -371,11 +371,16 @@ func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type, } } - // Unify type parameters with their structural constraints, if any. + // If a constraint has a structural type, unify the corresponding type parameter with it. for _, tpar := range tparams { typ := tpar - sbound := typ.structuralType() + sbound := structure(tpar) if sbound != nil { + // If the structural type is the underlying type of a single + // defined type in the constraint, use that defined type instead. + if named, _ := tpar.singleType().(*Named); named != nil { + sbound = named + } if !u.unify(typ, sbound) { check.errorf(tpar.obj, _Todo, "%s does not match %s", tpar.obj, sbound) return nil, 0 @@ -384,7 +389,7 @@ func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type, } // u.x.types() now contains the incoming type arguments plus any additional type - // arguments for which there were structural constraints. The newly inferred non- + // arguments which were inferred from structural types. The newly inferred non- // nil entries may still contain references to other type parameters. // For instance, for [A any, B interface{ []C }, C interface{ *A }], if A == int // was given, unification produced the type list [int, []C, *A]. We eliminate the diff --git a/src/go/types/stmt.go b/src/go/types/stmt.go index 7197310bd9..cc4eceae5d 100644 --- a/src/go/types/stmt.go +++ b/src/go/types/stmt.go @@ -834,7 +834,7 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.Stmt) { if x.mode != invalid { // Ranging over a type parameter is permitted if it has a single underlying type. var cause string - u := singleUnder(x.typ) + u := structure(x.typ) switch t := u.(type) { case nil: cause = "type set has no single underlying type" diff --git a/src/go/types/termlist.go b/src/go/types/termlist.go index 99114cbf4c..c4ab0e037e 100644 --- a/src/go/types/termlist.go +++ b/src/go/types/termlist.go @@ -93,8 +93,8 @@ func (xl termlist) norm() termlist { } // If the type set represented by xl is specified by a single (non-𝓤) term, -// structuralType returns that type. Otherwise it returns nil. -func (xl termlist) structuralType() Type { +// singleType returns that type. Otherwise it returns nil. +func (xl termlist) singleType() Type { if nl := xl.norm(); len(nl) == 1 { return nl[0].typ // if nl.isAll() then typ is nil, which is ok } diff --git a/src/go/types/termlist_test.go b/src/go/types/termlist_test.go index d1fe28f728..dddca7a682 100644 --- a/src/go/types/termlist_test.go +++ b/src/go/types/termlist_test.go @@ -106,7 +106,7 @@ func TestTermlistNorm(t *testing.T) { } } -func TestTermlistStructuralType(t *testing.T) { +func TestTermlistSingleType(t *testing.T) { // helper to deal with nil types tstring := func(typ Type) string { if typ == nil { @@ -128,9 +128,9 @@ func TestTermlistStructuralType(t *testing.T) { "∅ ∪ ~int ∪ string": "nil", } { xl := maketl(test) - got := tstring(xl.structuralType()) + got := tstring(xl.singleType()) if got != want { - t.Errorf("(%v).structuralType() == %v; want %v", test, got, want) + t.Errorf("(%v).singleType() == %v; want %v", test, got, want) } } } diff --git a/src/go/types/testdata/examples/inference.go2 b/src/go/types/testdata/examples/inference.go2 index 9a2dcc47f2..73246b0137 100644 --- a/src/go/types/testdata/examples/inference.go2 +++ b/src/go/types/testdata/examples/inference.go2 @@ -99,3 +99,26 @@ func _() { related2(1.0, []int{}) related2 /* ERROR does not satisfy */ (float64(1.0), []int{}) } + +type List[P any] []P + +func related3[Elem any, Slice []Elem | List[Elem]]() Slice { return nil } + +func _() { + // related3 can be instantiated explicitly + related3[int, []int]() + related3[byte, List[byte]]() + + // Alternatively, the 2nd type argument can be inferred + // from the first one through constraint type inference. + related3[int]() + + // The inferred type is the structural type of the Slice + // type parameter. + var _ []int = related3[int]() + + // It is not the defined parameterized type List. + type anotherList []float32 + var _ anotherList = related3[float32]() // valid + var _ anotherList = related3 /* ERROR cannot use .* \(value of type List\[float32\]\) as anotherList */ [float32, List[float32]]() +} diff --git a/src/go/types/typeparam.go b/src/go/types/typeparam.go index 791e9db8f8..731b746d05 100644 --- a/src/go/types/typeparam.go +++ b/src/go/types/typeparam.go @@ -118,9 +118,9 @@ func (t *TypeParam) iface() *Interface { return ityp } -// structuralType returns the structural type of the type parameter's constraint; or nil. -func (t *TypeParam) structuralType() Type { - return t.iface().typeSet().structuralType() +// singleType returns the single type of the type parameter constraint; or nil. +func (t *TypeParam) singleType() Type { + return t.iface().typeSet().singleType() } // hasTerms reports whether the type parameter constraint has specific type terms. diff --git a/src/go/types/typeset.go b/src/go/types/typeset.go index 215b48488f..f8e76ed400 100644 --- a/src/go/types/typeset.go +++ b/src/go/types/typeset.go @@ -102,8 +102,8 @@ func (s *_TypeSet) String() string { // hasTerms reports whether the type set has specific type terms. func (s *_TypeSet) hasTerms() bool { return !s.terms.isEmpty() && !s.terms.isAll() } -// structuralType returns the single type in s if there is exactly one; otherwise the result is nil. -func (s *_TypeSet) structuralType() Type { return s.terms.structuralType() } +// singleType returns the single type in s if there is exactly one; otherwise the result is nil. +func (s *_TypeSet) singleType() Type { return s.terms.singleType() } // includes reports whether t ∈ s. func (s *_TypeSet) includes(t Type) bool { return s.terms.includes(t) } From ea403bc237657e160e628e2670bbbb62016bf2b2 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 2 Nov 2021 11:42:54 -0400 Subject: [PATCH 325/406] go/types: disallow lone type parameter on RHS of type declaration This is a clean port of CL 359177 to go/types. Change-Id: I6c1574e3a1c23ea326eb8d4aacea0e78415703ab Reviewed-on: https://go-review.googlesource.com/c/go/+/360758 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/api_test.go | 14 ---- src/go/types/decl.go | 9 ++- src/go/types/testdata/check/linalg.go2 | 61 +++++++++-------- src/go/types/testdata/check/typeinst.go2 | 5 +- src/go/types/testdata/check/typeinst2.go2 | 30 +++++---- src/go/types/testdata/check/typeparams.go2 | 19 +++--- src/go/types/testdata/examples/methods.go2 | 31 +++++---- src/go/types/testdata/examples/types.go2 | 13 ++-- .../types/testdata/fixedbugs/issue39634.go2 | 7 +- .../types/testdata/fixedbugs/issue39768.go2 | 17 ++--- .../types/testdata/fixedbugs/issue39938.go2 | 2 +- .../types/testdata/fixedbugs/issue45639.go2 | 13 ++-- .../types/testdata/fixedbugs/issue47747.go2 | 67 ++++++++++--------- 13 files changed, 143 insertions(+), 145 deletions(-) diff --git a/src/go/types/api_test.go b/src/go/types/api_test.go index 7407426979..34cc61fc2c 100644 --- a/src/go/types/api_test.go +++ b/src/go/types/api_test.go @@ -604,13 +604,6 @@ func TestDefsInfo(t *testing.T) { {`package p3; type x int`, `x`, `type p3.x int`}, {`package p4; func f()`, `f`, `func p4.f()`}, {`package p5; func f() int { x, _ := 1, 2; return x }`, `_`, `var _ int`}, - - // generic types must be sanitized - // (need to use sufficiently nested types to provoke unexpanded types) - {genericPkg + `g0; type t[P any] P; const x = t[int](42)`, `x`, `const generic_g0.x generic_g0.t[int]`}, - {genericPkg + `g1; type t[P any] P; var x = t[int](42)`, `x`, `var generic_g1.x generic_g1.t[int]`}, - {genericPkg + `g2; type t[P any] P; type x struct{ f t[int] }`, `x`, `type generic_g2.x struct{f generic_g2.t[int]}`}, - {genericPkg + `g3; type t[P any] P; func f(x struct{ f t[string] }); var g = f`, `g`, `var generic_g3.g func(x struct{f generic_g3.t[string]})`}, } for _, test := range tests { @@ -649,13 +642,6 @@ func TestUsesInfo(t *testing.T) { {`package p2; func _() { _ = x }; var x int`, `x`, `var p2.x int`}, {`package p3; func _() { type _ x }; type x int`, `x`, `type p3.x int`}, {`package p4; func _() { _ = f }; func f()`, `f`, `func p4.f()`}, - - // generic types must be sanitized - // (need to use sufficiently nested types to provoke unexpanded types) - {genericPkg + `g0; func _() { _ = x }; type t[P any] P; const x = t[int](42)`, `x`, `const generic_g0.x generic_g0.t[int]`}, - {genericPkg + `g1; func _() { _ = x }; type t[P any] P; var x = t[int](42)`, `x`, `var generic_g1.x generic_g1.t[int]`}, - {genericPkg + `g2; func _() { type _ x }; type t[P any] P; type x struct{ f t[int] }`, `x`, `type generic_g2.x struct{f generic_g2.t[int]}`}, - {genericPkg + `g3; func _() { _ = f }; type t[P any] P; func f(x struct{ f t[string] })`, `f`, `func generic_g3.f(x struct{f generic_g3.t[string]})`}, } for _, test := range tests { diff --git a/src/go/types/decl.go b/src/go/types/decl.go index 6982fed0b8..8d255dcf3d 100644 --- a/src/go/types/decl.go +++ b/src/go/types/decl.go @@ -653,9 +653,12 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *Named) { named.underlying = Typ[Invalid] } - // If the RHS is a type parameter, it must be from this type declaration. - if tpar, _ := named.underlying.(*TypeParam); tpar != nil && tparamIndex(named.TypeParams().list(), tpar) < 0 { - check.errorf(tdecl.Type, _Todo, "cannot use function type parameter %s as RHS in type declaration", tpar) + // Disallow a lone type parameter as the RHS of a type declaration (issue #45639). + // We can look directly at named.underlying because even if it is still a *Named + // type (underlying not fully resolved yet) it cannot become a type parameter due + // to this very restriction. + if tpar, _ := named.underlying.(*TypeParam); tpar != nil { + check.error(tdecl.Type, _Todo, "cannot use a type parameter as RHS in type declaration") named.underlying = Typ[Invalid] } } diff --git a/src/go/types/testdata/check/linalg.go2 b/src/go/types/testdata/check/linalg.go2 index efc090a1d1..f02e773dbe 100644 --- a/src/go/types/testdata/check/linalg.go2 +++ b/src/go/types/testdata/check/linalg.go2 @@ -4,8 +4,6 @@ package linalg -import "math" - // Numeric is type bound that matches any numeric type. // It would likely be in a constraints package in the standard library. type Numeric interface { @@ -52,32 +50,33 @@ type Complex interface { ~complex64 | ~complex128 } -// OrderedAbs is a helper type that defines an Abs method for -// ordered numeric types. -type OrderedAbs[T OrderedNumeric] T - -func (a OrderedAbs[T]) Abs() OrderedAbs[T] { - if a < 0 { - return -a - } - return a -} - -// ComplexAbs is a helper type that defines an Abs method for -// complex types. -type ComplexAbs[T Complex] T - -func (a ComplexAbs[T]) Abs() ComplexAbs[T] { - r := float64(real(a)) - i := float64(imag(a)) - d := math.Sqrt(r * r + i * i) - return ComplexAbs[T](complex(d, 0)) -} - -func OrderedAbsDifference[T OrderedNumeric](a, b T) T { - return T(AbsDifference(OrderedAbs[T](a), OrderedAbs[T](b))) -} - -func ComplexAbsDifference[T Complex](a, b T) T { - return T(AbsDifference(ComplexAbs[T](a), ComplexAbs[T](b))) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// // OrderedAbs is a helper type that defines an Abs method for +// // ordered numeric types. +// type OrderedAbs[T OrderedNumeric] T +// +// func (a OrderedAbs[T]) Abs() OrderedAbs[T] { +// if a < 0 { +// return -a +// } +// return a +// } +// +// // ComplexAbs is a helper type that defines an Abs method for +// // complex types. +// type ComplexAbs[T Complex] T +// +// func (a ComplexAbs[T]) Abs() ComplexAbs[T] { +// r := float64(real(a)) +// i := float64(imag(a)) +// d := math.Sqrt(r * r + i * i) +// return ComplexAbs[T](complex(d, 0)) +// } +// +// func OrderedAbsDifference[T OrderedNumeric](a, b T) T { +// return T(AbsDifference(OrderedAbs[T](a), OrderedAbs[T](b))) +// } +// +// func ComplexAbsDifference[T Complex](a, b T) T { +// return T(AbsDifference(ComplexAbs[T](a), ComplexAbs[T](b))) +// } diff --git a/src/go/types/testdata/check/typeinst.go2 b/src/go/types/testdata/check/typeinst.go2 index f4f6c0264b..65481202e4 100644 --- a/src/go/types/testdata/check/typeinst.go2 +++ b/src/go/types/testdata/check/typeinst.go2 @@ -8,7 +8,8 @@ type myInt int // Parameterized type declarations -type T1[P any] P +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +type T1[P any] P // ERROR cannot use a type parameter as RHS in type declaration type T2[P any] struct { f P @@ -19,7 +20,7 @@ type List[P any] []P // Alias type declarations cannot have type parameters. // Issue #46477 proposses to change that. -type A1[P any] = /* ERROR cannot be alias */ P +type A1[P any] = /* ERROR cannot be alias */ struct{} // Pending clarification of #46477 we disallow aliases // of generic types. diff --git a/src/go/types/testdata/check/typeinst2.go2 b/src/go/types/testdata/check/typeinst2.go2 index ebcc300675..f07c42a1da 100644 --- a/src/go/types/testdata/check/typeinst2.go2 +++ b/src/go/types/testdata/check/typeinst2.go2 @@ -87,25 +87,27 @@ type NumericAbs[T any] interface { func AbsDifference[T NumericAbs[T]](x T) { panic(0) } -type OrderedAbs[T any] T - -func (a OrderedAbs[T]) Abs() OrderedAbs[T] - -func OrderedAbsDifference[T any](x T) { - AbsDifference(OrderedAbs[T](x)) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type OrderedAbs[T any] T +// +// func (a OrderedAbs[T]) Abs() OrderedAbs[T] +// +// func OrderedAbsDifference[T any](x T) { +// AbsDifference(OrderedAbs[T](x)) +// } // same code, reduced to essence func g[P interface{ m() P }](x P) { panic(0) } -type T4[P any] P - -func (_ T4[P]) m() T4[P] - -func _[Q any](x Q) { - g(T4[Q](x)) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type T4[P any] P +// +// func (_ T4[P]) m() T4[P] +// +// func _[Q any](x Q) { +// g(T4[Q](x)) +// } // Another test case that caused problems in the past diff --git a/src/go/types/testdata/check/typeparams.go2 b/src/go/types/testdata/check/typeparams.go2 index 3694b0ed00..446667cd66 100644 --- a/src/go/types/testdata/check/typeparams.go2 +++ b/src/go/types/testdata/check/typeparams.go2 @@ -352,15 +352,16 @@ func _() { // the previous example was extracted from -func f12[T interface{m() T}]() {} - -type A[T any] T - -func (a A[T]) m() A[T] - -func _[T any]() { - f12[A[T]]() -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// func f12[T interface{m() T}]() {} +// +// type A[T any] T +// +// func (a A[T]) m() A[T] +// +// func _[T any]() { +// f12[A[T]]() +// } // method expressions diff --git a/src/go/types/testdata/examples/methods.go2 b/src/go/types/testdata/examples/methods.go2 index 4e87041e54..1d76d553dc 100644 --- a/src/go/types/testdata/examples/methods.go2 +++ b/src/go/types/testdata/examples/methods.go2 @@ -6,8 +6,6 @@ package p -import "unsafe" - // Parameterized types may have methods. type T1[A any] struct{ a A } @@ -97,17 +95,18 @@ type T0 struct{} func (T0) _() {} func (T1[A]) _() {} -// A generic receiver type may constrain its type parameter such -// that it must be a pointer type. Such receiver types are not -// permitted. -type T3a[P interface{ ~int | ~string | ~float64 }] P - -func (T3a[_]) m() {} // this is ok - -type T3b[P interface{ ~unsafe.Pointer }] P - -func (T3b /* ERROR invalid receiver */ [_]) m() {} - -type T3c[P interface{ *int | *string }] P - -func (T3c /* ERROR invalid receiver */ [_]) m() {} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// // A generic receiver type may constrain its type parameter such +// // that it must be a pointer type. Such receiver types are not +// // permitted. +// type T3a[P interface{ ~int | ~string | ~float64 }] P +// +// func (T3a[_]) m() {} // this is ok +// +// type T3b[P interface{ ~unsafe.Pointer }] P +// +// func (T3b /* ERROR invalid receiver */ [_]) m() {} +// +// type T3c[P interface{ *int | *string }] P +// +// func (T3c /* ERROR invalid receiver */ [_]) m() {} diff --git a/src/go/types/testdata/examples/types.go2 b/src/go/types/testdata/examples/types.go2 index 367b73120c..33642fa42f 100644 --- a/src/go/types/testdata/examples/types.go2 +++ b/src/go/types/testdata/examples/types.go2 @@ -191,12 +191,13 @@ type _ struct { // _ = y < 0 //} -// It is not permitted to declare a local type whose underlying -// type is a type parameter not declared by that type declaration. -func _[T any]() { - type _ T // ERROR cannot use function type parameter T as RHS in type declaration - type _ [_ any] T // ERROR cannot use function type parameter T as RHS in type declaration -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// // It is not permitted to declare a local type whose underlying +// // type is a type parameter not declared by that type declaration. +// func _[T any]() { +// type _ T // ERROR cannot use function type parameter T as RHS in type declaration +// type _ [_ any] T // ERROR cannot use function type parameter T as RHS in type declaration +// } // As a special case, an explicit type argument may be omitted // from a type parameter bound if the type bound expects exactly diff --git a/src/go/types/testdata/fixedbugs/issue39634.go2 b/src/go/types/testdata/fixedbugs/issue39634.go2 index 5cff6e7555..2de2f4378a 100644 --- a/src/go/types/testdata/fixedbugs/issue39634.go2 +++ b/src/go/types/testdata/fixedbugs/issue39634.go2 @@ -74,9 +74,10 @@ func F20[t Z20]() { F20(t /* ERROR invalid composite literal type */ {}) } type Z21 /* ERROR illegal cycle */ interface{ Z21 } func F21[T Z21]() { ( /* ERROR not used */ F21[Z21]) } -// crash 24 -type T24[P any] P -func (r T24[P]) m() { T24 /* ERROR without instantiation */ .m() } +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// // crash 24 +// type T24[P any] P +// func (r T24[P]) m() { T24 /* ERROR without instantiation */ .m() } // crash 25 type T25[A any] int diff --git a/src/go/types/testdata/fixedbugs/issue39768.go2 b/src/go/types/testdata/fixedbugs/issue39768.go2 index fb522733e0..696d9d9bee 100644 --- a/src/go/types/testdata/fixedbugs/issue39768.go2 +++ b/src/go/types/testdata/fixedbugs/issue39768.go2 @@ -4,14 +4,15 @@ package p -type T[P any] P -type A = T // ERROR cannot use generic type -var x A[int] -var _ A - -type B = T[int] -var y B = x -var _ B /* ERROR not a generic type */ [int] +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type T[P any] P +// type A = T // ERROR cannot use generic type +// var x A[int] +// var _ A +// +// type B = T[int] +// var y B = x +// var _ B /* ERROR not a generic type */ [int] // test case from issue diff --git a/src/go/types/testdata/fixedbugs/issue39938.go2 b/src/go/types/testdata/fixedbugs/issue39938.go2 index 31bec5fb01..114646786d 100644 --- a/src/go/types/testdata/fixedbugs/issue39938.go2 +++ b/src/go/types/testdata/fixedbugs/issue39938.go2 @@ -8,7 +8,7 @@ package p -type E0[P any] P +type E0[P any] []P type E1[P any] *P type E2[P any] struct{ _ P } type E3[P any] struct{ _ *P } diff --git a/src/go/types/testdata/fixedbugs/issue45639.go2 b/src/go/types/testdata/fixedbugs/issue45639.go2 index 441fb4cb34..80148fe481 100644 --- a/src/go/types/testdata/fixedbugs/issue45639.go2 +++ b/src/go/types/testdata/fixedbugs/issue45639.go2 @@ -4,9 +4,10 @@ package P -// It is not permitted to declare a local type whose underlying -// type is a type parameters not declared by that type declaration. -func _[T any]() { - type _ T // ERROR cannot use function type parameter T as RHS in type declaration - type _ [_ any] T // ERROR cannot use function type parameter T as RHS in type declaration -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// // It is not permitted to declare a local type whose underlying +// // type is a type parameters not declared by that type declaration. +// func _[T any]() { +// type _ T // ERROR cannot use function type parameter T as RHS in type declaration +// type _ [_ any] T // ERROR cannot use function type parameter T as RHS in type declaration +// } diff --git a/src/go/types/testdata/fixedbugs/issue47747.go2 b/src/go/types/testdata/fixedbugs/issue47747.go2 index af52056bef..6a2e787bf9 100644 --- a/src/go/types/testdata/fixedbugs/issue47747.go2 +++ b/src/go/types/testdata/fixedbugs/issue47747.go2 @@ -4,15 +4,16 @@ package p -type T1[P any] P - -func (T1[_]) m() {} - -func _[P any](x *T1[P]) { - // x.m exists because x is of type *T1 where T1 is a defined type - // (even though under(T1) is a type parameter) - x.m() -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type T1[P any] P +// +// func (T1[_]) m() {} +// +// func _[P any](x *T1[P]) { +// // x.m exists because x is of type *T1 where T1 is a defined type +// // (even though under(T1) is a type parameter) +// x.m() +// } func _[P interface{ m() }](x P) { @@ -40,29 +41,31 @@ type Barer[t any] interface { Bar(t) } -type Foo1[t any] t -type Bar[t any] t - -func (l Foo1[t]) Foo(v Barer[t]) { v.Bar(t(l)) } -func (b *Bar[t]) Bar(l t) { *b = Bar[t](l) } - -func _[t any](f Fooer1[t]) t { - var b Bar[t] - f.Foo(&b) - return t(b) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type Foo1[t any] t +// type Bar[t any] t +// +// func (l Foo1[t]) Foo(v Barer[t]) { v.Bar(t(l)) } +// func (b *Bar[t]) Bar(l t) { *b = Bar[t](l) } +// +// func _[t any](f Fooer1[t]) t { +// var b Bar[t] +// f.Foo(&b) +// return t(b) +// } // Test case 2 from issue -type Fooer2[t any] interface { - Foo() -} - -type Foo2[t any] t - -func (f *Foo2[t]) Foo() {} - -func _[t any](v t) { - var f = Foo2[t](v) - _ = Fooer2[t](&f) -} +// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639). +// type Fooer2[t any] interface { +// Foo() +// } +// +// type Foo2[t any] t +// +// func (f *Foo2[t]) Foo() {} +// +// func _[t any](v t) { +// var f = Foo2[t](v) +// _ = Fooer2[t](&f) +// } From 42e6b5bce2d027d4fcc4a7358b97a468494855d8 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 2 Nov 2021 11:46:25 -0400 Subject: [PATCH 326/406] go/types: differently named types are not assignable This is a clean port of CL 360274 to go/types. Change-Id: Idfa584fab95f7226e10b1a7c5b06d56a0bf9d757 Reviewed-on: https://go-review.googlesource.com/c/go/+/360759 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/operand.go | 68 +++++++++---------- .../types/testdata/fixedbugs/issue49242.go2 | 27 ++++++++ src/go/types/testdata/spec/assignability.go2 | 46 ++++++++++--- 3 files changed, 95 insertions(+), 46 deletions(-) create mode 100644 src/go/types/testdata/fixedbugs/issue49242.go2 diff --git a/src/go/types/operand.go b/src/go/types/operand.go index a71449083f..8b76e939b6 100644 --- a/src/go/types/operand.go +++ b/src/go/types/operand.go @@ -302,19 +302,11 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er } } - // common case: if we don't have type parameters, we're done + // optimization: if we don't have type parameters, we're done if Vp == nil && Tp == nil { return false, _IncompatibleAssign } - // determine type parameter operands with specific type terms - if Vp != nil && !Vp.hasTerms() { - Vp = nil - } - if Tp != nil && !Tp.hasTerms() { - Tp = nil - } - errorf := func(format string, args ...interface{}) { if check != nil && reason != nil { msg := check.sprintf(format, args...) @@ -325,25 +317,36 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er } } - ok := false - code := _IncompatibleAssign - switch { - case Vp != nil && Tp != nil: - x := *x // don't clobber outer x - ok = Vp.is(func(V *term) bool { - x.typ = V.typ - return Tp.is(func(T *term) bool { - ok, code = x.assignableTo(check, T.typ, reason) - if !ok { - errorf("cannot assign %s (in %s) to %s (in %s)", V.typ, Vp, T.typ, Tp) - return false - } - return true - }) + // x's type V is not a named type and T is a type parameter, and + // x is assignable to each specific type in T's type set. + if !hasName(V) && Tp != nil { + ok := false + code := _IncompatibleAssign + Tp.is(func(T *term) bool { + if T == nil { + return false // no specific types + } + ok, code = x.assignableTo(check, T.typ, reason) + if !ok { + errorf("cannot assign %s to %s (in %s)", x.typ, T.typ, Tp) + return false + } + return true }) - case Vp != nil: + return ok, code + } + + // x's type V is a type parameter and T is not a named type, + // and values x' of each specific type in V's type set are + // assignable to T. + if Vp != nil && !hasName(T) { x := *x // don't clobber outer x - ok = Vp.is(func(V *term) bool { + ok := false + code := _IncompatibleAssign + Vp.is(func(V *term) bool { + if V == nil { + return false // no specific types + } x.typ = V.typ ok, code = x.assignableTo(check, T, reason) if !ok { @@ -352,17 +355,8 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er } return true }) - case Tp != nil: - x := *x // don't clobber outer x - ok = Tp.is(func(T *term) bool { - ok, code = x.assignableTo(check, T.typ, reason) - if !ok { - errorf("cannot assign %s to %s (in %s)", x.typ, T.typ, Tp) - return false - } - return true - }) + return ok, code } - return ok, code + return false, _IncompatibleAssign } diff --git a/src/go/types/testdata/fixedbugs/issue49242.go2 b/src/go/types/testdata/fixedbugs/issue49242.go2 new file mode 100644 index 0000000000..524a0cbae3 --- /dev/null +++ b/src/go/types/testdata/fixedbugs/issue49242.go2 @@ -0,0 +1,27 @@ +// Copyright 2021 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 p + +func _[P int](x P) int { + return x // ERROR cannot use x .* as int value in return statement +} + +func _[P int]() int { + return P /* ERROR cannot use P\(1\) .* as int value in return statement */ (1) +} + +func _[P int](x int) P { + return x // ERROR cannot use x .* as P value in return statement +} + +func _[P, Q any](x P) Q { + return x // ERROR cannot use x .* as Q value in return statement +} + +// test case from issue +func F[G interface{ uint }]() int { + f := func(uint) int { return 0 } + return f(G /* ERROR cannot use G\(1\) .* as uint value in argument to f */ (1)) +} diff --git a/src/go/types/testdata/spec/assignability.go2 b/src/go/types/testdata/spec/assignability.go2 index 8ec878bf39..a6e71aac81 100644 --- a/src/go/types/testdata/spec/assignability.go2 +++ b/src/go/types/testdata/spec/assignability.go2 @@ -109,20 +109,48 @@ func _[ ) var ( - _ _CC = C - _ _SC = C - _ _RC = C + _ _CC = C // ERROR cannot use C .* as _CC value + _ _SC = C // ERROR cannot use C .* as _SC value + _ _RC = C // ERROR cannot use C .* as _RC value - _ CC = _CC(nil) - _ SC = _CC(nil) - _ RC = _CC(nil) + _ CC = _CC /* ERROR cannot use _CC\(nil\) .* as CC value */ (nil) + _ SC = _CC /* ERROR cannot use _CC\(nil\) .* as SC value */ (nil) + _ RC = _CC /* ERROR cannot use _CC\(nil\) .* as RC value */ (nil) - _ CC = C - _ SC = C // ERROR cannot use C .* as SC value .* cannot assign Chan to SendChan - _ RC = C // ERROR cannot use C .* as RC value .* cannot assign Chan to RecvChan + _ CC = C // ERROR cannot use C .* as CC value + _ SC = C // ERROR cannot use C .* as SC value + _ RC = C // ERROR cannot use C .* as RC value ) } +// "x's type V is not a named type and T is a type parameter, and x is assignable to each specific type in T's type set." +func _[ + TP0 any, + TP1 ~_Chan, + TP2 ~chan int | ~chan byte, +]() { + var ( + _ TP0 = c // ERROR cannot use c .* as TP0 value + _ TP0 = C // ERROR cannot use C .* as TP0 value + _ TP1 = c + _ TP1 = C // ERROR cannot use C .* as TP1 value + _ TP2 = c // ERROR .* cannot assign chan int to chan byte + ) +} + +// "x's type V is a type parameter and T is not a named type, and values x' of each specific type in V's type set are assignable to T." +func _[ + TP0 Interface, + TP1 ~_Chan, + TP2 ~chan int | ~chan byte, +](X0 TP0, X1 TP1, X2 TP2) { + i = X0 + I = X0 + c = X1 + C = X1 // ERROR cannot use X1 .* as Chan value + c = X2 // ERROR .* cannot assign chan byte \(in TP2\) to chan int +} + // "x is the predeclared identifier nil and T is a pointer, function, slice, map, channel, or interface type" // TODO(rfindley) error messages about untyped nil diverge from types2 here. // Consider aligning them. From 2157498dfee125e43cc37cad622fb7d2115dd3a8 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 2 Nov 2021 07:59:16 -0700 Subject: [PATCH 327/406] doc/go1.18: remove some redundancy from netip docs Change-Id: I593862331add3366f6b337844588568301746b80 Reviewed-on: https://go-review.googlesource.com/c/go/+/360608 Reviewed-by: Josh Bleecher Snyder Trust: Josh Bleecher Snyder Trust: Brad Fitzpatrick --- doc/go1.18.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/go1.18.html b/doc/go1.18.html index 82fe6f4520..171cc3cb22 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -131,8 +131,8 @@ Do not send CLs removing the interior tags from such phrases.

New net/netip package

The new net/netip - package defines a new IP address type, Addr - that's a small, comparable, value type. Compared to the existing + package defines a new IP address type, Addr. + Compared to the existing net.IP type, the netip.Addr type takes less memory, is immutable, and is comparable so it supports == and can be used as a map key. From eb63cbd2950e703ff2a6bd04330e97dc76c7923d Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Tue, 2 Nov 2021 12:30:37 -0700 Subject: [PATCH 328/406] cmd/compile: remove TODO that is no longer relevant types2 methods are now sorted in the same way as types1, so this TODO is no longer needed. (Comment change only). Change-Id: Ic975ce001a5d54f15381a9cb7b6969dff795e3b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/360856 Trust: Dan Scales Run-TryBot: Dan Scales TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/noder/expr.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/cmd/compile/internal/noder/expr.go b/src/cmd/compile/internal/noder/expr.go index d19513a1ac..24e6dbefe7 100644 --- a/src/cmd/compile/internal/noder/expr.go +++ b/src/cmd/compile/internal/noder/expr.go @@ -235,12 +235,6 @@ func (g *irgen) selectorExpr(pos src.XPos, typ types2.Type, expr *syntax.Selecto return DotField(pos, x, last) } - // TODO(danscales,mdempsky): Interface method sets are not sorted the - // same between types and types2. In particular, using "last" here - // without conversion will likely fail if an interface contains - // unexported methods from two different packages (due to cross-package - // interface embedding). - var n ir.Node method2 := selinfo.Obj().(*types2.Func) From a0f373ca08b05eb97e4bff7e8710c023d94231c3 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 2 Nov 2021 13:56:22 -0700 Subject: [PATCH 329/406] runtime/asan: declare asan reporting functions in C Fixes #49287 Change-Id: I3f970d6db0b1dee886df2f7bb6cbeb56a37c42c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/360860 Trust: Ian Lance Taylor Reviewed-by: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot --- src/runtime/asan/asan.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/runtime/asan/asan.go b/src/runtime/asan/asan.go index ac71466b71..eb66b3aab5 100644 --- a/src/runtime/asan/asan.go +++ b/src/runtime/asan/asan.go @@ -10,9 +10,21 @@ package asan #cgo CFLAGS: -fsanitize=address #cgo LDFLAGS: -fsanitize=address +#include #include #include +extern void __asan_report_load1(void*); +extern void __asan_report_load2(void*); +extern void __asan_report_load4(void*); +extern void __asan_report_load8(void*); +extern void __asan_report_load_n(void*, uintptr_t); +extern void __asan_report_store1(void*); +extern void __asan_report_store2(void*); +extern void __asan_report_store4(void*); +extern void __asan_report_store8(void*); +extern void __asan_report_store_n(void*, uintptr_t); + void __asan_read_go(void *addr, uintptr_t sz) { if (__asan_region_is_poisoned(addr, sz)) { switch (sz) { From 32d27527a6dfb45a98d47a4a9ac5341028d79aa1 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 2 Nov 2021 18:25:21 -0400 Subject: [PATCH 330/406] go/types: fix conversions of constants to type parameter This is a port of both CL 360396 and CL 360796 to go/types. The latter is added to avoid introducing an intermediate bug. An error message was adjusted in issue49296.go2, with a TODO to switch to the types2 error. Change-Id: Iede294b69b4e097e53876498f039ee18667568c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/360934 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/conversions.go | 41 ++++++++++++++----- src/go/types/expr.go | 1 + src/go/types/predicates.go | 6 +++ .../types/testdata/fixedbugs/issue49247.go2 | 20 +++++++++ .../types/testdata/fixedbugs/issue49296.go2 | 21 ++++++++++ src/go/types/testdata/spec/conversions.go2 | 21 ++++++++++ 6 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 src/go/types/testdata/fixedbugs/issue49247.go2 create mode 100644 src/go/types/testdata/fixedbugs/issue49296.go2 diff --git a/src/go/types/conversions.go b/src/go/types/conversions.go index f8af12b68f..9baad98e09 100644 --- a/src/go/types/conversions.go +++ b/src/go/types/conversions.go @@ -16,26 +16,47 @@ import ( func (check *Checker) conversion(x *operand, T Type) { constArg := x.mode == constant_ - var ok bool - var cause string - switch { - case constArg && isConstType(T): - // constant conversion (T cannot be a type parameter) + constConvertibleTo := func(T Type, val *constant.Value) bool { switch t := asBasic(T); { - case representableConst(x.val, check, t, &x.val): - ok = true + case t == nil: + // nothing to do + case representableConst(x.val, check, t, val): + return true case isInteger(x.typ) && isString(t): codepoint := unicode.ReplacementChar if i, ok := constant.Uint64Val(x.val); ok && i <= unicode.MaxRune { codepoint = rune(i) } - x.val = constant.MakeString(string(codepoint)) - ok = true + if val != nil { + *val = constant.MakeString(string(codepoint)) + } + return true } + return false + } + + var ok bool + var cause string + switch { + case constArg && isConstType(T): + // constant conversion + ok = constConvertibleTo(T, &x.val) + case constArg && isTypeParam(T): + // x is convertible to T if it is convertible + // to each specific type in the type set of T. + // If T's type set is empty, or if it doesn't + // have specific types, constant x cannot be + // converted. + ok = under(T).(*TypeParam).underIs(func(u Type) bool { + // t is nil if there are no specific type terms + // TODO(gri) add a cause in case of failure + return u != nil && constConvertibleTo(u, nil) + }) + x.mode = value // type parameters are not constants case x.convertibleTo(check, T, &cause): // non-constant conversion - x.mode = value ok = true + x.mode = value } if !ok { diff --git a/src/go/types/expr.go b/src/go/types/expr.go index 612f0da210..d4de212e06 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -681,6 +681,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const return nil, nil, _InvalidUntypedConversion } case *TypeParam: + // TODO(gri) review this code - doesn't look quite right ok := t.underIs(func(t Type) bool { target, _, _ := check.implicitTypeAndValue(x, t) return target != nil diff --git a/src/go/types/predicates.go b/src/go/types/predicates.go index 2f74397d41..3c76d15c79 100644 --- a/src/go/types/predicates.go +++ b/src/go/types/predicates.go @@ -82,6 +82,12 @@ func IsInterface(typ Type) bool { return asInterface(typ) != nil } +// isTypeParam reports whether typ is a type parameter. +func isTypeParam(typ Type) bool { + _, ok := under(typ).(*TypeParam) + return ok +} + // Comparable reports whether values of type T are comparable. func Comparable(T Type) bool { return comparable(T, nil) diff --git a/src/go/types/testdata/fixedbugs/issue49247.go2 b/src/go/types/testdata/fixedbugs/issue49247.go2 new file mode 100644 index 0000000000..3f25e0ee35 --- /dev/null +++ b/src/go/types/testdata/fixedbugs/issue49247.go2 @@ -0,0 +1,20 @@ +// Copyright 2021 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 p + +type integer interface { + ~int | ~int8 | ~int16 | ~int32 | ~int64 | + ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr +} + +func Add1024[T integer](s []T) { + for i, v := range s { + s[i] = v + 1024 // ERROR cannot convert 1024 \(untyped int constant\) to T + } +} + +func f[T interface{ int8 }]() { + println(T(1024 /* ERROR cannot convert 1024 \(untyped int value\) to T */)) +} diff --git a/src/go/types/testdata/fixedbugs/issue49296.go2 b/src/go/types/testdata/fixedbugs/issue49296.go2 new file mode 100644 index 0000000000..8c6d0b678d --- /dev/null +++ b/src/go/types/testdata/fixedbugs/issue49296.go2 @@ -0,0 +1,21 @@ +// Copyright 2021 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 p + +func _[ + T0 any, + T1 []int, + T2 ~float64 | ~complex128 | chan int, +]() { + // TODO(rfindley): the types2 error here is clearer. + _ = T0(nil /* ERROR cannot convert nil \(untyped nil value\) to T0 */ ) + _ = T1(1 /* ERROR cannot convert 1 .* to T1 */ ) + _ = T2(2 /* ERROR cannot convert 2 .* to T2 */ ) +} + +// test case from issue +func f[T interface{[]int}]() { + _ = T(1 /* ERROR cannot convert */ ) +} diff --git a/src/go/types/testdata/spec/conversions.go2 b/src/go/types/testdata/spec/conversions.go2 index eb988ffed1..47b1f07d87 100644 --- a/src/go/types/testdata/spec/conversions.go2 +++ b/src/go/types/testdata/spec/conversions.go2 @@ -6,6 +6,27 @@ package conversions import "unsafe" +// constant conversions + +func _[T ~byte]() T { return 255 } +func _[T ~byte]() T { return 256 /* ERROR cannot use 256 .* as T value */ } + +func _[T ~byte]() { + const _ = T /* ERROR T\(0\) .* is not constant */ (0) + var _ T = 255 + var _ T = 256 // ERROR cannot use 256 .* as T value +} + +func _[T ~string]() T { return T('a') } +func _[T ~int | ~string]() T { return T('a') } +func _[T ~byte | ~int | ~string]() T { return T(256 /* ERROR cannot convert 256 .* to T */ ) } + +// implicit conversions never convert to string +func _[T ~string]() { + var _ string = 0 // ERROR cannot use .* as string value + var _ T = 0 // ERROR cannot use .* as T value +} + // "x is assignable to T" // - tested via assignability tests From d6f7203a3c63276680457b9794191a366a1a4401 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 2 Nov 2021 18:29:27 -0400 Subject: [PATCH 331/406] go/types: adjust printing of type parameter in error This is a clean port of CL 360514 to go/types. Change-Id: Ia13638b3758b3b8017867934d09136ac5f9a62ca Reviewed-on: https://go-review.googlesource.com/c/go/+/360935 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/infer.go | 7 ++++--- src/go/types/testdata/fixedbugs/issue45985.go2 | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/go/types/infer.go b/src/go/types/infer.go index 61f7eaf91e..41326a1be8 100644 --- a/src/go/types/infer.go +++ b/src/go/types/infer.go @@ -373,7 +373,6 @@ func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type, // If a constraint has a structural type, unify the corresponding type parameter with it. for _, tpar := range tparams { - typ := tpar sbound := structure(tpar) if sbound != nil { // If the structural type is the underlying type of a single @@ -381,8 +380,10 @@ func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type, if named, _ := tpar.singleType().(*Named); named != nil { sbound = named } - if !u.unify(typ, sbound) { - check.errorf(tpar.obj, _Todo, "%s does not match %s", tpar.obj, sbound) + if !u.unify(tpar, sbound) { + // TODO(gri) improve error message by providing the type arguments + // which we know already + check.errorf(tpar.obj, _Todo, "%s does not match %s", tpar, sbound) return nil, 0 } } diff --git a/src/go/types/testdata/fixedbugs/issue45985.go2 b/src/go/types/testdata/fixedbugs/issue45985.go2 index 07395911cd..637e2cad5e 100644 --- a/src/go/types/testdata/fixedbugs/issue45985.go2 +++ b/src/go/types/testdata/fixedbugs/issue45985.go2 @@ -5,7 +5,7 @@ package issue45985 // TODO(rFindley): this error should be on app[int] below. -func app[S /* ERROR "type S S does not match" */ interface{ ~[]T }, T any](s S, e T) S { +func app[S /* ERROR "S does not match" */ interface{ ~[]T }, T any](s S, e T) S { return append(s, e) } From 2b81b863a258decaaca26ab4c01bfd070cc01ebe Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 2 Nov 2021 18:36:36 -0400 Subject: [PATCH 332/406] go/types: fix indexing of generic types This is a clean port of CL 360603 to go/types. Change-Id: Iadb312f07e509ff83339d5525765b7b7987bf233 Reviewed-on: https://go-review.googlesource.com/c/go/+/360936 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/index.go | 89 +++++++++++----------- src/go/types/testdata/check/typeparams.go2 | 8 ++ 2 files changed, 54 insertions(+), 43 deletions(-) diff --git a/src/go/types/index.go b/src/go/types/index.go index 807cf58980..a85d314efa 100644 --- a/src/go/types/index.go +++ b/src/go/types/index.go @@ -101,77 +101,80 @@ func (check *Checker) indexExpr(x *operand, e *typeparams.IndexExpr) (isFuncInst case *TypeParam: // TODO(gri) report detailed failure cause for better error messages - var tkey, telem Type // tkey != nil if we have maps + var key, elem Type // key != nil: we must have all maps + mode := variable // non-maps result mode + // TODO(gri) factor out closure and use it for non-typeparam cases as well if typ.underIs(func(u Type) bool { - var key, elem Type - alen := int64(-1) // valid if >= 0 + l := int64(-1) // valid if >= 0 + var k, e Type // k is only set for maps switch t := u.(type) { case *Basic: - if !isString(t) { - return false + if isString(t) { + e = universeByte + mode = value } - elem = universeByte case *Array: - elem = t.elem - alen = t.len - case *Pointer: - a, _ := under(t.base).(*Array) - if a == nil { - return false + l = t.len + e = t.elem + if x.mode != variable { + mode = value + } + case *Pointer: + if t := asArray(t.base); t != nil { + l = t.len + e = t.elem } - elem = a.elem - alen = a.len case *Slice: - elem = t.elem + e = t.elem case *Map: - key = t.key - elem = t.elem - default: + k = t.key + e = t.elem + } + if e == nil { return false } - assert(elem != nil) - if telem == nil { + if elem == nil { // first type - tkey, telem = key, elem - length = alen - } else { - // all map keys must be identical (incl. all nil) - if !Identical(key, tkey) { - return false - } - // all element types must be identical - if !Identical(elem, telem) { - return false - } - tkey, telem = key, elem - // track the minimal length for arrays - if alen >= 0 && alen < length { - length = alen - } + length = l + key, elem = k, e + return true + } + // all map keys must be identical (incl. all nil) + // (that is, we cannot mix maps with other types) + if !Identical(key, k) { + return false + } + // all element types must be identical + if !Identical(elem, e) { + return false + } + // track the minimal length for arrays, if any + if l >= 0 && l < length { + length = l } return true }) { // For maps, the index expression must be assignable to the map key type. - if tkey != nil { + if key != nil { index := check.singleIndex(e) if index == nil { x.mode = invalid return false } - var key operand - check.expr(&key, index) - check.assignment(&key, tkey, "map index") + var k operand + check.expr(&k, index) + check.assignment(&k, key, "map index") // ok to continue even if indexing failed - map element type is known x.mode = mapindex - x.typ = telem + x.typ = elem x.expr = e return false } // no maps valid = true - x.mode = variable - x.typ = telem + x.mode = mode + x.typ = elem } } diff --git a/src/go/types/testdata/check/typeparams.go2 b/src/go/types/testdata/check/typeparams.go2 index 446667cd66..09d478c4d7 100644 --- a/src/go/types/testdata/check/typeparams.go2 +++ b/src/go/types/testdata/check/typeparams.go2 @@ -114,6 +114,14 @@ func _[T interface{ [10]int }](x T, i int) { _ = x[i]; _ = x[9]; _ = x[10 /* ERR func _[T interface{ [10]byte | string }](x T, i int) { _ = x[i]; _ = x[9]; _ = x[10 /* ERROR out of bounds */ ] } func _[T interface{ [10]int | *[20]int | []int }](x T, i int) { _ = x[i]; _ = x[9]; _ = x[10 /* ERROR out of bounds */ ] } +// indexing with strings and non-variable arrays (assignment not permitted) +func _[T string](x T) { _ = x[0]; x /* ERROR cannot assign */ [0] = 0 } +func _[T []byte | string](x T) { x /* ERROR cannot assign */ [0] = 0 } +func _[T [10]byte]() { f := func() (x T) { return }; f /* ERROR cannot assign */ ()[0] = 0 } +func _[T [10]byte]() { f := func() (x *T) { return }; f /* ERROR cannot index */ ()[0] = 0 } +func _[T [10]byte]() { f := func() (x *T) { return }; (*f())[0] = 0 } +func _[T *[10]byte]() { f := func() (x T) { return }; f()[0] = 0 } + // slicing func _[T interface{ ~[10]E }, E any] (x T, i, j, k int) { var _ []E = x[i:j] } From 49a00631b118834010e4d0124ccc04eeaf2cd7ac Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 2 Nov 2021 18:42:51 -0400 Subject: [PATCH 333/406] go/types: report cause for failing const conversions This is a port of CL 360795 to go/types. Error messages were adjusted accordingly, with a TODO to fix the discrepancy. Change-Id: Ifd7d8248fa11a31fde391021f3c5f1840877892f Reviewed-on: https://go-review.googlesource.com/c/go/+/360937 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/conversions.go | 11 +++++++++-- src/go/types/testdata/spec/conversions.go2 | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/go/types/conversions.go b/src/go/types/conversions.go index 9baad98e09..a6f0714ba0 100644 --- a/src/go/types/conversions.go +++ b/src/go/types/conversions.go @@ -49,8 +49,15 @@ func (check *Checker) conversion(x *operand, T Type) { // converted. ok = under(T).(*TypeParam).underIs(func(u Type) bool { // t is nil if there are no specific type terms - // TODO(gri) add a cause in case of failure - return u != nil && constConvertibleTo(u, nil) + if u == nil { + cause = check.sprintf("%s does not contain specific types", T) + return false + } + if !constConvertibleTo(u, nil) { + cause = check.sprintf("cannot convert %s to %s (in %s)", x, u, T) + return false + } + return true }) x.mode = value // type parameters are not constants case x.convertibleTo(check, T, &cause): diff --git a/src/go/types/testdata/spec/conversions.go2 b/src/go/types/testdata/spec/conversions.go2 index 47b1f07d87..e54403cea9 100644 --- a/src/go/types/testdata/spec/conversions.go2 +++ b/src/go/types/testdata/spec/conversions.go2 @@ -27,6 +27,20 @@ func _[T ~string]() { var _ T = 0 // ERROR cannot use .* as T value } +// failing const conversions of constants to type parameters report a cause +func _[ + T1 any, + T2 interface{ m() }, + T3 ~int | ~float64 | ~bool, + T4 ~int | ~string, +]() { + // TODO(rfindley): align the error formatting here with types2. + _ = T1(0 /* ERROR cannot convert 0 .* to T1.*T1 does not contain specific types */ ) + _ = T2(1 /* ERROR cannot convert 1 .* to T2.*T2 does not contain specific types */ ) + _ = T3(2 /* ERROR cannot convert 2 .* to T3.*cannot convert 2 .* to bool \(in T3\) */ ) + _ = T4(3.14 /* ERROR cannot convert 3.14 .* to T4.*cannot convert 3.14 .* to int \(in T4\) */ ) +} + // "x is assignable to T" // - tested via assignability tests From 8f0ca7dc720b7197c91e02c8cef6e19ad95978d0 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 2 Nov 2021 09:58:12 -0700 Subject: [PATCH 334/406] cmd/compile/internal/types2: report cause for failing const conversions Follow-up on CL 360396. Change-Id: Icd802baffb1fef91f8fef0070b6167a438ceda1a Reviewed-on: https://go-review.googlesource.com/c/go/+/360795 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/conversions.go | 11 +++++++++-- .../internal/types2/testdata/spec/conversions.go2 | 13 +++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index 4d0ed79c38..5798bacca7 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -49,8 +49,15 @@ func (check *Checker) conversion(x *operand, T Type) { // converted. ok = under(T).(*TypeParam).underIs(func(u Type) bool { // t is nil if there are no specific type terms - // TODO(gri) add a cause in case of failure - return u != nil && constConvertibleTo(u, nil) + if u == nil { + cause = check.sprintf("%s does not contain specific types", T) + return false + } + if !constConvertibleTo(u, nil) { + cause = check.sprintf("cannot convert %s to %s (in %s)", x, u, T) + return false + } + return true }) x.mode = value // type parameters are not constants case x.convertibleTo(check, T, &cause): diff --git a/src/cmd/compile/internal/types2/testdata/spec/conversions.go2 b/src/cmd/compile/internal/types2/testdata/spec/conversions.go2 index 942d9c0f6f..fde332f34b 100644 --- a/src/cmd/compile/internal/types2/testdata/spec/conversions.go2 +++ b/src/cmd/compile/internal/types2/testdata/spec/conversions.go2 @@ -27,6 +27,19 @@ func _[T ~string]() { var _ T = 0 // ERROR cannot use .* as T value } +// failing const conversions of constants to type parameters report a cause +func _[ + T1 any, + T2 interface{ m() }, + T3 ~int | ~float64 | ~bool, + T4 ~int | ~string, +]() { + _ = T1(0 /* ERROR cannot convert 0 .* to T1\n\tT1 does not contain specific types */ ) + _ = T2(1 /* ERROR cannot convert 1 .* to T2\n\tT2 does not contain specific types */ ) + _ = T3(2 /* ERROR cannot convert 2 .* to T3\n\tcannot convert 2 .* to bool \(in T3\) */ ) + _ = T4(3.14 /* ERROR cannot convert 3.14 .* to T4\n\tcannot convert 3.14 .* to int \(in T4\) */ ) +} + // "x is assignable to T" // - tested via assignability tests From a4b2c579e92c001287fd7b549bc9f67bcf2bfe7b Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 2 Nov 2021 14:12:05 -0700 Subject: [PATCH 335/406] runtime: install sigPreempt signal handler for c-archive/c-shared Fixes #49288 Change-Id: I7bfcbecbefa68871a3e556935a73f241fff44c0e Reviewed-on: https://go-review.googlesource.com/c/go/+/360861 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- misc/cgo/testcarchive/carchive_test.go | 52 ++++++++++++++++++++++ misc/cgo/testcarchive/testdata/libgo8/a.go | 36 +++++++++++++++ misc/cgo/testcarchive/testdata/main8.c | 16 +++++++ src/runtime/signal_unix.go | 4 +- 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 misc/cgo/testcarchive/testdata/libgo8/a.go create mode 100644 misc/cgo/testcarchive/testdata/main8.c diff --git a/misc/cgo/testcarchive/carchive_test.go b/misc/cgo/testcarchive/carchive_test.go index 55be3c5f70..a2b43bb72d 100644 --- a/misc/cgo/testcarchive/carchive_test.go +++ b/misc/cgo/testcarchive/carchive_test.go @@ -931,3 +931,55 @@ func TestManyCalls(t *testing.T) { t.Error(err) } } + +// Issue 49288. +func TestPreemption(t *testing.T) { + if runtime.Compiler == "gccgo" { + t.Skip("skipping asynchronous preemption test with gccgo") + } + + t.Parallel() + + if !testWork { + defer func() { + os.Remove("testp8" + exeSuffix) + os.Remove("libgo8.a") + os.Remove("libgo8.h") + }() + } + + cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo8.a", "./libgo8") + if out, err := cmd.CombinedOutput(); err != nil { + t.Logf("%s", out) + t.Fatal(err) + } + checkLineComments(t, "libgo8.h") + + ccArgs := append(cc, "-o", "testp8"+exeSuffix, "main8.c", "libgo8.a") + if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil { + t.Logf("%s", out) + t.Fatal(err) + } + + argv := cmdToRun("./testp8") + cmd = exec.Command(argv[0], argv[1:]...) + var sb strings.Builder + cmd.Stdout = &sb + cmd.Stderr = &sb + if err := cmd.Start(); err != nil { + t.Fatal(err) + } + + timer := time.AfterFunc(time.Minute, + func() { + t.Error("test program timed out") + cmd.Process.Kill() + }, + ) + defer timer.Stop() + + if err := cmd.Wait(); err != nil { + t.Log(sb.String()) + t.Error(err) + } +} diff --git a/misc/cgo/testcarchive/testdata/libgo8/a.go b/misc/cgo/testcarchive/testdata/libgo8/a.go new file mode 100644 index 0000000000..718418ecb8 --- /dev/null +++ b/misc/cgo/testcarchive/testdata/libgo8/a.go @@ -0,0 +1,36 @@ +// Copyright 2021 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 main + +import "C" + +import ( + "os" + "runtime" + "sync/atomic" +) + +var started int32 + +// Start a goroutine that loops forever. +func init() { + runtime.GOMAXPROCS(1) + go func() { + for { + atomic.StoreInt32(&started, 1) + } + }() +} + +//export GoFunction8 +func GoFunction8() { + for atomic.LoadInt32(&started) == 0 { + runtime.Gosched() + } + os.Exit(0) +} + +func main() { +} diff --git a/misc/cgo/testcarchive/testdata/main8.c b/misc/cgo/testcarchive/testdata/main8.c new file mode 100644 index 0000000000..95fb7a349e --- /dev/null +++ b/misc/cgo/testcarchive/testdata/main8.c @@ -0,0 +1,16 @@ +// Copyright 2021 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. + +// Test preemption. + +#include + +#include "libgo8.h" + +int main() { + GoFunction8(); + + // That should have exited the program. + abort(); +} diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go index 7c454437e4..dbcbfc67bc 100644 --- a/src/runtime/signal_unix.go +++ b/src/runtime/signal_unix.go @@ -167,8 +167,8 @@ func sigInstallGoHandler(sig uint32) bool { } // When built using c-archive or c-shared, only install signal - // handlers for synchronous signals and SIGPIPE. - if (isarchive || islibrary) && t.flags&_SigPanic == 0 && sig != _SIGPIPE { + // handlers for synchronous signals and SIGPIPE and sigPreempt. + if (isarchive || islibrary) && t.flags&_SigPanic == 0 && sig != _SIGPIPE && sig != sigPreempt { return false } From 519c0a2323700934cbec97b75df92917108548be Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Tue, 2 Nov 2021 12:50:05 -0700 Subject: [PATCH 336/406] cmd/compile/internal/types2: port nomono check from go/types Same logic as CL 357449 (including CL 360815), just ported to types2. Updates #48098. Change-Id: I4578f7329bb4ffc42410025bb6cb97e24697ebfd Reviewed-on: https://go-review.googlesource.com/c/go/+/360857 Trust: Matthew Dempsky Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/types2/call.go | 2 + src/cmd/compile/internal/types2/check.go | 6 + src/cmd/compile/internal/types2/mono.go | 337 ++++++++++++++++++ src/cmd/compile/internal/types2/mono_test.go | 89 +++++ src/cmd/compile/internal/types2/signature.go | 1 + .../types2/testdata/fixedbugs/issue48974.go2 | 2 +- src/cmd/compile/internal/types2/typexpr.go | 2 + 7 files changed, 438 insertions(+), 1 deletion(-) create mode 100644 src/cmd/compile/internal/types2/mono.go create mode 100644 src/cmd/compile/internal/types2/mono_test.go diff --git a/src/cmd/compile/internal/types2/call.go b/src/cmd/compile/internal/types2/call.go index 220ba940b3..49cae5a930 100644 --- a/src/cmd/compile/internal/types2/call.go +++ b/src/cmd/compile/internal/types2/call.go @@ -88,6 +88,8 @@ func (check *Checker) instantiateSignature(pos syntax.Pos, typ *Signature, targs pos = posList[i] } check.softErrorf(pos, err.Error()) + } else { + check.mono.recordInstance(check.pkg, pos, tparams, targs, posList) } return inst diff --git a/src/cmd/compile/internal/types2/check.go b/src/cmd/compile/internal/types2/check.go index 6e8883e5de..ffc59f7011 100644 --- a/src/cmd/compile/internal/types2/check.go +++ b/src/cmd/compile/internal/types2/check.go @@ -126,6 +126,7 @@ type Checker struct { imports []*PkgName // list of imported packages dotImportMap map[dotImportKey]*PkgName // maps dot-imported objects to the package they were dot-imported through recvTParamMap map[*syntax.Name]*TypeParam // maps blank receiver type parameters to their type + mono monoGraph // graph for detecting non-monomorphizable instantiation loops firstErr error // first error encountered methods map[*TypeName][]*Func // maps package scope type names to associated non-blank (non-interface) methods @@ -317,6 +318,11 @@ func (check *Checker) checkFiles(files []*syntax.File) (err error) { print("== recordUntyped ==") check.recordUntyped() + if check.firstErr == nil { + // TODO(mdempsky): Ensure monomorph is safe when errors exist. + check.monomorph() + } + check.pkg.complete = true // no longer needed - release memory diff --git a/src/cmd/compile/internal/types2/mono.go b/src/cmd/compile/internal/types2/mono.go new file mode 100644 index 0000000000..39c4d4fbef --- /dev/null +++ b/src/cmd/compile/internal/types2/mono.go @@ -0,0 +1,337 @@ +// Copyright 2021 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 + +import ( + "cmd/compile/internal/syntax" +) + +// This file implements a check to validate that a Go package doesn't +// have unbounded recursive instantiation, which is not compatible +// with compilers using static instantiation (such as +// monomorphization). +// +// It implements a sort of "type flow" analysis by detecting which +// type parameters are instantiated with other type parameters (or +// types derived thereof). A package cannot be statically instantiated +// if the graph has any cycles involving at least one derived type. +// +// Concretely, we construct a directed, weighted graph. Vertices are +// used to represent type parameters as well as some defined +// types. Edges are used to represent how types depend on each other: +// +// * Everywhere a type-parameterized function or type is instantiated, +// we add edges to each type parameter from the vertices (if any) +// representing each type parameter or defined type referenced by +// the type argument. If the type argument is just the referenced +// type itself, then the edge has weight 0, otherwise 1. +// +// * For every defined type declared within a type-parameterized +// function or method, we add an edge of weight 1 to the defined +// type from each ambient type parameter. +// +// For example, given: +// +// func f[A, B any]() { +// type T int +// f[T, map[A]B]() +// } +// +// we construct vertices representing types A, B, and T. Because of +// declaration "type T int", we construct edges T<-A and T<-B with +// weight 1; and because of instantiation "f[T, map[A]B]" we construct +// edges A<-T with weight 0, and B<-A and B<-B with weight 1. +// +// Finally, we look for any positive-weight cycles. Zero-weight cycles +// are allowed because static instantiation will reach a fixed point. + +type monoGraph struct { + vertices []monoVertex + edges []monoEdge + + // canon maps method receiver type parameters to their respective + // receiver type's type parameters. + canon map[*TypeParam]*TypeParam + + // nameIdx maps a defined type or (canonical) type parameter to its + // vertex index. + nameIdx map[*TypeName]int +} + +type monoVertex struct { + weight int // weight of heaviest known path to this vertex + pre int // previous edge (if any) in the above path + len int // length of the above path + + // obj is the defined type or type parameter represented by this + // vertex. + obj *TypeName +} + +type monoEdge struct { + dst, src int + weight int + + pos syntax.Pos + typ Type +} + +func (check *Checker) monomorph() { + // We detect unbounded instantiation cycles using a variant of + // Bellman-Ford's algorithm. Namely, instead of always running |V| + // iterations, we run until we either reach a fixed point or we've + // found a path of length |V|. This allows us to terminate earlier + // when there are no cycles, which should be the common case. + + again := true + for again { + again = false + + for i, edge := range check.mono.edges { + src := &check.mono.vertices[edge.src] + dst := &check.mono.vertices[edge.dst] + + // N.B., we're looking for the greatest weight paths, unlike + // typical Bellman-Ford. + w := src.weight + edge.weight + if w <= dst.weight { + continue + } + + dst.pre = i + dst.len = src.len + 1 + if dst.len == len(check.mono.vertices) { + check.reportInstanceLoop(edge.dst) + return + } + + dst.weight = w + again = true + } + } +} + +func (check *Checker) reportInstanceLoop(v int) { + var stack []int + seen := make([]bool, len(check.mono.vertices)) + + // We have a path that contains a cycle and ends at v, but v may + // only be reachable from the cycle, not on the cycle itself. We + // start by walking backwards along the path until we find a vertex + // that appears twice. + for !seen[v] { + stack = append(stack, v) + seen[v] = true + v = check.mono.edges[check.mono.vertices[v].pre].src + } + + // Trim any vertices we visited before visiting v the first + // time. Since v is the first vertex we found within the cycle, any + // vertices we visited earlier cannot be part of the cycle. + for stack[0] != v { + stack = stack[1:] + } + + // TODO(mdempsky): Pivot stack so we report the cycle from the top? + + var err error_ + obj0 := check.mono.vertices[v].obj + err.errorf(obj0, "instantiation cycle:") + + qf := RelativeTo(check.pkg) + for _, v := range stack { + edge := check.mono.edges[check.mono.vertices[v].pre] + obj := check.mono.vertices[edge.dst].obj + + switch obj.Type().(type) { + default: + panic("unexpected type") + case *Named: + err.errorf(edge.pos, "%s implicitly parameterized by %s", obj.Name(), TypeString(edge.typ, qf)) // secondary error, \t indented + case *TypeParam: + err.errorf(edge.pos, "%s instantiated as %s", obj.Name(), TypeString(edge.typ, qf)) // secondary error, \t indented + } + } + check.report(&err) +} + +// recordCanon records that tpar is the canonical type parameter +// corresponding to method type parameter mpar. +func (w *monoGraph) recordCanon(mpar, tpar *TypeParam) { + if w.canon == nil { + w.canon = make(map[*TypeParam]*TypeParam) + } + w.canon[mpar] = tpar +} + +// recordInstance records that the given type parameters were +// instantiated with the corresponding type arguments. +func (w *monoGraph) recordInstance(pkg *Package, pos syntax.Pos, tparams []*TypeParam, targs []Type, posList []syntax.Pos) { + for i, tpar := range tparams { + pos := pos + if i < len(posList) { + pos = posList[i] + } + w.assign(pkg, pos, tpar, targs[i]) + } +} + +// assign records that tpar was instantiated as targ at pos. +func (w *monoGraph) assign(pkg *Package, pos syntax.Pos, tpar *TypeParam, targ Type) { + // Go generics do not have an analog to C++`s template-templates, + // where a template parameter can itself be an instantiable + // template. So any instantiation cycles must occur within a single + // package. Accordingly, we can ignore instantiations of imported + // type parameters. + // + // TODO(mdempsky): Push this check up into recordInstance? All type + // parameters in a list will appear in the same package. + if tpar.Obj().Pkg() != pkg { + return + } + + // flow adds an edge from vertex src representing that typ flows to tpar. + flow := func(src int, typ Type) { + weight := 1 + if typ == targ { + weight = 0 + } + + w.addEdge(w.typeParamVertex(tpar), src, weight, pos, targ) + } + + // Recursively walk the type argument to find any defined types or + // type parameters. + var do func(typ Type) + do = func(typ Type) { + switch typ := typ.(type) { + default: + panic("unexpected type") + + case *TypeParam: + assert(typ.Obj().Pkg() == pkg) + flow(w.typeParamVertex(typ), typ) + + case *Named: + if src := w.localNamedVertex(pkg, typ.Origin()); src >= 0 { + flow(src, typ) + } + + targs := typ.TypeArgs() + for i := 0; i < targs.Len(); i++ { + do(targs.At(i)) + } + + case *Array: + do(typ.Elem()) + case *Basic: + // ok + case *Chan: + do(typ.Elem()) + case *Map: + do(typ.Key()) + do(typ.Elem()) + case *Pointer: + do(typ.Elem()) + case *Slice: + do(typ.Elem()) + + case *Interface: + for i := 0; i < typ.NumMethods(); i++ { + do(typ.Method(i).Type()) + } + case *Signature: + tuple := func(tup *Tuple) { + for i := 0; i < tup.Len(); i++ { + do(tup.At(i).Type()) + } + } + tuple(typ.Params()) + tuple(typ.Results()) + case *Struct: + for i := 0; i < typ.NumFields(); i++ { + do(typ.Field(i).Type()) + } + } + } + do(targ) +} + +// localNamedVertex returns the index of the vertex representing +// named, or -1 if named doesn't need representation. +func (w *monoGraph) localNamedVertex(pkg *Package, named *Named) int { + obj := named.Obj() + if obj.Pkg() != pkg { + return -1 // imported type + } + + root := pkg.Scope() + if obj.Parent() == root { + return -1 // package scope, no ambient type parameters + } + + if idx, ok := w.nameIdx[obj]; ok { + return idx + } + + idx := -1 + + // Walk the type definition's scope to find any ambient type + // parameters that it's implicitly parameterized by. + for scope := obj.Parent(); scope != root; scope = scope.Parent() { + for _, elem := range scope.elems { + if elem, ok := elem.(*TypeName); ok && !elem.IsAlias() && elem.Pos().Cmp(obj.Pos()) < 0 { + if tpar, ok := elem.Type().(*TypeParam); ok { + if idx < 0 { + idx = len(w.vertices) + w.vertices = append(w.vertices, monoVertex{obj: obj}) + } + + w.addEdge(idx, w.typeParamVertex(tpar), 1, obj.Pos(), tpar) + } + } + } + } + + if w.nameIdx == nil { + w.nameIdx = make(map[*TypeName]int) + } + w.nameIdx[obj] = idx + return idx +} + +// typeParamVertex returns the index of the vertex representing tpar. +func (w *monoGraph) typeParamVertex(tpar *TypeParam) int { + if x, ok := w.canon[tpar]; ok { + tpar = x + } + + obj := tpar.Obj() + + if idx, ok := w.nameIdx[obj]; ok { + return idx + } + + if w.nameIdx == nil { + w.nameIdx = make(map[*TypeName]int) + } + + idx := len(w.vertices) + w.vertices = append(w.vertices, monoVertex{obj: obj}) + w.nameIdx[obj] = idx + return idx +} + +func (w *monoGraph) addEdge(dst, src, weight int, pos syntax.Pos, typ Type) { + // TODO(mdempsky): Deduplicate redundant edges? + w.edges = append(w.edges, monoEdge{ + dst: dst, + src: src, + weight: weight, + + pos: pos, + typ: typ, + }) +} diff --git a/src/cmd/compile/internal/types2/mono_test.go b/src/cmd/compile/internal/types2/mono_test.go new file mode 100644 index 0000000000..19d0e95637 --- /dev/null +++ b/src/cmd/compile/internal/types2/mono_test.go @@ -0,0 +1,89 @@ +// Copyright 2021 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 ( + "bytes" + "cmd/compile/internal/syntax" + "cmd/compile/internal/types2" + "errors" + "fmt" + "strings" + "testing" +) + +func checkMono(t *testing.T, body string) error { + src := "package x; import `unsafe`; var _ unsafe.Pointer;\n" + body + file, err := syntax.Parse(syntax.NewFileBase("x.go"), strings.NewReader(src), nil, nil, syntax.AllowGenerics) + if err != nil { + t.Fatal(err) + } + files := []*syntax.File{file} + + var buf bytes.Buffer + conf := types2.Config{ + Error: func(err error) { fmt.Fprintln(&buf, err) }, + Importer: defaultImporter(), + } + conf.Check("x", files, nil) + if buf.Len() == 0 { + return nil + } + return errors.New(strings.TrimRight(buf.String(), "\n")) +} + +func TestMonoGood(t *testing.T) { + for i, good := range goods { + if err := checkMono(t, good); err != nil { + t.Errorf("%d: unexpected failure: %v", i, err) + } + } +} + +func TestMonoBad(t *testing.T) { + for i, bad := range bads { + if err := checkMono(t, bad); err == nil { + t.Errorf("%d: unexpected success", i) + } else { + t.Log(err) + } + } +} + +var goods = []string{ + "func F[T any](x T) { F(x) }", + "func F[T, U, V any]() { F[U, V, T](); F[V, T, U]() }", + "type Ring[A, B, C any] struct { L *Ring[B, C, A]; R *Ring[C, A, B] }", + "func F[T any]() { type U[T any] [unsafe.Sizeof(F[*T])]byte }", + "func F[T any]() { type U[T any] [unsafe.Sizeof(F[*T])]byte; var _ U[int] }", + "type U[T any] [unsafe.Sizeof(F[*T])]byte; func F[T any]() { var _ U[U[int]] }", + "func F[T any]() { type A = int; F[A]() }", +} + +// TODO(mdempsky): Validate specific error messages and positioning. + +var bads = []string{ + "func F[T any](x T) { F(&x) }", + "func F[T any]() { F[*T]() }", + "func F[T any]() { F[[]T]() }", + "func F[T any]() { F[[1]T]() }", + "func F[T any]() { F[chan T]() }", + "func F[T any]() { F[map[*T]int]() }", + "func F[T any]() { F[map[error]T]() }", + "func F[T any]() { F[func(T)]() }", + "func F[T any]() { F[func() T]() }", + "func F[T any]() { F[struct{ t T }]() }", + "func F[T any]() { F[interface{ t() T }]() }", + "type U[_ any] int; func F[T any]() { F[U[T]]() }", + "func F[T any]() { type U int; F[U]() }", + "func F[T any]() { type U int; F[*U]() }", + "type U[T any] int; func (U[T]) m() { var _ U[*T] }", + "type U[T any] int; func (*U[T]) m() { var _ U[*T] }", + "type U[T1 any] [unsafe.Sizeof(F[*T1])]byte; func F[T2 any]() { var _ U[T2] }", + "func F[A, B, C, D, E any]() { F[B, C, D, E, *A]() }", + "type U[_ any] int; const X = unsafe.Sizeof(func() { type A[T any] U[A[*T]] })", + "func F[T any]() { type A = *T; F[A]() }", + "type A[T any] struct { _ A[*T] }", +} diff --git a/src/cmd/compile/internal/types2/signature.go b/src/cmd/compile/internal/types2/signature.go index 604d0c9dbd..4541435587 100644 --- a/src/cmd/compile/internal/types2/signature.go +++ b/src/cmd/compile/internal/types2/signature.go @@ -148,6 +148,7 @@ func (check *Checker) funcType(sig *Signature, recvPar *syntax.Field, tparams [] list := make([]Type, sig.RecvTypeParams().Len()) for i, t := range sig.RecvTypeParams().list() { list[i] = t + check.mono.recordCanon(t, recvTParams[i]) } smap := makeSubstMap(recvTParams, list) for i, tpar := range sig.RecvTypeParams().list() { diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48974.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48974.go2 index ca4b6d9321..d8ff7c8cf4 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48974.go2 +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48974.go2 @@ -8,7 +8,7 @@ type Fooer interface { Foo() } -type Fooable[F Fooer] struct { +type Fooable[F /* ERROR instantiation cycle */ Fooer] struct { ptr F } diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go index d8183bfd9c..95893fd1e1 100644 --- a/src/cmd/compile/internal/types2/typexpr.go +++ b/src/cmd/compile/internal/types2/typexpr.go @@ -481,6 +481,8 @@ func (check *Checker) instantiatedType(x syntax.Expr, targsx []syntax.Expr, def pos = posList[i] } check.softErrorf(pos, err.Error()) + } else { + check.mono.recordInstance(check.pkg, x.Pos(), inst.tparams.list(), inst.targs.list(), posList) } } From 5b213178e72b6031c9ec790bf9fe784c66b397e3 Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Sun, 26 Sep 2021 19:21:29 +1000 Subject: [PATCH 337/406] cmd/asm,cmd/compile,runtime: stop using X3 (aka GP) on riscv64 The X3 (aka GP) register will potentially be loaded with the __global_pointer$ symbol during program start up (usually by the dynamic linker). As such, non-Go code may depend on the contents of GP and calculate offsets based on it, including code called via cgo and signal handlers installed by non-Go code. As such, stop using the X3 register so that there are fewer issues interacting between Go and non-Go code. While here remove the X4 (TP) name from the assembler such that any references must use the 'TP' name. This should reduce the likelihood of accidental use (like we do for the 'g' register). The same applies for X3 (GP) when the -shared flag is given. Updates #47100 Change-Id: I72e82b5ca3f80c46a781781345ca0432a4111b74 Reviewed-on: https://go-review.googlesource.com/c/go/+/351859 Trust: Joel Sing Run-TryBot: Joel Sing Reviewed-by: Cherry Mui TryBot-Result: Go Bot --- src/cmd/asm/internal/arch/arch.go | 14 +- src/cmd/asm/internal/asm/operand_test.go | 2 +- src/cmd/asm/main.go | 6 +- .../compile/internal/ssa/gen/RISCV64Ops.go | 5 +- src/cmd/compile/internal/ssa/opGen.go | 500 +++++++++--------- src/runtime/asm_riscv64.s | 97 ++-- src/runtime/cgo/asm_riscv64.s | 60 +-- src/runtime/cgo/gcc_riscv64.S | 108 ++-- src/runtime/mkpreempt.go | 8 +- src/runtime/preempt_riscv64.s | 238 +++++---- src/runtime/tls_riscv64.s | 4 +- 11 files changed, 519 insertions(+), 523 deletions(-) diff --git a/src/cmd/asm/internal/arch/arch.go b/src/cmd/asm/internal/arch/arch.go index 8c71b79965..4d374cb828 100644 --- a/src/cmd/asm/internal/arch/arch.go +++ b/src/cmd/asm/internal/arch/arch.go @@ -50,7 +50,7 @@ func nilRegisterNumber(name string, n int16) (int16, bool) { // Set configures the architecture specified by GOARCH and returns its representation. // It returns nil if GOARCH is not recognized. -func Set(GOARCH string) *Arch { +func Set(GOARCH string, shared bool) *Arch { switch GOARCH { case "386": return archX86(&x86.Link386) @@ -73,7 +73,7 @@ func Set(GOARCH string) *Arch { case "ppc64le": return archPPC64(&ppc64.Linkppc64le) case "riscv64": - return archRISCV64() + return archRISCV64(shared) case "s390x": return archS390x() case "wasm": @@ -541,12 +541,18 @@ func archMips64(linkArch *obj.LinkArch) *Arch { } } -func archRISCV64() *Arch { +func archRISCV64(shared bool) *Arch { register := make(map[string]int16) // Standard register names. for i := riscv.REG_X0; i <= riscv.REG_X31; i++ { - if i == riscv.REG_G { + // Disallow X3 in shared mode, as this will likely be used as the + // GP register, which could result in problems in non-Go code, + // including signal handlers. + if shared && i == riscv.REG_GP { + continue + } + if i == riscv.REG_TP || i == riscv.REG_G { continue } name := fmt.Sprintf("X%d", i-riscv.REG_X0) diff --git a/src/cmd/asm/internal/asm/operand_test.go b/src/cmd/asm/internal/asm/operand_test.go index 8ef02b1a0e..c1295a0c42 100644 --- a/src/cmd/asm/internal/asm/operand_test.go +++ b/src/cmd/asm/internal/asm/operand_test.go @@ -19,7 +19,7 @@ import ( func setArch(goarch string) (*arch.Arch, *obj.Link) { buildcfg.GOOS = "linux" // obj can handle this OS for all architectures. buildcfg.GOARCH = goarch - architecture := arch.Set(goarch) + architecture := arch.Set(goarch, false) if architecture == nil { panic("asm: unrecognized architecture " + goarch) } diff --git a/src/cmd/asm/main.go b/src/cmd/asm/main.go index 043bc696e5..3e32aa3d7d 100644 --- a/src/cmd/asm/main.go +++ b/src/cmd/asm/main.go @@ -29,13 +29,13 @@ func main() { buildcfg.Check() GOARCH := buildcfg.GOARCH - architecture := arch.Set(GOARCH) + flags.Parse() + + architecture := arch.Set(GOARCH, *flags.Shared || *flags.Dynlink) if architecture == nil { log.Fatalf("unrecognized architecture %s", GOARCH) } - flags.Parse() - ctxt := obj.Linknew(architecture.LinkArch) ctxt.Debugasm = flags.PrintOut ctxt.Debugvlog = flags.DebugV diff --git a/src/cmd/compile/internal/ssa/gen/RISCV64Ops.go b/src/cmd/compile/internal/ssa/gen/RISCV64Ops.go index 880fad1c49..076919773b 100644 --- a/src/cmd/compile/internal/ssa/gen/RISCV64Ops.go +++ b/src/cmd/compile/internal/ssa/gen/RISCV64Ops.go @@ -29,6 +29,7 @@ const ( riscv64REG_CTXT = 20 riscv64REG_LR = 1 riscv64REG_SP = 2 + riscv64REG_GP = 3 riscv64REG_TP = 4 riscv64REG_TMP = 31 riscv64REG_ZERO = 0 @@ -80,8 +81,8 @@ func init() { // Add general purpose registers to gpMask. switch r { - // ZERO, TP and TMP are not in any gp mask. - case riscv64REG_ZERO, riscv64REG_TP, riscv64REG_TMP: + // ZERO, GP, TP and TMP are not in any gp mask. + case riscv64REG_ZERO, riscv64REG_GP, riscv64REG_TP, riscv64REG_TMP: case riscv64REG_G: gpgMask |= mask gpspsbgMask |= mask diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go index ed10f35fb9..2038575b0c 100644 --- a/src/cmd/compile/internal/ssa/opGen.go +++ b/src/cmd/compile/internal/ssa/opGen.go @@ -27949,11 +27949,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.AADD, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -27964,10 +27964,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AADDI, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -27978,10 +27978,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AADDIW, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -27991,10 +27991,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.ANEG, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28004,10 +28004,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.ANEGW, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28017,11 +28017,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASUB, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28031,11 +28031,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASUBW, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28046,11 +28046,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMUL, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28061,11 +28061,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMULW, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28076,11 +28076,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMULH, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28091,11 +28091,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMULHU, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28105,12 +28105,12 @@ var opcodeTable = [...]opInfo{ resultNotInArgs: true, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28120,12 +28120,12 @@ var opcodeTable = [...]opInfo{ resultNotInArgs: true, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28135,11 +28135,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.ADIV, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28149,11 +28149,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.ADIVU, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28163,11 +28163,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.ADIVW, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28177,11 +28177,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.ADIVUW, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28191,11 +28191,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.AREM, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28205,11 +28205,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.AREMU, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28219,11 +28219,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.AREMW, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28233,11 +28233,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.AREMUW, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28250,10 +28250,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOV, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28265,7 +28265,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOV, reg: regInfo{ outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28278,10 +28278,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVB, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28294,10 +28294,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVH, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28310,10 +28310,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVW, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28326,10 +28326,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOV, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28342,10 +28342,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVBU, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28358,10 +28358,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVHU, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28374,10 +28374,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVWU, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28390,8 +28390,8 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVB, reg: regInfo{ inputs: []inputInfo{ - {1, 1006632950}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, }, }, @@ -28404,8 +28404,8 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVH, reg: regInfo{ inputs: []inputInfo{ - {1, 1006632950}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, }, }, @@ -28418,8 +28418,8 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVW, reg: regInfo{ inputs: []inputInfo{ - {1, 1006632950}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, }, }, @@ -28432,8 +28432,8 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOV, reg: regInfo{ inputs: []inputInfo{ - {1, 1006632950}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, }, }, @@ -28446,7 +28446,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVB, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, }, }, @@ -28459,7 +28459,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVH, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, }, }, @@ -28472,7 +28472,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVW, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, }, }, @@ -28485,7 +28485,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOV, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, }, }, @@ -28495,10 +28495,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVB, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28508,10 +28508,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVH, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28521,10 +28521,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVW, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28534,10 +28534,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOV, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28547,10 +28547,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVBU, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28560,10 +28560,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVHU, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28573,10 +28573,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVWU, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28586,10 +28586,10 @@ var opcodeTable = [...]opInfo{ resultInArg0: true, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28599,11 +28599,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASLL, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28613,11 +28613,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASRA, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28627,11 +28627,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASRL, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28642,10 +28642,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASLLI, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28656,10 +28656,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASRAI, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28670,10 +28670,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASRLI, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28684,11 +28684,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.AXOR, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28699,10 +28699,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AXORI, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28713,11 +28713,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.AOR, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28728,10 +28728,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AORI, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28742,11 +28742,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.AAND, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28757,10 +28757,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AANDI, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28770,10 +28770,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.ANOT, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28783,10 +28783,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASEQZ, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28796,10 +28796,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASNEZ, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28809,11 +28809,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASLT, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28824,10 +28824,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASLTI, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28837,11 +28837,11 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASLTU, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28852,10 +28852,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.ASLTIU, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28865,10 +28865,10 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOV, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28878,7 +28878,7 @@ var opcodeTable = [...]opInfo{ argLen: 1, call: true, reg: regInfo{ - clobbers: 9223372035781033972, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + clobbers: 9223372035781033968, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, }, { @@ -28888,7 +28888,7 @@ var opcodeTable = [...]opInfo{ call: true, tailCall: true, reg: regInfo{ - clobbers: 9223372035781033972, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + clobbers: 9223372035781033968, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, }, { @@ -28899,9 +28899,9 @@ var opcodeTable = [...]opInfo{ reg: regInfo{ inputs: []inputInfo{ {1, 524288}, // X20 - {0, 1006632950}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, - clobbers: 9223372035781033972, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + clobbers: 9223372035781033968, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, }, { @@ -28911,9 +28911,9 @@ var opcodeTable = [...]opInfo{ call: true, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, - clobbers: 9223372035781033972, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + clobbers: 9223372035781033968, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, }, { @@ -28950,7 +28950,7 @@ var opcodeTable = [...]opInfo{ reg: regInfo{ inputs: []inputInfo{ {0, 16}, // X5 - {1, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, clobbers: 16, // X5 }, @@ -28965,7 +28965,7 @@ var opcodeTable = [...]opInfo{ inputs: []inputInfo{ {0, 16}, // X5 {1, 32}, // X6 - {2, 1006632884}, // X3 X5 X6 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {2, 1006632880}, // X5 X6 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, clobbers: 112, // X5 X6 X7 }, @@ -28976,10 +28976,10 @@ var opcodeTable = [...]opInfo{ faultOnNilArg0: true, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -28989,10 +28989,10 @@ var opcodeTable = [...]opInfo{ faultOnNilArg0: true, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29002,10 +29002,10 @@ var opcodeTable = [...]opInfo{ faultOnNilArg0: true, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29016,8 +29016,8 @@ var opcodeTable = [...]opInfo{ hasSideEffects: true, reg: regInfo{ inputs: []inputInfo{ - {1, 1006632950}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, }, }, @@ -29028,8 +29028,8 @@ var opcodeTable = [...]opInfo{ hasSideEffects: true, reg: regInfo{ inputs: []inputInfo{ - {1, 1006632950}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, }, }, @@ -29040,8 +29040,8 @@ var opcodeTable = [...]opInfo{ hasSideEffects: true, reg: regInfo{ inputs: []inputInfo{ - {1, 1006632950}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, }, }, @@ -29053,11 +29053,11 @@ var opcodeTable = [...]opInfo{ hasSideEffects: true, reg: regInfo{ inputs: []inputInfo{ - {1, 1073741812}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 - {0, 9223372037928517622}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29069,11 +29069,11 @@ var opcodeTable = [...]opInfo{ hasSideEffects: true, reg: regInfo{ inputs: []inputInfo{ - {1, 1073741812}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 - {0, 9223372037928517622}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29086,11 +29086,11 @@ var opcodeTable = [...]opInfo{ unsafePoint: true, reg: regInfo{ inputs: []inputInfo{ - {1, 1073741812}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 - {0, 9223372037928517622}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29103,11 +29103,11 @@ var opcodeTable = [...]opInfo{ unsafePoint: true, reg: regInfo{ inputs: []inputInfo{ - {1, 1073741812}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 - {0, 9223372037928517622}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29120,12 +29120,12 @@ var opcodeTable = [...]opInfo{ unsafePoint: true, reg: regInfo{ inputs: []inputInfo{ - {1, 1073741812}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 - {2, 1073741812}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 - {0, 9223372037928517622}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {2, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29138,12 +29138,12 @@ var opcodeTable = [...]opInfo{ unsafePoint: true, reg: regInfo{ inputs: []inputInfo{ - {1, 1073741812}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 - {2, 1073741812}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 - {0, 9223372037928517622}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {2, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29155,8 +29155,8 @@ var opcodeTable = [...]opInfo{ asm: riscv.AAMOANDW, reg: regInfo{ inputs: []inputInfo{ - {1, 1073741812}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 - {0, 9223372037928517622}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB }, }, }, @@ -29168,8 +29168,8 @@ var opcodeTable = [...]opInfo{ asm: riscv.AAMOORW, reg: regInfo{ inputs: []inputInfo{ - {1, 1073741812}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 - {0, 9223372037928517622}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB }, }, }, @@ -29180,7 +29180,7 @@ var opcodeTable = [...]opInfo{ faultOnNilArg0: true, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632950}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29199,7 +29199,7 @@ var opcodeTable = [...]opInfo{ rematerializeable: true, reg: regInfo{ outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29209,7 +29209,7 @@ var opcodeTable = [...]opInfo{ rematerializeable: true, reg: regInfo{ outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29353,7 +29353,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AFMVSX, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ {0, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 @@ -29366,7 +29366,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AFCVTSW, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ {0, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 @@ -29379,7 +29379,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AFCVTSL, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ {0, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 @@ -29395,7 +29395,7 @@ var opcodeTable = [...]opInfo{ {0, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29408,7 +29408,7 @@ var opcodeTable = [...]opInfo{ {0, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29421,7 +29421,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVF, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ {0, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 @@ -29437,7 +29437,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVF, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB {1, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, }, @@ -29453,7 +29453,7 @@ var opcodeTable = [...]opInfo{ {1, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29468,7 +29468,7 @@ var opcodeTable = [...]opInfo{ {1, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29482,7 +29482,7 @@ var opcodeTable = [...]opInfo{ {1, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29496,7 +29496,7 @@ var opcodeTable = [...]opInfo{ {1, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29681,7 +29681,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AFMVDX, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ {0, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 @@ -29694,7 +29694,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AFCVTDW, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ {0, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 @@ -29707,7 +29707,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AFCVTDL, reg: regInfo{ inputs: []inputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, outputs: []outputInfo{ {0, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 @@ -29723,7 +29723,7 @@ var opcodeTable = [...]opInfo{ {0, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29736,7 +29736,7 @@ var opcodeTable = [...]opInfo{ {0, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29775,7 +29775,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVD, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB }, outputs: []outputInfo{ {0, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 @@ -29791,7 +29791,7 @@ var opcodeTable = [...]opInfo{ asm: riscv.AMOVD, reg: regInfo{ inputs: []inputInfo{ - {0, 9223372037861408758}, // SP X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB {1, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, }, @@ -29807,7 +29807,7 @@ var opcodeTable = [...]opInfo{ {1, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29822,7 +29822,7 @@ var opcodeTable = [...]opInfo{ {1, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29836,7 +29836,7 @@ var opcodeTable = [...]opInfo{ {1, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -29850,7 +29850,7 @@ var opcodeTable = [...]opInfo{ {1, 9223372034707292160}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 }, outputs: []outputInfo{ - {0, 1006632948}, // X3 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 }, }, }, @@ -37293,34 +37293,34 @@ var linkRegPPC64 = int8(-1) var registersRISCV64 = [...]Register{ {0, riscv.REG_X0, -1, "X0"}, {1, riscv.REGSP, -1, "SP"}, - {2, riscv.REG_X3, 0, "X3"}, + {2, riscv.REG_X3, -1, "X3"}, {3, riscv.REG_X4, -1, "X4"}, - {4, riscv.REG_X5, 1, "X5"}, - {5, riscv.REG_X6, 2, "X6"}, - {6, riscv.REG_X7, 3, "X7"}, - {7, riscv.REG_X8, 4, "X8"}, - {8, riscv.REG_X9, 5, "X9"}, - {9, riscv.REG_X10, 6, "X10"}, - {10, riscv.REG_X11, 7, "X11"}, - {11, riscv.REG_X12, 8, "X12"}, - {12, riscv.REG_X13, 9, "X13"}, - {13, riscv.REG_X14, 10, "X14"}, - {14, riscv.REG_X15, 11, "X15"}, - {15, riscv.REG_X16, 12, "X16"}, - {16, riscv.REG_X17, 13, "X17"}, - {17, riscv.REG_X18, 14, "X18"}, - {18, riscv.REG_X19, 15, "X19"}, - {19, riscv.REG_X20, 16, "X20"}, - {20, riscv.REG_X21, 17, "X21"}, - {21, riscv.REG_X22, 18, "X22"}, - {22, riscv.REG_X23, 19, "X23"}, - {23, riscv.REG_X24, 20, "X24"}, - {24, riscv.REG_X25, 21, "X25"}, - {25, riscv.REG_X26, 22, "X26"}, + {4, riscv.REG_X5, 0, "X5"}, + {5, riscv.REG_X6, 1, "X6"}, + {6, riscv.REG_X7, 2, "X7"}, + {7, riscv.REG_X8, 3, "X8"}, + {8, riscv.REG_X9, 4, "X9"}, + {9, riscv.REG_X10, 5, "X10"}, + {10, riscv.REG_X11, 6, "X11"}, + {11, riscv.REG_X12, 7, "X12"}, + {12, riscv.REG_X13, 8, "X13"}, + {13, riscv.REG_X14, 9, "X14"}, + {14, riscv.REG_X15, 10, "X15"}, + {15, riscv.REG_X16, 11, "X16"}, + {16, riscv.REG_X17, 12, "X17"}, + {17, riscv.REG_X18, 13, "X18"}, + {18, riscv.REG_X19, 14, "X19"}, + {19, riscv.REG_X20, 15, "X20"}, + {20, riscv.REG_X21, 16, "X21"}, + {21, riscv.REG_X22, 17, "X22"}, + {22, riscv.REG_X23, 18, "X23"}, + {23, riscv.REG_X24, 19, "X24"}, + {24, riscv.REG_X25, 20, "X25"}, + {25, riscv.REG_X26, 21, "X26"}, {26, riscv.REGG, -1, "g"}, - {27, riscv.REG_X28, 23, "X28"}, - {28, riscv.REG_X29, 24, "X29"}, - {29, riscv.REG_X30, 25, "X30"}, + {27, riscv.REG_X28, 22, "X28"}, + {28, riscv.REG_X29, 23, "X29"}, + {29, riscv.REG_X30, 24, "X30"}, {30, riscv.REG_X31, -1, "X31"}, {31, riscv.REG_F0, -1, "F0"}, {32, riscv.REG_F1, -1, "F1"}, @@ -37358,7 +37358,7 @@ var registersRISCV64 = [...]Register{ } var paramIntRegRISCV64 = []int8(nil) var paramFloatRegRISCV64 = []int8(nil) -var gpRegMaskRISCV64 = regMask(1006632948) +var gpRegMaskRISCV64 = regMask(1006632944) var fpRegMaskRISCV64 = regMask(9223372034707292160) var specialRegMaskRISCV64 = regMask(0) var framepointerRegRISCV64 = int8(-1) diff --git a/src/runtime/asm_riscv64.s b/src/runtime/asm_riscv64.s index 531b46927c..0e813189d4 100644 --- a/src/runtime/asm_riscv64.s +++ b/src/runtime/asm_riscv64.s @@ -631,10 +631,10 @@ TEXT ·checkASM(SB),NOSPLIT,$0-1 // The act of CALLing gcWriteBarrier will clobber RA (LR). // It does not clobber any other general-purpose registers, // but may clobber others (e.g., floating point registers). -TEXT runtime·gcWriteBarrier(SB),NOSPLIT,$216 +TEXT runtime·gcWriteBarrier(SB),NOSPLIT,$208 // Save the registers clobbered by the fast path. - MOV A0, 25*8(X2) - MOV A1, 26*8(X2) + MOV A0, 24*8(X2) + MOV A1, 25*8(X2) MOV g_m(g), A0 MOV m_p(A0), A0 MOV (p_wbBuf+wbBuf_next)(A0), A1 @@ -650,8 +650,8 @@ TEXT runtime·gcWriteBarrier(SB),NOSPLIT,$216 // Is the buffer full? BEQ A1, T6, flush ret: - MOV 25*8(X2), A0 - MOV 26*8(X2), A1 + MOV 24*8(X2), A0 + MOV 25*8(X2), A1 // Do the write. MOV T1, (T0) RET @@ -664,34 +664,34 @@ flush: // X0 is zero register // X1 is LR, saved by prologue // X2 is SP - MOV X3, 3*8(X2) + // X3 is GP // X4 is TP // X5 is first arg to wbBufFlush (T0) // X6 is second arg to wbBufFlush (T1) - MOV X7, 4*8(X2) - MOV X8, 5*8(X2) - MOV X9, 6*8(X2) + MOV X7, 3*8(X2) + MOV X8, 4*8(X2) + MOV X9, 5*8(X2) // X10 already saved (A0) // X11 already saved (A1) - MOV X12, 7*8(X2) - MOV X13, 8*8(X2) - MOV X14, 9*8(X2) - MOV X15, 10*8(X2) - MOV X16, 11*8(X2) - MOV X17, 12*8(X2) - MOV X18, 13*8(X2) - MOV X19, 14*8(X2) - MOV X20, 15*8(X2) - MOV X21, 16*8(X2) - MOV X22, 17*8(X2) - MOV X23, 18*8(X2) - MOV X24, 19*8(X2) - MOV X25, 20*8(X2) - MOV X26, 21*8(X2) + MOV X12, 6*8(X2) + MOV X13, 7*8(X2) + MOV X14, 8*8(X2) + MOV X15, 9*8(X2) + MOV X16, 10*8(X2) + MOV X17, 11*8(X2) + MOV X18, 12*8(X2) + MOV X19, 13*8(X2) + MOV X20, 14*8(X2) + MOV X21, 15*8(X2) + MOV X22, 16*8(X2) + MOV X23, 17*8(X2) + MOV X24, 18*8(X2) + MOV X25, 19*8(X2) + MOV X26, 20*8(X2) // X27 is g. - MOV X28, 22*8(X2) - MOV X29, 23*8(X2) - MOV X30, 24*8(X2) + MOV X28, 21*8(X2) + MOV X29, 22*8(X2) + MOV X30, 23*8(X2) // X31 is tmp register. // This takes arguments T0 and T1. @@ -699,28 +699,27 @@ flush: MOV 1*8(X2), T0 MOV 2*8(X2), T1 - MOV 3*8(X2), X3 - MOV 4*8(X2), X7 - MOV 5*8(X2), X8 - MOV 6*8(X2), X9 - MOV 7*8(X2), X12 - MOV 8*8(X2), X13 - MOV 9*8(X2), X14 - MOV 10*8(X2), X15 - MOV 11*8(X2), X16 - MOV 12*8(X2), X17 - MOV 13*8(X2), X18 - MOV 14*8(X2), X19 - MOV 15*8(X2), X20 - MOV 16*8(X2), X21 - MOV 17*8(X2), X22 - MOV 18*8(X2), X23 - MOV 19*8(X2), X24 - MOV 20*8(X2), X25 - MOV 21*8(X2), X26 - MOV 22*8(X2), X28 - MOV 23*8(X2), X29 - MOV 24*8(X2), X30 + MOV 3*8(X2), X7 + MOV 4*8(X2), X8 + MOV 5*8(X2), X9 + MOV 6*8(X2), X12 + MOV 7*8(X2), X13 + MOV 8*8(X2), X14 + MOV 9*8(X2), X15 + MOV 10*8(X2), X16 + MOV 11*8(X2), X17 + MOV 12*8(X2), X18 + MOV 13*8(X2), X19 + MOV 14*8(X2), X20 + MOV 15*8(X2), X21 + MOV 16*8(X2), X22 + MOV 17*8(X2), X23 + MOV 18*8(X2), X24 + MOV 19*8(X2), X25 + MOV 20*8(X2), X26 + MOV 21*8(X2), X28 + MOV 22*8(X2), X29 + MOV 23*8(X2), X30 JMP ret diff --git a/src/runtime/cgo/asm_riscv64.s b/src/runtime/cgo/asm_riscv64.s index fcd1d36ca8..45151bf02b 100644 --- a/src/runtime/cgo/asm_riscv64.s +++ b/src/runtime/cgo/asm_riscv64.s @@ -14,7 +14,7 @@ TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0 * registers. Note that at procedure entry the first argument is at * 8(X2). */ - ADD $(-8*31), X2 + ADD $(-8*29), X2 MOV X10, (8*1)(X2) // fn unsafe.Pointer MOV X11, (8*2)(X2) // a unsafe.Pointer MOV X13, (8*3)(X2) // ctxt uintptr @@ -30,21 +30,19 @@ TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0 MOV X25, (8*13)(X2) MOV X26, (8*14)(X2) MOV g, (8*15)(X2) - MOV X3, (8*16)(X2) - MOV X4, (8*17)(X2) - MOV X1, (8*18)(X2) - MOVD F8, (8*19)(X2) - MOVD F9, (8*20)(X2) - MOVD F18, (8*21)(X2) - MOVD F19, (8*22)(X2) - MOVD F20, (8*23)(X2) - MOVD F21, (8*24)(X2) - MOVD F22, (8*25)(X2) - MOVD F23, (8*26)(X2) - MOVD F24, (8*27)(X2) - MOVD F25, (8*28)(X2) - MOVD F26, (8*29)(X2) - MOVD F27, (8*30)(X2) + MOV X1, (8*16)(X2) + MOVD F8, (8*17)(X2) + MOVD F9, (8*18)(X2) + MOVD F18, (8*19)(X2) + MOVD F19, (8*20)(X2) + MOVD F20, (8*21)(X2) + MOVD F21, (8*22)(X2) + MOVD F22, (8*23)(X2) + MOVD F23, (8*24)(X2) + MOVD F24, (8*25)(X2) + MOVD F25, (8*26)(X2) + MOVD F26, (8*27)(X2) + MOVD F27, (8*28)(X2) // Initialize Go ABI environment CALL runtime·load_g(SB) @@ -62,21 +60,19 @@ TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0 MOV (8*13)(X2), X25 MOV (8*14)(X2), X26 MOV (8*15)(X2), g - MOV (8*16)(X2), X3 - MOV (8*17)(X2), X4 - MOV (8*18)(X2), X1 - MOVD (8*19)(X2), F8 - MOVD (8*20)(X2), F9 - MOVD (8*21)(X2), F18 - MOVD (8*22)(X2), F19 - MOVD (8*23)(X2), F20 - MOVD (8*24)(X2), F21 - MOVD (8*25)(X2), F22 - MOVD (8*26)(X2), F23 - MOVD (8*27)(X2), F24 - MOVD (8*28)(X2), F25 - MOVD (8*29)(X2), F26 - MOVD (8*30)(X2), F27 - ADD $(8*31), X2 + MOV (8*16)(X2), X1 + MOVD (8*17)(X2), F8 + MOVD (8*18)(X2), F9 + MOVD (8*19)(X2), F18 + MOVD (8*20)(X2), F19 + MOVD (8*21)(X2), F20 + MOVD (8*22)(X2), F21 + MOVD (8*23)(X2), F22 + MOVD (8*24)(X2), F23 + MOVD (8*25)(X2), F24 + MOVD (8*26)(X2), F25 + MOVD (8*27)(X2), F26 + MOVD (8*28)(X2), F27 + ADD $(8*29), X2 RET diff --git a/src/runtime/cgo/gcc_riscv64.S b/src/runtime/cgo/gcc_riscv64.S index fdc77496d9..f429dc64ee 100644 --- a/src/runtime/cgo/gcc_riscv64.S +++ b/src/runtime/cgo/gcc_riscv64.S @@ -8,38 +8,36 @@ * Calling into the gc tool chain, where all registers are caller save. * Called from standard RISCV ELF psABI, where x8-x9, x18-x27, f8-f9 and * f18-f27 are callee-save, so they must be saved explicitly, along with - * x1 (LR), x3 (GP) and x4 (TP). + * x1 (LR). */ .globl crosscall1 crosscall1: - sd x1, -216(sp) - addi sp, sp, -216 - sd x3, 8(sp) - sd x4, 16(sp) - sd x8, 24(sp) - sd x9, 32(sp) - sd x18, 40(sp) - sd x19, 48(sp) - sd x20, 56(sp) - sd x21, 64(sp) - sd x22, 72(sp) - sd x23, 80(sp) - sd x24, 88(sp) - sd x25, 96(sp) - sd x26, 104(sp) - sd x27, 112(sp) - fsd f8, 120(sp) - fsd f9, 128(sp) - fsd f18, 136(sp) - fsd f19, 144(sp) - fsd f20, 152(sp) - fsd f21, 160(sp) - fsd f22, 168(sp) - fsd f23, 176(sp) - fsd f24, 184(sp) - fsd f25, 192(sp) - fsd f26, 200(sp) - fsd f27, 208(sp) + sd x1, -200(sp) + addi sp, sp, -200 + sd x8, 8(sp) + sd x9, 16(sp) + sd x18, 24(sp) + sd x19, 32(sp) + sd x20, 40(sp) + sd x21, 48(sp) + sd x22, 56(sp) + sd x23, 64(sp) + sd x24, 72(sp) + sd x25, 80(sp) + sd x26, 88(sp) + sd x27, 96(sp) + fsd f8, 104(sp) + fsd f9, 112(sp) + fsd f18, 120(sp) + fsd f19, 128(sp) + fsd f20, 136(sp) + fsd f21, 144(sp) + fsd f22, 152(sp) + fsd f23, 160(sp) + fsd f24, 168(sp) + fsd f25, 176(sp) + fsd f26, 184(sp) + fsd f27, 192(sp) // a0 = *fn, a1 = *setg_gcc, a2 = *g mv s1, a0 @@ -49,33 +47,31 @@ crosscall1: jalr ra, s1 // call fn ld x1, 0(sp) - ld x3, 8(sp) - ld x4, 16(sp) - ld x8, 24(sp) - ld x9, 32(sp) - ld x18, 40(sp) - ld x19, 48(sp) - ld x20, 56(sp) - ld x21, 64(sp) - ld x22, 72(sp) - ld x23, 80(sp) - ld x24, 88(sp) - ld x25, 96(sp) - ld x26, 104(sp) - ld x27, 112(sp) - fld f8, 120(sp) - fld f9, 128(sp) - fld f18, 136(sp) - fld f19, 144(sp) - fld f20, 152(sp) - fld f21, 160(sp) - fld f22, 168(sp) - fld f23, 176(sp) - fld f24, 184(sp) - fld f25, 192(sp) - fld f26, 200(sp) - fld f27, 208(sp) - addi sp, sp, 216 + ld x8, 8(sp) + ld x9, 16(sp) + ld x18, 24(sp) + ld x19, 32(sp) + ld x20, 40(sp) + ld x21, 48(sp) + ld x22, 56(sp) + ld x23, 64(sp) + ld x24, 72(sp) + ld x25, 80(sp) + ld x26, 88(sp) + ld x27, 96(sp) + fld f8, 104(sp) + fld f9, 112(sp) + fld f18, 120(sp) + fld f19, 128(sp) + fld f20, 136(sp) + fld f21, 144(sp) + fld f22, 152(sp) + fld f23, 160(sp) + fld f24, 168(sp) + fld f25, 176(sp) + fld f26, 184(sp) + fld f27, 192(sp) + addi sp, sp, 200 jr ra diff --git a/src/runtime/mkpreempt.go b/src/runtime/mkpreempt.go index d662e73813..e8c23d485a 100644 --- a/src/runtime/mkpreempt.go +++ b/src/runtime/mkpreempt.go @@ -504,12 +504,12 @@ func genPPC64() { } func genRISCV64() { - // X0 (zero), X1 (LR), X2 (SP), X4 (TP), X27 (g), X31 (TMP) are special. + // X0 (zero), X1 (LR), X2 (SP), X3 (GP), X4 (TP), X27 (g), X31 (TMP) are special. var l = layout{sp: "X2", stack: 8} - // Add integer registers (X3, X5-X26, X28-30). - for i := 3; i < 31; i++ { - if i == 4 || i == 27 { + // Add integer registers (X5-X26, X28-30). + for i := 5; i < 31; i++ { + if i == 27 { continue } reg := fmt.Sprintf("X%d", i) diff --git a/src/runtime/preempt_riscv64.s b/src/runtime/preempt_riscv64.s index eb68dcba2b..56df6c30e0 100644 --- a/src/runtime/preempt_riscv64.s +++ b/src/runtime/preempt_riscv64.s @@ -4,126 +4,124 @@ #include "textflag.h" TEXT ·asyncPreempt(SB),NOSPLIT|NOFRAME,$0-0 - MOV X1, -472(X2) - ADD $-472, X2 - MOV X3, 8(X2) - MOV X5, 16(X2) - MOV X6, 24(X2) - MOV X7, 32(X2) - MOV X8, 40(X2) - MOV X9, 48(X2) - MOV X10, 56(X2) - MOV X11, 64(X2) - MOV X12, 72(X2) - MOV X13, 80(X2) - MOV X14, 88(X2) - MOV X15, 96(X2) - MOV X16, 104(X2) - MOV X17, 112(X2) - MOV X18, 120(X2) - MOV X19, 128(X2) - MOV X20, 136(X2) - MOV X21, 144(X2) - MOV X22, 152(X2) - MOV X23, 160(X2) - MOV X24, 168(X2) - MOV X25, 176(X2) - MOV X26, 184(X2) - MOV X28, 192(X2) - MOV X29, 200(X2) - MOV X30, 208(X2) - MOVD F0, 216(X2) - MOVD F1, 224(X2) - MOVD F2, 232(X2) - MOVD F3, 240(X2) - MOVD F4, 248(X2) - MOVD F5, 256(X2) - MOVD F6, 264(X2) - MOVD F7, 272(X2) - MOVD F8, 280(X2) - MOVD F9, 288(X2) - MOVD F10, 296(X2) - MOVD F11, 304(X2) - MOVD F12, 312(X2) - MOVD F13, 320(X2) - MOVD F14, 328(X2) - MOVD F15, 336(X2) - MOVD F16, 344(X2) - MOVD F17, 352(X2) - MOVD F18, 360(X2) - MOVD F19, 368(X2) - MOVD F20, 376(X2) - MOVD F21, 384(X2) - MOVD F22, 392(X2) - MOVD F23, 400(X2) - MOVD F24, 408(X2) - MOVD F25, 416(X2) - MOVD F26, 424(X2) - MOVD F27, 432(X2) - MOVD F28, 440(X2) - MOVD F29, 448(X2) - MOVD F30, 456(X2) - MOVD F31, 464(X2) + MOV X1, -464(X2) + ADD $-464, X2 + MOV X5, 8(X2) + MOV X6, 16(X2) + MOV X7, 24(X2) + MOV X8, 32(X2) + MOV X9, 40(X2) + MOV X10, 48(X2) + MOV X11, 56(X2) + MOV X12, 64(X2) + MOV X13, 72(X2) + MOV X14, 80(X2) + MOV X15, 88(X2) + MOV X16, 96(X2) + MOV X17, 104(X2) + MOV X18, 112(X2) + MOV X19, 120(X2) + MOV X20, 128(X2) + MOV X21, 136(X2) + MOV X22, 144(X2) + MOV X23, 152(X2) + MOV X24, 160(X2) + MOV X25, 168(X2) + MOV X26, 176(X2) + MOV X28, 184(X2) + MOV X29, 192(X2) + MOV X30, 200(X2) + MOVD F0, 208(X2) + MOVD F1, 216(X2) + MOVD F2, 224(X2) + MOVD F3, 232(X2) + MOVD F4, 240(X2) + MOVD F5, 248(X2) + MOVD F6, 256(X2) + MOVD F7, 264(X2) + MOVD F8, 272(X2) + MOVD F9, 280(X2) + MOVD F10, 288(X2) + MOVD F11, 296(X2) + MOVD F12, 304(X2) + MOVD F13, 312(X2) + MOVD F14, 320(X2) + MOVD F15, 328(X2) + MOVD F16, 336(X2) + MOVD F17, 344(X2) + MOVD F18, 352(X2) + MOVD F19, 360(X2) + MOVD F20, 368(X2) + MOVD F21, 376(X2) + MOVD F22, 384(X2) + MOVD F23, 392(X2) + MOVD F24, 400(X2) + MOVD F25, 408(X2) + MOVD F26, 416(X2) + MOVD F27, 424(X2) + MOVD F28, 432(X2) + MOVD F29, 440(X2) + MOVD F30, 448(X2) + MOVD F31, 456(X2) CALL ·asyncPreempt2(SB) - MOVD 464(X2), F31 - MOVD 456(X2), F30 - MOVD 448(X2), F29 - MOVD 440(X2), F28 - MOVD 432(X2), F27 - MOVD 424(X2), F26 - MOVD 416(X2), F25 - MOVD 408(X2), F24 - MOVD 400(X2), F23 - MOVD 392(X2), F22 - MOVD 384(X2), F21 - MOVD 376(X2), F20 - MOVD 368(X2), F19 - MOVD 360(X2), F18 - MOVD 352(X2), F17 - MOVD 344(X2), F16 - MOVD 336(X2), F15 - MOVD 328(X2), F14 - MOVD 320(X2), F13 - MOVD 312(X2), F12 - MOVD 304(X2), F11 - MOVD 296(X2), F10 - MOVD 288(X2), F9 - MOVD 280(X2), F8 - MOVD 272(X2), F7 - MOVD 264(X2), F6 - MOVD 256(X2), F5 - MOVD 248(X2), F4 - MOVD 240(X2), F3 - MOVD 232(X2), F2 - MOVD 224(X2), F1 - MOVD 216(X2), F0 - MOV 208(X2), X30 - MOV 200(X2), X29 - MOV 192(X2), X28 - MOV 184(X2), X26 - MOV 176(X2), X25 - MOV 168(X2), X24 - MOV 160(X2), X23 - MOV 152(X2), X22 - MOV 144(X2), X21 - MOV 136(X2), X20 - MOV 128(X2), X19 - MOV 120(X2), X18 - MOV 112(X2), X17 - MOV 104(X2), X16 - MOV 96(X2), X15 - MOV 88(X2), X14 - MOV 80(X2), X13 - MOV 72(X2), X12 - MOV 64(X2), X11 - MOV 56(X2), X10 - MOV 48(X2), X9 - MOV 40(X2), X8 - MOV 32(X2), X7 - MOV 24(X2), X6 - MOV 16(X2), X5 - MOV 8(X2), X3 - MOV 472(X2), X1 + MOVD 456(X2), F31 + MOVD 448(X2), F30 + MOVD 440(X2), F29 + MOVD 432(X2), F28 + MOVD 424(X2), F27 + MOVD 416(X2), F26 + MOVD 408(X2), F25 + MOVD 400(X2), F24 + MOVD 392(X2), F23 + MOVD 384(X2), F22 + MOVD 376(X2), F21 + MOVD 368(X2), F20 + MOVD 360(X2), F19 + MOVD 352(X2), F18 + MOVD 344(X2), F17 + MOVD 336(X2), F16 + MOVD 328(X2), F15 + MOVD 320(X2), F14 + MOVD 312(X2), F13 + MOVD 304(X2), F12 + MOVD 296(X2), F11 + MOVD 288(X2), F10 + MOVD 280(X2), F9 + MOVD 272(X2), F8 + MOVD 264(X2), F7 + MOVD 256(X2), F6 + MOVD 248(X2), F5 + MOVD 240(X2), F4 + MOVD 232(X2), F3 + MOVD 224(X2), F2 + MOVD 216(X2), F1 + MOVD 208(X2), F0 + MOV 200(X2), X30 + MOV 192(X2), X29 + MOV 184(X2), X28 + MOV 176(X2), X26 + MOV 168(X2), X25 + MOV 160(X2), X24 + MOV 152(X2), X23 + MOV 144(X2), X22 + MOV 136(X2), X21 + MOV 128(X2), X20 + MOV 120(X2), X19 + MOV 112(X2), X18 + MOV 104(X2), X17 + MOV 96(X2), X16 + MOV 88(X2), X15 + MOV 80(X2), X14 + MOV 72(X2), X13 + MOV 64(X2), X12 + MOV 56(X2), X11 + MOV 48(X2), X10 + MOV 40(X2), X9 + MOV 32(X2), X8 + MOV 24(X2), X7 + MOV 16(X2), X6 + MOV 8(X2), X5 + MOV 464(X2), X1 MOV (X2), X31 - ADD $480, X2 + ADD $472, X2 JMP (X31) diff --git a/src/runtime/tls_riscv64.s b/src/runtime/tls_riscv64.s index 22b550b761..397919aeba 100644 --- a/src/runtime/tls_riscv64.s +++ b/src/runtime/tls_riscv64.s @@ -15,7 +15,7 @@ TEXT runtime·save_g(SB),NOSPLIT|NOFRAME,$0-0 BEQ X0, X31, nocgo MOV runtime·tls_g(SB), X31 - ADD X4, X31 // add offset to thread pointer (X4) + ADD TP, X31 // add offset to thread pointer (X4) MOV g, (X31) nocgo: @@ -23,7 +23,7 @@ nocgo: TEXT runtime·load_g(SB),NOSPLIT|NOFRAME,$0-0 MOV runtime·tls_g(SB), X31 - ADD X4, X31 // add offset to thread pointer (X4) + ADD TP, X31 // add offset to thread pointer (X4) MOV (X31), g RET From 6458b2e8db7c4529248934f7e491df02d1e89318 Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Fri, 16 Jul 2021 03:06:18 +1000 Subject: [PATCH 338/406] all: add support for c-archive and c-shared on linux/riscv64 This provides the runtime glue (_rt0_riscv64_linux_lib) for c-archive and c-shared support, along with enabling both of these buildmodes on linux/riscv64. Both misc/cgo/testcarchive and misc/cgo/testcshared now pass on this platform. Fixes #47100 Change-Id: I7ad75b23ae1d592dbac60d15bba557668287711f Reviewed-on: https://go-review.googlesource.com/c/go/+/334872 Trust: Joel Sing Run-TryBot: Joel Sing Reviewed-by: Cherry Mui --- misc/cgo/testcshared/testdata/libgo2/dup2.go | 2 +- misc/cgo/testcshared/testdata/libgo2/dup3.go | 2 +- src/cmd/compile/internal/ssa/regalloc.go | 2 + src/cmd/dist/test.go | 4 +- src/cmd/internal/sys/supported.go | 2 +- src/cmd/link/internal/ld/config.go | 2 +- src/runtime/rt0_linux_riscv64.s | 98 ++++++++++++++++++++ 7 files changed, 106 insertions(+), 6 deletions(-) diff --git a/misc/cgo/testcshared/testdata/libgo2/dup2.go b/misc/cgo/testcshared/testdata/libgo2/dup2.go index d18f0b130d..d343aa54d9 100644 --- a/misc/cgo/testcshared/testdata/libgo2/dup2.go +++ b/misc/cgo/testcshared/testdata/libgo2/dup2.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. -// +build darwin dragonfly freebsd linux,!arm64 netbsd openbsd +// +build darwin dragonfly freebsd linux,!arm64,!riscv64 netbsd openbsd package main diff --git a/misc/cgo/testcshared/testdata/libgo2/dup3.go b/misc/cgo/testcshared/testdata/libgo2/dup3.go index c9c65a6e3c..459f0dc196 100644 --- a/misc/cgo/testcshared/testdata/libgo2/dup3.go +++ b/misc/cgo/testcshared/testdata/libgo2/dup3.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. -// +build linux,arm64 +// +build linux,arm64 linux,riscv64 package main diff --git a/src/cmd/compile/internal/ssa/regalloc.go b/src/cmd/compile/internal/ssa/regalloc.go index 91b04e99f4..64792d0c80 100644 --- a/src/cmd/compile/internal/ssa/regalloc.go +++ b/src/cmd/compile/internal/ssa/regalloc.go @@ -635,6 +635,8 @@ func (s *regAllocState) init(f *Func) { // nothing to do case "ppc64le": // R2 already reserved. // nothing to do + case "riscv64": // X3 (aka GP) and X4 (aka TP) already reserved. + // nothing to do case "s390x": s.allocatable &^= 1 << 11 // R11 default: diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index 5935011e19..14b48351db 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -1031,7 +1031,7 @@ func (t *tester) supportedBuildmode(mode string) bool { switch pair { case "aix-ppc64", "darwin-amd64", "darwin-arm64", "ios-arm64", - "linux-amd64", "linux-386", "linux-ppc64le", "linux-s390x", + "linux-amd64", "linux-386", "linux-ppc64le", "linux-riscv64", "linux-s390x", "freebsd-amd64", "windows-amd64", "windows-386": return true @@ -1039,7 +1039,7 @@ func (t *tester) supportedBuildmode(mode string) bool { return false case "c-shared": switch pair { - case "linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-s390x", + case "linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-riscv64", "linux-s390x", "darwin-amd64", "darwin-arm64", "freebsd-amd64", "android-arm", "android-arm64", "android-386", diff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go index de2a3fd140..c6a78a51eb 100644 --- a/src/cmd/internal/sys/supported.go +++ b/src/cmd/internal/sys/supported.go @@ -105,7 +105,7 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool { case "c-shared": switch platform { - case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/ppc64le", "linux/s390x", + case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/ppc64le", "linux/riscv64", "linux/s390x", "android/amd64", "android/arm", "android/arm64", "android/386", "freebsd/amd64", "darwin/amd64", "darwin/arm64", diff --git a/src/cmd/link/internal/ld/config.go b/src/cmd/link/internal/ld/config.go index 72616ff62f..2d7e1bff68 100644 --- a/src/cmd/link/internal/ld/config.go +++ b/src/cmd/link/internal/ld/config.go @@ -74,7 +74,7 @@ func (mode *BuildMode) Set(s string) error { *mode = BuildModeCArchive case "c-shared": switch buildcfg.GOARCH { - case "386", "amd64", "arm", "arm64", "ppc64le", "s390x": + case "386", "amd64", "arm", "arm64", "ppc64le", "riscv64", "s390x": default: return badmode() } diff --git a/src/runtime/rt0_linux_riscv64.s b/src/runtime/rt0_linux_riscv64.s index f31f7f75e5..d6b8ac85dc 100644 --- a/src/runtime/rt0_linux_riscv64.s +++ b/src/runtime/rt0_linux_riscv64.s @@ -9,6 +9,104 @@ TEXT _rt0_riscv64_linux(SB),NOSPLIT|NOFRAME,$0 ADD $8, X2, A1 // argv JMP main(SB) +// When building with -buildmode=c-shared, this symbol is called when the shared +// library is loaded. +TEXT _rt0_riscv64_linux_lib(SB),NOSPLIT,$224 + // Preserve callee-save registers, along with X1 (LR). + MOV X1, (8*3)(X2) + MOV X8, (8*4)(X2) + MOV X9, (8*5)(X2) + MOV X18, (8*6)(X2) + MOV X19, (8*7)(X2) + MOV X20, (8*8)(X2) + MOV X21, (8*9)(X2) + MOV X22, (8*10)(X2) + MOV X23, (8*11)(X2) + MOV X24, (8*12)(X2) + MOV X25, (8*13)(X2) + MOV X26, (8*14)(X2) + MOV g, (8*15)(X2) + MOVD F8, (8*16)(X2) + MOVD F9, (8*17)(X2) + MOVD F18, (8*18)(X2) + MOVD F19, (8*19)(X2) + MOVD F20, (8*20)(X2) + MOVD F21, (8*21)(X2) + MOVD F22, (8*22)(X2) + MOVD F23, (8*23)(X2) + MOVD F24, (8*24)(X2) + MOVD F25, (8*25)(X2) + MOVD F26, (8*26)(X2) + MOVD F27, (8*27)(X2) + + // Initialize g as nil in case of using g later e.g. sigaction in cgo_sigaction.go + MOV X0, g + + MOV A0, _rt0_riscv64_linux_lib_argc<>(SB) + MOV A1, _rt0_riscv64_linux_lib_argv<>(SB) + + // Synchronous initialization. + MOV $runtime·libpreinit(SB), T0 + JALR RA, T0 + + // Create a new thread to do the runtime initialization and return. + MOV _cgo_sys_thread_create(SB), T0 + BEQZ T0, nocgo + MOV $_rt0_riscv64_linux_lib_go(SB), A0 + MOV $0, A1 + JALR RA, T0 + JMP restore + +nocgo: + MOV $0x800000, A0 // stacksize = 8192KB + MOV $_rt0_riscv64_linux_lib_go(SB), A1 + MOV A0, 8(X2) + MOV A1, 16(X2) + MOV $runtime·newosproc0(SB), T0 + JALR RA, T0 + +restore: + // Restore callee-save registers, along with X1 (LR). + MOV (8*3)(X2), X1 + MOV (8*4)(X2), X8 + MOV (8*5)(X2), X9 + MOV (8*6)(X2), X18 + MOV (8*7)(X2), X19 + MOV (8*8)(X2), X20 + MOV (8*9)(X2), X21 + MOV (8*10)(X2), X22 + MOV (8*11)(X2), X23 + MOV (8*12)(X2), X24 + MOV (8*13)(X2), X25 + MOV (8*14)(X2), X26 + MOV (8*15)(X2), g + MOVD (8*16)(X2), F8 + MOVD (8*17)(X2), F9 + MOVD (8*18)(X2), F18 + MOVD (8*19)(X2), F19 + MOVD (8*20)(X2), F20 + MOVD (8*21)(X2), F21 + MOVD (8*22)(X2), F22 + MOVD (8*23)(X2), F23 + MOVD (8*24)(X2), F24 + MOVD (8*25)(X2), F25 + MOVD (8*26)(X2), F26 + MOVD (8*27)(X2), F27 + + RET + +TEXT _rt0_riscv64_linux_lib_go(SB),NOSPLIT,$0 + MOV _rt0_riscv64_linux_lib_argc<>(SB), A0 + MOV _rt0_riscv64_linux_lib_argv<>(SB), A1 + MOV $runtime·rt0_go(SB), T0 + JALR ZERO, T0 + +DATA _rt0_riscv64_linux_lib_argc<>(SB)/8, $0 +GLOBL _rt0_riscv64_linux_lib_argc<>(SB),NOPTR, $8 +DATA _rt0_riscv64_linux_lib_argv<>(SB)/8, $0 +GLOBL _rt0_riscv64_linux_lib_argv<>(SB),NOPTR, $8 + + TEXT main(SB),NOSPLIT|NOFRAME,$0 MOV $runtime·rt0_go(SB), T0 JALR ZERO, T0 From c143661568dc23badd4ba04f4193658fc1fd9c33 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Tue, 2 Nov 2021 20:42:21 -0700 Subject: [PATCH 339/406] test/typeparam: add test for indexing on typeparams with various constraints Add test for indexing on variables whose types are constrained to various kinds of types. Change-Id: I991eecfe39dba5d817c0fbe259ba558d4881ea84 Reviewed-on: https://go-review.googlesource.com/c/go/+/360867 Trust: Dan Scales Run-TryBot: Dan Scales TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- test/typeparam/index2.go | 67 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 test/typeparam/index2.go diff --git a/test/typeparam/index2.go b/test/typeparam/index2.go new file mode 100644 index 0000000000..683b76f76d --- /dev/null +++ b/test/typeparam/index2.go @@ -0,0 +1,67 @@ +// run -gcflags=-G=3 + +// Copyright 2021 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. + +// Testing various generic uses of indexing, both for reads and writes. + +package main + +import "fmt" + +// Can index an argument (read/write) constrained to be a slice or an array. +func Index1[T interface{ []int64 | [5]int64 }](x T) int64 { + x[2] = 5 + return x[3] +} + +// Can index an argument (read) constrained to be a byte array or a string. +func Index2[T interface{ []byte | string }](x T) byte { + return x[3] +} + +// Can index an argument (write) constrained to be a byte array, but not a string. +func Index2a[T interface{ []byte }](x T) byte { + x[2] = 'b' + return x[3] +} + +// Can index an argument (read/write) constrained to be a map. Maps can't +// be combined with any other type for indexing purposes. +func Index3[T interface{ map[int]int64 }](x T) int64 { + x[2] = 43 + return x[3] +} + +// But the type of the map keys or values can be parameterized. +func Index4[T any](x map[int]T) T { + var zero T + x[2] = zero + return x[3] +} + +func test[T comparable](got, want T) { + if got != want { + panic(fmt.Sprintf("got %v, want %v", got, want)) + } +} + +func main() { + x := make([]int64, 4) + x[3] = 2 + y := [5]int64{1, 2, 3, 4, 5} + z := "abcd" + w := make([]byte, 4) + w[3] = 5 + v := make(map[int]int64) + v[3] = 18 + + test(Index1(x), int64(2)) + test(Index1(y), int64(4)) + test(Index2(z), byte(100)) + test(Index2(w), byte(5)) + test(Index2a(w), byte(5)) + test(Index3(v), int64(18)) + test(Index4(v), int64(18)) +} From 5f0e5d21bb1f2c1baf15bfd90ad5b090b88e6292 Mon Sep 17 00:00:00 2001 From: Rhys Hiltner Date: Fri, 29 Oct 2021 17:35:30 -0700 Subject: [PATCH 340/406] runtime/pprof: disable GC during calibration test TestCPUProfileMultithreadMagnitude compares Go's CPU profile against the OS's accounting of the process's execution time, expecting them to be near equal. Background work from the runtime (especially in the garbage collector) can add significant noise to that measurement and flakiness to the test. Disable automatic GC cycles during the test. Updates #49065 Change-Id: Ie88895bfea17374278c5187f3a83e9f486bd37fb Reviewed-on: https://go-review.googlesource.com/c/go/+/359934 Reviewed-by: Michael Pratt Trust: Michael Pratt Trust: Michael Knyszek --- src/runtime/pprof/pprof_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index 06e0274e9a..417d5034a6 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -20,6 +20,7 @@ import ( "os/exec" "regexp" "runtime" + "runtime/debug" "strings" "sync" "sync/atomic" @@ -133,6 +134,14 @@ func TestCPUProfileMultithreadMagnitude(t *testing.T) { parallelism := runtime.GOMAXPROCS(0) + // This test compares the process's total CPU time against the CPU + // profiler's view of time spent in direct execution of user code. + // Background work, especially from the garbage collector, adds noise to + // that measurement. Disable automatic triggering of the GC, and then + // request a complete GC cycle (up through sweep termination). + defer debug.SetGCPercent(debug.SetGCPercent(-1)) + runtime.GC() + var cpuTime1, cpuTimeN time.Duration p := testCPUProfile(t, stackContains, []string{"runtime/pprof.cpuHog1", "runtime/pprof.cpuHog3"}, avoidFunctions(), func(dur time.Duration) { cpuTime1 = diffCPUTime(t, func() { From e0e6e4d23fe840c2c9b4caed30930cad6788b797 Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Wed, 3 Nov 2021 10:58:59 -0400 Subject: [PATCH 341/406] internal/fuzz: improve error for mismatched types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #48635 Change-Id: Ia3cde119d5eb31bc771fe3a39acb2372dbd988ff Reviewed-on: https://go-review.googlesource.com/c/go/+/361114 Trust: Katie Hockman Trust: Daniel Martí Run-TryBot: Katie Hockman Reviewed-by: Daniel Martí Reviewed-by: Bryan C. Mills --- src/cmd/go/testdata/script/test_fuzz.txt | 5 +++-- src/internal/fuzz/fuzz.go | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/cmd/go/testdata/script/test_fuzz.txt b/src/cmd/go/testdata/script/test_fuzz.txt index 020012d73e..150491be04 100644 --- a/src/cmd/go/testdata/script/test_fuzz.txt +++ b/src/cmd/go/testdata/script/test_fuzz.txt @@ -152,6 +152,7 @@ stdout FAIL # Test that the wrong type given with f.Add will fail. ! go test -run FuzzWrongType fuzz_add_test.go ! stdout ^ok +stdout '\[string int\], want \[\[\]uint8 int8\]' stdout FAIL # Test fatal with testdata seed corpus @@ -435,8 +436,8 @@ func FuzzAddDifferentType(f *testing.F) { } func FuzzWrongType(f *testing.F) { - f.Add("hello") - f.Fuzz(func(*testing.T, []byte) {}) + f.Add("hello", 50) + f.Fuzz(func(*testing.T, []byte, int8) {}) } -- corpustesting/fuzz_testdata_corpus_test.go -- diff --git a/src/internal/fuzz/fuzz.go b/src/internal/fuzz/fuzz.go index 2ebe2a64db..aef1dee978 100644 --- a/src/internal/fuzz/fuzz.go +++ b/src/internal/fuzz/fuzz.go @@ -997,11 +997,15 @@ func readCorpusData(data []byte, types []reflect.Type) ([]interface{}, error) { // provided. func CheckCorpus(vals []interface{}, types []reflect.Type) error { if len(vals) != len(types) { - return fmt.Errorf("wrong number of values in corpus entry %v: want %v", vals, types) + return fmt.Errorf("wrong number of values in corpus entry: %d, want %d", len(vals), len(types)) + } + valsT := make([]reflect.Type, len(vals)) + for valsI, v := range vals { + valsT[valsI] = reflect.TypeOf(v) } for i := range types { - if reflect.TypeOf(vals[i]) != types[i] { - return fmt.Errorf("mismatched types in corpus entry: %v, want %v", vals, types) + if valsT[i] != types[i] { + return fmt.Errorf("mismatched types in corpus entry: %v, want %v", valsT, types) } } return nil From d4e0e8e4a41e5e1e7d0359287a1015791ce778ed Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Wed, 3 Nov 2021 09:40:32 -0700 Subject: [PATCH 342/406] cmd/compile: make pointers to arrays their own shape Pointers to arrays can be used to cast from a slice. We need the shape of such type params to be different so we can compile those casts correctly. This is kind of a big hammer to fix #49295. It would be nice to only do this when we know there's a []T->*[N]T conversion. Fixes #49295 Change-Id: Ibda33057fab2dd28162537aab0f1244211d68e3f Reviewed-on: https://go-review.googlesource.com/c/go/+/361135 Trust: Keith Randall Trust: Dan Scales Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/typecheck/subr.go | 4 ++- test/typeparam/issue49295.go | 30 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test/typeparam/issue49295.go diff --git a/src/cmd/compile/internal/typecheck/subr.go b/src/cmd/compile/internal/typecheck/subr.go index 96e120fe03..1986845f64 100644 --- a/src/cmd/compile/internal/typecheck/subr.go +++ b/src/cmd/compile/internal/typecheck/subr.go @@ -1421,7 +1421,9 @@ func Shapify(t *types.Type, index int) *types.Type { // All pointers have the same shape. // TODO: Make unsafe.Pointer the same shape as normal pointers. - if u.Kind() == types.TPTR { + // Note: pointers to arrays are special because of slice-to-array-pointer + // conversions. See issue 49295. + if u.Kind() == types.TPTR && u.Elem().Kind() != types.TARRAY { u = types.Types[types.TUINT8].PtrTo() } diff --git a/test/typeparam/issue49295.go b/test/typeparam/issue49295.go new file mode 100644 index 0000000000..435b44d10c --- /dev/null +++ b/test/typeparam/issue49295.go @@ -0,0 +1,30 @@ +// run -gcflags=-G=3 + +// Copyright 2021 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 main + +import "io" + +type Reader struct { + buf []byte +} +type Token *[16]byte + +func Read[T interface{ ~*[16]byte }](r *Reader) (t T, err error) { + if n := len(t); len(r.buf) >= n { + t = T(r.buf[:n]) + r.buf = r.buf[n:] + return + } + err = io.EOF + return +} + +func main() { + r := &Reader{buf: []byte("0123456789abcdef")} + token, err := Read[Token](r) + _, _ = token, err +} From cfd016df1fba2a2a104f4cca705aa4357777986b Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 3 Nov 2021 18:19:04 +0100 Subject: [PATCH 343/406] runtime: on windows, read nanotime with one instruction or issue barrier On 64-bit, this is more efficient, and on ARM64, this prevents the time from moving backwards due to the weaker memory model. On ARM32 due to the weaker memory model, we issue a memory barrier. Updates #48072. Change-Id: If4695716c3039d8af14e14808af217f5c99fc93a Reviewed-on: https://go-review.googlesource.com/c/go/+/361057 Trust: Jason A. Donenfeld Run-TryBot: Jason A. Donenfeld TryBot-Result: Go Bot Reviewed-by: Austin Clements --- src/runtime/sys_windows_amd64.s | 13 +++---------- src/runtime/sys_windows_arm.s | 2 ++ src/runtime/sys_windows_arm64.s | 10 +--------- src/runtime/time_windows.h | 1 + src/runtime/time_windows_amd64.s | 19 +++---------------- src/runtime/time_windows_arm.s | 4 ++++ src/runtime/time_windows_arm64.s | 22 +++------------------- 7 files changed, 17 insertions(+), 54 deletions(-) diff --git a/src/runtime/sys_windows_amd64.s b/src/runtime/sys_windows_amd64.s index 1e4c1d2b61..1467b4d57b 100644 --- a/src/runtime/sys_windows_amd64.s +++ b/src/runtime/sys_windows_amd64.s @@ -344,16 +344,9 @@ TEXT runtime·nanotime1(SB),NOSPLIT,$0-8 CMPB runtime·useQPCTime(SB), $0 JNE useQPC MOVQ $_INTERRUPT_TIME, DI -loop: - MOVL time_hi1(DI), AX - MOVL time_lo(DI), BX - MOVL time_hi2(DI), CX - CMPL AX, CX - JNE loop - SHLQ $32, CX - ORQ BX, CX - IMULQ $100, CX - MOVQ CX, ret+0(FP) + MOVQ time_lo(DI), AX + IMULQ $100, AX + MOVQ AX, ret+0(FP) RET useQPC: JMP runtime·nanotimeQPC(SB) diff --git a/src/runtime/sys_windows_arm.s b/src/runtime/sys_windows_arm.s index c9e96cb652..e5b1b7e9f3 100644 --- a/src/runtime/sys_windows_arm.s +++ b/src/runtime/sys_windows_arm.s @@ -350,7 +350,9 @@ TEXT runtime·nanotime1(SB),NOSPLIT|NOFRAME,$0-8 MOVW $_INTERRUPT_TIME, R3 loop: MOVW time_hi1(R3), R1 + DMB MB_ISH MOVW time_lo(R3), R0 + DMB MB_ISH MOVW time_hi2(R3), R2 CMP R1, R2 BNE loop diff --git a/src/runtime/sys_windows_arm64.s b/src/runtime/sys_windows_arm64.s index 44145c53fb..87f8f0d218 100644 --- a/src/runtime/sys_windows_arm64.s +++ b/src/runtime/sys_windows_arm64.s @@ -415,15 +415,7 @@ TEXT runtime·nanotime1(SB),NOSPLIT|NOFRAME,$0-8 CMP $0, R0 BNE useQPC MOVD $_INTERRUPT_TIME, R3 -loop: - MOVWU time_hi1(R3), R1 - MOVWU time_lo(R3), R0 - MOVWU time_hi2(R3), R2 - CMP R1, R2 - BNE loop - - // wintime = R1:R0, multiply by 100 - ORR R1<<32, R0 + MOVD time_lo(R3), R0 MOVD $100, R1 MUL R1, R0 MOVD R0, ret+0(FP) diff --git a/src/runtime/time_windows.h b/src/runtime/time_windows.h index cd16fd163b..7c2e65c328 100644 --- a/src/runtime/time_windows.h +++ b/src/runtime/time_windows.h @@ -9,6 +9,7 @@ // http://web.archive.org/web/20210411000829/https://wrkhpi.wordpress.com/2007/08/09/getting-os-information-the-kuser_shared_data-structure/ // Must read hi1, then lo, then hi2. The snapshot is valid if hi1 == hi2. +// Or, on 64-bit, just read lo:hi1 all at once atomically. #define _INTERRUPT_TIME 0x7ffe0008 #define _SYSTEM_TIME 0x7ffe0014 #define time_lo 0 diff --git a/src/runtime/time_windows_amd64.s b/src/runtime/time_windows_amd64.s index 93ab960b06..045f64eb46 100644 --- a/src/runtime/time_windows_amd64.s +++ b/src/runtime/time_windows_amd64.s @@ -12,27 +12,14 @@ TEXT time·now(SB),NOSPLIT,$0-24 CMPB runtime·useQPCTime(SB), $0 JNE useQPC + MOVQ $_INTERRUPT_TIME, DI -loop: - MOVL time_hi1(DI), AX - MOVL time_lo(DI), BX - MOVL time_hi2(DI), CX - CMPL AX, CX - JNE loop - SHLQ $32, AX - ORQ BX, AX + MOVQ time_lo(DI), AX IMULQ $100, AX MOVQ AX, mono+16(FP) MOVQ $_SYSTEM_TIME, DI -wall: - MOVL time_hi1(DI), AX - MOVL time_lo(DI), BX - MOVL time_hi2(DI), CX - CMPL AX, CX - JNE wall - SHLQ $32, AX - ORQ BX, AX + MOVQ time_lo(DI), AX MOVQ $116444736000000000, DI SUBQ DI, AX IMULQ $100, AX diff --git a/src/runtime/time_windows_arm.s b/src/runtime/time_windows_arm.s index 7c763b66ed..6552d75ff1 100644 --- a/src/runtime/time_windows_arm.s +++ b/src/runtime/time_windows_arm.s @@ -17,7 +17,9 @@ TEXT time·now(SB),NOSPLIT|NOFRAME,$0-20 MOVW $_INTERRUPT_TIME, R3 loop: MOVW time_hi1(R3), R1 + DMB MB_ISH MOVW time_lo(R3), R0 + DMB MB_ISH MOVW time_hi2(R3), R2 CMP R1, R2 BNE loop @@ -34,7 +36,9 @@ loop: MOVW $_SYSTEM_TIME, R3 wall: MOVW time_hi1(R3), R1 + DMB MB_ISH MOVW time_lo(R3), R0 + DMB MB_ISH MOVW time_hi2(R3), R2 CMP R1, R2 BNE wall diff --git a/src/runtime/time_windows_arm64.s b/src/runtime/time_windows_arm64.s index ef52ce4c99..e8a0eb2f93 100644 --- a/src/runtime/time_windows_arm64.s +++ b/src/runtime/time_windows_arm64.s @@ -13,34 +13,18 @@ TEXT time·now(SB),NOSPLIT|NOFRAME,$0-24 MOVB runtime·useQPCTime(SB), R0 CMP $0, R0 BNE useQPC - MOVD $_INTERRUPT_TIME, R3 -loop: - MOVWU time_hi1(R3), R1 - MOVWU time_lo(R3), R0 - MOVWU time_hi2(R3), R2 - CMP R1, R2 - BNE loop - // wintime = R1:R0, multiply by 100 - ORR R1<<32, R0 + MOVD $_INTERRUPT_TIME, R3 + MOVD time_lo(R3), R0 MOVD $100, R1 MUL R1, R0 MOVD R0, mono+16(FP) MOVD $_SYSTEM_TIME, R3 -wall: - MOVWU time_hi1(R3), R1 - MOVWU time_lo(R3), R0 - MOVWU time_hi2(R3), R2 - CMP R1, R2 - BNE wall - - // w = R1:R0 in 100ns units + MOVD time_lo(R3), R0 // convert to Unix epoch (but still 100ns units) #define delta 116444736000000000 - ORR R1<<32, R0 SUB $delta, R0 - // Convert to nSec MOVD $100, R1 MUL R1, R0 From 74f99d0933d5c201fc17d90ab612cd1a9c7d425f Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Tue, 9 Jun 2020 08:58:08 +0100 Subject: [PATCH 344/406] database/sql: Fix idle connection reuse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix idle connection reuse so that ConnMaxIdleTime clears down excessive idle connections. This now ensures that db.freeConn is ordered by returnedAt and that connections that have been idle for the shortest period are reused first. In addition connectionCleanerRunLocked updates the next check deadline based on idle and maximum life time information so that we avoid waiting up to double MaxIdleTime to close connections. Corrected the calling timer of connectionCleaner. Fixes #39471 Change-Id: I6d26b3542179ef35aa13e5265a89bc0f08ba7fa1 Reviewed-on: https://go-review.googlesource.com/c/go/+/237337 Reviewed-by: Tamás Gulácsi Reviewed-by: Daniel Theophanes Trust: Ian Lance Taylor --- src/database/sql/sql.go | 88 +++++++++++++++++++++++------------ src/database/sql/sql_test.go | 89 +++++++++++++++++++++++++++++------- 2 files changed, 132 insertions(+), 45 deletions(-) diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go index b40b5c8fe4..e4a5a225b0 100644 --- a/src/database/sql/sql.go +++ b/src/database/sql/sql.go @@ -464,8 +464,8 @@ type DB struct { // connections in Stmt.css. numClosed uint64 - mu sync.Mutex // protects following fields - freeConn []*driverConn + mu sync.Mutex // protects following fields + freeConn []*driverConn // free connections ordered by returnedAt oldest to newest connRequests map[uint64]chan connRequest nextRequest uint64 // Next key to use in connRequests. numOpen int // number of opened and pending open connections @@ -1079,7 +1079,7 @@ func (db *DB) connectionCleaner(d time.Duration) { return } - closing := db.connectionCleanerRunLocked() + d, closing := db.connectionCleanerRunLocked(d) db.mu.Unlock() for _, c := range closing { c.Close() @@ -1088,45 +1088,74 @@ func (db *DB) connectionCleaner(d time.Duration) { if d < minInterval { d = minInterval } + + if !t.Stop() { + select { + case <-t.C: + default: + } + } t.Reset(d) } } -func (db *DB) connectionCleanerRunLocked() (closing []*driverConn) { +// connectionCleanerRunLocked removes connections that should be closed from +// freeConn and returns them along side an updated duration to the next check +// if a quicker check is required to ensure connections are checked appropriately. +func (db *DB) connectionCleanerRunLocked(d time.Duration) (time.Duration, []*driverConn) { + var idleClosing int64 + var closing []*driverConn + if db.maxIdleTime > 0 { + // As freeConn is ordered by returnedAt process + // in reverse order to minimise the work needed. + idleSince := nowFunc().Add(-db.maxIdleTime) + last := len(db.freeConn) - 1 + for i := last; i >= 0; i-- { + c := db.freeConn[i] + if c.returnedAt.Before(idleSince) { + i++ + closing = db.freeConn[:i] + db.freeConn = db.freeConn[i:] + idleClosing = int64(len(closing)) + db.maxIdleTimeClosed += idleClosing + break + } + } + + if len(db.freeConn) > 0 { + c := db.freeConn[0] + if d2 := c.returnedAt.Sub(idleSince); d2 < d { + // Ensure idle connections are cleaned up as soon as + // possible. + d = d2 + } + } + } + if db.maxLifetime > 0 { expiredSince := nowFunc().Add(-db.maxLifetime) for i := 0; i < len(db.freeConn); i++ { c := db.freeConn[i] if c.createdAt.Before(expiredSince) { closing = append(closing, c) + last := len(db.freeConn) - 1 - db.freeConn[i] = db.freeConn[last] + // Use slow delete as order is required to ensure + // connections are reused least idle time first. + copy(db.freeConn[i:], db.freeConn[i+1:]) db.freeConn[last] = nil db.freeConn = db.freeConn[:last] i-- + } else if d2 := c.createdAt.Sub(expiredSince); d2 < d { + // Prevent connections sitting the freeConn when they + // have expired by updating our next deadline d. + d = d2 } } - db.maxLifetimeClosed += int64(len(closing)) + db.maxLifetimeClosed += int64(len(closing)) - idleClosing } - if db.maxIdleTime > 0 { - expiredSince := nowFunc().Add(-db.maxIdleTime) - var expiredCount int64 - for i := 0; i < len(db.freeConn); i++ { - c := db.freeConn[i] - if db.maxIdleTime > 0 && c.returnedAt.Before(expiredSince) { - closing = append(closing, c) - expiredCount++ - last := len(db.freeConn) - 1 - db.freeConn[i] = db.freeConn[last] - db.freeConn[last] = nil - db.freeConn = db.freeConn[:last] - i-- - } - } - db.maxIdleTimeClosed += expiredCount - } - return + return d, closing } // DBStats contains database statistics. @@ -1272,11 +1301,12 @@ func (db *DB) conn(ctx context.Context, strategy connReuseStrategy) (*driverConn lifetime := db.maxLifetime // Prefer a free connection, if possible. - numFree := len(db.freeConn) - if strategy == cachedOrNewConn && numFree > 0 { - conn := db.freeConn[0] - copy(db.freeConn, db.freeConn[1:]) - db.freeConn = db.freeConn[:numFree-1] + last := len(db.freeConn) - 1 + if strategy == cachedOrNewConn && last >= 0 { + // Reuse the lowest idle time connection so we can close + // connections which remain idle as soon as possible. + conn := db.freeConn[last] + db.freeConn = db.freeConn[:last] conn.inUse = true if conn.expired(lifetime) { db.maxLifetimeClosed++ diff --git a/src/database/sql/sql_test.go b/src/database/sql/sql_test.go index f771dee4a9..15c30e0d00 100644 --- a/src/database/sql/sql_test.go +++ b/src/database/sql/sql_test.go @@ -2399,10 +2399,14 @@ func TestConnMaxLifetime(t *testing.T) { tx.Commit() tx2.Commit() - driver.mu.Lock() - opens = driver.openCount - opens0 - closes = driver.closeCount - closes0 - driver.mu.Unlock() + // Give connectionCleaner chance to run. + for i := 0; i < 100 && closes != 1; i++ { + time.Sleep(time.Millisecond) + driver.mu.Lock() + opens = driver.openCount - opens0 + closes = driver.closeCount - closes0 + driver.mu.Unlock() + } if opens != 3 { t.Errorf("opens = %d; want 3", opens) @@ -2410,6 +2414,10 @@ func TestConnMaxLifetime(t *testing.T) { if closes != 1 { t.Errorf("closes = %d; want 1", closes) } + + if s := db.Stats(); s.MaxLifetimeClosed != 1 { + t.Errorf("MaxLifetimeClosed = %d; want 1 %#v", s.MaxLifetimeClosed, s) + } } // golang.org/issue/5323 @@ -3896,14 +3904,48 @@ func TestStatsMaxIdleClosedTen(t *testing.T) { } } +// testUseConns uses count concurrent connections with 1 nanosecond apart. +// Returns the returnedAt time of the final connection. +func testUseConns(t *testing.T, count int, tm time.Time, db *DB) time.Time { + conns := make([]*Conn, count) + ctx := context.Background() + for i := range conns { + c, err := db.Conn(ctx) + if err != nil { + t.Error(err) + } + conns[i] = c + } + + for _, c := range conns { + tm = tm.Add(time.Nanosecond) + nowFunc = func() time.Time { + return tm + } + if err := c.Close(); err != nil { + t.Error(err) + } + } + + return tm +} + func TestMaxIdleTime(t *testing.T) { + usedConns := 5 + reusedConns := 2 list := []struct { wantMaxIdleTime time.Duration + wantNextCheck time.Duration wantIdleClosed int64 timeOffset time.Duration }{ - {time.Nanosecond, 1, 10 * time.Millisecond}, - {time.Hour, 0, 10 * time.Millisecond}, + { + time.Millisecond, + time.Millisecond - time.Nanosecond, + int64(usedConns - reusedConns), + 10 * time.Millisecond, + }, + {time.Hour, time.Second, 0, 10 * time.Millisecond}, } baseTime := time.Unix(0, 0) defer func() { @@ -3917,23 +3959,38 @@ func TestMaxIdleTime(t *testing.T) { db := newTestDB(t, "people") defer closeDB(t, db) - db.SetMaxOpenConns(1) - db.SetMaxIdleConns(1) + db.SetMaxOpenConns(usedConns) + db.SetMaxIdleConns(usedConns) db.SetConnMaxIdleTime(item.wantMaxIdleTime) db.SetConnMaxLifetime(0) preMaxIdleClosed := db.Stats().MaxIdleTimeClosed - if err := db.Ping(); err != nil { - t.Fatal(err) - } + // Busy usedConns. + tm := testUseConns(t, usedConns, baseTime, db) - nowFunc = func() time.Time { - return baseTime.Add(item.timeOffset) - } + tm = baseTime.Add(item.timeOffset) + + // Reuse connections which should never be considered idle + // and exercises the sorting for issue 39471. + testUseConns(t, reusedConns, tm, db) db.mu.Lock() - closing := db.connectionCleanerRunLocked() + nc, closing := db.connectionCleanerRunLocked(time.Second) + if nc != item.wantNextCheck { + t.Errorf("got %v; want %v next check duration", nc, item.wantNextCheck) + } + + // Validate freeConn order. + var last time.Time + for _, c := range db.freeConn { + if last.After(c.returnedAt) { + t.Error("freeConn is not ordered by returnedAt") + break + } + last = c.returnedAt + } + db.mu.Unlock() for _, c := range closing { c.Close() @@ -3945,7 +4002,7 @@ func TestMaxIdleTime(t *testing.T) { st := db.Stats() maxIdleClosed := st.MaxIdleTimeClosed - preMaxIdleClosed if g, w := maxIdleClosed, item.wantIdleClosed; g != w { - t.Errorf(" got: %d; want %d max idle closed conns", g, w) + t.Errorf("got: %d; want %d max idle closed conns", g, w) } }) } From 7f2463cc363fe8dbcbb89d521d1ede650de86c9b Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Wed, 3 Nov 2021 11:26:37 -0700 Subject: [PATCH 345/406] cmd/compile: fix up shape type package Use go.shape instead of .shape as the package the compiler uses to store shape types. Prevent path escaping for compiler-internal types, so we don't need to see %2e everywhere. Change-Id: I98e39c3b6472560113bdea7e0ba6eb7b81cb35e0 Reviewed-on: https://go-review.googlesource.com/c/go/+/361174 Trust: Keith Randall Trust: Dan Scales Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/types/pkg.go | 9 ++++++++- src/cmd/compile/internal/types/type.go | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/types/pkg.go b/src/cmd/compile/internal/types/pkg.go index f63a357f0d..fe42049cee 100644 --- a/src/cmd/compile/internal/types/pkg.go +++ b/src/cmd/compile/internal/types/pkg.go @@ -9,6 +9,7 @@ import ( "cmd/internal/objabi" "fmt" "sort" + "strings" "sync" ) @@ -48,7 +49,13 @@ func NewPkg(path, name string) *Pkg { p := new(Pkg) p.Path = path p.Name = name - p.Prefix = objabi.PathToPrefix(path) + if strings.HasPrefix(path, "go.") { + // Special compiler-internal packages don't need to be escaped. + // This particularly helps with the go.shape package. + p.Prefix = path + } else { + p.Prefix = objabi.PathToPrefix(path) + } p.Syms = make(map[string]*Sym) pkgMap[path] = p diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go index c3efbc9f07..6288df30d6 100644 --- a/src/cmd/compile/internal/types/type.go +++ b/src/cmd/compile/internal/types/type.go @@ -2202,4 +2202,4 @@ var ( var SimType [NTYPE]Kind -var ShapePkg = NewPkg(".shape", ".shape") +var ShapePkg = NewPkg("go.shape", "go.shape") From d3f5dd57811ca6c55654e67c58cf594fc2e5091e Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 3 Nov 2021 13:43:12 -0700 Subject: [PATCH 346/406] syscall: migrate new UDP send/recv API to internal/syscall/unix CL 331490 and friends added new API to package syscall. This was a mistake that we need to fix before Go 1.18 is released. Change-Id: I697c9a4fa649d564822f585dc163df5ab9e5ae08 Reviewed-on: https://go-review.googlesource.com/c/go/+/361216 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- api/next.txt | 108 -------------------- src/internal/poll/fd_unix.go | 9 +- src/internal/poll/fd_windows.go | 4 +- src/internal/syscall/unix/net.go | 28 +++++ src/internal/syscall/unix/net_js.go | 28 +++++ src/internal/syscall/windows/net_windows.go | 18 ++++ src/syscall/net_js.go | 16 --- src/syscall/syscall_unix.go | 8 +- src/syscall/syscall_windows.go | 4 +- 9 files changed, 87 insertions(+), 136 deletions(-) create mode 100644 src/internal/syscall/unix/net.go create mode 100644 src/internal/syscall/unix/net_js.go create mode 100644 src/internal/syscall/windows/net_windows.go diff --git a/api/next.txt b/api/next.txt index 9e4bb83cb7..cc4120b7ab 100644 --- a/api/next.txt +++ b/api/next.txt @@ -8,114 +8,6 @@ pkg runtime/debug, type BuildInfo struct, Settings []BuildSetting pkg runtime/debug, type BuildSetting struct pkg runtime/debug, type BuildSetting struct, Key string pkg runtime/debug, type BuildSetting struct, Value string -pkg syscall (darwin-amd64), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (darwin-amd64), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (darwin-amd64), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (darwin-amd64), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (darwin-amd64-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (darwin-amd64-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (darwin-amd64-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (darwin-amd64-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (freebsd-386), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (freebsd-386), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (freebsd-386), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (freebsd-386), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (freebsd-386-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (freebsd-386-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (freebsd-386-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (freebsd-386-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (freebsd-amd64), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (freebsd-amd64), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (freebsd-amd64), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (freebsd-amd64), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (freebsd-amd64-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (freebsd-amd64-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (freebsd-amd64-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (freebsd-amd64-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (freebsd-arm), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (freebsd-arm), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (freebsd-arm), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (freebsd-arm), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (freebsd-arm-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (freebsd-arm-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (freebsd-arm-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (freebsd-arm-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (linux-386), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (linux-386), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (linux-386), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (linux-386), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (linux-386-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (linux-386-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (linux-386-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (linux-386-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (linux-amd64), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (linux-amd64), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (linux-amd64), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (linux-amd64), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (linux-amd64-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (linux-amd64-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (linux-amd64-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (linux-amd64-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (linux-arm), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (linux-arm), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (linux-arm), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (linux-arm), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (linux-arm-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (linux-arm-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (linux-arm-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (linux-arm-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (netbsd-386), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (netbsd-386), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (netbsd-386), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (netbsd-386), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (netbsd-386-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (netbsd-386-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (netbsd-386-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (netbsd-386-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (netbsd-amd64), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (netbsd-amd64), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (netbsd-amd64), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (netbsd-amd64), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (netbsd-amd64-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (netbsd-amd64-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (netbsd-amd64-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (netbsd-amd64-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (netbsd-arm), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (netbsd-arm), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (netbsd-arm), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (netbsd-arm), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (netbsd-arm-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (netbsd-arm-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (netbsd-arm-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (netbsd-arm-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (netbsd-arm64), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (netbsd-arm64), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (netbsd-arm64), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (netbsd-arm64), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (netbsd-arm64-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (netbsd-arm64-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (netbsd-arm64-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (netbsd-arm64-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (openbsd-386), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (openbsd-386), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (openbsd-386), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (openbsd-386), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (openbsd-386-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (openbsd-386-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (openbsd-386-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (openbsd-386-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (openbsd-amd64), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (openbsd-amd64), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (openbsd-amd64), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (openbsd-amd64), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (openbsd-amd64-cgo), func RecvfromInet4(int, []uint8, int, *SockaddrInet4) (int, error) -pkg syscall (openbsd-amd64-cgo), func RecvfromInet6(int, []uint8, int, *SockaddrInet6) (int, error) -pkg syscall (openbsd-amd64-cgo), func SendtoInet4(int, []uint8, int, SockaddrInet4) error -pkg syscall (openbsd-amd64-cgo), func SendtoInet6(int, []uint8, int, SockaddrInet6) error -pkg syscall (windows-386), func WSASendtoInet4(Handle, *WSABuf, uint32, *uint32, uint32, SockaddrInet4, *Overlapped, *uint8) error -pkg syscall (windows-386), func WSASendtoInet6(Handle, *WSABuf, uint32, *uint32, uint32, SockaddrInet6, *Overlapped, *uint8) error -pkg syscall (windows-amd64), func WSASendtoInet4(Handle, *WSABuf, uint32, *uint32, uint32, SockaddrInet4, *Overlapped, *uint8) error -pkg syscall (windows-amd64), func WSASendtoInet6(Handle, *WSABuf, uint32, *uint32, uint32, SockaddrInet6, *Overlapped, *uint8) error pkg testing, func Fuzz(func(*F)) FuzzResult pkg testing, func MainStart(testDeps, []InternalTest, []InternalBenchmark, []InternalFuzzTarget, []InternalExample) *M pkg testing, func RunFuzzTargets(func(string, string) (bool, error), []InternalFuzzTarget) bool diff --git a/src/internal/poll/fd_unix.go b/src/internal/poll/fd_unix.go index d4c32e4d41..fd5ac85850 100644 --- a/src/internal/poll/fd_unix.go +++ b/src/internal/poll/fd_unix.go @@ -7,6 +7,7 @@ package poll import ( + "internal/syscall/unix" "io" "sync/atomic" "syscall" @@ -239,7 +240,7 @@ func (fd *FD) ReadFromInet4(p []byte, from *syscall.SockaddrInet4) (int, error) return 0, err } for { - n, err := syscall.RecvfromInet4(fd.Sysfd, p, 0, from) + n, err := unix.RecvfromInet4(fd.Sysfd, p, 0, from) if err != nil { if err == syscall.EINTR { continue @@ -266,7 +267,7 @@ func (fd *FD) ReadFromInet6(p []byte, from *syscall.SockaddrInet6) (int, error) return 0, err } for { - n, err := syscall.RecvfromInet6(fd.Sysfd, p, 0, from) + n, err := unix.RecvfromInet6(fd.Sysfd, p, 0, from) if err != nil { if err == syscall.EINTR { continue @@ -390,7 +391,7 @@ func (fd *FD) WriteToInet4(p []byte, sa syscall.SockaddrInet4) (int, error) { return 0, err } for { - err := syscall.SendtoInet4(fd.Sysfd, p, 0, sa) + err := unix.SendtoInet4(fd.Sysfd, p, 0, sa) if err == syscall.EINTR { continue } @@ -416,7 +417,7 @@ func (fd *FD) WriteToInet6(p []byte, sa syscall.SockaddrInet6) (int, error) { return 0, err } for { - err := syscall.SendtoInet6(fd.Sysfd, p, 0, sa) + err := unix.SendtoInet6(fd.Sysfd, p, 0, sa) if err == syscall.EINTR { continue } diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go index d883cd1ecc..0f5ae8e0d4 100644 --- a/src/internal/poll/fd_windows.go +++ b/src/internal/poll/fd_windows.go @@ -870,7 +870,7 @@ func (fd *FD) WriteToInet4(buf []byte, sa4 syscall.SockaddrInet4) (int, error) { o.InitBuf(buf) o.sa4 = sa4 n, err := execIO(o, func(o *operation) error { - return syscall.WSASendtoInet4(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa4, &o.o, nil) + return windows.WSASendtoInet4(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa4, &o.o, nil) }) return n, err } @@ -885,7 +885,7 @@ func (fd *FD) WriteToInet4(buf []byte, sa4 syscall.SockaddrInet4) (int, error) { o.InitBuf(b) o.sa4 = sa4 n, err := execIO(o, func(o *operation) error { - return syscall.WSASendtoInet4(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa4, &o.o, nil) + return windows.WSASendtoInet4(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa4, &o.o, nil) }) ntotal += int(n) if err != nil { diff --git a/src/internal/syscall/unix/net.go b/src/internal/syscall/unix/net.go new file mode 100644 index 0000000000..773cf34d96 --- /dev/null +++ b/src/internal/syscall/unix/net.go @@ -0,0 +1,28 @@ +// Copyright 2021 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. + +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris + +package unix + +import ( + "syscall" + _ "unsafe" +) + +//go:linkname RecvfromInet4 syscall.recvfromInet4 +//go:noescape +func RecvfromInet4(fd int, p []byte, flags int, from *syscall.SockaddrInet4) (int, error) + +//go:linkname RecvfromInet6 syscall.recvfromInet6 +//go:noescape +func RecvfromInet6(fd int, p []byte, flags int, from *syscall.SockaddrInet6) (n int, err error) + +//go:linkname SendtoInet4 syscall.sendtoInet4 +//go:noescape +func SendtoInet4(fd int, p []byte, flags int, to syscall.SockaddrInet4) (err error) + +//go:linkname SendtoInet6 syscall.sendtoInet6 +//go:noescape +func SendtoInet6(fd int, p []byte, flags int, to syscall.SockaddrInet6) (err error) diff --git a/src/internal/syscall/unix/net_js.go b/src/internal/syscall/unix/net_js.go new file mode 100644 index 0000000000..3fc5a66470 --- /dev/null +++ b/src/internal/syscall/unix/net_js.go @@ -0,0 +1,28 @@ +// Copyright 2021 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. + +//go:build js + +package unix + +import ( + "syscall" + _ "unsafe" +) + +func RecvfromInet4(fd int, p []byte, flags int, from *syscall.SockaddrInet4) (int, error) { + return 0, syscall.ENOSYS +} + +func RecvfromInet6(fd int, p []byte, flags int, from *syscall.SockaddrInet6) (n int, err error) { + return 0, syscall.ENOSYS +} + +func SendtoInet4(fd int, p []byte, flags int, to syscall.SockaddrInet4) (err error) { + return syscall.ENOSYS +} + +func SendtoInet6(fd int, p []byte, flags int, to syscall.SockaddrInet6) (err error) { + return syscall.ENOSYS +} diff --git a/src/internal/syscall/windows/net_windows.go b/src/internal/syscall/windows/net_windows.go new file mode 100644 index 0000000000..1fccd55e4b --- /dev/null +++ b/src/internal/syscall/windows/net_windows.go @@ -0,0 +1,18 @@ +// Copyright 2021 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 windows + +import ( + "syscall" + _ "unsafe" +) + +//go:linkname WSASendtoInet4 syscall.wsaSendtoInet4 +//go:noescape +func WSASendtoInet4(s syscall.Handle, bufs *syscall.WSABuf, bufcnt uint32, sent *uint32, flags uint32, to syscall.SockaddrInet4, overlapped *syscall.Overlapped, croutine *byte) (err error) + +//go:linkname WSASendtoInet6 syscall.wsaSendtoInet6 +//go:noescape +func WSASendtoInet6(s syscall.Handle, bufs *syscall.WSABuf, bufcnt uint32, sent *uint32, flags uint32, to syscall.SockaddrInet6, overlapped *syscall.Overlapped, croutine *byte) (err error) diff --git a/src/syscall/net_js.go b/src/syscall/net_js.go index 4f8258ddb3..253ab22dd9 100644 --- a/src/syscall/net_js.go +++ b/src/syscall/net_js.go @@ -91,26 +91,10 @@ func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) { return 0, nil, ENOSYS } -func RecvfromInet4(fd int, p []byte, flags int, from *SockaddrInet4) (n int, err error) { - return 0, ENOSYS -} - -func RecvfromInet6(fd int, p []byte, flags int, from *SockaddrInet6) (n int, err error) { - return 0, ENOSYS -} - func Sendto(fd int, p []byte, flags int, to Sockaddr) error { return ENOSYS } -func SendtoInet4(fd int, p []byte, flags int, to SockaddrInet4) error { - return ENOSYS -} - -func SendtoInet6(fd int, p []byte, flags int, to SockaddrInet6) error { - return ENOSYS -} - func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn, recvflags int, from Sockaddr, err error) { return 0, 0, 0, nil, ENOSYS } diff --git a/src/syscall/syscall_unix.go b/src/syscall/syscall_unix.go index 5a91a023e1..adc1e5dbfb 100644 --- a/src/syscall/syscall_unix.go +++ b/src/syscall/syscall_unix.go @@ -297,7 +297,7 @@ func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) { return } -func RecvfromInet4(fd int, p []byte, flags int, from *SockaddrInet4) (n int, err error) { +func recvfromInet4(fd int, p []byte, flags int, from *SockaddrInet4) (n int, err error) { var rsa RawSockaddrAny var socklen _Socklen = SizeofSockaddrAny if n, err = recvfrom(fd, p, flags, &rsa, &socklen); err != nil { @@ -310,7 +310,7 @@ func RecvfromInet4(fd int, p []byte, flags int, from *SockaddrInet4) (n int, err return } -func RecvfromInet6(fd int, p []byte, flags int, from *SockaddrInet6) (n int, err error) { +func recvfromInet6(fd int, p []byte, flags int, from *SockaddrInet6) (n int, err error) { var rsa RawSockaddrAny var socklen _Socklen = SizeofSockaddrAny if n, err = recvfrom(fd, p, flags, &rsa, &socklen); err != nil { @@ -324,7 +324,7 @@ func RecvfromInet6(fd int, p []byte, flags int, from *SockaddrInet6) (n int, err return } -func SendtoInet4(fd int, p []byte, flags int, to SockaddrInet4) (err error) { +func sendtoInet4(fd int, p []byte, flags int, to SockaddrInet4) (err error) { ptr, n, err := to.sockaddr() if err != nil { return err @@ -332,7 +332,7 @@ func SendtoInet4(fd int, p []byte, flags int, to SockaddrInet4) (err error) { return sendto(fd, p, flags, ptr, n) } -func SendtoInet6(fd int, p []byte, flags int, to SockaddrInet6) (err error) { +func sendtoInet6(fd int, p []byte, flags int, to SockaddrInet6) (err error) { ptr, n, err := to.sockaddr() if err != nil { return err diff --git a/src/syscall/syscall_windows.go b/src/syscall/syscall_windows.go index 0456074d47..48fedb33d7 100644 --- a/src/syscall/syscall_windows.go +++ b/src/syscall/syscall_windows.go @@ -922,7 +922,7 @@ func WSASendto(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32 return err } -func WSASendtoInet4(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to SockaddrInet4, overlapped *Overlapped, croutine *byte) (err error) { +func wsaSendtoInet4(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to SockaddrInet4, overlapped *Overlapped, croutine *byte) (err error) { rsa, len, err := to.sockaddr() if err != nil { return err @@ -938,7 +938,7 @@ func WSASendtoInet4(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags u return err } -func WSASendtoInet6(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to SockaddrInet6, overlapped *Overlapped, croutine *byte) (err error) { +func wsaSendtoInet6(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to SockaddrInet6, overlapped *Overlapped, croutine *byte) (err error) { rsa, len, err := to.sockaddr() if err != nil { return err From 1f368d5b860b178bcbd55dfeb64474295263516b Mon Sep 17 00:00:00 2001 From: Daniel Theophanes Date: Mon, 12 Jul 2021 09:25:04 -0500 Subject: [PATCH 347/406] database/sql: use errors.Is when checking ErrBadConn When drivers return driver.ErrBadConn, no meaningful information about what the cause of the problem is returned. Ideally the driver.ErrBadConn would be always caught with the retry loop, but this is not always the case. Drivers today must choose between returning a useful error and use the rety logic. This allows supporting both. Fixes #47142 Change-Id: I454573028f041dfdf874eed6c254fb194ccf6d96 Reviewed-on: https://go-review.googlesource.com/c/go/+/333949 Run-TryBot: Ian Lance Taylor Trust: Ian Lance Taylor Trust: Daniel Theophanes TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/database/sql/driver/driver.go | 3 ++ src/database/sql/fakedb_test.go | 27 ++++++++---- src/database/sql/sql.go | 69 ++++++++++++++++++------------- src/database/sql/sql_test.go | 2 +- 4 files changed, 64 insertions(+), 37 deletions(-) diff --git a/src/database/sql/driver/driver.go b/src/database/sql/driver/driver.go index f09396175a..ea1de5a8fb 100644 --- a/src/database/sql/driver/driver.go +++ b/src/database/sql/driver/driver.go @@ -156,6 +156,9 @@ var ErrSkip = errors.New("driver: skip fast-path; continue as if unimplemented") // if there's a possibility that the database server might have // performed the operation. Even if the server sends back an error, // you shouldn't return ErrBadConn. +// +// Errors will be checked using errors.Is. An error may +// wrap ErrBadConn or implement the Is(error) bool method. var ErrBadConn = errors.New("driver: bad connection") // Pinger is an optional interface that may be implemented by a Conn. diff --git a/src/database/sql/fakedb_test.go b/src/database/sql/fakedb_test.go index 4b68f1cba9..34e97e012b 100644 --- a/src/database/sql/fakedb_test.go +++ b/src/database/sql/fakedb_test.go @@ -96,6 +96,19 @@ type fakeDB struct { allowAny bool } +type fakeError struct { + Message string + Wrapped error +} + +func (err fakeError) Error() string { + return err.Message +} + +func (err fakeError) Unwrap() error { + return err.Wrapped +} + type table struct { mu sync.Mutex colname []string @@ -368,7 +381,7 @@ func (c *fakeConn) isDirtyAndMark() bool { func (c *fakeConn) Begin() (driver.Tx, error) { if c.isBad() { - return nil, driver.ErrBadConn + return nil, fakeError{Wrapped: driver.ErrBadConn} } if c.currTx != nil { return nil, errors.New("fakedb: already in a transaction") @@ -401,7 +414,7 @@ func (c *fakeConn) ResetSession(ctx context.Context) error { c.dirtySession = false c.currTx = nil if c.isBad() { - return driver.ErrBadConn + return fakeError{Message: "Reset Session: bad conn", Wrapped: driver.ErrBadConn} } return nil } @@ -629,7 +642,7 @@ func (c *fakeConn) PrepareContext(ctx context.Context, query string) (driver.Stm } if c.stickyBad || (hookPrepareBadConn != nil && hookPrepareBadConn()) { - return nil, driver.ErrBadConn + return nil, fakeError{Message: "Preapre: Sticky Bad", Wrapped: driver.ErrBadConn} } c.touchMem() @@ -756,7 +769,7 @@ func (s *fakeStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (d } if s.c.stickyBad || (hookExecBadConn != nil && hookExecBadConn()) { - return nil, driver.ErrBadConn + return nil, fakeError{Message: "Exec: Sticky Bad", Wrapped: driver.ErrBadConn} } if s.c.isDirtyAndMark() { return nil, errFakeConnSessionDirty @@ -870,7 +883,7 @@ func (s *fakeStmt) QueryContext(ctx context.Context, args []driver.NamedValue) ( } if s.c.stickyBad || (hookQueryBadConn != nil && hookQueryBadConn()) { - return nil, driver.ErrBadConn + return nil, fakeError{Message: "Query: Sticky Bad", Wrapped: driver.ErrBadConn} } if s.c.isDirtyAndMark() { return nil, errFakeConnSessionDirty @@ -1031,7 +1044,7 @@ var hookCommitBadConn func() bool func (tx *fakeTx) Commit() error { tx.c.currTx = nil if hookCommitBadConn != nil && hookCommitBadConn() { - return driver.ErrBadConn + return fakeError{Message: "Commit: Hook Bad Conn", Wrapped: driver.ErrBadConn} } tx.c.touchMem() return nil @@ -1043,7 +1056,7 @@ var hookRollbackBadConn func() bool func (tx *fakeTx) Rollback() error { tx.c.currTx = nil if hookRollbackBadConn != nil && hookRollbackBadConn() { - return driver.ErrBadConn + return fakeError{Message: "Rollback: Hook Bad Conn", Wrapped: driver.ErrBadConn} } tx.c.touchMem() return nil diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go index e4a5a225b0..897bca059b 100644 --- a/src/database/sql/sql.go +++ b/src/database/sql/sql.go @@ -848,14 +848,15 @@ func (db *DB) pingDC(ctx context.Context, dc *driverConn, release func(error)) e func (db *DB) PingContext(ctx context.Context) error { var dc *driverConn var err error - + var isBadConn bool for i := 0; i < maxBadConnRetries; i++ { dc, err = db.conn(ctx, cachedOrNewConn) - if err != driver.ErrBadConn { + isBadConn = errors.Is(err, driver.ErrBadConn) + if !isBadConn { break } } - if err == driver.ErrBadConn { + if isBadConn { dc, err = db.conn(ctx, alwaysNewConn) } if err != nil { @@ -1317,9 +1318,9 @@ func (db *DB) conn(ctx context.Context, strategy connReuseStrategy) (*driverConn db.mu.Unlock() // Reset the session if required. - if err := conn.resetSession(ctx); err == driver.ErrBadConn { + if err := conn.resetSession(ctx); errors.Is(err, driver.ErrBadConn) { conn.Close() - return nil, driver.ErrBadConn + return nil, err } return conn, nil @@ -1381,9 +1382,9 @@ func (db *DB) conn(ctx context.Context, strategy connReuseStrategy) (*driverConn } // Reset the session if required. - if err := ret.conn.resetSession(ctx); err == driver.ErrBadConn { + if err := ret.conn.resetSession(ctx); errors.Is(err, driver.ErrBadConn) { ret.conn.Close() - return nil, driver.ErrBadConn + return nil, err } return ret.conn, ret.err } @@ -1442,7 +1443,7 @@ const debugGetPut = false // putConn adds a connection to the db's free pool. // err is optionally the last error that occurred on this connection. func (db *DB) putConn(dc *driverConn, err error, resetSession bool) { - if err != driver.ErrBadConn { + if !errors.Is(err, driver.ErrBadConn) { if !dc.validateConnection(resetSession) { err = driver.ErrBadConn } @@ -1456,7 +1457,7 @@ func (db *DB) putConn(dc *driverConn, err error, resetSession bool) { panic("sql: connection returned that was never out") } - if err != driver.ErrBadConn && dc.expired(db.maxLifetime) { + if !errors.Is(err, driver.ErrBadConn) && dc.expired(db.maxLifetime) { db.maxLifetimeClosed++ err = driver.ErrBadConn } @@ -1471,7 +1472,7 @@ func (db *DB) putConn(dc *driverConn, err error, resetSession bool) { } dc.onPut = nil - if err == driver.ErrBadConn { + if errors.Is(err, driver.ErrBadConn) { // Don't reuse bad connections. // Since the conn is considered bad and is being discarded, treat it // as closed. Don't decrement the open count here, finalClose will @@ -1551,13 +1552,15 @@ const maxBadConnRetries = 2 func (db *DB) PrepareContext(ctx context.Context, query string) (*Stmt, error) { var stmt *Stmt var err error + var isBadConn bool for i := 0; i < maxBadConnRetries; i++ { stmt, err = db.prepare(ctx, query, cachedOrNewConn) - if err != driver.ErrBadConn { + isBadConn = errors.Is(err, driver.ErrBadConn) + if !isBadConn { break } } - if err == driver.ErrBadConn { + if isBadConn { return db.prepare(ctx, query, alwaysNewConn) } return stmt, err @@ -1627,13 +1630,15 @@ func (db *DB) prepareDC(ctx context.Context, dc *driverConn, release func(error) func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (Result, error) { var res Result var err error + var isBadConn bool for i := 0; i < maxBadConnRetries; i++ { res, err = db.exec(ctx, query, args, cachedOrNewConn) - if err != driver.ErrBadConn { + isBadConn = errors.Is(err, driver.ErrBadConn) + if !isBadConn { break } } - if err == driver.ErrBadConn { + if isBadConn { return db.exec(ctx, query, args, alwaysNewConn) } return res, err @@ -1700,13 +1705,15 @@ func (db *DB) execDC(ctx context.Context, dc *driverConn, release func(error), q func (db *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error) { var rows *Rows var err error + var isBadConn bool for i := 0; i < maxBadConnRetries; i++ { rows, err = db.query(ctx, query, args, cachedOrNewConn) - if err != driver.ErrBadConn { + isBadConn = errors.Is(err, driver.ErrBadConn) + if !isBadConn { break } } - if err == driver.ErrBadConn { + if isBadConn { return db.query(ctx, query, args, alwaysNewConn) } return rows, err @@ -1835,13 +1842,15 @@ func (db *DB) QueryRow(query string, args ...interface{}) *Row { func (db *DB) BeginTx(ctx context.Context, opts *TxOptions) (*Tx, error) { var tx *Tx var err error + var isBadConn bool for i := 0; i < maxBadConnRetries; i++ { tx, err = db.begin(ctx, opts, cachedOrNewConn) - if err != driver.ErrBadConn { + isBadConn = errors.Is(err, driver.ErrBadConn) + if !isBadConn { break } } - if err == driver.ErrBadConn { + if isBadConn { return db.begin(ctx, opts, alwaysNewConn) } return tx, err @@ -1914,13 +1923,15 @@ var ErrConnDone = errors.New("sql: connection is already closed") func (db *DB) Conn(ctx context.Context) (*Conn, error) { var dc *driverConn var err error + var isBadConn bool for i := 0; i < maxBadConnRetries; i++ { dc, err = db.conn(ctx, cachedOrNewConn) - if err != driver.ErrBadConn { + isBadConn = errors.Is(err, driver.ErrBadConn) + if !isBadConn { break } } - if err == driver.ErrBadConn { + if isBadConn { dc, err = db.conn(ctx, alwaysNewConn) } if err != nil { @@ -2032,8 +2043,8 @@ func (c *Conn) PrepareContext(ctx context.Context, query string) (*Stmt, error) // Raw executes f exposing the underlying driver connection for the // duration of f. The driverConn must not be used outside of f. // -// Once f returns and err is not equal to driver.ErrBadConn, the Conn will -// continue to be usable until Conn.Close is called. +// Once f returns and err is not driver.ErrBadConn, the Conn will continue to be usable +// until Conn.Close is called. func (c *Conn) Raw(f func(driverConn interface{}) error) (err error) { var dc *driverConn var release releaseConn @@ -2084,7 +2095,7 @@ func (c *Conn) BeginTx(ctx context.Context, opts *TxOptions) (*Tx, error) { // as the sql operation is done with the dc. func (c *Conn) closemuRUnlockCondReleaseConn(err error) { c.closemu.RUnlock() - if err == driver.ErrBadConn { + if errors.Is(err, driver.ErrBadConn) { c.close(err) } } @@ -2278,7 +2289,7 @@ func (tx *Tx) Commit() error { withLock(tx.dc, func() { err = tx.txi.Commit() }) - if err != driver.ErrBadConn { + if !errors.Is(err, driver.ErrBadConn) { tx.closePrepared() } tx.close(err) @@ -2310,7 +2321,7 @@ func (tx *Tx) rollback(discardConn bool) error { withLock(tx.dc, func() { err = tx.txi.Rollback() }) - if err != driver.ErrBadConn { + if !errors.Is(err, driver.ErrBadConn) { tx.closePrepared() } if discardConn { @@ -2616,7 +2627,7 @@ func (s *Stmt) ExecContext(ctx context.Context, args ...interface{}) (Result, er } dc, releaseConn, ds, err := s.connStmt(ctx, strategy) if err != nil { - if err == driver.ErrBadConn { + if errors.Is(err, driver.ErrBadConn) { continue } return nil, err @@ -2624,7 +2635,7 @@ func (s *Stmt) ExecContext(ctx context.Context, args ...interface{}) (Result, er res, err = resultFromStatement(ctx, dc.ci, ds, args...) releaseConn(err) - if err != driver.ErrBadConn { + if !errors.Is(err, driver.ErrBadConn) { return res, err } } @@ -2764,7 +2775,7 @@ func (s *Stmt) QueryContext(ctx context.Context, args ...interface{}) (*Rows, er } dc, releaseConn, ds, err := s.connStmt(ctx, strategy) if err != nil { - if err == driver.ErrBadConn { + if errors.Is(err, driver.ErrBadConn) { continue } return nil, err @@ -2798,7 +2809,7 @@ func (s *Stmt) QueryContext(ctx context.Context, args ...interface{}) (*Rows, er } releaseConn(err) - if err != driver.ErrBadConn { + if !errors.Is(err, driver.ErrBadConn) { return nil, err } } diff --git a/src/database/sql/sql_test.go b/src/database/sql/sql_test.go index 15c30e0d00..889adc3164 100644 --- a/src/database/sql/sql_test.go +++ b/src/database/sql/sql_test.go @@ -3159,7 +3159,7 @@ func TestTxEndBadConn(t *testing.T) { return broken } - if err := op(); err != driver.ErrBadConn { + if err := op(); !errors.Is(err, driver.ErrBadConn) { t.Errorf(name+": %v", err) return } From 283373d124b39be62fb4dc0349ddf0cb1c99aeb7 Mon Sep 17 00:00:00 2001 From: Mostafa Solati Date: Tue, 3 Aug 2021 21:39:29 +0430 Subject: [PATCH 348/406] database/sql: fix tx.Prepare documentation Fixes: #45978 Change-Id: I3d5ccd621d670f97bb1a642b4e84b6629347a315 Reviewed-on: https://go-review.googlesource.com/c/go/+/339291 Reviewed-by: Daniel Theophanes Trust: Cherry Mui --- src/database/sql/sql.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go index 897bca059b..5131c08b51 100644 --- a/src/database/sql/sql.go +++ b/src/database/sql/sql.go @@ -2364,8 +2364,8 @@ func (tx *Tx) PrepareContext(ctx context.Context, query string) (*Stmt, error) { // Prepare creates a prepared statement for use within a transaction. // -// The returned statement operates within the transaction and can no longer -// be used once the transaction has been committed or rolled back. +// The returned statement operates within the transaction and will be closed +// when the transaction has been committed or rolled back. // // To use an existing prepared statement on this transaction, see Tx.Stmt. // From fa19146038e0e94480c93d43e2a8306c419d5119 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 3 Nov 2021 16:18:36 +0100 Subject: [PATCH 349/406] net/netip: fix various typos in comments Change-Id: I67998f70969ac6e6ff1b52a56e49a61ef167ed50 Reviewed-on: https://go-review.googlesource.com/c/go/+/361055 Trust: Jason A. Donenfeld Run-TryBot: Jason A. Donenfeld TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/net/netip/netip.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/net/netip/netip.go b/src/net/netip/netip.go index 4ef3b4bb68..d15a4947ac 100644 --- a/src/net/netip/netip.go +++ b/src/net/netip/netip.go @@ -4,7 +4,7 @@ // Package netip defines a IP address type that's a small value type. // Building on that Addr type, the package also defines AddrPort (an -// IP address and a port), and Prefix (a IP address and a bit length +// IP address and a port), and Prefix (an IP address and a bit length // prefix). // // Compared to the net.IP type, this package's Addr type takes less @@ -1184,7 +1184,7 @@ type Prefix struct { // bits is logically a uint8 (storing [0,128]) but also // encodes an "invalid" bit, currently represented by the // invalidPrefixBits sentinel value. It could be packed into - // the uint8 more with more comlicated expressions in the + // the uint8 more with more complicated expressions in the // accessors, but the extra byte (in padding anyway) doesn't // hurt and simplifies code below. bits int16 @@ -1195,7 +1195,7 @@ type Prefix struct { // public API. const invalidPrefixBits = -1 -// PrefixFrom returns an Prefix with the provided IP address and bit +// PrefixFrom returns a Prefix with the provided IP address and bit // prefix length. // // It does not allocate. Unlike Addr.Prefix, PrefixFrom does not mask @@ -1222,7 +1222,7 @@ func (p Prefix) Addr() Addr { return p.ip } // It reports -1 if invalid. func (p Prefix) Bits() int { return int(p.bits) } -// IsValid reports whether whether p.Bits() has a valid range for p.IP(). +// IsValid reports whether p.Bits() has a valid range for p.IP(). // If p.Addr() is the zero Addr, IsValid returns false. // Note that if p is the zero Prefix, then p.IsValid() == false. func (p Prefix) IsValid() bool { return !p.ip.isZero() && p.bits >= 0 && int(p.bits) <= p.ip.BitLen() } From 604963052072d7895138c78751c477cf25625e7d Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 3 Nov 2021 13:54:08 -0700 Subject: [PATCH 350/406] internal/poll: remove alloc sending IPv6 UDP on Windows This was an oversight in CL 331511. Change-Id: Ibc20bf6ea80a8675d43d9691ed551dffab1d9215 Reviewed-on: https://go-review.googlesource.com/c/go/+/361254 Trust: Josh Bleecher Snyder Trust: Brad Fitzpatrick Run-TryBot: Josh Bleecher Snyder Reviewed-by: Brad Fitzpatrick TryBot-Result: Go Bot --- src/internal/poll/fd_windows.go | 42 +++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go index 0f5ae8e0d4..139f78a7c1 100644 --- a/src/internal/poll/fd_windows.go +++ b/src/internal/poll/fd_windows.go @@ -857,7 +857,7 @@ func (fd *FD) WriteTo(buf []byte, sa syscall.Sockaddr) (int, error) { return ntotal, nil } -// WriteTo wraps the sendto network call for IPv4. +// WriteToInet4 is WriteTo, specialized for syscall.SockaddrInet4. func (fd *FD) WriteToInet4(buf []byte, sa4 syscall.SockaddrInet4) (int, error) { if err := fd.writeLock(); err != nil { return 0, err @@ -896,9 +896,43 @@ func (fd *FD) WriteToInet4(buf []byte, sa4 syscall.SockaddrInet4) (int, error) { return ntotal, nil } -// WriteTo wraps the sendto network call for IPv6. -func (fd *FD) WriteToInet6(buf []byte, sa syscall.SockaddrInet6) (int, error) { - return fd.WriteTo(buf, &sa) +// WriteToInet6 is WriteTo, specialized for syscall.SockaddrInet6. +func (fd *FD) WriteToInet6(buf []byte, sa6 syscall.SockaddrInet6) (int, error) { + if err := fd.writeLock(); err != nil { + return 0, err + } + defer fd.writeUnlock() + + if len(buf) == 0 { + // handle zero-byte payload + o := &fd.wop + o.InitBuf(buf) + o.sa6 = sa6 + n, err := execIO(o, func(o *operation) error { + return windows.WSASendtoInet6(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa6, &o.o, nil) + }) + return n, err + } + + ntotal := 0 + for len(buf) > 0 { + b := buf + if len(b) > maxRW { + b = b[:maxRW] + } + o := &fd.wop + o.InitBuf(b) + o.sa6 = sa6 + n, err := execIO(o, func(o *operation) error { + return windows.WSASendtoInet6(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa6, &o.o, nil) + }) + ntotal += int(n) + if err != nil { + return ntotal, err + } + buf = buf[n:] + } + return ntotal, nil } // Call ConnectEx. This doesn't need any locking, since it is only From be0cd9e5ec01141def07412b0ef3fa0d3f8cba9d Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 2 Nov 2021 11:59:56 -0700 Subject: [PATCH 351/406] syscall: unify unix Sendmsg prologues These were identical. This is a preliminary step towards remove allocs per UDP send. Change-Id: I21e1264c7d4747baa626ddb93afff4c1cf225d13 Reviewed-on: https://go-review.googlesource.com/c/go/+/361256 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/syscall/syscall_aix.go | 15 +-------------- src/syscall/syscall_bsd.go | 15 +-------------- src/syscall/syscall_linux.go | 16 +--------------- src/syscall/syscall_solaris.go | 15 +-------------- src/syscall/syscall_unix.go | 17 +++++++++++++++++ 5 files changed, 21 insertions(+), 57 deletions(-) diff --git a/src/syscall/syscall_aix.go b/src/syscall/syscall_aix.go index f3b160cae4..36172cc678 100644 --- a/src/syscall/syscall_aix.go +++ b/src/syscall/syscall_aix.go @@ -360,20 +360,7 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from return } -func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { - _, err = SendmsgN(fd, p, oob, to, flags) - return -} - -func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { - var ptr unsafe.Pointer - var salen _Socklen - if to != nil { - ptr, salen, err = to.sockaddr() - if err != nil { - return 0, err - } - } +func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags int) (n int, err error) { var msg Msghdr msg.Name = (*byte)(unsafe.Pointer(ptr)) msg.Namelen = uint32(salen) diff --git a/src/syscall/syscall_bsd.go b/src/syscall/syscall_bsd.go index 8945661300..71a331d6c0 100644 --- a/src/syscall/syscall_bsd.go +++ b/src/syscall/syscall_bsd.go @@ -394,20 +394,7 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) -func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { - _, err = SendmsgN(fd, p, oob, to, flags) - return -} - -func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { - var ptr unsafe.Pointer - var salen _Socklen - if to != nil { - ptr, salen, err = to.sockaddr() - if err != nil { - return 0, err - } - } +func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags int) (n int, err error) { var msg Msghdr msg.Name = (*byte)(unsafe.Pointer(ptr)) msg.Namelen = uint32(salen) diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go index 1c6033bbab..695ce2b198 100644 --- a/src/syscall/syscall_linux.go +++ b/src/syscall/syscall_linux.go @@ -679,21 +679,7 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from return } -func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { - _, err = SendmsgN(fd, p, oob, to, flags) - return -} - -func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { - var ptr unsafe.Pointer - var salen _Socklen - if to != nil { - var err error - ptr, salen, err = to.sockaddr() - if err != nil { - return 0, err - } - } +func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags int) (n int, err error) { var msg Msghdr msg.Name = (*byte)(ptr) msg.Namelen = uint32(salen) diff --git a/src/syscall/syscall_solaris.go b/src/syscall/syscall_solaris.go index 13616fca9d..15b3c2bb40 100644 --- a/src/syscall/syscall_solaris.go +++ b/src/syscall/syscall_solaris.go @@ -365,22 +365,9 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from return } -func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { - _, err = SendmsgN(fd, p, oob, to, flags) - return -} - //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.__xnet_sendmsg -func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { - var ptr unsafe.Pointer - var salen _Socklen - if to != nil { - ptr, salen, err = to.sockaddr() - if err != nil { - return 0, err - } - } +func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags int) (n int, err error) { var msg Msghdr msg.Name = (*byte)(unsafe.Pointer(ptr)) msg.Namelen = uint32(salen) diff --git a/src/syscall/syscall_unix.go b/src/syscall/syscall_unix.go index adc1e5dbfb..2837c976e3 100644 --- a/src/syscall/syscall_unix.go +++ b/src/syscall/syscall_unix.go @@ -324,6 +324,23 @@ func recvfromInet6(fd int, p []byte, flags int, from *SockaddrInet6) (n int, err return } +func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { + _, err = SendmsgN(fd, p, oob, to, flags) + return +} + +func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { + var ptr unsafe.Pointer + var salen _Socklen + if to != nil { + ptr, salen, err = to.sockaddr() + if err != nil { + return 0, err + } + } + return sendmsgN(fd, p, oob, ptr, salen, flags) +} + func sendtoInet4(fd int, p []byte, flags int, to SockaddrInet4) (err error) { ptr, n, err := to.sockaddr() if err != nil { From 91962dfde1a754a0ccdc514c9a2acfae25fc1f5e Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 2 Nov 2021 12:25:23 -0700 Subject: [PATCH 352/406] syscall: unify unix Recvmsg epilogues These were identical. This is a preliminary step towards remove allocs per UDP receive. Change-Id: I83106cd3f1fe4bc5bae2d1b0ebd23eedd820abed Reviewed-on: https://go-review.googlesource.com/c/go/+/361258 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/syscall/syscall_aix.go | 9 ++------- src/syscall/syscall_bsd.go | 9 ++------- src/syscall/syscall_linux.go | 9 ++------- src/syscall/syscall_solaris.go | 9 ++------- src/syscall/syscall_unix.go | 10 ++++++++++ 5 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/syscall/syscall_aix.go b/src/syscall/syscall_aix.go index 36172cc678..0f5101999f 100644 --- a/src/syscall/syscall_aix.go +++ b/src/syscall/syscall_aix.go @@ -321,10 +321,9 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) { return } -func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { +func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn int, recvflags int, err error) { var msg Msghdr - var rsa RawSockaddrAny - msg.Name = (*byte)(unsafe.Pointer(&rsa)) + msg.Name = (*byte)(unsafe.Pointer(rsa)) msg.Namelen = uint32(SizeofSockaddrAny) var iov Iovec if len(p) > 0 { @@ -353,10 +352,6 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from } oobn = int(msg.Controllen) recvflags = int(msg.Flags) - // source address is only specified if the socket is unconnected - if rsa.Addr.Family != AF_UNSPEC { - from, err = anyToSockaddr(&rsa) - } return } diff --git a/src/syscall/syscall_bsd.go b/src/syscall/syscall_bsd.go index 71a331d6c0..5e636d5258 100644 --- a/src/syscall/syscall_bsd.go +++ b/src/syscall/syscall_bsd.go @@ -358,10 +358,9 @@ func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) { //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) -func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { +func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn int, recvflags int, err error) { var msg Msghdr - var rsa RawSockaddrAny - msg.Name = (*byte)(unsafe.Pointer(&rsa)) + msg.Name = (*byte)(unsafe.Pointer(rsa)) msg.Namelen = uint32(SizeofSockaddrAny) var iov Iovec if len(p) > 0 { @@ -385,10 +384,6 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from } oobn = int(msg.Controllen) recvflags = int(msg.Flags) - // source address is only specified if the socket is unconnected - if rsa.Addr.Family != AF_UNSPEC { - from, err = anyToSockaddr(&rsa) - } return } diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go index 695ce2b198..c002299641 100644 --- a/src/syscall/syscall_linux.go +++ b/src/syscall/syscall_linux.go @@ -638,10 +638,9 @@ func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) { return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq)) } -func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { +func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn int, recvflags int, err error) { var msg Msghdr - var rsa RawSockaddrAny - msg.Name = (*byte)(unsafe.Pointer(&rsa)) + msg.Name = (*byte)(unsafe.Pointer(rsa)) msg.Namelen = uint32(SizeofSockaddrAny) var iov Iovec if len(p) > 0 { @@ -672,10 +671,6 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from } oobn = int(msg.Controllen) recvflags = int(msg.Flags) - // source address is only specified if the socket is unconnected - if rsa.Addr.Family != AF_UNSPEC { - from, err = anyToSockaddr(&rsa) - } return } diff --git a/src/syscall/syscall_solaris.go b/src/syscall/syscall_solaris.go index 15b3c2bb40..5f12f229c4 100644 --- a/src/syscall/syscall_solaris.go +++ b/src/syscall/syscall_solaris.go @@ -332,10 +332,9 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) { return } -func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { +func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn int, recvflags int, err error) { var msg Msghdr - var rsa RawSockaddrAny - msg.Name = (*byte)(unsafe.Pointer(&rsa)) + msg.Name = (*byte)(unsafe.Pointer(rsa)) msg.Namelen = uint32(SizeofSockaddrAny) var iov Iovec if len(p) > 0 { @@ -358,10 +357,6 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from return } oobn = int(msg.Accrightslen) - // source address is only specified if the socket is unconnected - if rsa.Addr.Family != AF_UNSPEC { - from, err = anyToSockaddr(&rsa) - } return } diff --git a/src/syscall/syscall_unix.go b/src/syscall/syscall_unix.go index 2837c976e3..d1ecc361c6 100644 --- a/src/syscall/syscall_unix.go +++ b/src/syscall/syscall_unix.go @@ -324,6 +324,16 @@ func recvfromInet6(fd int, p []byte, flags int, from *SockaddrInet6) (n int, err return } +func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { + var rsa RawSockaddrAny + n, oobn, recvflags, err = recvmsgRaw(fd, p, oob, flags, &rsa) + // source address is only specified if the socket is unconnected + if rsa.Addr.Family != AF_UNSPEC { + from, err = anyToSockaddr(&rsa) + } + return +} + func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { _, err = SendmsgN(fd, p, oob, to, flags) return From 9cf671106721451af4a556dc0bf56c133836d008 Mon Sep 17 00:00:00 2001 From: Zvonimir Pavlinovic Date: Wed, 3 Nov 2021 16:31:11 -0700 Subject: [PATCH 353/406] cmd/cover: use fmt.Print for newline-ending fixed string This redundancy is now caught by the improved printf vet checker (golang/go#30436). Updates #49322 Change-Id: Id450247adc6fa28a9244c019be3c1b52c2d17f49 Reviewed-on: https://go-review.googlesource.com/c/go/+/361263 Run-TryBot: Zvonimir Pavlinovic TryBot-Result: Go Bot Trust: Zvonimir Pavlinovic Reviewed-by: Dmitri Shuralyov --- src/cmd/cover/cover.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/cover/cover.go b/src/cmd/cover/cover.go index 7ee000861b..9c8529f7eb 100644 --- a/src/cmd/cover/cover.go +++ b/src/cmd/cover/cover.go @@ -40,8 +40,8 @@ Finally, to generate modified source code with coverage annotations ` func usage() { - fmt.Fprintln(os.Stderr, usageMessage) - fmt.Fprintln(os.Stderr, "Flags:") + fmt.Fprint(os.Stderr, usageMessage) + fmt.Fprintln(os.Stderr, "\nFlags:") flag.PrintDefaults() fmt.Fprintln(os.Stderr, "\n Only one of -html, -func, or -mode may be set.") os.Exit(2) From a419f2f5c364031e2f65a9f031e8bb52e9c22fc9 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 3 Nov 2021 14:58:59 -0700 Subject: [PATCH 354/406] cmd/compile/internal/syntax: better error message when type parameters are not permitted Fixes #48382. Change-Id: I215896a4429839c41c9136b6922b1b748ed47734 Reviewed-on: https://go-review.googlesource.com/c/go/+/361259 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/syntax/parser.go | 45 ++++++++++++------- .../internal/syntax/testdata/issue48382.go2 | 15 +++++++ 2 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 src/cmd/compile/internal/syntax/testdata/issue48382.go2 diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go index 9f02cb6c2c..770175fe54 100644 --- a/src/cmd/compile/internal/syntax/parser.go +++ b/src/cmd/compile/internal/syntax/parser.go @@ -708,15 +708,7 @@ func (p *parser) funcDeclOrNil() *FuncDecl { } f.Name = p.name() - if p.allowGenerics() && p.got(_Lbrack) { - if p.tok == _Rbrack { - p.syntaxError("empty type parameter list") - p.next() - } else { - f.TParamList = p.paramList(nil, _Rbrack, true) - } - } - f.Type = p.funcType() + f.TParamList, f.Type = p.funcType("") if p.tok == _Lbrace { f.Body = p.funcBody() } @@ -944,7 +936,7 @@ func (p *parser) operand(keep_parens bool) Expr { case _Func: pos := p.pos() p.next() - ftyp := p.funcType() + _, ftyp := p.funcType("function literal") if p.tok == _Lbrace { p.xnest++ @@ -1284,7 +1276,8 @@ func (p *parser) typeOrNil() Expr { case _Func: // fntype p.next() - return p.funcType() + _, t := p.funcType("function type") + return t case _Lbrack: // '[' oexpr ']' ntype @@ -1357,18 +1350,34 @@ func (p *parser) typeInstance(typ Expr) Expr { return x } -func (p *parser) funcType() *FuncType { +// If context != "", type parameters are not permitted. +func (p *parser) funcType(context string) ([]*Field, *FuncType) { if trace { defer p.trace("funcType")() } typ := new(FuncType) typ.pos = p.pos() + + var tparamList []*Field + if p.allowGenerics() && p.got(_Lbrack) { + if context != "" { + // accept but complain + p.syntaxErrorAt(typ.pos, context+" cannot have type parameters") + } + if p.tok == _Rbrack { + p.syntaxError("empty type parameter list") + p.next() + } else { + tparamList = p.paramList(nil, _Rbrack, true) + } + } + p.want(_Lparen) typ.ParamList = p.paramList(nil, _Rparen, false) typ.ResultList = p.funcResult() - return typ + return tparamList, typ } // "[" has already been consumed, and pos is its position. @@ -1697,11 +1706,13 @@ func (p *parser) methodDecl() *Field { // already progressed, no need to advance } + const context = "interface method" + switch p.tok { case _Lparen: // method f.Name = name - f.Type = p.funcType() + _, f.Type = p.funcType(context) case _Lbrack: if p.allowGenerics() { @@ -1721,7 +1732,7 @@ func (p *parser) methodDecl() *Field { // name[]( p.errorAt(pos, "empty type parameter list") f.Name = name - f.Type = p.funcType() + _, f.Type = p.funcType(context) } else { p.errorAt(pos, "empty type argument list") f.Type = name @@ -1738,7 +1749,7 @@ func (p *parser) methodDecl() *Field { // as if [] were absent. if p.tok == _Lparen { f.Name = name - f.Type = p.funcType() + _, f.Type = p.funcType(context) } else { f.Type = name } @@ -1749,7 +1760,7 @@ func (p *parser) methodDecl() *Field { if list[0].Name != nil { // generic method f.Name = name - f.Type = p.funcType() + _, f.Type = p.funcType(context) // TODO(gri) Record list as type parameter list with f.Type // if we want to type-check the generic method. // For now, report an error so this is not a silent event. diff --git a/src/cmd/compile/internal/syntax/testdata/issue48382.go2 b/src/cmd/compile/internal/syntax/testdata/issue48382.go2 new file mode 100644 index 0000000000..1e8f4b0ec6 --- /dev/null +++ b/src/cmd/compile/internal/syntax/testdata/issue48382.go2 @@ -0,0 +1,15 @@ +// Copyright 2021 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 p + +type _ func /* ERROR function type cannot have type parameters */ [ /* ERROR empty type parameter list */ ]() +type _ func /* ERROR function type cannot have type parameters */ [ x /* ERROR missing type constraint */ ]() +type _ func /* ERROR function type cannot have type parameters */ [P any]() + +var _ = func /* ERROR function literal cannot have type parameters */ [P any]() {} + +type _ interface{ + m /* ERROR interface method cannot have type parameters */ [P any]() +} From 1292e212416f5bca1f32d3ec0679b7dae97f6f1b Mon Sep 17 00:00:00 2001 From: Zvonimir Pavlinovic Date: Wed, 3 Nov 2021 16:44:44 -0700 Subject: [PATCH 355/406] cmd/trace: use fmt.Print for newline-ending fixed string This redundancy is now caught by the improved printf vet checker. Updates #49322 Change-Id: Ic7a931b8d4838be02ebb855b69624b95093bd114 Reviewed-on: https://go-review.googlesource.com/c/go/+/361265 Run-TryBot: Zvonimir Pavlinovic TryBot-Result: Go Bot Trust: Zvonimir Pavlinovic Reviewed-by: Ian Lance Taylor --- src/cmd/trace/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/trace/main.go b/src/cmd/trace/main.go index f94586abf3..3aeba223ee 100644 --- a/src/cmd/trace/main.go +++ b/src/cmd/trace/main.go @@ -66,7 +66,7 @@ var ( func main() { flag.Usage = func() { - fmt.Fprintln(os.Stderr, usageMessage) + fmt.Fprint(os.Stderr, usageMessage) os.Exit(2) } flag.Parse() From e72d7150cb7f62edf6768ac5f33194d7f96443a1 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 2 Nov 2021 19:49:15 -0400 Subject: [PATCH 356/406] go/types: remove qualification from type parameter strings Type parameters only exist within the scope of a type or function declaration, so there is really no reason to package-qualify them. It is also confusing to do so, as it makes their type string look like a defined type. Fixes #49215 Change-Id: I986c527e78d45f3cadd75bc3b244e23dabe707ee Reviewed-on: https://go-review.googlesource.com/c/go/+/360938 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/api_test.go | 12 ++++++------ src/go/types/builtins_test.go | 6 +++--- src/go/types/typestring.go | 4 ---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/go/types/api_test.go b/src/go/types/api_test.go index 34cc61fc2c..807bffbff6 100644 --- a/src/go/types/api_test.go +++ b/src/go/types/api_test.go @@ -345,18 +345,18 @@ func TestTypesInfo(t *testing.T) { {broken + `x5; func _() { var x map[string][...]int; x = map[string][...]int{"": {1,2,3}} }`, `x`, `map[string][-1]int`}, // parameterized functions - {genericPkg + `p0; func f[T any](T) {}; var _ = f[int]`, `f`, `func[generic_p0.T interface{}](generic_p0.T)`}, + {genericPkg + `p0; func f[T any](T) {}; var _ = f[int]`, `f`, `func[T interface{}](T)`}, {genericPkg + `p1; func f[T any](T) {}; var _ = f[int]`, `f[int]`, `func(int)`}, {genericPkg + `p2; func f[T any](T) {}; func _() { f(42) }`, `f`, `func(int)`}, {genericPkg + `p3; func f[T any](T) {}; func _() { f[int](42) }`, `f[int]`, `func(int)`}, - {genericPkg + `p4; func f[T any](T) {}; func _() { f[int](42) }`, `f`, `func[generic_p4.T interface{}](generic_p4.T)`}, + {genericPkg + `p4; func f[T any](T) {}; func _() { f[int](42) }`, `f`, `func[T interface{}](T)`}, {genericPkg + `p5; func f[T any](T) {}; func _() { f(42) }`, `f(42)`, `()`}, // type parameters {genericPkg + `t0; type t[] int; var _ t`, `t`, `generic_t0.t`}, // t[] is a syntax error that is ignored in this test in favor of t - {genericPkg + `t1; type t[P any] int; var _ t[int]`, `t`, `generic_t1.t[generic_t1.P interface{}]`}, - {genericPkg + `t2; type t[P interface{}] int; var _ t[int]`, `t`, `generic_t2.t[generic_t2.P interface{}]`}, - {genericPkg + `t3; type t[P, Q interface{}] int; var _ t[int, int]`, `t`, `generic_t3.t[generic_t3.P, generic_t3.Q interface{}]`}, + {genericPkg + `t1; type t[P any] int; var _ t[int]`, `t`, `generic_t1.t[P interface{}]`}, + {genericPkg + `t2; type t[P interface{}] int; var _ t[int]`, `t`, `generic_t2.t[P interface{}]`}, + {genericPkg + `t3; type t[P, Q interface{}] int; var _ t[int, int]`, `t`, `generic_t3.t[P, Q interface{}]`}, // TODO (rFindley): compare with types2, which resolves the type broken_t4.t[P₁, Q₂ interface{m()}] here {broken + `t4; type t[P, Q interface{ m() }] int; var _ t[int, int]`, `t`, `broken_t4.t`}, @@ -365,7 +365,7 @@ func TestTypesInfo(t *testing.T) { {genericPkg + `g0; type t[P any] int; var x struct{ f t[int] }; var _ = x.f`, `x.f`, `generic_g0.t[int]`}, // issue 45096 - {genericPkg + `issue45096; func _[T interface{ ~int8 | ~int16 | ~int32 }](x T) { _ = x < 0 }`, `0`, `generic_issue45096.T`}, + {genericPkg + `issue45096; func _[T interface{ ~int8 | ~int16 | ~int32 }](x T) { _ = x < 0 }`, `0`, `T`}, // issue 47895 {`package p; import "unsafe"; type S struct { f int }; var s S; var _ = unsafe.Offsetof(s.f)`, `s.f`, `int`}, diff --git a/src/go/types/builtins_test.go b/src/go/types/builtins_test.go index db56aea3fe..edcd7e7724 100644 --- a/src/go/types/builtins_test.go +++ b/src/go/types/builtins_test.go @@ -113,15 +113,15 @@ var builtinCalls = []struct { {"Alignof", `_ = unsafe.Alignof(0)`, `invalid type`}, // constant {"Alignof", `var x struct{}; _ = unsafe.Alignof(x)`, `invalid type`}, // constant - {"Alignof", `var x P; _ = unsafe.Alignof(x)`, `func(p.P) uintptr`}, + {"Alignof", `var x P; _ = unsafe.Alignof(x)`, `func(P) uintptr`}, {"Offsetof", `var x struct{f bool}; _ = unsafe.Offsetof(x.f)`, `invalid type`}, // constant {"Offsetof", `var x struct{_ int; f bool}; _ = unsafe.Offsetof((&x).f)`, `invalid type`}, // constant - {"Offsetof", `var x struct{_ int; f P}; _ = unsafe.Offsetof((&x).f)`, `func(p.P) uintptr`}, + {"Offsetof", `var x struct{_ int; f P}; _ = unsafe.Offsetof((&x).f)`, `func(P) uintptr`}, {"Sizeof", `_ = unsafe.Sizeof(0)`, `invalid type`}, // constant {"Sizeof", `var x struct{}; _ = unsafe.Sizeof(x)`, `invalid type`}, // constant - {"Sizeof", `var x P; _ = unsafe.Sizeof(x)`, `func(p.P) uintptr`}, + {"Sizeof", `var x P; _ = unsafe.Sizeof(x)`, `func(P) uintptr`}, {"Slice", `var p *int; _ = unsafe.Slice(p, 1)`, `func(*int, int) []int`}, {"Slice", `var p *byte; var n uintptr; _ = unsafe.Slice(p, n)`, `func(*byte, uintptr) []byte`}, diff --git a/src/go/types/typestring.go b/src/go/types/typestring.go index 40a8ff475d..e138af6488 100644 --- a/src/go/types/typestring.go +++ b/src/go/types/typestring.go @@ -274,10 +274,6 @@ func (w *typeWriter) typ(typ Type) { w.error("unnamed type parameter") break } - // Optionally write out package for typeparams (like Named). - if t.obj.pkg != nil { - writePackage(w.buf, t.obj.pkg, w.qf) - } w.string(t.obj.name) if w.debug || w.ctxt != nil { w.string(subscript(t.id)) From 240df188d67edc3df498a77bf99d3152244c14ab Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Wed, 3 Nov 2021 15:29:43 -0700 Subject: [PATCH 357/406] cmd/compile: add extra test for the non-mono pass Just add a test for another function that is not monomorphisable, which comes from the Featherweight Go paper. Updates #48018 Change-Id: I664e3f48412b02678e32b50204dc4befae90374c Reviewed-on: https://go-review.googlesource.com/c/go/+/361262 Trust: Dan Scales Run-TryBot: Dan Scales TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- .../types2/testdata/fixedbugs/issue48018.go2 | 20 +++++++++++++++++++ .../types/testdata/fixedbugs/issue48018.go2 | 20 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/cmd/compile/internal/types2/testdata/fixedbugs/issue48018.go2 create mode 100644 src/go/types/testdata/fixedbugs/issue48018.go2 diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48018.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48018.go2 new file mode 100644 index 0000000000..e6ccc6b9be --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue48018.go2 @@ -0,0 +1,20 @@ +// Copyright 2021 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 main + +type Box[A any] struct { + value A +} + +func Nest[A /* ERROR instantiation cycle */ any](b Box[A], n int) interface{} { + if n == 0 { + return b + } + return Nest(Box[Box[A]]{b}, n-1) +} + +func main() { + Nest(Box[int]{0}, 10) +} diff --git a/src/go/types/testdata/fixedbugs/issue48018.go2 b/src/go/types/testdata/fixedbugs/issue48018.go2 new file mode 100644 index 0000000000..e6ccc6b9be --- /dev/null +++ b/src/go/types/testdata/fixedbugs/issue48018.go2 @@ -0,0 +1,20 @@ +// Copyright 2021 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 main + +type Box[A any] struct { + value A +} + +func Nest[A /* ERROR instantiation cycle */ any](b Box[A], n int) interface{} { + if n == 0 { + return b + } + return Nest(Box[Box[A]]{b}, n-1) +} + +func main() { + Nest(Box[int]{0}, 10) +} From d9bb5f6f109a4342c52958f30acfc3f3d633ee4f Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Wed, 3 Nov 2021 18:18:18 +0000 Subject: [PATCH 358/406] syscall: fix and document uses of RegEnumKeyEx RegEnumKeyEx has an undocumented requirement that subsequent calls need to be made from the same thread. This change documents that requirement and fixes uses of it in std. Fixes #49320. Change-Id: I6d182227e22dd437996a878b3a978943f01b2d61 Reviewed-on: https://go-review.googlesource.com/c/go/+/361154 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/internal/syscall/windows/registry/key.go | 11 ++++++- src/syscall/syscall_windows.go | 30 +++++++++++++++++++- src/syscall/zsyscall_windows.go | 2 +- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/internal/syscall/windows/registry/key.go b/src/internal/syscall/windows/registry/key.go index ba5c292c5e..ec38cf9288 100644 --- a/src/internal/syscall/windows/registry/key.go +++ b/src/internal/syscall/windows/registry/key.go @@ -25,7 +25,10 @@ // package registry -import "syscall" +import ( + "runtime" + "syscall" +) const ( // Registry key security and access rights. @@ -88,6 +91,12 @@ func OpenKey(k Key, path string, access uint32) (Key, error) { // ReadSubKeyNames returns the names of subkeys of key k. func (k Key) ReadSubKeyNames() ([]string, error) { + // RegEnumKeyEx must be called repeatedly and to completion. + // During this time, this goroutine cannot migrate away from + // its current thread. See #49320. + runtime.LockOSThread() + defer runtime.UnlockOSThread() + names := make([]string, 0) // Registry key size limit is 255 bytes and described there: // https://msdn.microsoft.com/library/windows/desktop/ms724872.aspx diff --git a/src/syscall/syscall_windows.go b/src/syscall/syscall_windows.go index 48fedb33d7..69e163e00f 100644 --- a/src/syscall/syscall_windows.go +++ b/src/syscall/syscall_windows.go @@ -279,7 +279,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) = advapi32.RegOpenKeyExW //sys RegCloseKey(key Handle) (regerrno error) = advapi32.RegCloseKey //sys RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegQueryInfoKeyW -//sys RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegEnumKeyExW +//sys regEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegEnumKeyExW //sys RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegQueryValueExW //sys getCurrentProcessId() (pid uint32) = kernel32.GetCurrentProcessId //sys GetConsoleMode(console Handle, mode *uint32) (err error) = kernel32.GetConsoleMode @@ -1301,3 +1301,31 @@ func newProcThreadAttributeList(maxAttrCount uint32) (*_PROC_THREAD_ATTRIBUTE_LI } return al, nil } + +// RegEnumKeyEx enumerates the subkeys of an open registry key. +// Each call retrieves information about one subkey. name is +// a buffer that should be large enough to hold the name of the +// subkey plus a null terminating character. nameLen is its +// length. On return, nameLen will contain the actual length of the +// subkey. +// +// Should name not be large enough to hold the subkey, this function +// will return ERROR_MORE_DATA, and must be called again with an +// appropriately sized buffer. +// +// reserved must be nil. class and classLen behave like name and nameLen +// but for the class of the subkey, except that they are optional. +// lastWriteTime, if not nil, will be populated with the time the subkey +// was last written. +// +// The caller must enumerate all subkeys in order. That is +// RegEnumKeyEx must be called with index starting at 0, incrementing +// the index until the function returns ERROR_NO_MORE_ITEMS, or with +// the index of the last subkey (obtainable from RegQueryInfoKey), +// decrementing until index 0 is enumerated. +// +// Successive calls to this API must happen on the same OS thread, +// so call runtime.LockOSThread before calling this function. +func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) { + return regEnumKeyEx(key, index, name, nameLen, reserved, class, classLen, lastWriteTime) +} diff --git a/src/syscall/zsyscall_windows.go b/src/syscall/zsyscall_windows.go index 7bfff16be6..2d6f34e059 100644 --- a/src/syscall/zsyscall_windows.go +++ b/src/syscall/zsyscall_windows.go @@ -305,7 +305,7 @@ func RegCloseKey(key Handle) (regerrno error) { return } -func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) { +func regEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) { r0, _, _ := Syscall9(procRegEnumKeyExW.Addr(), 8, uintptr(key), uintptr(index), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(classLen)), uintptr(unsafe.Pointer(lastWriteTime)), 0) if r0 != 0 { regerrno = Errno(r0) From bd49a998bf68609259c155cd7b9f4ed76d948a0d Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Mon, 1 Nov 2021 14:32:39 +0700 Subject: [PATCH 359/406] cmd/compile: fix missing update source type in storeArgOrLoad After removing trivial wrapper types, the source needs to be updated with new type, otherwise, it leads to mismatch between field offset and the source type for selecting struct/array. Fixes #49249 Change-Id: I26f9440bcb2e78bcf0617afc21d9d40cdbe4aca6 Reviewed-on: https://go-review.googlesource.com/c/go/+/360057 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: David Chase --- src/cmd/compile/internal/ssa/expand_calls.go | 2 + test/fixedbugs/issue49249.go | 55 ++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 test/fixedbugs/issue49249.go diff --git a/src/cmd/compile/internal/ssa/expand_calls.go b/src/cmd/compile/internal/ssa/expand_calls.go index 18c9ab696d..91ff9f87f9 100644 --- a/src/cmd/compile/internal/ssa/expand_calls.go +++ b/src/cmd/compile/internal/ssa/expand_calls.go @@ -954,6 +954,7 @@ func (x *expandState) storeArgOrLoad(pos src.XPos, b *Block, source, mem *Value, elt := t.Elem() if source.Type != t && t.NumElem() == 1 && elt.Size() == t.Size() && t.Size() == x.regSize { t = removeTrivialWrapperTypes(t) + source.Type = t // it could be a leaf type, but the "leaf" could be complex64 (for example) return x.storeArgOrLoad(pos, b, source, mem, t, storeOffset, loadRegOffset, storeRc) } @@ -987,6 +988,7 @@ func (x *expandState) storeArgOrLoad(pos src.XPos, b *Block, source, mem *Value, // v139 is later stored as an intVal == struct{val *big.Int} which naively requires the fields of // of a *uint8, which does not succeed. t = removeTrivialWrapperTypes(t) + source.Type = t // it could be a leaf type, but the "leaf" could be complex64 (for example) return x.storeArgOrLoad(pos, b, source, mem, t, storeOffset, loadRegOffset, storeRc) } diff --git a/test/fixedbugs/issue49249.go b/test/fixedbugs/issue49249.go new file mode 100644 index 0000000000..f152a5a701 --- /dev/null +++ b/test/fixedbugs/issue49249.go @@ -0,0 +1,55 @@ +// compile -l + +// Copyright 2021 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 p + +func f() int { + var a, b struct { + s struct { + s struct { + byte + float32 + } + } + } + _ = a + + return func() int { + return func() int { + a = struct { + s struct { + s struct { + byte + float32 + } + } + }{b.s} + return 0 + }() + }() +} + +func g() int { + var a, b struct { + s [1][1]struct { + byte + float32 + } + } + _ = a + + return func() int { + return func() int { + a = struct { + s [1][1]struct { + byte + float32 + } + }{b.s} + return 0 + }() + }() +} From 747e4afe0756cefd4281ba77855c6666e07beabf Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 3 Nov 2021 18:06:42 -0700 Subject: [PATCH 360/406] cmd/compile/internal/types2: remove qualification from type parameter strings This is a clean port of CL 360938 from go/types to types2. For #49215. Change-Id: If20779c862b71641cb6afe4c281fbad5488a8abe Reviewed-on: https://go-review.googlesource.com/c/go/+/361266 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/api_test.go | 14 +++++++------- src/cmd/compile/internal/types2/builtins_test.go | 6 +++--- src/cmd/compile/internal/types2/typestring.go | 4 ---- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/cmd/compile/internal/types2/api_test.go b/src/cmd/compile/internal/types2/api_test.go index 5e111d6d87..30cfbe0ee4 100644 --- a/src/cmd/compile/internal/types2/api_test.go +++ b/src/cmd/compile/internal/types2/api_test.go @@ -326,25 +326,25 @@ func TestTypesInfo(t *testing.T) { {brokenPkg + `x5; func _() { var x map[string][...]int; x = map[string][...]int{"": {1,2,3}} }`, `x`, `map[string]invalid type`}, // parameterized functions - {genericPkg + `p0; func f[T any](T) {}; var _ = f[int]`, `f`, `func[generic_p0.T interface{}](generic_p0.T)`}, + {genericPkg + `p0; func f[T any](T) {}; var _ = f[int]`, `f`, `func[T interface{}](T)`}, {genericPkg + `p1; func f[T any](T) {}; var _ = f[int]`, `f[int]`, `func(int)`}, {genericPkg + `p2; func f[T any](T) {}; func _() { f(42) }`, `f`, `func(int)`}, {genericPkg + `p3; func f[T any](T) {}; func _() { f[int](42) }`, `f[int]`, `func(int)`}, - {genericPkg + `p4; func f[T any](T) {}; func _() { f[int](42) }`, `f`, `func[generic_p4.T interface{}](generic_p4.T)`}, + {genericPkg + `p4; func f[T any](T) {}; func _() { f[int](42) }`, `f`, `func[T interface{}](T)`}, {genericPkg + `p5; func f[T any](T) {}; func _() { f(42) }`, `f(42)`, `()`}, // type parameters {genericPkg + `t0; type t[] int; var _ t`, `t`, `generic_t0.t`}, // t[] is a syntax error that is ignored in this test in favor of t - {genericPkg + `t1; type t[P any] int; var _ t[int]`, `t`, `generic_t1.t[generic_t1.P interface{}]`}, - {genericPkg + `t2; type t[P interface{}] int; var _ t[int]`, `t`, `generic_t2.t[generic_t2.P interface{}]`}, - {genericPkg + `t3; type t[P, Q interface{}] int; var _ t[int, int]`, `t`, `generic_t3.t[generic_t3.P, generic_t3.Q interface{}]`}, - {brokenPkg + `t4; type t[P, Q interface{ m() }] int; var _ t[int, int]`, `t`, `broken_t4.t[broken_t4.P, broken_t4.Q interface{m()}]`}, + {genericPkg + `t1; type t[P any] int; var _ t[int]`, `t`, `generic_t1.t[P interface{}]`}, + {genericPkg + `t2; type t[P interface{}] int; var _ t[int]`, `t`, `generic_t2.t[P interface{}]`}, + {genericPkg + `t3; type t[P, Q interface{}] int; var _ t[int, int]`, `t`, `generic_t3.t[P, Q interface{}]`}, + {brokenPkg + `t4; type t[P, Q interface{ m() }] int; var _ t[int, int]`, `t`, `broken_t4.t[P, Q interface{m()}]`}, // instantiated types must be sanitized {genericPkg + `g0; type t[P any] int; var x struct{ f t[int] }; var _ = x.f`, `x.f`, `generic_g0.t[int]`}, // issue 45096 - {genericPkg + `issue45096; func _[T interface{ ~int8 | ~int16 | ~int32 }](x T) { _ = x < 0 }`, `0`, `generic_issue45096.T`}, + {genericPkg + `issue45096; func _[T interface{ ~int8 | ~int16 | ~int32 }](x T) { _ = x < 0 }`, `0`, `T`}, // issue 47895 {`package p; import "unsafe"; type S struct { f int }; var s S; var _ = unsafe.Offsetof(s.f)`, `s.f`, `int`}, diff --git a/src/cmd/compile/internal/types2/builtins_test.go b/src/cmd/compile/internal/types2/builtins_test.go index dd71715a27..be5707cdfe 100644 --- a/src/cmd/compile/internal/types2/builtins_test.go +++ b/src/cmd/compile/internal/types2/builtins_test.go @@ -112,15 +112,15 @@ var builtinCalls = []struct { {"Alignof", `_ = unsafe.Alignof(0)`, `invalid type`}, // constant {"Alignof", `var x struct{}; _ = unsafe.Alignof(x)`, `invalid type`}, // constant - {"Alignof", `var x P; _ = unsafe.Alignof(x)`, `func(p.P) uintptr`}, + {"Alignof", `var x P; _ = unsafe.Alignof(x)`, `func(P) uintptr`}, {"Offsetof", `var x struct{f bool}; _ = unsafe.Offsetof(x.f)`, `invalid type`}, // constant {"Offsetof", `var x struct{_ int; f bool}; _ = unsafe.Offsetof((&x).f)`, `invalid type`}, // constant - {"Offsetof", `var x struct{_ int; f P}; _ = unsafe.Offsetof((&x).f)`, `func(p.P) uintptr`}, + {"Offsetof", `var x struct{_ int; f P}; _ = unsafe.Offsetof((&x).f)`, `func(P) uintptr`}, {"Sizeof", `_ = unsafe.Sizeof(0)`, `invalid type`}, // constant {"Sizeof", `var x struct{}; _ = unsafe.Sizeof(x)`, `invalid type`}, // constant - {"Sizeof", `var x P; _ = unsafe.Sizeof(x)`, `func(p.P) uintptr`}, + {"Sizeof", `var x P; _ = unsafe.Sizeof(x)`, `func(P) uintptr`}, {"Slice", `var p *int; _ = unsafe.Slice(p, 1)`, `func(*int, int) []int`}, {"Slice", `var p *byte; var n uintptr; _ = unsafe.Slice(p, n)`, `func(*byte, uintptr) []byte`}, diff --git a/src/cmd/compile/internal/types2/typestring.go b/src/cmd/compile/internal/types2/typestring.go index 56bf4124fd..f18a32016f 100644 --- a/src/cmd/compile/internal/types2/typestring.go +++ b/src/cmd/compile/internal/types2/typestring.go @@ -273,10 +273,6 @@ func (w *typeWriter) typ(typ Type) { w.error("unnamed type parameter") break } - // Optionally write out package for typeparams (like Named). - if t.obj.pkg != nil { - writePackage(w.buf, t.obj.pkg, w.qf) - } w.string(t.obj.name) if w.debug || w.ctxt != nil { w.string(subscript(t.id)) From 9e4e23c724bc2145c5aee6edf3ec60cc322047cc Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 2 Nov 2021 17:31:51 -0700 Subject: [PATCH 361/406] cmd/compile/internal/types2: rename isX predicates to allX, add simple is_X (step 1 of 2) Rename the isX predicates to allX to clearly identify that these predicates are looking inside type parameters. Introduce is_X as predicates that do not look inside type parameters so we can see all call sites. The next CL will rename them all back to isX. Review all call sites and use correct predicate. Replace the single helper function is with isBasic and allBasic. Change-Id: I3430ccfc466fdedf4b58a6158f95d47b9020f7a5 Change-Id: I81116b87cf8f2e17526723c7440676d133057aca Reviewed-on: https://go-review.googlesource.com/c/go/+/360955 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/builtins.go | 14 +-- src/cmd/compile/internal/types2/check.go | 6 +- .../compile/internal/types2/conversions.go | 12 +-- src/cmd/compile/internal/types2/expr.go | 90 +++++++++---------- src/cmd/compile/internal/types2/index.go | 8 +- src/cmd/compile/internal/types2/predicates.go | 66 +++++++++----- src/cmd/compile/internal/types2/sizes.go | 2 +- src/cmd/compile/internal/types2/stmt.go | 8 +- src/cmd/compile/internal/types2/typexpr.go | 2 +- 9 files changed, 114 insertions(+), 94 deletions(-) diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index c5c6bdf0a5..c92eccf765 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -101,7 +101,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( if x.mode == invalid { return } - if isString(x.typ) { + if allString(x.typ) { if check.Types != nil { sig := makeSig(S, S, x.typ) sig.variadic = true @@ -146,7 +146,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( var val constant.Value switch typ = arrayPtrDeref(under(x.typ)); t := typ.(type) { case *Basic: - if isString(t) && id == _Len { + if is_String(t) && id == _Len { if x.mode == constant_ { mode = constant_ val = constant.MakeInt64(int64(len(constant.StringVal(x.val)))) @@ -182,7 +182,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( if t.underIs(func(t Type) bool { switch t := arrayPtrDeref(t).(type) { case *Basic: - if isString(t) && id == _Len { + if is_String(t) && id == _Len { return true } case *Array, *Slice, *Chan: @@ -267,7 +267,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // because shifts of floats are not permitted) if x.mode == constant_ && y.mode == constant_ { toFloat := func(x *operand) { - if isNumeric(x.typ) && constant.Sign(constant.Imag(x.val)) == 0 { + if is_Numeric(x.typ) && constant.Sign(constant.Imag(x.val)) == 0 { x.typ = Typ[UntypedFloat] } } @@ -398,7 +398,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( if x.mode == constant_ { // an untyped constant number can always be considered // as a complex constant - if isNumeric(x.typ) { + if is_Numeric(x.typ) { x.typ = Typ[UntypedComplex] } } else { @@ -726,7 +726,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // assert(pred) causes a typechecker error if pred is false. // The result of assert is the value of pred if there is no error. // Note: assert is only available in self-test mode. - if x.mode != constant_ || !isBoolean(x.typ) { + if x.mode != constant_ || !is_Boolean(x.typ) { check.errorf(x, invalidArg+"%s is not a boolean constant", x) return } @@ -802,7 +802,7 @@ func structure(typ Type) Type { func structureString(typ Type) Type { var su Type if underIs(typ, func(u Type) bool { - if isString(u) { + if is_String(u) { u = NewSlice(universeByte) } if su != nil && !Identical(su, u) { diff --git a/src/cmd/compile/internal/types2/check.go b/src/cmd/compile/internal/types2/check.go index ffc59f7011..f69514e38a 100644 --- a/src/cmd/compile/internal/types2/check.go +++ b/src/cmd/compile/internal/types2/check.go @@ -430,9 +430,9 @@ func (check *Checker) recordTypeAndValue(x syntax.Expr, mode operandMode, typ Ty } if mode == constant_ { assert(val != nil) - // We check is(typ, IsConstType) here as constant expressions may be + // We check allBasic(typ, IsConstType) here as constant expressions may be // recorded as type parameters. - assert(typ == Typ[Invalid] || is(typ, IsConstType)) + assert(typ == Typ[Invalid] || allBasic(typ, IsConstType)) } if m := check.Types; m != nil { m[x] = TypeAndValue{mode, typ, val} @@ -462,7 +462,7 @@ func (check *Checker) recordCommaOkTypes(x syntax.Expr, a [2]Type) { if a[0] == nil || a[1] == nil { return } - assert(isTyped(a[0]) && isTyped(a[1]) && (isBoolean(a[1]) || a[1] == universeError)) + assert(isTyped(a[0]) && isTyped(a[1]) && (is_Boolean(a[1]) || a[1] == universeError)) if m := check.Types; m != nil { for { tv := m[x] diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index 5798bacca7..c029f1147d 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -22,7 +22,7 @@ func (check *Checker) conversion(x *operand, T Type) { // nothing to do case representableConst(x.val, check, t, val): return true - case isInteger(x.typ) && isString(t): + case is_Integer(x.typ) && is_String(t): codepoint := unicode.ReplacementChar if i, ok := constant.Uint64Val(x.val); ok && i <= unicode.MaxRune { codepoint = rune(i) @@ -93,7 +93,7 @@ func (check *Checker) conversion(x *operand, T Type) { // ok } else if IsInterface(T) || constArg && !isConstType(T) { final = Default(x.typ) - } else if isInteger(x.typ) && isString(T) { + } else if is_Integer(x.typ) && allString(T) { final = x.typ } check.updateExprType(x.expr, final, true) @@ -197,22 +197,22 @@ func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { } // "V and T are both integer or floating point types" - if isIntegerOrFloat(V) && isIntegerOrFloat(T) { + if is_IntegerOrFloat(V) && is_IntegerOrFloat(T) { return true } // "V and T are both complex types" - if isComplex(V) && isComplex(T) { + if is_Complex(V) && is_Complex(T) { return true } // "V is an integer or a slice of bytes or runes and T is a string type" - if (isInteger(V) || isBytesOrRunes(Vu)) && isString(T) { + if (is_Integer(V) || isBytesOrRunes(Vu)) && is_String(T) { return true } // "V is a string and T is a slice of bytes or runes" - if isString(V) && isBytesOrRunes(Tu) { + if is_String(V) && isBytesOrRunes(Tu) { return true } diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index eb5ec9f3fb..1db5af00da 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -63,10 +63,10 @@ var unaryOpPredicates opPredicates func init() { // Setting unaryOpPredicates in init avoids declaration cycles. unaryOpPredicates = opPredicates{ - syntax.Add: isNumeric, - syntax.Sub: isNumeric, - syntax.Xor: isInteger, - syntax.Not: isBoolean, + syntax.Add: allNumeric, + syntax.Sub: allNumeric, + syntax.Xor: allInteger, + syntax.Not: allBoolean, } } @@ -225,7 +225,7 @@ func (check *Checker) unary(x *operand, e *syntax.Operation) { return } var prec uint - if isUnsigned(x.typ) { + if is_Unsigned(x.typ) { prec = uint(check.conf.sizeof(x.typ) * 8) } x.val = constant.UnaryOp(op2tok[e.Op], x.val, prec) @@ -302,7 +302,7 @@ func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *c } switch { - case isInteger(typ): + case is_Integer(typ): x := constant.ToInt(x) if x.Kind() != constant.Int { return false @@ -357,7 +357,7 @@ func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *c return true } - case isFloat(typ): + case is_Float(typ): x := constant.ToFloat(x) if x.Kind() != constant.Float { return false @@ -387,7 +387,7 @@ func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *c unreachable() } - case isComplex(typ): + case is_Complex(typ): x := constant.ToComplex(x) if x.Kind() != constant.Complex { return false @@ -419,10 +419,10 @@ func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *c unreachable() } - case isString(typ): + case is_String(typ): return x.Kind() == constant.String - case isBoolean(typ): + case is_Boolean(typ): return x.Kind() == constant.Bool } @@ -474,7 +474,7 @@ func (check *Checker) representation(x *operand, typ *Basic) (constant.Value, er assert(x.mode == constant_) v := x.val if !representableConst(x.val, check, typ, &v) { - if isNumeric(x.typ) && isNumeric(typ) { + if is_Numeric(x.typ) && is_Numeric(typ) { // numeric conversion : error msg // // integer -> integer : overflows @@ -482,7 +482,7 @@ func (check *Checker) representation(x *operand, typ *Basic) (constant.Value, er // float -> integer : truncated // float -> float : overflows // - if !isInteger(x.typ) && isInteger(typ) { + if !is_Integer(x.typ) && is_Integer(typ) { return nil, _TruncatedFloat } else { return nil, _NumericOverflow @@ -630,7 +630,7 @@ func (check *Checker) updateExprType(x syntax.Expr, typ Type, final bool) { // If x is the lhs of a shift, its final type must be integer. // We already know from the shift check that it is representable // as an integer if it is a constant. - if !isInteger(typ) { + if !is_Integer(typ) { check.errorf(x, invalidOp+"shifted operand %s (type %s) must be integer", x, typ) return } @@ -692,7 +692,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const // both x and target are untyped xkind := x.typ.(*Basic).kind tkind := target.(*Basic).kind - if isNumeric(x.typ) && isNumeric(target) { + if is_Numeric(x.typ) && is_Numeric(target) { if xkind < tkind { return target, nil, 0 } @@ -710,10 +710,10 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const return nil, nil, _InvalidUntypedConversion } - switch t := under(target).(type) { + switch u := under(target).(type) { case *Basic: if x.mode == constant_ { - v, code := check.representation(x, t) + v, code := check.representation(x, u) if code != 0 { return nil, nil, code } @@ -725,18 +725,18 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const // the value nil. switch x.typ.(*Basic).kind { case UntypedBool: - if !isBoolean(target) { + if !is_Boolean(target) { return nil, nil, _InvalidUntypedConversion } case UntypedInt, UntypedRune, UntypedFloat, UntypedComplex: - if !isNumeric(target) { + if !is_Numeric(target) { return nil, nil, _InvalidUntypedConversion } case UntypedString: // Non-constant untyped string values are not permitted by the spec and // should not occur during normal typechecking passes, but this path is // reachable via the AssignableTo API. - if !isString(target) { + if !is_String(target) { return nil, nil, _InvalidUntypedConversion } default: @@ -744,7 +744,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const } case *TypeParam: // TODO(gri) review this code - doesn't look quite right - ok := t.underIs(func(t Type) bool { + ok := u.underIs(func(t Type) bool { target, _, _ := check.implicitTypeAndValue(x, t) return target != nil }) @@ -755,7 +755,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const // Update operand types to the default type rather than the target // (interface) type: values must have concrete dynamic types. // Untyped nil was handled upfront. - if !t.Empty() { + if !u.Empty() { return nil, nil, _InvalidUntypedConversion // cannot assign untyped values to non-empty interfaces } return Default(x.typ), nil, 0 // default type for nil is nil @@ -779,7 +779,7 @@ func (check *Checker) comparison(x, y *operand, op syntax.Operator) { defined = Comparable(x.typ) && Comparable(y.typ) || x.isNil() && hasNil(y.typ) || y.isNil() && hasNil(x.typ) case syntax.Lss, syntax.Leq, syntax.Gtr, syntax.Geq: // spec: The ordering operators <, <=, >, and >= apply to operands that are ordered." - defined = isOrdered(x.typ) && isOrdered(y.typ) + defined = allOrdered(x.typ) && allOrdered(y.typ) default: unreachable() } @@ -833,7 +833,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) { xval = constant.ToInt(x.val) } - if isInteger(x.typ) || isUntyped(x.typ) && xval != nil && xval.Kind() == constant.Int { + if allInteger(x.typ) || isUntyped(x.typ) && xval != nil && xval.Kind() == constant.Int { // The lhs is of integer type or an untyped constant representable // as an integer. Nothing to do. } else { @@ -856,7 +856,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) { } } - // Caution: Check for isUntyped first because isInteger includes untyped + // Caution: Check for isUntyped first because is_Integer includes untyped // integers (was bug #43697). if isUntyped(y.typ) { check.convertUntyped(y, Typ[Uint]) @@ -864,11 +864,11 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) { x.mode = invalid return } - } else if !isInteger(y.typ) { + } else if !allInteger(y.typ) { check.errorf(y, invalidOp+"shift count %s must be integer", y) x.mode = invalid return - } else if !isUnsigned(y.typ) && !check.allowVersion(check.pkg, 1, 13) { + } else if !allUnsigned(y.typ) && !check.allowVersion(check.pkg, 1, 13) { check.errorf(y, invalidOp+"signed shift count %s requires go1.13 or later", y) x.mode = invalid return @@ -880,7 +880,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) { if x.val.Kind() == constant.Unknown || y.val.Kind() == constant.Unknown { x.val = constant.MakeUnknown() // ensure the correct type - see comment below - if !isInteger(x.typ) { + if !is_Integer(x.typ) { x.typ = Typ[UntypedInt] } return @@ -897,7 +897,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) { // (e.g., 2.0, an untyped float) - this can only happen for untyped // non-integer numeric constants. Correct the type so that the shift // result is of integer type. - if !isInteger(x.typ) { + if !is_Integer(x.typ) { x.typ = Typ[UntypedInt] } // x is a constant so xval != nil and it must be of Int kind. @@ -939,7 +939,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) { } // non-constant shift - lhs must be an integer - if !isInteger(x.typ) { + if !allInteger(x.typ) { check.errorf(x, invalidOp+"shifted operand %s must be integer", x) x.mode = invalid return @@ -953,19 +953,19 @@ var binaryOpPredicates opPredicates func init() { // Setting binaryOpPredicates in init avoids declaration cycles. binaryOpPredicates = opPredicates{ - syntax.Add: isNumericOrString, - syntax.Sub: isNumeric, - syntax.Mul: isNumeric, - syntax.Div: isNumeric, - syntax.Rem: isInteger, + syntax.Add: allNumericOrString, + syntax.Sub: allNumeric, + syntax.Mul: allNumeric, + syntax.Div: allNumeric, + syntax.Rem: allInteger, - syntax.And: isInteger, - syntax.Or: isInteger, - syntax.Xor: isInteger, - syntax.AndNot: isInteger, + syntax.And: allInteger, + syntax.Or: allInteger, + syntax.Xor: allInteger, + syntax.AndNot: allInteger, - syntax.AndAnd: isBoolean, - syntax.OrOr: isBoolean, + syntax.AndAnd: allBoolean, + syntax.OrOr: allBoolean, } } @@ -995,10 +995,10 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op if IsInterface(x.typ) || IsInterface(y.typ) { return true } - if isBoolean(x.typ) != isBoolean(y.typ) { + if allBoolean(x.typ) != allBoolean(y.typ) { return false } - if isString(x.typ) != isString(y.typ) { + if allString(x.typ) != allString(y.typ) { return false } if x.isNil() && !hasNil(y.typ) { @@ -1047,14 +1047,14 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op if op == syntax.Div || op == syntax.Rem { // check for zero divisor - if (x.mode == constant_ || isInteger(x.typ)) && y.mode == constant_ && constant.Sign(y.val) == 0 { + if (x.mode == constant_ || allInteger(x.typ)) && y.mode == constant_ && constant.Sign(y.val) == 0 { check.error(&y, invalidOp+"division by zero") x.mode = invalid return } // check for divisor underflow in complex division (see issue 20227) - if x.mode == constant_ && y.mode == constant_ && isComplex(x.typ) { + if x.mode == constant_ && y.mode == constant_ && is_Complex(x.typ) { re, im := constant.Real(y.val), constant.Imag(y.val) re2, im2 := constant.BinaryOp(re, token.MUL, re), constant.BinaryOp(im, token.MUL, im) if constant.Sign(re2) == 0 && constant.Sign(im2) == 0 { @@ -1074,7 +1074,7 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op } // force integer division for integer operands tok := op2tok[op] - if op == syntax.Div && isInteger(x.typ) { + if op == syntax.Div && is_Integer(x.typ) { tok = token.QUO_ASSIGN } x.val = constant.BinaryOp(x.val, tok, y.val) diff --git a/src/cmd/compile/internal/types2/index.go b/src/cmd/compile/internal/types2/index.go index bb7033e957..1b080139f3 100644 --- a/src/cmd/compile/internal/types2/index.go +++ b/src/cmd/compile/internal/types2/index.go @@ -51,7 +51,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo length := int64(-1) // valid if >= 0 switch typ := under(x.typ).(type) { case *Basic: - if isString(typ) { + if is_String(typ) { valid = true if x.mode == constant_ { length = int64(len(constant.StringVal(x.val))) @@ -109,7 +109,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo var k, e Type // k is only set for maps switch t := u.(type) { case *Basic: - if isString(t) { + if is_String(t) { e = universeByte mode = value } @@ -217,7 +217,7 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) { return case *Basic: - if isString(u) { + if is_String(u) { if e.Full { check.error(x, invalidOp+"3-index slice of string") x.mode = invalid @@ -386,7 +386,7 @@ func (check *Checker) isValidIndex(x *operand, what string, allowNegative bool) } // spec: "the index x must be of integer type or an untyped constant" - if !isInteger(x.typ) { + if !allInteger(x.typ) { check.errorf(x, invalidArg+"%s %s must be integer", what, x) return false } diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go index 6d93a8a227..980d254084 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -25,33 +25,55 @@ func isGeneric(typ Type) bool { return named != nil && named.obj != nil && named.targs == nil && named.TypeParams() != nil } -func is(typ Type, what BasicInfo) bool { - switch t := under(typ).(type) { +// The is_X predicates below report whether t is an X. +// If t is a type parameter the result is false; i.e., +// these predicates don't look inside a type parameter. + +func is_Boolean(t Type) bool { return isBasic(t, IsBoolean) } +func is_Integer(t Type) bool { return isBasic(t, IsInteger) } +func is_Unsigned(t Type) bool { return isBasic(t, IsUnsigned) } +func is_Float(t Type) bool { return isBasic(t, IsFloat) } +func is_Complex(t Type) bool { return isBasic(t, IsComplex) } +func is_Numeric(t Type) bool { return isBasic(t, IsNumeric) } +func is_String(t Type) bool { return isBasic(t, IsString) } +func is_IntegerOrFloat(t Type) bool { return isBasic(t, IsInteger|IsFloat) } + +// isBasic reports whether under(t) is a basic type with the specified info. +// If t is a type parameter the result is false; i.e., +// isBasic does not look inside a type parameter. +func isBasic(t Type, info BasicInfo) bool { + u, _ := under(t).(*Basic) + return u != nil && u.info&info != 0 +} + +// The allX predicates below report whether t is an X. +// If t is a type parameter the result is true if is_X is true +// for all specified types of the type parameter's type set. +// allX is an optimized version of is_X(structure(t)) (which +// is the same as underIs(t, is_X)). + +func allBoolean(t Type) bool { return allBasic(t, IsBoolean) } +func allInteger(t Type) bool { return allBasic(t, IsInteger) } +func allUnsigned(t Type) bool { return allBasic(t, IsUnsigned) } +func allNumeric(t Type) bool { return allBasic(t, IsNumeric) } +func allString(t Type) bool { return allBasic(t, IsString) } +func allOrdered(t Type) bool { return allBasic(t, IsOrdered) } +func allNumericOrString(t Type) bool { return allBasic(t, IsNumeric|IsString) } + +// allBasic reports whether under(t) is a basic type with the specified info. +// If t is a type parameter, the result is true if isBasic(t, info) is true +// for all specific types of the type parameter's type set. +// allBasic(t, info) is an optimized version of isBasic(structure(t), info). +func allBasic(t Type, info BasicInfo) bool { + switch u := under(t).(type) { case *Basic: - return t.info&what != 0 + return u.info&info != 0 case *TypeParam: - return t.underIs(func(t Type) bool { return is(t, what) }) + return u.is(func(t *term) bool { return t != nil && isBasic(t.typ, info) }) } return false } -func isBoolean(typ Type) bool { return is(typ, IsBoolean) } -func isInteger(typ Type) bool { return is(typ, IsInteger) } -func isUnsigned(typ Type) bool { return is(typ, IsUnsigned) } -func isFloat(typ Type) bool { return is(typ, IsFloat) } -func isComplex(typ Type) bool { return is(typ, IsComplex) } -func isNumeric(typ Type) bool { return is(typ, IsNumeric) } -func isString(typ Type) bool { return is(typ, IsString) } - -// Note that if typ is a type parameter, isInteger(typ) || isFloat(typ) does not -// produce the expected result because a type set that contains both an integer -// and a floating-point type is neither (all) integers, nor (all) floats. -// Use isIntegerOrFloat instead. -func isIntegerOrFloat(typ Type) bool { return is(typ, IsInteger|IsFloat) } - -// isNumericOrString is the equivalent of isIntegerOrFloat for isNumeric(typ) || isString(typ). -func isNumericOrString(typ Type) bool { return is(typ, IsNumeric|IsString) } - // isTyped reports whether typ is typed; i.e., not an untyped // constant or boolean. isTyped may be called with types that // are not fully set up. @@ -67,8 +89,6 @@ func isUntyped(typ Type) bool { return !isTyped(typ) } -func isOrdered(typ Type) bool { return is(typ, IsOrdered) } - func isConstType(typ Type) bool { // Type parameters are never const types. t := asBasic(typ) diff --git a/src/cmd/compile/internal/types2/sizes.go b/src/cmd/compile/internal/types2/sizes.go index 6a3d19d8ea..8f93ca6b87 100644 --- a/src/cmd/compile/internal/types2/sizes.go +++ b/src/cmd/compile/internal/types2/sizes.go @@ -82,7 +82,7 @@ func (s *StdSizes) Alignof(T Type) int64 { return 1 } // complex{64,128} are aligned like [2]float{32,64}. - if isComplex(T) { + if is_Complex(T) { a /= 2 } if a > s.MaxAlign { diff --git a/src/cmd/compile/internal/types2/stmt.go b/src/cmd/compile/internal/types2/stmt.go index dd2100f711..b8b53a868e 100644 --- a/src/cmd/compile/internal/types2/stmt.go +++ b/src/cmd/compile/internal/types2/stmt.go @@ -443,7 +443,7 @@ func (check *Checker) stmt(ctxt stmtContext, s syntax.Stmt) { if x.mode == invalid { return } - if !isNumeric(x.typ) { + if !allNumeric(x.typ) { check.errorf(lhs[0], invalidOp+"%s%s%s (non-numeric type %s)", lhs[0], s.Op, s.Op, x.typ) return } @@ -556,7 +556,7 @@ func (check *Checker) stmt(ctxt stmtContext, s syntax.Stmt) { check.simpleStmt(s.Init) var x operand check.expr(&x, s.Cond) - if x.mode != invalid && !isBoolean(x.typ) { + if x.mode != invalid && !allBoolean(x.typ) { check.error(s.Cond, "non-boolean condition in if statement") } check.stmt(inner, s.Then) @@ -645,7 +645,7 @@ func (check *Checker) stmt(ctxt stmtContext, s syntax.Stmt) { if s.Cond != nil { var x operand check.expr(&x, s.Cond) - if x.mode != invalid && !isBoolean(x.typ) { + if x.mode != invalid && !allBoolean(x.typ) { check.error(s.Cond, "non-boolean condition in for statement") } } @@ -942,7 +942,7 @@ func (check *Checker) rangeStmt(inner stmtContext, s *syntax.ForStmt, rclause *s func rangeKeyVal(typ Type) (key, val Type) { switch typ := arrayPtrDeref(typ).(type) { case *Basic: - if isString(typ) { + if is_String(typ) { return Typ[Int], universeRune // use 'rune' name } case *Array: diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go index 95893fd1e1..7007176980 100644 --- a/src/cmd/compile/internal/types2/typexpr.go +++ b/src/cmd/compile/internal/types2/typexpr.go @@ -513,7 +513,7 @@ func (check *Checker) arrayLength(e syntax.Expr) int64 { return -1 } - if isUntyped(x.typ) || isInteger(x.typ) { + if isUntyped(x.typ) || is_Integer(x.typ) { if val := constant.ToInt(x.val); val.Kind() == constant.Int { if representableConst(val, check, Typ[Int], nil) { if n, ok := constant.Int64Val(val); ok && n >= 0 { From ad2044a498cbbb211fe14fd4eeb0a63709363cfc Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 3 Nov 2021 08:39:41 -0700 Subject: [PATCH 362/406] cmd/compile/internal/types2: rename is_X predicates back to isX (step 2 of 2) This is s/is_/is/ throughout. No other changes. Change-Id: I1be77a209133edc68a6dec0677a4991a7683f116 Reviewed-on: https://go-review.googlesource.com/c/go/+/361134 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/builtins.go | 12 +++---- src/cmd/compile/internal/types2/check.go | 2 +- .../compile/internal/types2/conversions.go | 12 +++---- src/cmd/compile/internal/types2/expr.go | 36 +++++++++---------- src/cmd/compile/internal/types2/index.go | 6 ++-- src/cmd/compile/internal/types2/predicates.go | 24 ++++++------- src/cmd/compile/internal/types2/sizes.go | 2 +- src/cmd/compile/internal/types2/stmt.go | 2 +- src/cmd/compile/internal/types2/typexpr.go | 2 +- 9 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index c92eccf765..548d55e10c 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -146,7 +146,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( var val constant.Value switch typ = arrayPtrDeref(under(x.typ)); t := typ.(type) { case *Basic: - if is_String(t) && id == _Len { + if isString(t) && id == _Len { if x.mode == constant_ { mode = constant_ val = constant.MakeInt64(int64(len(constant.StringVal(x.val)))) @@ -182,7 +182,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( if t.underIs(func(t Type) bool { switch t := arrayPtrDeref(t).(type) { case *Basic: - if is_String(t) && id == _Len { + if isString(t) && id == _Len { return true } case *Array, *Slice, *Chan: @@ -267,7 +267,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // because shifts of floats are not permitted) if x.mode == constant_ && y.mode == constant_ { toFloat := func(x *operand) { - if is_Numeric(x.typ) && constant.Sign(constant.Imag(x.val)) == 0 { + if isNumeric(x.typ) && constant.Sign(constant.Imag(x.val)) == 0 { x.typ = Typ[UntypedFloat] } } @@ -398,7 +398,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( if x.mode == constant_ { // an untyped constant number can always be considered // as a complex constant - if is_Numeric(x.typ) { + if isNumeric(x.typ) { x.typ = Typ[UntypedComplex] } } else { @@ -726,7 +726,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // assert(pred) causes a typechecker error if pred is false. // The result of assert is the value of pred if there is no error. // Note: assert is only available in self-test mode. - if x.mode != constant_ || !is_Boolean(x.typ) { + if x.mode != constant_ || !isBoolean(x.typ) { check.errorf(x, invalidArg+"%s is not a boolean constant", x) return } @@ -802,7 +802,7 @@ func structure(typ Type) Type { func structureString(typ Type) Type { var su Type if underIs(typ, func(u Type) bool { - if is_String(u) { + if isString(u) { u = NewSlice(universeByte) } if su != nil && !Identical(su, u) { diff --git a/src/cmd/compile/internal/types2/check.go b/src/cmd/compile/internal/types2/check.go index f69514e38a..b9a76a8990 100644 --- a/src/cmd/compile/internal/types2/check.go +++ b/src/cmd/compile/internal/types2/check.go @@ -462,7 +462,7 @@ func (check *Checker) recordCommaOkTypes(x syntax.Expr, a [2]Type) { if a[0] == nil || a[1] == nil { return } - assert(isTyped(a[0]) && isTyped(a[1]) && (is_Boolean(a[1]) || a[1] == universeError)) + assert(isTyped(a[0]) && isTyped(a[1]) && (isBoolean(a[1]) || a[1] == universeError)) if m := check.Types; m != nil { for { tv := m[x] diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index c029f1147d..bd7b82fabf 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -22,7 +22,7 @@ func (check *Checker) conversion(x *operand, T Type) { // nothing to do case representableConst(x.val, check, t, val): return true - case is_Integer(x.typ) && is_String(t): + case isInteger(x.typ) && isString(t): codepoint := unicode.ReplacementChar if i, ok := constant.Uint64Val(x.val); ok && i <= unicode.MaxRune { codepoint = rune(i) @@ -93,7 +93,7 @@ func (check *Checker) conversion(x *operand, T Type) { // ok } else if IsInterface(T) || constArg && !isConstType(T) { final = Default(x.typ) - } else if is_Integer(x.typ) && allString(T) { + } else if isInteger(x.typ) && allString(T) { final = x.typ } check.updateExprType(x.expr, final, true) @@ -197,22 +197,22 @@ func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { } // "V and T are both integer or floating point types" - if is_IntegerOrFloat(V) && is_IntegerOrFloat(T) { + if isIntegerOrFloat(V) && isIntegerOrFloat(T) { return true } // "V and T are both complex types" - if is_Complex(V) && is_Complex(T) { + if isComplex(V) && isComplex(T) { return true } // "V is an integer or a slice of bytes or runes and T is a string type" - if (is_Integer(V) || isBytesOrRunes(Vu)) && is_String(T) { + if (isInteger(V) || isBytesOrRunes(Vu)) && isString(T) { return true } // "V is a string and T is a slice of bytes or runes" - if is_String(V) && isBytesOrRunes(Tu) { + if isString(V) && isBytesOrRunes(Tu) { return true } diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index 1db5af00da..95b96f2334 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -225,7 +225,7 @@ func (check *Checker) unary(x *operand, e *syntax.Operation) { return } var prec uint - if is_Unsigned(x.typ) { + if isUnsigned(x.typ) { prec = uint(check.conf.sizeof(x.typ) * 8) } x.val = constant.UnaryOp(op2tok[e.Op], x.val, prec) @@ -302,7 +302,7 @@ func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *c } switch { - case is_Integer(typ): + case isInteger(typ): x := constant.ToInt(x) if x.Kind() != constant.Int { return false @@ -357,7 +357,7 @@ func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *c return true } - case is_Float(typ): + case isFloat(typ): x := constant.ToFloat(x) if x.Kind() != constant.Float { return false @@ -387,7 +387,7 @@ func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *c unreachable() } - case is_Complex(typ): + case isComplex(typ): x := constant.ToComplex(x) if x.Kind() != constant.Complex { return false @@ -419,10 +419,10 @@ func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *c unreachable() } - case is_String(typ): + case isString(typ): return x.Kind() == constant.String - case is_Boolean(typ): + case isBoolean(typ): return x.Kind() == constant.Bool } @@ -474,7 +474,7 @@ func (check *Checker) representation(x *operand, typ *Basic) (constant.Value, er assert(x.mode == constant_) v := x.val if !representableConst(x.val, check, typ, &v) { - if is_Numeric(x.typ) && is_Numeric(typ) { + if isNumeric(x.typ) && isNumeric(typ) { // numeric conversion : error msg // // integer -> integer : overflows @@ -482,7 +482,7 @@ func (check *Checker) representation(x *operand, typ *Basic) (constant.Value, er // float -> integer : truncated // float -> float : overflows // - if !is_Integer(x.typ) && is_Integer(typ) { + if !isInteger(x.typ) && isInteger(typ) { return nil, _TruncatedFloat } else { return nil, _NumericOverflow @@ -630,7 +630,7 @@ func (check *Checker) updateExprType(x syntax.Expr, typ Type, final bool) { // If x is the lhs of a shift, its final type must be integer. // We already know from the shift check that it is representable // as an integer if it is a constant. - if !is_Integer(typ) { + if !isInteger(typ) { check.errorf(x, invalidOp+"shifted operand %s (type %s) must be integer", x, typ) return } @@ -692,7 +692,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const // both x and target are untyped xkind := x.typ.(*Basic).kind tkind := target.(*Basic).kind - if is_Numeric(x.typ) && is_Numeric(target) { + if isNumeric(x.typ) && isNumeric(target) { if xkind < tkind { return target, nil, 0 } @@ -725,18 +725,18 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const // the value nil. switch x.typ.(*Basic).kind { case UntypedBool: - if !is_Boolean(target) { + if !isBoolean(target) { return nil, nil, _InvalidUntypedConversion } case UntypedInt, UntypedRune, UntypedFloat, UntypedComplex: - if !is_Numeric(target) { + if !isNumeric(target) { return nil, nil, _InvalidUntypedConversion } case UntypedString: // Non-constant untyped string values are not permitted by the spec and // should not occur during normal typechecking passes, but this path is // reachable via the AssignableTo API. - if !is_String(target) { + if !isString(target) { return nil, nil, _InvalidUntypedConversion } default: @@ -856,7 +856,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) { } } - // Caution: Check for isUntyped first because is_Integer includes untyped + // Caution: Check for isUntyped first because isInteger includes untyped // integers (was bug #43697). if isUntyped(y.typ) { check.convertUntyped(y, Typ[Uint]) @@ -880,7 +880,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) { if x.val.Kind() == constant.Unknown || y.val.Kind() == constant.Unknown { x.val = constant.MakeUnknown() // ensure the correct type - see comment below - if !is_Integer(x.typ) { + if !isInteger(x.typ) { x.typ = Typ[UntypedInt] } return @@ -897,7 +897,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) { // (e.g., 2.0, an untyped float) - this can only happen for untyped // non-integer numeric constants. Correct the type so that the shift // result is of integer type. - if !is_Integer(x.typ) { + if !isInteger(x.typ) { x.typ = Typ[UntypedInt] } // x is a constant so xval != nil and it must be of Int kind. @@ -1054,7 +1054,7 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op } // check for divisor underflow in complex division (see issue 20227) - if x.mode == constant_ && y.mode == constant_ && is_Complex(x.typ) { + if x.mode == constant_ && y.mode == constant_ && isComplex(x.typ) { re, im := constant.Real(y.val), constant.Imag(y.val) re2, im2 := constant.BinaryOp(re, token.MUL, re), constant.BinaryOp(im, token.MUL, im) if constant.Sign(re2) == 0 && constant.Sign(im2) == 0 { @@ -1074,7 +1074,7 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op } // force integer division for integer operands tok := op2tok[op] - if op == syntax.Div && is_Integer(x.typ) { + if op == syntax.Div && isInteger(x.typ) { tok = token.QUO_ASSIGN } x.val = constant.BinaryOp(x.val, tok, y.val) diff --git a/src/cmd/compile/internal/types2/index.go b/src/cmd/compile/internal/types2/index.go index 1b080139f3..67110704e9 100644 --- a/src/cmd/compile/internal/types2/index.go +++ b/src/cmd/compile/internal/types2/index.go @@ -51,7 +51,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo length := int64(-1) // valid if >= 0 switch typ := under(x.typ).(type) { case *Basic: - if is_String(typ) { + if isString(typ) { valid = true if x.mode == constant_ { length = int64(len(constant.StringVal(x.val))) @@ -109,7 +109,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo var k, e Type // k is only set for maps switch t := u.(type) { case *Basic: - if is_String(t) { + if isString(t) { e = universeByte mode = value } @@ -217,7 +217,7 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) { return case *Basic: - if is_String(u) { + if isString(u) { if e.Full { check.error(x, invalidOp+"3-index slice of string") x.mode = invalid diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go index 980d254084..5a82608671 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -25,18 +25,18 @@ func isGeneric(typ Type) bool { return named != nil && named.obj != nil && named.targs == nil && named.TypeParams() != nil } -// The is_X predicates below report whether t is an X. +// The isX predicates below report whether t is an X. // If t is a type parameter the result is false; i.e., // these predicates don't look inside a type parameter. -func is_Boolean(t Type) bool { return isBasic(t, IsBoolean) } -func is_Integer(t Type) bool { return isBasic(t, IsInteger) } -func is_Unsigned(t Type) bool { return isBasic(t, IsUnsigned) } -func is_Float(t Type) bool { return isBasic(t, IsFloat) } -func is_Complex(t Type) bool { return isBasic(t, IsComplex) } -func is_Numeric(t Type) bool { return isBasic(t, IsNumeric) } -func is_String(t Type) bool { return isBasic(t, IsString) } -func is_IntegerOrFloat(t Type) bool { return isBasic(t, IsInteger|IsFloat) } +func isBoolean(t Type) bool { return isBasic(t, IsBoolean) } +func isInteger(t Type) bool { return isBasic(t, IsInteger) } +func isUnsigned(t Type) bool { return isBasic(t, IsUnsigned) } +func isFloat(t Type) bool { return isBasic(t, IsFloat) } +func isComplex(t Type) bool { return isBasic(t, IsComplex) } +func isNumeric(t Type) bool { return isBasic(t, IsNumeric) } +func isString(t Type) bool { return isBasic(t, IsString) } +func isIntegerOrFloat(t Type) bool { return isBasic(t, IsInteger|IsFloat) } // isBasic reports whether under(t) is a basic type with the specified info. // If t is a type parameter the result is false; i.e., @@ -47,10 +47,10 @@ func isBasic(t Type, info BasicInfo) bool { } // The allX predicates below report whether t is an X. -// If t is a type parameter the result is true if is_X is true +// If t is a type parameter the result is true if isX is true // for all specified types of the type parameter's type set. -// allX is an optimized version of is_X(structure(t)) (which -// is the same as underIs(t, is_X)). +// allX is an optimized version of isX(structure(t)) (which +// is the same as underIs(t, isX)). func allBoolean(t Type) bool { return allBasic(t, IsBoolean) } func allInteger(t Type) bool { return allBasic(t, IsInteger) } diff --git a/src/cmd/compile/internal/types2/sizes.go b/src/cmd/compile/internal/types2/sizes.go index 8f93ca6b87..6a3d19d8ea 100644 --- a/src/cmd/compile/internal/types2/sizes.go +++ b/src/cmd/compile/internal/types2/sizes.go @@ -82,7 +82,7 @@ func (s *StdSizes) Alignof(T Type) int64 { return 1 } // complex{64,128} are aligned like [2]float{32,64}. - if is_Complex(T) { + if isComplex(T) { a /= 2 } if a > s.MaxAlign { diff --git a/src/cmd/compile/internal/types2/stmt.go b/src/cmd/compile/internal/types2/stmt.go index b8b53a868e..eaf420aca7 100644 --- a/src/cmd/compile/internal/types2/stmt.go +++ b/src/cmd/compile/internal/types2/stmt.go @@ -942,7 +942,7 @@ func (check *Checker) rangeStmt(inner stmtContext, s *syntax.ForStmt, rclause *s func rangeKeyVal(typ Type) (key, val Type) { switch typ := arrayPtrDeref(typ).(type) { case *Basic: - if is_String(typ) { + if isString(typ) { return Typ[Int], universeRune // use 'rune' name } case *Array: diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go index 7007176980..95893fd1e1 100644 --- a/src/cmd/compile/internal/types2/typexpr.go +++ b/src/cmd/compile/internal/types2/typexpr.go @@ -513,7 +513,7 @@ func (check *Checker) arrayLength(e syntax.Expr) int64 { return -1 } - if isUntyped(x.typ) || is_Integer(x.typ) { + if isUntyped(x.typ) || isInteger(x.typ) { if val := constant.ToInt(x.val); val.Kind() == constant.Int { if representableConst(val, check, Typ[Int], nil) { if n, ok := constant.Int64Val(val); ok && n >= 0 { From 5fd0c49a4d8cd3bfff3c06e17a0fd9c41bc2f64a Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 2 Nov 2021 21:31:50 -0700 Subject: [PATCH 363/406] cmd/compile/internal/types2: minor cleanups in predicates.go - reordered some functions for better organization - renamed single arguments typ to t for consistency - updated some comments No functional changes. Change-Id: I4362ac48044595cdf5c3d9eb7b2f7b94e776d65b Reviewed-on: https://go-review.googlesource.com/c/go/+/360956 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/predicates.go | 89 +++++++++---------- 1 file changed, 42 insertions(+), 47 deletions(-) diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go index 5a82608671..7fbb91eb61 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -6,25 +6,6 @@ package types2 -// hasName reports whether typ has a name. This includes -// predeclared types, defined types, and type parameters. -// hasName may be called with types that are not fully set up. -func hasName(typ Type) bool { - switch typ.(type) { - case *Basic, *Named, *TypeParam: - return true - } - return false -} - -// isGeneric reports whether a type is a generic, uninstantiated type (generic -// signatures are not included). -func isGeneric(typ Type) bool { - // A parameterized type is only instantiated if it doesn't have an instantiation already. - named, _ := typ.(*Named) - return named != nil && named.obj != nil && named.targs == nil && named.TypeParams() != nil -} - // The isX predicates below report whether t is an X. // If t is a type parameter the result is false; i.e., // these predicates don't look inside a type parameter. @@ -37,6 +18,7 @@ func isComplex(t Type) bool { return isBasic(t, IsComplex) } func isNumeric(t Type) bool { return isBasic(t, IsNumeric) } func isString(t Type) bool { return isBasic(t, IsString) } func isIntegerOrFloat(t Type) bool { return isBasic(t, IsInteger|IsFloat) } +func isConstType(t Type) bool { return isBasic(t, IsConstType) } // isBasic reports whether under(t) is a basic type with the specified info. // If t is a type parameter the result is false; i.e., @@ -74,38 +56,52 @@ func allBasic(t Type, info BasicInfo) bool { return false } -// isTyped reports whether typ is typed; i.e., not an untyped +// hasName reports whether t has a name. This includes +// predeclared types, defined types, and type parameters. +// hasName may be called with types that are not fully set up. +func hasName(t Type) bool { + switch t.(type) { + case *Basic, *Named, *TypeParam: + return true + } + return false +} + +// isTyped reports whether t is typed; i.e., not an untyped // constant or boolean. isTyped may be called with types that // are not fully set up. -func isTyped(typ Type) bool { +func isTyped(t Type) bool { // isTyped is called with types that are not fully // set up. Must not call asBasic()! - t, _ := typ.(*Basic) - return t == nil || t.info&IsUntyped == 0 + b, _ := t.(*Basic) + return b == nil || b.info&IsUntyped == 0 } -// isUntyped(typ) is the same as !isTyped(typ). -func isUntyped(typ Type) bool { - return !isTyped(typ) +// isUntyped(t) is the same as !isTyped(t). +func isUntyped(t Type) bool { + return !isTyped(t) } -func isConstType(typ Type) bool { - // Type parameters are never const types. - t := asBasic(typ) - return t != nil && t.info&IsConstType != 0 +// IsInterface reports whether t is an interface type. +func IsInterface(t Type) bool { + return asInterface(t) != nil } -// IsInterface reports whether typ is an interface type. -func IsInterface(typ Type) bool { - return asInterface(typ) != nil -} - -// isTypeParam reports whether typ is a type parameter. -func isTypeParam(typ Type) bool { - _, ok := under(typ).(*TypeParam) +// isTypeParam reports whether t is a type parameter. +func isTypeParam(t Type) bool { + _, ok := under(t).(*TypeParam) return ok } +// isGeneric reports whether a type is a generic, uninstantiated type +// (generic signatures are not included). +// TODO(gri) should we include signatures or assert that they are not present? +func isGeneric(t Type) bool { + // A parameterized type is only generic if it doesn't have an instantiation already. + named, _ := t.(*Named) + return named != nil && named.obj != nil && named.targs == nil && named.TypeParams() != nil +} + // Comparable reports whether values of type T are comparable. func Comparable(T Type) bool { return comparable(T, nil) @@ -142,15 +138,15 @@ func comparable(T Type, seen map[Type]bool) bool { return false } -// hasNil reports whether a type includes the nil value. -func hasNil(typ Type) bool { - switch t := under(typ).(type) { +// hasNil reports whether type t includes the nil value. +func hasNil(t Type) bool { + switch u := under(t).(type) { case *Basic: - return t.kind == UnsafePointer + return u.kind == UnsafePointer case *Slice, *Pointer, *Signature, *Interface, *Map, *Chan: return true case *TypeParam: - return t.underIs(hasNil) + return u.underIs(hasNil) } return false } @@ -392,9 +388,8 @@ func identicalTParams(x, y []*TypeParam, cmpTags bool, p *ifacePair) bool { // Default returns the default "typed" type for an "untyped" type; // it returns the incoming type for all other types. The default type // for untyped nil is untyped nil. -// -func Default(typ Type) Type { - if t, ok := typ.(*Basic); ok { +func Default(t Type) Type { + if t, ok := t.(*Basic); ok { switch t.kind { case UntypedBool: return Typ[Bool] @@ -410,5 +405,5 @@ func Default(typ Type) Type { return Typ[String] } } - return typ + return t } From 2cf85b1fb8b3b6629b834016735ddeaaf7b96fda Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 3 Nov 2021 12:39:43 -0700 Subject: [PATCH 364/406] cmd/compile/internal/types2: implement compiler helper functions without using under These functions are exported for the compiler and are used after type checking is finished. There is no need to call under() in their implementations; they can rely entirely on the public API. This opens the door to moving them into the compiler eventually. They may also be slightly more efficient. Change-Id: Ib4f83d2dcf82e3c319c3147e01ecaea684553ea5 Reviewed-on: https://go-review.googlesource.com/c/go/+/361214 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/type.go | 34 ++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/cmd/compile/internal/types2/type.go b/src/cmd/compile/internal/types2/type.go index 33d3d3642c..300c81f5fa 100644 --- a/src/cmd/compile/internal/types2/type.go +++ b/src/cmd/compile/internal/types2/type.go @@ -81,10 +81,32 @@ func asTypeParam(t Type) *TypeParam { return u } -// Exported for the compiler. +// Helper functions exported for the compiler. +// These functions assume type checking has completed +// and Type.Underlying() is returning the fully set up +// underlying type. Do not use internally. -func AsPointer(t Type) *Pointer { return asPointer(t) } -func AsNamed(t Type) *Named { return asNamed(t) } -func AsSignature(t Type) *Signature { return asSignature(t) } -func AsInterface(t Type) *Interface { return asInterface(t) } -func AsTypeParam(t Type) *TypeParam { return asTypeParam(t) } +func AsPointer(t Type) *Pointer { + u, _ := t.Underlying().(*Pointer) + return u +} + +func AsNamed(t Type) *Named { + u, _ := t.(*Named) + return u +} + +func AsSignature(t Type) *Signature { + u, _ := t.Underlying().(*Signature) + return u +} + +func AsInterface(t Type) *Interface { + u, _ := t.Underlying().(*Interface) + return u +} + +func AsTypeParam(t Type) *TypeParam { + u, _ := t.Underlying().(*TypeParam) + return u +} From 2622235a99800d1d7add47c5c138f5efbe51361c Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Sun, 31 Oct 2021 17:58:34 +1100 Subject: [PATCH 365/406] runtime: do not generate crash dump on Windows 7 It appears Windows 7 ignores WER_FAULT_REPORTING_NO_UI WerSetFlags API flag. And now after CL 307372, runtime will display WER GUI dialogue. We don't want to introduce random GUI dialogues during Go program execution. So disable dump crash creation on Windows 7 altogether. Updates #20498 Change-Id: Ie268a7d4609f8a0eba4fe9ecf250856b0a61b331 Reviewed-on: https://go-review.googlesource.com/c/go/+/360617 Trust: Alex Brainman Run-TryBot: Alex Brainman TryBot-Result: Go Bot Reviewed-by: Patrik Nyblom --- src/runtime/signal_windows.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/runtime/signal_windows.go b/src/runtime/signal_windows.go index ca4a9ea451..b036f3c965 100644 --- a/src/runtime/signal_windows.go +++ b/src/runtime/signal_windows.go @@ -22,8 +22,16 @@ func disableWER() { stdcall1(_SetErrorMode, uintptr(errormode)|SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX) } +// isWin7 returns true on Windows 7. Otherwise it returns false. +// +//go:nosplit +func isWin7() bool { + var maj, min, build uint32 + stdcall3(_RtlGetNtVersionNumbers, uintptr(unsafe.Pointer(&maj)), uintptr(unsafe.Pointer(&min)), uintptr(unsafe.Pointer(&build))) + return maj < 6 || (maj == 6 && min <= 1) +} + // enableWERNoUI re-enables Windows error reporting without fault reporting UI. -// It returns false on older Windows versions (XP and earlier) where WerSetFlags() is not supported. // // This is marked nosplit since it is used during crash. // @@ -224,9 +232,14 @@ func lastcontinuehandler(info *exceptionrecord, r *context, gp *g) int32 { _, _, docrash := gotraceback() if docrash { - // trigger crash dump creation - if enableWERNoUI() { - return _EXCEPTION_CONTINUE_SEARCH + // Windows 7 apears to ignore WER_FAULT_REPORTING_NO_UI + // WerSetFlags API flag. So do not call enableWERNoUI + // on Windows 7. + if !isWin7() { + // trigger crash dump creation + if enableWERNoUI() { + return _EXCEPTION_CONTINUE_SEARCH + } } } exit(2) From a3f7be9b8cee00aa281a0bedeae22b4cd4bc64dd Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 3 Nov 2021 22:15:17 -0400 Subject: [PATCH 366/406] net/http: reduce TestClientTimeout_h{1,2} latency The test had been setting an arbitrary 200ms timeout to allow the server's handler to set up before timing out. That is not only potentially flaky on slow machines, but also typically much longer than necessary. Replace the hard-coded timeout with a much shorter initial timeout, and use exponential backoff to lengthen it if needed. This allows the test to be run about 20x faster in the typical case, which may make it easier to reproduce rare failure modes by running with a higher -count flag. For #43120 Change-Id: I1e0d0ec99d5a107fff56e3bcc7174d686ec582d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/361275 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Damien Neil --- src/net/http/client_test.go | 98 +++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 41 deletions(-) diff --git a/src/net/http/client_test.go b/src/net/http/client_test.go index e741c3746f..fb6fbe7197 100644 --- a/src/net/http/client_test.go +++ b/src/net/http/client_test.go @@ -1205,64 +1205,80 @@ func TestClientTimeout_h2(t *testing.T) { testClientTimeout(t, h2Mode) } func testClientTimeout(t *testing.T, h2 bool) { setParallel(t) defer afterTest(t) - testDone := make(chan struct{}) // closed in defer below - sawRoot := make(chan bool, 1) - sawSlow := make(chan bool, 1) + var ( + mu sync.Mutex + nonce string // a unique per-request string + sawSlowNonce bool // true if the handler saw /slow?nonce= + ) cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) { + _ = r.ParseForm() if r.URL.Path == "/" { - sawRoot <- true - Redirect(w, r, "/slow", StatusFound) + Redirect(w, r, "/slow?nonce="+r.Form.Get("nonce"), StatusFound) return } if r.URL.Path == "/slow" { - sawSlow <- true + mu.Lock() + if r.Form.Get("nonce") == nonce { + sawSlowNonce = true + } else { + t.Logf("mismatched nonce: received %s, want %s", r.Form.Get("nonce"), nonce) + } + mu.Unlock() + w.Write([]byte("Hello")) w.(Flusher).Flush() - <-testDone + <-r.Context().Done() return } })) defer cst.close() - defer close(testDone) // before cst.close, to unblock /slow handler - // 200ms should be long enough to get a normal request (the / - // handler), but not so long that it makes the test slow. - const timeout = 200 * time.Millisecond - cst.c.Timeout = timeout - - res, err := cst.c.Get(cst.ts.URL) - if err != nil { - if strings.Contains(err.Error(), "Client.Timeout") { - t.Skipf("host too slow to get fast resource in %v", timeout) + // Try to trigger a timeout after reading part of the response body. + // The initial timeout is emprically usually long enough on a decently fast + // machine, but if we undershoot we'll retry with exponentially longer + // timeouts until the test either passes or times out completely. + // This keeps the test reasonably fast in the typical case but allows it to + // also eventually succeed on arbitrarily slow machines. + timeout := 10 * time.Millisecond + nextNonce := 0 + for ; ; timeout *= 2 { + if timeout <= 0 { + // The only way we can feasibly hit this while the test is running is if + // the request fails without actually waiting for the timeout to occur. + t.Fatalf("timeout overflow") } - t.Fatal(err) - } + if deadline, ok := t.Deadline(); ok && !time.Now().Add(timeout).Before(deadline) { + t.Fatalf("failed to produce expected timeout before test deadline") + } + t.Logf("attempting test with timeout %v", timeout) + cst.c.Timeout = timeout - select { - case <-sawRoot: - // good. - default: - t.Fatal("handler never got / request") - } + mu.Lock() + nonce = fmt.Sprint(nextNonce) + nextNonce++ + sawSlowNonce = false + mu.Unlock() + res, err := cst.c.Get(cst.ts.URL + "/?nonce=" + nonce) + if err != nil { + if strings.Contains(err.Error(), "Client.Timeout") { + // Timed out before handler could respond. + t.Logf("timeout before response received") + continue + } + t.Fatal(err) + } - select { - case <-sawSlow: - // good. - default: - t.Fatal("handler never got /slow request") - } + mu.Lock() + ok := sawSlowNonce + mu.Unlock() + if !ok { + t.Fatal("handler never got /slow request, but client returned response") + } - errc := make(chan error, 1) - go func() { - _, err := io.ReadAll(res.Body) - errc <- err + _, err = io.ReadAll(res.Body) res.Body.Close() - }() - const failTime = 5 * time.Second - select { - case err := <-errc: if err == nil { t.Fatal("expected error from ReadAll") } @@ -1275,8 +1291,8 @@ func testClientTimeout(t *testing.T, h2 bool) { if got := ne.Error(); !strings.Contains(got, "(Client.Timeout") { t.Errorf("error string = %q; missing timeout substring", got) } - case <-time.After(failTime): - t.Errorf("timeout after %v waiting for timeout of %v", failTime, timeout) + + break } } From 901bf291bc90819cb6dad76064475cf9ecbc9651 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 3 Dec 2020 13:29:58 +0100 Subject: [PATCH 367/406] runtime: allow builtin write function to be redirected with function pointer The x/sys/windows package currently uses go:linkname for other facilities inside of runtime that are not suitable to be exposed as a public API due to their dangers but are still necessary for manipulating any low-level plumbing that the runtime controls. Logging, via the built-in println and panic handler, is one such low-level plumbing feature. In this case, x/sys/windows/svc needs to be able to redirect panics to the Windows event log. Because the event log is a complicated interface, this requires a bit more fiddling than the simple solution used on Android (baking it into runtime itself), and because Windows services are very diverse, the event log might not even always be a desirable destination. This commit accomplishes this by exposing a function pointer called "overrideWrite" that low-level runtime packages like x/sys/windows/svc can use to redirect output logs toward the event log or otherwise. It is not safe or acceptable to use as a generic mechanism, and for that reason, we wouldn't want to expose this as a real stable API, similar to the other instances of go:linkname in x/sys/windows. But for packages that must interoperate with low-level Go runtime fundamentals, this is a safety hatch for packages that are developed in tandem with the runtime. x/sys/windows is one such package. Updates #42888. Change-Id: I77a32ff7e1494324e8cc38e792e007f86d32672d Reviewed-on: https://go-review.googlesource.com/c/go/+/278792 Trust: Jason A. Donenfeld Run-TryBot: Jason A. Donenfeld TryBot-Result: Go Bot Reviewed-by: Russ Cox --- src/runtime/time_nofake.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/runtime/time_nofake.go b/src/runtime/time_nofake.go index 2b85c5aa01..70a2102b22 100644 --- a/src/runtime/time_nofake.go +++ b/src/runtime/time_nofake.go @@ -19,9 +19,14 @@ func nanotime() int64 { return nanotime1() } +var overrideWrite func(fd uintptr, p unsafe.Pointer, n int32) int32 + // write must be nosplit on Windows (see write1) // //go:nosplit func write(fd uintptr, p unsafe.Pointer, n int32) int32 { + if overrideWrite != nil { + return overrideWrite(fd, noescape(p), n) + } return write1(fd, p, n) } From 00d6d2037ee1bf4b6959219120b79b7c01244b02 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Fri, 29 Oct 2021 17:41:41 -0400 Subject: [PATCH 368/406] cmd/doc, go/doc: add basic support for generic code Update cmd/doc and go/doc for the generics, by adding handling for type parameters and the new embedded interface elements. Specifically: - Format type parameters when summarizing type and function nodes. - Find the origin type name for instantiation expressions, so that methods are associated with generic type declarations. - Generalize the handling of embedding 'error' in interfaces to arbitrary predeclared types. - Keep embedded type literals. - Update filtering to descend into embedded type literals. Also add "any" to the list of predeclared types. Updates #49210 Change-Id: I6ea82869f19c3cdbc3c842f01581c8fc7e1c2ee7 Reviewed-on: https://go-review.googlesource.com/c/go/+/359778 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/cmd/doc/pkg.go | 21 ++++++-- src/go/doc/exports.go | 58 +++++++++++++++------- src/go/doc/filter.go | 2 + src/go/doc/reader.go | 29 +++++++---- src/go/doc/testdata/generics.0.golden | 70 +++++++++++++++++++++++++++ src/go/doc/testdata/generics.1.golden | 60 +++++++++++++++++++++++ src/go/doc/testdata/generics.2.golden | 70 +++++++++++++++++++++++++++ src/go/doc/testdata/generics.go | 61 +++++++++++++++++++++++ 8 files changed, 339 insertions(+), 32 deletions(-) create mode 100644 src/go/doc/testdata/generics.0.golden create mode 100644 src/go/doc/testdata/generics.1.golden create mode 100644 src/go/doc/testdata/generics.2.golden create mode 100644 src/go/doc/testdata/generics.go diff --git a/src/cmd/doc/pkg.go b/src/cmd/doc/pkg.go index 822c9e16f8..2257c5c0eb 100644 --- a/src/cmd/doc/pkg.go +++ b/src/cmd/doc/pkg.go @@ -323,7 +323,8 @@ func (pkg *Package) oneLineNodeDepth(node ast.Node, depth int) string { if n.Assign.IsValid() { sep = " = " } - return fmt.Sprintf("type %s%s%s", n.Name.Name, sep, pkg.oneLineNodeDepth(n.Type, depth)) + tparams := pkg.formatTypeParams(n.TypeParams, depth) + return fmt.Sprintf("type %s%s%s%s", n.Name.Name, tparams, sep, pkg.oneLineNodeDepth(n.Type, depth)) case *ast.FuncType: var params []string @@ -342,15 +343,16 @@ func (pkg *Package) oneLineNodeDepth(node ast.Node, depth int) string { } } + tparam := pkg.formatTypeParams(n.TypeParams, depth) param := joinStrings(params) if len(results) == 0 { - return fmt.Sprintf("func(%s)", param) + return fmt.Sprintf("func%s(%s)", tparam, param) } result := joinStrings(results) if !needParens { - return fmt.Sprintf("func(%s) %s", param, result) + return fmt.Sprintf("func%s(%s) %s", tparam, param, result) } - return fmt.Sprintf("func(%s) (%s)", param, result) + return fmt.Sprintf("func%s(%s) (%s)", tparam, param, result) case *ast.StructType: if n.Fields == nil || len(n.Fields.List) == 0 { @@ -419,6 +421,17 @@ func (pkg *Package) oneLineNodeDepth(node ast.Node, depth int) string { } } +func (pkg *Package) formatTypeParams(list *ast.FieldList, depth int) string { + if list.NumFields() == 0 { + return "" + } + var tparams []string + for _, field := range list.List { + tparams = append(tparams, pkg.oneLineField(field, depth)) + } + return "[" + joinStrings(tparams) + "]" +} + // oneLineField returns a one-line summary of the field. func (pkg *Package) oneLineField(field *ast.Field, depth int) string { var names []string diff --git a/src/go/doc/exports.go b/src/go/doc/exports.go index 819c030c9b..671c622205 100644 --- a/src/go/doc/exports.go +++ b/src/go/doc/exports.go @@ -79,18 +79,15 @@ func hasExportedName(list []*ast.Ident) bool { return false } -// removeErrorField removes anonymous fields named "error" from an interface. -// This is called when "error" has been determined to be a local name, -// not the predeclared type. -// -func removeErrorField(ityp *ast.InterfaceType) { +// removeAnonymousField removes anonymous fields named name from an interface. +func removeAnonymousField(name string, ityp *ast.InterfaceType) { list := ityp.Methods.List // we know that ityp.Methods != nil j := 0 for _, field := range list { keepField := true if n := len(field.Names); n == 0 { // anonymous field - if fname, _ := baseTypeName(field.Type); fname == "error" { + if fname, _ := baseTypeName(field.Type); fname == name { keepField = false } } @@ -119,16 +116,25 @@ func (r *reader) filterFieldList(parent *namedType, fields *ast.FieldList, ityp for _, field := range list { keepField := false if n := len(field.Names); n == 0 { - // anonymous field + // anonymous field or embedded type or union element fname := r.recordAnonymousField(parent, field.Type) - if token.IsExported(fname) { - keepField = true - } else if ityp != nil && fname == "error" { - // possibly the predeclared error interface; keep - // it for now but remember this interface so that - // it can be fixed if error is also defined locally - keepField = true - r.remember(ityp) + if fname != "" { + if token.IsExported(fname) { + keepField = true + } else if ityp != nil && predeclaredTypes[fname] { + // possibly an embedded predeclared type; keep it for now but + // remember this interface so that it can be fixed if name is also + // defined locally + keepField = true + r.remember(fname, ityp) + } + } else { + // If we're operating on an interface, assume that this is an embedded + // type or union element. + // + // TODO(rfindley): consider traversing into approximation/unions + // elements to see if they are entirely unexported. + keepField = ityp != nil } } else { field.Names = filterIdentList(field.Names) @@ -172,6 +178,17 @@ func (r *reader) filterType(parent *namedType, typ ast.Expr) { // nothing to do case *ast.ParenExpr: r.filterType(nil, t.X) + case *ast.StarExpr: // possibly an embedded type literal + r.filterType(nil, t.X) + case *ast.UnaryExpr: + if t.Op == token.TILDE { // approximation element + r.filterType(nil, t.X) + } + case *ast.BinaryExpr: + if t.Op == token.OR { // union + r.filterType(nil, t.X) + r.filterType(nil, t.Y) + } case *ast.ArrayType: r.filterType(nil, t.Elt) case *ast.StructType: @@ -179,6 +196,7 @@ func (r *reader) filterType(parent *namedType, typ ast.Expr) { t.Incomplete = true } case *ast.FuncType: + r.filterParamList(t.TypeParams) r.filterParamList(t.Params) r.filterParamList(t.Results) case *ast.InterfaceType: @@ -219,12 +237,16 @@ func (r *reader) filterSpec(spec ast.Spec) bool { } } case *ast.TypeSpec: + // Don't filter type parameters here, by analogy with function parameters + // which are not filtered for top-level function declarations. if name := s.Name.Name; token.IsExported(name) { r.filterType(r.lookupType(s.Name.Name), s.Type) return true - } else if name == "error" { - // special case: remember that error is declared locally - r.errorDecl = true + } else if IsPredeclared(name) { + if r.shadowedPredecl == nil { + r.shadowedPredecl = make(map[string]bool) + } + r.shadowedPredecl[name] = true } } return false diff --git a/src/go/doc/filter.go b/src/go/doc/filter.go index a6f243f33e..9904da150e 100644 --- a/src/go/doc/filter.go +++ b/src/go/doc/filter.go @@ -34,6 +34,8 @@ func matchDecl(d *ast.GenDecl, f Filter) bool { if f(v.Name.Name) { return true } + // We don't match ordinary parameters in filterFuncs, so by analogy don't + // match type parameters here. switch t := v.Type.(type) { case *ast.StructType: if matchFields(t.Fields, f) { diff --git a/src/go/doc/reader.go b/src/go/doc/reader.go index c277b35e89..348b9b59a0 100644 --- a/src/go/doc/reader.go +++ b/src/go/doc/reader.go @@ -101,6 +101,10 @@ func baseTypeName(x ast.Expr) (name string, imported bool) { switch t := x.(type) { case *ast.Ident: return t.Name, false + case *ast.IndexExpr: + return baseTypeName(t.X) + case *ast.IndexListExpr: + return baseTypeName(t.X) case *ast.SelectorExpr: if _, ok := t.X.(*ast.Ident); ok { // only possible for qualified type names; @@ -112,7 +116,7 @@ func baseTypeName(x ast.Expr) (name string, imported bool) { case *ast.StarExpr: return baseTypeName(t.X) } - return + return "", false } // An embeddedSet describes a set of embedded types. @@ -163,9 +167,9 @@ type reader struct { types map[string]*namedType funcs methodSet - // support for package-local error type declarations - errorDecl bool // if set, type "error" was declared locally - fixlist []*ast.InterfaceType // list of interfaces containing anonymous field "error" + // support for package-local shadowing of predeclared types + shadowedPredecl map[string]bool + fixmap map[string][]*ast.InterfaceType } func (r *reader) isVisible(name string) bool { @@ -224,8 +228,11 @@ func (r *reader) readDoc(comment *ast.CommentGroup) { r.doc += "\n" + text } -func (r *reader) remember(typ *ast.InterfaceType) { - r.fixlist = append(r.fixlist, typ) +func (r *reader) remember(predecl string, typ *ast.InterfaceType) { + if r.fixmap == nil { + r.fixmap = make(map[string][]*ast.InterfaceType) + } + r.fixmap[predecl] = append(r.fixmap[predecl], typ) } func specNames(specs []ast.Spec) []string { @@ -679,10 +686,11 @@ func (r *reader) computeMethodSets() { } } - // if error was declared locally, don't treat it as exported field anymore - if r.errorDecl { - for _, ityp := range r.fixlist { - removeErrorField(ityp) + // For any predeclared names that are declared locally, don't treat them as + // exported fields anymore. + for predecl := range r.shadowedPredecl { + for _, ityp := range r.fixmap[predecl] { + removeAnonymousField(predecl, ityp) } } } @@ -869,6 +877,7 @@ func IsPredeclared(s string) bool { } var predeclaredTypes = map[string]bool{ + "any": true, "bool": true, "byte": true, "complex64": true, diff --git a/src/go/doc/testdata/generics.0.golden b/src/go/doc/testdata/generics.0.golden new file mode 100644 index 0000000000..a6dbcf673c --- /dev/null +++ b/src/go/doc/testdata/generics.0.golden @@ -0,0 +1,70 @@ +// Package generics contains the new syntax supporting generic ... +PACKAGE generics + +IMPORTPATH + testdata/generics + +FILENAMES + testdata/generics.go + +FUNCTIONS + // AnotherFunc has an implicit constraint interface. Neither type ... + func AnotherFunc[T ~struct{ f int }](_ struct{ f int }) + + // Func has an instantiated constraint. + func Func[T Constraint[string, Type[int]]]() + + +TYPES + // AFuncType demonstrates filtering of parameters and type ... + type AFuncType[T ~struct{ f int }] func(_ struct { + // contains filtered or unexported fields + }) + + // Constraint is a constraint interface with two type parameters. + type Constraint[P, Q interface{ string | ~int | Type[int] }] interface { + ~int | ~byte | Type[string] + M() P + } + + // NewEmbeddings demonstrates how we filter the new embedded ... + type NewEmbeddings interface { + string // should not be filtered + + struct { + // contains filtered or unexported fields + } + ~struct { + // contains filtered or unexported fields + } + *struct { + // contains filtered or unexported fields + } + struct { + // contains filtered or unexported fields + } | ~struct { + // contains filtered or unexported fields + } + // contains filtered or unexported methods + } + + // Parameterized types should be shown. + type Type[P any] struct { + Field P + } + + // Variables with an instantiated type should be shown. + var X Type[int] + + // Constructors for parameterized types should be shown. + func Constructor[lowerCase any]() Type[lowerCase] + + // MethodA uses a different name for its receiver type parameter. + func (t Type[A]) MethodA(p A) + + // MethodB has a blank receiver type parameter. + func (t Type[_]) MethodB() + + // MethodC has a lower-case receiver type parameter. + func (t Type[c]) MethodC() + diff --git a/src/go/doc/testdata/generics.1.golden b/src/go/doc/testdata/generics.1.golden new file mode 100644 index 0000000000..c0548b5e96 --- /dev/null +++ b/src/go/doc/testdata/generics.1.golden @@ -0,0 +1,60 @@ +// Package generics contains the new syntax supporting generic ... +PACKAGE generics + +IMPORTPATH + testdata/generics + +FILENAMES + testdata/generics.go + +FUNCTIONS + // AnotherFunc has an implicit constraint interface. Neither type ... + func AnotherFunc[T ~struct{ f int }](_ struct{ f int }) + + // Func has an instantiated constraint. + func Func[T Constraint[string, Type[int]]]() + + +TYPES + // AFuncType demonstrates filtering of parameters and type ... + type AFuncType[T ~struct{ f int }] func(_ struct{ f int }) + + // Constraint is a constraint interface with two type parameters. + type Constraint[P, Q interface{ string | ~int | Type[int] }] interface { + ~int | ~byte | Type[string] + M() P + } + + // NewEmbeddings demonstrates how we filter the new embedded ... + type NewEmbeddings interface { + string // should not be filtered + int16 + struct{ f int } + ~struct{ f int } + *struct{ f int } + struct{ f int } | ~struct{ f int } + } + + // Parameterized types should be shown. + type Type[P any] struct { + Field P + } + + // Variables with an instantiated type should be shown. + var X Type[int] + + // Constructors for parameterized types should be shown. + func Constructor[lowerCase any]() Type[lowerCase] + + // MethodA uses a different name for its receiver type parameter. + func (t Type[A]) MethodA(p A) + + // MethodB has a blank receiver type parameter. + func (t Type[_]) MethodB() + + // MethodC has a lower-case receiver type parameter. + func (t Type[c]) MethodC() + + // int16 shadows the predeclared type int16. + type int16 int + diff --git a/src/go/doc/testdata/generics.2.golden b/src/go/doc/testdata/generics.2.golden new file mode 100644 index 0000000000..a6dbcf673c --- /dev/null +++ b/src/go/doc/testdata/generics.2.golden @@ -0,0 +1,70 @@ +// Package generics contains the new syntax supporting generic ... +PACKAGE generics + +IMPORTPATH + testdata/generics + +FILENAMES + testdata/generics.go + +FUNCTIONS + // AnotherFunc has an implicit constraint interface. Neither type ... + func AnotherFunc[T ~struct{ f int }](_ struct{ f int }) + + // Func has an instantiated constraint. + func Func[T Constraint[string, Type[int]]]() + + +TYPES + // AFuncType demonstrates filtering of parameters and type ... + type AFuncType[T ~struct{ f int }] func(_ struct { + // contains filtered or unexported fields + }) + + // Constraint is a constraint interface with two type parameters. + type Constraint[P, Q interface{ string | ~int | Type[int] }] interface { + ~int | ~byte | Type[string] + M() P + } + + // NewEmbeddings demonstrates how we filter the new embedded ... + type NewEmbeddings interface { + string // should not be filtered + + struct { + // contains filtered or unexported fields + } + ~struct { + // contains filtered or unexported fields + } + *struct { + // contains filtered or unexported fields + } + struct { + // contains filtered or unexported fields + } | ~struct { + // contains filtered or unexported fields + } + // contains filtered or unexported methods + } + + // Parameterized types should be shown. + type Type[P any] struct { + Field P + } + + // Variables with an instantiated type should be shown. + var X Type[int] + + // Constructors for parameterized types should be shown. + func Constructor[lowerCase any]() Type[lowerCase] + + // MethodA uses a different name for its receiver type parameter. + func (t Type[A]) MethodA(p A) + + // MethodB has a blank receiver type parameter. + func (t Type[_]) MethodB() + + // MethodC has a lower-case receiver type parameter. + func (t Type[c]) MethodC() + diff --git a/src/go/doc/testdata/generics.go b/src/go/doc/testdata/generics.go new file mode 100644 index 0000000000..b5debba437 --- /dev/null +++ b/src/go/doc/testdata/generics.go @@ -0,0 +1,61 @@ +// Copyright 2021 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 generics contains the new syntax supporting generic programming in +// Go. +package generics + +// Variables with an instantiated type should be shown. +var X Type[int] + +// Parameterized types should be shown. +type Type[P any] struct { + Field P +} + +// Constructors for parameterized types should be shown. +func Constructor[lowerCase any]() Type[lowerCase] { + return Type[lowerCase]{} +} + +// MethodA uses a different name for its receiver type parameter. +func (t Type[A]) MethodA(p A) {} + +// MethodB has a blank receiver type parameter. +func (t Type[_]) MethodB() {} + +// MethodC has a lower-case receiver type parameter. +func (t Type[c]) MethodC() {} + +// Constraint is a constraint interface with two type parameters. +type Constraint[P, Q interface{ string | ~int | Type[int] }] interface { + ~int | ~byte | Type[string] + M() P +} + +// int16 shadows the predeclared type int16. +type int16 int + +// NewEmbeddings demonstrates how we filter the new embedded elements. +type NewEmbeddings interface { + string // should not be filtered + int16 + struct{ f int } + ~struct{ f int } + *struct{ f int } + struct{ f int } | ~struct{ f int } +} + +// Func has an instantiated constraint. +func Func[T Constraint[string, Type[int]]]() {} + +// AnotherFunc has an implicit constraint interface. +// +// Neither type parameters nor regular parameters should be filtered. +func AnotherFunc[T ~struct{ f int }](_ struct{ f int }) {} + +// AFuncType demonstrates filtering of parameters and type parameters. Here we +// don't filter type parameters (to be consistent with function declarations), +// but DO filter the RHS. +type AFuncType[T ~struct{ f int }] func(_ struct{ f int }) From 6ba68a0581d537edfd6eb2e5675c408f18eb4eed Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Wed, 3 Nov 2021 14:47:04 -0700 Subject: [PATCH 369/406] cmd/compile: don't inline fn with no shape params, but passed a shape arg Don't inline a function fn that has no shape parameters, but is passed at least one shape arg. This means we must be inlining a non-generic function fn that was passed into a generic function, and can be called with a shape arg because it matches an appropriate type parameter. But fn may include an interface conversion (that may be applied to a shape arg) that was not apparent when we first created the instantiation of the generic function. We can't handle this if we actually do the inlining, since we want to know all interface conversions immediately after stenciling. So, we avoid inlining in this case. Fixes #49309. Change-Id: I7b8ab7b13e58fdb0111db91bc92a91d313f7c2c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/361260 Trust: Dan Scales Run-TryBot: Dan Scales TryBot-Result: Go Bot Reviewed-by: Keith Randall Reviewed-by: Cuong Manh Le --- src/cmd/compile/internal/inline/inl.go | 21 +++++++++++++++++++++ test/typeparam/issue49309.go | 25 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 test/typeparam/issue49309.go diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index da905bd627..b764aed534 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -685,6 +685,27 @@ func mkinlcall(n *ir.CallExpr, fn *ir.Func, maxCost int32, inlMap map[*ir.Func]b return n } + // Don't inline a function fn that has no shape parameters, but is passed at + // least one shape arg. This means we must be inlining a non-generic function + // fn that was passed into a generic function, and can be called with a shape + // arg because it matches an appropriate type parameters. But fn may include + // an interface conversion (that may be applied to a shape arg) that was not + // apparent when we first created the instantiation of the generic function. + // We can't handle this if we actually do the inlining, since we want to know + // all interface conversions immediately after stenciling. So, we avoid + // inlining in this case. See #49309. + if !fn.Type().HasShape() { + for _, arg := range n.Args { + if arg.Type().HasShape() { + if logopt.Enabled() { + logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", ir.FuncName(ir.CurFunc), + fmt.Sprintf("inlining non-shape function %v with shape args", ir.FuncName(fn))) + } + return n + } + } + } + if base.Flag.Cfg.Instrumenting && types.IsRuntimePkg(fn.Sym().Pkg) { // Runtime package must not be instrumented. // Instrument skips runtime package. However, some runtime code can be diff --git a/test/typeparam/issue49309.go b/test/typeparam/issue49309.go new file mode 100644 index 0000000000..36da86a9c3 --- /dev/null +++ b/test/typeparam/issue49309.go @@ -0,0 +1,25 @@ +// run -gcflags=-G=3 + +// Copyright 2021 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 main + +func genfunc[T any](f func(c T)) { + var r T + + f(r) +} + +func myfunc(c string) { + test2(c) +} + +//go:noinline +func test2(a interface{}) { +} + +func main() { + genfunc(myfunc) +} From f934b8326f18c4be2cb26ed1e87621d926ba209b Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 3 Nov 2021 20:42:44 -0700 Subject: [PATCH 370/406] cmd/compile/internal/types2: check non-generic conversions first This enables the elimination of convertibleToImpl again, with the code structure close to the original non-generic version, and closely matching the structure of assignableTo. We also don't need the hasTerm tests; instead we can rely directly on the mechanism of TypeParam.is which is feeding a nil term if there are no specific types. Change-Id: I0385acca779d75c3c961d06afb464714fe51705d Reviewed-on: https://go-review.googlesource.com/c/go/+/361269 Trust: Robert Griesemer Reviewed-by: Robert Findley --- .../compile/internal/types2/conversions.go | 119 +++++++++--------- 1 file changed, 62 insertions(+), 57 deletions(-) diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index bd7b82fabf..44e8aad84f 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -122,64 +122,8 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { return true } - // determine type parameter operands with specific type terms - Vp, _ := under(x.typ).(*TypeParam) - Tp, _ := under(T).(*TypeParam) - if Vp != nil && !Vp.hasTerms() { - Vp = nil - } - if Tp != nil && !Tp.hasTerms() { - Tp = nil - } - - errorf := func(format string, args ...interface{}) { - if check != nil && cause != nil { - msg := check.sprintf(format, args...) - if *cause != "" { - msg += "\n\t" + *cause - } - *cause = msg - } - } - - // generic cases with specific type terms - // (generic operands cannot be constants, so we can ignore x.val) - switch { - case Vp != nil && Tp != nil: - return Vp.is(func(V *term) bool { - return Tp.is(func(T *term) bool { - if !convertibleToImpl(check, V.typ, T.typ, cause) { - errorf("cannot convert %s (in %s) to %s (in %s)", V.typ, Vp, T.typ, Tp) - return false - } - return true - }) - }) - case Vp != nil: - return Vp.is(func(V *term) bool { - if !convertibleToImpl(check, V.typ, T, cause) { - errorf("cannot convert %s (in %s) to %s", V.typ, Vp, T) - return false - } - return true - }) - case Tp != nil: - return Tp.is(func(T *term) bool { - if !convertibleToImpl(check, x.typ, T.typ, cause) { - errorf("cannot convert %s to %s (in %s)", x.typ, T.typ, Tp) - return false - } - return true - }) - } - - // non-generic case - return convertibleToImpl(check, x.typ, T, cause) -} - -// convertibleToImpl should only be called by convertibleTo -func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { // "V and T have identical underlying types if tags are ignored" + V := x.typ Vu := under(V) Tu := under(T) if IdenticalIgnoreTags(Vu, Tu) { @@ -250,6 +194,67 @@ func convertibleToImpl(check *Checker, V, T Type, cause *string) bool { } } + // optimization: if we don't have type parameters, we're done + Vp, _ := Vu.(*TypeParam) + Tp, _ := Tu.(*TypeParam) + if Vp == nil && Tp == nil { + return false + } + + errorf := func(format string, args ...interface{}) { + if check != nil && cause != nil { + msg := check.sprintf(format, args...) + if *cause != "" { + msg += "\n\t" + *cause + } + *cause = msg + } + } + + // generic cases with specific type terms + // (generic operands cannot be constants, so we can ignore x.val) + switch { + case Vp != nil && Tp != nil: + x := *x // don't clobber outer x + return Vp.is(func(V *term) bool { + if V == nil { + return false // no specific types + } + x.typ = V.typ + return Tp.is(func(T *term) bool { + if !x.convertibleTo(check, T.typ, cause) { + errorf("cannot convert %s (in %s) to %s (in %s)", V.typ, Vp, T.typ, Tp) + return false + } + return true + }) + }) + case Vp != nil: + x := *x // don't clobber outer x + return Vp.is(func(V *term) bool { + if V == nil { + return false // no specific types + } + x.typ = V.typ + if !x.convertibleTo(check, T, cause) { + errorf("cannot convert %s (in %s) to %s", V.typ, Vp, T) + return false + } + return true + }) + case Tp != nil: + return Tp.is(func(T *term) bool { + if T == nil { + return false // no specific types + } + if !x.convertibleTo(check, T.typ, cause) { + errorf("cannot convert %s to %s (in %s)", x.typ, T.typ, Tp) + return false + } + return true + }) + } + return false } From 6e7b82a4bbd08e5724a29e204faf97342a0b6a15 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Thu, 4 Nov 2021 08:46:07 -0400 Subject: [PATCH 371/406] cmd/pprof: update vendored github.com/google/pprof Pull in the latest published version of github.com/google/pprof as part of #36905. This adds the fmt.Println redundant newline fix from google/pprof@f987b9c94b318d4bd026dcc7892f7f1fab6eadab. Done with: go get -d github.com/google/pprof@latest go mod tidy go mod vendor For #36905. Fixes #49322. Change-Id: Ia832766bba65a30c68407b73b33fefbe81438e65 Reviewed-on: https://go-review.googlesource.com/c/go/+/361294 Trust: Dmitri Shuralyov Trust: Zvonimir Pavlinovic Run-TryBot: Dmitri Shuralyov Run-TryBot: Zvonimir Pavlinovic TryBot-Result: Go Bot Reviewed-by: Zvonimir Pavlinovic --- src/cmd/go.mod | 6 +- src/cmd/go.sum | 13 +- .../google/pprof/internal/elfexec/elfexec.go | 105 +- .../pprof/internal/report/source_html.go | 3 +- .../ianlancetaylor/demangle/README.md | 2 +- .../github.com/ianlancetaylor/demangle/ast.go | 982 +++++- .../ianlancetaylor/demangle/demangle.go | 578 ++- .../ianlancetaylor/demangle/rust.go | 1069 ++++++ .../vendor/golang.org/x/sys/unix/mkerrors.sh | 9 +- .../golang.org/x/sys/unix/syscall_darwin.go | 40 +- .../golang.org/x/sys/unix/syscall_illumos.go | 8 + .../golang.org/x/sys/unix/syscall_linux.go | 82 +- .../x/sys/unix/syscall_linux_386.go | 38 - .../x/sys/unix/syscall_linux_amd64.go | 48 - .../x/sys/unix/syscall_linux_arm.go | 42 - .../x/sys/unix/syscall_linux_arm64.go | 51 - .../x/sys/unix/syscall_linux_mips64x.go | 39 - .../x/sys/unix/syscall_linux_mipsx.go | 35 - .../x/sys/unix/syscall_linux_ppc.go | 38 - .../x/sys/unix/syscall_linux_ppc64x.go | 38 - .../x/sys/unix/syscall_linux_riscv64.go | 51 - .../x/sys/unix/syscall_linux_s390x.go | 36 - .../x/sys/unix/syscall_linux_sparc64.go | 37 - .../golang.org/x/sys/unix/sysvshm_linux.go | 21 + .../golang.org/x/sys/unix/sysvshm_unix.go | 61 + .../x/sys/unix/sysvshm_unix_other.go | 14 + .../x/sys/unix/zerrors_darwin_amd64.go | 3126 +++++++++-------- .../x/sys/unix/zerrors_darwin_arm64.go | 3126 +++++++++-------- .../golang.org/x/sys/unix/zerrors_linux.go | 16 + .../x/sys/unix/zsyscall_darwin_amd64.go | 59 + .../x/sys/unix/zsyscall_darwin_amd64.s | 24 + .../x/sys/unix/zsyscall_darwin_arm64.go | 59 + .../x/sys/unix/zsyscall_darwin_arm64.s | 24 + .../golang.org/x/sys/unix/zsyscall_linux.go | 69 +- .../x/sys/unix/zsyscall_linux_386.go | 53 - .../x/sys/unix/zsyscall_linux_amd64.go | 53 - .../x/sys/unix/zsyscall_linux_arm.go | 53 - .../x/sys/unix/zsyscall_linux_mips.go | 55 - .../x/sys/unix/zsyscall_linux_mips64.go | 32 - .../x/sys/unix/zsyscall_linux_mips64le.go | 32 - .../x/sys/unix/zsyscall_linux_mipsle.go | 55 - .../x/sys/unix/zsyscall_linux_ppc.go | 53 - .../x/sys/unix/zsyscall_linux_ppc64.go | 53 - .../x/sys/unix/zsyscall_linux_ppc64le.go | 53 - .../x/sys/unix/zsyscall_linux_s390x.go | 43 - .../x/sys/unix/zsyscall_linux_sparc64.go | 42 - .../x/sys/unix/ztypes_darwin_amd64.go | 127 + .../x/sys/unix/ztypes_darwin_arm64.go | 127 + .../x/sys/unix/ztypes_freebsd_386.go | 2 + .../x/sys/unix/ztypes_freebsd_amd64.go | 2 + .../x/sys/unix/ztypes_freebsd_arm.go | 2 + .../x/sys/unix/ztypes_freebsd_arm64.go | 2 + .../x/sys/unix/ztypes_illumos_amd64.go | 2 + .../golang.org/x/sys/unix/ztypes_linux.go | 33 + .../golang.org/x/sys/unix/ztypes_linux_386.go | 33 + .../x/sys/unix/ztypes_linux_amd64.go | 30 + .../golang.org/x/sys/unix/ztypes_linux_arm.go | 33 + .../x/sys/unix/ztypes_linux_arm64.go | 30 + .../x/sys/unix/ztypes_linux_mips.go | 32 + .../x/sys/unix/ztypes_linux_mips64.go | 30 + .../x/sys/unix/ztypes_linux_mips64le.go | 30 + .../x/sys/unix/ztypes_linux_mipsle.go | 32 + .../golang.org/x/sys/unix/ztypes_linux_ppc.go | 34 + .../x/sys/unix/ztypes_linux_ppc64.go | 29 + .../x/sys/unix/ztypes_linux_ppc64le.go | 29 + .../x/sys/unix/ztypes_linux_riscv64.go | 30 + .../x/sys/unix/ztypes_linux_s390x.go | 29 + .../x/sys/unix/ztypes_linux_sparc64.go | 29 + .../x/sys/windows/memory_windows.go | 11 + .../x/sys/windows/syscall_windows.go | 10 + .../golang.org/x/sys/windows/types_windows.go | 14 + .../x/sys/windows/zsyscall_windows.go | 90 + src/cmd/vendor/modules.txt | 8 +- src/go.mod | 2 +- src/go.sum | 4 +- src/vendor/modules.txt | 2 +- 76 files changed, 7008 insertions(+), 4386 deletions(-) create mode 100644 src/cmd/vendor/github.com/ianlancetaylor/demangle/rust.go create mode 100644 src/cmd/vendor/golang.org/x/sys/unix/sysvshm_linux.go create mode 100644 src/cmd/vendor/golang.org/x/sys/unix/sysvshm_unix.go create mode 100644 src/cmd/vendor/golang.org/x/sys/unix/sysvshm_unix_other.go diff --git a/src/cmd/go.mod b/src/cmd/go.mod index e6fdc902dd..f7802a1675 100644 --- a/src/cmd/go.mod +++ b/src/cmd/go.mod @@ -3,7 +3,7 @@ module cmd go 1.18 require ( - github.com/google/pprof v0.0.0-20211001005136-7fe48b4c820b + github.com/google/pprof v0.0.0-20211104044539-f987b9c94b31 golang.org/x/arch v0.0.0-20210901143047-ebb09ed340f1 golang.org/x/mod v0.5.1-0.20210913215816-37dd6891021a golang.org/x/sync v0.0.0-20210220032951-036812b2e83c @@ -12,8 +12,8 @@ require ( ) require ( - github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 // indirect + github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d // indirect golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect - golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e // indirect + golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect ) diff --git a/src/cmd/go.sum b/src/cmd/go.sum index 4993128d1a..25c25d81bd 100644 --- a/src/cmd/go.sum +++ b/src/cmd/go.sum @@ -1,10 +1,10 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/google/pprof v0.0.0-20211001005136-7fe48b4c820b h1:GX4+fGLMW5XTmDXB3R6UhTwZIYqgAOdA19+Ea0+3CU4= -github.com/google/pprof v0.0.0-20211001005136-7fe48b4c820b/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/google/pprof v0.0.0-20211104044539-f987b9c94b31 h1:YvpxjnjGhf/vDEeYOysNbsrtB///PKS8lqkFNSDm1p8= +github.com/google/pprof v0.0.0-20211104044539-f987b9c94b31/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= +github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d h1:uGg2frlt3IcT7kbV6LEp5ONv4vmoO2FW4qSO+my/aoM= +github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= golang.org/x/arch v0.0.0-20210901143047-ebb09ed340f1 h1:MwxAfiDvuwX8Nnnc6iRDhzyMyyc2tz5tYyCP/pZcPCg= golang.org/x/arch v0.0.0-20210901143047-ebb09ed340f1/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= @@ -13,9 +13,8 @@ golang.org/x/mod v0.5.1-0.20210913215816-37dd6891021a h1:55PVa91KndtPGH2lus5l2gD golang.org/x/mod v0.5.1-0.20210913215816-37dd6891021a/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e h1:XMgFehsDnnLGtjvjOfqWSUzt0alpTR1RSEuznObga2c= -golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/tools v0.1.8-0.20211025211149-f916b54a1784 h1:+xP+QoP2SEPgbn+07I/yJTzP+gavj0XKGS6+JU5tlck= diff --git a/src/cmd/vendor/github.com/google/pprof/internal/elfexec/elfexec.go b/src/cmd/vendor/github.com/google/pprof/internal/elfexec/elfexec.go index 4f11645185..6447092d3d 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/elfexec/elfexec.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/elfexec/elfexec.go @@ -165,18 +165,60 @@ func GetBuildID(binary io.ReaderAt) ([]byte, error) { return nil, nil } +// kernelBase caluclates the base for kernel mappings, which usually require +// special handling. For kernel mappings, tools (like perf) use the address of +// the kernel relocation symbol (_text or _stext) as the mmap start. Additionaly, +// for obfuscation, ChromeOS profiles have the kernel image remapped to the 0-th page. +func kernelBase(loadSegment *elf.ProgHeader, stextOffset *uint64, start, limit, offset uint64) (uint64, bool) { + const ( + // PAGE_OFFSET for PowerPC64, see arch/powerpc/Kconfig in the kernel sources. + pageOffsetPpc64 = 0xc000000000000000 + pageSize = 4096 + ) + + if loadSegment.Vaddr == start-offset { + return offset, true + } + if start == 0 && limit != 0 && stextOffset != nil { + // ChromeOS remaps its kernel to 0. Nothing else should come + // down this path. Empirical values: + // VADDR=0xffffffff80200000 + // stextOffset=0xffffffff80200198 + return start - *stextOffset, true + } + if start >= loadSegment.Vaddr && limit > start && (offset == 0 || offset == pageOffsetPpc64 || offset == start) { + // Some kernels look like: + // VADDR=0xffffffff80200000 + // stextOffset=0xffffffff80200198 + // Start=0xffffffff83200000 + // Limit=0xffffffff84200000 + // Offset=0 (0xc000000000000000 for PowerPC64) (== Start for ASLR kernel) + // So the base should be: + if stextOffset != nil && (start%pageSize) == (*stextOffset%pageSize) { + // perf uses the address of _stext as start. Some tools may + // adjust for this before calling GetBase, in which case the page + // alignment should be different from that of stextOffset. + return start - *stextOffset, true + } + + return start - loadSegment.Vaddr, true + } + if start%pageSize != 0 && stextOffset != nil && *stextOffset%pageSize == start%pageSize { + // ChromeOS remaps its kernel to 0 + start%pageSize. Nothing + // else should come down this path. Empirical values: + // start=0x198 limit=0x2f9fffff offset=0 + // VADDR=0xffffffff81000000 + // stextOffset=0xffffffff81000198 + return start - *stextOffset, true + } + return 0, false +} + // GetBase determines the base address to subtract from virtual // address to get symbol table address. For an executable, the base // is 0. Otherwise, it's a shared library, and the base is the -// address where the mapping starts. The kernel is special, and may -// use the address of the _stext symbol as the mmap start. _stext -// offset can be obtained with `nm vmlinux | grep _stext` +// address where the mapping starts. The kernel needs special hanldling. func GetBase(fh *elf.FileHeader, loadSegment *elf.ProgHeader, stextOffset *uint64, start, limit, offset uint64) (uint64, error) { - const ( - pageSize = 4096 - // PAGE_OFFSET for PowerPC64, see arch/powerpc/Kconfig in the kernel sources. - pageOffsetPpc64 = 0xc000000000000000 - ) if start == 0 && offset == 0 && (limit == ^uint64(0) || limit == 0) { // Some tools may introduce a fake mapping that spans the entire @@ -202,43 +244,15 @@ func GetBase(fh *elf.FileHeader, loadSegment *elf.ProgHeader, stextOffset *uint6 // the 64-bit address space. return start - offset + loadSegment.Off - loadSegment.Vaddr, nil } - // Various kernel heuristics and cases follow. - if loadSegment.Vaddr == start-offset { - return offset, nil + // Various kernel heuristics and cases are handled separately. + if base, match := kernelBase(loadSegment, stextOffset, start, limit, offset); match { + return base, nil } - if start == 0 && limit != 0 { - // ChromeOS remaps its kernel to 0. Nothing else should come - // down this path. Empirical values: - // VADDR=0xffffffff80200000 - // stextOffset=0xffffffff80200198 - if stextOffset != nil { - return -*stextOffset, nil - } - return -loadSegment.Vaddr, nil - } - if start >= loadSegment.Vaddr && limit > start && (offset == 0 || offset == pageOffsetPpc64 || offset == start) { - // Some kernels look like: - // VADDR=0xffffffff80200000 - // stextOffset=0xffffffff80200198 - // Start=0xffffffff83200000 - // Limit=0xffffffff84200000 - // Offset=0 (0xc000000000000000 for PowerPC64) (== Start for ASLR kernel) - // So the base should be: - if stextOffset != nil && (start%pageSize) == (*stextOffset%pageSize) { - // perf uses the address of _stext as start. Some tools may - // adjust for this before calling GetBase, in which case the page - // alignment should be different from that of stextOffset. - return start - *stextOffset, nil - } - + // ChromeOS can remap its kernel to 0, and the caller might have not found + // the _stext symbol. Split this case from kernelBase() above, since we don't + // want to apply it to an ET_DYN user-mode executable. + if start == 0 && limit != 0 && stextOffset == nil { return start - loadSegment.Vaddr, nil - } else if start%pageSize != 0 && stextOffset != nil && *stextOffset%pageSize == start%pageSize { - // ChromeOS remaps its kernel to 0 + start%pageSize. Nothing - // else should come down this path. Empirical values: - // start=0x198 limit=0x2f9fffff offset=0 - // VADDR=0xffffffff81000000 - // stextOffset=0xffffffff81000198 - return start - *stextOffset, nil } return 0, fmt.Errorf("don't know how to handle EXEC segment: %v start=0x%x limit=0x%x offset=0x%x", *loadSegment, start, limit, offset) @@ -255,6 +269,11 @@ func GetBase(fh *elf.FileHeader, loadSegment *elf.ProgHeader, stextOffset *uint6 if loadSegment == nil { return start - offset, nil } + // Kernels compiled as PIE can be ET_DYN as well. Use heuristic, similar to + // the ET_EXEC case above. + if base, match := kernelBase(loadSegment, stextOffset, start, limit, offset); match { + return base, nil + } // The program header, if not nil, indicates the offset in the file where // the executable segment is located (loadSegment.Off), and the base virtual // address where the first byte of the segment is loaded diff --git a/src/cmd/vendor/github.com/google/pprof/internal/report/source_html.go b/src/cmd/vendor/github.com/google/pprof/internal/report/source_html.go index 17c9f6eb94..851693f1d0 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/report/source_html.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/report/source_html.go @@ -72,5 +72,4 @@ function pprof_toggle_asm(e) { const weblistPageClosing = ` - -` +` diff --git a/src/cmd/vendor/github.com/ianlancetaylor/demangle/README.md b/src/cmd/vendor/github.com/ianlancetaylor/demangle/README.md index ef3f94a63d..2c01cae088 100644 --- a/src/cmd/vendor/github.com/ianlancetaylor/demangle/README.md +++ b/src/cmd/vendor/github.com/ianlancetaylor/demangle/README.md @@ -1,3 +1,3 @@ # github.com/ianlancetaylor/demangle -A Go package that can be used to demangle C++ symbol names. +A Go package that can be used to demangle C++ and Rust symbol names. diff --git a/src/cmd/vendor/github.com/ianlancetaylor/demangle/ast.go b/src/cmd/vendor/github.com/ianlancetaylor/demangle/ast.go index ccbe5b3559..7b9178f1bb 100644 --- a/src/cmd/vendor/github.com/ianlancetaylor/demangle/ast.go +++ b/src/cmd/vendor/github.com/ianlancetaylor/demangle/ast.go @@ -11,6 +11,7 @@ import ( // AST is an abstract syntax tree representing a C++ declaration. // This is sufficient for the demangler but is by no means a general C++ AST. +// This abstract syntax tree is only used for C++ symbols, not Rust symbols. type AST interface { // Internal method to convert to demangled string. print(*printState) @@ -37,21 +38,25 @@ type AST interface { // ASTToString returns the demangled name of the AST. func ASTToString(a AST, options ...Option) string { tparams := true + llvmStyle := false for _, o := range options { switch o { case NoTemplateParams: tparams = false + case LLVMStyle: + llvmStyle = true } } - ps := printState{tparams: tparams} + ps := printState{tparams: tparams, llvmStyle: llvmStyle} a.print(&ps) return ps.buf.String() } // The printState type holds information needed to print an AST. type printState struct { - tparams bool // whether to print template parameters + tparams bool // whether to print template parameters + llvmStyle bool buf strings.Builder last byte // Last byte written to buffer. @@ -408,7 +413,11 @@ type LambdaAuto struct { func (la *LambdaAuto) print(ps *printState) { // We print the index plus 1 because that is what the standard // demangler does. - fmt.Fprintf(&ps.buf, "auto:%d", la.Index+1) + if ps.llvmStyle { + ps.writeString("auto") + } else { + fmt.Fprintf(&ps.buf, "auto:%d", la.Index+1) + } } func (la *LambdaAuto) Traverse(fn func(AST) bool) { @@ -504,6 +513,9 @@ func (q *Qualifier) print(ps *printState) { ps.writeByte('(') first := true for _, e := range q.Exprs { + if el, ok := e.(*ExprList); ok && len(el.Exprs) == 0 { + continue + } if !first { ps.writeString(", ") } @@ -715,7 +727,11 @@ type BuiltinType struct { } func (bt *BuiltinType) print(ps *printState) { - ps.writeString(bt.Name) + name := bt.Name + if ps.llvmStyle && name == "decltype(nullptr)" { + name = "std::nullptr_t" + } + ps.writeString(name) } func (bt *BuiltinType) Traverse(fn func(AST) bool) { @@ -970,10 +986,15 @@ type VendorQualifier struct { } func (vq *VendorQualifier) print(ps *printState) { - ps.inner = append(ps.inner, vq) - ps.print(vq.Type) - if len(ps.inner) > 0 { - ps.printOneInner(nil) + if ps.llvmStyle { + ps.print(vq.Type) + vq.printInner(ps) + } else { + ps.inner = append(ps.inner, vq) + ps.print(vq.Type) + if len(ps.inner) > 0 { + ps.printOneInner(nil) + } } } @@ -1110,19 +1131,27 @@ func (at *ArrayType) goString(indent int, field string) string { at.Element.goString(indent+2, "Element: ")) } -// FunctionType is a function type. The Return field may be nil for -// cases where the return type is not part of the mangled name. +// FunctionType is a function type. type FunctionType struct { Return AST Args []AST + + // The forLocalName field reports whether this FunctionType + // was created for a local name. With the default GNU demangling + // output we don't print the return type in that case. + ForLocalName bool } func (ft *FunctionType) print(ps *printState) { - if ft.Return != nil { + retType := ft.Return + if ft.ForLocalName && !ps.llvmStyle { + retType = nil + } + if retType != nil { // Pass the return type as an inner type in order to // print the arguments in the right location. ps.inner = append(ps.inner, ft) - ps.print(ft.Return) + ps.print(retType) if len(ps.inner) == 0 { // Everything was printed. return @@ -1227,7 +1256,11 @@ func (ft *FunctionType) Copy(fn func(AST) AST, skip func(AST) bool) AST { if !changed { return fn(ft) } - ft = &FunctionType{Return: ret, Args: args} + ft = &FunctionType{ + Return: ret, + Args: args, + ForLocalName: ft.ForLocalName, + } if r := fn(ft); r != nil { return r } @@ -1239,6 +1272,10 @@ func (ft *FunctionType) GoString() string { } func (ft *FunctionType) goString(indent int, field string) string { + var forLocalName string + if ft.ForLocalName { + forLocalName = " ForLocalName: true" + } var r string if ft.Return == nil { r = fmt.Sprintf("%*sReturn: nil", indent+2, "") @@ -1255,7 +1292,8 @@ func (ft *FunctionType) goString(indent int, field string) string { args += a.goString(indent+4, fmt.Sprintf("%d: ", i)) } } - return fmt.Sprintf("%*s%sFunctionType:\n%s\n%s", indent, "", field, r, args) + return fmt.Sprintf("%*s%sFunctionType:%s\n%s\n%s", indent, "", field, + forLocalName, r, args) } // FunctionParam is a parameter of a function, used for last-specified @@ -1267,6 +1305,12 @@ type FunctionParam struct { func (fp *FunctionParam) print(ps *printState) { if fp.Index == 0 { ps.writeString("this") + } else if ps.llvmStyle { + if fp.Index == 1 { + ps.writeString("fp") + } else { + fmt.Fprintf(&ps.buf, "fp%d", fp.Index-2) + } } else { fmt.Fprintf(&ps.buf, "{parm#%d}", fp.Index) } @@ -1422,9 +1466,15 @@ func (vt *VectorType) print(ps *printState) { } func (vt *VectorType) printInner(ps *printState) { - ps.writeString(" __vector(") + end := byte(')') + if ps.llvmStyle { + ps.writeString(" vector[") + end = ']' + } else { + ps.writeString(" __vector(") + } ps.print(vt.Dimension) - ps.writeByte(')') + ps.writeByte(end) } func (vt *VectorType) Traverse(fn func(AST) bool) { @@ -1466,13 +1516,59 @@ func (vt *VectorType) goString(indent int, field string) string { vt.Base.goString(indent+2, "Base: ")) } +// ElaboratedType is an elaborated struct/union/enum type. +type ElaboratedType struct { + Kind string + Type AST +} + +func (et *ElaboratedType) print(ps *printState) { + ps.writeString(et.Kind) + ps.writeString(" ") + et.Type.print(ps) +} + +func (et *ElaboratedType) Traverse(fn func(AST) bool) { + if fn(et) { + et.Type.Traverse(fn) + } +} + +func (et *ElaboratedType) Copy(fn func(AST) AST, skip func(AST) bool) AST { + if skip(et) { + return nil + } + typ := et.Type.Copy(fn, skip) + if typ == nil { + return fn(et) + } + et = &ElaboratedType{Kind: et.Kind, Type: typ} + if r := fn(et); r != nil { + return r + } + return et +} + +func (et *ElaboratedType) GoString() string { + return et.goString(0, "") +} + +func (et *ElaboratedType) goString(indent int, field string) string { + return fmt.Sprintf("%*s%sElaboratedtype: Kind: %s\n%s", indent, "", field, + et.Kind, et.Type.goString(indent+2, "Expr: ")) +} + // Decltype is the decltype operator. type Decltype struct { Expr AST } func (dt *Decltype) print(ps *printState) { - ps.writeString("decltype (") + ps.writeString("decltype") + if !ps.llvmStyle { + ps.writeString(" ") + } + ps.writeString("(") ps.print(dt.Expr) ps.writeByte(')') } @@ -1544,15 +1640,20 @@ func (op *Operator) goString(indent int, field string) string { // Constructor is a constructor. type Constructor struct { Name AST + Base AST // base class of inheriting constructor } func (c *Constructor) print(ps *printState) { ps.print(c.Name) + // We don't include the base class in the demangled string. } func (c *Constructor) Traverse(fn func(AST) bool) { if fn(c) { c.Name.Traverse(fn) + if c.Base != nil { + c.Base.Traverse(fn) + } } } @@ -1561,10 +1662,20 @@ func (c *Constructor) Copy(fn func(AST) AST, skip func(AST) bool) AST { return nil } name := c.Name.Copy(fn, skip) - if name == nil { + var base AST + if c.Base != nil { + base = c.Base.Copy(fn, skip) + } + if name == nil && base == nil { return fn(c) } - c = &Constructor{Name: name} + if name == nil { + name = c.Name + } + if base == nil { + base = c.Base + } + c = &Constructor{Name: name, Base: base} if r := fn(c); r != nil { return r } @@ -1576,7 +1687,13 @@ func (c *Constructor) GoString() string { } func (c *Constructor) goString(indent int, field string) string { - return fmt.Sprintf("%*s%sConstructor:\n%s", indent, "", field, c.Name.goString(indent+2, "Name: ")) + var sb strings.Builder + fmt.Fprintf(&sb, "%*s%sConstructor:\n", indent, "", field) + if c.Base != nil { + fmt.Fprintf(&sb, "%s\n", c.Base.goString(indent+2, "Base: ")) + } + fmt.Fprintf(&sb, "%s", c.Name.goString(indent+2, "Name: ")) + return sb.String() } // Destructor is a destructor. @@ -1727,8 +1844,12 @@ func (pe *PackExpansion) print(ps *printState) { // We normally only get here if the simplify function was // unable to locate and expand the pack. if pe.Pack == nil { - parenthesize(ps, pe.Base) - ps.writeString("...") + if ps.llvmStyle { + ps.print(pe.Base) + } else { + parenthesize(ps, pe.Base) + ps.writeString("...") + } } else { ps.print(pe.Base) } @@ -1834,7 +1955,13 @@ type SizeofPack struct { } func (sp *SizeofPack) print(ps *printState) { - ps.writeString(fmt.Sprintf("%d", len(sp.Pack.Args))) + if ps.llvmStyle { + ps.writeString("sizeof...(") + ps.print(sp.Pack) + ps.writeByte(')') + } else { + ps.writeString(fmt.Sprintf("%d", len(sp.Pack.Args))) + } } func (sp *SizeofPack) Traverse(fn func(AST) bool) { @@ -1932,6 +2059,287 @@ func (sa *SizeofArgs) goString(indent int, field string) string { return fmt.Sprintf("%*s%sSizeofArgs:\n%s", indent, "", field, args) } +// TemplateParamName is the name of a template parameter that the +// demangler introduced for a lambda that has explicit template +// parameters. This is a prefix with an index. +type TemplateParamName struct { + Prefix string + Index int +} + +func (tpn *TemplateParamName) print(ps *printState) { + ps.writeString(tpn.Prefix) + if tpn.Index > 0 { + ps.writeString(fmt.Sprintf("%d", tpn.Index-1)) + } +} + +func (tpn *TemplateParamName) Traverse(fn func(AST) bool) { + fn(tpn) +} + +func (tpn *TemplateParamName) Copy(fn func(AST) AST, skip func(AST) bool) AST { + if skip(tpn) { + return nil + } + return fn(tpn) +} + +func (tpn *TemplateParamName) GoString() string { + return tpn.goString(0, "") +} + +func (tpn *TemplateParamName) goString(indent int, field string) string { + name := tpn.Prefix + if tpn.Index > 0 { + name += fmt.Sprintf("%d", tpn.Index-1) + } + return fmt.Sprintf("%*s%sTemplateParamName: %s", indent, "", field, name) +} + +// TypeTemplateParam is a type template parameter that appears in a +// lambda with explicit template parameters. +type TypeTemplateParam struct { + Name AST +} + +func (ttp *TypeTemplateParam) print(ps *printState) { + ps.writeString("typename ") + ps.printInner(false) + ps.print(ttp.Name) +} + +func (ttp *TypeTemplateParam) Traverse(fn func(AST) bool) { + if fn(ttp) { + ttp.Name.Traverse(fn) + } +} + +func (ttp *TypeTemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) AST { + if skip(ttp) { + return nil + } + name := ttp.Name.Copy(fn, skip) + if name == nil { + return fn(ttp) + } + ttp = &TypeTemplateParam{Name: name} + if r := fn(ttp); r != nil { + return r + } + return ttp +} + +func (ttp *TypeTemplateParam) GoString() string { + return ttp.goString(0, "") +} + +func (ttp *TypeTemplateParam) goString(indent int, field string) string { + return fmt.Sprintf("%*s%sTypeTemplateParam:\n%s", indent, "", field, + ttp.Name.goString(indent+2, "Name")) +} + +// NonTypeTemplateParam is a non-type template parameter that appears +// in a lambda with explicit template parameters. +type NonTypeTemplateParam struct { + Name AST + Type AST +} + +func (nttp *NonTypeTemplateParam) print(ps *printState) { + ps.inner = append(ps.inner, nttp) + ps.print(nttp.Type) + if len(ps.inner) > 0 { + ps.writeByte(' ') + ps.print(nttp.Name) + ps.inner = ps.inner[:len(ps.inner)-1] + } +} + +func (nttp *NonTypeTemplateParam) printInner(ps *printState) { + ps.print(nttp.Name) +} + +func (nttp *NonTypeTemplateParam) Traverse(fn func(AST) bool) { + if fn(nttp) { + nttp.Name.Traverse(fn) + nttp.Type.Traverse(fn) + } +} + +func (nttp *NonTypeTemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) AST { + if skip(nttp) { + return nil + } + name := nttp.Name.Copy(fn, skip) + typ := nttp.Type.Copy(fn, skip) + if name == nil && typ == nil { + return fn(nttp) + } + if name == nil { + name = nttp.Name + } + if typ == nil { + typ = nttp.Type + } + nttp = &NonTypeTemplateParam{Name: name, Type: typ} + if r := fn(nttp); r != nil { + return r + } + return nttp +} + +func (nttp *NonTypeTemplateParam) GoString() string { + return nttp.goString(0, "") +} + +func (nttp *NonTypeTemplateParam) goString(indent int, field string) string { + return fmt.Sprintf("%*s%sNonTypeTemplateParam:\n%s\n%s", indent, "", field, + nttp.Name.goString(indent+2, "Name: "), + nttp.Type.goString(indent+2, "Type: ")) +} + +// TemplateTemplateParam is a template template parameter that appears +// in a lambda with explicit template parameters. +type TemplateTemplateParam struct { + Name AST + Params []AST +} + +func (ttp *TemplateTemplateParam) print(ps *printState) { + ps.writeString("template<") + for i, param := range ttp.Params { + if i > 0 { + ps.writeString(", ") + } + ps.print(param) + } + ps.writeString("> typename ") + ps.print(ttp.Name) +} + +func (ttp *TemplateTemplateParam) Traverse(fn func(AST) bool) { + if fn(ttp) { + ttp.Name.Traverse(fn) + for _, param := range ttp.Params { + param.Traverse(fn) + } + } +} + +func (ttp *TemplateTemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) AST { + if skip(ttp) { + return nil + } + + changed := false + + name := ttp.Name.Copy(fn, skip) + if name == nil { + name = ttp.Name + } else { + changed = true + } + + params := make([]AST, len(ttp.Params)) + for i, p := range ttp.Params { + pc := p.Copy(fn, skip) + if pc == nil { + params[i] = p + } else { + params[i] = pc + changed = true + } + } + + if !changed { + return fn(ttp) + } + + ttp = &TemplateTemplateParam{ + Name: name, + Params: params, + } + if r := fn(ttp); r != nil { + return r + } + return ttp +} + +func (ttp *TemplateTemplateParam) GoString() string { + return ttp.goString(0, "") +} + +func (ttp *TemplateTemplateParam) goString(indent int, field string) string { + var params strings.Builder + fmt.Fprintf(¶ms, "%*sParams:", indent+2, "") + for i, p := range ttp.Params { + params.WriteByte('\n') + params.WriteString(p.goString(indent+4, fmt.Sprintf("%d: ", i))) + } + return fmt.Sprintf("%*s%sTemplateTemplateParam:\n%s\n%s", indent, "", field, + ttp.Name.goString(indent+2, "Name: "), + params.String()) +} + +// TemplateParamPack is a template parameter pack that appears in a +// lambda with explicit template parameters. +type TemplateParamPack struct { + Param AST +} + +func (tpp *TemplateParamPack) print(ps *printState) { + holdInner := ps.inner + defer func() { ps.inner = holdInner }() + + ps.inner = []AST{tpp} + if nttp, ok := tpp.Param.(*NonTypeTemplateParam); ok { + ps.print(nttp.Type) + } else { + ps.print(tpp.Param) + } + if len(ps.inner) > 0 { + ps.writeString("...") + } +} + +func (tpp *TemplateParamPack) printInner(ps *printState) { + ps.writeString("...") + if nttp, ok := tpp.Param.(*NonTypeTemplateParam); ok { + ps.print(nttp.Name) + } +} + +func (tpp *TemplateParamPack) Traverse(fn func(AST) bool) { + if fn(tpp) { + tpp.Param.Traverse(fn) + } +} + +func (tpp *TemplateParamPack) Copy(fn func(AST) AST, skip func(AST) bool) AST { + if skip(tpp) { + return nil + } + param := tpp.Param.Copy(fn, skip) + if param == nil { + return fn(tpp) + } + tpp = &TemplateParamPack{Param: param} + if r := fn(tpp); r != nil { + return r + } + return tpp +} + +func (tpp *TemplateParamPack) GoString() string { + return tpp.goString(0, "") +} + +func (tpp *TemplateParamPack) goString(indent int, field string) string { + return fmt.Sprintf("%*s%sTemplateParamPack:\n%s", indent, "", field, + tpp.Param.goString(indent+2, "Param: ")) +} + // Cast is a type cast. type Cast struct { To AST @@ -1977,7 +2385,11 @@ func (c *Cast) goString(indent int, field string) string { func parenthesize(ps *printState, val AST) { paren := false switch v := val.(type) { - case *Name, *InitializerList, *FunctionParam: + case *Name, *InitializerList: + case *FunctionParam: + if ps.llvmStyle { + paren = true + } case *Qualified: if v.LocalName { paren = true @@ -2047,14 +2459,17 @@ type Unary struct { } func (u *Unary) print(ps *printState) { + op, _ := u.Op.(*Operator) expr := u.Expr // Don't print the argument list when taking the address of a // function. - if op, ok := u.Op.(*Operator); ok && op.Name == "&" { - if t, ok := expr.(*Typed); ok { - if _, ok := t.Type.(*FunctionType); ok { - expr = t.Name + if !ps.llvmStyle { + if op != nil && op.Name == "&" { + if t, ok := expr.(*Typed); ok { + if _, ok := t.Type.(*FunctionType); ok { + expr = t.Name + } } } } @@ -2063,8 +2478,11 @@ func (u *Unary) print(ps *printState) { parenthesize(ps, expr) } - if op, ok := u.Op.(*Operator); ok { + if op != nil { ps.writeString(op.Name) + if ps.llvmStyle && op.Name == "noexcept" { + ps.writeByte(' ') + } } else if c, ok := u.Op.(*Cast); ok { ps.writeByte('(') ps.print(c.To) @@ -2074,7 +2492,7 @@ func (u *Unary) print(ps *printState) { } if !u.Suffix { - if op, ok := u.Op.(*Operator); ok && op.Name == "::" { + if op != nil && op.Name == "::" { // Don't use parentheses after ::. ps.print(expr) } else if u.SizeofType { @@ -2082,6 +2500,19 @@ func (u *Unary) print(ps *printState) { ps.writeByte('(') ps.print(expr) ps.writeByte(')') + } else if op != nil && op.Name == "__alignof__" { + // Always use parentheses for __alignof__ argument. + ps.writeByte('(') + ps.print(expr) + ps.writeByte(')') + } else if ps.llvmStyle { + if op == nil || op.Name != `operator"" ` { + ps.writeByte('(') + } + ps.print(expr) + if op == nil || op.Name != `operator"" ` { + ps.writeByte(')') + } } else { parenthesize(ps, expr) } @@ -2140,7 +2571,16 @@ func isDesignatedInitializer(x AST) bool { switch x := x.(type) { case *Binary: if op, ok := x.Op.(*Operator); ok { - return op.Name == "=" || op.Name == "]=" + if op.Name == "]=" { + return true + } + if op.Name != "=" { + return false + } + if _, ok := x.Left.(*Literal); ok { + return false + } + return true } case *Trinary: if op, ok := x.Op.(*Operator); ok { @@ -2185,8 +2625,13 @@ func (b *Binary) print(ps *printState) { // initializer chains. ps.print(b.Right) } else { - ps.writeByte('=') - parenthesize(ps, b.Right) + if ps.llvmStyle { + ps.writeString(" = ") + ps.print(b.Right) + } else { + ps.writeByte('=') + parenthesize(ps, b.Right) + } } return } @@ -2200,9 +2645,19 @@ func (b *Binary) print(ps *printState) { left := b.Left + skipParens := false + skipBothParens := false + addSpaces := ps.llvmStyle + if ps.llvmStyle && op != nil { + switch op.Name { + case ".", "->": + skipBothParens = true + addSpaces = false + } + } + // For a function call in an expression, don't print the types // of the arguments unless there is a return type. - skipParens := false if op != nil && op.Name == "()" { if ty, ok := b.Left.(*Typed); ok { if ft, ok := ty.Type.(*FunctionType); ok { @@ -2215,10 +2670,17 @@ func (b *Binary) print(ps *printState) { left = ty.Name } } + if ps.llvmStyle { + skipParens = true + } } - if skipParens { + if skipParens || skipBothParens { ps.print(left) + } else if ps.llvmStyle { + ps.writeByte('(') + ps.print(left) + ps.writeByte(')') } else { parenthesize(ps, left) } @@ -2232,13 +2694,27 @@ func (b *Binary) print(ps *printState) { if op != nil { if op.Name != "()" { + if addSpaces { + ps.writeByte(' ') + } ps.writeString(op.Name) + if addSpaces { + ps.writeByte(' ') + } } } else { ps.print(b.Op) } - parenthesize(ps, b.Right) + if skipBothParens { + ps.print(b.Right) + } else if ps.llvmStyle { + ps.writeByte('(') + ps.print(b.Right) + ps.writeByte(')') + } else { + parenthesize(ps, b.Right) + } if op != nil && op.Name == ">" { ps.writeByte(')') @@ -2310,14 +2786,23 @@ func (t *Trinary) print(ps *printState) { // initializer chains. ps.print(t.Third) } else { - ps.writeByte('=') - parenthesize(ps, t.Third) + if ps.llvmStyle { + ps.writeString(" = ") + ps.print(t.Third) + } else { + ps.writeByte('=') + parenthesize(ps, t.Third) + } } return } parenthesize(ps, t.First) - ps.writeByte('?') + if ps.llvmStyle { + ps.writeString(" ? ") + } else { + ps.writeByte('?') + } parenthesize(ps, t.Second) ps.writeString(" : ") parenthesize(ps, t.Third) @@ -2386,31 +2871,44 @@ func (f *Fold) print(ps *printState) { op, _ := f.Op.(*Operator) printOp := func() { if op != nil { + if ps.llvmStyle { + ps.writeByte(' ') + } ps.writeString(op.Name) + if ps.llvmStyle { + ps.writeByte(' ') + } } else { ps.print(f.Op) } } + foldParenthesize := func(a AST) { + if _, ok := a.(*ArgumentPack); ok || !ps.llvmStyle { + parenthesize(ps, a) + } else { + ps.print(a) + } + } if f.Arg2 == nil { if f.Left { ps.writeString("(...") printOp() - parenthesize(ps, f.Arg1) + foldParenthesize(f.Arg1) ps.writeString(")") } else { ps.writeString("(") - parenthesize(ps, f.Arg1) + foldParenthesize(f.Arg1) printOp() ps.writeString("...)") } } else { ps.writeString("(") - parenthesize(ps, f.Arg1) + foldParenthesize(f.Arg1) printOp() ps.writeString("...") printOp() - parenthesize(ps, f.Arg2) + foldParenthesize(f.Arg2) ps.writeString(")") } } @@ -2471,6 +2969,143 @@ func (f *Fold) goString(indent int, field string) string { } } +// Subobject is a a reference to an offset in an expression. This is +// used for C++20 manglings of class types used as the type of +// non-type template arguments. +// +// See https://github.com/itanium-cxx-abi/cxx-abi/issues/47. +type Subobject struct { + Type AST + SubExpr AST + Offset int + Selectors []int + PastEnd bool +} + +func (so *Subobject) print(ps *printState) { + ps.print(so.SubExpr) + ps.writeString(".<") + ps.print(so.Type) + ps.writeString(fmt.Sprintf(" at offset %d>", so.Offset)) +} + +func (so *Subobject) Traverse(fn func(AST) bool) { + if fn(so) { + so.Type.Traverse(fn) + so.SubExpr.Traverse(fn) + } +} + +func (so *Subobject) Copy(fn func(AST) AST, skip func(AST) bool) AST { + if skip(so) { + return nil + } + typ := so.Type.Copy(fn, skip) + subExpr := so.SubExpr.Copy(fn, skip) + if typ == nil && subExpr == nil { + return nil + } + if typ == nil { + typ = so.Type + } + if subExpr == nil { + subExpr = so.SubExpr + } + so = &Subobject{ + Type: typ, + SubExpr: subExpr, + Offset: so.Offset, + Selectors: so.Selectors, + PastEnd: so.PastEnd, + } + if r := fn(so); r != nil { + return r + } + return so +} + +func (so *Subobject) GoString() string { + return so.goString(0, "") +} + +func (so *Subobject) goString(indent int, field string) string { + var selectors string + for _, s := range so.Selectors { + selectors += fmt.Sprintf(" %d", s) + } + return fmt.Sprintf("%*s%sSubobject:\n%s\n%s\n%*sOffset: %d\n%*sSelectors:%s\n%*sPastEnd: %t", + indent, "", field, + so.Type.goString(indent+2, "Type: "), + so.SubExpr.goString(indent+2, "SubExpr: "), + indent+2, "", so.Offset, + indent+2, "", selectors, + indent+2, "", so.PastEnd) +} + +// PtrMemCast is a conversion of an expression to a pointer-to-member +// type. This is used for C++20 manglings of class types used as the +// type of non-type template arguments. +// +// See https://github.com/itanium-cxx-abi/cxx-abi/issues/47. +type PtrMemCast struct { + Type AST + Expr AST + Offset int +} + +func (pmc *PtrMemCast) print(ps *printState) { + ps.writeString("(") + ps.print(pmc.Type) + ps.writeString(")(") + ps.print(pmc.Expr) + ps.writeString(")") +} + +func (pmc *PtrMemCast) Traverse(fn func(AST) bool) { + if fn(pmc) { + pmc.Type.Traverse(fn) + pmc.Expr.Traverse(fn) + } +} + +func (pmc *PtrMemCast) Copy(fn func(AST) AST, skip func(AST) bool) AST { + if skip(pmc) { + return nil + } + typ := pmc.Type.Copy(fn, skip) + expr := pmc.Expr.Copy(fn, skip) + if typ == nil && expr == nil { + return nil + } + if typ == nil { + typ = pmc.Type + } + if expr == nil { + expr = pmc.Expr + } + pmc = &PtrMemCast{ + Type: typ, + Expr: expr, + Offset: pmc.Offset, + } + if r := fn(pmc); r != nil { + return r + } + return pmc +} + +func (pmc *PtrMemCast) GoString() string { + return pmc.goString(0, "") +} + +func (pmc *PtrMemCast) goString(indent int, field string) string { + return fmt.Sprintf("%*s%sPtrMemCast:\n%s\n%s\n%*sOffset: %d", + indent, "", field, + pmc.Type.goString(indent+2, "Type: "), + pmc.Expr.goString(indent+2, "Expr: "), + indent+2, "", pmc.Offset) +} + // New is a use of operator new in an expression. type New struct { Op AST @@ -2609,7 +3244,11 @@ func (l *Literal) print(ps *printState) { return } } else if b.Name == "decltype(nullptr)" && l.Val == "" { - ps.print(l.Type) + if ps.llvmStyle { + ps.writeString("nullptr") + } else { + ps.print(l.Type) + } return } else { isFloat = builtinTypeFloat[b.Name] @@ -2667,6 +3306,90 @@ func (l *Literal) goString(indent int, field string) string { indent+2, "", l.Val) } +// StringLiteral is a string literal. +type StringLiteral struct { + Type AST +} + +func (sl *StringLiteral) print(ps *printState) { + ps.writeString(`"<`) + sl.Type.print(ps) + ps.writeString(`>"`) +} + +func (sl *StringLiteral) Traverse(fn func(AST) bool) { + if fn(sl) { + sl.Type.Traverse(fn) + } +} + +func (sl *StringLiteral) Copy(fn func(AST) AST, skip func(AST) bool) AST { + if skip(sl) { + return nil + } + typ := sl.Type.Copy(fn, skip) + if typ == nil { + return fn(sl) + } + sl = &StringLiteral{Type: typ} + if r := fn(sl); r != nil { + return r + } + return sl +} + +func (sl *StringLiteral) GoString() string { + return sl.goString(0, "") +} + +func (sl *StringLiteral) goString(indent int, field string) string { + return fmt.Sprintf("%*s%sStringLiteral:\n%s", indent, "", field, + sl.Type.goString(indent+2, "")) +} + +// LambdaExpr is a literal that is a lambda expression. +type LambdaExpr struct { + Type AST +} + +func (le *LambdaExpr) print(ps *printState) { + ps.writeString("[]") + if cl, ok := le.Type.(*Closure); ok { + cl.printTypes(ps) + } + ps.writeString("{...}") +} + +func (le *LambdaExpr) Traverse(fn func(AST) bool) { + if fn(le) { + le.Type.Traverse(fn) + } +} + +func (le *LambdaExpr) Copy(fn func(AST) AST, skip func(AST) bool) AST { + if skip(le) { + return nil + } + typ := le.Type.Copy(fn, skip) + if typ == nil { + return fn(le) + } + le = &LambdaExpr{Type: typ} + if r := fn(le); r != nil { + return r + } + return le +} + +func (le *LambdaExpr) GoString() string { + return le.goString(0, "") +} + +func (le *LambdaExpr) goString(indent int, field string) string { + return fmt.Sprintf("%*s%sLambdaExpr:\n%s", indent, "", field, + le.Type.goString(indent+2, "")) +} + // ExprList is a list of expressions, typically arguments to a // function call in an expression. type ExprList struct { @@ -2803,7 +3526,9 @@ type DefaultArg struct { } func (da *DefaultArg) print(ps *printState) { - fmt.Fprintf(&ps.buf, "{default arg#%d}::", da.Num+1) + if !ps.llvmStyle { + fmt.Fprintf(&ps.buf, "{default arg#%d}::", da.Num+1) + } ps.print(da.Arg) } @@ -2839,23 +3564,53 @@ func (da *DefaultArg) goString(indent int, field string) string { // Closure is a closure, or lambda expression. type Closure struct { - Types []AST - Num int + TemplateArgs []AST + Types []AST + Num int } func (cl *Closure) print(ps *printState) { - ps.writeString("{lambda(") + if ps.llvmStyle { + if cl.Num == 0 { + ps.writeString("'lambda'") + } else { + ps.writeString(fmt.Sprintf("'lambda%d'", cl.Num-1)) + } + } else { + ps.writeString("{lambda") + } + cl.printTypes(ps) + if !ps.llvmStyle { + ps.writeString(fmt.Sprintf("#%d}", cl.Num+1)) + } +} + +func (cl *Closure) printTypes(ps *printState) { + if len(cl.TemplateArgs) > 0 { + ps.writeString("<") + for i, a := range cl.TemplateArgs { + if i > 0 { + ps.writeString(", ") + } + ps.print(a) + } + ps.writeString(">") + } + ps.writeString("(") for i, t := range cl.Types { if i > 0 { ps.writeString(", ") } ps.print(t) } - ps.writeString(fmt.Sprintf(")#%d}", cl.Num+1)) + ps.writeString(")") } func (cl *Closure) Traverse(fn func(AST) bool) { if fn(cl) { + for _, a := range cl.TemplateArgs { + a.Traverse(fn) + } for _, t := range cl.Types { t.Traverse(fn) } @@ -2866,8 +3621,20 @@ func (cl *Closure) Copy(fn func(AST) AST, skip func(AST) bool) AST { if skip(cl) { return nil } - types := make([]AST, len(cl.Types)) changed := false + + args := make([]AST, len(cl.TemplateArgs)) + for i, a := range cl.TemplateArgs { + ac := a.Copy(fn, skip) + if ac == nil { + args[i] = a + } else { + args[i] = ac + changed = true + } + } + + types := make([]AST, len(cl.Types)) for i, t := range cl.Types { tc := t.Copy(fn, skip) if tc == nil { @@ -2877,10 +3644,11 @@ func (cl *Closure) Copy(fn func(AST) AST, skip func(AST) bool) AST { changed = true } } + if !changed { return fn(cl) } - cl = &Closure{Types: types, Num: cl.Num} + cl = &Closure{TemplateArgs: args, Types: types, Num: cl.Num} if r := fn(cl); r != nil { return r } @@ -2892,6 +3660,16 @@ func (cl *Closure) GoString() string { } func (cl *Closure) goString(indent int, field string) string { + var args string + if len(cl.TemplateArgs) == 0 { + args = fmt.Sprintf("%*sTemplateArgs: nil", indent+2, "") + } else { + args = fmt.Sprintf("%*sTemplateArgs:", indent+2, "") + for i, a := range cl.TemplateArgs { + args += "\n" + args += a.goString(indent+4, fmt.Sprintf("%d: ", i)) + } + } var types string if len(cl.Types) == 0 { types = fmt.Sprintf("%*sTypes: nil", indent+2, "") @@ -2902,7 +3680,71 @@ func (cl *Closure) goString(indent int, field string) string { types += t.goString(indent+4, fmt.Sprintf("%d: ", i)) } } - return fmt.Sprintf("%*s%sClosure: Num: %d\n%s", indent, "", field, cl.Num, types) + return fmt.Sprintf("%*s%sClosure: Num: %d\n%s\n%s", indent, "", field, + cl.Num, args, types) +} + +// StructuredBindings is a structured binding declaration. +type StructuredBindings struct { + Bindings []AST +} + +func (sb *StructuredBindings) print(ps *printState) { + ps.writeString("[") + for i, b := range sb.Bindings { + if i > 0 { + ps.writeString(", ") + } + b.print(ps) + } + ps.writeString("]") +} + +func (sb *StructuredBindings) Traverse(fn func(AST) bool) { + if fn(sb) { + for _, b := range sb.Bindings { + b.Traverse(fn) + } + } +} + +func (sb *StructuredBindings) Copy(fn func(AST) AST, skip func(AST) bool) AST { + if skip(sb) { + return nil + } + changed := false + bindings := make([]AST, len(sb.Bindings)) + for i, b := range sb.Bindings { + bc := b.Copy(fn, skip) + if bc == nil { + bindings[i] = b + } else { + bindings[i] = bc + changed = true + } + } + if !changed { + return fn(sb) + } + sb = &StructuredBindings{Bindings: bindings} + if r := fn(sb); r != nil { + return r + } + return sb +} + +func (sb *StructuredBindings) GoString() string { + return sb.goString(0, "") +} + +func (sb *StructuredBindings) goString(indent int, field string) string { + var strb strings.Builder + fmt.Fprintf(&strb, "%*s%sStructuredBinding:", indent, "", field) + for _, b := range sb.Bindings { + strb.WriteByte('\n') + strb.WriteString(b.goString(indent+2, "")) + } + return strb.String() } // UnnamedType is an unnamed type, that just has an index. @@ -2911,7 +3753,15 @@ type UnnamedType struct { } func (ut *UnnamedType) print(ps *printState) { - ps.writeString(fmt.Sprintf("{unnamed type#%d}", ut.Num+1)) + if ps.llvmStyle { + if ut.Num == 0 { + ps.writeString("'unnamed'") + } else { + ps.writeString(fmt.Sprintf("'unnamed%d'", ut.Num-1)) + } + } else { + ps.writeString(fmt.Sprintf("{unnamed type#%d}", ut.Num+1)) + } } func (ut *UnnamedType) Traverse(fn func(AST) bool) { @@ -2941,7 +3791,13 @@ type Clone struct { func (c *Clone) print(ps *printState) { ps.print(c.Base) - ps.writeString(fmt.Sprintf(" [clone %s]", c.Suffix)) + if ps.llvmStyle { + ps.writeString(" (") + ps.writeString(c.Suffix) + ps.writeByte(')') + } else { + ps.writeString(fmt.Sprintf(" [clone %s]", c.Suffix)) + } } func (c *Clone) Traverse(fn func(AST) bool) { @@ -2982,7 +3838,16 @@ type Special struct { } func (s *Special) print(ps *printState) { - ps.writeString(s.Prefix) + prefix := s.Prefix + if ps.llvmStyle { + switch prefix { + case "TLS wrapper function for ": + prefix = "thread-local wrapper routine for " + case "TLS init function for ": + prefix = "thread-local initialization routine for " + } + } + ps.writeString(prefix) ps.print(s.Val) } @@ -3194,7 +4059,12 @@ func (ps *printState) printOneInner(save *[]AST) { func (ps *printState) isEmpty(a AST) bool { switch a := a.(type) { case *ArgumentPack: - return len(a.Args) == 0 + for _, a := range a.Args { + if !ps.isEmpty(a) { + return false + } + } + return true case *ExprList: return len(a.Exprs) == 0 case *PackExpansion: diff --git a/src/cmd/vendor/github.com/ianlancetaylor/demangle/demangle.go b/src/cmd/vendor/github.com/ianlancetaylor/demangle/demangle.go index c2667446df..9eec0aa3c8 100644 --- a/src/cmd/vendor/github.com/ianlancetaylor/demangle/demangle.go +++ b/src/cmd/vendor/github.com/ianlancetaylor/demangle/demangle.go @@ -2,9 +2,12 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package demangle defines functions that demangle GCC/LLVM C++ symbol names. +// Package demangle defines functions that demangle GCC/LLVM +// C++ and Rust symbol names. // This package recognizes names that were mangled according to the C++ ABI -// defined at http://codesourcery.com/cxx-abi/. +// defined at http://codesourcery.com/cxx-abi/ and the Rust ABI +// defined at +// https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html // // Most programs will want to call Filter or ToString. package demangle @@ -17,7 +20,7 @@ import ( // ErrNotMangledName is returned by CheckedDemangle if the string does // not appear to be a C++ symbol name. -var ErrNotMangledName = errors.New("not a C++ mangled name") +var ErrNotMangledName = errors.New("not a C++ or Rust mangled name") // Option is the type of demangler options. type Option int @@ -33,11 +36,23 @@ const ( // NoParams implies NoClones. NoClones + // The NoRust option disables demangling of old-style Rust + // mangled names, which can be confused with C++ style mangled + // names. New style Rust mangled names are still recognized. + NoRust + // The Verbose option turns on more verbose demangling. Verbose + + // LLVMStyle tries to translate an AST to a string in the + // style of the LLVM demangler. This does not affect + // the parsing of the AST, only the conversion of the AST + // to a string. + LLVMStyle ) -// Filter demangles a C++ symbol name, returning the human-readable C++ name. +// Filter demangles a C++ or Rust symbol name, +// returning the human-readable C++ or Rust name. // If any error occurs during demangling, the input string is returned. func Filter(name string, options ...Option) string { ret, err := ToString(name, options...) @@ -47,11 +62,34 @@ func Filter(name string, options ...Option) string { return ret } -// ToString demangles a C++ symbol name, returning a human-readable C++ -// name or an error. -// If the name does not appear to be a C++ symbol name at all, the -// error will be ErrNotMangledName. +// ToString demangles a C++ or Rust symbol name, +// returning a human-readable C++ or Rust name or an error. +// If the name does not appear to be a C++ or Rust symbol name at all, +// the error will be ErrNotMangledName. func ToString(name string, options ...Option) (string, error) { + if strings.HasPrefix(name, "_R") { + return rustToString(name, options) + } + + // Check for an old-style Rust mangled name. + // It starts with _ZN and ends with "17h" followed by 16 hex digits + // followed by "E". + if strings.HasPrefix(name, "_ZN") && strings.HasSuffix(name, "E") && len(name) > 23 && name[len(name)-20:len(name)-17] == "17h" { + noRust := false + for _, o := range options { + if o == NoRust { + noRust = true + break + } + } + if !noRust { + s, ok := oldRustToString(name, options) + if ok { + return s, nil + } + } + } + a, err := ToAST(name, options...) if err != nil { return "", err @@ -65,12 +103,37 @@ func ToString(name string, options ...Option) (string, error) { // the parameter types are not demangled. // If the name does not appear to be a C++ symbol name at all, the // error will be ErrNotMangledName. +// This function does not currently support Rust symbol names. func ToAST(name string, options ...Option) (AST, error) { if strings.HasPrefix(name, "_Z") { a, err := doDemangle(name[2:], options...) return a, adjustErr(err, 2) } + if strings.HasPrefix(name, "___Z") { + // clang extensions + block := strings.LastIndex(name, "_block_invoke") + if block == -1 { + return nil, ErrNotMangledName + } + a, err := doDemangle(name[4:block], options...) + if err != nil { + return a, adjustErr(err, 4) + } + name = strings.TrimPrefix(name[block:], "_block_invoke") + if len(name) > 0 && name[0] == '_' { + name = name[1:] + } + for len(name) > 0 && isDigit(name[0]) { + name = name[1:] + } + if len(name) > 0 && name[0] != '.' { + return nil, errors.New("unparsed characters at end of mangled name") + } + a = &Special{Prefix: "invocation function for block in ", Val: a} + return a, nil + } + const prefix = "_GLOBAL_" if strings.HasPrefix(name, prefix) { // The standard demangler ignores NoParams for global @@ -150,12 +213,13 @@ func doDemangle(name string, options ...Option) (ret AST, err error) { case NoParams: params = false clones = false - case NoTemplateParams: - // This is a valid option but only affect printing of the AST. case NoClones: clones = false case Verbose: verbose = true + case NoTemplateParams, LLVMStyle: + // These are valid options but only affect + // printing of the AST. default: return nil, fmt.Errorf("unrecognized demangler option %v", o) } @@ -185,7 +249,16 @@ type state struct { off int // offset of str within original string subs substitutions // substitutions templates []*Template // templates being processed - inLambda int // number of lambdas being parsed + + // The number of entries in templates when we started parsing + // a lambda, plus 1 so that 0 means not parsing a lambda. + lambdaTemplateLevel int + + // Counts of template parameters without template arguments, + // for lambdas. + typeTemplateParamCount int + nonTypeTemplateParamCount int + templateTemplateParamCount int } // copy returns a copy of the current state. @@ -308,35 +381,40 @@ func (st *state) encoding(params bool, local forLocalNameType) AST { return a } - check := a - mwq, _ := check.(*MethodWithQualifiers) - if mwq != nil { - check = mwq.Method + mwq, _ := a.(*MethodWithQualifiers) + + var findTemplate func(AST) *Template + findTemplate = func(check AST) *Template { + switch check := check.(type) { + case *Template: + return check + case *Qualified: + if check.LocalName { + return findTemplate(check.Name) + } else if _, ok := check.Name.(*Constructor); ok { + return findTemplate(check.Name) + } + case *MethodWithQualifiers: + return findTemplate(check.Method) + case *Constructor: + if check.Base != nil { + return findTemplate(check.Base) + } + } + return nil } - var template *Template - switch check := check.(type) { - case *Template: - template = check - case *Qualified: - if check.LocalName { - n := check.Name - if nmwq, ok := n.(*MethodWithQualifiers); ok { - n = nmwq.Method - } - template, _ = n.(*Template) - } - } - var oldInLambda int + template := findTemplate(a) + var oldLambdaTemplateLevel int if template != nil { st.templates = append(st.templates, template) - oldInLambda = st.inLambda - st.inLambda = 0 + oldLambdaTemplateLevel = st.lambdaTemplateLevel + st.lambdaTemplateLevel = 0 } // Checking for the enable_if attribute here is what the LLVM // demangler does. This is not very general but perhaps it is - // sufficent. + // sufficient. const enableIfPrefix = "Ua9enable_ifI" var enableIfArgs []AST if strings.HasPrefix(st.str, enableIfPrefix) { @@ -348,7 +426,7 @@ func (st *state) encoding(params bool, local forLocalNameType) AST { if template != nil { st.templates = st.templates[:len(st.templates)-1] - st.inLambda = oldInLambda + st.lambdaTemplateLevel = oldLambdaTemplateLevel } ft = simplify(ft) @@ -357,7 +435,7 @@ func (st *state) encoding(params bool, local forLocalNameType) AST { // doesn't get confused with the top level return type. if local == forLocalName { if functype, ok := ft.(*FunctionType); ok { - functype.Return = nil + functype.ForLocalName = true } } @@ -573,7 +651,7 @@ func (st *state) prefix() AST { var next AST c := st.str[0] - if isDigit(c) || isLower(c) || c == 'U' || c == 'L' { + if isDigit(c) || isLower(c) || c == 'U' || c == 'L' || (c == 'D' && len(st.str) > 1 && st.str[1] == 'C') { un, isUnCast := st.unqualifiedName() next = un if isUnCast { @@ -595,10 +673,17 @@ func (st *state) prefix() AST { st.fail("constructor before name is seen") } st.advance(1) + var base AST if inheriting { - last = st.demangleType(false) + base = st.demangleType(false) + } + next = &Constructor{ + Name: getLast(last), + Base: base, + } + if len(st.str) > 0 && st.str[0] == 'B' { + next = st.taggedName(next) } - next = &Constructor{Name: getLast(last)} case 'D': if len(st.str) > 1 && (st.str[1] == 'T' || st.str[1] == 't') { next = st.demangleType(false) @@ -611,6 +696,9 @@ func (st *state) prefix() AST { } st.advance(2) next = &Destructor{Name: getLast(last)} + if len(st.str) > 0 && st.str[0] == 'B' { + next = st.taggedName(next) + } } case 'S': next = st.substitution(true) @@ -713,6 +801,18 @@ func (st *state) unqualifiedName() (r AST, isCast bool) { n := st.sourceName() a = &Unary{Op: op, Expr: n, Suffix: false, SizeofType: false} } + } else if c == 'D' && len(st.str) > 1 && st.str[1] == 'C' { + var bindings []AST + st.advance(2) + for { + binding := st.sourceName() + bindings = append(bindings, binding) + if len(st.str) > 0 && st.str[0] == 'E' { + st.advance(1) + break + } + } + a = &StructuredBindings{Bindings: bindings} } else { switch c { case 'C', 'D': @@ -728,6 +828,10 @@ func (st *state) unqualifiedName() (r AST, isCast bool) { } c := st.str[1] switch c { + case 'b': + st.advance(2) + st.compactNumber() + a = &Name{Name: "'block-literal'"} case 'l': a = st.closureTypeName() case 't': @@ -802,6 +906,42 @@ func (st *state) number() int { return val } +// ::= <0-9A-Z>+ +// +// We expect this to be followed by an underscore. +func (st *state) seqID(eofOK bool) int { + if len(st.str) > 0 && st.str[0] == '_' { + st.advance(1) + return 0 + } + id := 0 + for { + if len(st.str) == 0 { + if eofOK { + return id + 1 + } + st.fail("missing end to sequence ID") + } + // Don't overflow a 32-bit int. + if id >= 0x80000000/36-36 { + st.fail("sequence ID overflow") + } + c := st.str[0] + if c == '_' { + st.advance(1) + return id + 1 + } + if isDigit(c) { + id = id*36 + int(c-'0') + } else if isUpper(c) { + id = id*36 + int(c-'A') + 10 + } else { + st.fail("invalid character in sequence ID") + } + st.advance(1) + } +} + // An operator is the demangled name, and the number of arguments it // takes in an expression. type operator struct { @@ -864,6 +1004,7 @@ var operators = map[string]operator{ "ng": {"-", 1}, "nt": {"!", 1}, "nw": {"new", 3}, + "nx": {"noexcept", 1}, "oR": {"|=", 2}, "oo": {"||", 2}, "or": {"|", 2}, @@ -1094,8 +1235,8 @@ func (st *state) specialName() AST { return &Special{Prefix: "guard variable for ", Val: n} case 'R': n := st.name() - i := st.number() - return &Special{Prefix: fmt.Sprintf("reference temporary #%d for ", i), Val: n} + st.seqID(true) + return &Special{Prefix: "reference temporary for ", Val: n} case 'A': v := st.encoding(true, notForLocalName) return &Special{Prefix: "hidden alias for ", Val: v} @@ -1257,6 +1398,23 @@ func (st *state) demangleType(isCast bool) AST { case 'M': ret = st.pointerToMemberType(isCast) case 'T': + if len(st.str) > 1 && (st.str[1] == 's' || st.str[1] == 'u' || st.str[1] == 'e') { + c = st.str[1] + st.advance(2) + ret = st.name() + var kind string + switch c { + case 's': + kind = "struct" + case 'u': + kind = "union" + case 'e': + kind = "enum" + } + ret = &ElaboratedType{Kind: kind, Type: ret} + break + } + ret = st.templateParam() if len(st.str) > 0 && st.str[0] == 'I' { // See the function comment to explain this. @@ -1681,7 +1839,11 @@ func (st *state) bareFunctionType(hasReturnType bool) AST { returnType = st.demangleType(false) } types := st.parmlist() - return &FunctionType{Return: returnType, Args: types} + return &FunctionType{ + Return: returnType, + Args: types, + ForLocalName: false, // may be set later in encoding + } } // ::= A <(positive dimension) number> _ <(element) type> @@ -1798,6 +1960,8 @@ func (st *state) compactNumber() int { // ::= T_ // ::= T <(parameter-2 non-negative) number> _ +// ::= TL __ +// ::= TL _ _ // // When a template parameter is a substitution candidate, any // reference to that substitution refers to the template parameter @@ -1805,22 +1969,27 @@ func (st *state) compactNumber() int { // whatever the template parameter would be expanded to here. We sort // this out in substitution and simplify. func (st *state) templateParam() AST { - if len(st.templates) == 0 && st.inLambda == 0 { - st.fail("template parameter not in scope of template") - } off := st.off - st.checkChar('T') + + level := 0 + if len(st.str) > 0 && st.str[0] == 'L' { + st.advance(1) + level = st.compactNumber() + } + n := st.compactNumber() - if st.inLambda > 0 { - // g++ mangles lambda auto params as template params. - // Apparently we can't encounter a template within a lambda. - // See https://gcc.gnu.org/PR78252. - return &LambdaAuto{Index: n} + if level >= len(st.templates) { + if st.lambdaTemplateLevel > 0 && level == st.lambdaTemplateLevel-1 { + // Lambda auto params are mangled as template params. + // See https://gcc.gnu.org/PR78252. + return &LambdaAuto{Index: n} + } + st.failEarlier(fmt.Sprintf("template parameter is not in scope of template (level %d >= %d)", level, len(st.templates)), st.off-off) } - template := st.templates[len(st.templates)-1] + template := st.templates[level] if template == nil { // We are parsing a cast operator. If the cast is @@ -1830,6 +1999,11 @@ func (st *state) templateParam() AST { } if n >= len(template.Args) { + if st.lambdaTemplateLevel > 0 && level == st.lambdaTemplateLevel-1 { + // Lambda auto params are mangled as template params. + // See https://gcc.gnu.org/PR78252. + return &LambdaAuto{Index: n} + } st.failEarlier(fmt.Sprintf("template index out of range (%d >= %d)", n, len(template.Args)), st.off-off) } @@ -1968,9 +2142,11 @@ func (st *state) exprList(stop byte) AST { // ::= dc // ::= sc // ::= cc +// ::= mc [] E // ::= rc // ::= ti // ::= te +// ::= so [] * [p] E // ::= st // ::= sz // ::= at @@ -1991,6 +2167,7 @@ func (st *state) exprList(stop byte) AST { // ::= fR // ::= tw // ::= tr +// ::= u * E // ::= // ::= // @@ -2013,6 +2190,9 @@ func (st *state) expression() AST { return st.exprPrimary() } else if st.str[0] == 'T' { return st.templateParam() + } else if st.str[0] == 's' && len(st.str) > 1 && st.str[1] == 'o' { + st.advance(2) + return st.subobject() } else if st.str[0] == 's' && len(st.str) > 1 && st.str[1] == 'r' { return st.unresolvedName() } else if st.str[0] == 's' && len(st.str) > 1 && st.str[1] == 'p' { @@ -2063,6 +2243,23 @@ func (st *state) expression() AST { st.cvQualifiers() index := st.compactNumber() return &FunctionParam{Index: index + 1} + } else if st.str[0] == 'm' && len(st.str) > 1 && st.str[1] == 'c' { + st.advance(2) + typ := st.demangleType(false) + expr := st.expression() + offset := 0 + if len(st.str) > 0 && (st.str[0] == 'n' || isDigit(st.str[0])) { + offset = st.number() + } + if len(st.str) == 0 || st.str[0] != 'E' { + st.fail("expected E after pointer-to-member conversion") + } + st.advance(1) + return &PtrMemCast{ + Type: typ, + Expr: expr, + Offset: offset, + } } else if isDigit(st.str[0]) || (st.str[0] == 'o' && len(st.str) > 1 && st.str[1] == 'n') { if st.str[0] == 'o' { // Skip operator function ID. @@ -2088,6 +2285,50 @@ func (st *state) expression() AST { o, _ := st.operatorName(true) t := st.demangleType(false) return &Unary{Op: o, Expr: t, Suffix: false, SizeofType: true} + } else if st.str[0] == 'u' { + st.advance(1) + name := st.sourceName() + // Special case __uuidof followed by type or + // expression, as used by LLVM. + if n, ok := name.(*Name); ok && n.Name == "__uuidof" { + if len(st.str) < 2 { + st.fail("missing uuidof argument") + } + var operand AST + if st.str[0] == 't' { + st.advance(1) + operand = st.demangleType(false) + } else if st.str[0] == 'z' { + st.advance(1) + operand = st.expression() + } + if operand != nil { + return &Binary{ + Op: &Operator{Name: "()"}, + Left: name, + Right: &ExprList{ + Exprs: []AST{operand}, + }, + } + } + } + var args []AST + for { + if len(st.str) == 0 { + st.fail("missing argument in vendor extended expressoin") + } + if st.str[0] == 'E' { + st.advance(1) + break + } + arg := st.templateArg() + args = append(args, arg) + } + return &Binary{ + Op: &Operator{Name: "()"}, + Left: name, + Right: &ExprList{Exprs: args}, + } } else { if len(st.str) < 2 { st.fail("missing operator code") @@ -2185,6 +2426,42 @@ func (st *state) expression() AST { } } +// ::= so [] * [p] E +// ::= _ [] +func (st *state) subobject() AST { + typ := st.demangleType(false) + expr := st.expression() + offset := 0 + if len(st.str) > 0 && (st.str[0] == 'n' || isDigit(st.str[0])) { + offset = st.number() + } + var selectors []int + for len(st.str) > 0 && st.str[0] == '_' { + st.advance(1) + selector := 0 + if len(st.str) > 0 && (st.str[0] == 'n' || isDigit(st.str[0])) { + selector = st.number() + } + selectors = append(selectors, selector) + } + pastEnd := false + if len(st.str) > 0 && st.str[0] == 'p' { + st.advance(1) + pastEnd = true + } + if len(st.str) == 0 || st.str[0] != 'E' { + st.fail("expected E after subobject") + } + st.advance(1) + return &Subobject{ + Type: typ, + SubExpr: expr, + Offset: offset, + Selectors: selectors, + PastEnd: pastEnd, + } +} + // ::= [gs] // ::= sr // ::= srN + E @@ -2320,6 +2597,14 @@ func (st *state) exprPrimary() AST { } else { t := st.demangleType(false) + isArrayType := func(typ AST) bool { + if twq, ok := typ.(*TypeWithQualifiers); ok { + typ = twq.Base + } + _, ok := typ.(*ArrayType) + return ok + } + neg := false if len(st.str) > 0 && st.str[0] == 'n' { neg = true @@ -2331,6 +2616,13 @@ func (st *state) exprPrimary() AST { // We accept one if present because GCC // used to generate one. // https://gcc.gnu.org/PR91979. + } else if cl, ok := t.(*Closure); ok { + // A closure doesn't have a value. + st.advance(1) + return &LambdaExpr{Type: cl} + } else if isArrayType(t) { + st.advance(1) + return &StringLiteral{Type: t} } else { st.fail("missing literal value") } @@ -2354,6 +2646,15 @@ func (st *state) exprPrimary() AST { // __ <(non-negative) number> _ (when number >= 10) func (st *state) discriminator(a AST) AST { if len(st.str) == 0 || st.str[0] != '_' { + // clang can generate a discriminator at the end of + // the string with no underscore. + for i := 0; i < len(st.str); i++ { + if !isDigit(st.str[i]) { + return a + } + } + // Skip the trailing digits. + st.advance(len(st.str)) return a } off := st.off @@ -2379,18 +2680,131 @@ func (st *state) discriminator(a AST) AST { } // ::= Ul E [ ] _ +// ::= + func (st *state) closureTypeName() AST { st.checkChar('U') st.checkChar('l') - st.inLambda++ + + oldLambdaTemplateLevel := st.lambdaTemplateLevel + st.lambdaTemplateLevel = len(st.templates) + 1 + + var templateArgs []AST + var template *Template + for len(st.str) > 1 && st.str[0] == 'T' { + arg, templateVal := st.templateParamDecl() + if arg == nil { + break + } + templateArgs = append(templateArgs, arg) + if template == nil { + template = &Template{ + Name: &Name{Name: "lambda"}, + } + st.templates = append(st.templates, template) + } + template.Args = append(template.Args, templateVal) + } + types := st.parmlist() - st.inLambda-- + + st.lambdaTemplateLevel = oldLambdaTemplateLevel + + if template != nil { + st.templates = st.templates[:len(st.templates)-1] + } + if len(st.str) == 0 || st.str[0] != 'E' { st.fail("expected E after closure type name") } st.advance(1) num := st.compactNumber() - return &Closure{Types: types, Num: num} + return &Closure{TemplateArgs: templateArgs, Types: types, Num: num} +} + +// ::= Ty # type parameter +// ::= Tn # non-type parameter +// ::= Tt * E # template parameter +// ::= Tp # parameter pack +// +// Returns the new AST to include in the AST we are building and the +// new AST to add to the list of template parameters. +// +// Returns nil, nil if not looking at a template-param-decl. +func (st *state) templateParamDecl() (AST, AST) { + if len(st.str) < 2 || st.str[0] != 'T' { + return nil, nil + } + mk := func(prefix string, p *int) AST { + idx := *p + (*p)++ + return &TemplateParamName{ + Prefix: prefix, + Index: idx, + } + } + switch st.str[1] { + case 'y': + st.advance(2) + name := mk("$T", &st.typeTemplateParamCount) + tp := &TypeTemplateParam{ + Name: name, + } + return tp, name + case 'n': + st.advance(2) + name := mk("$N", &st.nonTypeTemplateParamCount) + typ := st.demangleType(false) + tp := &NonTypeTemplateParam{ + Name: name, + Type: typ, + } + return tp, name + case 't': + st.advance(2) + name := mk("$TT", &st.templateTemplateParamCount) + var params []AST + var template *Template + for { + if len(st.str) == 0 { + st.fail("expected closure template parameter") + } + if st.str[0] == 'E' { + st.advance(1) + break + } + off := st.off + param, templateVal := st.templateParamDecl() + if param == nil { + st.failEarlier("expected closure template parameter", st.off-off) + } + params = append(params, param) + if template == nil { + template = &Template{ + Name: &Name{Name: "template_template"}, + } + st.templates = append(st.templates, template) + } + template.Args = append(template.Args, templateVal) + } + if template != nil { + st.templates = st.templates[:len(st.templates)-1] + } + tp := &TemplateTemplateParam{ + Name: name, + Params: params, + } + return tp, name + case 'p': + st.advance(2) + off := st.off + param, templateVal := st.templateParamDecl() + if param == nil { + st.failEarlier("expected lambda template parameter", st.off-off) + } + return &TemplateParamPack{Param: param}, templateVal + default: + return nil, nil + } } // ::= Ut [ ] _ @@ -2504,36 +2918,11 @@ func (st *state) substitution(forPrefix bool) AST { st.fail("missing substitution index") } c := st.str[0] - st.advance(1) - dec := 1 + off := st.off if c == '_' || isDigit(c) || isUpper(c) { - id := 0 - if c != '_' { - for c != '_' { - // Don't overflow a 32-bit int. - if id >= 0x80000000/36-36 { - st.fail("substitution index overflow") - } - if isDigit(c) { - id = id*36 + int(c-'0') - } else if isUpper(c) { - id = id*36 + int(c-'A') + 10 - } else { - st.fail("invalid character in substitution index") - } - - if len(st.str) == 0 { - st.fail("missing end to substitution index") - } - c = st.str[0] - st.advance(1) - dec++ - } - id++ - } - + id := st.seqID(false) if id >= len(st.subs) { - st.failEarlier(fmt.Sprintf("substitution index out of range (%d >= %d)", id, len(st.subs)), dec) + st.failEarlier(fmt.Sprintf("substitution index out of range (%d >= %d)", id, len(st.subs)), st.off-off) } ret := st.subs[id] @@ -2545,18 +2934,18 @@ func (st *state) substitution(forPrefix bool) AST { // When copying a Typed we may need to adjust // the templates. copyTemplates := st.templates - var oldInLambda []int + var oldLambdaTemplateLevel []int // pushTemplate is called from skip, popTemplate from copy. pushTemplate := func(template *Template) { copyTemplates = append(copyTemplates, template) - oldInLambda = append(oldInLambda, st.inLambda) - st.inLambda = 0 + oldLambdaTemplateLevel = append(oldLambdaTemplateLevel, st.lambdaTemplateLevel) + st.lambdaTemplateLevel = 0 } popTemplate := func() { copyTemplates = copyTemplates[:len(copyTemplates)-1] - st.inLambda = oldInLambda[len(oldInLambda)-1] - oldInLambda = oldInLambda[:len(oldInLambda)-1] + st.lambdaTemplateLevel = oldLambdaTemplateLevel[len(oldLambdaTemplateLevel)-1] + oldLambdaTemplateLevel = oldLambdaTemplateLevel[:len(oldLambdaTemplateLevel)-1] } copy := func(a AST) AST { @@ -2569,8 +2958,9 @@ func (st *state) substitution(forPrefix bool) AST { } return nil case *Closure: - // Undo the decrement in skip. - st.inLambda-- + // Undo the save in skip. + st.lambdaTemplateLevel = oldLambdaTemplateLevel[len(oldLambdaTemplateLevel)-1] + oldLambdaTemplateLevel = oldLambdaTemplateLevel[:len(oldLambdaTemplateLevel)-1] return nil case *TemplateParam: index = a.Index @@ -2582,7 +2972,7 @@ func (st *state) substitution(forPrefix bool) AST { default: return nil } - if st.inLambda > 0 { + if st.lambdaTemplateLevel > 0 { if _, ok := a.(*LambdaAuto); ok { return nil } @@ -2598,7 +2988,7 @@ func (st *state) substitution(forPrefix bool) AST { // here. template = rt } else { - st.failEarlier("substituted template parameter not in scope of template", dec) + st.failEarlier("substituted template parameter not in scope of template", st.off-off) } if template == nil { // This template parameter is within @@ -2607,7 +2997,7 @@ func (st *state) substitution(forPrefix bool) AST { } if index >= len(template.Args) { - st.failEarlier(fmt.Sprintf("substituted template index out of range (%d >= %d)", index, len(template.Args)), dec) + st.failEarlier(fmt.Sprintf("substituted template index out of range (%d >= %d)", index, len(template.Args)), st.off-off) } return &TemplateParam{Index: index, Template: template} @@ -2622,8 +3012,9 @@ func (st *state) substitution(forPrefix bool) AST { } return false case *Closure: - // This is decremented in copy. - st.inLambda++ + // This is undone in copy. + oldLambdaTemplateLevel = append(oldLambdaTemplateLevel, st.lambdaTemplateLevel) + st.lambdaTemplateLevel = len(copyTemplates) + 1 return false case *TemplateParam, *LambdaAuto: return false @@ -2643,6 +3034,7 @@ func (st *state) substitution(forPrefix bool) AST { return ret } else { + st.advance(1) m := subAST if st.verbose { m = verboseAST diff --git a/src/cmd/vendor/github.com/ianlancetaylor/demangle/rust.go b/src/cmd/vendor/github.com/ianlancetaylor/demangle/rust.go new file mode 100644 index 0000000000..140b631644 --- /dev/null +++ b/src/cmd/vendor/github.com/ianlancetaylor/demangle/rust.go @@ -0,0 +1,1069 @@ +// Copyright 2021 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 demangle + +import ( + "fmt" + "math" + "math/bits" + "strings" + "unicode/utf8" +) + +// rustToString demangles a Rust symbol. +func rustToString(name string, options []Option) (ret string, err error) { + if !strings.HasPrefix(name, "_R") { + return "", ErrNotMangledName + } + + // When the demangling routines encounter an error, they panic + // with a value of type demangleErr. + defer func() { + if r := recover(); r != nil { + if de, ok := r.(demangleErr); ok { + ret = "" + err = de + return + } + panic(r) + } + }() + + suffix := "" + dot := strings.Index(name, ".") + if dot >= 0 { + suffix = name[dot:] + name = name[:dot] + } + + name = name[2:] + rst := &rustState{orig: name, str: name} + rst.symbolName() + + if len(rst.str) > 0 { + rst.fail("unparsed characters at end of mangled name") + } + + if suffix != "" { + rst.skip = false + rst.writeString(" (") + rst.writeString(suffix) + rst.writeByte(')') + } + + return rst.buf.String(), nil +} + +// A rustState holds the current state of demangling a Rust string. +type rustState struct { + orig string // the original string being demangled + str string // remainder of string to demangle + off int // offset of str within original string + buf strings.Builder // demangled string being built + skip bool // don't print, just skip + lifetimes int64 // number of bound lifetimes + last byte // last byte written to buffer +} + +// fail panics with demangleErr, to be caught in rustToString. +func (rst *rustState) fail(err string) { + panic(demangleErr{err: err, off: rst.off}) +} + +// advance advances the current string offset. +func (rst *rustState) advance(add int) { + if len(rst.str) < add { + panic("internal error") + } + rst.str = rst.str[add:] + rst.off += add +} + +// checkChar requires that the next character in the string be c, +// and advances past it. +func (rst *rustState) checkChar(c byte) { + if len(rst.str) == 0 || rst.str[0] != c { + rst.fail("expected " + string(c)) + } + rst.advance(1) +} + +// writeByte writes a byte to the buffer. +func (rst *rustState) writeByte(c byte) { + if rst.skip { + return + } + rst.last = c + rst.buf.WriteByte(c) +} + +// writeString writes a string to the buffer. +func (rst *rustState) writeString(s string) { + if rst.skip { + return + } + if len(s) > 0 { + rst.last = s[len(s)-1] + rst.buf.WriteString(s) + } +} + +// = "_R" [] [] +// = +// +// We've already skipped the "_R". +func (rst *rustState) symbolName() { + if len(rst.str) < 1 { + rst.fail("expected symbol-name") + } + + if isDigit(rst.str[0]) { + rst.fail("unsupported Rust encoding version") + } + + rst.path(true) + + if len(rst.str) > 0 { + rst.skip = true + rst.path(false) + } +} + +// = "C" // crate root +// | "M" // (inherent impl) +// | "X" // (trait impl) +// | "Y" // (trait definition) +// | "N" // ...::ident (nested path) +// | "I" {} "E" // ... (generic args) +// | +// = "C" // closure +// | "S" // shim +// | // other special namespaces +// | // internal namespaces +// +// needsSeparator is true if we need to write out :: for a generic; +// it is passed as false if we are in the middle of a type. +func (rst *rustState) path(needsSeparator bool) { + if len(rst.str) < 1 { + rst.fail("expected path") + } + switch c := rst.str[0]; c { + case 'C': + rst.advance(1) + _, ident := rst.identifier() + rst.writeString(ident) + case 'M', 'X': + rst.advance(1) + rst.implPath() + rst.writeByte('<') + rst.demangleType() + if c == 'X' { + rst.writeString(" as ") + rst.path(false) + } + rst.writeByte('>') + case 'Y': + rst.advance(1) + rst.writeByte('<') + rst.demangleType() + rst.writeString(" as ") + rst.path(false) + rst.writeByte('>') + case 'N': + rst.advance(1) + + if len(rst.str) < 1 { + rst.fail("expected namespace") + } + ns := rst.str[0] + switch { + case ns >= 'a' && ns <= 'z': + case ns >= 'A' && ns <= 'Z': + default: + rst.fail("invalid namespace character") + } + rst.advance(1) + + rst.path(needsSeparator) + + dis, ident := rst.identifier() + + if ns >= 'A' && ns <= 'Z' { + rst.writeString("::{") + switch ns { + case 'C': + rst.writeString("closure") + case 'S': + rst.writeString("shim") + default: + rst.writeByte(ns) + } + if len(ident) > 0 { + rst.writeByte(':') + rst.writeString(ident) + } + if !rst.skip { + fmt.Fprintf(&rst.buf, "#%d}", dis) + rst.last = '}' + } + } else { + rst.writeString("::") + rst.writeString(ident) + } + case 'I': + rst.advance(1) + rst.path(needsSeparator) + if needsSeparator { + rst.writeString("::") + } + rst.writeByte('<') + first := true + for len(rst.str) > 0 && rst.str[0] != 'E' { + if first { + first = false + } else { + rst.writeString(", ") + } + rst.genericArg() + } + rst.writeByte('>') + rst.checkChar('E') + case 'B': + rst.backref(func() { rst.path(needsSeparator) }) + default: + rst.fail("unrecognized letter in path") + } +} + +// = [] +func (rst *rustState) implPath() { + // This path is not part of the demangled string. + hold := rst.skip + rst.skip = true + defer func() { + rst.skip = hold + }() + + rst.disambiguator() + rst.path(false) +} + +// = [] +// Returns the disambiguator and the identifier. +func (rst *rustState) identifier() (int64, string) { + dis := rst.disambiguator() + ident := rst.undisambiguatedIdentifier() + return dis, ident +} + +// = "s" +// This is optional. +func (rst *rustState) disambiguator() int64 { + if len(rst.str) == 0 || rst.str[0] != 's' { + return 0 + } + rst.advance(1) + return rst.base62Number() + 1 +} + +// = ["u"] ["_"] +func (rst *rustState) undisambiguatedIdentifier() string { + punycode := false + if len(rst.str) > 0 && rst.str[0] == 'u' { + rst.advance(1) + punycode = true + } + + val := rst.decimalNumber() + + if len(rst.str) > 0 && rst.str[0] == '_' { + rst.advance(1) + } + + if len(rst.str) < val { + rst.fail("not enough characters for identifier") + } + id := rst.str[:val] + rst.advance(val) + + for i := 0; i < len(id); i++ { + c := id[i] + switch { + case c >= '0' && c <= '9': + case c >= 'A' && c <= 'Z': + case c >= 'a' && c <= 'z': + case c == '_': + default: + rst.fail("invalid character in identifier") + } + } + + if punycode { + id = rst.expandPunycode(id) + } + + return id +} + +// expandPunycode decodes the Rust version of punycode. +// This algorithm is taken from RFC 3492 section 6.2. +func (rst *rustState) expandPunycode(s string) string { + const ( + base = 36 + tmin = 1 + tmax = 26 + skew = 38 + damp = 700 + initialBias = 72 + initialN = 128 + ) + + idx := strings.LastIndex(s, "_") + if idx < 0 { + rst.fail("missing underscore in punycode string") + } + + output := []rune(s[:idx]) + encoding := s[idx+1:] + + i := 0 + n := initialN + bias := initialBias + + pos := 0 + for pos < len(encoding) { + oldI := i + w := 1 + for k := base; ; k += base { + if pos == len(encoding) { + rst.fail("unterminated punycode") + } + + var digit byte + d := encoding[pos] + pos++ + switch { + case '0' <= d && d <= '9': + digit = d - '0' + 26 + case 'A' <= d && d <= 'Z': + digit = d - 'A' + case 'a' <= d && d <= 'z': + digit = d - 'a' + default: + rst.fail("invalid punycode digit") + } + + i += int(digit) * w + if i < 0 { + rst.fail("punycode number overflow") + } + + var t int + if k <= bias { + t = tmin + } else if k > bias+tmax { + t = tmax + } else { + t = k - bias + } + + if int(digit) < t { + break + } + + if w >= math.MaxInt32/base { + rst.fail("punycode number overflow") + } + w *= base - t + } + + delta := i - oldI + numPoints := len(output) + 1 + firstTime := oldI == 0 + if firstTime { + delta /= damp + } else { + delta /= 2 + } + delta += delta / numPoints + k := 0 + for delta > ((base-tmin)*tmax)/2 { + delta /= base - tmin + k += base + } + bias = k + ((base-tmin+1)*delta)/(delta+skew) + + n += i / (len(output) + 1) + if n > utf8.MaxRune { + rst.fail("punycode rune overflow") + } + i %= len(output) + 1 + output = append(output, 0) + copy(output[i+1:], output[i:]) + output[i] = rune(n) + i++ + } + + return string(output) +} + +// = +// | +// | "K" // forward-compat for const generics +// = "L" +func (rst *rustState) genericArg() { + if len(rst.str) < 1 { + rst.fail("expected generic-arg") + } + if rst.str[0] == 'L' { + rst.advance(1) + rst.writeLifetime(rst.base62Number()) + } else if rst.str[0] == 'K' { + rst.advance(1) + rst.demangleConst() + } else { + rst.demangleType() + } +} + +// = "G" +// This is optional. +func (rst *rustState) binder() { + if len(rst.str) < 1 || rst.str[0] != 'G' { + return + } + rst.advance(1) + + binderLifetimes := rst.base62Number() + 1 + + // Every bound lifetime should be referenced later. + if binderLifetimes >= int64(len(rst.str))-rst.lifetimes { + rst.fail("binder lifetimes overflow") + } + + rst.writeString("for<") + for i := int64(0); i < binderLifetimes; i++ { + if i > 0 { + rst.writeString(", ") + } + rst.lifetimes++ + rst.writeLifetime(1) + } + rst.writeString("> ") +} + +// = +// | // named type +// | "A" // [T; N] +// | "S" // [T] +// | "T" {} "E" // (T1, T2, T3, ...) +// | "R" [] // &T +// | "Q" [] // &mut T +// | "P" // *const T +// | "O" // *mut T +// | "F" // fn(...) -> ... +// | "D" // dyn Trait + Send + 'a +// | +func (rst *rustState) demangleType() { + if len(rst.str) < 1 { + rst.fail("expected type") + } + c := rst.str[0] + if c >= 'a' && c <= 'z' { + rst.basicType() + return + } + switch c { + case 'C', 'M', 'X', 'Y', 'N', 'I': + rst.path(false) + case 'A', 'S': + rst.advance(1) + rst.writeByte('[') + rst.demangleType() + if c == 'A' { + rst.writeString("; ") + rst.demangleConst() + } + rst.writeByte(']') + case 'T': + rst.advance(1) + rst.writeByte('(') + c := 0 + for len(rst.str) > 0 && rst.str[0] != 'E' { + if c > 0 { + rst.writeString(", ") + } + c++ + rst.demangleType() + } + if c == 1 { + rst.writeByte(',') + } + rst.writeByte(')') + rst.checkChar('E') + case 'R', 'Q': + rst.advance(1) + rst.writeByte('&') + if len(rst.str) > 0 && rst.str[0] == 'L' { + rst.advance(1) + if lifetime := rst.base62Number(); lifetime > 0 { + rst.writeLifetime(lifetime) + rst.writeByte(' ') + } + } + if c == 'Q' { + rst.writeString("mut ") + } + rst.demangleType() + case 'P': + rst.advance(1) + rst.writeString("*const ") + rst.demangleType() + case 'O': + rst.advance(1) + rst.writeString("*mut ") + rst.demangleType() + case 'F': + rst.advance(1) + hold := rst.lifetimes + rst.fnSig() + rst.lifetimes = hold + case 'D': + rst.advance(1) + hold := rst.lifetimes + rst.dynBounds() + rst.lifetimes = hold + if len(rst.str) == 0 || rst.str[0] != 'L' { + rst.fail("expected L") + } + rst.advance(1) + if lifetime := rst.base62Number(); lifetime > 0 { + if rst.last != ' ' { + rst.writeByte(' ') + } + rst.writeString("+ ") + rst.writeLifetime(lifetime) + } + case 'B': + rst.backref(rst.demangleType) + default: + rst.fail("unrecognized character in type") + } +} + +var rustBasicTypes = map[byte]string{ + 'a': "i8", + 'b': "bool", + 'c': "char", + 'd': "f64", + 'e': "str", + 'f': "f32", + 'h': "u8", + 'i': "isize", + 'j': "usize", + 'l': "i32", + 'm': "u32", + 'n': "i128", + 'o': "u128", + 'p': "_", + 's': "i16", + 't': "u16", + 'u': "()", + 'v': "...", + 'x': "i64", + 'y': "u64", + 'z': "!", +} + +// +func (rst *rustState) basicType() { + if len(rst.str) < 1 { + rst.fail("expected basic type") + } + str, ok := rustBasicTypes[rst.str[0]] + if !ok { + rst.fail("unrecognized basic type character") + } + rst.advance(1) + rst.writeString(str) +} + +// = [] ["U"] ["K" ] {} "E" +// = "C" +// | +func (rst *rustState) fnSig() { + rst.binder() + if len(rst.str) > 0 && rst.str[0] == 'U' { + rst.advance(1) + rst.writeString("unsafe ") + } + if len(rst.str) > 0 && rst.str[0] == 'K' { + rst.advance(1) + if len(rst.str) > 0 && rst.str[0] == 'C' { + rst.advance(1) + rst.writeString(`extern "C" `) + } else { + rst.writeString(`extern "`) + id := rst.undisambiguatedIdentifier() + id = strings.ReplaceAll(id, "_", "-") + rst.writeString(id) + rst.writeString(`" `) + } + } + rst.writeString("fn(") + first := true + for len(rst.str) > 0 && rst.str[0] != 'E' { + if first { + first = false + } else { + rst.writeString(", ") + } + rst.demangleType() + } + rst.checkChar('E') + rst.writeByte(')') + if len(rst.str) > 0 && rst.str[0] == 'u' { + rst.advance(1) + } else { + rst.writeString(" -> ") + rst.demangleType() + } +} + +// = [] {} "E" +func (rst *rustState) dynBounds() { + rst.writeString("dyn ") + rst.binder() + first := true + for len(rst.str) > 0 && rst.str[0] != 'E' { + if first { + first = false + } else { + rst.writeString(" + ") + } + rst.dynTrait() + } + rst.checkChar('E') +} + +// = {} +// = "p" +func (rst *rustState) dynTrait() { + started := rst.pathStartGenerics() + for len(rst.str) > 0 && rst.str[0] == 'p' { + rst.advance(1) + if started { + rst.writeString(", ") + } else { + rst.writeByte('<') + started = true + } + rst.writeString(rst.undisambiguatedIdentifier()) + rst.writeString(" = ") + rst.demangleType() + } + if started { + rst.writeByte('>') + } +} + +// pathStartGenerics is like path but if it sees an I to start generic +// arguments it won't close them. It reports whether it started generics. +func (rst *rustState) pathStartGenerics() bool { + if len(rst.str) < 1 { + rst.fail("expected path") + } + switch rst.str[0] { + case 'I': + rst.advance(1) + rst.path(false) + rst.writeByte('<') + first := true + for len(rst.str) > 0 && rst.str[0] != 'E' { + if first { + first = false + } else { + rst.writeString(", ") + } + rst.genericArg() + } + rst.checkChar('E') + return true + case 'B': + var started bool + rst.backref(func() { started = rst.pathStartGenerics() }) + return started + default: + rst.path(false) + return false + } +} + +// writeLifetime writes out a lifetime binding. +func (rst *rustState) writeLifetime(lifetime int64) { + rst.writeByte('\'') + if lifetime == 0 { + rst.writeByte('_') + return + } + depth := rst.lifetimes - lifetime + if depth < 0 { + rst.fail("invalid lifetime") + } else if depth < 26 { + rst.writeByte('a' + byte(depth)) + } else { + rst.writeByte('z') + if !rst.skip { + fmt.Fprintf(&rst.buf, "%d", depth-26+1) + rst.last = '0' + } + } +} + +// = +// | "p" // placeholder, shown as _ +// | +// = ["n"] {} "_" +func (rst *rustState) demangleConst() { + if len(rst.str) < 1 { + rst.fail("expected constant") + } + + if rst.str[0] == 'B' { + rst.backref(rst.demangleConst) + return + } + + if rst.str[0] == 'p' { + rst.advance(1) + rst.writeByte('_') + return + } + + typ := rst.str[0] + + const ( + invalid = iota + signedInt + unsignedInt + boolean + character + ) + + var kind int + switch typ { + case 'a', 's', 'l', 'x', 'n', 'i': + kind = signedInt + case 'h', 't', 'm', 'y', 'o', 'j': + kind = unsignedInt + case 'b': + kind = boolean + case 'c': + kind = character + default: + rst.fail("unrecognized constant type") + } + + rst.advance(1) + + if kind == signedInt && len(rst.str) > 0 && rst.str[0] == 'n' { + rst.advance(1) + rst.writeByte('-') + } + + start := rst.str + digits := 0 + val := uint64(0) +digitLoop: + for len(rst.str) > 0 { + c := rst.str[0] + var digit uint64 + switch { + case c >= '0' && c <= '9': + digit = uint64(c - '0') + case c >= 'a' && c <= 'f': + digit = uint64(c - 'a' + 10) + case c == '_': + rst.advance(1) + break digitLoop + default: + rst.fail("expected hex digit or _") + } + rst.advance(1) + if val == 0 && digit == 0 && (len(rst.str) == 0 || rst.str[0] != '_') { + rst.fail("invalid leading 0 in constant") + } + val *= 16 + val += digit + digits++ + } + + if digits == 0 { + rst.fail("expected constant") + } + + switch kind { + case signedInt, unsignedInt: + if digits > 16 { + // Value too big, just write out the string. + rst.writeString("0x") + rst.writeString(start[:digits]) + } else { + if !rst.skip { + fmt.Fprintf(&rst.buf, "%d", val) + rst.last = '0' + } + } + case boolean: + if digits > 1 { + rst.fail("boolean value too large") + } else if val == 0 { + rst.writeString("false") + } else if val == 1 { + rst.writeString("true") + } else { + rst.fail("invalid boolean value") + } + case character: + if digits > 6 { + rst.fail("character value too large") + } + rst.writeByte('\'') + if val == '\t' { + rst.writeString(`\t`) + } else if val == '\r' { + rst.writeString(`\r`) + } else if val == '\n' { + rst.writeString(`\n`) + } else if val == '\\' { + rst.writeString(`\\`) + } else if val == '\'' { + rst.writeString(`\'`) + } else if val >= ' ' && val <= '~' { + // printable ASCII character + rst.writeByte(byte(val)) + } else { + if !rst.skip { + fmt.Fprintf(&rst.buf, `\u{%x}`, val) + rst.last = '}' + } + } + rst.writeByte('\'') + default: + panic("internal error") + } +} + +// = {<0-9a-zA-Z>} "_" +func (rst *rustState) base62Number() int64 { + if len(rst.str) > 0 && rst.str[0] == '_' { + rst.advance(1) + return 0 + } + val := int64(0) + for len(rst.str) > 0 { + c := rst.str[0] + rst.advance(1) + if c == '_' { + return val + 1 + } + val *= 62 + if c >= '0' && c <= '9' { + val += int64(c - '0') + } else if c >= 'a' && c <= 'z' { + val += int64(c - 'a' + 10) + } else if c >= 'A' && c <= 'Z' { + val += int64(c - 'A' + 36) + } else { + rst.fail("invalid digit in base 62 number") + } + } + rst.fail("expected _ after base 62 number") + return 0 +} + +// = "B" +func (rst *rustState) backref(demangle func()) { + backoff := rst.off + + rst.checkChar('B') + idx64 := rst.base62Number() + + if rst.skip { + return + } + + idx := int(idx64) + if int64(idx) != idx64 { + rst.fail("backref index overflow") + } + if idx < 0 || idx >= backoff { + rst.fail("invalid backref index") + } + + holdStr := rst.str + holdOff := rst.off + rst.str = rst.orig[idx:backoff] + rst.off = idx + defer func() { + rst.str = holdStr + rst.off = holdOff + }() + + demangle() +} + +func (rst *rustState) decimalNumber() int { + if len(rst.str) == 0 { + rst.fail("expected number") + } + + val := 0 + for len(rst.str) > 0 && isDigit(rst.str[0]) { + add := int(rst.str[0] - '0') + if val >= math.MaxInt32/10-add { + rst.fail("decimal number overflow") + } + val *= 10 + val += add + rst.advance(1) + } + return val +} + +// oldRustToString demangles a Rust symbol using the old demangling. +// The second result reports whether this is a valid Rust mangled name. +func oldRustToString(name string, options []Option) (string, bool) { + // We know that the string starts with _ZN. + name = name[3:] + + hexDigit := func(c byte) (byte, bool) { + switch { + case c >= '0' && c <= '9': + return c - '0', true + case c >= 'a' && c <= 'f': + return c - 'a' + 10, true + default: + return 0, false + } + } + + // We know that the strings end with "17h" followed by 16 characters + // followed by "E". We check that the 16 characters are all hex digits. + // Also the hex digits must contain at least 5 distinct digits. + seen := uint16(0) + for i := len(name) - 17; i < len(name) - 1; i++ { + digit, ok := hexDigit(name[i]) + if !ok { + return "", false + } + seen |= 1 << digit + } + if bits.OnesCount16(seen) < 5 { + return "", false + } + name = name[:len(name)-20] + + // The name is a sequence of length-preceded identifiers. + var sb strings.Builder + for len(name) > 0 { + if !isDigit(name[0]) { + return "", false + } + + val := 0 + for len(name) > 0 && isDigit(name[0]) { + add := int(name[0] - '0') + if val >= math.MaxInt32/10-add { + return "", false + } + val *= 10 + val += add + name = name[1:] + } + + // An optional trailing underscore can separate the + // length from the identifier. + if len(name) > 0 && name[0] == '_' { + name = name[1:] + val-- + } + + if len(name) < val { + return "", false + } + + id := name[:val] + name = name[val:] + + if sb.Len() > 0 { + sb.WriteString("::") + } + + // Ignore leading underscores preceding escape sequences. + if strings.HasPrefix(id, "_$") { + id = id[1:] + } + + // The identifier can have escape sequences. + escape: + for len(id) > 0 { + switch c := id[0]; c { + case '$': + codes := map[string]byte { + "SP": '@', + "BP": '*', + "RF": '&', + "LT": '<', + "GT": '>', + "LP": '(', + "RP": ')', + } + + valid := true + if len(id) > 2 && id[1] == 'C' && id[2] == '$' { + sb.WriteByte(',') + id = id[3:] + } else if len(id) > 4 && id[1] == 'u' && id[4] == '$' { + dig1, ok1 := hexDigit(id[2]) + dig2, ok2 := hexDigit(id[3]) + val := (dig1 << 4) | dig2 + if !ok1 || !ok2 || dig1 > 7 || val < ' ' { + valid = false + } else { + sb.WriteByte(val) + id = id[5:] + } + } else if len(id) > 3 && id[3] == '$' { + if code, ok := codes[id[1:3]]; !ok { + valid = false + } else { + sb.WriteByte(code) + id = id[4:] + } + } else { + valid = false + } + if !valid { + sb.WriteString(id) + break escape + } + case '.': + if strings.HasPrefix(id, "..") { + sb.WriteString("::") + id = id[2:] + } else { + sb.WriteByte(c) + id = id[1:] + } + default: + sb.WriteByte(c) + id = id[1:] + } + } + } + + return sb.String(), true +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/mkerrors.sh b/src/cmd/vendor/golang.org/x/sys/unix/mkerrors.sh index 0bcb8c3226..a74ef58f8c 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/src/cmd/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -54,7 +54,7 @@ includes_AIX=' includes_Darwin=' #define _DARWIN_C_SOURCE -#define KERNEL +#define KERNEL 1 #define _DARWIN_USE_64_BIT_INODE #define __APPLE_USE_RFC_3542 #include @@ -75,6 +75,7 @@ includes_Darwin=' #include #include #include +#include #include #include #include @@ -82,6 +83,9 @@ includes_Darwin=' #include #include #include + +// for backwards compatibility because moved TIOCREMOTE to Kernel.framework after MacOSX12.0.sdk. +#define TIOCREMOTE 0x80047469 ' includes_DragonFly=' @@ -229,6 +233,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -465,7 +470,6 @@ ccflags="$@" $2 !~ /^EQUIV_/ && $2 !~ /^EXPR_/ && $2 !~ /^EVIOC/ && - $2 !~ /^EV_/ && $2 ~ /^E[A-Z0-9_]+$/ || $2 ~ /^B[0-9_]+$/ || $2 ~ /^(OLD|NEW)DEV$/ || @@ -497,6 +501,7 @@ ccflags="$@" $2 ~ /^O?XTABS$/ || $2 ~ /^TC[IO](ON|OFF)$/ || $2 ~ /^IN_/ || + $2 ~ /^LANDLOCK_/ || $2 ~ /^LOCK_(SH|EX|NB|UN)$/ || $2 ~ /^LO_(KEY|NAME)_SIZE$/ || $2 ~ /^LOOP_(CLR|CTL|GET|SET)_/ || diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_darwin.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_darwin.go index 23f6b57606..a8c13317d7 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -48,6 +48,30 @@ func (sa *SockaddrCtl) sockaddr() (unsafe.Pointer, _Socklen, error) { return unsafe.Pointer(&sa.raw), SizeofSockaddrCtl, nil } +// SockaddrVM implements the Sockaddr interface for AF_VSOCK type sockets. +// SockaddrVM provides access to Darwin VM sockets: a mechanism that enables +// bidirectional communication between a hypervisor and its guest virtual +// machines. +type SockaddrVM struct { + // CID and Port specify a context ID and port address for a VM socket. + // Guests have a unique CID, and hosts may have a well-known CID of: + // - VMADDR_CID_HYPERVISOR: refers to the hypervisor process. + // - VMADDR_CID_LOCAL: refers to local communication (loopback). + // - VMADDR_CID_HOST: refers to other processes on the host. + CID uint32 + Port uint32 + raw RawSockaddrVM +} + +func (sa *SockaddrVM) sockaddr() (unsafe.Pointer, _Socklen, error) { + sa.raw.Len = SizeofSockaddrVM + sa.raw.Family = AF_VSOCK + sa.raw.Port = sa.Port + sa.raw.Cid = sa.CID + + return unsafe.Pointer(&sa.raw), SizeofSockaddrVM, nil +} + func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { switch rsa.Addr.Family { case AF_SYSTEM: @@ -58,6 +82,13 @@ func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa.Unit = pp.Sc_unit return sa, nil } + case AF_VSOCK: + pp := (*RawSockaddrVM)(unsafe.Pointer(rsa)) + sa := &SockaddrVM{ + CID: pp.Cid, + Port: pp.Port, + } + return sa, nil } return nil, EAFNOSUPPORT } @@ -433,6 +464,11 @@ func SysctlKinfoProcSlice(name string) ([]KinfoProc, error) { //sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) +//sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error) +//sys shmctl(id int, cmd int, buf *SysvShmDesc) (result int, err error) +//sys shmdt(addr uintptr) (err error) +//sys shmget(key int, size int, flag int) (id int, err error) + /* * Exposed directly */ @@ -590,10 +626,6 @@ func SysctlKinfoProcSlice(name string) ([]KinfoProc, error) { // Msgget // Msgsnd // Msgrcv -// Shmat -// Shmctl -// Shmdt -// Shmget // Shm_open // Shm_unlink // Sem_open diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_illumos.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_illumos.go index 8c53576835..8d5f294c42 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_illumos.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_illumos.go @@ -162,6 +162,14 @@ func (l *Lifreq) GetLifruInt() int { return *(*int)(unsafe.Pointer(&l.Lifru[0])) } +func (l *Lifreq) SetLifruUint(d uint) { + *(*uint)(unsafe.Pointer(&l.Lifru[0])) = d +} + +func (l *Lifreq) GetLifruUint() uint { + return *(*uint)(unsafe.Pointer(&l.Lifru[0])) +} + func IoctlLifreq(fd int, req uint, l *Lifreq) error { return ioctl(fd, req, uintptr(unsafe.Pointer(l))) } diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux.go index 2839435e3d..fff38a84c9 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -13,7 +13,6 @@ package unix import ( "encoding/binary" - "runtime" "syscall" "unsafe" ) @@ -38,6 +37,13 @@ func Creat(path string, mode uint32) (fd int, err error) { return Open(path, O_CREAT|O_WRONLY|O_TRUNC, mode) } +func EpollCreate(size int) (fd int, err error) { + if size <= 0 { + return -1, EINVAL + } + return EpollCreate1(0) +} + //sys FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) //sys fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) @@ -66,6 +72,10 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { return fchmodat(dirfd, path, mode) } +func InotifyInit() (fd int, err error) { + return InotifyInit1(0) +} + //sys ioctl(fd int, req uint, arg uintptr) (err error) = SYS_IOCTL //sys ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_IOCTL @@ -109,6 +119,23 @@ func Openat2(dirfd int, path string, how *OpenHow) (fd int, err error) { return openat2(dirfd, path, how, SizeofOpenHow) } +func Pipe(p []int) error { + return Pipe2(p, 0) +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) error { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err := pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return err +} + //sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { @@ -118,6 +145,15 @@ func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error return ppoll(&fds[0], len(fds), timeout, sigmask) } +func Poll(fds []PollFd, timeout int) (n int, err error) { + var ts *Timespec + if timeout >= 0 { + ts = new(Timespec) + *ts = NsecToTimespec(int64(timeout) * 1e6) + } + return Ppoll(fds, ts, nil) +} + //sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error) func Readlink(path string, buf []byte) (n int, err error) { @@ -168,27 +204,7 @@ func Utimes(path string, tv []Timeval) error { //sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) func UtimesNano(path string, ts []Timespec) error { - if ts == nil { - err := utimensat(AT_FDCWD, path, nil, 0) - if err != ENOSYS { - return err - } - return utimes(path, nil) - } - if len(ts) != 2 { - return EINVAL - } - err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) - if err != ENOSYS { - return err - } - // If the utimensat syscall isn't available (utimensat was added to Linux - // in 2.6.22, Released, 8 July 2007) then fall back to utimes - var tv [2]Timeval - for i := 0; i < 2; i++ { - tv[i] = NsecToTimeval(TimespecToNsec(ts[i])) - } - return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) + return UtimesNanoAt(AT_FDCWD, path, ts, 0) } func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error { @@ -1229,11 +1245,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { func Accept(fd int) (nfd int, sa Sockaddr, err error) { var rsa RawSockaddrAny var len _Socklen = SizeofSockaddrAny - // Try accept4 first for Android, then try accept for kernel older than 2.6.28 nfd, err = accept4(fd, &rsa, &len, 0) - if err == ENOSYS { - nfd, err = accept(fd, &rsa, &len) - } if err != nil { return } @@ -1816,11 +1828,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys Dup(oldfd int) (fd int, err error) func Dup2(oldfd, newfd int) error { - // Android O and newer blocks dup2; riscv and arm64 don't implement dup2. - if runtime.GOOS == "android" || runtime.GOARCH == "riscv64" || runtime.GOARCH == "arm64" { - return Dup3(oldfd, newfd, 0) - } - return dup2(oldfd, newfd) + return Dup3(oldfd, newfd, 0) } //sys Dup3(oldfd int, newfd int, flags int) (err error) @@ -2308,6 +2316,14 @@ type RemoteIovec struct { //sys ProcessVMReadv(pid int, localIov []Iovec, remoteIov []RemoteIovec, flags uint) (n int, err error) = SYS_PROCESS_VM_READV //sys ProcessVMWritev(pid int, localIov []Iovec, remoteIov []RemoteIovec, flags uint) (n int, err error) = SYS_PROCESS_VM_WRITEV +//sys PidfdOpen(pid int, flags int) (fd int, err error) = SYS_PIDFD_OPEN +//sys PidfdGetfd(pidfd int, targetfd int, flags int) (fd int, err error) = SYS_PIDFD_GETFD + +//sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error) +//sys shmctl(id int, cmd int, buf *SysvShmDesc) (result int, err error) +//sys shmdt(addr uintptr) (err error) +//sys shmget(key int, size int, flag int) (id int, err error) + /* * Unimplemented */ @@ -2389,10 +2405,6 @@ type RemoteIovec struct { // SetRobustList // SetThreadArea // SetTidAddress -// Shmat -// Shmctl -// Shmdt -// Shmget // Sigaltstack // Swapoff // Swapon diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_386.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_386.go index 91317d749a..5f757e8aa7 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_386.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_386.go @@ -19,36 +19,8 @@ func setTimeval(sec, usec int64) Timeval { return Timeval{Sec: int32(sec), Usec: int32(usec)} } -//sysnb pipe(p *[2]_C_int) (err error) - -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe(&pp) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sysnb pipe2(p *[2]_C_int, flags int) (err error) - -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - // 64-bit file system and 32-bit uid calls // (386 default is 32-bit file system and 16-bit uid). -//sys dup2(oldfd int, newfd int) (err error) -//sysnb EpollCreate(size int) (fd int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64_64 //sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 @@ -59,7 +31,6 @@ func Pipe2(p []int, flags int) (err error) { //sysnb Geteuid() (euid int) = SYS_GETEUID32 //sysnb Getgid() (gid int) = SYS_GETGID32 //sysnb Getuid() (uid int) = SYS_GETUID32 -//sysnb InotifyInit() (fd int, err error) //sys Ioperm(from int, num int, on int) (err error) //sys Iopl(level int) (err error) //sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32 @@ -381,12 +352,3 @@ func (cmsg *Cmsghdr) SetLen(length int) { func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { rsa.Service_name_len = uint32(length) } - -//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) - -func Poll(fds []PollFd, timeout int) (n int, err error) { - if len(fds) == 0 { - return poll(nil, 0, timeout) - } - return poll(&fds[0], len(fds), timeout) -} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go index 85cd97da09..4299125aa7 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -7,8 +7,6 @@ package unix -//sys dup2(oldfd int, newfd int) (err error) -//sysnb EpollCreate(size int) (fd int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) @@ -21,17 +19,6 @@ package unix //sysnb Getgid() (gid int) //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) //sysnb Getuid() (uid int) -//sysnb inotifyInit() (fd int, err error) - -func InotifyInit() (fd int, err error) { - // First try inotify_init1, because Android's seccomp policy blocks the latter. - fd, err = InotifyInit1(0) - if err == ENOSYS { - fd, err = inotifyInit() - } - return -} - //sys Ioperm(from int, num int, on int) (err error) //sys Iopl(level int) (err error) //sys Lchown(path string, uid int, gid int) (err error) @@ -126,32 +113,6 @@ func setTimeval(sec, usec int64) Timeval { return Timeval{Sec: sec, Usec: usec} } -//sysnb pipe(p *[2]_C_int) (err error) - -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe(&pp) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sysnb pipe2(p *[2]_C_int, flags int) (err error) - -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - func (r *PtraceRegs) PC() uint64 { return r.Rip } func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc } @@ -176,15 +137,6 @@ func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { rsa.Service_name_len = uint64(length) } -//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) - -func Poll(fds []PollFd, timeout int) (n int, err error) { - if len(fds) == 0 { - return poll(nil, 0, timeout) - } - return poll(&fds[0], len(fds), timeout) -} - //sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_arm.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_arm.go index b961a620e9..79edeb9cb1 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_arm.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_arm.go @@ -19,36 +19,6 @@ func setTimeval(sec, usec int64) Timeval { return Timeval{Sec: int32(sec), Usec: int32(usec)} } -//sysnb pipe(p *[2]_C_int) (err error) - -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - // Try pipe2 first for Android O, then try pipe for kernel 2.6.23. - err = pipe2(&pp, 0) - if err == ENOSYS { - err = pipe(&pp) - } - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sysnb pipe2(p *[2]_C_int, flags int) (err error) - -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { newoffset, errno := seek(fd, offset, whence) if errno != 0 { @@ -76,8 +46,6 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { // 64-bit file system and 32-bit uid calls // (16-bit uid calls are not always supported in newer kernels) -//sys dup2(oldfd int, newfd int) (err error) -//sysnb EpollCreate(size int) (fd int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 @@ -86,7 +54,6 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { //sysnb Geteuid() (euid int) = SYS_GETEUID32 //sysnb Getgid() (gid int) = SYS_GETGID32 //sysnb Getuid() (uid int) = SYS_GETUID32 -//sysnb InotifyInit() (fd int, err error) //sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32 //sys Listen(s int, n int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 @@ -260,15 +227,6 @@ func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { rsa.Service_name_len = uint32(length) } -//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) - -func Poll(fds []PollFd, timeout int) (n int, err error) { - if len(fds) == 0 { - return poll(nil, 0, timeout) - } - return poll(&fds[0], len(fds), timeout) -} - //sys armSyncFileRange(fd int, flags int, off int64, n int64) (err error) = SYS_ARM_SYNC_FILE_RANGE func SyncFileRange(fd int, off int64, n int64, flags int) error { diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go index 4b977ba44b..862890de29 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go @@ -9,13 +9,6 @@ package unix import "unsafe" -func EpollCreate(size int) (fd int, err error) { - if size <= 0 { - return -1, EINVAL - } - return EpollCreate1(0) -} - //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) @@ -145,30 +138,6 @@ func utimes(path string, tv *[2]Timeval) (err error) { return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) } -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, 0) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sysnb pipe2(p *[2]_C_int, flags int) (err error) - -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - // Getrlimit prefers the prlimit64 system call. See issue 38604. func Getrlimit(resource int, rlim *Rlimit) error { err := Prlimit(0, resource, nil, rlim) @@ -211,31 +180,11 @@ func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { rsa.Service_name_len = uint64(length) } -func InotifyInit() (fd int, err error) { - return InotifyInit1(0) -} - -// dup2 exists because func Dup3 in syscall_linux.go references -// it in an unreachable path. dup2 isn't available on arm64. -func dup2(oldfd int, newfd int) error - func Pause() error { _, err := ppoll(nil, 0, nil, nil) return err } -func Poll(fds []PollFd, timeout int) (n int, err error) { - var ts *Timespec - if timeout >= 0 { - ts = new(Timespec) - *ts = NsecToTimespec(int64(timeout) * 1e6) - } - if len(fds) == 0 { - return ppoll(nil, 0, ts, nil) - } - return ppoll(&fds[0], len(fds), ts, nil) -} - //sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go index 27aee81d97..8932e34ad2 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go @@ -8,8 +8,6 @@ package unix -//sys dup2(oldfd int, newfd int) (err error) -//sysnb EpollCreate(size int) (fd int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) @@ -94,30 +92,6 @@ func setTimeval(sec, usec int64) Timeval { return Timeval{Sec: sec, Usec: usec} } -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, 0) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sysnb pipe2(p *[2]_C_int, flags int) (err error) - -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - func Ioperm(from int, num int, on int) (err error) { return ENOSYS } @@ -220,16 +194,3 @@ func (cmsg *Cmsghdr) SetLen(length int) { func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { rsa.Service_name_len = uint64(length) } - -func InotifyInit() (fd int, err error) { - return InotifyInit1(0) -} - -//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) - -func Poll(fds []PollFd, timeout int) (n int, err error) { - if len(fds) == 0 { - return poll(nil, 0, timeout) - } - return poll(&fds[0], len(fds), timeout) -} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go index 21d74e2fbe..7821c25d9f 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go @@ -15,8 +15,6 @@ import ( func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) -//sys dup2(oldfd int, newfd int) (err error) -//sysnb EpollCreate(size int) (fd int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) @@ -60,7 +58,6 @@ func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) -//sysnb InotifyInit() (fd int, err error) //sys Ioperm(from int, num int, on int) (err error) //sys Iopl(level int) (err error) @@ -113,29 +110,6 @@ func setTimeval(sec, usec int64) Timeval { return Timeval{Sec: int32(sec), Usec: int32(usec)} } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) - -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sysnb pipe() (p1 int, p2 int, err error) - -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - p[0], p[1], err = pipe() - return -} - //sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { @@ -232,12 +206,3 @@ func (cmsg *Cmsghdr) SetLen(length int) { func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { rsa.Service_name_len = uint32(length) } - -//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) - -func Poll(fds []PollFd, timeout int) (n int, err error) { - if len(fds) == 0 { - return poll(nil, 0, timeout) - } - return poll(&fds[0], len(fds), timeout) -} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go index 6f1fc581ed..c5053a0f03 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go @@ -12,8 +12,6 @@ import ( "unsafe" ) -//sys dup2(oldfd int, newfd int) (err error) -//sysnb EpollCreate(size int) (fd int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 @@ -23,7 +21,6 @@ import ( //sysnb Geteuid() (euid int) //sysnb Getgid() (gid int) //sysnb Getuid() (uid int) -//sysnb InotifyInit() (fd int, err error) //sys Ioperm(from int, num int, on int) (err error) //sys Iopl(level int) (err error) //sys Lchown(path string, uid int, gid int) (err error) @@ -218,41 +215,6 @@ func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { rsa.Service_name_len = uint32(length) } -//sysnb pipe(p *[2]_C_int) (err error) - -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe(&pp) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sysnb pipe2(p *[2]_C_int, flags int) (err error) - -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) - -func Poll(fds []PollFd, timeout int) (n int, err error) { - if len(fds) == 0 { - return poll(nil, 0, timeout) - } - return poll(&fds[0], len(fds), timeout) -} - //sys syncFileRange2(fd int, flags int, off int64, n int64) (err error) = SYS_SYNC_FILE_RANGE2 func SyncFileRange(fd int, off int64, n int64, flags int) error { diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go index 5259a5feaf..25786c4216 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -8,8 +8,6 @@ package unix -//sys dup2(oldfd int, newfd int) (err error) -//sysnb EpollCreate(size int) (fd int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) @@ -22,7 +20,6 @@ package unix //sysnb Getgid() (gid int) //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT //sysnb Getuid() (uid int) -//sysnb InotifyInit() (fd int, err error) //sys Ioperm(from int, num int, on int) (err error) //sys Iopl(level int) (err error) //sys Lchown(path string, uid int, gid int) (err error) @@ -104,41 +101,6 @@ func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { rsa.Service_name_len = uint64(length) } -//sysnb pipe(p *[2]_C_int) (err error) - -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe(&pp) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sysnb pipe2(p *[2]_C_int, flags int) (err error) - -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) - -func Poll(fds []PollFd, timeout int) (n int, err error) { - if len(fds) == 0 { - return poll(nil, 0, timeout) - } - return poll(&fds[0], len(fds), timeout) -} - //sys syncFileRange2(fd int, flags int, off int64, n int64) (err error) = SYS_SYNC_FILE_RANGE2 func SyncFileRange(fd int, off int64, n int64, flags int) error { diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go index 8ef821e5da..6f9f710414 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go @@ -9,13 +9,6 @@ package unix import "unsafe" -func EpollCreate(size int) (fd int, err error) { - if size <= 0 { - return -1, EINVAL - } - return EpollCreate1(0) -} - //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) @@ -144,30 +137,6 @@ func utimes(path string, tv *[2]Timeval) (err error) { return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) } -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, 0) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sysnb pipe2(p *[2]_C_int, flags int) (err error) - -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - func (r *PtraceRegs) PC() uint64 { return r.Pc } func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc } @@ -192,27 +161,11 @@ func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { rsa.Service_name_len = uint64(length) } -func InotifyInit() (fd int, err error) { - return InotifyInit1(0) -} - func Pause() error { _, err := ppoll(nil, 0, nil, nil) return err } -func Poll(fds []PollFd, timeout int) (n int, err error) { - var ts *Timespec - if timeout >= 0 { - ts = new(Timespec) - *ts = NsecToTimespec(int64(timeout) * 1e6) - } - if len(fds) == 0 { - return ppoll(nil, 0, ts, nil) - } - return ppoll(&fds[0], len(fds), ts, nil) -} - func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { return Renameat2(olddirfd, oldpath, newdirfd, newpath, 0) } @@ -229,7 +182,3 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error } return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) } - -// dup2 exists because func Dup3 in syscall_linux.go references -// it in an unreachable path. dup2 isn't available on arm64. -func dup2(oldfd int, newfd int) error diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go index a1c0574b58..6aa59cb270 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -11,8 +11,6 @@ import ( "unsafe" ) -//sys dup2(oldfd int, newfd int) (err error) -//sysnb EpollCreate(size int) (fd int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) @@ -25,7 +23,6 @@ import ( //sysnb Getgid() (gid int) //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) //sysnb Getuid() (uid int) -//sysnb InotifyInit() (fd int, err error) //sys Lchown(path string, uid int, gid int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) //sys Pause() (err error) @@ -77,30 +74,6 @@ func setTimeval(sec, usec int64) Timeval { return Timeval{Sec: sec, Usec: usec} } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) - -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, 0) // pipe2 is the same as pipe when flags are set to 0. - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - func Ioperm(from int, num int, on int) (err error) { return ENOSYS } @@ -324,15 +297,6 @@ func Shutdown(s, how int) error { return nil } -//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) - -func Poll(fds []PollFd, timeout int) (n int, err error) { - if len(fds) == 0 { - return poll(nil, 0, timeout) - } - return poll(&fds[0], len(fds), timeout) -} - //sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go index de14b88983..bbe8d174f8 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go @@ -9,7 +9,6 @@ package unix //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 -//sys dup2(oldfd int, newfd int) (err error) //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstat(fd int, stat *Stat_t) (err error) //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 @@ -20,7 +19,6 @@ package unix //sysnb Getgid() (gid int) //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) //sysnb Getuid() (uid int) -//sysnb InotifyInit() (fd int, err error) //sys Lchown(path string, uid int, gid int) (err error) //sys Listen(s int, n int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) @@ -119,38 +117,3 @@ func (cmsg *Cmsghdr) SetLen(length int) { func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { rsa.Service_name_len = uint64(length) } - -//sysnb pipe(p *[2]_C_int) (err error) - -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe(&pp) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sysnb pipe2(p *[2]_C_int, flags int) (err error) - -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) - -func Poll(fds []PollFd, timeout int) (n int, err error) { - if len(fds) == 0 { - return poll(nil, 0, timeout) - } - return poll(&fds[0], len(fds), timeout) -} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/sysvshm_linux.go b/src/cmd/vendor/golang.org/x/sys/unix/sysvshm_linux.go new file mode 100644 index 0000000000..2c3a4437f0 --- /dev/null +++ b/src/cmd/vendor/golang.org/x/sys/unix/sysvshm_linux.go @@ -0,0 +1,21 @@ +// Copyright 2021 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. + +//go:build linux +// +build linux + +package unix + +import "runtime" + +// SysvShmCtl performs control operations on the shared memory segment +// specified by id. +func SysvShmCtl(id, cmd int, desc *SysvShmDesc) (result int, err error) { + if runtime.GOARCH == "arm" || + runtime.GOARCH == "mips64" || runtime.GOARCH == "mips64le" { + cmd |= ipc_64 + } + + return shmctl(id, cmd, desc) +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/sysvshm_unix.go b/src/cmd/vendor/golang.org/x/sys/unix/sysvshm_unix.go new file mode 100644 index 0000000000..0bb4c8de55 --- /dev/null +++ b/src/cmd/vendor/golang.org/x/sys/unix/sysvshm_unix.go @@ -0,0 +1,61 @@ +// Copyright 2021 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. + +//go:build (darwin && !ios) || linux +// +build darwin,!ios linux + +package unix + +import ( + "unsafe" + + "golang.org/x/sys/internal/unsafeheader" +) + +// SysvShmAttach attaches the Sysv shared memory segment associated with the +// shared memory identifier id. +func SysvShmAttach(id int, addr uintptr, flag int) ([]byte, error) { + addr, errno := shmat(id, addr, flag) + if errno != nil { + return nil, errno + } + + // Retrieve the size of the shared memory to enable slice creation + var info SysvShmDesc + + _, err := SysvShmCtl(id, IPC_STAT, &info) + if err != nil { + // release the shared memory if we can't find the size + + // ignoring error from shmdt as there's nothing sensible to return here + shmdt(addr) + return nil, err + } + + // Use unsafe to convert addr into a []byte. + // TODO: convert to unsafe.Slice once we can assume Go 1.17 + var b []byte + hdr := (*unsafeheader.Slice)(unsafe.Pointer(&b)) + hdr.Data = unsafe.Pointer(addr) + hdr.Cap = int(info.Segsz) + hdr.Len = int(info.Segsz) + return b, nil +} + +// SysvShmDetach unmaps the shared memory slice returned from SysvShmAttach. +// +// It is not safe to use the slice after calling this function. +func SysvShmDetach(data []byte) error { + if len(data) == 0 { + return EINVAL + } + + return shmdt(uintptr(unsafe.Pointer(&data[0]))) +} + +// SysvShmGet returns the Sysv shared memory identifier associated with key. +// If the IPC_CREAT flag is specified a new segment is created. +func SysvShmGet(key, size, flag int) (id int, err error) { + return shmget(key, size, flag) +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/sysvshm_unix_other.go b/src/cmd/vendor/golang.org/x/sys/unix/sysvshm_unix_other.go new file mode 100644 index 0000000000..71bddefdb8 --- /dev/null +++ b/src/cmd/vendor/golang.org/x/sys/unix/sysvshm_unix_other.go @@ -0,0 +1,14 @@ +// Copyright 2021 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. + +//go:build darwin && !ios +// +build darwin,!ios + +package unix + +// SysvShmCtl performs control operations on the shared memory segment +// specified by id. +func SysvShmCtl(id, cmd int, desc *SysvShmDesc) (result int, err error) { + return shmctl(id, cmd, desc) +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/src/cmd/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index a3a45fec59..476a1c7e77 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -12,1556 +12,1582 @@ package unix import "syscall" const ( - AF_APPLETALK = 0x10 - AF_CCITT = 0xa - AF_CHAOS = 0x5 - AF_CNT = 0x15 - AF_COIP = 0x14 - AF_DATAKIT = 0x9 - AF_DECnet = 0xc - AF_DLI = 0xd - AF_E164 = 0x1c - AF_ECMA = 0x8 - AF_HYLINK = 0xf - AF_IEEE80211 = 0x25 - AF_IMPLINK = 0x3 - AF_INET = 0x2 - AF_INET6 = 0x1e - AF_IPX = 0x17 - AF_ISDN = 0x1c - AF_ISO = 0x7 - AF_LAT = 0xe - AF_LINK = 0x12 - AF_LOCAL = 0x1 - AF_MAX = 0x29 - AF_NATM = 0x1f - AF_NDRV = 0x1b - AF_NETBIOS = 0x21 - AF_NS = 0x6 - AF_OSI = 0x7 - AF_PPP = 0x22 - AF_PUP = 0x4 - AF_RESERVED_36 = 0x24 - AF_ROUTE = 0x11 - AF_SIP = 0x18 - AF_SNA = 0xb - AF_SYSTEM = 0x20 - AF_SYS_CONTROL = 0x2 - AF_UNIX = 0x1 - AF_UNSPEC = 0x0 - AF_UTUN = 0x26 - AF_VSOCK = 0x28 - ALTWERASE = 0x200 - ATTR_BIT_MAP_COUNT = 0x5 - ATTR_CMN_ACCESSMASK = 0x20000 - ATTR_CMN_ACCTIME = 0x1000 - ATTR_CMN_ADDEDTIME = 0x10000000 - ATTR_CMN_BKUPTIME = 0x2000 - ATTR_CMN_CHGTIME = 0x800 - ATTR_CMN_CRTIME = 0x200 - ATTR_CMN_DATA_PROTECT_FLAGS = 0x40000000 - ATTR_CMN_DEVID = 0x2 - ATTR_CMN_DOCUMENT_ID = 0x100000 - ATTR_CMN_ERROR = 0x20000000 - ATTR_CMN_EXTENDED_SECURITY = 0x400000 - ATTR_CMN_FILEID = 0x2000000 - ATTR_CMN_FLAGS = 0x40000 - ATTR_CMN_FNDRINFO = 0x4000 - ATTR_CMN_FSID = 0x4 - ATTR_CMN_FULLPATH = 0x8000000 - ATTR_CMN_GEN_COUNT = 0x80000 - ATTR_CMN_GRPID = 0x10000 - ATTR_CMN_GRPUUID = 0x1000000 - ATTR_CMN_MODTIME = 0x400 - ATTR_CMN_NAME = 0x1 - ATTR_CMN_NAMEDATTRCOUNT = 0x80000 - ATTR_CMN_NAMEDATTRLIST = 0x100000 - ATTR_CMN_OBJID = 0x20 - ATTR_CMN_OBJPERMANENTID = 0x40 - ATTR_CMN_OBJTAG = 0x10 - ATTR_CMN_OBJTYPE = 0x8 - ATTR_CMN_OWNERID = 0x8000 - ATTR_CMN_PARENTID = 0x4000000 - ATTR_CMN_PAROBJID = 0x80 - ATTR_CMN_RETURNED_ATTRS = 0x80000000 - ATTR_CMN_SCRIPT = 0x100 - ATTR_CMN_SETMASK = 0x51c7ff00 - ATTR_CMN_USERACCESS = 0x200000 - ATTR_CMN_UUID = 0x800000 - ATTR_CMN_VALIDMASK = 0xffffffff - ATTR_CMN_VOLSETMASK = 0x6700 - ATTR_FILE_ALLOCSIZE = 0x4 - ATTR_FILE_CLUMPSIZE = 0x10 - ATTR_FILE_DATAALLOCSIZE = 0x400 - ATTR_FILE_DATAEXTENTS = 0x800 - ATTR_FILE_DATALENGTH = 0x200 - ATTR_FILE_DEVTYPE = 0x20 - ATTR_FILE_FILETYPE = 0x40 - ATTR_FILE_FORKCOUNT = 0x80 - ATTR_FILE_FORKLIST = 0x100 - ATTR_FILE_IOBLOCKSIZE = 0x8 - ATTR_FILE_LINKCOUNT = 0x1 - ATTR_FILE_RSRCALLOCSIZE = 0x2000 - ATTR_FILE_RSRCEXTENTS = 0x4000 - ATTR_FILE_RSRCLENGTH = 0x1000 - ATTR_FILE_SETMASK = 0x20 - ATTR_FILE_TOTALSIZE = 0x2 - ATTR_FILE_VALIDMASK = 0x37ff - ATTR_VOL_ALLOCATIONCLUMP = 0x40 - ATTR_VOL_ATTRIBUTES = 0x40000000 - ATTR_VOL_CAPABILITIES = 0x20000 - ATTR_VOL_DIRCOUNT = 0x400 - ATTR_VOL_ENCODINGSUSED = 0x10000 - ATTR_VOL_FILECOUNT = 0x200 - ATTR_VOL_FSTYPE = 0x1 - ATTR_VOL_INFO = 0x80000000 - ATTR_VOL_IOBLOCKSIZE = 0x80 - ATTR_VOL_MAXOBJCOUNT = 0x800 - ATTR_VOL_MINALLOCATION = 0x20 - ATTR_VOL_MOUNTEDDEVICE = 0x8000 - ATTR_VOL_MOUNTFLAGS = 0x4000 - ATTR_VOL_MOUNTPOINT = 0x1000 - ATTR_VOL_NAME = 0x2000 - ATTR_VOL_OBJCOUNT = 0x100 - ATTR_VOL_QUOTA_SIZE = 0x10000000 - ATTR_VOL_RESERVED_SIZE = 0x20000000 - ATTR_VOL_SETMASK = 0x80002000 - ATTR_VOL_SIGNATURE = 0x2 - ATTR_VOL_SIZE = 0x4 - ATTR_VOL_SPACEAVAIL = 0x10 - ATTR_VOL_SPACEFREE = 0x8 - ATTR_VOL_UUID = 0x40000 - ATTR_VOL_VALIDMASK = 0xf007ffff - B0 = 0x0 - B110 = 0x6e - B115200 = 0x1c200 - B1200 = 0x4b0 - B134 = 0x86 - B14400 = 0x3840 - B150 = 0x96 - B1800 = 0x708 - B19200 = 0x4b00 - B200 = 0xc8 - B230400 = 0x38400 - B2400 = 0x960 - B28800 = 0x7080 - B300 = 0x12c - B38400 = 0x9600 - B4800 = 0x12c0 - B50 = 0x32 - B57600 = 0xe100 - B600 = 0x258 - B7200 = 0x1c20 - B75 = 0x4b - B76800 = 0x12c00 - B9600 = 0x2580 - BIOCFLUSH = 0x20004268 - BIOCGBLEN = 0x40044266 - BIOCGDLT = 0x4004426a - BIOCGDLTLIST = 0xc00c4279 - BIOCGETIF = 0x4020426b - BIOCGHDRCMPLT = 0x40044274 - BIOCGRSIG = 0x40044272 - BIOCGRTIMEOUT = 0x4010426e - BIOCGSEESENT = 0x40044276 - BIOCGSTATS = 0x4008426f - BIOCIMMEDIATE = 0x80044270 - BIOCPROMISC = 0x20004269 - BIOCSBLEN = 0xc0044266 - BIOCSDLT = 0x80044278 - BIOCSETF = 0x80104267 - BIOCSETFNR = 0x8010427e - BIOCSETIF = 0x8020426c - BIOCSHDRCMPLT = 0x80044275 - BIOCSRSIG = 0x80044273 - BIOCSRTIMEOUT = 0x8010426d - BIOCSSEESENT = 0x80044277 - BIOCVERSION = 0x40044271 - BPF_A = 0x10 - BPF_ABS = 0x20 - BPF_ADD = 0x0 - BPF_ALIGNMENT = 0x4 - BPF_ALU = 0x4 - BPF_AND = 0x50 - BPF_B = 0x10 - BPF_DIV = 0x30 - BPF_H = 0x8 - BPF_IMM = 0x0 - BPF_IND = 0x40 - BPF_JA = 0x0 - BPF_JEQ = 0x10 - BPF_JGE = 0x30 - BPF_JGT = 0x20 - BPF_JMP = 0x5 - BPF_JSET = 0x40 - BPF_K = 0x0 - BPF_LD = 0x0 - BPF_LDX = 0x1 - BPF_LEN = 0x80 - BPF_LSH = 0x60 - BPF_MAJOR_VERSION = 0x1 - BPF_MAXBUFSIZE = 0x80000 - BPF_MAXINSNS = 0x200 - BPF_MEM = 0x60 - BPF_MEMWORDS = 0x10 - BPF_MINBUFSIZE = 0x20 - BPF_MINOR_VERSION = 0x1 - BPF_MISC = 0x7 - BPF_MSH = 0xa0 - BPF_MUL = 0x20 - BPF_NEG = 0x80 - BPF_OR = 0x40 - BPF_RELEASE = 0x30bb6 - BPF_RET = 0x6 - BPF_RSH = 0x70 - BPF_ST = 0x2 - BPF_STX = 0x3 - BPF_SUB = 0x10 - BPF_TAX = 0x0 - BPF_TXA = 0x80 - BPF_W = 0x0 - BPF_X = 0x8 - BRKINT = 0x2 - BS0 = 0x0 - BS1 = 0x8000 - BSDLY = 0x8000 - CFLUSH = 0xf - CLOCAL = 0x8000 - CLOCK_MONOTONIC = 0x6 - CLOCK_MONOTONIC_RAW = 0x4 - CLOCK_MONOTONIC_RAW_APPROX = 0x5 - CLOCK_PROCESS_CPUTIME_ID = 0xc - CLOCK_REALTIME = 0x0 - CLOCK_THREAD_CPUTIME_ID = 0x10 - CLOCK_UPTIME_RAW = 0x8 - CLOCK_UPTIME_RAW_APPROX = 0x9 - CLONE_NOFOLLOW = 0x1 - CLONE_NOOWNERCOPY = 0x2 - CR0 = 0x0 - CR1 = 0x1000 - CR2 = 0x2000 - CR3 = 0x3000 - CRDLY = 0x3000 - CREAD = 0x800 - CRTSCTS = 0x30000 - CS5 = 0x0 - CS6 = 0x100 - CS7 = 0x200 - CS8 = 0x300 - CSIZE = 0x300 - CSTART = 0x11 - CSTATUS = 0x14 - CSTOP = 0x13 - CSTOPB = 0x400 - CSUSP = 0x1a - CTLIOCGINFO = 0xc0644e03 - CTL_HW = 0x6 - CTL_KERN = 0x1 - CTL_MAXNAME = 0xc - CTL_NET = 0x4 - DLT_A429 = 0xb8 - DLT_A653_ICM = 0xb9 - DLT_AIRONET_HEADER = 0x78 - DLT_AOS = 0xde - DLT_APPLE_IP_OVER_IEEE1394 = 0x8a - DLT_ARCNET = 0x7 - DLT_ARCNET_LINUX = 0x81 - DLT_ATM_CLIP = 0x13 - DLT_ATM_RFC1483 = 0xb - DLT_AURORA = 0x7e - DLT_AX25 = 0x3 - DLT_AX25_KISS = 0xca - DLT_BACNET_MS_TP = 0xa5 - DLT_BLUETOOTH_HCI_H4 = 0xbb - DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 - DLT_CAN20B = 0xbe - DLT_CAN_SOCKETCAN = 0xe3 - DLT_CHAOS = 0x5 - DLT_CHDLC = 0x68 - DLT_CISCO_IOS = 0x76 - DLT_C_HDLC = 0x68 - DLT_C_HDLC_WITH_DIR = 0xcd - DLT_DBUS = 0xe7 - DLT_DECT = 0xdd - DLT_DOCSIS = 0x8f - DLT_DVB_CI = 0xeb - DLT_ECONET = 0x73 - DLT_EN10MB = 0x1 - DLT_EN3MB = 0x2 - DLT_ENC = 0x6d - DLT_ERF = 0xc5 - DLT_ERF_ETH = 0xaf - DLT_ERF_POS = 0xb0 - DLT_FC_2 = 0xe0 - DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 - DLT_FDDI = 0xa - DLT_FLEXRAY = 0xd2 - DLT_FRELAY = 0x6b - DLT_FRELAY_WITH_DIR = 0xce - DLT_GCOM_SERIAL = 0xad - DLT_GCOM_T1E1 = 0xac - DLT_GPF_F = 0xab - DLT_GPF_T = 0xaa - DLT_GPRS_LLC = 0xa9 - DLT_GSMTAP_ABIS = 0xda - DLT_GSMTAP_UM = 0xd9 - DLT_HHDLC = 0x79 - DLT_IBM_SN = 0x92 - DLT_IBM_SP = 0x91 - DLT_IEEE802 = 0x6 - DLT_IEEE802_11 = 0x69 - DLT_IEEE802_11_RADIO = 0x7f - DLT_IEEE802_11_RADIO_AVS = 0xa3 - DLT_IEEE802_15_4 = 0xc3 - DLT_IEEE802_15_4_LINUX = 0xbf - DLT_IEEE802_15_4_NOFCS = 0xe6 - DLT_IEEE802_15_4_NONASK_PHY = 0xd7 - DLT_IEEE802_16_MAC_CPS = 0xbc - DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 - DLT_IPFILTER = 0x74 - DLT_IPMB = 0xc7 - DLT_IPMB_LINUX = 0xd1 - DLT_IPNET = 0xe2 - DLT_IPOIB = 0xf2 - DLT_IPV4 = 0xe4 - DLT_IPV6 = 0xe5 - DLT_IP_OVER_FC = 0x7a - DLT_JUNIPER_ATM1 = 0x89 - DLT_JUNIPER_ATM2 = 0x87 - DLT_JUNIPER_ATM_CEMIC = 0xee - DLT_JUNIPER_CHDLC = 0xb5 - DLT_JUNIPER_ES = 0x84 - DLT_JUNIPER_ETHER = 0xb2 - DLT_JUNIPER_FIBRECHANNEL = 0xea - DLT_JUNIPER_FRELAY = 0xb4 - DLT_JUNIPER_GGSN = 0x85 - DLT_JUNIPER_ISM = 0xc2 - DLT_JUNIPER_MFR = 0x86 - DLT_JUNIPER_MLFR = 0x83 - DLT_JUNIPER_MLPPP = 0x82 - DLT_JUNIPER_MONITOR = 0xa4 - DLT_JUNIPER_PIC_PEER = 0xae - DLT_JUNIPER_PPP = 0xb3 - DLT_JUNIPER_PPPOE = 0xa7 - DLT_JUNIPER_PPPOE_ATM = 0xa8 - DLT_JUNIPER_SERVICES = 0x88 - DLT_JUNIPER_SRX_E2E = 0xe9 - DLT_JUNIPER_ST = 0xc8 - DLT_JUNIPER_VP = 0xb7 - DLT_JUNIPER_VS = 0xe8 - DLT_LAPB_WITH_DIR = 0xcf - DLT_LAPD = 0xcb - DLT_LIN = 0xd4 - DLT_LINUX_EVDEV = 0xd8 - DLT_LINUX_IRDA = 0x90 - DLT_LINUX_LAPD = 0xb1 - DLT_LINUX_PPP_WITHDIRECTION = 0xa6 - DLT_LINUX_SLL = 0x71 - DLT_LOOP = 0x6c - DLT_LTALK = 0x72 - DLT_MATCHING_MAX = 0x10a - DLT_MATCHING_MIN = 0x68 - DLT_MFR = 0xb6 - DLT_MOST = 0xd3 - DLT_MPEG_2_TS = 0xf3 - DLT_MPLS = 0xdb - DLT_MTP2 = 0x8c - DLT_MTP2_WITH_PHDR = 0x8b - DLT_MTP3 = 0x8d - DLT_MUX27010 = 0xec - DLT_NETANALYZER = 0xf0 - DLT_NETANALYZER_TRANSPARENT = 0xf1 - DLT_NFC_LLCP = 0xf5 - DLT_NFLOG = 0xef - DLT_NG40 = 0xf4 - DLT_NULL = 0x0 - DLT_PCI_EXP = 0x7d - DLT_PFLOG = 0x75 - DLT_PFSYNC = 0x12 - DLT_PPI = 0xc0 - DLT_PPP = 0x9 - DLT_PPP_BSDOS = 0x10 - DLT_PPP_ETHER = 0x33 - DLT_PPP_PPPD = 0xa6 - DLT_PPP_SERIAL = 0x32 - DLT_PPP_WITH_DIR = 0xcc - DLT_PPP_WITH_DIRECTION = 0xa6 - DLT_PRISM_HEADER = 0x77 - DLT_PRONET = 0x4 - DLT_RAIF1 = 0xc6 - DLT_RAW = 0xc - DLT_RIO = 0x7c - DLT_SCCP = 0x8e - DLT_SITA = 0xc4 - DLT_SLIP = 0x8 - DLT_SLIP_BSDOS = 0xf - DLT_STANAG_5066_D_PDU = 0xed - DLT_SUNATM = 0x7b - DLT_SYMANTEC_FIREWALL = 0x63 - DLT_TZSP = 0x80 - DLT_USB = 0xba - DLT_USB_DARWIN = 0x10a - DLT_USB_LINUX = 0xbd - DLT_USB_LINUX_MMAPPED = 0xdc - DLT_USER0 = 0x93 - DLT_USER1 = 0x94 - DLT_USER10 = 0x9d - DLT_USER11 = 0x9e - DLT_USER12 = 0x9f - DLT_USER13 = 0xa0 - DLT_USER14 = 0xa1 - DLT_USER15 = 0xa2 - DLT_USER2 = 0x95 - DLT_USER3 = 0x96 - DLT_USER4 = 0x97 - DLT_USER5 = 0x98 - DLT_USER6 = 0x99 - DLT_USER7 = 0x9a - DLT_USER8 = 0x9b - DLT_USER9 = 0x9c - DLT_WIHART = 0xdf - DLT_X2E_SERIAL = 0xd5 - DLT_X2E_XORAYA = 0xd6 - DT_BLK = 0x6 - DT_CHR = 0x2 - DT_DIR = 0x4 - DT_FIFO = 0x1 - DT_LNK = 0xa - DT_REG = 0x8 - DT_SOCK = 0xc - DT_UNKNOWN = 0x0 - DT_WHT = 0xe - ECHO = 0x8 - ECHOCTL = 0x40 - ECHOE = 0x2 - ECHOK = 0x4 - ECHOKE = 0x1 - ECHONL = 0x10 - ECHOPRT = 0x20 - EVFILT_AIO = -0x3 - EVFILT_EXCEPT = -0xf - EVFILT_FS = -0x9 - EVFILT_MACHPORT = -0x8 - EVFILT_PROC = -0x5 - EVFILT_READ = -0x1 - EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0x11 - EVFILT_THREADMARKER = 0x11 - EVFILT_TIMER = -0x7 - EVFILT_USER = -0xa - EVFILT_VM = -0xc - EVFILT_VNODE = -0x4 - EVFILT_WRITE = -0x2 - EV_ADD = 0x1 - EV_CLEAR = 0x20 - EV_DELETE = 0x2 - EV_DISABLE = 0x8 - EV_DISPATCH = 0x80 - EV_DISPATCH2 = 0x180 - EV_ENABLE = 0x4 - EV_EOF = 0x8000 - EV_ERROR = 0x4000 - EV_FLAG0 = 0x1000 - EV_FLAG1 = 0x2000 - EV_ONESHOT = 0x10 - EV_OOBAND = 0x2000 - EV_POLL = 0x1000 - EV_RECEIPT = 0x40 - EV_SYSFLAGS = 0xf000 - EV_UDATA_SPECIFIC = 0x100 - EV_VANISHED = 0x200 - EXTA = 0x4b00 - EXTB = 0x9600 - EXTPROC = 0x800 - FD_CLOEXEC = 0x1 - FD_SETSIZE = 0x400 - FF0 = 0x0 - FF1 = 0x4000 - FFDLY = 0x4000 - FLUSHO = 0x800000 - FSOPT_ATTR_CMN_EXTENDED = 0x20 - FSOPT_NOFOLLOW = 0x1 - FSOPT_NOINMEMUPDATE = 0x2 - FSOPT_PACK_INVAL_ATTRS = 0x8 - FSOPT_REPORT_FULLSIZE = 0x4 - FSOPT_RETURN_REALDEV = 0x200 - F_ADDFILESIGS = 0x3d - F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 - F_ADDFILESIGS_INFO = 0x67 - F_ADDFILESIGS_RETURN = 0x61 - F_ADDFILESUPPL = 0x68 - F_ADDSIGS = 0x3b - F_ALLOCATEALL = 0x4 - F_ALLOCATECONTIG = 0x2 - F_BARRIERFSYNC = 0x55 - F_CHECK_LV = 0x62 - F_CHKCLEAN = 0x29 - F_DUPFD = 0x0 - F_DUPFD_CLOEXEC = 0x43 - F_FINDSIGS = 0x4e - F_FLUSH_DATA = 0x28 - F_FREEZE_FS = 0x35 - F_FULLFSYNC = 0x33 - F_GETCODEDIR = 0x48 - F_GETFD = 0x1 - F_GETFL = 0x3 - F_GETLK = 0x7 - F_GETLKPID = 0x42 - F_GETNOSIGPIPE = 0x4a - F_GETOWN = 0x5 - F_GETPATH = 0x32 - F_GETPATH_MTMINFO = 0x47 - F_GETPATH_NOFIRMLINK = 0x66 - F_GETPROTECTIONCLASS = 0x3f - F_GETPROTECTIONLEVEL = 0x4d - F_GETSIGSINFO = 0x69 - F_GLOBAL_NOCACHE = 0x37 - F_LOG2PHYS = 0x31 - F_LOG2PHYS_EXT = 0x41 - F_NOCACHE = 0x30 - F_NODIRECT = 0x3e - F_OK = 0x0 - F_PATHPKG_CHECK = 0x34 - F_PEOFPOSMODE = 0x3 - F_PREALLOCATE = 0x2a - F_PUNCHHOLE = 0x63 - F_RDADVISE = 0x2c - F_RDAHEAD = 0x2d - F_RDLCK = 0x1 - F_SETBACKINGSTORE = 0x46 - F_SETFD = 0x2 - F_SETFL = 0x4 - F_SETLK = 0x8 - F_SETLKW = 0x9 - F_SETLKWTIMEOUT = 0xa - F_SETNOSIGPIPE = 0x49 - F_SETOWN = 0x6 - F_SETPROTECTIONCLASS = 0x40 - F_SETSIZE = 0x2b - F_SINGLE_WRITER = 0x4c - F_SPECULATIVE_READ = 0x65 - F_THAW_FS = 0x36 - F_TRANSCODEKEY = 0x4b - F_TRIM_ACTIVE_FILE = 0x64 - F_UNLCK = 0x2 - F_VOLPOSMODE = 0x4 - F_WRLCK = 0x3 - HUPCL = 0x4000 - HW_MACHINE = 0x1 - ICANON = 0x100 - ICMP6_FILTER = 0x12 - ICRNL = 0x100 - IEXTEN = 0x400 - IFF_ALLMULTI = 0x200 - IFF_ALTPHYS = 0x4000 - IFF_BROADCAST = 0x2 - IFF_DEBUG = 0x4 - IFF_LINK0 = 0x1000 - IFF_LINK1 = 0x2000 - IFF_LINK2 = 0x4000 - IFF_LOOPBACK = 0x8 - IFF_MULTICAST = 0x8000 - IFF_NOARP = 0x80 - IFF_NOTRAILERS = 0x20 - IFF_OACTIVE = 0x400 - IFF_POINTOPOINT = 0x10 - IFF_PROMISC = 0x100 - IFF_RUNNING = 0x40 - IFF_SIMPLEX = 0x800 - IFF_UP = 0x1 - IFNAMSIZ = 0x10 - IFT_1822 = 0x2 - IFT_6LOWPAN = 0x40 - IFT_AAL5 = 0x31 - IFT_ARCNET = 0x23 - IFT_ARCNETPLUS = 0x24 - IFT_ATM = 0x25 - IFT_BRIDGE = 0xd1 - IFT_CARP = 0xf8 - IFT_CELLULAR = 0xff - IFT_CEPT = 0x13 - IFT_DS3 = 0x1e - IFT_ENC = 0xf4 - IFT_EON = 0x19 - IFT_ETHER = 0x6 - IFT_FAITH = 0x38 - IFT_FDDI = 0xf - IFT_FRELAY = 0x20 - IFT_FRELAYDCE = 0x2c - IFT_GIF = 0x37 - IFT_HDH1822 = 0x3 - IFT_HIPPI = 0x2f - IFT_HSSI = 0x2e - IFT_HY = 0xe - IFT_IEEE1394 = 0x90 - IFT_IEEE8023ADLAG = 0x88 - IFT_ISDNBASIC = 0x14 - IFT_ISDNPRIMARY = 0x15 - IFT_ISO88022LLC = 0x29 - IFT_ISO88023 = 0x7 - IFT_ISO88024 = 0x8 - IFT_ISO88025 = 0x9 - IFT_ISO88026 = 0xa - IFT_L2VLAN = 0x87 - IFT_LAPB = 0x10 - IFT_LOCALTALK = 0x2a - IFT_LOOP = 0x18 - IFT_MIOX25 = 0x26 - IFT_MODEM = 0x30 - IFT_NSIP = 0x1b - IFT_OTHER = 0x1 - IFT_P10 = 0xc - IFT_P80 = 0xd - IFT_PARA = 0x22 - IFT_PDP = 0xff - IFT_PFLOG = 0xf5 - IFT_PFSYNC = 0xf6 - IFT_PKTAP = 0xfe - IFT_PPP = 0x17 - IFT_PROPMUX = 0x36 - IFT_PROPVIRTUAL = 0x35 - IFT_PTPSERIAL = 0x16 - IFT_RS232 = 0x21 - IFT_SDLC = 0x11 - IFT_SIP = 0x1f - IFT_SLIP = 0x1c - IFT_SMDSDXI = 0x2b - IFT_SMDSICIP = 0x34 - IFT_SONET = 0x27 - IFT_SONETPATH = 0x32 - IFT_SONETVT = 0x33 - IFT_STARLAN = 0xb - IFT_STF = 0x39 - IFT_T1 = 0x12 - IFT_ULTRA = 0x1d - IFT_V35 = 0x2d - IFT_X25 = 0x5 - IFT_X25DDN = 0x4 - IFT_X25PLE = 0x28 - IFT_XETHER = 0x1a - IGNBRK = 0x1 - IGNCR = 0x80 - IGNPAR = 0x4 - IMAXBEL = 0x2000 - INLCR = 0x40 - INPCK = 0x10 - IN_CLASSA_HOST = 0xffffff - IN_CLASSA_MAX = 0x80 - IN_CLASSA_NET = 0xff000000 - IN_CLASSA_NSHIFT = 0x18 - IN_CLASSB_HOST = 0xffff - IN_CLASSB_MAX = 0x10000 - IN_CLASSB_NET = 0xffff0000 - IN_CLASSB_NSHIFT = 0x10 - IN_CLASSC_HOST = 0xff - IN_CLASSC_NET = 0xffffff00 - IN_CLASSC_NSHIFT = 0x8 - IN_CLASSD_HOST = 0xfffffff - IN_CLASSD_NET = 0xf0000000 - IN_CLASSD_NSHIFT = 0x1c - IN_LINKLOCALNETNUM = 0xa9fe0000 - IN_LOOPBACKNET = 0x7f - IPPROTO_3PC = 0x22 - IPPROTO_ADFS = 0x44 - IPPROTO_AH = 0x33 - IPPROTO_AHIP = 0x3d - IPPROTO_APES = 0x63 - IPPROTO_ARGUS = 0xd - IPPROTO_AX25 = 0x5d - IPPROTO_BHA = 0x31 - IPPROTO_BLT = 0x1e - IPPROTO_BRSATMON = 0x4c - IPPROTO_CFTP = 0x3e - IPPROTO_CHAOS = 0x10 - IPPROTO_CMTP = 0x26 - IPPROTO_CPHB = 0x49 - IPPROTO_CPNX = 0x48 - IPPROTO_DDP = 0x25 - IPPROTO_DGP = 0x56 - IPPROTO_DIVERT = 0xfe - IPPROTO_DONE = 0x101 - IPPROTO_DSTOPTS = 0x3c - IPPROTO_EGP = 0x8 - IPPROTO_EMCON = 0xe - IPPROTO_ENCAP = 0x62 - IPPROTO_EON = 0x50 - IPPROTO_ESP = 0x32 - IPPROTO_ETHERIP = 0x61 - IPPROTO_FRAGMENT = 0x2c - IPPROTO_GGP = 0x3 - IPPROTO_GMTP = 0x64 - IPPROTO_GRE = 0x2f - IPPROTO_HELLO = 0x3f - IPPROTO_HMP = 0x14 - IPPROTO_HOPOPTS = 0x0 - IPPROTO_ICMP = 0x1 - IPPROTO_ICMPV6 = 0x3a - IPPROTO_IDP = 0x16 - IPPROTO_IDPR = 0x23 - IPPROTO_IDRP = 0x2d - IPPROTO_IGMP = 0x2 - IPPROTO_IGP = 0x55 - IPPROTO_IGRP = 0x58 - IPPROTO_IL = 0x28 - IPPROTO_INLSP = 0x34 - IPPROTO_INP = 0x20 - IPPROTO_IP = 0x0 - IPPROTO_IPCOMP = 0x6c - IPPROTO_IPCV = 0x47 - IPPROTO_IPEIP = 0x5e - IPPROTO_IPIP = 0x4 - IPPROTO_IPPC = 0x43 - IPPROTO_IPV4 = 0x4 - IPPROTO_IPV6 = 0x29 - IPPROTO_IRTP = 0x1c - IPPROTO_KRYPTOLAN = 0x41 - IPPROTO_LARP = 0x5b - IPPROTO_LEAF1 = 0x19 - IPPROTO_LEAF2 = 0x1a - IPPROTO_MAX = 0x100 - IPPROTO_MAXID = 0x34 - IPPROTO_MEAS = 0x13 - IPPROTO_MHRP = 0x30 - IPPROTO_MICP = 0x5f - IPPROTO_MTP = 0x5c - IPPROTO_MUX = 0x12 - IPPROTO_ND = 0x4d - IPPROTO_NHRP = 0x36 - IPPROTO_NONE = 0x3b - IPPROTO_NSP = 0x1f - IPPROTO_NVPII = 0xb - IPPROTO_OSPFIGP = 0x59 - IPPROTO_PGM = 0x71 - IPPROTO_PIGP = 0x9 - IPPROTO_PIM = 0x67 - IPPROTO_PRM = 0x15 - IPPROTO_PUP = 0xc - IPPROTO_PVP = 0x4b - IPPROTO_RAW = 0xff - IPPROTO_RCCMON = 0xa - IPPROTO_RDP = 0x1b - IPPROTO_ROUTING = 0x2b - IPPROTO_RSVP = 0x2e - IPPROTO_RVD = 0x42 - IPPROTO_SATEXPAK = 0x40 - IPPROTO_SATMON = 0x45 - IPPROTO_SCCSP = 0x60 - IPPROTO_SCTP = 0x84 - IPPROTO_SDRP = 0x2a - IPPROTO_SEP = 0x21 - IPPROTO_SRPC = 0x5a - IPPROTO_ST = 0x7 - IPPROTO_SVMTP = 0x52 - IPPROTO_SWIPE = 0x35 - IPPROTO_TCF = 0x57 - IPPROTO_TCP = 0x6 - IPPROTO_TP = 0x1d - IPPROTO_TPXX = 0x27 - IPPROTO_TRUNK1 = 0x17 - IPPROTO_TRUNK2 = 0x18 - IPPROTO_TTP = 0x54 - IPPROTO_UDP = 0x11 - IPPROTO_VINES = 0x53 - IPPROTO_VISA = 0x46 - IPPROTO_VMTP = 0x51 - IPPROTO_WBEXPAK = 0x4f - IPPROTO_WBMON = 0x4e - IPPROTO_WSN = 0x4a - IPPROTO_XNET = 0xf - IPPROTO_XTP = 0x24 - IPV6_2292DSTOPTS = 0x17 - IPV6_2292HOPLIMIT = 0x14 - IPV6_2292HOPOPTS = 0x16 - IPV6_2292NEXTHOP = 0x15 - IPV6_2292PKTINFO = 0x13 - IPV6_2292PKTOPTIONS = 0x19 - IPV6_2292RTHDR = 0x18 - IPV6_3542DSTOPTS = 0x32 - IPV6_3542HOPLIMIT = 0x2f - IPV6_3542HOPOPTS = 0x31 - IPV6_3542NEXTHOP = 0x30 - IPV6_3542PKTINFO = 0x2e - IPV6_3542RTHDR = 0x33 - IPV6_ADDR_MC_FLAGS_PREFIX = 0x20 - IPV6_ADDR_MC_FLAGS_TRANSIENT = 0x10 - IPV6_ADDR_MC_FLAGS_UNICAST_BASED = 0x30 - IPV6_AUTOFLOWLABEL = 0x3b - IPV6_BINDV6ONLY = 0x1b - IPV6_BOUND_IF = 0x7d - IPV6_CHECKSUM = 0x1a - IPV6_DEFAULT_MULTICAST_HOPS = 0x1 - IPV6_DEFAULT_MULTICAST_LOOP = 0x1 - IPV6_DEFHLIM = 0x40 - IPV6_DONTFRAG = 0x3e - IPV6_DSTOPTS = 0x32 - IPV6_FAITH = 0x1d - IPV6_FLOWINFO_MASK = 0xffffff0f - IPV6_FLOWLABEL_MASK = 0xffff0f00 - IPV6_FLOW_ECN_MASK = 0x3000 - IPV6_FRAGTTL = 0x3c - IPV6_FW_ADD = 0x1e - IPV6_FW_DEL = 0x1f - IPV6_FW_FLUSH = 0x20 - IPV6_FW_GET = 0x22 - IPV6_FW_ZERO = 0x21 - IPV6_HLIMDEC = 0x1 - IPV6_HOPLIMIT = 0x2f - IPV6_HOPOPTS = 0x31 - IPV6_IPSEC_POLICY = 0x1c - IPV6_JOIN_GROUP = 0xc - IPV6_LEAVE_GROUP = 0xd - IPV6_MAXHLIM = 0xff - IPV6_MAXOPTHDR = 0x800 - IPV6_MAXPACKET = 0xffff - IPV6_MAX_GROUP_SRC_FILTER = 0x200 - IPV6_MAX_MEMBERSHIPS = 0xfff - IPV6_MAX_SOCK_SRC_FILTER = 0x80 - IPV6_MIN_MEMBERSHIPS = 0x1f - IPV6_MMTU = 0x500 - IPV6_MSFILTER = 0x4a - IPV6_MULTICAST_HOPS = 0xa - IPV6_MULTICAST_IF = 0x9 - IPV6_MULTICAST_LOOP = 0xb - IPV6_NEXTHOP = 0x30 - IPV6_PATHMTU = 0x2c - IPV6_PKTINFO = 0x2e - IPV6_PORTRANGE = 0xe - IPV6_PORTRANGE_DEFAULT = 0x0 - IPV6_PORTRANGE_HIGH = 0x1 - IPV6_PORTRANGE_LOW = 0x2 - IPV6_PREFER_TEMPADDR = 0x3f - IPV6_RECVDSTOPTS = 0x28 - IPV6_RECVHOPLIMIT = 0x25 - IPV6_RECVHOPOPTS = 0x27 - IPV6_RECVPATHMTU = 0x2b - IPV6_RECVPKTINFO = 0x3d - IPV6_RECVRTHDR = 0x26 - IPV6_RECVTCLASS = 0x23 - IPV6_RTHDR = 0x33 - IPV6_RTHDRDSTOPTS = 0x39 - IPV6_RTHDR_LOOSE = 0x0 - IPV6_RTHDR_STRICT = 0x1 - IPV6_RTHDR_TYPE_0 = 0x0 - IPV6_SOCKOPT_RESERVED1 = 0x3 - IPV6_TCLASS = 0x24 - IPV6_UNICAST_HOPS = 0x4 - IPV6_USE_MIN_MTU = 0x2a - IPV6_V6ONLY = 0x1b - IPV6_VERSION = 0x60 - IPV6_VERSION_MASK = 0xf0 - IP_ADD_MEMBERSHIP = 0xc - IP_ADD_SOURCE_MEMBERSHIP = 0x46 - IP_BLOCK_SOURCE = 0x48 - IP_BOUND_IF = 0x19 - IP_DEFAULT_MULTICAST_LOOP = 0x1 - IP_DEFAULT_MULTICAST_TTL = 0x1 - IP_DF = 0x4000 - IP_DONTFRAG = 0x1c - IP_DROP_MEMBERSHIP = 0xd - IP_DROP_SOURCE_MEMBERSHIP = 0x47 - IP_DUMMYNET_CONFIGURE = 0x3c - IP_DUMMYNET_DEL = 0x3d - IP_DUMMYNET_FLUSH = 0x3e - IP_DUMMYNET_GET = 0x40 - IP_FAITH = 0x16 - IP_FW_ADD = 0x28 - IP_FW_DEL = 0x29 - IP_FW_FLUSH = 0x2a - IP_FW_GET = 0x2c - IP_FW_RESETLOG = 0x2d - IP_FW_ZERO = 0x2b - IP_HDRINCL = 0x2 - IP_IPSEC_POLICY = 0x15 - IP_MAXPACKET = 0xffff - IP_MAX_GROUP_SRC_FILTER = 0x200 - IP_MAX_MEMBERSHIPS = 0xfff - IP_MAX_SOCK_MUTE_FILTER = 0x80 - IP_MAX_SOCK_SRC_FILTER = 0x80 - IP_MF = 0x2000 - IP_MIN_MEMBERSHIPS = 0x1f - IP_MSFILTER = 0x4a - IP_MSS = 0x240 - IP_MULTICAST_IF = 0x9 - IP_MULTICAST_IFINDEX = 0x42 - IP_MULTICAST_LOOP = 0xb - IP_MULTICAST_TTL = 0xa - IP_MULTICAST_VIF = 0xe - IP_NAT__XXX = 0x37 - IP_OFFMASK = 0x1fff - IP_OLD_FW_ADD = 0x32 - IP_OLD_FW_DEL = 0x33 - IP_OLD_FW_FLUSH = 0x34 - IP_OLD_FW_GET = 0x36 - IP_OLD_FW_RESETLOG = 0x38 - IP_OLD_FW_ZERO = 0x35 - IP_OPTIONS = 0x1 - IP_PKTINFO = 0x1a - IP_PORTRANGE = 0x13 - IP_PORTRANGE_DEFAULT = 0x0 - IP_PORTRANGE_HIGH = 0x1 - IP_PORTRANGE_LOW = 0x2 - IP_RECVDSTADDR = 0x7 - IP_RECVIF = 0x14 - IP_RECVOPTS = 0x5 - IP_RECVPKTINFO = 0x1a - IP_RECVRETOPTS = 0x6 - IP_RECVTOS = 0x1b - IP_RECVTTL = 0x18 - IP_RETOPTS = 0x8 - IP_RF = 0x8000 - IP_RSVP_OFF = 0x10 - IP_RSVP_ON = 0xf - IP_RSVP_VIF_OFF = 0x12 - IP_RSVP_VIF_ON = 0x11 - IP_STRIPHDR = 0x17 - IP_TOS = 0x3 - IP_TRAFFIC_MGT_BACKGROUND = 0x41 - IP_TTL = 0x4 - IP_UNBLOCK_SOURCE = 0x49 - ISIG = 0x80 - ISTRIP = 0x20 - IUTF8 = 0x4000 - IXANY = 0x800 - IXOFF = 0x400 - IXON = 0x200 - KERN_HOSTNAME = 0xa - KERN_OSRELEASE = 0x2 - KERN_OSTYPE = 0x1 - KERN_VERSION = 0x4 - LOCAL_PEERCRED = 0x1 - LOCAL_PEEREPID = 0x3 - LOCAL_PEEREUUID = 0x5 - LOCAL_PEERPID = 0x2 - LOCAL_PEERTOKEN = 0x6 - LOCAL_PEERUUID = 0x4 - LOCK_EX = 0x2 - LOCK_NB = 0x4 - LOCK_SH = 0x1 - LOCK_UN = 0x8 - MADV_CAN_REUSE = 0x9 - MADV_DONTNEED = 0x4 - MADV_FREE = 0x5 - MADV_FREE_REUSABLE = 0x7 - MADV_FREE_REUSE = 0x8 - MADV_NORMAL = 0x0 - MADV_PAGEOUT = 0xa - MADV_RANDOM = 0x1 - MADV_SEQUENTIAL = 0x2 - MADV_WILLNEED = 0x3 - MADV_ZERO_WIRED_PAGES = 0x6 - MAP_32BIT = 0x8000 - MAP_ANON = 0x1000 - MAP_ANONYMOUS = 0x1000 - MAP_COPY = 0x2 - MAP_FILE = 0x0 - MAP_FIXED = 0x10 - MAP_HASSEMAPHORE = 0x200 - MAP_JIT = 0x800 - MAP_NOCACHE = 0x400 - MAP_NOEXTEND = 0x100 - MAP_NORESERVE = 0x40 - MAP_PRIVATE = 0x2 - MAP_RENAME = 0x20 - MAP_RESERVED0080 = 0x80 - MAP_RESILIENT_CODESIGN = 0x2000 - MAP_RESILIENT_MEDIA = 0x4000 - MAP_SHARED = 0x1 - MAP_TRANSLATED_ALLOW_EXECUTE = 0x20000 - MAP_UNIX03 = 0x40000 - MCAST_BLOCK_SOURCE = 0x54 - MCAST_EXCLUDE = 0x2 - MCAST_INCLUDE = 0x1 - MCAST_JOIN_GROUP = 0x50 - MCAST_JOIN_SOURCE_GROUP = 0x52 - MCAST_LEAVE_GROUP = 0x51 - MCAST_LEAVE_SOURCE_GROUP = 0x53 - MCAST_UNBLOCK_SOURCE = 0x55 - MCAST_UNDEFINED = 0x0 - MCL_CURRENT = 0x1 - MCL_FUTURE = 0x2 - MNT_ASYNC = 0x40 - MNT_AUTOMOUNTED = 0x400000 - MNT_CMDFLAGS = 0xf0000 - MNT_CPROTECT = 0x80 - MNT_DEFWRITE = 0x2000000 - MNT_DONTBROWSE = 0x100000 - MNT_DOVOLFS = 0x8000 - MNT_DWAIT = 0x4 - MNT_EXPORTED = 0x100 - MNT_EXT_ROOT_DATA_VOL = 0x1 - MNT_FORCE = 0x80000 - MNT_IGNORE_OWNERSHIP = 0x200000 - MNT_JOURNALED = 0x800000 - MNT_LOCAL = 0x1000 - MNT_MULTILABEL = 0x4000000 - MNT_NOATIME = 0x10000000 - MNT_NOBLOCK = 0x20000 - MNT_NODEV = 0x10 - MNT_NOEXEC = 0x4 - MNT_NOSUID = 0x8 - MNT_NOUSERXATTR = 0x1000000 - MNT_NOWAIT = 0x2 - MNT_QUARANTINE = 0x400 - MNT_QUOTA = 0x2000 - MNT_RDONLY = 0x1 - MNT_RELOAD = 0x40000 - MNT_REMOVABLE = 0x200 - MNT_ROOTFS = 0x4000 - MNT_SNAPSHOT = 0x40000000 - MNT_STRICTATIME = 0x80000000 - MNT_SYNCHRONOUS = 0x2 - MNT_UNION = 0x20 - MNT_UNKNOWNPERMISSIONS = 0x200000 - MNT_UPDATE = 0x10000 - MNT_VISFLAGMASK = 0xd7f0f7ff - MNT_WAIT = 0x1 - MSG_CTRUNC = 0x20 - MSG_DONTROUTE = 0x4 - MSG_DONTWAIT = 0x80 - MSG_EOF = 0x100 - MSG_EOR = 0x8 - MSG_FLUSH = 0x400 - MSG_HAVEMORE = 0x2000 - MSG_HOLD = 0x800 - MSG_NEEDSA = 0x10000 - MSG_NOSIGNAL = 0x80000 - MSG_OOB = 0x1 - MSG_PEEK = 0x2 - MSG_RCVMORE = 0x4000 - MSG_SEND = 0x1000 - MSG_TRUNC = 0x10 - MSG_WAITALL = 0x40 - MSG_WAITSTREAM = 0x200 - MS_ASYNC = 0x1 - MS_DEACTIVATE = 0x8 - MS_INVALIDATE = 0x2 - MS_KILLPAGES = 0x4 - MS_SYNC = 0x10 - NAME_MAX = 0xff - NET_RT_DUMP = 0x1 - NET_RT_DUMP2 = 0x7 - NET_RT_FLAGS = 0x2 - NET_RT_FLAGS_PRIV = 0xa - NET_RT_IFLIST = 0x3 - NET_RT_IFLIST2 = 0x6 - NET_RT_MAXID = 0xb - NET_RT_STAT = 0x4 - NET_RT_TRASH = 0x5 - NFDBITS = 0x20 - NL0 = 0x0 - NL1 = 0x100 - NL2 = 0x200 - NL3 = 0x300 - NLDLY = 0x300 - NOFLSH = 0x80000000 - NOKERNINFO = 0x2000000 - NOTE_ABSOLUTE = 0x8 - NOTE_ATTRIB = 0x8 - NOTE_BACKGROUND = 0x40 - NOTE_CHILD = 0x4 - NOTE_CRITICAL = 0x20 - NOTE_DELETE = 0x1 - NOTE_EXEC = 0x20000000 - NOTE_EXIT = 0x80000000 - NOTE_EXITSTATUS = 0x4000000 - NOTE_EXIT_CSERROR = 0x40000 - NOTE_EXIT_DECRYPTFAIL = 0x10000 - NOTE_EXIT_DETAIL = 0x2000000 - NOTE_EXIT_DETAIL_MASK = 0x70000 - NOTE_EXIT_MEMORY = 0x20000 - NOTE_EXIT_REPARENTED = 0x80000 - NOTE_EXTEND = 0x4 - NOTE_FFAND = 0x40000000 - NOTE_FFCOPY = 0xc0000000 - NOTE_FFCTRLMASK = 0xc0000000 - NOTE_FFLAGSMASK = 0xffffff - NOTE_FFNOP = 0x0 - NOTE_FFOR = 0x80000000 - NOTE_FORK = 0x40000000 - NOTE_FUNLOCK = 0x100 - NOTE_LEEWAY = 0x10 - NOTE_LINK = 0x10 - NOTE_LOWAT = 0x1 - NOTE_MACHTIME = 0x100 - NOTE_MACH_CONTINUOUS_TIME = 0x80 - NOTE_NONE = 0x80 - NOTE_NSECONDS = 0x4 - NOTE_OOB = 0x2 - NOTE_PCTRLMASK = -0x100000 - NOTE_PDATAMASK = 0xfffff - NOTE_REAP = 0x10000000 - NOTE_RENAME = 0x20 - NOTE_REVOKE = 0x40 - NOTE_SECONDS = 0x1 - NOTE_SIGNAL = 0x8000000 - NOTE_TRACK = 0x1 - NOTE_TRACKERR = 0x2 - NOTE_TRIGGER = 0x1000000 - NOTE_USECONDS = 0x2 - NOTE_VM_ERROR = 0x10000000 - NOTE_VM_PRESSURE = 0x80000000 - NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000 - NOTE_VM_PRESSURE_TERMINATE = 0x40000000 - NOTE_WRITE = 0x2 - OCRNL = 0x10 - OFDEL = 0x20000 - OFILL = 0x80 - ONLCR = 0x2 - ONLRET = 0x40 - ONOCR = 0x20 - ONOEOT = 0x8 - OPOST = 0x1 - OXTABS = 0x4 - O_ACCMODE = 0x3 - O_ALERT = 0x20000000 - O_APPEND = 0x8 - O_ASYNC = 0x40 - O_CLOEXEC = 0x1000000 - O_CREAT = 0x200 - O_DIRECTORY = 0x100000 - O_DP_GETRAWENCRYPTED = 0x1 - O_DP_GETRAWUNENCRYPTED = 0x2 - O_DSYNC = 0x400000 - O_EVTONLY = 0x8000 - O_EXCL = 0x800 - O_EXLOCK = 0x20 - O_FSYNC = 0x80 - O_NDELAY = 0x4 - O_NOCTTY = 0x20000 - O_NOFOLLOW = 0x100 - O_NOFOLLOW_ANY = 0x20000000 - O_NONBLOCK = 0x4 - O_POPUP = 0x80000000 - O_RDONLY = 0x0 - O_RDWR = 0x2 - O_SHLOCK = 0x10 - O_SYMLINK = 0x200000 - O_SYNC = 0x80 - O_TRUNC = 0x400 - O_WRONLY = 0x1 - PARENB = 0x1000 - PARMRK = 0x8 - PARODD = 0x2000 - PENDIN = 0x20000000 - PRIO_PGRP = 0x1 - PRIO_PROCESS = 0x0 - PRIO_USER = 0x2 - PROT_EXEC = 0x4 - PROT_NONE = 0x0 - PROT_READ = 0x1 - PROT_WRITE = 0x2 - PT_ATTACH = 0xa - PT_ATTACHEXC = 0xe - PT_CONTINUE = 0x7 - PT_DENY_ATTACH = 0x1f - PT_DETACH = 0xb - PT_FIRSTMACH = 0x20 - PT_FORCEQUOTA = 0x1e - PT_KILL = 0x8 - PT_READ_D = 0x2 - PT_READ_I = 0x1 - PT_READ_U = 0x3 - PT_SIGEXC = 0xc - PT_STEP = 0x9 - PT_THUPDATE = 0xd - PT_TRACE_ME = 0x0 - PT_WRITE_D = 0x5 - PT_WRITE_I = 0x4 - PT_WRITE_U = 0x6 - RLIMIT_AS = 0x5 - RLIMIT_CORE = 0x4 - RLIMIT_CPU = 0x0 - RLIMIT_CPU_USAGE_MONITOR = 0x2 - RLIMIT_DATA = 0x2 - RLIMIT_FSIZE = 0x1 - RLIMIT_MEMLOCK = 0x6 - RLIMIT_NOFILE = 0x8 - RLIMIT_NPROC = 0x7 - RLIMIT_RSS = 0x5 - RLIMIT_STACK = 0x3 - RLIM_INFINITY = 0x7fffffffffffffff - RTAX_AUTHOR = 0x6 - RTAX_BRD = 0x7 - RTAX_DST = 0x0 - RTAX_GATEWAY = 0x1 - RTAX_GENMASK = 0x3 - RTAX_IFA = 0x5 - RTAX_IFP = 0x4 - RTAX_MAX = 0x8 - RTAX_NETMASK = 0x2 - RTA_AUTHOR = 0x40 - RTA_BRD = 0x80 - RTA_DST = 0x1 - RTA_GATEWAY = 0x2 - RTA_GENMASK = 0x8 - RTA_IFA = 0x20 - RTA_IFP = 0x10 - RTA_NETMASK = 0x4 - RTF_BLACKHOLE = 0x1000 - RTF_BROADCAST = 0x400000 - RTF_CLONING = 0x100 - RTF_CONDEMNED = 0x2000000 - RTF_DEAD = 0x20000000 - RTF_DELCLONE = 0x80 - RTF_DONE = 0x40 - RTF_DYNAMIC = 0x10 - RTF_GATEWAY = 0x2 - RTF_GLOBAL = 0x40000000 - RTF_HOST = 0x4 - RTF_IFREF = 0x4000000 - RTF_IFSCOPE = 0x1000000 - RTF_LLDATA = 0x400 - RTF_LLINFO = 0x400 - RTF_LOCAL = 0x200000 - RTF_MODIFIED = 0x20 - RTF_MULTICAST = 0x800000 - RTF_NOIFREF = 0x2000 - RTF_PINNED = 0x100000 - RTF_PRCLONING = 0x10000 - RTF_PROTO1 = 0x8000 - RTF_PROTO2 = 0x4000 - RTF_PROTO3 = 0x40000 - RTF_PROXY = 0x8000000 - RTF_REJECT = 0x8 - RTF_ROUTER = 0x10000000 - RTF_STATIC = 0x800 - RTF_UP = 0x1 - RTF_WASCLONED = 0x20000 - RTF_XRESOLVE = 0x200 - RTM_ADD = 0x1 - RTM_CHANGE = 0x3 - RTM_DELADDR = 0xd - RTM_DELETE = 0x2 - RTM_DELMADDR = 0x10 - RTM_GET = 0x4 - RTM_GET2 = 0x14 - RTM_IFINFO = 0xe - RTM_IFINFO2 = 0x12 - RTM_LOCK = 0x8 - RTM_LOSING = 0x5 - RTM_MISS = 0x7 - RTM_NEWADDR = 0xc - RTM_NEWMADDR = 0xf - RTM_NEWMADDR2 = 0x13 - RTM_OLDADD = 0x9 - RTM_OLDDEL = 0xa - RTM_REDIRECT = 0x6 - RTM_RESOLVE = 0xb - RTM_RTTUNIT = 0xf4240 - RTM_VERSION = 0x5 - RTV_EXPIRE = 0x4 - RTV_HOPCOUNT = 0x2 - RTV_MTU = 0x1 - RTV_RPIPE = 0x8 - RTV_RTT = 0x40 - RTV_RTTVAR = 0x80 - RTV_SPIPE = 0x10 - RTV_SSTHRESH = 0x20 - RUSAGE_CHILDREN = -0x1 - RUSAGE_SELF = 0x0 - SCM_CREDS = 0x3 - SCM_RIGHTS = 0x1 - SCM_TIMESTAMP = 0x2 - SCM_TIMESTAMP_MONOTONIC = 0x4 - SEEK_CUR = 0x1 - SEEK_DATA = 0x4 - SEEK_END = 0x2 - SEEK_HOLE = 0x3 - SEEK_SET = 0x0 - SHUT_RD = 0x0 - SHUT_RDWR = 0x2 - SHUT_WR = 0x1 - SIOCADDMULTI = 0x80206931 - SIOCAIFADDR = 0x8040691a - SIOCARPIPLL = 0xc0206928 - SIOCATMARK = 0x40047307 - SIOCAUTOADDR = 0xc0206926 - SIOCAUTONETMASK = 0x80206927 - SIOCDELMULTI = 0x80206932 - SIOCDIFADDR = 0x80206919 - SIOCDIFPHYADDR = 0x80206941 - SIOCGDRVSPEC = 0xc028697b - SIOCGETVLAN = 0xc020697f - SIOCGHIWAT = 0x40047301 - SIOCGIF6LOWPAN = 0xc02069c5 - SIOCGIFADDR = 0xc0206921 - SIOCGIFALTMTU = 0xc0206948 - SIOCGIFASYNCMAP = 0xc020697c - SIOCGIFBOND = 0xc0206947 - SIOCGIFBRDADDR = 0xc0206923 - SIOCGIFCAP = 0xc020695b - SIOCGIFCONF = 0xc00c6924 - SIOCGIFDEVMTU = 0xc0206944 - SIOCGIFDSTADDR = 0xc0206922 - SIOCGIFFLAGS = 0xc0206911 - SIOCGIFFUNCTIONALTYPE = 0xc02069ad - SIOCGIFGENERIC = 0xc020693a - SIOCGIFKPI = 0xc0206987 - SIOCGIFMAC = 0xc0206982 - SIOCGIFMEDIA = 0xc02c6938 - SIOCGIFMETRIC = 0xc0206917 - SIOCGIFMTU = 0xc0206933 - SIOCGIFNETMASK = 0xc0206925 - SIOCGIFPDSTADDR = 0xc0206940 - SIOCGIFPHYS = 0xc0206935 - SIOCGIFPSRCADDR = 0xc020693f - SIOCGIFSTATUS = 0xc331693d - SIOCGIFVLAN = 0xc020697f - SIOCGIFWAKEFLAGS = 0xc0206988 - SIOCGIFXMEDIA = 0xc02c6948 - SIOCGLOWAT = 0x40047303 - SIOCGPGRP = 0x40047309 - SIOCIFCREATE = 0xc0206978 - SIOCIFCREATE2 = 0xc020697a - SIOCIFDESTROY = 0x80206979 - SIOCIFGCLONERS = 0xc0106981 - SIOCRSLVMULTI = 0xc010693b - SIOCSDRVSPEC = 0x8028697b - SIOCSETVLAN = 0x8020697e - SIOCSHIWAT = 0x80047300 - SIOCSIF6LOWPAN = 0x802069c4 - SIOCSIFADDR = 0x8020690c - SIOCSIFALTMTU = 0x80206945 - SIOCSIFASYNCMAP = 0x8020697d - SIOCSIFBOND = 0x80206946 - SIOCSIFBRDADDR = 0x80206913 - SIOCSIFCAP = 0x8020695a - SIOCSIFDSTADDR = 0x8020690e - SIOCSIFFLAGS = 0x80206910 - SIOCSIFGENERIC = 0x80206939 - SIOCSIFKPI = 0x80206986 - SIOCSIFLLADDR = 0x8020693c - SIOCSIFMAC = 0x80206983 - SIOCSIFMEDIA = 0xc0206937 - SIOCSIFMETRIC = 0x80206918 - SIOCSIFMTU = 0x80206934 - SIOCSIFNETMASK = 0x80206916 - SIOCSIFPHYADDR = 0x8040693e - SIOCSIFPHYS = 0x80206936 - SIOCSIFVLAN = 0x8020697e - SIOCSLOWAT = 0x80047302 - SIOCSPGRP = 0x80047308 - SOCK_DGRAM = 0x2 - SOCK_MAXADDRLEN = 0xff - SOCK_RAW = 0x3 - SOCK_RDM = 0x4 - SOCK_SEQPACKET = 0x5 - SOCK_STREAM = 0x1 - SOL_LOCAL = 0x0 - SOL_SOCKET = 0xffff - SOMAXCONN = 0x80 - SO_ACCEPTCONN = 0x2 - SO_BROADCAST = 0x20 - SO_DEBUG = 0x1 - SO_DONTROUTE = 0x10 - SO_DONTTRUNC = 0x2000 - SO_ERROR = 0x1007 - SO_KEEPALIVE = 0x8 - SO_LABEL = 0x1010 - SO_LINGER = 0x80 - SO_LINGER_SEC = 0x1080 - SO_NETSVC_MARKING_LEVEL = 0x1119 - SO_NET_SERVICE_TYPE = 0x1116 - SO_NKE = 0x1021 - SO_NOADDRERR = 0x1023 - SO_NOSIGPIPE = 0x1022 - SO_NOTIFYCONFLICT = 0x1026 - SO_NP_EXTENSIONS = 0x1083 - SO_NREAD = 0x1020 - SO_NUMRCVPKT = 0x1112 - SO_NWRITE = 0x1024 - SO_OOBINLINE = 0x100 - SO_PEERLABEL = 0x1011 - SO_RANDOMPORT = 0x1082 - SO_RCVBUF = 0x1002 - SO_RCVLOWAT = 0x1004 - SO_RCVTIMEO = 0x1006 - SO_REUSEADDR = 0x4 - SO_REUSEPORT = 0x200 - SO_REUSESHAREUID = 0x1025 - SO_SNDBUF = 0x1001 - SO_SNDLOWAT = 0x1003 - SO_SNDTIMEO = 0x1005 - SO_TIMESTAMP = 0x400 - SO_TIMESTAMP_MONOTONIC = 0x800 - SO_TYPE = 0x1008 - SO_UPCALLCLOSEWAIT = 0x1027 - SO_USELOOPBACK = 0x40 - SO_WANTMORE = 0x4000 - SO_WANTOOBFLAG = 0x8000 - S_IEXEC = 0x40 - S_IFBLK = 0x6000 - S_IFCHR = 0x2000 - S_IFDIR = 0x4000 - S_IFIFO = 0x1000 - S_IFLNK = 0xa000 - S_IFMT = 0xf000 - S_IFREG = 0x8000 - S_IFSOCK = 0xc000 - S_IFWHT = 0xe000 - S_IREAD = 0x100 - S_IRGRP = 0x20 - S_IROTH = 0x4 - S_IRUSR = 0x100 - S_IRWXG = 0x38 - S_IRWXO = 0x7 - S_IRWXU = 0x1c0 - S_ISGID = 0x400 - S_ISTXT = 0x200 - S_ISUID = 0x800 - S_ISVTX = 0x200 - S_IWGRP = 0x10 - S_IWOTH = 0x2 - S_IWRITE = 0x80 - S_IWUSR = 0x80 - S_IXGRP = 0x8 - S_IXOTH = 0x1 - S_IXUSR = 0x40 - TAB0 = 0x0 - TAB1 = 0x400 - TAB2 = 0x800 - TAB3 = 0x4 - TABDLY = 0xc04 - TCIFLUSH = 0x1 - TCIOFF = 0x3 - TCIOFLUSH = 0x3 - TCION = 0x4 - TCOFLUSH = 0x2 - TCOOFF = 0x1 - TCOON = 0x2 - TCP_CONNECTIONTIMEOUT = 0x20 - TCP_CONNECTION_INFO = 0x106 - TCP_ENABLE_ECN = 0x104 - TCP_FASTOPEN = 0x105 - TCP_KEEPALIVE = 0x10 - TCP_KEEPCNT = 0x102 - TCP_KEEPINTVL = 0x101 - TCP_MAXHLEN = 0x3c - TCP_MAXOLEN = 0x28 - TCP_MAXSEG = 0x2 - TCP_MAXWIN = 0xffff - TCP_MAX_SACK = 0x4 - TCP_MAX_WINSHIFT = 0xe - TCP_MINMSS = 0xd8 - TCP_MSS = 0x200 - TCP_NODELAY = 0x1 - TCP_NOOPT = 0x8 - TCP_NOPUSH = 0x4 - TCP_NOTSENT_LOWAT = 0x201 - TCP_RXT_CONNDROPTIME = 0x80 - TCP_RXT_FINDROP = 0x100 - TCP_SENDMOREACKS = 0x103 - TCSAFLUSH = 0x2 - TIOCCBRK = 0x2000747a - TIOCCDTR = 0x20007478 - TIOCCONS = 0x80047462 - TIOCDCDTIMESTAMP = 0x40107458 - TIOCDRAIN = 0x2000745e - TIOCDSIMICROCODE = 0x20007455 - TIOCEXCL = 0x2000740d - TIOCEXT = 0x80047460 - TIOCFLUSH = 0x80047410 - TIOCGDRAINWAIT = 0x40047456 - TIOCGETA = 0x40487413 - TIOCGETD = 0x4004741a - TIOCGPGRP = 0x40047477 - TIOCGWINSZ = 0x40087468 - TIOCIXOFF = 0x20007480 - TIOCIXON = 0x20007481 - TIOCMBIC = 0x8004746b - TIOCMBIS = 0x8004746c - TIOCMGDTRWAIT = 0x4004745a - TIOCMGET = 0x4004746a - TIOCMODG = 0x40047403 - TIOCMODS = 0x80047404 - TIOCMSDTRWAIT = 0x8004745b - TIOCMSET = 0x8004746d - TIOCM_CAR = 0x40 - TIOCM_CD = 0x40 - TIOCM_CTS = 0x20 - TIOCM_DSR = 0x100 - TIOCM_DTR = 0x2 - TIOCM_LE = 0x1 - TIOCM_RI = 0x80 - TIOCM_RNG = 0x80 - TIOCM_RTS = 0x4 - TIOCM_SR = 0x10 - TIOCM_ST = 0x8 - TIOCNOTTY = 0x20007471 - TIOCNXCL = 0x2000740e - TIOCOUTQ = 0x40047473 - TIOCPKT = 0x80047470 - TIOCPKT_DATA = 0x0 - TIOCPKT_DOSTOP = 0x20 - TIOCPKT_FLUSHREAD = 0x1 - TIOCPKT_FLUSHWRITE = 0x2 - TIOCPKT_IOCTL = 0x40 - TIOCPKT_NOSTOP = 0x10 - TIOCPKT_START = 0x8 - TIOCPKT_STOP = 0x4 - TIOCPTYGNAME = 0x40807453 - TIOCPTYGRANT = 0x20007454 - TIOCPTYUNLK = 0x20007452 - TIOCREMOTE = 0x80047469 - TIOCSBRK = 0x2000747b - TIOCSCONS = 0x20007463 - TIOCSCTTY = 0x20007461 - TIOCSDRAINWAIT = 0x80047457 - TIOCSDTR = 0x20007479 - TIOCSETA = 0x80487414 - TIOCSETAF = 0x80487416 - TIOCSETAW = 0x80487415 - TIOCSETD = 0x8004741b - TIOCSIG = 0x2000745f - TIOCSPGRP = 0x80047476 - TIOCSTART = 0x2000746e - TIOCSTAT = 0x20007465 - TIOCSTI = 0x80017472 - TIOCSTOP = 0x2000746f - TIOCSWINSZ = 0x80087467 - TIOCTIMESTAMP = 0x40107459 - TIOCUCNTL = 0x80047466 - TOSTOP = 0x400000 - VDISCARD = 0xf - VDSUSP = 0xb - VEOF = 0x0 - VEOL = 0x1 - VEOL2 = 0x2 - VERASE = 0x3 - VINTR = 0x8 - VKILL = 0x5 - VLNEXT = 0xe - VMIN = 0x10 - VM_LOADAVG = 0x2 - VM_MACHFACTOR = 0x4 - VM_MAXID = 0x6 - VM_METER = 0x1 - VM_SWAPUSAGE = 0x5 - VQUIT = 0x9 - VREPRINT = 0x6 - VSTART = 0xc - VSTATUS = 0x12 - VSTOP = 0xd - VSUSP = 0xa - VT0 = 0x0 - VT1 = 0x10000 - VTDLY = 0x10000 - VTIME = 0x11 - VWERASE = 0x4 - WCONTINUED = 0x10 - WCOREFLAG = 0x80 - WEXITED = 0x4 - WNOHANG = 0x1 - WNOWAIT = 0x20 - WORDSIZE = 0x40 - WSTOPPED = 0x8 - WUNTRACED = 0x2 - XATTR_CREATE = 0x2 - XATTR_NODEFAULT = 0x10 - XATTR_NOFOLLOW = 0x1 - XATTR_NOSECURITY = 0x8 - XATTR_REPLACE = 0x4 - XATTR_SHOWCOMPRESSION = 0x20 + AF_APPLETALK = 0x10 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1c + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1e + AF_IPX = 0x17 + AF_ISDN = 0x1c + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_NATM = 0x1f + AF_NDRV = 0x1b + AF_NETBIOS = 0x21 + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PPP = 0x22 + AF_PUP = 0x4 + AF_RESERVED_36 = 0x24 + AF_ROUTE = 0x11 + AF_SIP = 0x18 + AF_SNA = 0xb + AF_SYSTEM = 0x20 + AF_SYS_CONTROL = 0x2 + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_UTUN = 0x26 + AF_VSOCK = 0x28 + ALTWERASE = 0x200 + ATTR_BIT_MAP_COUNT = 0x5 + ATTR_CMN_ACCESSMASK = 0x20000 + ATTR_CMN_ACCTIME = 0x1000 + ATTR_CMN_ADDEDTIME = 0x10000000 + ATTR_CMN_BKUPTIME = 0x2000 + ATTR_CMN_CHGTIME = 0x800 + ATTR_CMN_CRTIME = 0x200 + ATTR_CMN_DATA_PROTECT_FLAGS = 0x40000000 + ATTR_CMN_DEVID = 0x2 + ATTR_CMN_DOCUMENT_ID = 0x100000 + ATTR_CMN_ERROR = 0x20000000 + ATTR_CMN_EXTENDED_SECURITY = 0x400000 + ATTR_CMN_FILEID = 0x2000000 + ATTR_CMN_FLAGS = 0x40000 + ATTR_CMN_FNDRINFO = 0x4000 + ATTR_CMN_FSID = 0x4 + ATTR_CMN_FULLPATH = 0x8000000 + ATTR_CMN_GEN_COUNT = 0x80000 + ATTR_CMN_GRPID = 0x10000 + ATTR_CMN_GRPUUID = 0x1000000 + ATTR_CMN_MODTIME = 0x400 + ATTR_CMN_NAME = 0x1 + ATTR_CMN_NAMEDATTRCOUNT = 0x80000 + ATTR_CMN_NAMEDATTRLIST = 0x100000 + ATTR_CMN_OBJID = 0x20 + ATTR_CMN_OBJPERMANENTID = 0x40 + ATTR_CMN_OBJTAG = 0x10 + ATTR_CMN_OBJTYPE = 0x8 + ATTR_CMN_OWNERID = 0x8000 + ATTR_CMN_PARENTID = 0x4000000 + ATTR_CMN_PAROBJID = 0x80 + ATTR_CMN_RETURNED_ATTRS = 0x80000000 + ATTR_CMN_SCRIPT = 0x100 + ATTR_CMN_SETMASK = 0x51c7ff00 + ATTR_CMN_USERACCESS = 0x200000 + ATTR_CMN_UUID = 0x800000 + ATTR_CMN_VALIDMASK = 0xffffffff + ATTR_CMN_VOLSETMASK = 0x6700 + ATTR_FILE_ALLOCSIZE = 0x4 + ATTR_FILE_CLUMPSIZE = 0x10 + ATTR_FILE_DATAALLOCSIZE = 0x400 + ATTR_FILE_DATAEXTENTS = 0x800 + ATTR_FILE_DATALENGTH = 0x200 + ATTR_FILE_DEVTYPE = 0x20 + ATTR_FILE_FILETYPE = 0x40 + ATTR_FILE_FORKCOUNT = 0x80 + ATTR_FILE_FORKLIST = 0x100 + ATTR_FILE_IOBLOCKSIZE = 0x8 + ATTR_FILE_LINKCOUNT = 0x1 + ATTR_FILE_RSRCALLOCSIZE = 0x2000 + ATTR_FILE_RSRCEXTENTS = 0x4000 + ATTR_FILE_RSRCLENGTH = 0x1000 + ATTR_FILE_SETMASK = 0x20 + ATTR_FILE_TOTALSIZE = 0x2 + ATTR_FILE_VALIDMASK = 0x37ff + ATTR_VOL_ALLOCATIONCLUMP = 0x40 + ATTR_VOL_ATTRIBUTES = 0x40000000 + ATTR_VOL_CAPABILITIES = 0x20000 + ATTR_VOL_DIRCOUNT = 0x400 + ATTR_VOL_ENCODINGSUSED = 0x10000 + ATTR_VOL_FILECOUNT = 0x200 + ATTR_VOL_FSTYPE = 0x1 + ATTR_VOL_INFO = 0x80000000 + ATTR_VOL_IOBLOCKSIZE = 0x80 + ATTR_VOL_MAXOBJCOUNT = 0x800 + ATTR_VOL_MINALLOCATION = 0x20 + ATTR_VOL_MOUNTEDDEVICE = 0x8000 + ATTR_VOL_MOUNTFLAGS = 0x4000 + ATTR_VOL_MOUNTPOINT = 0x1000 + ATTR_VOL_NAME = 0x2000 + ATTR_VOL_OBJCOUNT = 0x100 + ATTR_VOL_QUOTA_SIZE = 0x10000000 + ATTR_VOL_RESERVED_SIZE = 0x20000000 + ATTR_VOL_SETMASK = 0x80002000 + ATTR_VOL_SIGNATURE = 0x2 + ATTR_VOL_SIZE = 0x4 + ATTR_VOL_SPACEAVAIL = 0x10 + ATTR_VOL_SPACEFREE = 0x8 + ATTR_VOL_SPACEUSED = 0x800000 + ATTR_VOL_UUID = 0x40000 + ATTR_VOL_VALIDMASK = 0xf087ffff + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc00c4279 + BIOCGETIF = 0x4020426b + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDLT = 0x80044278 + BIOCSETF = 0x80104267 + BIOCSETFNR = 0x8010427e + BIOCSETIF = 0x8020426c + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8010426d + BIOCSSEESENT = 0x80044277 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x8000 + BSDLY = 0x8000 + CFLUSH = 0xf + CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_MONOTONIC_RAW_APPROX = 0x5 + CLOCK_PROCESS_CPUTIME_ID = 0xc + CLOCK_REALTIME = 0x0 + CLOCK_THREAD_CPUTIME_ID = 0x10 + CLOCK_UPTIME_RAW = 0x8 + CLOCK_UPTIME_RAW_APPROX = 0x9 + CLONE_NOFOLLOW = 0x1 + CLONE_NOOWNERCOPY = 0x2 + CR0 = 0x0 + CR1 = 0x1000 + CR2 = 0x2000 + CR3 = 0x3000 + CRDLY = 0x3000 + CREAD = 0x800 + CRTSCTS = 0x30000 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTLIOCGINFO = 0xc0644e03 + CTL_HW = 0x6 + CTL_KERN = 0x1 + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0x10a + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_DARWIN = 0x10a + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_EXCEPT = -0xf + EVFILT_FS = -0x9 + EVFILT_MACHPORT = -0x8 + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0x11 + EVFILT_THREADMARKER = 0x11 + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xa + EVFILT_VM = -0xc + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_DISPATCH2 = 0x180 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG0 = 0x1000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_OOBAND = 0x2000 + EV_POLL = 0x1000 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EV_UDATA_SPECIFIC = 0x100 + EV_VANISHED = 0x200 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x4000 + FFDLY = 0x4000 + FLUSHO = 0x800000 + FSOPT_ATTR_CMN_EXTENDED = 0x20 + FSOPT_NOFOLLOW = 0x1 + FSOPT_NOINMEMUPDATE = 0x2 + FSOPT_PACK_INVAL_ATTRS = 0x8 + FSOPT_REPORT_FULLSIZE = 0x4 + FSOPT_RETURN_REALDEV = 0x200 + F_ADDFILESIGS = 0x3d + F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 + F_ADDFILESIGS_INFO = 0x67 + F_ADDFILESIGS_RETURN = 0x61 + F_ADDFILESUPPL = 0x68 + F_ADDSIGS = 0x3b + F_ALLOCATEALL = 0x4 + F_ALLOCATECONTIG = 0x2 + F_BARRIERFSYNC = 0x55 + F_CHECK_LV = 0x62 + F_CHKCLEAN = 0x29 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x43 + F_FINDSIGS = 0x4e + F_FLUSH_DATA = 0x28 + F_FREEZE_FS = 0x35 + F_FULLFSYNC = 0x33 + F_GETCODEDIR = 0x48 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETLKPID = 0x42 + F_GETNOSIGPIPE = 0x4a + F_GETOWN = 0x5 + F_GETPATH = 0x32 + F_GETPATH_MTMINFO = 0x47 + F_GETPATH_NOFIRMLINK = 0x66 + F_GETPROTECTIONCLASS = 0x3f + F_GETPROTECTIONLEVEL = 0x4d + F_GETSIGSINFO = 0x69 + F_GLOBAL_NOCACHE = 0x37 + F_LOG2PHYS = 0x31 + F_LOG2PHYS_EXT = 0x41 + F_NOCACHE = 0x30 + F_NODIRECT = 0x3e + F_OK = 0x0 + F_PATHPKG_CHECK = 0x34 + F_PEOFPOSMODE = 0x3 + F_PREALLOCATE = 0x2a + F_PUNCHHOLE = 0x63 + F_RDADVISE = 0x2c + F_RDAHEAD = 0x2d + F_RDLCK = 0x1 + F_SETBACKINGSTORE = 0x46 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETLKWTIMEOUT = 0xa + F_SETNOSIGPIPE = 0x49 + F_SETOWN = 0x6 + F_SETPROTECTIONCLASS = 0x40 + F_SETSIZE = 0x2b + F_SINGLE_WRITER = 0x4c + F_SPECULATIVE_READ = 0x65 + F_THAW_FS = 0x36 + F_TRANSCODEKEY = 0x4b + F_TRIM_ACTIVE_FILE = 0x64 + F_UNLCK = 0x2 + F_VOLPOSMODE = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + HW_MACHINE = 0x1 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_1822 = 0x2 + IFT_6LOWPAN = 0x40 + IFT_AAL5 = 0x31 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ATM = 0x25 + IFT_BRIDGE = 0xd1 + IFT_CARP = 0xf8 + IFT_CELLULAR = 0xff + IFT_CEPT = 0x13 + IFT_DS3 = 0x1e + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_ETHER = 0x6 + IFT_FAITH = 0x38 + IFT_FDDI = 0xf + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_GIF = 0x37 + IFT_HDH1822 = 0x3 + IFT_HIPPI = 0x2f + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IEEE1394 = 0x90 + IFT_IEEE8023ADLAG = 0x88 + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88026 = 0xa + IFT_L2VLAN = 0x87 + IFT_LAPB = 0x10 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_NSIP = 0x1b + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PDP = 0xff + IFT_PFLOG = 0xf5 + IFT_PFSYNC = 0xf6 + IFT_PKTAP = 0xfe + IFT_PPP = 0x17 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PTPSERIAL = 0x16 + IFT_RS232 = 0x21 + IFT_SDLC = 0x11 + IFT_SIP = 0x1f + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_STARLAN = 0xb + IFT_STF = 0x39 + IFT_T1 = 0x12 + IFT_ULTRA = 0x1d + IFT_V35 = 0x2d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LINKLOCALNETNUM = 0xa9fe0000 + IN_LOOPBACKNET = 0x7f + IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x400473d1 + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0xfe + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MEAS = 0x13 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEP = 0x21 + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_2292DSTOPTS = 0x17 + IPV6_2292HOPLIMIT = 0x14 + IPV6_2292HOPOPTS = 0x16 + IPV6_2292NEXTHOP = 0x15 + IPV6_2292PKTINFO = 0x13 + IPV6_2292PKTOPTIONS = 0x19 + IPV6_2292RTHDR = 0x18 + IPV6_3542DSTOPTS = 0x32 + IPV6_3542HOPLIMIT = 0x2f + IPV6_3542HOPOPTS = 0x31 + IPV6_3542NEXTHOP = 0x30 + IPV6_3542PKTINFO = 0x2e + IPV6_3542RTHDR = 0x33 + IPV6_ADDR_MC_FLAGS_PREFIX = 0x20 + IPV6_ADDR_MC_FLAGS_TRANSIENT = 0x10 + IPV6_ADDR_MC_FLAGS_UNICAST_BASED = 0x30 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_BINDV6ONLY = 0x1b + IPV6_BOUND_IF = 0x7d + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FLOW_ECN_MASK = 0x3000 + IPV6_FRAGTTL = 0x3c + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x3d + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x23 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x39 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x24 + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BLOCK_SOURCE = 0x48 + IP_BOUND_IF = 0x19 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DONTFRAG = 0x1c + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FAITH = 0x16 + IP_FW_ADD = 0x28 + IP_FW_DEL = 0x29 + IP_FW_FLUSH = 0x2a + IP_FW_GET = 0x2c + IP_FW_RESETLOG = 0x2d + IP_FW_ZERO = 0x2b + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MF = 0x2000 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_IFINDEX = 0x42 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_NAT__XXX = 0x37 + IP_OFFMASK = 0x1fff + IP_OLD_FW_ADD = 0x32 + IP_OLD_FW_DEL = 0x33 + IP_OLD_FW_FLUSH = 0x34 + IP_OLD_FW_GET = 0x36 + IP_OLD_FW_RESETLOG = 0x38 + IP_OLD_FW_ZERO = 0x35 + IP_OPTIONS = 0x1 + IP_PKTINFO = 0x1a + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVPKTINFO = 0x1a + IP_RECVRETOPTS = 0x6 + IP_RECVTOS = 0x1b + IP_RECVTTL = 0x18 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_STRIPHDR = 0x17 + IP_TOS = 0x3 + IP_TRAFFIC_MGT_BACKGROUND = 0x41 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + KERN_HOSTNAME = 0xa + KERN_OSRELEASE = 0x2 + KERN_OSTYPE = 0x1 + KERN_VERSION = 0x4 + LOCAL_PEERCRED = 0x1 + LOCAL_PEEREPID = 0x3 + LOCAL_PEEREUUID = 0x5 + LOCAL_PEERPID = 0x2 + LOCAL_PEERTOKEN = 0x6 + LOCAL_PEERUUID = 0x4 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_CAN_REUSE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_FREE_REUSABLE = 0x7 + MADV_FREE_REUSE = 0x8 + MADV_NORMAL = 0x0 + MADV_PAGEOUT = 0xa + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MADV_ZERO_WIRED_PAGES = 0x6 + MAP_32BIT = 0x8000 + MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 + MAP_COPY = 0x2 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_JIT = 0x800 + MAP_NOCACHE = 0x400 + MAP_NOEXTEND = 0x100 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_RESERVED0080 = 0x80 + MAP_RESILIENT_CODESIGN = 0x2000 + MAP_RESILIENT_MEDIA = 0x4000 + MAP_SHARED = 0x1 + MAP_TRANSLATED_ALLOW_EXECUTE = 0x20000 + MAP_UNIX03 = 0x40000 + MCAST_BLOCK_SOURCE = 0x54 + MCAST_EXCLUDE = 0x2 + MCAST_INCLUDE = 0x1 + MCAST_JOIN_GROUP = 0x50 + MCAST_JOIN_SOURCE_GROUP = 0x52 + MCAST_LEAVE_GROUP = 0x51 + MCAST_LEAVE_SOURCE_GROUP = 0x53 + MCAST_UNBLOCK_SOURCE = 0x55 + MCAST_UNDEFINED = 0x0 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_AUTOMOUNTED = 0x400000 + MNT_CMDFLAGS = 0xf0000 + MNT_CPROTECT = 0x80 + MNT_DEFWRITE = 0x2000000 + MNT_DONTBROWSE = 0x100000 + MNT_DOVOLFS = 0x8000 + MNT_DWAIT = 0x4 + MNT_EXPORTED = 0x100 + MNT_EXT_ROOT_DATA_VOL = 0x1 + MNT_FORCE = 0x80000 + MNT_IGNORE_OWNERSHIP = 0x200000 + MNT_JOURNALED = 0x800000 + MNT_LOCAL = 0x1000 + MNT_MULTILABEL = 0x4000000 + MNT_NOATIME = 0x10000000 + MNT_NOBLOCK = 0x20000 + MNT_NODEV = 0x10 + MNT_NOEXEC = 0x4 + MNT_NOSUID = 0x8 + MNT_NOUSERXATTR = 0x1000000 + MNT_NOWAIT = 0x2 + MNT_QUARANTINE = 0x400 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELOAD = 0x40000 + MNT_REMOVABLE = 0x200 + MNT_ROOTFS = 0x4000 + MNT_SNAPSHOT = 0x40000000 + MNT_STRICTATIME = 0x80000000 + MNT_SYNCHRONOUS = 0x2 + MNT_UNION = 0x20 + MNT_UNKNOWNPERMISSIONS = 0x200000 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0xd7f0f7ff + MNT_WAIT = 0x1 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_FLUSH = 0x400 + MSG_HAVEMORE = 0x2000 + MSG_HOLD = 0x800 + MSG_NEEDSA = 0x10000 + MSG_NOSIGNAL = 0x80000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_RCVMORE = 0x4000 + MSG_SEND = 0x1000 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MSG_WAITSTREAM = 0x200 + MS_ASYNC = 0x1 + MS_DEACTIVATE = 0x8 + MS_INVALIDATE = 0x2 + MS_KILLPAGES = 0x4 + MS_SYNC = 0x10 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_DUMP2 = 0x7 + NET_RT_FLAGS = 0x2 + NET_RT_FLAGS_PRIV = 0xa + NET_RT_IFLIST = 0x3 + NET_RT_IFLIST2 = 0x6 + NET_RT_MAXID = 0xb + NET_RT_STAT = 0x4 + NET_RT_TRASH = 0x5 + NFDBITS = 0x20 + NL0 = 0x0 + NL1 = 0x100 + NL2 = 0x200 + NL3 = 0x300 + NLDLY = 0x300 + NOFLSH = 0x80000000 + NOKERNINFO = 0x2000000 + NOTE_ABSOLUTE = 0x8 + NOTE_ATTRIB = 0x8 + NOTE_BACKGROUND = 0x40 + NOTE_CHILD = 0x4 + NOTE_CRITICAL = 0x20 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXITSTATUS = 0x4000000 + NOTE_EXIT_CSERROR = 0x40000 + NOTE_EXIT_DECRYPTFAIL = 0x10000 + NOTE_EXIT_DETAIL = 0x2000000 + NOTE_EXIT_DETAIL_MASK = 0x70000 + NOTE_EXIT_MEMORY = 0x20000 + NOTE_EXIT_REPARENTED = 0x80000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FORK = 0x40000000 + NOTE_FUNLOCK = 0x100 + NOTE_LEEWAY = 0x10 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_MACHTIME = 0x100 + NOTE_MACH_CONTINUOUS_TIME = 0x80 + NOTE_NONE = 0x80 + NOTE_NSECONDS = 0x4 + NOTE_OOB = 0x2 + NOTE_PCTRLMASK = -0x100000 + NOTE_PDATAMASK = 0xfffff + NOTE_REAP = 0x10000000 + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_SECONDS = 0x1 + NOTE_SIGNAL = 0x8000000 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_USECONDS = 0x2 + NOTE_VM_ERROR = 0x10000000 + NOTE_VM_PRESSURE = 0x80000000 + NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000 + NOTE_VM_PRESSURE_TERMINATE = 0x40000000 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + OFDEL = 0x20000 + OFILL = 0x80 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + OXTABS = 0x4 + O_ACCMODE = 0x3 + O_ALERT = 0x20000000 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x1000000 + O_CREAT = 0x200 + O_DIRECTORY = 0x100000 + O_DP_GETRAWENCRYPTED = 0x1 + O_DP_GETRAWUNENCRYPTED = 0x2 + O_DSYNC = 0x400000 + O_EVTONLY = 0x8000 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x20000 + O_NOFOLLOW = 0x100 + O_NOFOLLOW_ANY = 0x20000000 + O_NONBLOCK = 0x4 + O_POPUP = 0x80000000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYMLINK = 0x200000 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PT_ATTACH = 0xa + PT_ATTACHEXC = 0xe + PT_CONTINUE = 0x7 + PT_DENY_ATTACH = 0x1f + PT_DETACH = 0xb + PT_FIRSTMACH = 0x20 + PT_FORCEQUOTA = 0x1e + PT_KILL = 0x8 + PT_READ_D = 0x2 + PT_READ_I = 0x1 + PT_READ_U = 0x3 + PT_SIGEXC = 0xc + PT_STEP = 0x9 + PT_THUPDATE = 0xd + PT_TRACE_ME = 0x0 + PT_WRITE_D = 0x5 + PT_WRITE_I = 0x4 + PT_WRITE_U = 0x6 + RLIMIT_AS = 0x5 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_CPU_USAGE_MONITOR = 0x2 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 + RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_CLONING = 0x100 + RTF_CONDEMNED = 0x2000000 + RTF_DEAD = 0x20000000 + RTF_DELCLONE = 0x80 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_GATEWAY = 0x2 + RTF_GLOBAL = 0x40000000 + RTF_HOST = 0x4 + RTF_IFREF = 0x4000000 + RTF_IFSCOPE = 0x1000000 + RTF_LLDATA = 0x400 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_NOIFREF = 0x2000 + RTF_PINNED = 0x100000 + RTF_PRCLONING = 0x10000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_PROXY = 0x8000000 + RTF_REJECT = 0x8 + RTF_ROUTER = 0x10000000 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_WASCLONED = 0x20000 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_GET2 = 0x14 + RTM_IFINFO = 0xe + RTM_IFINFO2 = 0x12 + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_NEWMADDR2 = 0x13 + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SCM_TIMESTAMP_MONOTONIC = 0x4 + SEEK_CUR = 0x1 + SEEK_DATA = 0x4 + SEEK_END = 0x2 + SEEK_HOLE = 0x3 + SEEK_SET = 0x0 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCARPIPLL = 0xc0206928 + SIOCATMARK = 0x40047307 + SIOCAUTOADDR = 0xc0206926 + SIOCAUTONETMASK = 0x80206927 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFPHYADDR = 0x80206941 + SIOCGDRVSPEC = 0xc028697b + SIOCGETVLAN = 0xc020697f + SIOCGHIWAT = 0x40047301 + SIOCGIF6LOWPAN = 0xc02069c5 + SIOCGIFADDR = 0xc0206921 + SIOCGIFALTMTU = 0xc0206948 + SIOCGIFASYNCMAP = 0xc020697c + SIOCGIFBOND = 0xc0206947 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020695b + SIOCGIFCONF = 0xc00c6924 + SIOCGIFDEVMTU = 0xc0206944 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFFUNCTIONALTYPE = 0xc02069ad + SIOCGIFGENERIC = 0xc020693a + SIOCGIFKPI = 0xc0206987 + SIOCGIFMAC = 0xc0206982 + SIOCGIFMEDIA = 0xc02c6938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206940 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc020693f + SIOCGIFSTATUS = 0xc331693d + SIOCGIFVLAN = 0xc020697f + SIOCGIFWAKEFLAGS = 0xc0206988 + SIOCGIFXMEDIA = 0xc02c6948 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCIFCREATE = 0xc0206978 + SIOCIFCREATE2 = 0xc020697a + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc0106981 + SIOCRSLVMULTI = 0xc010693b + SIOCSDRVSPEC = 0x8028697b + SIOCSETVLAN = 0x8020697e + SIOCSHIWAT = 0x80047300 + SIOCSIF6LOWPAN = 0x802069c4 + SIOCSIFADDR = 0x8020690c + SIOCSIFALTMTU = 0x80206945 + SIOCSIFASYNCMAP = 0x8020697d + SIOCSIFBOND = 0x80206946 + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020695a + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFKPI = 0x80206986 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206983 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x8040693e + SIOCSIFPHYS = 0x80206936 + SIOCSIFVLAN = 0x8020697e + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_LOCAL = 0x0 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_DONTTRUNC = 0x2000 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1010 + SO_LINGER = 0x80 + SO_LINGER_SEC = 0x1080 + SO_NETSVC_MARKING_LEVEL = 0x1119 + SO_NET_SERVICE_TYPE = 0x1116 + SO_NKE = 0x1021 + SO_NOADDRERR = 0x1023 + SO_NOSIGPIPE = 0x1022 + SO_NOTIFYCONFLICT = 0x1026 + SO_NP_EXTENSIONS = 0x1083 + SO_NREAD = 0x1020 + SO_NUMRCVPKT = 0x1112 + SO_NWRITE = 0x1024 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1011 + SO_RANDOMPORT = 0x1082 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_REUSESHAREUID = 0x1025 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TIMESTAMP_MONOTONIC = 0x800 + SO_TRACKER_ATTRIBUTE_FLAGS_APP_APPROVED = 0x1 + SO_TRACKER_ATTRIBUTE_FLAGS_DOMAIN_SHORT = 0x4 + SO_TRACKER_ATTRIBUTE_FLAGS_TRACKER = 0x2 + SO_TRACKER_TRANSPARENCY_VERSION = 0x3 + SO_TYPE = 0x1008 + SO_UPCALLCLOSEWAIT = 0x1027 + SO_USELOOPBACK = 0x40 + SO_WANTMORE = 0x4000 + SO_WANTOOBFLAG = 0x8000 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IFWHT = 0xe000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x400 + TAB2 = 0x800 + TAB3 = 0x4 + TABDLY = 0xc04 + TCIFLUSH = 0x1 + TCIOFF = 0x3 + TCIOFLUSH = 0x3 + TCION = 0x4 + TCOFLUSH = 0x2 + TCOOFF = 0x1 + TCOON = 0x2 + TCPOPT_CC = 0xb + TCPOPT_CCECHO = 0xd + TCPOPT_CCNEW = 0xc + TCPOPT_EOL = 0x0 + TCPOPT_FASTOPEN = 0x22 + TCPOPT_MAXSEG = 0x2 + TCPOPT_NOP = 0x1 + TCPOPT_SACK = 0x5 + TCPOPT_SACK_HDR = 0x1010500 + TCPOPT_SACK_PERMITTED = 0x4 + TCPOPT_SACK_PERMIT_HDR = 0x1010402 + TCPOPT_SIGNATURE = 0x13 + TCPOPT_TIMESTAMP = 0x8 + TCPOPT_TSTAMP_HDR = 0x101080a + TCPOPT_WINDOW = 0x3 + TCP_CONNECTIONTIMEOUT = 0x20 + TCP_CONNECTION_INFO = 0x106 + TCP_ENABLE_ECN = 0x104 + TCP_FASTOPEN = 0x105 + TCP_KEEPALIVE = 0x10 + TCP_KEEPCNT = 0x102 + TCP_KEEPINTVL = 0x101 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MINMSS = 0xd8 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_NOTSENT_LOWAT = 0x201 + TCP_RXT_CONNDROPTIME = 0x80 + TCP_RXT_FINDROP = 0x100 + TCP_SENDMOREACKS = 0x103 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDCDTIMESTAMP = 0x40107458 + TIOCDRAIN = 0x2000745e + TIOCDSIMICROCODE = 0x20007455 + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x40487413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGWINSZ = 0x40087468 + TIOCIXOFF = 0x20007480 + TIOCIXON = 0x20007481 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMODG = 0x40047403 + TIOCMODS = 0x80047404 + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTYGNAME = 0x40807453 + TIOCPTYGRANT = 0x20007454 + TIOCPTYUNLK = 0x20007452 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCONS = 0x20007463 + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x80487414 + TIOCSETAF = 0x80487416 + TIOCSETAW = 0x80487415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2000745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40107459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMADDR_CID_ANY = 0xffffffff + VMADDR_CID_HOST = 0x2 + VMADDR_CID_HYPERVISOR = 0x0 + VMADDR_CID_RESERVED = 0x1 + VMADDR_PORT_ANY = 0xffffffff + VMIN = 0x10 + VM_LOADAVG = 0x2 + VM_MACHFACTOR = 0x4 + VM_MAXID = 0x6 + VM_METER = 0x1 + VM_SWAPUSAGE = 0x5 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VT0 = 0x0 + VT1 = 0x10000 + VTDLY = 0x10000 + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x10 + WCOREFLAG = 0x80 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOWAIT = 0x20 + WORDSIZE = 0x40 + WSTOPPED = 0x8 + WUNTRACED = 0x2 + XATTR_CREATE = 0x2 + XATTR_NODEFAULT = 0x10 + XATTR_NOFOLLOW = 0x1 + XATTR_NOSECURITY = 0x8 + XATTR_REPLACE = 0x4 + XATTR_SHOWCOMPRESSION = 0x20 ) // Errors diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/src/cmd/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index 31009d7f05..e36f5178d6 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -12,1556 +12,1582 @@ package unix import "syscall" const ( - AF_APPLETALK = 0x10 - AF_CCITT = 0xa - AF_CHAOS = 0x5 - AF_CNT = 0x15 - AF_COIP = 0x14 - AF_DATAKIT = 0x9 - AF_DECnet = 0xc - AF_DLI = 0xd - AF_E164 = 0x1c - AF_ECMA = 0x8 - AF_HYLINK = 0xf - AF_IEEE80211 = 0x25 - AF_IMPLINK = 0x3 - AF_INET = 0x2 - AF_INET6 = 0x1e - AF_IPX = 0x17 - AF_ISDN = 0x1c - AF_ISO = 0x7 - AF_LAT = 0xe - AF_LINK = 0x12 - AF_LOCAL = 0x1 - AF_MAX = 0x29 - AF_NATM = 0x1f - AF_NDRV = 0x1b - AF_NETBIOS = 0x21 - AF_NS = 0x6 - AF_OSI = 0x7 - AF_PPP = 0x22 - AF_PUP = 0x4 - AF_RESERVED_36 = 0x24 - AF_ROUTE = 0x11 - AF_SIP = 0x18 - AF_SNA = 0xb - AF_SYSTEM = 0x20 - AF_SYS_CONTROL = 0x2 - AF_UNIX = 0x1 - AF_UNSPEC = 0x0 - AF_UTUN = 0x26 - AF_VSOCK = 0x28 - ALTWERASE = 0x200 - ATTR_BIT_MAP_COUNT = 0x5 - ATTR_CMN_ACCESSMASK = 0x20000 - ATTR_CMN_ACCTIME = 0x1000 - ATTR_CMN_ADDEDTIME = 0x10000000 - ATTR_CMN_BKUPTIME = 0x2000 - ATTR_CMN_CHGTIME = 0x800 - ATTR_CMN_CRTIME = 0x200 - ATTR_CMN_DATA_PROTECT_FLAGS = 0x40000000 - ATTR_CMN_DEVID = 0x2 - ATTR_CMN_DOCUMENT_ID = 0x100000 - ATTR_CMN_ERROR = 0x20000000 - ATTR_CMN_EXTENDED_SECURITY = 0x400000 - ATTR_CMN_FILEID = 0x2000000 - ATTR_CMN_FLAGS = 0x40000 - ATTR_CMN_FNDRINFO = 0x4000 - ATTR_CMN_FSID = 0x4 - ATTR_CMN_FULLPATH = 0x8000000 - ATTR_CMN_GEN_COUNT = 0x80000 - ATTR_CMN_GRPID = 0x10000 - ATTR_CMN_GRPUUID = 0x1000000 - ATTR_CMN_MODTIME = 0x400 - ATTR_CMN_NAME = 0x1 - ATTR_CMN_NAMEDATTRCOUNT = 0x80000 - ATTR_CMN_NAMEDATTRLIST = 0x100000 - ATTR_CMN_OBJID = 0x20 - ATTR_CMN_OBJPERMANENTID = 0x40 - ATTR_CMN_OBJTAG = 0x10 - ATTR_CMN_OBJTYPE = 0x8 - ATTR_CMN_OWNERID = 0x8000 - ATTR_CMN_PARENTID = 0x4000000 - ATTR_CMN_PAROBJID = 0x80 - ATTR_CMN_RETURNED_ATTRS = 0x80000000 - ATTR_CMN_SCRIPT = 0x100 - ATTR_CMN_SETMASK = 0x51c7ff00 - ATTR_CMN_USERACCESS = 0x200000 - ATTR_CMN_UUID = 0x800000 - ATTR_CMN_VALIDMASK = 0xffffffff - ATTR_CMN_VOLSETMASK = 0x6700 - ATTR_FILE_ALLOCSIZE = 0x4 - ATTR_FILE_CLUMPSIZE = 0x10 - ATTR_FILE_DATAALLOCSIZE = 0x400 - ATTR_FILE_DATAEXTENTS = 0x800 - ATTR_FILE_DATALENGTH = 0x200 - ATTR_FILE_DEVTYPE = 0x20 - ATTR_FILE_FILETYPE = 0x40 - ATTR_FILE_FORKCOUNT = 0x80 - ATTR_FILE_FORKLIST = 0x100 - ATTR_FILE_IOBLOCKSIZE = 0x8 - ATTR_FILE_LINKCOUNT = 0x1 - ATTR_FILE_RSRCALLOCSIZE = 0x2000 - ATTR_FILE_RSRCEXTENTS = 0x4000 - ATTR_FILE_RSRCLENGTH = 0x1000 - ATTR_FILE_SETMASK = 0x20 - ATTR_FILE_TOTALSIZE = 0x2 - ATTR_FILE_VALIDMASK = 0x37ff - ATTR_VOL_ALLOCATIONCLUMP = 0x40 - ATTR_VOL_ATTRIBUTES = 0x40000000 - ATTR_VOL_CAPABILITIES = 0x20000 - ATTR_VOL_DIRCOUNT = 0x400 - ATTR_VOL_ENCODINGSUSED = 0x10000 - ATTR_VOL_FILECOUNT = 0x200 - ATTR_VOL_FSTYPE = 0x1 - ATTR_VOL_INFO = 0x80000000 - ATTR_VOL_IOBLOCKSIZE = 0x80 - ATTR_VOL_MAXOBJCOUNT = 0x800 - ATTR_VOL_MINALLOCATION = 0x20 - ATTR_VOL_MOUNTEDDEVICE = 0x8000 - ATTR_VOL_MOUNTFLAGS = 0x4000 - ATTR_VOL_MOUNTPOINT = 0x1000 - ATTR_VOL_NAME = 0x2000 - ATTR_VOL_OBJCOUNT = 0x100 - ATTR_VOL_QUOTA_SIZE = 0x10000000 - ATTR_VOL_RESERVED_SIZE = 0x20000000 - ATTR_VOL_SETMASK = 0x80002000 - ATTR_VOL_SIGNATURE = 0x2 - ATTR_VOL_SIZE = 0x4 - ATTR_VOL_SPACEAVAIL = 0x10 - ATTR_VOL_SPACEFREE = 0x8 - ATTR_VOL_UUID = 0x40000 - ATTR_VOL_VALIDMASK = 0xf007ffff - B0 = 0x0 - B110 = 0x6e - B115200 = 0x1c200 - B1200 = 0x4b0 - B134 = 0x86 - B14400 = 0x3840 - B150 = 0x96 - B1800 = 0x708 - B19200 = 0x4b00 - B200 = 0xc8 - B230400 = 0x38400 - B2400 = 0x960 - B28800 = 0x7080 - B300 = 0x12c - B38400 = 0x9600 - B4800 = 0x12c0 - B50 = 0x32 - B57600 = 0xe100 - B600 = 0x258 - B7200 = 0x1c20 - B75 = 0x4b - B76800 = 0x12c00 - B9600 = 0x2580 - BIOCFLUSH = 0x20004268 - BIOCGBLEN = 0x40044266 - BIOCGDLT = 0x4004426a - BIOCGDLTLIST = 0xc00c4279 - BIOCGETIF = 0x4020426b - BIOCGHDRCMPLT = 0x40044274 - BIOCGRSIG = 0x40044272 - BIOCGRTIMEOUT = 0x4010426e - BIOCGSEESENT = 0x40044276 - BIOCGSTATS = 0x4008426f - BIOCIMMEDIATE = 0x80044270 - BIOCPROMISC = 0x20004269 - BIOCSBLEN = 0xc0044266 - BIOCSDLT = 0x80044278 - BIOCSETF = 0x80104267 - BIOCSETFNR = 0x8010427e - BIOCSETIF = 0x8020426c - BIOCSHDRCMPLT = 0x80044275 - BIOCSRSIG = 0x80044273 - BIOCSRTIMEOUT = 0x8010426d - BIOCSSEESENT = 0x80044277 - BIOCVERSION = 0x40044271 - BPF_A = 0x10 - BPF_ABS = 0x20 - BPF_ADD = 0x0 - BPF_ALIGNMENT = 0x4 - BPF_ALU = 0x4 - BPF_AND = 0x50 - BPF_B = 0x10 - BPF_DIV = 0x30 - BPF_H = 0x8 - BPF_IMM = 0x0 - BPF_IND = 0x40 - BPF_JA = 0x0 - BPF_JEQ = 0x10 - BPF_JGE = 0x30 - BPF_JGT = 0x20 - BPF_JMP = 0x5 - BPF_JSET = 0x40 - BPF_K = 0x0 - BPF_LD = 0x0 - BPF_LDX = 0x1 - BPF_LEN = 0x80 - BPF_LSH = 0x60 - BPF_MAJOR_VERSION = 0x1 - BPF_MAXBUFSIZE = 0x80000 - BPF_MAXINSNS = 0x200 - BPF_MEM = 0x60 - BPF_MEMWORDS = 0x10 - BPF_MINBUFSIZE = 0x20 - BPF_MINOR_VERSION = 0x1 - BPF_MISC = 0x7 - BPF_MSH = 0xa0 - BPF_MUL = 0x20 - BPF_NEG = 0x80 - BPF_OR = 0x40 - BPF_RELEASE = 0x30bb6 - BPF_RET = 0x6 - BPF_RSH = 0x70 - BPF_ST = 0x2 - BPF_STX = 0x3 - BPF_SUB = 0x10 - BPF_TAX = 0x0 - BPF_TXA = 0x80 - BPF_W = 0x0 - BPF_X = 0x8 - BRKINT = 0x2 - BS0 = 0x0 - BS1 = 0x8000 - BSDLY = 0x8000 - CFLUSH = 0xf - CLOCAL = 0x8000 - CLOCK_MONOTONIC = 0x6 - CLOCK_MONOTONIC_RAW = 0x4 - CLOCK_MONOTONIC_RAW_APPROX = 0x5 - CLOCK_PROCESS_CPUTIME_ID = 0xc - CLOCK_REALTIME = 0x0 - CLOCK_THREAD_CPUTIME_ID = 0x10 - CLOCK_UPTIME_RAW = 0x8 - CLOCK_UPTIME_RAW_APPROX = 0x9 - CLONE_NOFOLLOW = 0x1 - CLONE_NOOWNERCOPY = 0x2 - CR0 = 0x0 - CR1 = 0x1000 - CR2 = 0x2000 - CR3 = 0x3000 - CRDLY = 0x3000 - CREAD = 0x800 - CRTSCTS = 0x30000 - CS5 = 0x0 - CS6 = 0x100 - CS7 = 0x200 - CS8 = 0x300 - CSIZE = 0x300 - CSTART = 0x11 - CSTATUS = 0x14 - CSTOP = 0x13 - CSTOPB = 0x400 - CSUSP = 0x1a - CTLIOCGINFO = 0xc0644e03 - CTL_HW = 0x6 - CTL_KERN = 0x1 - CTL_MAXNAME = 0xc - CTL_NET = 0x4 - DLT_A429 = 0xb8 - DLT_A653_ICM = 0xb9 - DLT_AIRONET_HEADER = 0x78 - DLT_AOS = 0xde - DLT_APPLE_IP_OVER_IEEE1394 = 0x8a - DLT_ARCNET = 0x7 - DLT_ARCNET_LINUX = 0x81 - DLT_ATM_CLIP = 0x13 - DLT_ATM_RFC1483 = 0xb - DLT_AURORA = 0x7e - DLT_AX25 = 0x3 - DLT_AX25_KISS = 0xca - DLT_BACNET_MS_TP = 0xa5 - DLT_BLUETOOTH_HCI_H4 = 0xbb - DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 - DLT_CAN20B = 0xbe - DLT_CAN_SOCKETCAN = 0xe3 - DLT_CHAOS = 0x5 - DLT_CHDLC = 0x68 - DLT_CISCO_IOS = 0x76 - DLT_C_HDLC = 0x68 - DLT_C_HDLC_WITH_DIR = 0xcd - DLT_DBUS = 0xe7 - DLT_DECT = 0xdd - DLT_DOCSIS = 0x8f - DLT_DVB_CI = 0xeb - DLT_ECONET = 0x73 - DLT_EN10MB = 0x1 - DLT_EN3MB = 0x2 - DLT_ENC = 0x6d - DLT_ERF = 0xc5 - DLT_ERF_ETH = 0xaf - DLT_ERF_POS = 0xb0 - DLT_FC_2 = 0xe0 - DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 - DLT_FDDI = 0xa - DLT_FLEXRAY = 0xd2 - DLT_FRELAY = 0x6b - DLT_FRELAY_WITH_DIR = 0xce - DLT_GCOM_SERIAL = 0xad - DLT_GCOM_T1E1 = 0xac - DLT_GPF_F = 0xab - DLT_GPF_T = 0xaa - DLT_GPRS_LLC = 0xa9 - DLT_GSMTAP_ABIS = 0xda - DLT_GSMTAP_UM = 0xd9 - DLT_HHDLC = 0x79 - DLT_IBM_SN = 0x92 - DLT_IBM_SP = 0x91 - DLT_IEEE802 = 0x6 - DLT_IEEE802_11 = 0x69 - DLT_IEEE802_11_RADIO = 0x7f - DLT_IEEE802_11_RADIO_AVS = 0xa3 - DLT_IEEE802_15_4 = 0xc3 - DLT_IEEE802_15_4_LINUX = 0xbf - DLT_IEEE802_15_4_NOFCS = 0xe6 - DLT_IEEE802_15_4_NONASK_PHY = 0xd7 - DLT_IEEE802_16_MAC_CPS = 0xbc - DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 - DLT_IPFILTER = 0x74 - DLT_IPMB = 0xc7 - DLT_IPMB_LINUX = 0xd1 - DLT_IPNET = 0xe2 - DLT_IPOIB = 0xf2 - DLT_IPV4 = 0xe4 - DLT_IPV6 = 0xe5 - DLT_IP_OVER_FC = 0x7a - DLT_JUNIPER_ATM1 = 0x89 - DLT_JUNIPER_ATM2 = 0x87 - DLT_JUNIPER_ATM_CEMIC = 0xee - DLT_JUNIPER_CHDLC = 0xb5 - DLT_JUNIPER_ES = 0x84 - DLT_JUNIPER_ETHER = 0xb2 - DLT_JUNIPER_FIBRECHANNEL = 0xea - DLT_JUNIPER_FRELAY = 0xb4 - DLT_JUNIPER_GGSN = 0x85 - DLT_JUNIPER_ISM = 0xc2 - DLT_JUNIPER_MFR = 0x86 - DLT_JUNIPER_MLFR = 0x83 - DLT_JUNIPER_MLPPP = 0x82 - DLT_JUNIPER_MONITOR = 0xa4 - DLT_JUNIPER_PIC_PEER = 0xae - DLT_JUNIPER_PPP = 0xb3 - DLT_JUNIPER_PPPOE = 0xa7 - DLT_JUNIPER_PPPOE_ATM = 0xa8 - DLT_JUNIPER_SERVICES = 0x88 - DLT_JUNIPER_SRX_E2E = 0xe9 - DLT_JUNIPER_ST = 0xc8 - DLT_JUNIPER_VP = 0xb7 - DLT_JUNIPER_VS = 0xe8 - DLT_LAPB_WITH_DIR = 0xcf - DLT_LAPD = 0xcb - DLT_LIN = 0xd4 - DLT_LINUX_EVDEV = 0xd8 - DLT_LINUX_IRDA = 0x90 - DLT_LINUX_LAPD = 0xb1 - DLT_LINUX_PPP_WITHDIRECTION = 0xa6 - DLT_LINUX_SLL = 0x71 - DLT_LOOP = 0x6c - DLT_LTALK = 0x72 - DLT_MATCHING_MAX = 0x10a - DLT_MATCHING_MIN = 0x68 - DLT_MFR = 0xb6 - DLT_MOST = 0xd3 - DLT_MPEG_2_TS = 0xf3 - DLT_MPLS = 0xdb - DLT_MTP2 = 0x8c - DLT_MTP2_WITH_PHDR = 0x8b - DLT_MTP3 = 0x8d - DLT_MUX27010 = 0xec - DLT_NETANALYZER = 0xf0 - DLT_NETANALYZER_TRANSPARENT = 0xf1 - DLT_NFC_LLCP = 0xf5 - DLT_NFLOG = 0xef - DLT_NG40 = 0xf4 - DLT_NULL = 0x0 - DLT_PCI_EXP = 0x7d - DLT_PFLOG = 0x75 - DLT_PFSYNC = 0x12 - DLT_PPI = 0xc0 - DLT_PPP = 0x9 - DLT_PPP_BSDOS = 0x10 - DLT_PPP_ETHER = 0x33 - DLT_PPP_PPPD = 0xa6 - DLT_PPP_SERIAL = 0x32 - DLT_PPP_WITH_DIR = 0xcc - DLT_PPP_WITH_DIRECTION = 0xa6 - DLT_PRISM_HEADER = 0x77 - DLT_PRONET = 0x4 - DLT_RAIF1 = 0xc6 - DLT_RAW = 0xc - DLT_RIO = 0x7c - DLT_SCCP = 0x8e - DLT_SITA = 0xc4 - DLT_SLIP = 0x8 - DLT_SLIP_BSDOS = 0xf - DLT_STANAG_5066_D_PDU = 0xed - DLT_SUNATM = 0x7b - DLT_SYMANTEC_FIREWALL = 0x63 - DLT_TZSP = 0x80 - DLT_USB = 0xba - DLT_USB_DARWIN = 0x10a - DLT_USB_LINUX = 0xbd - DLT_USB_LINUX_MMAPPED = 0xdc - DLT_USER0 = 0x93 - DLT_USER1 = 0x94 - DLT_USER10 = 0x9d - DLT_USER11 = 0x9e - DLT_USER12 = 0x9f - DLT_USER13 = 0xa0 - DLT_USER14 = 0xa1 - DLT_USER15 = 0xa2 - DLT_USER2 = 0x95 - DLT_USER3 = 0x96 - DLT_USER4 = 0x97 - DLT_USER5 = 0x98 - DLT_USER6 = 0x99 - DLT_USER7 = 0x9a - DLT_USER8 = 0x9b - DLT_USER9 = 0x9c - DLT_WIHART = 0xdf - DLT_X2E_SERIAL = 0xd5 - DLT_X2E_XORAYA = 0xd6 - DT_BLK = 0x6 - DT_CHR = 0x2 - DT_DIR = 0x4 - DT_FIFO = 0x1 - DT_LNK = 0xa - DT_REG = 0x8 - DT_SOCK = 0xc - DT_UNKNOWN = 0x0 - DT_WHT = 0xe - ECHO = 0x8 - ECHOCTL = 0x40 - ECHOE = 0x2 - ECHOK = 0x4 - ECHOKE = 0x1 - ECHONL = 0x10 - ECHOPRT = 0x20 - EVFILT_AIO = -0x3 - EVFILT_EXCEPT = -0xf - EVFILT_FS = -0x9 - EVFILT_MACHPORT = -0x8 - EVFILT_PROC = -0x5 - EVFILT_READ = -0x1 - EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0x11 - EVFILT_THREADMARKER = 0x11 - EVFILT_TIMER = -0x7 - EVFILT_USER = -0xa - EVFILT_VM = -0xc - EVFILT_VNODE = -0x4 - EVFILT_WRITE = -0x2 - EV_ADD = 0x1 - EV_CLEAR = 0x20 - EV_DELETE = 0x2 - EV_DISABLE = 0x8 - EV_DISPATCH = 0x80 - EV_DISPATCH2 = 0x180 - EV_ENABLE = 0x4 - EV_EOF = 0x8000 - EV_ERROR = 0x4000 - EV_FLAG0 = 0x1000 - EV_FLAG1 = 0x2000 - EV_ONESHOT = 0x10 - EV_OOBAND = 0x2000 - EV_POLL = 0x1000 - EV_RECEIPT = 0x40 - EV_SYSFLAGS = 0xf000 - EV_UDATA_SPECIFIC = 0x100 - EV_VANISHED = 0x200 - EXTA = 0x4b00 - EXTB = 0x9600 - EXTPROC = 0x800 - FD_CLOEXEC = 0x1 - FD_SETSIZE = 0x400 - FF0 = 0x0 - FF1 = 0x4000 - FFDLY = 0x4000 - FLUSHO = 0x800000 - FSOPT_ATTR_CMN_EXTENDED = 0x20 - FSOPT_NOFOLLOW = 0x1 - FSOPT_NOINMEMUPDATE = 0x2 - FSOPT_PACK_INVAL_ATTRS = 0x8 - FSOPT_REPORT_FULLSIZE = 0x4 - FSOPT_RETURN_REALDEV = 0x200 - F_ADDFILESIGS = 0x3d - F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 - F_ADDFILESIGS_INFO = 0x67 - F_ADDFILESIGS_RETURN = 0x61 - F_ADDFILESUPPL = 0x68 - F_ADDSIGS = 0x3b - F_ALLOCATEALL = 0x4 - F_ALLOCATECONTIG = 0x2 - F_BARRIERFSYNC = 0x55 - F_CHECK_LV = 0x62 - F_CHKCLEAN = 0x29 - F_DUPFD = 0x0 - F_DUPFD_CLOEXEC = 0x43 - F_FINDSIGS = 0x4e - F_FLUSH_DATA = 0x28 - F_FREEZE_FS = 0x35 - F_FULLFSYNC = 0x33 - F_GETCODEDIR = 0x48 - F_GETFD = 0x1 - F_GETFL = 0x3 - F_GETLK = 0x7 - F_GETLKPID = 0x42 - F_GETNOSIGPIPE = 0x4a - F_GETOWN = 0x5 - F_GETPATH = 0x32 - F_GETPATH_MTMINFO = 0x47 - F_GETPATH_NOFIRMLINK = 0x66 - F_GETPROTECTIONCLASS = 0x3f - F_GETPROTECTIONLEVEL = 0x4d - F_GETSIGSINFO = 0x69 - F_GLOBAL_NOCACHE = 0x37 - F_LOG2PHYS = 0x31 - F_LOG2PHYS_EXT = 0x41 - F_NOCACHE = 0x30 - F_NODIRECT = 0x3e - F_OK = 0x0 - F_PATHPKG_CHECK = 0x34 - F_PEOFPOSMODE = 0x3 - F_PREALLOCATE = 0x2a - F_PUNCHHOLE = 0x63 - F_RDADVISE = 0x2c - F_RDAHEAD = 0x2d - F_RDLCK = 0x1 - F_SETBACKINGSTORE = 0x46 - F_SETFD = 0x2 - F_SETFL = 0x4 - F_SETLK = 0x8 - F_SETLKW = 0x9 - F_SETLKWTIMEOUT = 0xa - F_SETNOSIGPIPE = 0x49 - F_SETOWN = 0x6 - F_SETPROTECTIONCLASS = 0x40 - F_SETSIZE = 0x2b - F_SINGLE_WRITER = 0x4c - F_SPECULATIVE_READ = 0x65 - F_THAW_FS = 0x36 - F_TRANSCODEKEY = 0x4b - F_TRIM_ACTIVE_FILE = 0x64 - F_UNLCK = 0x2 - F_VOLPOSMODE = 0x4 - F_WRLCK = 0x3 - HUPCL = 0x4000 - HW_MACHINE = 0x1 - ICANON = 0x100 - ICMP6_FILTER = 0x12 - ICRNL = 0x100 - IEXTEN = 0x400 - IFF_ALLMULTI = 0x200 - IFF_ALTPHYS = 0x4000 - IFF_BROADCAST = 0x2 - IFF_DEBUG = 0x4 - IFF_LINK0 = 0x1000 - IFF_LINK1 = 0x2000 - IFF_LINK2 = 0x4000 - IFF_LOOPBACK = 0x8 - IFF_MULTICAST = 0x8000 - IFF_NOARP = 0x80 - IFF_NOTRAILERS = 0x20 - IFF_OACTIVE = 0x400 - IFF_POINTOPOINT = 0x10 - IFF_PROMISC = 0x100 - IFF_RUNNING = 0x40 - IFF_SIMPLEX = 0x800 - IFF_UP = 0x1 - IFNAMSIZ = 0x10 - IFT_1822 = 0x2 - IFT_6LOWPAN = 0x40 - IFT_AAL5 = 0x31 - IFT_ARCNET = 0x23 - IFT_ARCNETPLUS = 0x24 - IFT_ATM = 0x25 - IFT_BRIDGE = 0xd1 - IFT_CARP = 0xf8 - IFT_CELLULAR = 0xff - IFT_CEPT = 0x13 - IFT_DS3 = 0x1e - IFT_ENC = 0xf4 - IFT_EON = 0x19 - IFT_ETHER = 0x6 - IFT_FAITH = 0x38 - IFT_FDDI = 0xf - IFT_FRELAY = 0x20 - IFT_FRELAYDCE = 0x2c - IFT_GIF = 0x37 - IFT_HDH1822 = 0x3 - IFT_HIPPI = 0x2f - IFT_HSSI = 0x2e - IFT_HY = 0xe - IFT_IEEE1394 = 0x90 - IFT_IEEE8023ADLAG = 0x88 - IFT_ISDNBASIC = 0x14 - IFT_ISDNPRIMARY = 0x15 - IFT_ISO88022LLC = 0x29 - IFT_ISO88023 = 0x7 - IFT_ISO88024 = 0x8 - IFT_ISO88025 = 0x9 - IFT_ISO88026 = 0xa - IFT_L2VLAN = 0x87 - IFT_LAPB = 0x10 - IFT_LOCALTALK = 0x2a - IFT_LOOP = 0x18 - IFT_MIOX25 = 0x26 - IFT_MODEM = 0x30 - IFT_NSIP = 0x1b - IFT_OTHER = 0x1 - IFT_P10 = 0xc - IFT_P80 = 0xd - IFT_PARA = 0x22 - IFT_PDP = 0xff - IFT_PFLOG = 0xf5 - IFT_PFSYNC = 0xf6 - IFT_PKTAP = 0xfe - IFT_PPP = 0x17 - IFT_PROPMUX = 0x36 - IFT_PROPVIRTUAL = 0x35 - IFT_PTPSERIAL = 0x16 - IFT_RS232 = 0x21 - IFT_SDLC = 0x11 - IFT_SIP = 0x1f - IFT_SLIP = 0x1c - IFT_SMDSDXI = 0x2b - IFT_SMDSICIP = 0x34 - IFT_SONET = 0x27 - IFT_SONETPATH = 0x32 - IFT_SONETVT = 0x33 - IFT_STARLAN = 0xb - IFT_STF = 0x39 - IFT_T1 = 0x12 - IFT_ULTRA = 0x1d - IFT_V35 = 0x2d - IFT_X25 = 0x5 - IFT_X25DDN = 0x4 - IFT_X25PLE = 0x28 - IFT_XETHER = 0x1a - IGNBRK = 0x1 - IGNCR = 0x80 - IGNPAR = 0x4 - IMAXBEL = 0x2000 - INLCR = 0x40 - INPCK = 0x10 - IN_CLASSA_HOST = 0xffffff - IN_CLASSA_MAX = 0x80 - IN_CLASSA_NET = 0xff000000 - IN_CLASSA_NSHIFT = 0x18 - IN_CLASSB_HOST = 0xffff - IN_CLASSB_MAX = 0x10000 - IN_CLASSB_NET = 0xffff0000 - IN_CLASSB_NSHIFT = 0x10 - IN_CLASSC_HOST = 0xff - IN_CLASSC_NET = 0xffffff00 - IN_CLASSC_NSHIFT = 0x8 - IN_CLASSD_HOST = 0xfffffff - IN_CLASSD_NET = 0xf0000000 - IN_CLASSD_NSHIFT = 0x1c - IN_LINKLOCALNETNUM = 0xa9fe0000 - IN_LOOPBACKNET = 0x7f - IPPROTO_3PC = 0x22 - IPPROTO_ADFS = 0x44 - IPPROTO_AH = 0x33 - IPPROTO_AHIP = 0x3d - IPPROTO_APES = 0x63 - IPPROTO_ARGUS = 0xd - IPPROTO_AX25 = 0x5d - IPPROTO_BHA = 0x31 - IPPROTO_BLT = 0x1e - IPPROTO_BRSATMON = 0x4c - IPPROTO_CFTP = 0x3e - IPPROTO_CHAOS = 0x10 - IPPROTO_CMTP = 0x26 - IPPROTO_CPHB = 0x49 - IPPROTO_CPNX = 0x48 - IPPROTO_DDP = 0x25 - IPPROTO_DGP = 0x56 - IPPROTO_DIVERT = 0xfe - IPPROTO_DONE = 0x101 - IPPROTO_DSTOPTS = 0x3c - IPPROTO_EGP = 0x8 - IPPROTO_EMCON = 0xe - IPPROTO_ENCAP = 0x62 - IPPROTO_EON = 0x50 - IPPROTO_ESP = 0x32 - IPPROTO_ETHERIP = 0x61 - IPPROTO_FRAGMENT = 0x2c - IPPROTO_GGP = 0x3 - IPPROTO_GMTP = 0x64 - IPPROTO_GRE = 0x2f - IPPROTO_HELLO = 0x3f - IPPROTO_HMP = 0x14 - IPPROTO_HOPOPTS = 0x0 - IPPROTO_ICMP = 0x1 - IPPROTO_ICMPV6 = 0x3a - IPPROTO_IDP = 0x16 - IPPROTO_IDPR = 0x23 - IPPROTO_IDRP = 0x2d - IPPROTO_IGMP = 0x2 - IPPROTO_IGP = 0x55 - IPPROTO_IGRP = 0x58 - IPPROTO_IL = 0x28 - IPPROTO_INLSP = 0x34 - IPPROTO_INP = 0x20 - IPPROTO_IP = 0x0 - IPPROTO_IPCOMP = 0x6c - IPPROTO_IPCV = 0x47 - IPPROTO_IPEIP = 0x5e - IPPROTO_IPIP = 0x4 - IPPROTO_IPPC = 0x43 - IPPROTO_IPV4 = 0x4 - IPPROTO_IPV6 = 0x29 - IPPROTO_IRTP = 0x1c - IPPROTO_KRYPTOLAN = 0x41 - IPPROTO_LARP = 0x5b - IPPROTO_LEAF1 = 0x19 - IPPROTO_LEAF2 = 0x1a - IPPROTO_MAX = 0x100 - IPPROTO_MAXID = 0x34 - IPPROTO_MEAS = 0x13 - IPPROTO_MHRP = 0x30 - IPPROTO_MICP = 0x5f - IPPROTO_MTP = 0x5c - IPPROTO_MUX = 0x12 - IPPROTO_ND = 0x4d - IPPROTO_NHRP = 0x36 - IPPROTO_NONE = 0x3b - IPPROTO_NSP = 0x1f - IPPROTO_NVPII = 0xb - IPPROTO_OSPFIGP = 0x59 - IPPROTO_PGM = 0x71 - IPPROTO_PIGP = 0x9 - IPPROTO_PIM = 0x67 - IPPROTO_PRM = 0x15 - IPPROTO_PUP = 0xc - IPPROTO_PVP = 0x4b - IPPROTO_RAW = 0xff - IPPROTO_RCCMON = 0xa - IPPROTO_RDP = 0x1b - IPPROTO_ROUTING = 0x2b - IPPROTO_RSVP = 0x2e - IPPROTO_RVD = 0x42 - IPPROTO_SATEXPAK = 0x40 - IPPROTO_SATMON = 0x45 - IPPROTO_SCCSP = 0x60 - IPPROTO_SCTP = 0x84 - IPPROTO_SDRP = 0x2a - IPPROTO_SEP = 0x21 - IPPROTO_SRPC = 0x5a - IPPROTO_ST = 0x7 - IPPROTO_SVMTP = 0x52 - IPPROTO_SWIPE = 0x35 - IPPROTO_TCF = 0x57 - IPPROTO_TCP = 0x6 - IPPROTO_TP = 0x1d - IPPROTO_TPXX = 0x27 - IPPROTO_TRUNK1 = 0x17 - IPPROTO_TRUNK2 = 0x18 - IPPROTO_TTP = 0x54 - IPPROTO_UDP = 0x11 - IPPROTO_VINES = 0x53 - IPPROTO_VISA = 0x46 - IPPROTO_VMTP = 0x51 - IPPROTO_WBEXPAK = 0x4f - IPPROTO_WBMON = 0x4e - IPPROTO_WSN = 0x4a - IPPROTO_XNET = 0xf - IPPROTO_XTP = 0x24 - IPV6_2292DSTOPTS = 0x17 - IPV6_2292HOPLIMIT = 0x14 - IPV6_2292HOPOPTS = 0x16 - IPV6_2292NEXTHOP = 0x15 - IPV6_2292PKTINFO = 0x13 - IPV6_2292PKTOPTIONS = 0x19 - IPV6_2292RTHDR = 0x18 - IPV6_3542DSTOPTS = 0x32 - IPV6_3542HOPLIMIT = 0x2f - IPV6_3542HOPOPTS = 0x31 - IPV6_3542NEXTHOP = 0x30 - IPV6_3542PKTINFO = 0x2e - IPV6_3542RTHDR = 0x33 - IPV6_ADDR_MC_FLAGS_PREFIX = 0x20 - IPV6_ADDR_MC_FLAGS_TRANSIENT = 0x10 - IPV6_ADDR_MC_FLAGS_UNICAST_BASED = 0x30 - IPV6_AUTOFLOWLABEL = 0x3b - IPV6_BINDV6ONLY = 0x1b - IPV6_BOUND_IF = 0x7d - IPV6_CHECKSUM = 0x1a - IPV6_DEFAULT_MULTICAST_HOPS = 0x1 - IPV6_DEFAULT_MULTICAST_LOOP = 0x1 - IPV6_DEFHLIM = 0x40 - IPV6_DONTFRAG = 0x3e - IPV6_DSTOPTS = 0x32 - IPV6_FAITH = 0x1d - IPV6_FLOWINFO_MASK = 0xffffff0f - IPV6_FLOWLABEL_MASK = 0xffff0f00 - IPV6_FLOW_ECN_MASK = 0x3000 - IPV6_FRAGTTL = 0x3c - IPV6_FW_ADD = 0x1e - IPV6_FW_DEL = 0x1f - IPV6_FW_FLUSH = 0x20 - IPV6_FW_GET = 0x22 - IPV6_FW_ZERO = 0x21 - IPV6_HLIMDEC = 0x1 - IPV6_HOPLIMIT = 0x2f - IPV6_HOPOPTS = 0x31 - IPV6_IPSEC_POLICY = 0x1c - IPV6_JOIN_GROUP = 0xc - IPV6_LEAVE_GROUP = 0xd - IPV6_MAXHLIM = 0xff - IPV6_MAXOPTHDR = 0x800 - IPV6_MAXPACKET = 0xffff - IPV6_MAX_GROUP_SRC_FILTER = 0x200 - IPV6_MAX_MEMBERSHIPS = 0xfff - IPV6_MAX_SOCK_SRC_FILTER = 0x80 - IPV6_MIN_MEMBERSHIPS = 0x1f - IPV6_MMTU = 0x500 - IPV6_MSFILTER = 0x4a - IPV6_MULTICAST_HOPS = 0xa - IPV6_MULTICAST_IF = 0x9 - IPV6_MULTICAST_LOOP = 0xb - IPV6_NEXTHOP = 0x30 - IPV6_PATHMTU = 0x2c - IPV6_PKTINFO = 0x2e - IPV6_PORTRANGE = 0xe - IPV6_PORTRANGE_DEFAULT = 0x0 - IPV6_PORTRANGE_HIGH = 0x1 - IPV6_PORTRANGE_LOW = 0x2 - IPV6_PREFER_TEMPADDR = 0x3f - IPV6_RECVDSTOPTS = 0x28 - IPV6_RECVHOPLIMIT = 0x25 - IPV6_RECVHOPOPTS = 0x27 - IPV6_RECVPATHMTU = 0x2b - IPV6_RECVPKTINFO = 0x3d - IPV6_RECVRTHDR = 0x26 - IPV6_RECVTCLASS = 0x23 - IPV6_RTHDR = 0x33 - IPV6_RTHDRDSTOPTS = 0x39 - IPV6_RTHDR_LOOSE = 0x0 - IPV6_RTHDR_STRICT = 0x1 - IPV6_RTHDR_TYPE_0 = 0x0 - IPV6_SOCKOPT_RESERVED1 = 0x3 - IPV6_TCLASS = 0x24 - IPV6_UNICAST_HOPS = 0x4 - IPV6_USE_MIN_MTU = 0x2a - IPV6_V6ONLY = 0x1b - IPV6_VERSION = 0x60 - IPV6_VERSION_MASK = 0xf0 - IP_ADD_MEMBERSHIP = 0xc - IP_ADD_SOURCE_MEMBERSHIP = 0x46 - IP_BLOCK_SOURCE = 0x48 - IP_BOUND_IF = 0x19 - IP_DEFAULT_MULTICAST_LOOP = 0x1 - IP_DEFAULT_MULTICAST_TTL = 0x1 - IP_DF = 0x4000 - IP_DONTFRAG = 0x1c - IP_DROP_MEMBERSHIP = 0xd - IP_DROP_SOURCE_MEMBERSHIP = 0x47 - IP_DUMMYNET_CONFIGURE = 0x3c - IP_DUMMYNET_DEL = 0x3d - IP_DUMMYNET_FLUSH = 0x3e - IP_DUMMYNET_GET = 0x40 - IP_FAITH = 0x16 - IP_FW_ADD = 0x28 - IP_FW_DEL = 0x29 - IP_FW_FLUSH = 0x2a - IP_FW_GET = 0x2c - IP_FW_RESETLOG = 0x2d - IP_FW_ZERO = 0x2b - IP_HDRINCL = 0x2 - IP_IPSEC_POLICY = 0x15 - IP_MAXPACKET = 0xffff - IP_MAX_GROUP_SRC_FILTER = 0x200 - IP_MAX_MEMBERSHIPS = 0xfff - IP_MAX_SOCK_MUTE_FILTER = 0x80 - IP_MAX_SOCK_SRC_FILTER = 0x80 - IP_MF = 0x2000 - IP_MIN_MEMBERSHIPS = 0x1f - IP_MSFILTER = 0x4a - IP_MSS = 0x240 - IP_MULTICAST_IF = 0x9 - IP_MULTICAST_IFINDEX = 0x42 - IP_MULTICAST_LOOP = 0xb - IP_MULTICAST_TTL = 0xa - IP_MULTICAST_VIF = 0xe - IP_NAT__XXX = 0x37 - IP_OFFMASK = 0x1fff - IP_OLD_FW_ADD = 0x32 - IP_OLD_FW_DEL = 0x33 - IP_OLD_FW_FLUSH = 0x34 - IP_OLD_FW_GET = 0x36 - IP_OLD_FW_RESETLOG = 0x38 - IP_OLD_FW_ZERO = 0x35 - IP_OPTIONS = 0x1 - IP_PKTINFO = 0x1a - IP_PORTRANGE = 0x13 - IP_PORTRANGE_DEFAULT = 0x0 - IP_PORTRANGE_HIGH = 0x1 - IP_PORTRANGE_LOW = 0x2 - IP_RECVDSTADDR = 0x7 - IP_RECVIF = 0x14 - IP_RECVOPTS = 0x5 - IP_RECVPKTINFO = 0x1a - IP_RECVRETOPTS = 0x6 - IP_RECVTOS = 0x1b - IP_RECVTTL = 0x18 - IP_RETOPTS = 0x8 - IP_RF = 0x8000 - IP_RSVP_OFF = 0x10 - IP_RSVP_ON = 0xf - IP_RSVP_VIF_OFF = 0x12 - IP_RSVP_VIF_ON = 0x11 - IP_STRIPHDR = 0x17 - IP_TOS = 0x3 - IP_TRAFFIC_MGT_BACKGROUND = 0x41 - IP_TTL = 0x4 - IP_UNBLOCK_SOURCE = 0x49 - ISIG = 0x80 - ISTRIP = 0x20 - IUTF8 = 0x4000 - IXANY = 0x800 - IXOFF = 0x400 - IXON = 0x200 - KERN_HOSTNAME = 0xa - KERN_OSRELEASE = 0x2 - KERN_OSTYPE = 0x1 - KERN_VERSION = 0x4 - LOCAL_PEERCRED = 0x1 - LOCAL_PEEREPID = 0x3 - LOCAL_PEEREUUID = 0x5 - LOCAL_PEERPID = 0x2 - LOCAL_PEERTOKEN = 0x6 - LOCAL_PEERUUID = 0x4 - LOCK_EX = 0x2 - LOCK_NB = 0x4 - LOCK_SH = 0x1 - LOCK_UN = 0x8 - MADV_CAN_REUSE = 0x9 - MADV_DONTNEED = 0x4 - MADV_FREE = 0x5 - MADV_FREE_REUSABLE = 0x7 - MADV_FREE_REUSE = 0x8 - MADV_NORMAL = 0x0 - MADV_PAGEOUT = 0xa - MADV_RANDOM = 0x1 - MADV_SEQUENTIAL = 0x2 - MADV_WILLNEED = 0x3 - MADV_ZERO_WIRED_PAGES = 0x6 - MAP_32BIT = 0x8000 - MAP_ANON = 0x1000 - MAP_ANONYMOUS = 0x1000 - MAP_COPY = 0x2 - MAP_FILE = 0x0 - MAP_FIXED = 0x10 - MAP_HASSEMAPHORE = 0x200 - MAP_JIT = 0x800 - MAP_NOCACHE = 0x400 - MAP_NOEXTEND = 0x100 - MAP_NORESERVE = 0x40 - MAP_PRIVATE = 0x2 - MAP_RENAME = 0x20 - MAP_RESERVED0080 = 0x80 - MAP_RESILIENT_CODESIGN = 0x2000 - MAP_RESILIENT_MEDIA = 0x4000 - MAP_SHARED = 0x1 - MAP_TRANSLATED_ALLOW_EXECUTE = 0x20000 - MAP_UNIX03 = 0x40000 - MCAST_BLOCK_SOURCE = 0x54 - MCAST_EXCLUDE = 0x2 - MCAST_INCLUDE = 0x1 - MCAST_JOIN_GROUP = 0x50 - MCAST_JOIN_SOURCE_GROUP = 0x52 - MCAST_LEAVE_GROUP = 0x51 - MCAST_LEAVE_SOURCE_GROUP = 0x53 - MCAST_UNBLOCK_SOURCE = 0x55 - MCAST_UNDEFINED = 0x0 - MCL_CURRENT = 0x1 - MCL_FUTURE = 0x2 - MNT_ASYNC = 0x40 - MNT_AUTOMOUNTED = 0x400000 - MNT_CMDFLAGS = 0xf0000 - MNT_CPROTECT = 0x80 - MNT_DEFWRITE = 0x2000000 - MNT_DONTBROWSE = 0x100000 - MNT_DOVOLFS = 0x8000 - MNT_DWAIT = 0x4 - MNT_EXPORTED = 0x100 - MNT_EXT_ROOT_DATA_VOL = 0x1 - MNT_FORCE = 0x80000 - MNT_IGNORE_OWNERSHIP = 0x200000 - MNT_JOURNALED = 0x800000 - MNT_LOCAL = 0x1000 - MNT_MULTILABEL = 0x4000000 - MNT_NOATIME = 0x10000000 - MNT_NOBLOCK = 0x20000 - MNT_NODEV = 0x10 - MNT_NOEXEC = 0x4 - MNT_NOSUID = 0x8 - MNT_NOUSERXATTR = 0x1000000 - MNT_NOWAIT = 0x2 - MNT_QUARANTINE = 0x400 - MNT_QUOTA = 0x2000 - MNT_RDONLY = 0x1 - MNT_RELOAD = 0x40000 - MNT_REMOVABLE = 0x200 - MNT_ROOTFS = 0x4000 - MNT_SNAPSHOT = 0x40000000 - MNT_STRICTATIME = 0x80000000 - MNT_SYNCHRONOUS = 0x2 - MNT_UNION = 0x20 - MNT_UNKNOWNPERMISSIONS = 0x200000 - MNT_UPDATE = 0x10000 - MNT_VISFLAGMASK = 0xd7f0f7ff - MNT_WAIT = 0x1 - MSG_CTRUNC = 0x20 - MSG_DONTROUTE = 0x4 - MSG_DONTWAIT = 0x80 - MSG_EOF = 0x100 - MSG_EOR = 0x8 - MSG_FLUSH = 0x400 - MSG_HAVEMORE = 0x2000 - MSG_HOLD = 0x800 - MSG_NEEDSA = 0x10000 - MSG_NOSIGNAL = 0x80000 - MSG_OOB = 0x1 - MSG_PEEK = 0x2 - MSG_RCVMORE = 0x4000 - MSG_SEND = 0x1000 - MSG_TRUNC = 0x10 - MSG_WAITALL = 0x40 - MSG_WAITSTREAM = 0x200 - MS_ASYNC = 0x1 - MS_DEACTIVATE = 0x8 - MS_INVALIDATE = 0x2 - MS_KILLPAGES = 0x4 - MS_SYNC = 0x10 - NAME_MAX = 0xff - NET_RT_DUMP = 0x1 - NET_RT_DUMP2 = 0x7 - NET_RT_FLAGS = 0x2 - NET_RT_FLAGS_PRIV = 0xa - NET_RT_IFLIST = 0x3 - NET_RT_IFLIST2 = 0x6 - NET_RT_MAXID = 0xb - NET_RT_STAT = 0x4 - NET_RT_TRASH = 0x5 - NFDBITS = 0x20 - NL0 = 0x0 - NL1 = 0x100 - NL2 = 0x200 - NL3 = 0x300 - NLDLY = 0x300 - NOFLSH = 0x80000000 - NOKERNINFO = 0x2000000 - NOTE_ABSOLUTE = 0x8 - NOTE_ATTRIB = 0x8 - NOTE_BACKGROUND = 0x40 - NOTE_CHILD = 0x4 - NOTE_CRITICAL = 0x20 - NOTE_DELETE = 0x1 - NOTE_EXEC = 0x20000000 - NOTE_EXIT = 0x80000000 - NOTE_EXITSTATUS = 0x4000000 - NOTE_EXIT_CSERROR = 0x40000 - NOTE_EXIT_DECRYPTFAIL = 0x10000 - NOTE_EXIT_DETAIL = 0x2000000 - NOTE_EXIT_DETAIL_MASK = 0x70000 - NOTE_EXIT_MEMORY = 0x20000 - NOTE_EXIT_REPARENTED = 0x80000 - NOTE_EXTEND = 0x4 - NOTE_FFAND = 0x40000000 - NOTE_FFCOPY = 0xc0000000 - NOTE_FFCTRLMASK = 0xc0000000 - NOTE_FFLAGSMASK = 0xffffff - NOTE_FFNOP = 0x0 - NOTE_FFOR = 0x80000000 - NOTE_FORK = 0x40000000 - NOTE_FUNLOCK = 0x100 - NOTE_LEEWAY = 0x10 - NOTE_LINK = 0x10 - NOTE_LOWAT = 0x1 - NOTE_MACHTIME = 0x100 - NOTE_MACH_CONTINUOUS_TIME = 0x80 - NOTE_NONE = 0x80 - NOTE_NSECONDS = 0x4 - NOTE_OOB = 0x2 - NOTE_PCTRLMASK = -0x100000 - NOTE_PDATAMASK = 0xfffff - NOTE_REAP = 0x10000000 - NOTE_RENAME = 0x20 - NOTE_REVOKE = 0x40 - NOTE_SECONDS = 0x1 - NOTE_SIGNAL = 0x8000000 - NOTE_TRACK = 0x1 - NOTE_TRACKERR = 0x2 - NOTE_TRIGGER = 0x1000000 - NOTE_USECONDS = 0x2 - NOTE_VM_ERROR = 0x10000000 - NOTE_VM_PRESSURE = 0x80000000 - NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000 - NOTE_VM_PRESSURE_TERMINATE = 0x40000000 - NOTE_WRITE = 0x2 - OCRNL = 0x10 - OFDEL = 0x20000 - OFILL = 0x80 - ONLCR = 0x2 - ONLRET = 0x40 - ONOCR = 0x20 - ONOEOT = 0x8 - OPOST = 0x1 - OXTABS = 0x4 - O_ACCMODE = 0x3 - O_ALERT = 0x20000000 - O_APPEND = 0x8 - O_ASYNC = 0x40 - O_CLOEXEC = 0x1000000 - O_CREAT = 0x200 - O_DIRECTORY = 0x100000 - O_DP_GETRAWENCRYPTED = 0x1 - O_DP_GETRAWUNENCRYPTED = 0x2 - O_DSYNC = 0x400000 - O_EVTONLY = 0x8000 - O_EXCL = 0x800 - O_EXLOCK = 0x20 - O_FSYNC = 0x80 - O_NDELAY = 0x4 - O_NOCTTY = 0x20000 - O_NOFOLLOW = 0x100 - O_NOFOLLOW_ANY = 0x20000000 - O_NONBLOCK = 0x4 - O_POPUP = 0x80000000 - O_RDONLY = 0x0 - O_RDWR = 0x2 - O_SHLOCK = 0x10 - O_SYMLINK = 0x200000 - O_SYNC = 0x80 - O_TRUNC = 0x400 - O_WRONLY = 0x1 - PARENB = 0x1000 - PARMRK = 0x8 - PARODD = 0x2000 - PENDIN = 0x20000000 - PRIO_PGRP = 0x1 - PRIO_PROCESS = 0x0 - PRIO_USER = 0x2 - PROT_EXEC = 0x4 - PROT_NONE = 0x0 - PROT_READ = 0x1 - PROT_WRITE = 0x2 - PT_ATTACH = 0xa - PT_ATTACHEXC = 0xe - PT_CONTINUE = 0x7 - PT_DENY_ATTACH = 0x1f - PT_DETACH = 0xb - PT_FIRSTMACH = 0x20 - PT_FORCEQUOTA = 0x1e - PT_KILL = 0x8 - PT_READ_D = 0x2 - PT_READ_I = 0x1 - PT_READ_U = 0x3 - PT_SIGEXC = 0xc - PT_STEP = 0x9 - PT_THUPDATE = 0xd - PT_TRACE_ME = 0x0 - PT_WRITE_D = 0x5 - PT_WRITE_I = 0x4 - PT_WRITE_U = 0x6 - RLIMIT_AS = 0x5 - RLIMIT_CORE = 0x4 - RLIMIT_CPU = 0x0 - RLIMIT_CPU_USAGE_MONITOR = 0x2 - RLIMIT_DATA = 0x2 - RLIMIT_FSIZE = 0x1 - RLIMIT_MEMLOCK = 0x6 - RLIMIT_NOFILE = 0x8 - RLIMIT_NPROC = 0x7 - RLIMIT_RSS = 0x5 - RLIMIT_STACK = 0x3 - RLIM_INFINITY = 0x7fffffffffffffff - RTAX_AUTHOR = 0x6 - RTAX_BRD = 0x7 - RTAX_DST = 0x0 - RTAX_GATEWAY = 0x1 - RTAX_GENMASK = 0x3 - RTAX_IFA = 0x5 - RTAX_IFP = 0x4 - RTAX_MAX = 0x8 - RTAX_NETMASK = 0x2 - RTA_AUTHOR = 0x40 - RTA_BRD = 0x80 - RTA_DST = 0x1 - RTA_GATEWAY = 0x2 - RTA_GENMASK = 0x8 - RTA_IFA = 0x20 - RTA_IFP = 0x10 - RTA_NETMASK = 0x4 - RTF_BLACKHOLE = 0x1000 - RTF_BROADCAST = 0x400000 - RTF_CLONING = 0x100 - RTF_CONDEMNED = 0x2000000 - RTF_DEAD = 0x20000000 - RTF_DELCLONE = 0x80 - RTF_DONE = 0x40 - RTF_DYNAMIC = 0x10 - RTF_GATEWAY = 0x2 - RTF_GLOBAL = 0x40000000 - RTF_HOST = 0x4 - RTF_IFREF = 0x4000000 - RTF_IFSCOPE = 0x1000000 - RTF_LLDATA = 0x400 - RTF_LLINFO = 0x400 - RTF_LOCAL = 0x200000 - RTF_MODIFIED = 0x20 - RTF_MULTICAST = 0x800000 - RTF_NOIFREF = 0x2000 - RTF_PINNED = 0x100000 - RTF_PRCLONING = 0x10000 - RTF_PROTO1 = 0x8000 - RTF_PROTO2 = 0x4000 - RTF_PROTO3 = 0x40000 - RTF_PROXY = 0x8000000 - RTF_REJECT = 0x8 - RTF_ROUTER = 0x10000000 - RTF_STATIC = 0x800 - RTF_UP = 0x1 - RTF_WASCLONED = 0x20000 - RTF_XRESOLVE = 0x200 - RTM_ADD = 0x1 - RTM_CHANGE = 0x3 - RTM_DELADDR = 0xd - RTM_DELETE = 0x2 - RTM_DELMADDR = 0x10 - RTM_GET = 0x4 - RTM_GET2 = 0x14 - RTM_IFINFO = 0xe - RTM_IFINFO2 = 0x12 - RTM_LOCK = 0x8 - RTM_LOSING = 0x5 - RTM_MISS = 0x7 - RTM_NEWADDR = 0xc - RTM_NEWMADDR = 0xf - RTM_NEWMADDR2 = 0x13 - RTM_OLDADD = 0x9 - RTM_OLDDEL = 0xa - RTM_REDIRECT = 0x6 - RTM_RESOLVE = 0xb - RTM_RTTUNIT = 0xf4240 - RTM_VERSION = 0x5 - RTV_EXPIRE = 0x4 - RTV_HOPCOUNT = 0x2 - RTV_MTU = 0x1 - RTV_RPIPE = 0x8 - RTV_RTT = 0x40 - RTV_RTTVAR = 0x80 - RTV_SPIPE = 0x10 - RTV_SSTHRESH = 0x20 - RUSAGE_CHILDREN = -0x1 - RUSAGE_SELF = 0x0 - SCM_CREDS = 0x3 - SCM_RIGHTS = 0x1 - SCM_TIMESTAMP = 0x2 - SCM_TIMESTAMP_MONOTONIC = 0x4 - SEEK_CUR = 0x1 - SEEK_DATA = 0x4 - SEEK_END = 0x2 - SEEK_HOLE = 0x3 - SEEK_SET = 0x0 - SHUT_RD = 0x0 - SHUT_RDWR = 0x2 - SHUT_WR = 0x1 - SIOCADDMULTI = 0x80206931 - SIOCAIFADDR = 0x8040691a - SIOCARPIPLL = 0xc0206928 - SIOCATMARK = 0x40047307 - SIOCAUTOADDR = 0xc0206926 - SIOCAUTONETMASK = 0x80206927 - SIOCDELMULTI = 0x80206932 - SIOCDIFADDR = 0x80206919 - SIOCDIFPHYADDR = 0x80206941 - SIOCGDRVSPEC = 0xc028697b - SIOCGETVLAN = 0xc020697f - SIOCGHIWAT = 0x40047301 - SIOCGIF6LOWPAN = 0xc02069c5 - SIOCGIFADDR = 0xc0206921 - SIOCGIFALTMTU = 0xc0206948 - SIOCGIFASYNCMAP = 0xc020697c - SIOCGIFBOND = 0xc0206947 - SIOCGIFBRDADDR = 0xc0206923 - SIOCGIFCAP = 0xc020695b - SIOCGIFCONF = 0xc00c6924 - SIOCGIFDEVMTU = 0xc0206944 - SIOCGIFDSTADDR = 0xc0206922 - SIOCGIFFLAGS = 0xc0206911 - SIOCGIFFUNCTIONALTYPE = 0xc02069ad - SIOCGIFGENERIC = 0xc020693a - SIOCGIFKPI = 0xc0206987 - SIOCGIFMAC = 0xc0206982 - SIOCGIFMEDIA = 0xc02c6938 - SIOCGIFMETRIC = 0xc0206917 - SIOCGIFMTU = 0xc0206933 - SIOCGIFNETMASK = 0xc0206925 - SIOCGIFPDSTADDR = 0xc0206940 - SIOCGIFPHYS = 0xc0206935 - SIOCGIFPSRCADDR = 0xc020693f - SIOCGIFSTATUS = 0xc331693d - SIOCGIFVLAN = 0xc020697f - SIOCGIFWAKEFLAGS = 0xc0206988 - SIOCGIFXMEDIA = 0xc02c6948 - SIOCGLOWAT = 0x40047303 - SIOCGPGRP = 0x40047309 - SIOCIFCREATE = 0xc0206978 - SIOCIFCREATE2 = 0xc020697a - SIOCIFDESTROY = 0x80206979 - SIOCIFGCLONERS = 0xc0106981 - SIOCRSLVMULTI = 0xc010693b - SIOCSDRVSPEC = 0x8028697b - SIOCSETVLAN = 0x8020697e - SIOCSHIWAT = 0x80047300 - SIOCSIF6LOWPAN = 0x802069c4 - SIOCSIFADDR = 0x8020690c - SIOCSIFALTMTU = 0x80206945 - SIOCSIFASYNCMAP = 0x8020697d - SIOCSIFBOND = 0x80206946 - SIOCSIFBRDADDR = 0x80206913 - SIOCSIFCAP = 0x8020695a - SIOCSIFDSTADDR = 0x8020690e - SIOCSIFFLAGS = 0x80206910 - SIOCSIFGENERIC = 0x80206939 - SIOCSIFKPI = 0x80206986 - SIOCSIFLLADDR = 0x8020693c - SIOCSIFMAC = 0x80206983 - SIOCSIFMEDIA = 0xc0206937 - SIOCSIFMETRIC = 0x80206918 - SIOCSIFMTU = 0x80206934 - SIOCSIFNETMASK = 0x80206916 - SIOCSIFPHYADDR = 0x8040693e - SIOCSIFPHYS = 0x80206936 - SIOCSIFVLAN = 0x8020697e - SIOCSLOWAT = 0x80047302 - SIOCSPGRP = 0x80047308 - SOCK_DGRAM = 0x2 - SOCK_MAXADDRLEN = 0xff - SOCK_RAW = 0x3 - SOCK_RDM = 0x4 - SOCK_SEQPACKET = 0x5 - SOCK_STREAM = 0x1 - SOL_LOCAL = 0x0 - SOL_SOCKET = 0xffff - SOMAXCONN = 0x80 - SO_ACCEPTCONN = 0x2 - SO_BROADCAST = 0x20 - SO_DEBUG = 0x1 - SO_DONTROUTE = 0x10 - SO_DONTTRUNC = 0x2000 - SO_ERROR = 0x1007 - SO_KEEPALIVE = 0x8 - SO_LABEL = 0x1010 - SO_LINGER = 0x80 - SO_LINGER_SEC = 0x1080 - SO_NETSVC_MARKING_LEVEL = 0x1119 - SO_NET_SERVICE_TYPE = 0x1116 - SO_NKE = 0x1021 - SO_NOADDRERR = 0x1023 - SO_NOSIGPIPE = 0x1022 - SO_NOTIFYCONFLICT = 0x1026 - SO_NP_EXTENSIONS = 0x1083 - SO_NREAD = 0x1020 - SO_NUMRCVPKT = 0x1112 - SO_NWRITE = 0x1024 - SO_OOBINLINE = 0x100 - SO_PEERLABEL = 0x1011 - SO_RANDOMPORT = 0x1082 - SO_RCVBUF = 0x1002 - SO_RCVLOWAT = 0x1004 - SO_RCVTIMEO = 0x1006 - SO_REUSEADDR = 0x4 - SO_REUSEPORT = 0x200 - SO_REUSESHAREUID = 0x1025 - SO_SNDBUF = 0x1001 - SO_SNDLOWAT = 0x1003 - SO_SNDTIMEO = 0x1005 - SO_TIMESTAMP = 0x400 - SO_TIMESTAMP_MONOTONIC = 0x800 - SO_TYPE = 0x1008 - SO_UPCALLCLOSEWAIT = 0x1027 - SO_USELOOPBACK = 0x40 - SO_WANTMORE = 0x4000 - SO_WANTOOBFLAG = 0x8000 - S_IEXEC = 0x40 - S_IFBLK = 0x6000 - S_IFCHR = 0x2000 - S_IFDIR = 0x4000 - S_IFIFO = 0x1000 - S_IFLNK = 0xa000 - S_IFMT = 0xf000 - S_IFREG = 0x8000 - S_IFSOCK = 0xc000 - S_IFWHT = 0xe000 - S_IREAD = 0x100 - S_IRGRP = 0x20 - S_IROTH = 0x4 - S_IRUSR = 0x100 - S_IRWXG = 0x38 - S_IRWXO = 0x7 - S_IRWXU = 0x1c0 - S_ISGID = 0x400 - S_ISTXT = 0x200 - S_ISUID = 0x800 - S_ISVTX = 0x200 - S_IWGRP = 0x10 - S_IWOTH = 0x2 - S_IWRITE = 0x80 - S_IWUSR = 0x80 - S_IXGRP = 0x8 - S_IXOTH = 0x1 - S_IXUSR = 0x40 - TAB0 = 0x0 - TAB1 = 0x400 - TAB2 = 0x800 - TAB3 = 0x4 - TABDLY = 0xc04 - TCIFLUSH = 0x1 - TCIOFF = 0x3 - TCIOFLUSH = 0x3 - TCION = 0x4 - TCOFLUSH = 0x2 - TCOOFF = 0x1 - TCOON = 0x2 - TCP_CONNECTIONTIMEOUT = 0x20 - TCP_CONNECTION_INFO = 0x106 - TCP_ENABLE_ECN = 0x104 - TCP_FASTOPEN = 0x105 - TCP_KEEPALIVE = 0x10 - TCP_KEEPCNT = 0x102 - TCP_KEEPINTVL = 0x101 - TCP_MAXHLEN = 0x3c - TCP_MAXOLEN = 0x28 - TCP_MAXSEG = 0x2 - TCP_MAXWIN = 0xffff - TCP_MAX_SACK = 0x4 - TCP_MAX_WINSHIFT = 0xe - TCP_MINMSS = 0xd8 - TCP_MSS = 0x200 - TCP_NODELAY = 0x1 - TCP_NOOPT = 0x8 - TCP_NOPUSH = 0x4 - TCP_NOTSENT_LOWAT = 0x201 - TCP_RXT_CONNDROPTIME = 0x80 - TCP_RXT_FINDROP = 0x100 - TCP_SENDMOREACKS = 0x103 - TCSAFLUSH = 0x2 - TIOCCBRK = 0x2000747a - TIOCCDTR = 0x20007478 - TIOCCONS = 0x80047462 - TIOCDCDTIMESTAMP = 0x40107458 - TIOCDRAIN = 0x2000745e - TIOCDSIMICROCODE = 0x20007455 - TIOCEXCL = 0x2000740d - TIOCEXT = 0x80047460 - TIOCFLUSH = 0x80047410 - TIOCGDRAINWAIT = 0x40047456 - TIOCGETA = 0x40487413 - TIOCGETD = 0x4004741a - TIOCGPGRP = 0x40047477 - TIOCGWINSZ = 0x40087468 - TIOCIXOFF = 0x20007480 - TIOCIXON = 0x20007481 - TIOCMBIC = 0x8004746b - TIOCMBIS = 0x8004746c - TIOCMGDTRWAIT = 0x4004745a - TIOCMGET = 0x4004746a - TIOCMODG = 0x40047403 - TIOCMODS = 0x80047404 - TIOCMSDTRWAIT = 0x8004745b - TIOCMSET = 0x8004746d - TIOCM_CAR = 0x40 - TIOCM_CD = 0x40 - TIOCM_CTS = 0x20 - TIOCM_DSR = 0x100 - TIOCM_DTR = 0x2 - TIOCM_LE = 0x1 - TIOCM_RI = 0x80 - TIOCM_RNG = 0x80 - TIOCM_RTS = 0x4 - TIOCM_SR = 0x10 - TIOCM_ST = 0x8 - TIOCNOTTY = 0x20007471 - TIOCNXCL = 0x2000740e - TIOCOUTQ = 0x40047473 - TIOCPKT = 0x80047470 - TIOCPKT_DATA = 0x0 - TIOCPKT_DOSTOP = 0x20 - TIOCPKT_FLUSHREAD = 0x1 - TIOCPKT_FLUSHWRITE = 0x2 - TIOCPKT_IOCTL = 0x40 - TIOCPKT_NOSTOP = 0x10 - TIOCPKT_START = 0x8 - TIOCPKT_STOP = 0x4 - TIOCPTYGNAME = 0x40807453 - TIOCPTYGRANT = 0x20007454 - TIOCPTYUNLK = 0x20007452 - TIOCREMOTE = 0x80047469 - TIOCSBRK = 0x2000747b - TIOCSCONS = 0x20007463 - TIOCSCTTY = 0x20007461 - TIOCSDRAINWAIT = 0x80047457 - TIOCSDTR = 0x20007479 - TIOCSETA = 0x80487414 - TIOCSETAF = 0x80487416 - TIOCSETAW = 0x80487415 - TIOCSETD = 0x8004741b - TIOCSIG = 0x2000745f - TIOCSPGRP = 0x80047476 - TIOCSTART = 0x2000746e - TIOCSTAT = 0x20007465 - TIOCSTI = 0x80017472 - TIOCSTOP = 0x2000746f - TIOCSWINSZ = 0x80087467 - TIOCTIMESTAMP = 0x40107459 - TIOCUCNTL = 0x80047466 - TOSTOP = 0x400000 - VDISCARD = 0xf - VDSUSP = 0xb - VEOF = 0x0 - VEOL = 0x1 - VEOL2 = 0x2 - VERASE = 0x3 - VINTR = 0x8 - VKILL = 0x5 - VLNEXT = 0xe - VMIN = 0x10 - VM_LOADAVG = 0x2 - VM_MACHFACTOR = 0x4 - VM_MAXID = 0x6 - VM_METER = 0x1 - VM_SWAPUSAGE = 0x5 - VQUIT = 0x9 - VREPRINT = 0x6 - VSTART = 0xc - VSTATUS = 0x12 - VSTOP = 0xd - VSUSP = 0xa - VT0 = 0x0 - VT1 = 0x10000 - VTDLY = 0x10000 - VTIME = 0x11 - VWERASE = 0x4 - WCONTINUED = 0x10 - WCOREFLAG = 0x80 - WEXITED = 0x4 - WNOHANG = 0x1 - WNOWAIT = 0x20 - WORDSIZE = 0x40 - WSTOPPED = 0x8 - WUNTRACED = 0x2 - XATTR_CREATE = 0x2 - XATTR_NODEFAULT = 0x10 - XATTR_NOFOLLOW = 0x1 - XATTR_NOSECURITY = 0x8 - XATTR_REPLACE = 0x4 - XATTR_SHOWCOMPRESSION = 0x20 + AF_APPLETALK = 0x10 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1c + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1e + AF_IPX = 0x17 + AF_ISDN = 0x1c + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_NATM = 0x1f + AF_NDRV = 0x1b + AF_NETBIOS = 0x21 + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PPP = 0x22 + AF_PUP = 0x4 + AF_RESERVED_36 = 0x24 + AF_ROUTE = 0x11 + AF_SIP = 0x18 + AF_SNA = 0xb + AF_SYSTEM = 0x20 + AF_SYS_CONTROL = 0x2 + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_UTUN = 0x26 + AF_VSOCK = 0x28 + ALTWERASE = 0x200 + ATTR_BIT_MAP_COUNT = 0x5 + ATTR_CMN_ACCESSMASK = 0x20000 + ATTR_CMN_ACCTIME = 0x1000 + ATTR_CMN_ADDEDTIME = 0x10000000 + ATTR_CMN_BKUPTIME = 0x2000 + ATTR_CMN_CHGTIME = 0x800 + ATTR_CMN_CRTIME = 0x200 + ATTR_CMN_DATA_PROTECT_FLAGS = 0x40000000 + ATTR_CMN_DEVID = 0x2 + ATTR_CMN_DOCUMENT_ID = 0x100000 + ATTR_CMN_ERROR = 0x20000000 + ATTR_CMN_EXTENDED_SECURITY = 0x400000 + ATTR_CMN_FILEID = 0x2000000 + ATTR_CMN_FLAGS = 0x40000 + ATTR_CMN_FNDRINFO = 0x4000 + ATTR_CMN_FSID = 0x4 + ATTR_CMN_FULLPATH = 0x8000000 + ATTR_CMN_GEN_COUNT = 0x80000 + ATTR_CMN_GRPID = 0x10000 + ATTR_CMN_GRPUUID = 0x1000000 + ATTR_CMN_MODTIME = 0x400 + ATTR_CMN_NAME = 0x1 + ATTR_CMN_NAMEDATTRCOUNT = 0x80000 + ATTR_CMN_NAMEDATTRLIST = 0x100000 + ATTR_CMN_OBJID = 0x20 + ATTR_CMN_OBJPERMANENTID = 0x40 + ATTR_CMN_OBJTAG = 0x10 + ATTR_CMN_OBJTYPE = 0x8 + ATTR_CMN_OWNERID = 0x8000 + ATTR_CMN_PARENTID = 0x4000000 + ATTR_CMN_PAROBJID = 0x80 + ATTR_CMN_RETURNED_ATTRS = 0x80000000 + ATTR_CMN_SCRIPT = 0x100 + ATTR_CMN_SETMASK = 0x51c7ff00 + ATTR_CMN_USERACCESS = 0x200000 + ATTR_CMN_UUID = 0x800000 + ATTR_CMN_VALIDMASK = 0xffffffff + ATTR_CMN_VOLSETMASK = 0x6700 + ATTR_FILE_ALLOCSIZE = 0x4 + ATTR_FILE_CLUMPSIZE = 0x10 + ATTR_FILE_DATAALLOCSIZE = 0x400 + ATTR_FILE_DATAEXTENTS = 0x800 + ATTR_FILE_DATALENGTH = 0x200 + ATTR_FILE_DEVTYPE = 0x20 + ATTR_FILE_FILETYPE = 0x40 + ATTR_FILE_FORKCOUNT = 0x80 + ATTR_FILE_FORKLIST = 0x100 + ATTR_FILE_IOBLOCKSIZE = 0x8 + ATTR_FILE_LINKCOUNT = 0x1 + ATTR_FILE_RSRCALLOCSIZE = 0x2000 + ATTR_FILE_RSRCEXTENTS = 0x4000 + ATTR_FILE_RSRCLENGTH = 0x1000 + ATTR_FILE_SETMASK = 0x20 + ATTR_FILE_TOTALSIZE = 0x2 + ATTR_FILE_VALIDMASK = 0x37ff + ATTR_VOL_ALLOCATIONCLUMP = 0x40 + ATTR_VOL_ATTRIBUTES = 0x40000000 + ATTR_VOL_CAPABILITIES = 0x20000 + ATTR_VOL_DIRCOUNT = 0x400 + ATTR_VOL_ENCODINGSUSED = 0x10000 + ATTR_VOL_FILECOUNT = 0x200 + ATTR_VOL_FSTYPE = 0x1 + ATTR_VOL_INFO = 0x80000000 + ATTR_VOL_IOBLOCKSIZE = 0x80 + ATTR_VOL_MAXOBJCOUNT = 0x800 + ATTR_VOL_MINALLOCATION = 0x20 + ATTR_VOL_MOUNTEDDEVICE = 0x8000 + ATTR_VOL_MOUNTFLAGS = 0x4000 + ATTR_VOL_MOUNTPOINT = 0x1000 + ATTR_VOL_NAME = 0x2000 + ATTR_VOL_OBJCOUNT = 0x100 + ATTR_VOL_QUOTA_SIZE = 0x10000000 + ATTR_VOL_RESERVED_SIZE = 0x20000000 + ATTR_VOL_SETMASK = 0x80002000 + ATTR_VOL_SIGNATURE = 0x2 + ATTR_VOL_SIZE = 0x4 + ATTR_VOL_SPACEAVAIL = 0x10 + ATTR_VOL_SPACEFREE = 0x8 + ATTR_VOL_SPACEUSED = 0x800000 + ATTR_VOL_UUID = 0x40000 + ATTR_VOL_VALIDMASK = 0xf087ffff + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc00c4279 + BIOCGETIF = 0x4020426b + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDLT = 0x80044278 + BIOCSETF = 0x80104267 + BIOCSETFNR = 0x8010427e + BIOCSETIF = 0x8020426c + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8010426d + BIOCSSEESENT = 0x80044277 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x8000 + BSDLY = 0x8000 + CFLUSH = 0xf + CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_MONOTONIC_RAW_APPROX = 0x5 + CLOCK_PROCESS_CPUTIME_ID = 0xc + CLOCK_REALTIME = 0x0 + CLOCK_THREAD_CPUTIME_ID = 0x10 + CLOCK_UPTIME_RAW = 0x8 + CLOCK_UPTIME_RAW_APPROX = 0x9 + CLONE_NOFOLLOW = 0x1 + CLONE_NOOWNERCOPY = 0x2 + CR0 = 0x0 + CR1 = 0x1000 + CR2 = 0x2000 + CR3 = 0x3000 + CRDLY = 0x3000 + CREAD = 0x800 + CRTSCTS = 0x30000 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTLIOCGINFO = 0xc0644e03 + CTL_HW = 0x6 + CTL_KERN = 0x1 + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0x10a + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_DARWIN = 0x10a + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_EXCEPT = -0xf + EVFILT_FS = -0x9 + EVFILT_MACHPORT = -0x8 + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0x11 + EVFILT_THREADMARKER = 0x11 + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xa + EVFILT_VM = -0xc + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_DISPATCH2 = 0x180 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG0 = 0x1000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_OOBAND = 0x2000 + EV_POLL = 0x1000 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EV_UDATA_SPECIFIC = 0x100 + EV_VANISHED = 0x200 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x4000 + FFDLY = 0x4000 + FLUSHO = 0x800000 + FSOPT_ATTR_CMN_EXTENDED = 0x20 + FSOPT_NOFOLLOW = 0x1 + FSOPT_NOINMEMUPDATE = 0x2 + FSOPT_PACK_INVAL_ATTRS = 0x8 + FSOPT_REPORT_FULLSIZE = 0x4 + FSOPT_RETURN_REALDEV = 0x200 + F_ADDFILESIGS = 0x3d + F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 + F_ADDFILESIGS_INFO = 0x67 + F_ADDFILESIGS_RETURN = 0x61 + F_ADDFILESUPPL = 0x68 + F_ADDSIGS = 0x3b + F_ALLOCATEALL = 0x4 + F_ALLOCATECONTIG = 0x2 + F_BARRIERFSYNC = 0x55 + F_CHECK_LV = 0x62 + F_CHKCLEAN = 0x29 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x43 + F_FINDSIGS = 0x4e + F_FLUSH_DATA = 0x28 + F_FREEZE_FS = 0x35 + F_FULLFSYNC = 0x33 + F_GETCODEDIR = 0x48 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETLKPID = 0x42 + F_GETNOSIGPIPE = 0x4a + F_GETOWN = 0x5 + F_GETPATH = 0x32 + F_GETPATH_MTMINFO = 0x47 + F_GETPATH_NOFIRMLINK = 0x66 + F_GETPROTECTIONCLASS = 0x3f + F_GETPROTECTIONLEVEL = 0x4d + F_GETSIGSINFO = 0x69 + F_GLOBAL_NOCACHE = 0x37 + F_LOG2PHYS = 0x31 + F_LOG2PHYS_EXT = 0x41 + F_NOCACHE = 0x30 + F_NODIRECT = 0x3e + F_OK = 0x0 + F_PATHPKG_CHECK = 0x34 + F_PEOFPOSMODE = 0x3 + F_PREALLOCATE = 0x2a + F_PUNCHHOLE = 0x63 + F_RDADVISE = 0x2c + F_RDAHEAD = 0x2d + F_RDLCK = 0x1 + F_SETBACKINGSTORE = 0x46 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETLKWTIMEOUT = 0xa + F_SETNOSIGPIPE = 0x49 + F_SETOWN = 0x6 + F_SETPROTECTIONCLASS = 0x40 + F_SETSIZE = 0x2b + F_SINGLE_WRITER = 0x4c + F_SPECULATIVE_READ = 0x65 + F_THAW_FS = 0x36 + F_TRANSCODEKEY = 0x4b + F_TRIM_ACTIVE_FILE = 0x64 + F_UNLCK = 0x2 + F_VOLPOSMODE = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + HW_MACHINE = 0x1 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_1822 = 0x2 + IFT_6LOWPAN = 0x40 + IFT_AAL5 = 0x31 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ATM = 0x25 + IFT_BRIDGE = 0xd1 + IFT_CARP = 0xf8 + IFT_CELLULAR = 0xff + IFT_CEPT = 0x13 + IFT_DS3 = 0x1e + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_ETHER = 0x6 + IFT_FAITH = 0x38 + IFT_FDDI = 0xf + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_GIF = 0x37 + IFT_HDH1822 = 0x3 + IFT_HIPPI = 0x2f + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IEEE1394 = 0x90 + IFT_IEEE8023ADLAG = 0x88 + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88026 = 0xa + IFT_L2VLAN = 0x87 + IFT_LAPB = 0x10 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_NSIP = 0x1b + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PDP = 0xff + IFT_PFLOG = 0xf5 + IFT_PFSYNC = 0xf6 + IFT_PKTAP = 0xfe + IFT_PPP = 0x17 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PTPSERIAL = 0x16 + IFT_RS232 = 0x21 + IFT_SDLC = 0x11 + IFT_SIP = 0x1f + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_STARLAN = 0xb + IFT_STF = 0x39 + IFT_T1 = 0x12 + IFT_ULTRA = 0x1d + IFT_V35 = 0x2d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LINKLOCALNETNUM = 0xa9fe0000 + IN_LOOPBACKNET = 0x7f + IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x400473d1 + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0xfe + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MEAS = 0x13 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEP = 0x21 + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_2292DSTOPTS = 0x17 + IPV6_2292HOPLIMIT = 0x14 + IPV6_2292HOPOPTS = 0x16 + IPV6_2292NEXTHOP = 0x15 + IPV6_2292PKTINFO = 0x13 + IPV6_2292PKTOPTIONS = 0x19 + IPV6_2292RTHDR = 0x18 + IPV6_3542DSTOPTS = 0x32 + IPV6_3542HOPLIMIT = 0x2f + IPV6_3542HOPOPTS = 0x31 + IPV6_3542NEXTHOP = 0x30 + IPV6_3542PKTINFO = 0x2e + IPV6_3542RTHDR = 0x33 + IPV6_ADDR_MC_FLAGS_PREFIX = 0x20 + IPV6_ADDR_MC_FLAGS_TRANSIENT = 0x10 + IPV6_ADDR_MC_FLAGS_UNICAST_BASED = 0x30 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_BINDV6ONLY = 0x1b + IPV6_BOUND_IF = 0x7d + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FLOW_ECN_MASK = 0x3000 + IPV6_FRAGTTL = 0x3c + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x3d + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x23 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x39 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x24 + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BLOCK_SOURCE = 0x48 + IP_BOUND_IF = 0x19 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DONTFRAG = 0x1c + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FAITH = 0x16 + IP_FW_ADD = 0x28 + IP_FW_DEL = 0x29 + IP_FW_FLUSH = 0x2a + IP_FW_GET = 0x2c + IP_FW_RESETLOG = 0x2d + IP_FW_ZERO = 0x2b + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MF = 0x2000 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_IFINDEX = 0x42 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_NAT__XXX = 0x37 + IP_OFFMASK = 0x1fff + IP_OLD_FW_ADD = 0x32 + IP_OLD_FW_DEL = 0x33 + IP_OLD_FW_FLUSH = 0x34 + IP_OLD_FW_GET = 0x36 + IP_OLD_FW_RESETLOG = 0x38 + IP_OLD_FW_ZERO = 0x35 + IP_OPTIONS = 0x1 + IP_PKTINFO = 0x1a + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVPKTINFO = 0x1a + IP_RECVRETOPTS = 0x6 + IP_RECVTOS = 0x1b + IP_RECVTTL = 0x18 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_STRIPHDR = 0x17 + IP_TOS = 0x3 + IP_TRAFFIC_MGT_BACKGROUND = 0x41 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + KERN_HOSTNAME = 0xa + KERN_OSRELEASE = 0x2 + KERN_OSTYPE = 0x1 + KERN_VERSION = 0x4 + LOCAL_PEERCRED = 0x1 + LOCAL_PEEREPID = 0x3 + LOCAL_PEEREUUID = 0x5 + LOCAL_PEERPID = 0x2 + LOCAL_PEERTOKEN = 0x6 + LOCAL_PEERUUID = 0x4 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_CAN_REUSE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_FREE_REUSABLE = 0x7 + MADV_FREE_REUSE = 0x8 + MADV_NORMAL = 0x0 + MADV_PAGEOUT = 0xa + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MADV_ZERO_WIRED_PAGES = 0x6 + MAP_32BIT = 0x8000 + MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 + MAP_COPY = 0x2 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_JIT = 0x800 + MAP_NOCACHE = 0x400 + MAP_NOEXTEND = 0x100 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_RESERVED0080 = 0x80 + MAP_RESILIENT_CODESIGN = 0x2000 + MAP_RESILIENT_MEDIA = 0x4000 + MAP_SHARED = 0x1 + MAP_TRANSLATED_ALLOW_EXECUTE = 0x20000 + MAP_UNIX03 = 0x40000 + MCAST_BLOCK_SOURCE = 0x54 + MCAST_EXCLUDE = 0x2 + MCAST_INCLUDE = 0x1 + MCAST_JOIN_GROUP = 0x50 + MCAST_JOIN_SOURCE_GROUP = 0x52 + MCAST_LEAVE_GROUP = 0x51 + MCAST_LEAVE_SOURCE_GROUP = 0x53 + MCAST_UNBLOCK_SOURCE = 0x55 + MCAST_UNDEFINED = 0x0 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_AUTOMOUNTED = 0x400000 + MNT_CMDFLAGS = 0xf0000 + MNT_CPROTECT = 0x80 + MNT_DEFWRITE = 0x2000000 + MNT_DONTBROWSE = 0x100000 + MNT_DOVOLFS = 0x8000 + MNT_DWAIT = 0x4 + MNT_EXPORTED = 0x100 + MNT_EXT_ROOT_DATA_VOL = 0x1 + MNT_FORCE = 0x80000 + MNT_IGNORE_OWNERSHIP = 0x200000 + MNT_JOURNALED = 0x800000 + MNT_LOCAL = 0x1000 + MNT_MULTILABEL = 0x4000000 + MNT_NOATIME = 0x10000000 + MNT_NOBLOCK = 0x20000 + MNT_NODEV = 0x10 + MNT_NOEXEC = 0x4 + MNT_NOSUID = 0x8 + MNT_NOUSERXATTR = 0x1000000 + MNT_NOWAIT = 0x2 + MNT_QUARANTINE = 0x400 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELOAD = 0x40000 + MNT_REMOVABLE = 0x200 + MNT_ROOTFS = 0x4000 + MNT_SNAPSHOT = 0x40000000 + MNT_STRICTATIME = 0x80000000 + MNT_SYNCHRONOUS = 0x2 + MNT_UNION = 0x20 + MNT_UNKNOWNPERMISSIONS = 0x200000 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0xd7f0f7ff + MNT_WAIT = 0x1 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_FLUSH = 0x400 + MSG_HAVEMORE = 0x2000 + MSG_HOLD = 0x800 + MSG_NEEDSA = 0x10000 + MSG_NOSIGNAL = 0x80000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_RCVMORE = 0x4000 + MSG_SEND = 0x1000 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MSG_WAITSTREAM = 0x200 + MS_ASYNC = 0x1 + MS_DEACTIVATE = 0x8 + MS_INVALIDATE = 0x2 + MS_KILLPAGES = 0x4 + MS_SYNC = 0x10 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_DUMP2 = 0x7 + NET_RT_FLAGS = 0x2 + NET_RT_FLAGS_PRIV = 0xa + NET_RT_IFLIST = 0x3 + NET_RT_IFLIST2 = 0x6 + NET_RT_MAXID = 0xb + NET_RT_STAT = 0x4 + NET_RT_TRASH = 0x5 + NFDBITS = 0x20 + NL0 = 0x0 + NL1 = 0x100 + NL2 = 0x200 + NL3 = 0x300 + NLDLY = 0x300 + NOFLSH = 0x80000000 + NOKERNINFO = 0x2000000 + NOTE_ABSOLUTE = 0x8 + NOTE_ATTRIB = 0x8 + NOTE_BACKGROUND = 0x40 + NOTE_CHILD = 0x4 + NOTE_CRITICAL = 0x20 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXITSTATUS = 0x4000000 + NOTE_EXIT_CSERROR = 0x40000 + NOTE_EXIT_DECRYPTFAIL = 0x10000 + NOTE_EXIT_DETAIL = 0x2000000 + NOTE_EXIT_DETAIL_MASK = 0x70000 + NOTE_EXIT_MEMORY = 0x20000 + NOTE_EXIT_REPARENTED = 0x80000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FORK = 0x40000000 + NOTE_FUNLOCK = 0x100 + NOTE_LEEWAY = 0x10 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_MACHTIME = 0x100 + NOTE_MACH_CONTINUOUS_TIME = 0x80 + NOTE_NONE = 0x80 + NOTE_NSECONDS = 0x4 + NOTE_OOB = 0x2 + NOTE_PCTRLMASK = -0x100000 + NOTE_PDATAMASK = 0xfffff + NOTE_REAP = 0x10000000 + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_SECONDS = 0x1 + NOTE_SIGNAL = 0x8000000 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_USECONDS = 0x2 + NOTE_VM_ERROR = 0x10000000 + NOTE_VM_PRESSURE = 0x80000000 + NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000 + NOTE_VM_PRESSURE_TERMINATE = 0x40000000 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + OFDEL = 0x20000 + OFILL = 0x80 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + OXTABS = 0x4 + O_ACCMODE = 0x3 + O_ALERT = 0x20000000 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x1000000 + O_CREAT = 0x200 + O_DIRECTORY = 0x100000 + O_DP_GETRAWENCRYPTED = 0x1 + O_DP_GETRAWUNENCRYPTED = 0x2 + O_DSYNC = 0x400000 + O_EVTONLY = 0x8000 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x20000 + O_NOFOLLOW = 0x100 + O_NOFOLLOW_ANY = 0x20000000 + O_NONBLOCK = 0x4 + O_POPUP = 0x80000000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYMLINK = 0x200000 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PT_ATTACH = 0xa + PT_ATTACHEXC = 0xe + PT_CONTINUE = 0x7 + PT_DENY_ATTACH = 0x1f + PT_DETACH = 0xb + PT_FIRSTMACH = 0x20 + PT_FORCEQUOTA = 0x1e + PT_KILL = 0x8 + PT_READ_D = 0x2 + PT_READ_I = 0x1 + PT_READ_U = 0x3 + PT_SIGEXC = 0xc + PT_STEP = 0x9 + PT_THUPDATE = 0xd + PT_TRACE_ME = 0x0 + PT_WRITE_D = 0x5 + PT_WRITE_I = 0x4 + PT_WRITE_U = 0x6 + RLIMIT_AS = 0x5 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_CPU_USAGE_MONITOR = 0x2 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 + RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_CLONING = 0x100 + RTF_CONDEMNED = 0x2000000 + RTF_DEAD = 0x20000000 + RTF_DELCLONE = 0x80 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_GATEWAY = 0x2 + RTF_GLOBAL = 0x40000000 + RTF_HOST = 0x4 + RTF_IFREF = 0x4000000 + RTF_IFSCOPE = 0x1000000 + RTF_LLDATA = 0x400 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_NOIFREF = 0x2000 + RTF_PINNED = 0x100000 + RTF_PRCLONING = 0x10000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_PROXY = 0x8000000 + RTF_REJECT = 0x8 + RTF_ROUTER = 0x10000000 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_WASCLONED = 0x20000 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_GET2 = 0x14 + RTM_IFINFO = 0xe + RTM_IFINFO2 = 0x12 + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_NEWMADDR2 = 0x13 + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SCM_TIMESTAMP_MONOTONIC = 0x4 + SEEK_CUR = 0x1 + SEEK_DATA = 0x4 + SEEK_END = 0x2 + SEEK_HOLE = 0x3 + SEEK_SET = 0x0 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCARPIPLL = 0xc0206928 + SIOCATMARK = 0x40047307 + SIOCAUTOADDR = 0xc0206926 + SIOCAUTONETMASK = 0x80206927 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFPHYADDR = 0x80206941 + SIOCGDRVSPEC = 0xc028697b + SIOCGETVLAN = 0xc020697f + SIOCGHIWAT = 0x40047301 + SIOCGIF6LOWPAN = 0xc02069c5 + SIOCGIFADDR = 0xc0206921 + SIOCGIFALTMTU = 0xc0206948 + SIOCGIFASYNCMAP = 0xc020697c + SIOCGIFBOND = 0xc0206947 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020695b + SIOCGIFCONF = 0xc00c6924 + SIOCGIFDEVMTU = 0xc0206944 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFFUNCTIONALTYPE = 0xc02069ad + SIOCGIFGENERIC = 0xc020693a + SIOCGIFKPI = 0xc0206987 + SIOCGIFMAC = 0xc0206982 + SIOCGIFMEDIA = 0xc02c6938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206940 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc020693f + SIOCGIFSTATUS = 0xc331693d + SIOCGIFVLAN = 0xc020697f + SIOCGIFWAKEFLAGS = 0xc0206988 + SIOCGIFXMEDIA = 0xc02c6948 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCIFCREATE = 0xc0206978 + SIOCIFCREATE2 = 0xc020697a + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc0106981 + SIOCRSLVMULTI = 0xc010693b + SIOCSDRVSPEC = 0x8028697b + SIOCSETVLAN = 0x8020697e + SIOCSHIWAT = 0x80047300 + SIOCSIF6LOWPAN = 0x802069c4 + SIOCSIFADDR = 0x8020690c + SIOCSIFALTMTU = 0x80206945 + SIOCSIFASYNCMAP = 0x8020697d + SIOCSIFBOND = 0x80206946 + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020695a + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFKPI = 0x80206986 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206983 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x8040693e + SIOCSIFPHYS = 0x80206936 + SIOCSIFVLAN = 0x8020697e + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_LOCAL = 0x0 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_DONTTRUNC = 0x2000 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1010 + SO_LINGER = 0x80 + SO_LINGER_SEC = 0x1080 + SO_NETSVC_MARKING_LEVEL = 0x1119 + SO_NET_SERVICE_TYPE = 0x1116 + SO_NKE = 0x1021 + SO_NOADDRERR = 0x1023 + SO_NOSIGPIPE = 0x1022 + SO_NOTIFYCONFLICT = 0x1026 + SO_NP_EXTENSIONS = 0x1083 + SO_NREAD = 0x1020 + SO_NUMRCVPKT = 0x1112 + SO_NWRITE = 0x1024 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1011 + SO_RANDOMPORT = 0x1082 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_REUSESHAREUID = 0x1025 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TIMESTAMP_MONOTONIC = 0x800 + SO_TRACKER_ATTRIBUTE_FLAGS_APP_APPROVED = 0x1 + SO_TRACKER_ATTRIBUTE_FLAGS_DOMAIN_SHORT = 0x4 + SO_TRACKER_ATTRIBUTE_FLAGS_TRACKER = 0x2 + SO_TRACKER_TRANSPARENCY_VERSION = 0x3 + SO_TYPE = 0x1008 + SO_UPCALLCLOSEWAIT = 0x1027 + SO_USELOOPBACK = 0x40 + SO_WANTMORE = 0x4000 + SO_WANTOOBFLAG = 0x8000 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IFWHT = 0xe000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x400 + TAB2 = 0x800 + TAB3 = 0x4 + TABDLY = 0xc04 + TCIFLUSH = 0x1 + TCIOFF = 0x3 + TCIOFLUSH = 0x3 + TCION = 0x4 + TCOFLUSH = 0x2 + TCOOFF = 0x1 + TCOON = 0x2 + TCPOPT_CC = 0xb + TCPOPT_CCECHO = 0xd + TCPOPT_CCNEW = 0xc + TCPOPT_EOL = 0x0 + TCPOPT_FASTOPEN = 0x22 + TCPOPT_MAXSEG = 0x2 + TCPOPT_NOP = 0x1 + TCPOPT_SACK = 0x5 + TCPOPT_SACK_HDR = 0x1010500 + TCPOPT_SACK_PERMITTED = 0x4 + TCPOPT_SACK_PERMIT_HDR = 0x1010402 + TCPOPT_SIGNATURE = 0x13 + TCPOPT_TIMESTAMP = 0x8 + TCPOPT_TSTAMP_HDR = 0x101080a + TCPOPT_WINDOW = 0x3 + TCP_CONNECTIONTIMEOUT = 0x20 + TCP_CONNECTION_INFO = 0x106 + TCP_ENABLE_ECN = 0x104 + TCP_FASTOPEN = 0x105 + TCP_KEEPALIVE = 0x10 + TCP_KEEPCNT = 0x102 + TCP_KEEPINTVL = 0x101 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MINMSS = 0xd8 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_NOTSENT_LOWAT = 0x201 + TCP_RXT_CONNDROPTIME = 0x80 + TCP_RXT_FINDROP = 0x100 + TCP_SENDMOREACKS = 0x103 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDCDTIMESTAMP = 0x40107458 + TIOCDRAIN = 0x2000745e + TIOCDSIMICROCODE = 0x20007455 + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x40487413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGWINSZ = 0x40087468 + TIOCIXOFF = 0x20007480 + TIOCIXON = 0x20007481 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMODG = 0x40047403 + TIOCMODS = 0x80047404 + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTYGNAME = 0x40807453 + TIOCPTYGRANT = 0x20007454 + TIOCPTYUNLK = 0x20007452 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCONS = 0x20007463 + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x80487414 + TIOCSETAF = 0x80487416 + TIOCSETAW = 0x80487415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2000745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40107459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMADDR_CID_ANY = 0xffffffff + VMADDR_CID_HOST = 0x2 + VMADDR_CID_HYPERVISOR = 0x0 + VMADDR_CID_RESERVED = 0x1 + VMADDR_PORT_ANY = 0xffffffff + VMIN = 0x10 + VM_LOADAVG = 0x2 + VM_MACHFACTOR = 0x4 + VM_MAXID = 0x6 + VM_METER = 0x1 + VM_SWAPUSAGE = 0x5 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VT0 = 0x0 + VT1 = 0x10000 + VTDLY = 0x10000 + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x10 + WCOREFLAG = 0x80 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOWAIT = 0x20 + WORDSIZE = 0x40 + WSTOPPED = 0x8 + WUNTRACED = 0x2 + XATTR_CREATE = 0x2 + XATTR_NODEFAULT = 0x10 + XATTR_NOFOLLOW = 0x1 + XATTR_NOSECURITY = 0x8 + XATTR_REPLACE = 0x4 + XATTR_SHOWCOMPRESSION = 0x20 ) // Errors diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zerrors_linux.go b/src/cmd/vendor/golang.org/x/sys/unix/zerrors_linux.go index 8894c4af44..78d4b85ece 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -1333,6 +1333,20 @@ const ( KEY_SPEC_THREAD_KEYRING = -0x1 KEY_SPEC_USER_KEYRING = -0x4 KEY_SPEC_USER_SESSION_KEYRING = -0x5 + LANDLOCK_ACCESS_FS_EXECUTE = 0x1 + LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800 + LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40 + LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80 + LANDLOCK_ACCESS_FS_MAKE_FIFO = 0x400 + LANDLOCK_ACCESS_FS_MAKE_REG = 0x100 + LANDLOCK_ACCESS_FS_MAKE_SOCK = 0x200 + LANDLOCK_ACCESS_FS_MAKE_SYM = 0x1000 + LANDLOCK_ACCESS_FS_READ_DIR = 0x8 + LANDLOCK_ACCESS_FS_READ_FILE = 0x4 + LANDLOCK_ACCESS_FS_REMOVE_DIR = 0x10 + LANDLOCK_ACCESS_FS_REMOVE_FILE = 0x20 + LANDLOCK_ACCESS_FS_WRITE_FILE = 0x2 + LANDLOCK_CREATE_RULESET_VERSION = 0x1 LINUX_REBOOT_CMD_CAD_OFF = 0x0 LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef LINUX_REBOOT_CMD_HALT = 0xcdef0123 @@ -1383,6 +1397,8 @@ const ( MADV_NOHUGEPAGE = 0xf MADV_NORMAL = 0x0 MADV_PAGEOUT = 0x15 + MADV_POPULATE_READ = 0x16 + MADV_POPULATE_WRITE = 0x17 MADV_RANDOM = 0x1 MADV_REMOVE = 0x9 MADV_SEQUENTIAL = 0x2 diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index d4efe8d457..0ae0ed4cb8 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -734,6 +734,65 @@ var libc_sendfile_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func shmat(id int, addr uintptr, flag int) (ret uintptr, err error) { + r0, _, e1 := syscall_syscall(libc_shmat_trampoline_addr, uintptr(id), uintptr(addr), uintptr(flag)) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_shmat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_shmat shmat "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func shmctl(id int, cmd int, buf *SysvShmDesc) (result int, err error) { + r0, _, e1 := syscall_syscall(libc_shmctl_trampoline_addr, uintptr(id), uintptr(cmd), uintptr(unsafe.Pointer(buf))) + result = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_shmctl_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_shmctl shmctl "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func shmdt(addr uintptr) (err error) { + _, _, e1 := syscall_syscall(libc_shmdt_trampoline_addr, uintptr(addr), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_shmdt_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_shmdt shmdt "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func shmget(key int, size int, flag int) (id int, err error) { + r0, _, e1 := syscall_syscall(libc_shmget_trampoline_addr, uintptr(key), uintptr(size), uintptr(flag)) + id = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_shmget_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_shmget shmget "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index bc169c2ab9..eac6ca806f 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -264,6 +264,30 @@ TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8 DATA ·libc_sendfile_trampoline_addr(SB)/8, $libc_sendfile_trampoline<>(SB) +TEXT libc_shmat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_shmat(SB) + +GLOBL ·libc_shmat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_shmat_trampoline_addr(SB)/8, $libc_shmat_trampoline<>(SB) + +TEXT libc_shmctl_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_shmctl(SB) + +GLOBL ·libc_shmctl_trampoline_addr(SB), RODATA, $8 +DATA ·libc_shmctl_trampoline_addr(SB)/8, $libc_shmctl_trampoline<>(SB) + +TEXT libc_shmdt_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_shmdt(SB) + +GLOBL ·libc_shmdt_trampoline_addr(SB), RODATA, $8 +DATA ·libc_shmdt_trampoline_addr(SB)/8, $libc_shmdt_trampoline<>(SB) + +TEXT libc_shmget_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_shmget(SB) + +GLOBL ·libc_shmget_trampoline_addr(SB), RODATA, $8 +DATA ·libc_shmget_trampoline_addr(SB)/8, $libc_shmget_trampoline<>(SB) + TEXT libc_access_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_access(SB) diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index f2ee2bd33b..cf71be3edb 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -734,6 +734,65 @@ var libc_sendfile_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func shmat(id int, addr uintptr, flag int) (ret uintptr, err error) { + r0, _, e1 := syscall_syscall(libc_shmat_trampoline_addr, uintptr(id), uintptr(addr), uintptr(flag)) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_shmat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_shmat shmat "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func shmctl(id int, cmd int, buf *SysvShmDesc) (result int, err error) { + r0, _, e1 := syscall_syscall(libc_shmctl_trampoline_addr, uintptr(id), uintptr(cmd), uintptr(unsafe.Pointer(buf))) + result = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_shmctl_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_shmctl shmctl "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func shmdt(addr uintptr) (err error) { + _, _, e1 := syscall_syscall(libc_shmdt_trampoline_addr, uintptr(addr), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_shmdt_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_shmdt shmdt "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func shmget(key int, size int, flag int) (id int, err error) { + r0, _, e1 := syscall_syscall(libc_shmget_trampoline_addr, uintptr(key), uintptr(size), uintptr(flag)) + id = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_shmget_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_shmget shmget "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 33e19776db..4ebcf21758 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -264,6 +264,30 @@ TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8 DATA ·libc_sendfile_trampoline_addr(SB)/8, $libc_sendfile_trampoline<>(SB) +TEXT libc_shmat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_shmat(SB) + +GLOBL ·libc_shmat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_shmat_trampoline_addr(SB)/8, $libc_shmat_trampoline<>(SB) + +TEXT libc_shmctl_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_shmctl(SB) + +GLOBL ·libc_shmctl_trampoline_addr(SB), RODATA, $8 +DATA ·libc_shmctl_trampoline_addr(SB)/8, $libc_shmctl_trampoline<>(SB) + +TEXT libc_shmdt_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_shmdt(SB) + +GLOBL ·libc_shmdt_trampoline_addr(SB), RODATA, $8 +DATA ·libc_shmdt_trampoline_addr(SB)/8, $libc_shmdt_trampoline<>(SB) + +TEXT libc_shmget_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_shmget(SB) + +GLOBL ·libc_shmget_trampoline_addr(SB), RODATA, $8 +DATA ·libc_shmget_trampoline_addr(SB)/8, $libc_shmget_trampoline<>(SB) + TEXT libc_access_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_access(SB) diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 2dbe3da7a0..4f5da1f54f 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -110,6 +110,16 @@ func openat2(dirfd int, path string, open_how *OpenHow, size int) (fd int, err e // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0) n = int(r0) @@ -1945,8 +1955,63 @@ func ProcessVMWritev(pid int, localIov []Iovec, remoteIov []RemoteIovec, flags u // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe2(p *[2]_C_int, flags int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) +func PidfdOpen(pid int, flags int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_PIDFD_OPEN, uintptr(pid), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PidfdGetfd(pidfd int, targetfd int, flags int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_PIDFD_GETFD, uintptr(pidfd), uintptr(targetfd), uintptr(flags)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func shmat(id int, addr uintptr, flag int) (ret uintptr, err error) { + r0, _, e1 := Syscall(SYS_SHMAT, uintptr(id), uintptr(addr), uintptr(flag)) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func shmctl(id int, cmd int, buf *SysvShmDesc) (result int, err error) { + r0, _, e1 := Syscall(SYS_SHMCTL, uintptr(id), uintptr(cmd), uintptr(unsafe.Pointer(buf))) + result = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func shmdt(addr uintptr) (err error) { + _, _, e1 := Syscall(SYS_SHMDT, uintptr(addr), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func shmget(key int, size int, flag int) (id int, err error) { + r0, _, e1 := Syscall(SYS_SHMGET, uintptr(key), uintptr(size), uintptr(flag)) + id = int(r0) if e1 != 0 { err = errnoErr(e1) } diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go index e37096e4de..ff90c81e73 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -46,37 +46,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func EpollCreate(size int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { @@ -181,17 +150,6 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func InotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Ioperm(from int, num int, on int) (err error) { _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) if e1 != 0 { @@ -566,14 +524,3 @@ func utimes(path string, times *[2]Timeval) (err error) { } return } - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { - r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index 9919d8486d..fa7d3dbe4e 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -46,27 +46,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func EpollCreate(size int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { @@ -191,17 +170,6 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func inotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Ioperm(from int, num int, on int) (err error) { _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) if e1 != 0 { @@ -711,27 +679,6 @@ func utimes(path string, times *[2]Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { - r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(cmdline) diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go index 076754d48d..654f91530f 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -46,16 +46,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) fd = int(r0) @@ -235,27 +225,6 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func EpollCreate(size int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { @@ -340,17 +309,6 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func InotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Lchown(path string, uid int, gid int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -681,17 +639,6 @@ func setrlimit(resource int, rlim *rlimit32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { - r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func armSyncFileRange(fd int, flags int, off int64, n int64) (err error) { _, _, e1 := Syscall6(SYS_ARM_SYNC_FILE_RANGE, uintptr(fd), uintptr(flags), uintptr(off), uintptr(off>>32), uintptr(n), uintptr(n>>32)) if e1 != 0 { diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go index 4703cf3c33..6d15528853 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go @@ -46,27 +46,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func EpollCreate(size int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { @@ -544,17 +523,6 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func InotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Ioperm(from int, num int, on int) (err error) { _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) if e1 != 0 { @@ -706,18 +674,6 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (p1 int, p2 int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - p1 = int(r0) - p2 = int(r1) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) { r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset)) xaddr = uintptr(r0) @@ -746,14 +702,3 @@ func setrlimit(resource int, rlim *rlimit32) (err error) { } return } - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { - r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go index a134f9a4d2..1e20d72df2 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -46,27 +46,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func EpollCreate(size int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { @@ -717,14 +696,3 @@ func stat(path string, st *stat_t) (err error) { } return } - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { - r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go index b1fff2d946..82b5e2d9ed 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -46,27 +46,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func EpollCreate(size int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { @@ -717,14 +696,3 @@ func stat(path string, st *stat_t) (err error) { } return } - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { - r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go index d13d6da01e..a0440c1d43 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go @@ -46,27 +46,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func EpollCreate(size int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { @@ -544,17 +523,6 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func InotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Ioperm(from int, num int, on int) (err error) { _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) if e1 != 0 { @@ -706,18 +674,6 @@ func Pause() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (p1 int, p2 int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - p1 = int(r0) - p2 = int(r1) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) { r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset)) xaddr = uintptr(r0) @@ -746,14 +702,3 @@ func setrlimit(resource int, rlim *rlimit32) (err error) { } return } - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { - r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go index 927cf1a00f..5864b9ca64 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go @@ -46,27 +46,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func EpollCreate(size int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { @@ -161,17 +140,6 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func InotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Ioperm(from int, num int, on int) (err error) { _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) if e1 != 0 { @@ -717,27 +685,6 @@ func setrlimit(resource int, rlim *rlimit32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { - r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func syncFileRange2(fd int, flags int, off int64, n int64) (err error) { _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(flags), uintptr(off>>32), uintptr(off), uintptr(n>>32), uintptr(n)) if e1 != 0 { diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index da8ec03966..beeb49e342 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -46,27 +46,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func EpollCreate(size int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { @@ -191,17 +170,6 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func InotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Ioperm(from int, num int, on int) (err error) { _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) if e1 != 0 { @@ -763,27 +731,6 @@ func utimes(path string, times *[2]Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { - r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func syncFileRange2(fd int, flags int, off int64, n int64) (err error) { _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(flags), uintptr(off), uintptr(n), 0, 0) if e1 != 0 { diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index 083f493bb6..53139b82c7 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -46,27 +46,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func EpollCreate(size int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { @@ -191,17 +170,6 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func InotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Ioperm(from int, num int, on int) (err error) { _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) if e1 != 0 { @@ -763,27 +731,6 @@ func utimes(path string, times *[2]Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { - r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func syncFileRange2(fd int, flags int, off int64, n int64) (err error) { _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(flags), uintptr(off), uintptr(n), 0, 0) if e1 != 0 { diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index bb347407d3..202add37d1 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -46,27 +46,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func EpollCreate(size int) (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { @@ -191,17 +170,6 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func InotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Lchown(path string, uid int, gid int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -553,17 +521,6 @@ func utimes(path string, times *[2]Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { - r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(cmdline) diff --git a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go index 8edc517e1e..2ab268c343 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go @@ -73,16 +73,6 @@ func Fadvise(fd int, offset int64, length int64, advice int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { @@ -180,17 +170,6 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func InotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Lchown(path string, uid int, gid int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -718,24 +697,3 @@ func utimes(path string, times *[2]Timeval) (err error) { } return } - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { - r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index 4c8dc0ba2e..7efe5ccba3 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -209,6 +209,92 @@ type RawSockaddrCtl struct { Sc_reserved [5]uint32 } +type RawSockaddrVM struct { + Len uint8 + Family uint8 + Reserved1 uint16 + Port uint32 + Cid uint32 +} + +type XVSockPCB struct { + Xv_len uint32 + Xv_vsockpp uint64 + Xvp_local_cid uint32 + Xvp_local_port uint32 + Xvp_remote_cid uint32 + Xvp_remote_port uint32 + Xvp_rxcnt uint32 + Xvp_txcnt uint32 + Xvp_peer_rxhiwat uint32 + Xvp_peer_rxcnt uint32 + Xvp_last_pid int32 + Xvp_gencnt uint64 + Xv_socket XSocket + _ [4]byte +} + +type XSocket struct { + Xso_len uint32 + Xso_so uint32 + So_type int16 + So_options int16 + So_linger int16 + So_state int16 + So_pcb uint32 + Xso_protocol int32 + Xso_family int32 + So_qlen int16 + So_incqlen int16 + So_qlimit int16 + So_timeo int16 + So_error uint16 + So_pgid int32 + So_oobmark uint32 + So_rcv XSockbuf + So_snd XSockbuf + So_uid uint32 +} + +type XSocket64 struct { + Xso_len uint32 + _ [8]byte + So_type int16 + So_options int16 + So_linger int16 + So_state int16 + _ [8]byte + Xso_protocol int32 + Xso_family int32 + So_qlen int16 + So_incqlen int16 + So_qlimit int16 + So_timeo int16 + So_error uint16 + So_pgid int32 + So_oobmark uint32 + So_rcv XSockbuf + So_snd XSockbuf + So_uid uint32 +} + +type XSockbuf struct { + Cc uint32 + Hiwat uint32 + Mbcnt uint32 + Mbmax uint32 + Lowat int32 + Flags int16 + Timeo int16 +} + +type XVSockPgen struct { + Len uint32 + Count uint64 + Gen uint64 + Sogen uint64 +} + type _Socklen uint32 type Xucred struct { @@ -287,6 +373,11 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x14 SizeofSockaddrCtl = 0x20 + SizeofSockaddrVM = 0xc + SizeofXvsockpcb = 0xa8 + SizeofXSocket = 0x64 + SizeofXSockbuf = 0x18 + SizeofXVSockPgen = 0x20 SizeofXucred = 0x4c SizeofLinger = 0x8 SizeofIovec = 0x10 @@ -639,3 +730,39 @@ type Ucred struct { Ngroups int16 Groups [16]uint32 } + +type SysvIpcPerm struct { + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint16 + _ uint16 + _ int32 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint64 + Lpid int32 + Cpid int32 + Nattch uint16 + _ [34]byte +} + +const ( + IPC_CREAT = 0x200 + IPC_EXCL = 0x400 + IPC_NOWAIT = 0x800 + IPC_PRIVATE = 0x0 +) + +const ( + IPC_RMID = 0x0 + IPC_SET = 0x1 + IPC_STAT = 0x2 +) + +const ( + SHM_RDONLY = 0x1000 + SHM_RND = 0x2000 +) diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index 96f0e6ae2a..b23a2efe81 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -209,6 +209,92 @@ type RawSockaddrCtl struct { Sc_reserved [5]uint32 } +type RawSockaddrVM struct { + Len uint8 + Family uint8 + Reserved1 uint16 + Port uint32 + Cid uint32 +} + +type XVSockPCB struct { + Xv_len uint32 + Xv_vsockpp uint64 + Xvp_local_cid uint32 + Xvp_local_port uint32 + Xvp_remote_cid uint32 + Xvp_remote_port uint32 + Xvp_rxcnt uint32 + Xvp_txcnt uint32 + Xvp_peer_rxhiwat uint32 + Xvp_peer_rxcnt uint32 + Xvp_last_pid int32 + Xvp_gencnt uint64 + Xv_socket XSocket + _ [4]byte +} + +type XSocket struct { + Xso_len uint32 + Xso_so uint32 + So_type int16 + So_options int16 + So_linger int16 + So_state int16 + So_pcb uint32 + Xso_protocol int32 + Xso_family int32 + So_qlen int16 + So_incqlen int16 + So_qlimit int16 + So_timeo int16 + So_error uint16 + So_pgid int32 + So_oobmark uint32 + So_rcv XSockbuf + So_snd XSockbuf + So_uid uint32 +} + +type XSocket64 struct { + Xso_len uint32 + _ [8]byte + So_type int16 + So_options int16 + So_linger int16 + So_state int16 + _ [8]byte + Xso_protocol int32 + Xso_family int32 + So_qlen int16 + So_incqlen int16 + So_qlimit int16 + So_timeo int16 + So_error uint16 + So_pgid int32 + So_oobmark uint32 + So_rcv XSockbuf + So_snd XSockbuf + So_uid uint32 +} + +type XSockbuf struct { + Cc uint32 + Hiwat uint32 + Mbcnt uint32 + Mbmax uint32 + Lowat int32 + Flags int16 + Timeo int16 +} + +type XVSockPgen struct { + Len uint32 + Count uint64 + Gen uint64 + Sogen uint64 +} + type _Socklen uint32 type Xucred struct { @@ -287,6 +373,11 @@ const ( SizeofSockaddrUnix = 0x6a SizeofSockaddrDatalink = 0x14 SizeofSockaddrCtl = 0x20 + SizeofSockaddrVM = 0xc + SizeofXvsockpcb = 0xa8 + SizeofXSocket = 0x64 + SizeofXSockbuf = 0x18 + SizeofXVSockPgen = 0x20 SizeofXucred = 0x4c SizeofLinger = 0x8 SizeofIovec = 0x10 @@ -639,3 +730,39 @@ type Ucred struct { Ngroups int16 Groups [16]uint32 } + +type SysvIpcPerm struct { + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint16 + _ uint16 + _ int32 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint64 + Lpid int32 + Cpid int32 + Nattch uint16 + _ [34]byte +} + +const ( + IPC_CREAT = 0x200 + IPC_EXCL = 0x400 + IPC_NOWAIT = 0x800 + IPC_PRIVATE = 0x0 +) + +const ( + IPC_RMID = 0x0 + IPC_SET = 0x1 + IPC_STAT = 0x2 +) + +const ( + SHM_RDONLY = 0x1000 + SHM_RND = 0x2000 +) diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go index 1f99c024af..4eec078e52 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -31,6 +31,8 @@ type Timeval struct { Usec int32 } +type Time_t int32 + type Rusage struct { Utime Timeval Stime Timeval diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index ddf0305a5d..7622904a53 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -31,6 +31,8 @@ type Timeval struct { Usec int64 } +type Time_t int64 + type Rusage struct { Utime Timeval Stime Timeval diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go index dce0a5c80c..19223ce8ec 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -33,6 +33,8 @@ type Timeval struct { _ [4]byte } +type Time_t int32 + type Rusage struct { Utime Timeval Stime Timeval diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go index e232447025..8e3e33f679 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go @@ -31,6 +31,8 @@ type Timeval struct { Usec int64 } +type Time_t int64 + type Rusage struct { Utime Timeval Stime Timeval diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go index 236f37ef6f..4c485261d6 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go @@ -13,6 +13,8 @@ const ( I_STR = 0x5308 I_POP = 0x5303 I_PUSH = 0x5302 + I_LINK = 0x530c + I_UNLINK = 0x530d I_PLINK = 0x5316 I_PUNLINK = 0x5317 diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux.go index 4b73bb3b63..249ecfcd4c 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -3923,3 +3923,36 @@ const ( NFC_SDP_ATTR_URI = 0x1 NFC_SDP_ATTR_SAP = 0x2 ) + +type LandlockRulesetAttr struct { + Access_fs uint64 +} + +type LandlockPathBeneathAttr struct { + Allowed_access uint64 + Parent_fd int32 +} + +const ( + LANDLOCK_RULE_PATH_BENEATH = 0x1 +) + +const ( + IPC_CREAT = 0x200 + IPC_EXCL = 0x400 + IPC_NOWAIT = 0x800 + IPC_PRIVATE = 0x0 + + ipc_64 = 0x100 +) + +const ( + IPC_RMID = 0x0 + IPC_SET = 0x1 + IPC_STAT = 0x2 +) + +const ( + SHM_RDONLY = 0x1000 + SHM_RND = 0x2000 +) diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index 72f2e96f32..eeeb9aa39a 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -635,3 +635,36 @@ const ( PPS_GETCAP = 0x800470a3 PPS_FETCH = 0xc00470a4 ) + +const ( + PIDFD_NONBLOCK = 0x800 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint16 + _ [2]uint8 + Seq uint16 + _ uint16 + _ uint32 + _ uint32 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint32 + Atime uint32 + Atime_high uint32 + Dtime uint32 + Dtime_high uint32 + Ctime uint32 + Ctime_high uint32 + Cpid int32 + Lpid int32 + Nattch uint32 + _ uint32 + _ uint32 +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index d5f018d13d..d30e1155cc 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -653,3 +653,33 @@ const ( PPS_GETCAP = 0x800870a3 PPS_FETCH = 0xc00870a4 ) + +const ( + PIDFD_NONBLOCK = 0x800 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + _ [0]uint8 + Seq uint16 + _ uint16 + _ uint64 + _ uint64 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint64 + Atime int64 + Dtime int64 + Ctime int64 + Cpid int32 + Lpid int32 + Nattch uint64 + _ uint64 + _ uint64 +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index 675446d936..69d0297520 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -630,3 +630,36 @@ const ( PPS_GETCAP = 0x800470a3 PPS_FETCH = 0xc00470a4 ) + +const ( + PIDFD_NONBLOCK = 0x800 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint16 + _ [2]uint8 + Seq uint16 + _ uint16 + _ uint32 + _ uint32 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint32 + Atime uint32 + Atime_high uint32 + Dtime uint32 + Dtime_high uint32 + Ctime uint32 + Ctime_high uint32 + Cpid int32 + Lpid int32 + Nattch uint32 + _ uint32 + _ uint32 +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index 711d0711cd..28a0455bc9 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -632,3 +632,33 @@ const ( PPS_GETCAP = 0x800870a3 PPS_FETCH = 0xc00870a4 ) + +const ( + PIDFD_NONBLOCK = 0x800 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + _ [0]uint8 + Seq uint16 + _ uint16 + _ uint64 + _ uint64 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint64 + Atime int64 + Dtime int64 + Ctime int64 + Cpid int32 + Lpid int32 + Nattch uint64 + _ uint64 + _ uint64 +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index c1131c7411..64a845483d 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -636,3 +636,35 @@ const ( PPS_GETCAP = 0x400470a3 PPS_FETCH = 0xc00470a4 ) + +const ( + PIDFD_NONBLOCK = 0x80 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + _ [0]uint8 + Seq uint16 + _ uint16 + _ uint32 + _ uint32 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint32 + Atime uint32 + Dtime uint32 + Ctime uint32 + Cpid int32 + Lpid int32 + Nattch uint32 + Atime_high uint16 + Dtime_high uint16 + Ctime_high uint16 + _ uint16 +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index 91d5574ff9..a1b7dee412 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -635,3 +635,33 @@ const ( PPS_GETCAP = 0x400870a3 PPS_FETCH = 0xc00870a4 ) + +const ( + PIDFD_NONBLOCK = 0x80 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + _ [0]uint8 + Seq uint16 + _ uint16 + _ uint64 + _ uint64 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint64 + Atime int64 + Dtime int64 + Ctime int64 + Cpid int32 + Lpid int32 + Nattch uint64 + _ uint64 + _ uint64 +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index 5d721497b7..936fa6a266 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -635,3 +635,33 @@ const ( PPS_GETCAP = 0x400870a3 PPS_FETCH = 0xc00870a4 ) + +const ( + PIDFD_NONBLOCK = 0x80 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + _ [0]uint8 + Seq uint16 + _ uint16 + _ uint64 + _ uint64 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint64 + Atime int64 + Dtime int64 + Ctime int64 + Cpid int32 + Lpid int32 + Nattch uint64 + _ uint64 + _ uint64 +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index a5addd06aa..5dd546fbf0 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -636,3 +636,35 @@ const ( PPS_GETCAP = 0x400470a3 PPS_FETCH = 0xc00470a4 ) + +const ( + PIDFD_NONBLOCK = 0x80 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + _ [0]uint8 + Seq uint16 + _ uint16 + _ uint32 + _ uint32 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint32 + Atime uint32 + Dtime uint32 + Ctime uint32 + Cpid int32 + Lpid int32 + Nattch uint32 + Atime_high uint16 + Dtime_high uint16 + Ctime_high uint16 + _ uint16 +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go index bb6b03dfcb..947b32e434 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go @@ -642,3 +642,37 @@ const ( PPS_GETCAP = 0x400470a3 PPS_FETCH = 0xc00470a4 ) + +const ( + PIDFD_NONBLOCK = 0x800 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + Seq uint32 + _ uint32 + _ uint64 + _ uint64 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Atime_high uint32 + Atime uint32 + Dtime_high uint32 + Dtime uint32 + Ctime_high uint32 + Ctime uint32 + _ uint32 + Segsz uint32 + Cpid int32 + Lpid int32 + Nattch uint32 + _ uint32 + _ uint32 + _ [4]byte +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index 7637243b7b..2a606151b0 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -642,3 +642,32 @@ const ( PPS_GETCAP = 0x400870a3 PPS_FETCH = 0xc00870a4 ) + +const ( + PIDFD_NONBLOCK = 0x800 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + Seq uint32 + _ uint32 + _ uint64 + _ uint64 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Atime int64 + Dtime int64 + Ctime int64 + Segsz uint64 + Cpid int32 + Lpid int32 + Nattch uint64 + _ uint64 + _ uint64 +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index a1a28e525f..d0d735d02c 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -642,3 +642,32 @@ const ( PPS_GETCAP = 0x400870a3 PPS_FETCH = 0xc00870a4 ) + +const ( + PIDFD_NONBLOCK = 0x800 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + Seq uint32 + _ uint32 + _ uint64 + _ uint64 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Atime int64 + Dtime int64 + Ctime int64 + Segsz uint64 + Cpid int32 + Lpid int32 + Nattch uint64 + _ uint64 + _ uint64 +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index e0a8a13622..95e3d6d06f 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -660,3 +660,33 @@ const ( PPS_GETCAP = 0x800870a3 PPS_FETCH = 0xc00870a4 ) + +const ( + PIDFD_NONBLOCK = 0x800 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + _ [0]uint8 + Seq uint16 + _ uint16 + _ uint64 + _ uint64 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint64 + Atime int64 + Dtime int64 + Ctime int64 + Cpid int32 + Lpid int32 + Nattch uint64 + _ uint64 + _ uint64 +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index 21d6e56c70..cccf1ef26a 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -656,3 +656,32 @@ const ( PPS_GETCAP = 0x800870a3 PPS_FETCH = 0xc00870a4 ) + +const ( + PIDFD_NONBLOCK = 0x800 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + _ uint16 + Seq uint16 + _ uint64 + _ uint64 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint64 + Atime int64 + Dtime int64 + Ctime int64 + Cpid int32 + Lpid int32 + Nattch uint64 + _ uint64 + _ uint64 +} diff --git a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go index 0531e98f64..44fcbe4e9a 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go @@ -637,3 +637,32 @@ const ( PPS_GETCAP = 0x400870a3 PPS_FETCH = 0xc00870a4 ) + +const ( + PIDFD_NONBLOCK = 0x4000 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + _ uint16 + Seq uint16 + _ uint64 + _ uint64 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Atime int64 + Dtime int64 + Ctime int64 + Segsz uint64 + Cpid int32 + Lpid int32 + Nattch uint64 + _ uint64 + _ uint64 +} diff --git a/src/cmd/vendor/golang.org/x/sys/windows/memory_windows.go b/src/cmd/vendor/golang.org/x/sys/windows/memory_windows.go index 1adb60739a..6dc0920a84 100644 --- a/src/cmd/vendor/golang.org/x/sys/windows/memory_windows.go +++ b/src/cmd/vendor/golang.org/x/sys/windows/memory_windows.go @@ -35,3 +35,14 @@ const ( QUOTA_LIMITS_HARDWS_MAX_DISABLE = 0x00000008 QUOTA_LIMITS_HARDWS_MAX_ENABLE = 0x00000004 ) + +type MemoryBasicInformation struct { + BaseAddress uintptr + AllocationBase uintptr + AllocationProtect uint32 + PartitionId uint16 + RegionSize uintptr + State uint32 + Protect uint32 + Type uint32 +} diff --git a/src/cmd/vendor/golang.org/x/sys/windows/syscall_windows.go b/src/cmd/vendor/golang.org/x/sys/windows/syscall_windows.go index 1215b2ae20..d3b59ae69c 100644 --- a/src/cmd/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/src/cmd/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -274,6 +274,11 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) = kernel32.VirtualAlloc //sys VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) = kernel32.VirtualFree //sys VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) = kernel32.VirtualProtect +//sys VirtualProtectEx(process Handle, address uintptr, size uintptr, newProtect uint32, oldProtect *uint32) (err error) = kernel32.VirtualProtectEx +//sys VirtualQuery(address uintptr, buffer *MemoryBasicInformation, length uintptr) (err error) = kernel32.VirtualQuery +//sys VirtualQueryEx(process Handle, address uintptr, buffer *MemoryBasicInformation, length uintptr) (err error) = kernel32.VirtualQueryEx +//sys ReadProcessMemory(process Handle, baseAddress uintptr, buffer *byte, size uintptr, numberOfBytesRead *uintptr) (err error) = kernel32.ReadProcessMemory +//sys WriteProcessMemory(process Handle, baseAddress uintptr, buffer *byte, size uintptr, numberOfBytesWritten *uintptr) (err error) = kernel32.WriteProcessMemory //sys TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) = mswsock.TransmitFile //sys ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) = kernel32.ReadDirectoryChangesW //sys FindFirstChangeNotification(path string, watchSubtree bool, notifyFilter uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.FindFirstChangeNotificationW @@ -398,6 +403,11 @@ func NewCallbackCDecl(fn interface{}) uintptr { // Process Status API (PSAPI) //sys EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) = psapi.EnumProcesses +//sys EnumProcessModules(process Handle, module *Handle, cb uint32, cbNeeded *uint32) (err error) = psapi.EnumProcessModules +//sys EnumProcessModulesEx(process Handle, module *Handle, cb uint32, cbNeeded *uint32, filterFlag uint32) (err error) = psapi.EnumProcessModulesEx +//sys GetModuleInformation(process Handle, module Handle, modinfo *ModuleInfo, cb uint32) (err error) = psapi.GetModuleInformation +//sys GetModuleFileNameEx(process Handle, module Handle, filename *uint16, size uint32) (err error) = psapi.GetModuleFileNameExW +//sys GetModuleBaseName(process Handle, module Handle, baseName *uint16, size uint32) (err error) = psapi.GetModuleBaseNameW // NT Native APIs //sys rtlNtStatusToDosErrorNoTeb(ntstatus NTStatus) (ret syscall.Errno) = ntdll.RtlNtStatusToDosErrorNoTeb diff --git a/src/cmd/vendor/golang.org/x/sys/windows/types_windows.go b/src/cmd/vendor/golang.org/x/sys/windows/types_windows.go index 17f03312df..88e0ce5d0d 100644 --- a/src/cmd/vendor/golang.org/x/sys/windows/types_windows.go +++ b/src/cmd/vendor/golang.org/x/sys/windows/types_windows.go @@ -242,6 +242,14 @@ const ( TH32CS_INHERIT = 0x80000000 ) +const ( + // flags for EnumProcessModulesEx + LIST_MODULES_32BIT = 0x01 + LIST_MODULES_64BIT = 0x02 + LIST_MODULES_ALL = 0x03 + LIST_MODULES_DEFAULT = 0x00 +) + const ( // filters for ReadDirectoryChangesW and FindFirstChangeNotificationW FILE_NOTIFY_CHANGE_FILE_NAME = 0x001 @@ -2773,3 +2781,9 @@ const ( // Flag for QueryFullProcessImageName. const PROCESS_NAME_NATIVE = 1 + +type ModuleInfo struct { + BaseOfDll uintptr + SizeOfImage uint32 + EntryPoint uintptr +} diff --git a/src/cmd/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/src/cmd/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 2083ec376e..4ea788e4c4 100644 --- a/src/cmd/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/src/cmd/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -303,6 +303,7 @@ var ( procReadConsoleW = modkernel32.NewProc("ReadConsoleW") procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW") procReadFile = modkernel32.NewProc("ReadFile") + procReadProcessMemory = modkernel32.NewProc("ReadProcessMemory") procReleaseMutex = modkernel32.NewProc("ReleaseMutex") procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW") procResetEvent = modkernel32.NewProc("ResetEvent") @@ -345,12 +346,16 @@ var ( procVirtualFree = modkernel32.NewProc("VirtualFree") procVirtualLock = modkernel32.NewProc("VirtualLock") procVirtualProtect = modkernel32.NewProc("VirtualProtect") + procVirtualProtectEx = modkernel32.NewProc("VirtualProtectEx") + procVirtualQuery = modkernel32.NewProc("VirtualQuery") + procVirtualQueryEx = modkernel32.NewProc("VirtualQueryEx") procVirtualUnlock = modkernel32.NewProc("VirtualUnlock") procWTSGetActiveConsoleSessionId = modkernel32.NewProc("WTSGetActiveConsoleSessionId") procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects") procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject") procWriteConsoleW = modkernel32.NewProc("WriteConsoleW") procWriteFile = modkernel32.NewProc("WriteFile") + procWriteProcessMemory = modkernel32.NewProc("WriteProcessMemory") procAcceptEx = modmswsock.NewProc("AcceptEx") procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs") procTransmitFile = modmswsock.NewProc("TransmitFile") @@ -377,7 +382,12 @@ var ( procCoTaskMemFree = modole32.NewProc("CoTaskMemFree") procCoUninitialize = modole32.NewProc("CoUninitialize") procStringFromGUID2 = modole32.NewProc("StringFromGUID2") + procEnumProcessModules = modpsapi.NewProc("EnumProcessModules") + procEnumProcessModulesEx = modpsapi.NewProc("EnumProcessModulesEx") procEnumProcesses = modpsapi.NewProc("EnumProcesses") + procGetModuleBaseNameW = modpsapi.NewProc("GetModuleBaseNameW") + procGetModuleFileNameExW = modpsapi.NewProc("GetModuleFileNameExW") + procGetModuleInformation = modpsapi.NewProc("GetModuleInformation") procSubscribeServiceChangeNotifications = modsechost.NewProc("SubscribeServiceChangeNotifications") procUnsubscribeServiceChangeNotifications = modsechost.NewProc("UnsubscribeServiceChangeNotifications") procGetUserNameExW = modsecur32.NewProc("GetUserNameExW") @@ -2631,6 +2641,14 @@ func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) ( return } +func ReadProcessMemory(process Handle, baseAddress uintptr, buffer *byte, size uintptr, numberOfBytesRead *uintptr) (err error) { + r1, _, e1 := syscall.Syscall6(procReadProcessMemory.Addr(), 5, uintptr(process), uintptr(baseAddress), uintptr(unsafe.Pointer(buffer)), uintptr(size), uintptr(unsafe.Pointer(numberOfBytesRead)), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func ReleaseMutex(mutex Handle) (err error) { r1, _, e1 := syscall.Syscall(procReleaseMutex.Addr(), 1, uintptr(mutex), 0, 0) if r1 == 0 { @@ -2985,6 +3003,30 @@ func VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect return } +func VirtualProtectEx(process Handle, address uintptr, size uintptr, newProtect uint32, oldProtect *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procVirtualProtectEx.Addr(), 5, uintptr(process), uintptr(address), uintptr(size), uintptr(newProtect), uintptr(unsafe.Pointer(oldProtect)), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func VirtualQuery(address uintptr, buffer *MemoryBasicInformation, length uintptr) (err error) { + r1, _, e1 := syscall.Syscall(procVirtualQuery.Addr(), 3, uintptr(address), uintptr(unsafe.Pointer(buffer)), uintptr(length)) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func VirtualQueryEx(process Handle, address uintptr, buffer *MemoryBasicInformation, length uintptr) (err error) { + r1, _, e1 := syscall.Syscall6(procVirtualQueryEx.Addr(), 4, uintptr(process), uintptr(address), uintptr(unsafe.Pointer(buffer)), uintptr(length), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func VirtualUnlock(addr uintptr, length uintptr) (err error) { r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0) if r1 == 0 { @@ -3041,6 +3083,14 @@ func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) return } +func WriteProcessMemory(process Handle, baseAddress uintptr, buffer *byte, size uintptr, numberOfBytesWritten *uintptr) (err error) { + r1, _, e1 := syscall.Syscall6(procWriteProcessMemory.Addr(), 5, uintptr(process), uintptr(baseAddress), uintptr(unsafe.Pointer(buffer)), uintptr(size), uintptr(unsafe.Pointer(numberOfBytesWritten)), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) { r1, _, e1 := syscall.Syscall9(procAcceptEx.Addr(), 8, uintptr(ls), uintptr(as), uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(overlapped)), 0) if r1 == 0 { @@ -3225,6 +3275,22 @@ func stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) { return } +func EnumProcessModules(process Handle, module *Handle, cb uint32, cbNeeded *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procEnumProcessModules.Addr(), 4, uintptr(process), uintptr(unsafe.Pointer(module)), uintptr(cb), uintptr(unsafe.Pointer(cbNeeded)), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func EnumProcessModulesEx(process Handle, module *Handle, cb uint32, cbNeeded *uint32, filterFlag uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procEnumProcessModulesEx.Addr(), 5, uintptr(process), uintptr(unsafe.Pointer(module)), uintptr(cb), uintptr(unsafe.Pointer(cbNeeded)), uintptr(filterFlag), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) { var _p0 *uint32 if len(processIds) > 0 { @@ -3237,6 +3303,30 @@ func EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) { return } +func GetModuleBaseName(process Handle, module Handle, baseName *uint16, size uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procGetModuleBaseNameW.Addr(), 4, uintptr(process), uintptr(module), uintptr(unsafe.Pointer(baseName)), uintptr(size), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func GetModuleFileNameEx(process Handle, module Handle, filename *uint16, size uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procGetModuleFileNameExW.Addr(), 4, uintptr(process), uintptr(module), uintptr(unsafe.Pointer(filename)), uintptr(size), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func GetModuleInformation(process Handle, module Handle, modinfo *ModuleInfo, cb uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procGetModuleInformation.Addr(), 4, uintptr(process), uintptr(module), uintptr(unsafe.Pointer(modinfo)), uintptr(cb), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func SubscribeServiceChangeNotifications(service Handle, eventType uint32, callback uintptr, callbackCtx uintptr, subscription *uintptr) (ret error) { ret = procSubscribeServiceChangeNotifications.Find() if ret != nil { diff --git a/src/cmd/vendor/modules.txt b/src/cmd/vendor/modules.txt index ecb170d290..ad08e583fb 100644 --- a/src/cmd/vendor/modules.txt +++ b/src/cmd/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/google/pprof v0.0.0-20211001005136-7fe48b4c820b +# github.com/google/pprof v0.0.0-20211104044539-f987b9c94b31 ## explicit; go 1.14 github.com/google/pprof/driver github.com/google/pprof/internal/binutils @@ -15,8 +15,8 @@ github.com/google/pprof/profile github.com/google/pprof/third_party/d3 github.com/google/pprof/third_party/d3flamegraph github.com/google/pprof/third_party/svgpan -# github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 -## explicit +# github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d +## explicit; go 1.12 github.com/ianlancetaylor/demangle # golang.org/x/arch v0.0.0-20210901143047-ebb09ed340f1 ## explicit; go 1.17 @@ -42,7 +42,7 @@ golang.org/x/mod/zip # golang.org/x/sync v0.0.0-20210220032951-036812b2e83c ## explicit golang.org/x/sync/semaphore -# golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e +# golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac ## explicit; go 1.17 golang.org/x/sys/internal/unsafeheader golang.org/x/sys/plan9 diff --git a/src/go.mod b/src/go.mod index 35231cf911..7d982c75aa 100644 --- a/src/go.mod +++ b/src/go.mod @@ -8,6 +8,6 @@ require ( ) require ( - golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e // indirect + golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect golang.org/x/text v0.3.7 // indirect ) diff --git a/src/go.sum b/src/go.sum index 621d61384a..ff1279697d 100644 --- a/src/go.sum +++ b/src/go.sum @@ -2,7 +2,7 @@ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s3 golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/net v0.0.0-20211005215030-d2e5035098b3 h1:G64nFNerDErBd2KdvHvIn3Ee6ccUQBTfhDZEO0DccfU= golang.org/x/net v0.0.0-20211005215030-d2e5035098b3/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e h1:XMgFehsDnnLGtjvjOfqWSUzt0alpTR1RSEuznObga2c= -golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= diff --git a/src/vendor/modules.txt b/src/vendor/modules.txt index 683040db9b..770a08e1fb 100644 --- a/src/vendor/modules.txt +++ b/src/vendor/modules.txt @@ -19,7 +19,7 @@ golang.org/x/net/idna golang.org/x/net/lif golang.org/x/net/nettest golang.org/x/net/route -# golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e +# golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac ## explicit; go 1.17 golang.org/x/sys/cpu # golang.org/x/text v0.3.7 From 577287728a8e8abbcbc6c96fdd49feb5a99ced0c Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 3 Nov 2021 16:28:51 -0400 Subject: [PATCH 372/406] runtime: clear upper half of sec in ARM walltime https://golang.org/cl/246763 accidentally changed this to assign the old value of vdsoPC to the upper half of sec as that is the last value in R1. The old value of vdsoPC is usually zero, so this typically works. However, the reentrant case will have a non-zero value, resulting in a bogus returned time. I am unsure if walltime is reachable from a signal handler, so this may never occur. Change-Id: I8562d6ec2a845fcffee9618d994b8ea57fbd199e Reviewed-on: https://go-review.googlesource.com/c/go/+/361159 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- src/runtime/sys_linux_arm.s | 1 + 1 file changed, 1 insertion(+) diff --git a/src/runtime/sys_linux_arm.s b/src/runtime/sys_linux_arm.s index 3f30da7b54..65935de99f 100644 --- a/src/runtime/sys_linux_arm.s +++ b/src/runtime/sys_linux_arm.s @@ -360,6 +360,7 @@ finish: MOVW R1, m_vdsoPC(R5) MOVW R0, sec_lo+0(FP) + MOVW $0, R1 MOVW R1, sec_hi+4(FP) MOVW R2, nsec+8(FP) RET From b2149ac336987940b3f14c50c064a43bf9a761de Mon Sep 17 00:00:00 2001 From: jiahua wang Date: Thu, 4 Nov 2021 10:13:11 +0800 Subject: [PATCH 373/406] net/netip: fix various typos in comment Change-Id: I02724dadacd9b3f23ca7e6bda581cba62ceff828 Reviewed-on: https://go-review.googlesource.com/c/go/+/361274 Reviewed-by: Ian Lance Taylor Reviewed-by: Damien Neil Trust: Damien Neil Run-TryBot: Damien Neil TryBot-Result: Go Bot --- src/net/netip/netip.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/netip/netip.go b/src/net/netip/netip.go index d15a4947ac..02a4aa0452 100644 --- a/src/net/netip/netip.go +++ b/src/net/netip/netip.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. -// Package netip defines a IP address type that's a small value type. +// Package netip defines an IP address type that's a small value type. // Building on that Addr type, the package also defines AddrPort (an // IP address and a port), and Prefix (an IP address and a bit length // prefix). From 5af93a2d1556226656f003f65ac1de034b8fb55f Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Thu, 4 Nov 2021 13:55:31 -0400 Subject: [PATCH 374/406] internal/fuzz: improve minimizing message In order to know the actual number of bytes of the entire corpus entry, the coordinator would likely need to unmarshal the bytes and tally up the length. That's more work than it is worth, so this change just clarifies that the printed # of bytes is the length of the entire file, not just the entry itself. Fixes #48989 Change-Id: I6fa0c0206a249cefdf6335040c560ec0c5a55b4a Reviewed-on: https://go-review.googlesource.com/c/go/+/361414 Trust: Katie Hockman Run-TryBot: Katie Hockman Reviewed-by: Roland Shoemaker TryBot-Result: Go Bot --- src/internal/fuzz/fuzz.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/fuzz/fuzz.go b/src/internal/fuzz/fuzz.go index aef1dee978..8bd40fe8bf 100644 --- a/src/internal/fuzz/fuzz.go +++ b/src/internal/fuzz/fuzz.go @@ -246,7 +246,7 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err // Send it back to a worker for minimization. Disable inputC so // other workers don't continue fuzzing. c.crashMinimizing = &result - fmt.Fprintf(c.opts.Log, "fuzz: minimizing %d-byte crash input...\n", len(result.entry.Data)) + fmt.Fprintf(c.opts.Log, "fuzz: minimizing %d-byte crash file\n", len(result.entry.Data)) c.queueForMinimization(result, nil) } else if !crashWritten { // Found a crasher that's either minimized or not minimizable. From 988efd58197205060ace508d29984fbab6eb3840 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Tue, 2 Nov 2021 18:30:08 -0400 Subject: [PATCH 375/406] cmd/link: don't use label symbol for absolute address relocations on ARM64 PE On ARM64 PE, when external linking, the PE relocation does not have an explicit addend, and instead has the addend encoded in the instruction or data. An instruction (e.g. ADRP, ADD) has limited width for the addend, so when the addend is large we use a label symbol, which points to the middle of the original target symbol, and a smaller addend. But for an absolute address relocation in the data section, we have the full width to encode the addend and we should not use the label symbol. Also, since we do not adjust the addend in the data, using the label symbol will actually make it point to the wrong address. E.g for an R_ADDR relocation targeting x+0x123456, we should emit 0x123456 in the data with an IMAGE_REL_ARM64_ADDR64 relocation pointing to x, whereas the current code emits 0x123456 in the data with an IMAGE_REL_ARM64_ADDR64 relocation pointing to the label symbol x+1MB, so it will actually be resolved to x+0x223456. This CL fixes this. Fixes #47557. Change-Id: I64e02b56f1d792f8c20ca61b78623ef5c3e34d7e Reviewed-on: https://go-review.googlesource.com/c/go/+/360895 Trust: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Go Bot Reviewed-by: Than McIntosh --- src/cmd/link/internal/arm64/asm.go | 2 +- src/cmd/link/link_test.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/cmd/link/internal/arm64/asm.go b/src/cmd/link/internal/arm64/asm.go index f56c9c1222..abae0f87bc 100644 --- a/src/cmd/link/internal/arm64/asm.go +++ b/src/cmd/link/internal/arm64/asm.go @@ -602,7 +602,7 @@ func pereloc1(arch *sys.Arch, out *ld.OutBuf, ldr *loader.Loader, s loader.Sym, rs := r.Xsym rt := r.Type - if r.Xadd != signext21(r.Xadd) { + if rt == objabi.R_ADDRARM64 && r.Xadd != signext21(r.Xadd) { // If the relocation target would overflow the addend, then target // a linker-manufactured label symbol with a smaller addend instead. label := ldr.Lookup(offsetLabelName(ldr, rs, r.Xadd/peRelocLimit*peRelocLimit), ldr.SymVersion(rs)) diff --git a/src/cmd/link/link_test.go b/src/cmd/link/link_test.go index 2b0b2dc4a1..ad7658bb25 100644 --- a/src/cmd/link/link_test.go +++ b/src/cmd/link/link_test.go @@ -997,13 +997,31 @@ package main var x = [1<<25]byte{1<<23: 23, 1<<24: 24} +var addr = [...]*byte{ + &x[1<<23-1], + &x[1<<23], + &x[1<<23+1], + &x[1<<24-1], + &x[1<<24], + &x[1<<24+1], +} + func main() { + // check relocations in instructions check(x[1<<23-1], 0) check(x[1<<23], 23) check(x[1<<23+1], 0) check(x[1<<24-1], 0) check(x[1<<24], 24) check(x[1<<24+1], 0) + + // check absolute address relocations in data + check(*addr[0], 0) + check(*addr[1], 23) + check(*addr[2], 0) + check(*addr[3], 0) + check(*addr[4], 24) + check(*addr[5], 0) } func check(x, y byte) { From a108b280bc724779ebaa6656d35f0fb307fb2a9b Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Tue, 13 Apr 2021 03:07:27 +0000 Subject: [PATCH 376/406] runtime: implement GC pacer redesign This change implements the GC pacer redesign outlined in #44167 and the accompanying design document, behind a GOEXPERIMENT flag that is on by default. In addition to adding the new pacer, this CL also includes code to track and account for stack and globals scan work in the pacer and in the assist credit system. The new pacer also deviates slightly from the document in that it increases the bound on the minimum trigger ratio from 0.6 (scaled by GOGC) to 0.7. The logic behind this change is that the new pacer much more consistently hits the goal (good!) leading to slightly less frequent GC cycles, but _longer_ ones (in this case, bad!). It turns out that the cost of having the GC on hurts throughput significantly (per byte of memory used), though tail latencies can improve by up to 10%! To be conservative, this change moves the value to 0.7 where there is a small improvement to both throughput and latency, given the memory use. Because the new pacer accounts for the two most significant sources of scan work after heap objects, it is now also safer to reduce the minimum heap size without leading to very poor amortization. This change thus decreases the minimum heap size to 512 KiB, which corresponds to the fact that the runtime has around 200 KiB of scannable globals always there, up-front, providing a baseline. Benchmark results: https://perf.golang.org/search?q=upload:20211001.6 tile38's KNearest benchmark shows a memory increase, but throughput (and latency) per byte of memory used is better. gopher-lua showed an increase in both CPU time and memory usage, but subsequent attempts to reproduce this behavior are inconsistent. Sometimes the overall performance is better, sometimes it's worse. This suggests that the benchmark is fairly noisy in a way not captured by the benchmarking framework itself. biogo-igor is the only benchmark to show a significant performance loss. This benchmark exhibits a very high GC rate, with relatively little work to do in each cycle. The idle mark workers are quite active. In the new pacer, mark phases are longer, mark assists are fewer, and some of that time in mark assists has shifted to idle workers. Linux perf indicates that the difference in CPU time can be mostly attributed to write-barrier slow path related calls, which in turn indicates that the write barrier being on for longer is the primary culprit. This also explains the memory increase, as a longer mark phase leads to more memory allocated black, surviving an extra cycle and contributing to the heap goal. For #44167. Change-Id: I8ac7cfef7d593e4a642c9b2be43fb3591a8ec9c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/309869 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Austin Clements Reviewed-by: Michael Pratt --- .../goexperiment/exp_pacerredesign_off.go | 9 + .../goexperiment/exp_pacerredesign_on.go | 9 + src/internal/goexperiment/flags.go | 6 + src/runtime/export_test.go | 4 +- src/runtime/mgc.go | 2 + src/runtime/mgcmark.go | 117 +++-- src/runtime/mgcpacer.go | 494 +++++++++++++++--- src/runtime/mgcpacer_test.go | 127 ++++- src/runtime/mgcwork.go | 11 +- 9 files changed, 678 insertions(+), 101 deletions(-) create mode 100644 src/internal/goexperiment/exp_pacerredesign_off.go create mode 100644 src/internal/goexperiment/exp_pacerredesign_on.go diff --git a/src/internal/goexperiment/exp_pacerredesign_off.go b/src/internal/goexperiment/exp_pacerredesign_off.go new file mode 100644 index 0000000000..62e1831437 --- /dev/null +++ b/src/internal/goexperiment/exp_pacerredesign_off.go @@ -0,0 +1,9 @@ +// Code generated by mkconsts.go. DO NOT EDIT. + +//go:build !goexperiment.pacerredesign +// +build !goexperiment.pacerredesign + +package goexperiment + +const PacerRedesign = false +const PacerRedesignInt = 0 diff --git a/src/internal/goexperiment/exp_pacerredesign_on.go b/src/internal/goexperiment/exp_pacerredesign_on.go new file mode 100644 index 0000000000..b22b031009 --- /dev/null +++ b/src/internal/goexperiment/exp_pacerredesign_on.go @@ -0,0 +1,9 @@ +// Code generated by mkconsts.go. DO NOT EDIT. + +//go:build goexperiment.pacerredesign +// +build goexperiment.pacerredesign + +package goexperiment + +const PacerRedesign = true +const PacerRedesignInt = 1 diff --git a/src/internal/goexperiment/flags.go b/src/internal/goexperiment/flags.go index 0a61a0e5fc..3bf19222e1 100644 --- a/src/internal/goexperiment/flags.go +++ b/src/internal/goexperiment/flags.go @@ -83,4 +83,10 @@ type Flags struct { // Requires wrappers (to do ABI translation), and reflect (so // reflection calls use registers). RegabiArgs bool + + // PacerRedesign enables the new GC pacer in the runtime. + // + // Details regarding the new pacer may be found at + // https://golang.org/design/44167-gc-pacer-redesign + PacerRedesign bool } diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index 533627fa58..5149252c83 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -1290,7 +1290,9 @@ type GCControllerReviseDelta struct { func (c *GCController) Revise(d GCControllerReviseDelta) { c.heapLive += uint64(d.HeapLive) c.heapScan += uint64(d.HeapScan) - c.scanWork += d.HeapScanWork + d.StackScanWork + d.GlobalsScanWork + c.heapScanWork.Add(d.HeapScanWork) + c.stackScanWork.Add(d.StackScanWork) + c.globalsScanWork.Add(d.GlobalsScanWork) c.revise() } diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 03711a9617..96f4157b59 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -1084,6 +1084,8 @@ func gcMarkTermination(nextTriggerRatio float64) { print(" ms cpu, ", work.heap0>>20, "->", work.heap1>>20, "->", work.heap2>>20, " MB, ", work.heapGoal>>20, " MB goal, ", + gcController.stackScan>>20, " MB stacks, ", + gcController.globalsScan>>20, " MB globals, ", work.maxprocs, " P") if work.userForced { print(" (forced)") diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go index efda65fe1e..a5129bd1ee 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -8,6 +8,7 @@ package runtime import ( "internal/goarch" + "internal/goexperiment" "runtime/internal/atomic" "runtime/internal/sys" "unsafe" @@ -151,20 +152,28 @@ var oneptrmask = [...]uint8{1} // // Preemption must be disabled (because this uses a gcWork). // +// Returns the amount of GC work credit produced by the operation. +// If flushBgCredit is true, then that credit is also flushed +// to the background credit pool. +// // nowritebarrier is only advisory here. // //go:nowritebarrier -func markroot(gcw *gcWork, i uint32) { +func markroot(gcw *gcWork, i uint32, flushBgCredit bool) int64 { // Note: if you add a case here, please also update heapdump.go:dumproots. + var workDone int64 + var workCounter *atomic.Int64 switch { case work.baseData <= i && i < work.baseBSS: + workCounter = &gcController.globalsScanWork for _, datap := range activeModules() { - markrootBlock(datap.data, datap.edata-datap.data, datap.gcdatamask.bytedata, gcw, int(i-work.baseData)) + workDone += markrootBlock(datap.data, datap.edata-datap.data, datap.gcdatamask.bytedata, gcw, int(i-work.baseData)) } case work.baseBSS <= i && i < work.baseSpans: + workCounter = &gcController.globalsScanWork for _, datap := range activeModules() { - markrootBlock(datap.bss, datap.ebss-datap.bss, datap.gcbssmask.bytedata, gcw, int(i-work.baseBSS)) + workDone += markrootBlock(datap.bss, datap.ebss-datap.bss, datap.gcbssmask.bytedata, gcw, int(i-work.baseBSS)) } case i == fixedRootFinalizers: @@ -184,6 +193,7 @@ func markroot(gcw *gcWork, i uint32) { default: // the rest is scanning goroutine stacks + workCounter = &gcController.stackScanWork var gp *g if work.baseStacks <= i && i < work.baseEnd { // N.B. Atomic read of allglen in gcMarkRootPrepare @@ -230,7 +240,7 @@ func markroot(gcw *gcWork, i uint32) { if gp.gcscandone { throw("g already scanned") } - scanstack(gp, gcw) + workDone += scanstack(gp, gcw) gp.gcscandone = true resumeG(stopped) @@ -239,13 +249,24 @@ func markroot(gcw *gcWork, i uint32) { } }) } + if goexperiment.PacerRedesign { + if workCounter != nil && workDone != 0 { + workCounter.Add(workDone) + if flushBgCredit { + gcFlushBgCredit(workDone) + } + } + } + return workDone } // markrootBlock scans the shard'th shard of the block of memory [b0, // b0+n0), with the given pointer mask. // +// Returns the amount of work done. +// //go:nowritebarrier -func markrootBlock(b0, n0 uintptr, ptrmask0 *uint8, gcw *gcWork, shard int) { +func markrootBlock(b0, n0 uintptr, ptrmask0 *uint8, gcw *gcWork, shard int) int64 { if rootBlockBytes%(8*goarch.PtrSize) != 0 { // This is necessary to pick byte offsets in ptrmask0. throw("rootBlockBytes must be a multiple of 8*ptrSize") @@ -256,7 +277,7 @@ func markrootBlock(b0, n0 uintptr, ptrmask0 *uint8, gcw *gcWork, shard int) { // These tests are written to avoid any possible overflow. off := uintptr(shard) * rootBlockBytes if off >= n0 { - return + return 0 } b := b0 + off ptrmask := (*uint8)(add(unsafe.Pointer(ptrmask0), uintptr(shard)*(rootBlockBytes/(8*goarch.PtrSize)))) @@ -267,6 +288,7 @@ func markrootBlock(b0, n0 uintptr, ptrmask0 *uint8, gcw *gcWork, shard int) { // Scan this shard. scanblock(b, n, ptrmask, gcw, nil) + return int64(n) } // markrootFreeGStacks frees stacks of dead Gs. @@ -681,6 +703,13 @@ func gcFlushBgCredit(scanWork int64) { // scanstack scans gp's stack, greying all pointers found on the stack. // +// For goexperiment.PacerRedesign: +// Returns the amount of scan work performed, but doesn't update +// gcController.stackScanWork or flush any credit. Any background credit produced +// by this function should be flushed by its caller. scanstack itself can't +// safely flush because it may result in trying to wake up a goroutine that +// was just scanned, resulting in a self-deadlock. +// // scanstack will also shrink the stack if it is safe to do so. If it // is not, it schedules a stack shrink for the next synchronous safe // point. @@ -690,7 +719,7 @@ func gcFlushBgCredit(scanWork int64) { // //go:nowritebarrier //go:systemstack -func scanstack(gp *g, gcw *gcWork) { +func scanstack(gp *g, gcw *gcWork) int64 { if readgstatus(gp)&_Gscan == 0 { print("runtime:scanstack: gp=", gp, ", goid=", gp.goid, ", gp->atomicstatus=", hex(readgstatus(gp)), "\n") throw("scanstack - bad status") @@ -701,7 +730,7 @@ func scanstack(gp *g, gcw *gcWork) { print("runtime: gp=", gp, ", goid=", gp.goid, ", gp->atomicstatus=", readgstatus(gp), "\n") throw("mark - bad status") case _Gdead: - return + return 0 case _Grunning: print("runtime: gp=", gp, ", goid=", gp.goid, ", gp->atomicstatus=", readgstatus(gp), "\n") throw("scanstack: goroutine not stopped") @@ -713,6 +742,15 @@ func scanstack(gp *g, gcw *gcWork) { throw("can't scan our own stack") } + // stackSize is the amount of work we'll be reporting. + // + // We report the total stack size, more than we scan, + // because this number needs to line up with gcControllerState's + // stackScan and scannableStackSize fields. + // + // See the documentation on those fields for more information. + stackSize := gp.stack.hi - gp.stack.lo + if isShrinkStackSafe(gp) { // Shrink the stack if not much of it is being used. shrinkstack(gp) @@ -852,6 +890,7 @@ func scanstack(gp *g, gcw *gcWork) { if state.buf != nil || state.cbuf != nil || state.freeBuf != nil { throw("remaining pointer buffers") } + return int64(stackSize) } // Scan a stack frame: local variables and function arguments/results. @@ -984,7 +1023,7 @@ func gcDrain(gcw *gcWork, flags gcDrainFlags) { flushBgCredit := flags&gcDrainFlushBgCredit != 0 idle := flags&gcDrainIdle != 0 - initScanWork := gcw.scanWork + initScanWork := gcw.heapScanWork // checkWork is the scan work before performing the next // self-preempt check. @@ -1007,7 +1046,7 @@ func gcDrain(gcw *gcWork, flags gcDrainFlags) { if job >= work.markrootJobs { break } - markroot(gcw, job) + markroot(gcw, job, flushBgCredit) if check != nil && check() { goto done } @@ -1046,14 +1085,14 @@ func gcDrain(gcw *gcWork, flags gcDrainFlags) { // Flush background scan work credit to the global // account if we've accumulated enough locally so // mutator assists can draw on it. - if gcw.scanWork >= gcCreditSlack { - atomic.Xaddint64(&gcController.scanWork, gcw.scanWork) + if gcw.heapScanWork >= gcCreditSlack { + gcController.heapScanWork.Add(gcw.heapScanWork) if flushBgCredit { - gcFlushBgCredit(gcw.scanWork - initScanWork) + gcFlushBgCredit(gcw.heapScanWork - initScanWork) initScanWork = 0 } - checkWork -= gcw.scanWork - gcw.scanWork = 0 + checkWork -= gcw.heapScanWork + gcw.heapScanWork = 0 if checkWork <= 0 { checkWork += drainCheckThreshold @@ -1066,12 +1105,12 @@ func gcDrain(gcw *gcWork, flags gcDrainFlags) { done: // Flush remaining scan work credit. - if gcw.scanWork > 0 { - atomic.Xaddint64(&gcController.scanWork, gcw.scanWork) + if gcw.heapScanWork > 0 { + gcController.heapScanWork.Add(gcw.heapScanWork) if flushBgCredit { - gcFlushBgCredit(gcw.scanWork - initScanWork) + gcFlushBgCredit(gcw.heapScanWork - initScanWork) } - gcw.scanWork = 0 + gcw.heapScanWork = 0 } } @@ -1095,10 +1134,10 @@ func gcDrainN(gcw *gcWork, scanWork int64) int64 { // There may already be scan work on the gcw, which we don't // want to claim was done by this call. - workFlushed := -gcw.scanWork + workFlushed := -gcw.heapScanWork gp := getg().m.curg - for !gp.preempt && workFlushed+gcw.scanWork < scanWork { + for !gp.preempt && workFlushed+gcw.heapScanWork < scanWork { // See gcDrain comment. if work.full == 0 { gcw.balance() @@ -1117,13 +1156,13 @@ func gcDrainN(gcw *gcWork, scanWork int64) int64 { if b == 0 { // Try to do a root job. - // - // TODO: Assists should get credit for this - // work. if work.markrootNext < work.markrootJobs { job := atomic.Xadd(&work.markrootNext, +1) - 1 if job < work.markrootJobs { - markroot(gcw, job) + work := markroot(gcw, job, false) + if goexperiment.PacerRedesign { + workFlushed += work + } continue } } @@ -1134,10 +1173,10 @@ func gcDrainN(gcw *gcWork, scanWork int64) int64 { scanobject(b, gcw) // Flush background scan work credit. - if gcw.scanWork >= gcCreditSlack { - atomic.Xaddint64(&gcController.scanWork, gcw.scanWork) - workFlushed += gcw.scanWork - gcw.scanWork = 0 + if gcw.heapScanWork >= gcCreditSlack { + gcController.heapScanWork.Add(gcw.heapScanWork) + workFlushed += gcw.heapScanWork + gcw.heapScanWork = 0 } } @@ -1145,14 +1184,14 @@ func gcDrainN(gcw *gcWork, scanWork int64) int64 { // here because this never flushes to bgScanCredit and // gcw.dispose will flush any remaining work to scanWork. - return workFlushed + gcw.scanWork + return workFlushed + gcw.heapScanWork } // scanblock scans b as scanobject would, but using an explicit // pointer bitmap instead of the heap bitmap. // // This is used to scan non-heap roots, so it does not update -// gcw.bytesMarked or gcw.scanWork. +// gcw.bytesMarked or gcw.heapScanWork. // // If stk != nil, possible stack pointers are also reported to stk.putPtr. //go:nowritebarrier @@ -1282,7 +1321,7 @@ func scanobject(b uintptr, gcw *gcWork) { } } gcw.bytesMarked += uint64(n) - gcw.scanWork += int64(i) + gcw.heapScanWork += int64(i) } // scanConservative scans block [b, b+n) conservatively, treating any @@ -1521,7 +1560,19 @@ func gcmarknewobject(span *mspan, obj, size, scanSize uintptr) { gcw := &getg().m.p.ptr().gcw gcw.bytesMarked += uint64(size) - gcw.scanWork += int64(scanSize) + if !goexperiment.PacerRedesign { + // The old pacer counts newly allocated memory toward + // heapScanWork because heapScan is continuously updated + // throughout the GC cyle with newly allocated memory. However, + // these objects are never actually scanned, so we need + // to account for them in heapScanWork here, "faking" their work. + // Otherwise the pacer will think it's always behind, potentially + // by a large margin. + // + // The new pacer doesn't care about this because it ceases to updated + // heapScan once a GC cycle starts, effectively snapshotting it. + gcw.heapScanWork += int64(scanSize) + } } // gcMarkTinyAllocs greys all active tiny alloc blocks. diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index af43e6258f..f886a07da1 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -6,6 +6,7 @@ package runtime import ( "internal/cpu" + "internal/goexperiment" "runtime/internal/atomic" "unsafe" ) @@ -13,7 +14,8 @@ import ( const ( // gcGoalUtilization is the goal CPU utilization for // marking as a fraction of GOMAXPROCS. - gcGoalUtilization = 0.30 + gcGoalUtilization = goexperiment.PacerRedesignInt*gcBackgroundUtilization + + (1-goexperiment.PacerRedesignInt)*(gcBackgroundUtilization+0.05) // gcBackgroundUtilization is the fixed CPU utilization for background // marking. It must be <= gcGoalUtilization. The difference between @@ -26,10 +28,15 @@ const ( // better control CPU and heap growth. However, the larger the gap, // the more mutator assists are expected to happen, which impact // mutator latency. + // + // If goexperiment.PacerRedesign, the trigger feedback controller + // is replaced with an estimate of the mark/cons ratio that doesn't + // have the same saturation issues, so this is set equal to + // gcGoalUtilization. gcBackgroundUtilization = 0.25 // gcCreditSlack is the amount of scan work credit that can - // accumulate locally before updating gcController.scanWork and, + // accumulate locally before updating gcController.heapScanWork and, // optionally, gcController.bgScanCredit. Lower values give a more // accurate assist ratio and make it more likely that assists will // successfully steal background credit. Higher values reduce memory @@ -46,7 +53,8 @@ const ( gcOverAssistWork = 64 << 10 // defaultHeapMinimum is the value of heapMinimum for GOGC==100. - defaultHeapMinimum = 4 << 20 + defaultHeapMinimum = goexperiment.PacerRedesignInt*(512<<10) + + (1-goexperiment.PacerRedesignInt)*(4<<20) // scannableStackSizeSlack is the bytes of stack space allocated or freed // that can accumulate on a P before updating gcController.stackSize. @@ -108,6 +116,8 @@ type gcControllerState struct { // during mark termination for the next cycle's trigger. // // Protected by mheap_.lock or a STW. + // + // Used if !goexperiment.PacerRedesign. triggerRatio float64 // trigger is the heap size that triggers marking. @@ -122,6 +132,31 @@ type gcControllerState struct { // Protected by mheap_.lock or a STW. trigger uint64 + // consMark is the estimated per-CPU consMark ratio for the application. + // + // It represents the ratio between the application's allocation + // rate, as bytes allocated per CPU-time, and the GC's scan rate, + // as bytes scanned per CPU-time. + // The units of this ratio are (B / cpu-ns) / (B / cpu-ns). + // + // At a high level, this value is computed as the bytes of memory + // allocated (cons) per unit of scan work completed (mark) in a GC + // cycle, divided by the CPU time spent on each activity. + // + // Updated at the end of each GC cycle, in endCycle. + // + // For goexperiment.PacerRedesign. + consMark float64 + + // consMarkController holds the state for the mark-cons ratio + // estimation over time. + // + // Its purpose is to smooth out noisiness in the computation of + // consMark; see consMark for details. + // + // For goexperiment.PacerRedesign. + consMarkController piController + // heapGoal is the goal heapLive for when next GC ends. // Set to ^uint64(0) if disabled. // @@ -164,12 +199,23 @@ type gcControllerState struct { // is the live heap (as counted by heapLive), but omitting // no-scan objects and no-scan tails of objects. // - // Whenever this is updated, call this gcControllerState's - // revise() method. + // For !goexperiment.PacerRedesign: Whenever this is updated, + // call this gcControllerState's revise() method. It is read + // and written atomically or with the world stopped. // - // Read and written atomically or with the world stopped. + // For goexperiment.PacerRedesign: This value is fixed at the + // start of a GC cycle, so during a GC cycle it is safe to + // read without atomics, and it represents the maximum scannable + // heap. heapScan uint64 + // lastHeapScan is the number of bytes of heap that were scanned + // last GC cycle. It is the same as heapMarked, but only + // includes the "scannable" parts of objects. + // + // Updated when the world is stopped. + lastHeapScan uint64 + // stackScan is a snapshot of scannableStackSize taken at each GC // STW pause and is used in pacing decisions. // @@ -179,6 +225,12 @@ type gcControllerState struct { // scannableStackSize is the amount of allocated goroutine stack space in // use by goroutines. // + // This number tracks allocated goroutine stack space rather than used + // goroutine stack space (i.e. what is actually scanned) because used + // goroutine stack space is much harder to measure cheaply. By using + // allocated space, we make an overestimate; this is OK, it's better + // to conservatively overcount than undercount. + // // Read and updated atomically. scannableStackSize uint64 @@ -194,16 +246,26 @@ type gcControllerState struct { // next mark termination. heapMarked uint64 - // scanWork is the total scan work performed this cycle. This - // is updated atomically during the cycle. Updates occur in - // bounded batches, since it is both written and read - // throughout the cycle. At the end of the cycle, this is how + // heapScanWork is the total heap scan work performed this cycle. + // stackScanWork is the total stack scan work performed this cycle. + // globalsScanWork is the total globals scan work performed this cycle. + // + // These are updated atomically during the cycle. Updates occur in + // bounded batches, since they are both written and read + // throughout the cycle. At the end of the cycle, heapScanWork is how // much of the retained heap is scannable. // - // Currently this is the bytes of heap scanned. For most uses, - // this is an opaque unit of work, but for estimation the - // definition is important. - scanWork int64 + // Currently these are measured in bytes. For most uses, this is an + // opaque unit of work, but for estimation the definition is important. + // + // Note that stackScanWork includes all allocated space, not just the + // size of the stack itself, mirroring stackSize. + // + // For !goexperiment.PacerRedesign, stackScanWork and globalsScanWork + // are always zero. + heapScanWork atomic.Int64 + stackScanWork atomic.Int64 + globalsScanWork atomic.Int64 // bgScanCredit is the scan work credit accumulated by the // concurrent background scan. This credit is accumulated by @@ -278,13 +340,39 @@ type gcControllerState struct { func (c *gcControllerState) init(gcPercent int32) { c.heapMinimum = defaultHeapMinimum - // Set a reasonable initial GC trigger. - c.triggerRatio = 7 / 8.0 + if goexperiment.PacerRedesign { + c.consMarkController = piController{ + // Tuned first via the Ziegler-Nichols process in simulation, + // then the integral time was manually tuned against real-world + // applications to deal with noisiness in the measured cons/mark + // ratio. + kp: 0.9, + ti: 4.0, - // Fake a heapMarked value so it looks like a trigger at - // heapMinimum is the appropriate growth from heapMarked. - // This will go into computing the initial GC goal. - c.heapMarked = uint64(float64(c.heapMinimum) / (1 + c.triggerRatio)) + // An update is done once per GC cycle. + period: 1, + + // Set a high reset time in GC cycles. + // This is inversely proportional to the rate at which we + // accumulate error from clipping. By making this very high + // we make the accumulation slow. In general, clipping is + // OK in our situation, hence the choice. + // + // Tune this if we get unintended effects from clipping for + // a long time. + tt: 1000, + min: -1000, + max: 1000, + } + } else { + // Set a reasonable initial GC trigger. + c.triggerRatio = 7 / 8.0 + + // Fake a heapMarked value so it looks like a trigger at + // heapMinimum is the appropriate growth from heapMarked. + // This will go into computing the initial GC goal. + c.heapMarked = uint64(float64(c.heapMinimum) / (1 + c.triggerRatio)) + } // This will also compute and set the GC trigger and goal. c.setGCPercent(gcPercent) @@ -294,7 +382,9 @@ func (c *gcControllerState) init(gcPercent int32) { // for a new GC cycle. The caller must hold worldsema and the world // must be stopped. func (c *gcControllerState) startCycle(markStartTime int64, procs int) { - c.scanWork = 0 + c.heapScanWork.Store(0) + c.stackScanWork.Store(0) + c.globalsScanWork.Store(0) c.bgScanCredit = 0 c.assistTime = 0 c.dedicatedMarkTime = 0 @@ -310,8 +400,14 @@ func (c *gcControllerState) startCycle(markStartTime int64, procs int) { // GOGC. Assist is proportional to this distance, so enforce a // minimum distance, even if it means going over the GOGC goal // by a tiny bit. - if c.heapGoal < c.heapLive+1024*1024 { - c.heapGoal = c.heapLive + 1024*1024 + if goexperiment.PacerRedesign { + if c.heapGoal < c.heapLive+64<<10 { + c.heapGoal = c.heapLive + 64<<10 + } + } else { + if c.heapGoal < c.heapLive+1<<20 { + c.heapGoal = c.heapLive + 1<<20 + } } // Compute the background mark utilization goal. In general, @@ -394,32 +490,79 @@ func (c *gcControllerState) revise() { } live := atomic.Load64(&c.heapLive) scan := atomic.Load64(&c.heapScan) - work := atomic.Loadint64(&c.scanWork) + work := c.heapScanWork.Load() + c.stackScanWork.Load() + c.globalsScanWork.Load() // Assume we're under the soft goal. Pace GC to complete at // heapGoal assuming the heap is in steady-state. heapGoal := int64(atomic.Load64(&c.heapGoal)) - // Compute the expected scan work remaining. - // - // This is estimated based on the expected - // steady-state scannable heap. For example, with - // GOGC=100, only half of the scannable heap is - // expected to be live, so that's what we target. - // - // (This is a float calculation to avoid overflowing on - // 100*heapScan.) - scanWorkExpected := int64(float64(scan) * 100 / float64(100+gcPercent)) + var scanWorkExpected int64 + if goexperiment.PacerRedesign { + // The expected scan work is computed as the amount of bytes scanned last + // GC cycle, plus our estimate of stacks and globals work for this cycle. + scanWorkExpected = int64(c.lastHeapScan + c.stackScan + c.globalsScan) - if int64(live) > heapGoal || work > scanWorkExpected { - // We're past the soft goal, or we've already done more scan - // work than we expected. Pace GC so that in the worst case it - // will complete by the hard goal. - const maxOvershoot = 1.1 - heapGoal = int64(float64(heapGoal) * maxOvershoot) + // maxScanWork is a worst-case estimate of the amount of scan work that + // needs to be performed in this GC cycle. Specifically, it represents + // the case where *all* scannable memory turns out to be live. + maxScanWork := int64(scan + c.stackScan + c.globalsScan) + if work > scanWorkExpected { + // We've already done more scan work than expected. Because our expectation + // is based on a steady-state scannable heap size, we assume this means our + // heap is growing. Compute a new heap goal that takes our existing runway + // computed for scanWorkExpected and extrapolates it to maxScanWork, the worst-case + // scan work. This keeps our assist ratio stable if the heap continues to grow. + // + // The effect of this mechanism is that assists stay flat in the face of heap + // growths. It's OK to use more memory this cycle to scan all the live heap, + // because the next GC cycle is inevitably going to use *at least* that much + // memory anyway. + heapGoal = int64(float64(heapGoal-int64(c.trigger))/float64(scanWorkExpected)*float64(maxScanWork)) + int64(c.trigger) + scanWorkExpected = maxScanWork - // Compute the upper bound on the scan work remaining. - scanWorkExpected = int64(scan) + // hardGoal is a hard limit on the amount that we're willing to push back the + // heap goal, and that's twice the heap goal (i.e. if GOGC=100 and the heap and/or + // stacks and/or globals grow to twice their size, this limits the current GC cycle's + // growth to 4x the original live heap's size). + // + // This maintains the invariant that we use no more memory than the next GC cycle + // will anyway. + hardGoal := int64((1.0 + float64(gcPercent)/100.0) * float64(heapGoal)) + if heapGoal > hardGoal { + heapGoal = hardGoal + } + } + if int64(live) > heapGoal { + // We're already past our heap goal, even the extrapolated one. + // Leave ourselves some extra runway, so in the worst case we + // finish by that point. + const maxOvershoot = 1.1 + heapGoal = int64(float64(heapGoal) * maxOvershoot) + + // Compute the upper bound on the scan work remaining. + scanWorkExpected = maxScanWork + } + } else { + // Compute the expected scan work remaining. + // + // This is estimated based on the expected + // steady-state scannable heap. For example, with + // GOGC=100, only half of the scannable heap is + // expected to be live, so that's what we target. + // + // (This is a float calculation to avoid overflowing on + // 100*heapScan.) + scanWorkExpected = int64(float64(scan) * 100 / float64(100+gcPercent)) + if int64(live) > heapGoal || work > scanWorkExpected { + // We're past the soft goal, or we've already done more scan + // work than we expected. Pace GC so that in the worst case it + // will complete by the hard goal. + const maxOvershoot = 1.1 + heapGoal = int64(float64(heapGoal) * maxOvershoot) + + // Compute the upper bound on the scan work remaining. + scanWorkExpected = int64(scan) + } } // Compute the remaining scan work estimate. @@ -464,7 +607,9 @@ func (c *gcControllerState) revise() { c.assistBytesPerWork.Store(assistBytesPerWork) } -// endCycle computes the trigger ratio for the next cycle. +// endCycle computes the trigger ratio (!goexperiment.PacerRedesign) +// or the consMark estimate (goexperiment.PacerRedesign) for the next cycle. +// Returns the trigger ratio if application, or 0 (goexperiment.PacerRedesign). // userForced indicates whether the current GC cycle was forced // by the application. func (c *gcControllerState) endCycle(now int64, procs int, userForced bool) float64 { @@ -472,6 +617,81 @@ func (c *gcControllerState) endCycle(now int64, procs int, userForced bool) floa // We'll be updating the heap goal soon. gcController.lastHeapGoal = gcController.heapGoal + // Compute the duration of time for which assists were turned on. + assistDuration := now - c.markStartTime + + // Assume background mark hit its utilization goal. + utilization := gcBackgroundUtilization + // Add assist utilization; avoid divide by zero. + if assistDuration > 0 { + utilization += float64(c.assistTime) / float64(assistDuration*int64(procs)) + } + + if goexperiment.PacerRedesign { + if c.heapLive <= c.trigger { + // Shouldn't happen, but let's be very safe about this in case the + // GC is somehow extremely short. + // + // In this case though, the only reasonable value for c.heapLive-c.trigger + // would be 0, which isn't really all that useful, i.e. the GC was so short + // that it didn't matter. + // + // Ignore this case and don't update anything. + return 0 + } + idleUtilization := 0.0 + if assistDuration > 0 { + idleUtilization = float64(c.idleMarkTime) / float64(assistDuration*int64(procs)) + } + // Determine the cons/mark ratio. + // + // The units we want for the numerator and denominator are both B / cpu-ns. + // We get this by taking the bytes allocated or scanned, and divide by the amount of + // CPU time it took for those operations. For allocations, that CPU time is + // + // assistDuration * procs * (1 - utilization) + // + // Where utilization includes just background GC workers and assists. It does *not* + // include idle GC work time, because in theory the mutator is free to take that at + // any point. + // + // For scanning, that CPU time is + // + // assistDuration * procs * (utilization + idleUtilization) + // + // In this case, we *include* idle utilization, because that is additional CPU time that the + // the GC had available to it. + // + // In effect, idle GC time is sort of double-counted here, but it's very weird compared + // to other kinds of GC work, because of how fluid it is. Namely, because the mutator is + // *always* free to take it. + // + // So this calculation is really: + // (heapLive-trigger) / (assistDuration * procs * (1-utilization)) / + // (scanWork) / (assistDuration * procs * (utilization+idleUtilization) + // + // Note that because we only care about the ratio, assistDuration and procs cancel out. + scanWork := c.heapScanWork.Load() + c.stackScanWork.Load() + c.globalsScanWork.Load() + currentConsMark := (float64(c.heapLive-c.trigger) * (utilization + idleUtilization)) / + (float64(scanWork) * (1 - utilization)) + + // Update cons/mark controller. + oldConsMark := c.consMark + c.consMark = c.consMarkController.next(c.consMark, currentConsMark) + + if debug.gcpacertrace > 0 { + printlock() + print("pacer: ", int(utilization*100), "% CPU (", int(gcGoalUtilization*100), " exp.) for ") + print(c.heapScanWork.Load(), "+", c.stackScanWork.Load(), "+", c.globalsScanWork.Load(), " B work (", c.lastHeapScan+c.stackScan+c.globalsScan, " B exp.) ") + print("in ", c.trigger, " B -> ", c.heapLive, " B (∆goal ", int64(c.heapLive)-int64(c.heapGoal), ", cons/mark ", oldConsMark, ")") + println() + printunlock() + } + return 0 + } + + // !goexperiment.PacerRedesign below. + if userForced { // Forced GC means this cycle didn't start at the // trigger, so where it finished isn't good @@ -498,15 +718,6 @@ func (c *gcControllerState) endCycle(now int64, procs int, userForced bool) floa // heap growth is the error. goalGrowthRatio := c.effectiveGrowthRatio() actualGrowthRatio := float64(c.heapLive)/float64(c.heapMarked) - 1 - assistDuration := now - c.markStartTime - - // Assume background mark hit its utilization goal. - utilization := gcBackgroundUtilization - // Add assist utilization; avoid divide by zero. - if assistDuration > 0 { - utilization += float64(c.assistTime) / float64(assistDuration*int64(procs)) - } - triggerError := goalGrowthRatio - c.triggerRatio - utilization/gcGoalUtilization*(actualGrowthRatio-c.triggerRatio) // Finally, we adjust the trigger for next time by this error, @@ -525,7 +736,7 @@ func (c *gcControllerState) endCycle(now int64, procs int, userForced bool) floa H_g := int64(float64(H_m_prev) * (1 + h_g)) u_a := utilization u_g := gcGoalUtilization - W_a := c.scanWork + W_a := c.heapScanWork.Load() print("pacer: H_m_prev=", H_m_prev, " h_t=", h_t, " H_T=", H_T, " h_a=", h_a, " H_a=", H_a, @@ -669,7 +880,8 @@ func (c *gcControllerState) findRunnableGCWorker(_p_ *p) *g { func (c *gcControllerState) resetLive(bytesMarked uint64) { c.heapMarked = bytesMarked c.heapLive = bytesMarked - c.heapScan = uint64(c.scanWork) + c.heapScan = uint64(c.heapScanWork.Load()) + c.lastHeapScan = uint64(c.heapScanWork.Load()) // heapLive was updated, so emit a trace event. if trace.enabled { @@ -703,8 +915,12 @@ func (c *gcControllerState) update(dHeapLive, dHeapScan int64) { traceHeapAlloc() } } - if dHeapScan != 0 { - atomic.Xadd64(&gcController.heapScan, dHeapScan) + // Only update heapScan in the new pacer redesign if we're not + // currently in a GC. + if !goexperiment.PacerRedesign || gcBlackenEnabled == 0 { + if dHeapScan != 0 { + atomic.Xadd64(&gcController.heapScan, dHeapScan) + } } if gcBlackenEnabled != 0 { // gcController.heapLive and heapScan changed. @@ -728,9 +944,10 @@ func (c *gcControllerState) addGlobals(amount int64) { atomic.Xadd64(&c.globalsScan, amount) } -// commit sets the trigger ratio and updates everything -// derived from it: the absolute trigger, the heap goal, mark pacing, -// and sweep pacing. +// commit recomputes all pacing parameters from scratch, namely +// absolute trigger, the heap goal, mark pacing, and sweep pacing. +// +// If goexperiment.PacerRedesign is true, triggerRatio is ignored. // // This can be called any time. If GC is the in the middle of a // concurrent phase, it will adjust the pacing of that phase. @@ -744,6 +961,130 @@ func (c *gcControllerState) commit(triggerRatio float64) { assertWorldStoppedOrLockHeld(&mheap_.lock) } + if !goexperiment.PacerRedesign { + c.oldCommit(triggerRatio) + return + } + + // Compute the next GC goal, which is when the allocated heap + // has grown by GOGC/100 over where it started the last cycle, + // plus additional runway for non-heap sources of GC work. + goal := ^uint64(0) + if c.gcPercent >= 0 { + goal = c.heapMarked + (c.heapMarked+atomic.Load64(&c.stackScan)+atomic.Load64(&c.globalsScan))*uint64(c.gcPercent)/100 + } + + // Don't trigger below the minimum heap size. + minTrigger := c.heapMinimum + if !isSweepDone() { + // Concurrent sweep happens in the heap growth + // from gcController.heapLive to trigger, so ensure + // that concurrent sweep has some heap growth + // in which to perform sweeping before we + // start the next GC cycle. + sweepMin := atomic.Load64(&c.heapLive) + sweepMinHeapDistance + if sweepMin > minTrigger { + minTrigger = sweepMin + } + } + + // If we let the trigger go too low, then if the application + // is allocating very rapidly we might end up in a situation + // where we're allocating black during a nearly always-on GC. + // The result of this is a growing heap and ultimately an + // increase in RSS. By capping us at a point >0, we're essentially + // saying that we're OK using more CPU during the GC to prevent + // this growth in RSS. + // + // The current constant was chosen empirically: given a sufficiently + // fast/scalable allocator with 48 Ps that could drive the trigger ratio + // to <0.05, this constant causes applications to retain the same peak + // RSS compared to not having this allocator. + if triggerBound := uint64(0.7*float64(goal-c.heapMarked)) + c.heapMarked; minTrigger < triggerBound { + minTrigger = triggerBound + } + + // For small heaps, set the max trigger point at 95% of the heap goal. + // This ensures we always have *some* headroom when the GC actually starts. + // For larger heaps, set the max trigger point at the goal, minus the + // minimum heap size. + // This choice follows from the fact that the minimum heap size is chosen + // to reflect the costs of a GC with no work to do. With a large heap but + // very little scan work to perform, this gives us exactly as much runway + // as we would need, in the worst case. + maxRunway := uint64(0.95 * float64(goal-c.heapMarked)) + if largeHeapMaxRunway := goal - c.heapMinimum; goal > c.heapMinimum && maxRunway < largeHeapMaxRunway { + maxRunway = largeHeapMaxRunway + } + maxTrigger := maxRunway + c.heapMarked + if maxTrigger < minTrigger { + maxTrigger = minTrigger + } + + // Compute the trigger by using our estimate of the cons/mark ratio. + // + // The idea is to take our expected scan work, and multiply it by + // the cons/mark ratio to determine how long it'll take to complete + // that scan work in terms of bytes allocated. This gives us our GC's + // runway. + // + // However, the cons/mark ratio is a ratio of rates per CPU-second, but + // here we care about the relative rates for some division of CPU + // resources among the mutator and the GC. + // + // To summarize, we have B / cpu-ns, and we want B / ns. We get that + // by multiplying by our desired division of CPU resources. We choose + // to express CPU resources as GOMAPROCS*fraction. Note that because + // we're working with a ratio here, we can omit the number of CPU cores, + // because they'll appear in the numerator and denominator and cancel out. + // As a result, this is basically just "weighing" the cons/mark ratio by + // our desired division of resources. + // + // Furthermore, by setting the trigger so that CPU resources are divided + // this way, assuming that the cons/mark ratio is correct, we make that + // division a reality. + var trigger uint64 + runway := uint64((c.consMark * (1 - gcGoalUtilization) / (gcGoalUtilization)) * float64(c.lastHeapScan+c.stackScan+c.globalsScan)) + if runway > goal { + trigger = minTrigger + } else { + trigger = goal - runway + } + if trigger < minTrigger { + trigger = minTrigger + } + if trigger > maxTrigger { + trigger = maxTrigger + } + if trigger > goal { + goal = trigger + } + + // Commit to the trigger and goal. + c.trigger = trigger + atomic.Store64(&c.heapGoal, goal) + if trace.enabled { + traceHeapGoal() + } + + // Update mark pacing. + if gcphase != _GCoff { + c.revise() + } +} + +// oldCommit sets the trigger ratio and updates everything +// derived from it: the absolute trigger, the heap goal, mark pacing, +// and sweep pacing. +// +// This can be called any time. If GC is the in the middle of a +// concurrent phase, it will adjust the pacing of that phase. +// +// This depends on gcPercent, gcController.heapMarked, and +// gcController.heapLive. These must be up to date. +// +// For !goexperiment.PacerRedesign. +func (c *gcControllerState) oldCommit(triggerRatio float64) { // Compute the next GC goal, which is when the allocated heap // has grown by GOGC/100 over the heap marked by the last // cycle. @@ -913,3 +1254,38 @@ func readGOGC() int32 { } return 100 } + +type piController struct { + kp float64 // Proportional constant. + ti float64 // Integral time constant. + tt float64 // Reset time in GC cyles. + + // Period in GC cycles between updates. + period float64 + + min, max float64 // Output boundaries. + + // PI controller state. + + errIntegral float64 // Integral of the error from t=0 to now. +} + +func (c *piController) next(input, setpoint float64) float64 { + // Compute the raw output value. + prop := c.kp * (setpoint - input) + rawOutput := prop + c.errIntegral + + // Clamp rawOutput into output. + output := rawOutput + if output < c.min { + output = c.min + } else if output > c.max { + output = c.max + } + + // Update the controller's state. + if c.ti != 0 && c.tt != 0 { + c.errIntegral += (c.kp*c.period/c.ti)*(setpoint-input) + (c.period/c.tt)*(output-rawOutput) + } + return output +} diff --git a/src/runtime/mgcpacer_test.go b/src/runtime/mgcpacer_test.go index 5a9f46c6d1..d2707ca5a1 100644 --- a/src/runtime/mgcpacer_test.go +++ b/src/runtime/mgcpacer_test.go @@ -6,6 +6,7 @@ package runtime_test import ( "fmt" + "internal/goexperiment" "math" "math/rand" . "runtime" @@ -34,12 +35,76 @@ func TestGcPacer(t *testing.T) { checker: func(t *testing.T, c []gcCycleResult) { n := len(c) if n >= 25 { + if goexperiment.PacerRedesign { + // For the pacer redesign, assert something even stronger: at this alloc/scan rate, + // it should be extremely close to the goal utilization. + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, GCGoalUtilization, 0.005) + } + // Make sure the pacer settles into a non-degenerate state in at least 25 GC cycles. assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[n-2].gcUtilization, 0.005) assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.95, 1.05) } }, }, + { + // Same as the steady-state case, but lots of stacks to scan relative to the heap size. + name: "SteadyBigStacks", + gcPercent: 100, + globalsBytes: 32 << 10, + nCores: 8, + allocRate: constant(132.0), + scanRate: constant(1024.0), + growthRate: constant(2.0).sum(ramp(-1.0, 12)), + scannableFrac: constant(1.0), + stackBytes: constant(2048).sum(ramp(128<<20, 8)), + length: 50, + checker: func(t *testing.T, c []gcCycleResult) { + // Check the same conditions as the steady-state case, except the old pacer can't + // really handle this well, so don't check the goal ratio for it. + n := len(c) + if n >= 25 { + if goexperiment.PacerRedesign { + // For the pacer redesign, assert something even stronger: at this alloc/scan rate, + // it should be extremely close to the goal utilization. + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, GCGoalUtilization, 0.005) + assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.95, 1.05) + } + + // Make sure the pacer settles into a non-degenerate state in at least 25 GC cycles. + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[n-2].gcUtilization, 0.005) + } + }, + }, + { + // Same as the steady-state case, but lots of globals to scan relative to the heap size. + name: "SteadyBigGlobals", + gcPercent: 100, + globalsBytes: 128 << 20, + nCores: 8, + allocRate: constant(132.0), + scanRate: constant(1024.0), + growthRate: constant(2.0).sum(ramp(-1.0, 12)), + scannableFrac: constant(1.0), + stackBytes: constant(8192), + length: 50, + checker: func(t *testing.T, c []gcCycleResult) { + // Check the same conditions as the steady-state case, except the old pacer can't + // really handle this well, so don't check the goal ratio for it. + n := len(c) + if n >= 25 { + if goexperiment.PacerRedesign { + // For the pacer redesign, assert something even stronger: at this alloc/scan rate, + // it should be extremely close to the goal utilization. + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, GCGoalUtilization, 0.005) + assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.95, 1.05) + } + + // Make sure the pacer settles into a non-degenerate state in at least 25 GC cycles. + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[n-2].gcUtilization, 0.005) + } + }, + }, { // This tests the GC pacer's response to a small change in allocation rate. name: "StepAlloc", @@ -106,6 +171,47 @@ func TestGcPacer(t *testing.T) { } }, }, + { + // Tests the pacer for a high GOGC value with a large heap growth happening + // in the middle. The purpose of the large heap growth is to check if GC + // utilization ends up sensitive + name: "HighGOGC", + gcPercent: 1500, + globalsBytes: 32 << 10, + nCores: 8, + allocRate: random(7, 0x53).offset(165), + scanRate: constant(1024.0), + growthRate: constant(2.0).sum(ramp(-1.0, 12), random(0.01, 0x1), unit(14).delay(25)), + scannableFrac: constant(1.0), + stackBytes: constant(8192), + length: 50, + checker: func(t *testing.T, c []gcCycleResult) { + n := len(c) + if goexperiment.PacerRedesign && n > 12 { + if n == 26 { + // In the 26th cycle there's a heap growth. Overshoot is expected to maintain + // a stable utilization, but we should *never* overshoot more than GOGC of + // the next cycle. + assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.90, 15) + } else { + // Give a wider goal range here. With such a high GOGC value we're going to be + // forced to undershoot. + // + // TODO(mknyszek): Instead of placing a 0.95 limit on the trigger, make the limit + // based on absolute bytes, that's based somewhat in how the minimum heap size + // is determined. + assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.90, 1.05) + } + + // Ensure utilization remains stable despite a growth in live heap size + // at GC #25. This test fails prior to the GC pacer redesign. + // + // Because GOGC is so large, we should also be really close to the goal utilization. + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, GCGoalUtilization, GCGoalUtilization+0.03) + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[n-2].gcUtilization, 0.03) + } + }, + }, { // This test makes sure that in the face of a varying (in this case, oscillating) allocation // rate, the pacer does a reasonably good job of staying abreast of the changes. @@ -126,7 +232,12 @@ func TestGcPacer(t *testing.T) { // 1. Utilization isn't varying _too_ much, and // 2. The pacer is mostly keeping up with the goal. assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.95, 1.05) - assertInRange(t, "GC utilization", c[n-1].gcUtilization, 0.25, 0.4) + if goexperiment.PacerRedesign { + assertInRange(t, "GC utilization", c[n-1].gcUtilization, 0.25, 0.3) + } else { + // The old pacer is messier here, and needs a lot more tolerance. + assertInRange(t, "GC utilization", c[n-1].gcUtilization, 0.25, 0.4) + } } }, }, @@ -149,7 +260,12 @@ func TestGcPacer(t *testing.T) { // 1. Utilization isn't varying _too_ much, and // 2. The pacer is mostly keeping up with the goal. assertInRange(t, "goal ratio", c[n-1].goalRatio(), 0.95, 1.05) - assertInRange(t, "GC utilization", c[n-1].gcUtilization, 0.25, 0.4) + if goexperiment.PacerRedesign { + assertInRange(t, "GC utilization", c[n-1].gcUtilization, 0.25, 0.3) + } else { + // The old pacer is messier here, and needs a lot more tolerance. + assertInRange(t, "GC utilization", c[n-1].gcUtilization, 0.25, 0.4) + } } }, }, @@ -177,7 +293,12 @@ func TestGcPacer(t *testing.T) { // Unlike the other tests, GC utilization here will vary more and tend higher. // Just make sure it's not going too crazy. assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[n-2].gcUtilization, 0.05) - assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[11].gcUtilization, 0.07) + if goexperiment.PacerRedesign { + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[11].gcUtilization, 0.05) + } else { + // The old pacer is messier here, and needs a little more tolerance. + assertInEpsilon(t, "GC utilization", c[n-1].gcUtilization, c[11].gcUtilization, 0.07) + } } }, }, diff --git a/src/runtime/mgcwork.go b/src/runtime/mgcwork.go index 8787d93d87..9c3f7fd223 100644 --- a/src/runtime/mgcwork.go +++ b/src/runtime/mgcwork.go @@ -77,9 +77,10 @@ type gcWork struct { // into work.bytesMarked by dispose. bytesMarked uint64 - // Scan work performed on this gcWork. This is aggregated into + // Heap scan work performed on this gcWork. This is aggregated into // gcController by dispose and may also be flushed by callers. - scanWork int64 + // Other types of scan work are flushed immediately. + heapScanWork int64 // flushedWork indicates that a non-empty work buffer was // flushed to the global work list since the last gcMarkDone @@ -274,9 +275,9 @@ func (w *gcWork) dispose() { atomic.Xadd64(&work.bytesMarked, int64(w.bytesMarked)) w.bytesMarked = 0 } - if w.scanWork != 0 { - atomic.Xaddint64(&gcController.scanWork, w.scanWork) - w.scanWork = 0 + if w.heapScanWork != 0 { + gcController.heapScanWork.Add(w.heapScanWork) + w.heapScanWork = 0 } } From 961aab26bffece299f1528b44d260ea0a921ac56 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 25 Oct 2021 21:43:27 +0000 Subject: [PATCH 377/406] internal/buildcfg: enable the pacer redesign by default Change-Id: Ifb90d5482cb0cedee6cb4d6297853ac7913d14ee Reviewed-on: https://go-review.googlesource.com/c/go/+/358674 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/internal/buildcfg/exp.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/internal/buildcfg/exp.go b/src/internal/buildcfg/exp.go index 043d079cf6..a9b29d6718 100644 --- a/src/internal/buildcfg/exp.go +++ b/src/internal/buildcfg/exp.go @@ -56,6 +56,7 @@ func ParseGOEXPERIMENT(goos, goarch, goexp string) (flags, baseline goexperiment RegabiWrappers: regabiSupported, RegabiReflect: regabiSupported, RegabiArgs: regabiSupported, + PacerRedesign: true, } // Start with the statically enabled set of experiments. From 9b2dd1f7714b38f1bfe25676357b62c1bb4cad64 Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Wed, 3 Nov 2021 14:44:16 -0400 Subject: [PATCH 378/406] internal/fuzz: fix internal error handling This doesn't handle every possible scenario, but improves the one we can control. For example, if the worker panics for some reason, we have no way of knowing whether the panic occurred in an expected way (while executing the fuzz target) or due to an internal error in the worker. So any panic will still be treated as a crash. However, if it fails due to some internal bug that we know how to catch, then the error should be reported to the user without a new crasher being written to testdata. This is very difficult to test. The reasons an internal error would occur is because something went very wrong, and we have a bug in our code (which is why they were previously panics). So simulating a problem like this in a test is not really feasible. Fixes #48804 Change-Id: I334618f84eb4a994a8d17419551a510b1fdef071 Reviewed-on: https://go-review.googlesource.com/c/go/+/361115 Trust: Katie Hockman Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills Reviewed-by: Roland Shoemaker --- src/internal/fuzz/worker.go | 47 ++++++++++++++++++-------------- src/internal/fuzz/worker_test.go | 2 +- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/internal/fuzz/worker.go b/src/internal/fuzz/worker.go index 388675f713..02efa7f84a 100644 --- a/src/internal/fuzz/worker.go +++ b/src/internal/fuzz/worker.go @@ -153,7 +153,7 @@ func (w *worker) coordinate(ctx context.Context) error { Warmup: input.warmup, CoverageData: input.coverageData, } - entry, resp, err := w.client.fuzz(ctx, input.entry, args) + entry, resp, isInternalError, err := w.client.fuzz(ctx, input.entry, args) canMinimize := true if err != nil { // Error communicating with worker. @@ -167,14 +167,6 @@ func (w *worker) coordinate(ctx context.Context) error { // Report an error, but don't record a crasher. return fmt.Errorf("communicating with fuzzing process: %v", err) } - if w.waitErr == nil || isInterruptError(w.waitErr) { - // Worker stopped, either by exiting with status 0 or after being - // interrupted with a signal (not sent by coordinator). See comment in - // termC case above. - // - // Since we expect I/O errors around interrupts, ignore this error. - return nil - } if sig, ok := terminationSignal(w.waitErr); ok && !isCrashSignal(sig) { // Worker terminated by a signal that probably wasn't caused by a // specific input to the fuzz function. For example, on Linux, @@ -183,6 +175,11 @@ func (w *worker) coordinate(ctx context.Context) error { // is closed. Don't record a crasher. return fmt.Errorf("fuzzing process terminated by unexpected signal; no crash will be recorded: %v", w.waitErr) } + if isInternalError { + // An internal error occurred which shouldn't be considered + // a crash. + return err + } // Unexpected termination. Set error message and fall through. // We'll restart the worker on the next iteration. // Don't attempt to minimize this since it crashed the worker. @@ -567,6 +564,10 @@ type fuzzResponse struct { // Err is the error string caused by the value in shared memory, which is // non-empty if the value in shared memory caused a crash. Err string + + // InternalErr is the error string caused by an internal error in the + // worker. This shouldn't be considered a crasher. + InternalErr string } // pingArgs contains arguments to workerServer.ping. @@ -663,7 +664,8 @@ func (ws *workerServer) serve(ctx context.Context) error { func (ws *workerServer) fuzz(ctx context.Context, args fuzzArgs) (resp fuzzResponse) { if args.CoverageData != nil { if ws.coverageMask != nil && len(args.CoverageData) != len(ws.coverageMask) { - panic(fmt.Sprintf("unexpected size for CoverageData: got %d, expected %d", len(args.CoverageData), len(ws.coverageMask))) + resp.InternalErr = fmt.Sprintf("unexpected size for CoverageData: got %d, expected %d", len(args.CoverageData), len(ws.coverageMask)) + return resp } ws.coverageMask = args.CoverageData } @@ -682,12 +684,14 @@ func (ws *workerServer) fuzz(ctx context.Context, args fuzzArgs) (resp fuzzRespo ws.memMu <- mem }() if args.Limit > 0 && mem.header().count >= args.Limit { - panic(fmt.Sprintf("mem.header().count %d already exceeds args.Limit %d", mem.header().count, args.Limit)) + resp.InternalErr = fmt.Sprintf("mem.header().count %d already exceeds args.Limit %d", mem.header().count, args.Limit) + return resp } vals, err := unmarshalCorpusFile(mem.valueCopy()) if err != nil { - panic(err) + resp.InternalErr = err.Error() + return resp } shouldStop := func() bool { @@ -1027,7 +1031,7 @@ func (wc *workerClient) minimize(ctx context.Context, entryIn CorpusEntry, args entryOut.Parent = entryIn.Parent entryOut.Generation = entryIn.Generation if err != nil { - panic(fmt.Sprintf("workerClient.minimize unmarshaling minimized value: %v", err)) + return CorpusEntry{}, minimizeResponse{}, fmt.Errorf("workerClient.minimize unmarshaling minimized value: %v", err) } } else { // Did not minimize, but the original input may still be interesting, @@ -1039,40 +1043,43 @@ func (wc *workerClient) minimize(ctx context.Context, entryIn CorpusEntry, args } // fuzz tells the worker to call the fuzz method. See workerServer.fuzz. -func (wc *workerClient) fuzz(ctx context.Context, entryIn CorpusEntry, args fuzzArgs) (entryOut CorpusEntry, resp fuzzResponse, err error) { +func (wc *workerClient) fuzz(ctx context.Context, entryIn CorpusEntry, args fuzzArgs) (entryOut CorpusEntry, resp fuzzResponse, isInternalError bool, err error) { wc.mu.Lock() defer wc.mu.Unlock() mem, ok := <-wc.memMu if !ok { - return CorpusEntry{}, fuzzResponse{}, errSharedMemClosed + return CorpusEntry{}, fuzzResponse{}, true, errSharedMemClosed } mem.header().count = 0 inp, err := CorpusEntryData(entryIn) if err != nil { - return CorpusEntry{}, fuzzResponse{}, err + return CorpusEntry{}, fuzzResponse{}, true, err } mem.setValue(inp) wc.memMu <- mem c := call{Fuzz: &args} callErr := wc.callLocked(ctx, c, &resp) + if resp.InternalErr != "" { + return CorpusEntry{}, fuzzResponse{}, true, errors.New(resp.InternalErr) + } mem, ok = <-wc.memMu if !ok { - return CorpusEntry{}, fuzzResponse{}, errSharedMemClosed + return CorpusEntry{}, fuzzResponse{}, true, errSharedMemClosed } defer func() { wc.memMu <- mem }() resp.Count = mem.header().count if !bytes.Equal(inp, mem.valueRef()) { - panic("workerServer.fuzz modified input") + return CorpusEntry{}, fuzzResponse{}, true, errors.New("workerServer.fuzz modified input") } needEntryOut := callErr != nil || resp.Err != "" || (!args.Warmup && resp.CoverageData != nil) if needEntryOut { valuesOut, err := unmarshalCorpusFile(inp) if err != nil { - panic(fmt.Sprintf("unmarshaling fuzz input value after call: %v", err)) + return CorpusEntry{}, fuzzResponse{}, true, fmt.Errorf("unmarshaling fuzz input value after call: %v", err) } wc.m.r.restore(mem.header().randState, mem.header().randInc) if !args.Warmup { @@ -1098,7 +1105,7 @@ func (wc *workerClient) fuzz(ctx context.Context, entryIn CorpusEntry, args fuzz } } - return entryOut, resp, callErr + return entryOut, resp, false, callErr } // ping tells the worker to call the ping method. See workerServer.ping. diff --git a/src/internal/fuzz/worker_test.go b/src/internal/fuzz/worker_test.go index e32770b02b..c6f83fd08d 100644 --- a/src/internal/fuzz/worker_test.go +++ b/src/internal/fuzz/worker_test.go @@ -96,7 +96,7 @@ func BenchmarkWorkerFuzz(b *testing.B) { Limit: int64(b.N) - i, Timeout: workerFuzzDuration, } - _, resp, err := w.client.fuzz(context.Background(), entry, args) + _, resp, _, err := w.client.fuzz(context.Background(), entry, args) if err != nil { b.Fatal(err) } From fc5e8cd6c9de00f8d7da645343934c548e62223e Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 4 Oct 2021 19:52:48 +0000 Subject: [PATCH 379/406] runtime: update and access scavengeGoal atomically The first step toward acquiring the heap lock less frequently in the scavenger. Change-Id: Idc69fd8602be2c83268c155951230d60e20b42fe Reviewed-on: https://go-review.googlesource.com/c/go/+/353973 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/runtime/mgcscavenge.go | 8 ++++---- src/runtime/mheap.go | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/runtime/mgcscavenge.go b/src/runtime/mgcscavenge.go index fb9b5c8694..4edeb8739e 100644 --- a/src/runtime/mgcscavenge.go +++ b/src/runtime/mgcscavenge.go @@ -125,7 +125,7 @@ func gcPaceScavenger(heapGoal, lastHeapGoal uint64) { // information about the heap yet) so this is fine, and avoids a fault // or garbage data later. if lastHeapGoal == 0 { - mheap_.scavengeGoal = ^uint64(0) + atomic.Store64(&mheap_.scavengeGoal, ^uint64(0)) return } // Compute our scavenging goal. @@ -157,10 +157,10 @@ func gcPaceScavenger(heapGoal, lastHeapGoal uint64) { // the background scavenger. We disable the background scavenger if there's // less than one physical page of work to do because it's not worth it. if retainedNow <= retainedGoal || retainedNow-retainedGoal < uint64(physPageSize) { - mheap_.scavengeGoal = ^uint64(0) + atomic.Store64(&mheap_.scavengeGoal, ^uint64(0)) return } - mheap_.scavengeGoal = retainedGoal + atomic.Store64(&mheap_.scavengeGoal, retainedGoal) } // Sleep/wait state of the background scavenger. @@ -299,7 +299,7 @@ func bgscavenge(c chan int) { lock(&mheap_.lock) // If background scavenging is disabled or if there's no work to do just park. - retained, goal := heapRetained(), mheap_.scavengeGoal + retained, goal := heapRetained(), atomic.Load64(&mheap_.scavengeGoal) if retained <= goal { unlock(&mheap_.lock) return diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index 057ab06b1d..f2f6e7f4cf 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -111,6 +111,8 @@ type mheap struct { // scavengeGoal is the amount of total retained heap memory (measured by // heapRetained) that the runtime will try to maintain by returning memory // to the OS. + // + // Accessed atomically. scavengeGoal uint64 // Page reclaimer state @@ -1399,9 +1401,10 @@ func (h *mheap) grow(npage uintptr) bool { // By scavenging inline we deal with the failure to allocate out of // memory fragments by scavenging the memory fragments that are least // likely to be re-used. - if retained := heapRetained(); retained+uint64(totalGrowth) > h.scavengeGoal { + scavengeGoal := atomic.Load64(&h.scavengeGoal) + if retained := heapRetained(); retained+uint64(totalGrowth) > scavengeGoal { todo := totalGrowth - if overage := uintptr(retained + uint64(totalGrowth) - h.scavengeGoal); todo > overage { + if overage := uintptr(retained + uint64(totalGrowth) - scavengeGoal); todo > overage { todo = overage } h.pages.scavenge(todo, false) From 6d1fffac6388d965616520eb23f36885760d5b66 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 18 Oct 2021 18:22:02 +0000 Subject: [PATCH 380/406] runtime: set and clear only the relevant bits in allocToCache Currently allocToCache ham-handedly calls pageAlloc.allocRange on the full size of the cache. This is fine as long as scavenged bits are never set when alloc bits are set. This is true right now, but won't be true as of the next CL. This change makes allocToCache more carefully set the bits. Note that in the allocToCache path, we were also calling update *twice*, erroneously. The first time, with contig=true! Luckily today there's no correctness error there because the page cache is small enough that the contig=true logic doesn't matter, but this should at least improve allocation performance a little bit. Change-Id: I3ff9590ac86d251e4c5063cfd633570238b0cdbf Reviewed-on: https://go-review.googlesource.com/c/go/+/356609 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/runtime/mpagecache.go | 12 ++++-- src/runtime/mpagecache_test.go | 68 ++++++++++++++++++++++------------ src/runtime/mpallocbits.go | 18 +++++++++ 3 files changed, 71 insertions(+), 27 deletions(-) diff --git a/src/runtime/mpagecache.go b/src/runtime/mpagecache.go index 4b5c66d8d6..7206e2dbdb 100644 --- a/src/runtime/mpagecache.go +++ b/src/runtime/mpagecache.go @@ -123,9 +123,10 @@ func (p *pageAlloc) allocToCache() pageCache { } c := pageCache{} ci := chunkIndex(p.searchAddr.addr()) // chunk index + var chunk *pallocData if p.summary[len(p.summary)-1][ci] != 0 { // Fast path: there's free pages at or near the searchAddr address. - chunk := p.chunkOf(ci) + chunk = p.chunkOf(ci) j, _ := chunk.find(1, chunkPageIndex(p.searchAddr.addr())) if j == ^uint(0) { throw("bad summary data") @@ -146,7 +147,7 @@ func (p *pageAlloc) allocToCache() pageCache { return pageCache{} } ci := chunkIndex(addr) - chunk := p.chunkOf(ci) + chunk = p.chunkOf(ci) c = pageCache{ base: alignDown(addr, 64*pageSize), cache: ^chunk.pages64(chunkPageIndex(addr)), @@ -154,8 +155,11 @@ func (p *pageAlloc) allocToCache() pageCache { } } - // Set the bits as allocated and clear the scavenged bits. - p.allocRange(c.base, pageCachePages) + // Set the page bits as allocated and clear the scavenged bits, but + // be careful to only set and clear the relevant bits. + cpi := chunkPageIndex(c.base) + chunk.allocPages64(cpi, c.cache) + chunk.scavenged.clearBlock64(cpi, c.cache&c.scav /* free and scavenged */) // Update as an allocation, but note that it's not contiguous. p.update(c.base, pageCachePages, false, true) diff --git a/src/runtime/mpagecache_test.go b/src/runtime/mpagecache_test.go index 2ed0c0aa6a..69084f9a84 100644 --- a/src/runtime/mpagecache_test.go +++ b/src/runtime/mpagecache_test.go @@ -261,17 +261,18 @@ func TestPageAllocAllocToCache(t *testing.T) { t.Skip("skipping because virtual memory is limited; see #36210") } type test struct { - before map[ChunkIdx][]BitRange - scav map[ChunkIdx][]BitRange - hits []PageCache // expected base addresses and patterns - after map[ChunkIdx][]BitRange + beforeAlloc map[ChunkIdx][]BitRange + beforeScav map[ChunkIdx][]BitRange + hits []PageCache // expected base addresses and patterns + afterAlloc map[ChunkIdx][]BitRange + afterScav map[ChunkIdx][]BitRange } tests := map[string]test{ "AllFree": { - before: map[ChunkIdx][]BitRange{ + beforeAlloc: map[ChunkIdx][]BitRange{ BaseChunkIdx: {}, }, - scav: map[ChunkIdx][]BitRange{ + beforeScav: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{1, 1}, {64, 64}}, }, hits: []PageCache{ @@ -280,17 +281,17 @@ func TestPageAllocAllocToCache(t *testing.T) { NewPageCache(PageBase(BaseChunkIdx, 128), ^uint64(0), 0), NewPageCache(PageBase(BaseChunkIdx, 192), ^uint64(0), 0), }, - after: map[ChunkIdx][]BitRange{ + afterAlloc: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{0, 256}}, }, }, "ManyArena": { - before: map[ChunkIdx][]BitRange{ + beforeAlloc: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{0, PallocChunkPages}}, BaseChunkIdx + 1: {{0, PallocChunkPages}}, BaseChunkIdx + 2: {{0, PallocChunkPages - 64}}, }, - scav: map[ChunkIdx][]BitRange{ + beforeScav: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{0, PallocChunkPages}}, BaseChunkIdx + 1: {{0, PallocChunkPages}}, BaseChunkIdx + 2: {}, @@ -298,46 +299,50 @@ func TestPageAllocAllocToCache(t *testing.T) { hits: []PageCache{ NewPageCache(PageBase(BaseChunkIdx+2, PallocChunkPages-64), ^uint64(0), 0), }, - after: map[ChunkIdx][]BitRange{ + afterAlloc: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{0, PallocChunkPages}}, BaseChunkIdx + 1: {{0, PallocChunkPages}}, BaseChunkIdx + 2: {{0, PallocChunkPages}}, }, }, "NotContiguous": { - before: map[ChunkIdx][]BitRange{ + beforeAlloc: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{0, PallocChunkPages}}, BaseChunkIdx + 0xff: {{0, 0}}, }, - scav: map[ChunkIdx][]BitRange{ + beforeScav: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{0, PallocChunkPages}}, BaseChunkIdx + 0xff: {{31, 67}}, }, hits: []PageCache{ NewPageCache(PageBase(BaseChunkIdx+0xff, 0), ^uint64(0), ((uint64(1)<<33)-1)<<31), }, - after: map[ChunkIdx][]BitRange{ + afterAlloc: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{0, PallocChunkPages}}, BaseChunkIdx + 0xff: {{0, 64}}, }, + afterScav: map[ChunkIdx][]BitRange{ + BaseChunkIdx: {{0, PallocChunkPages}}, + BaseChunkIdx + 0xff: {{64, 34}}, + }, }, "First": { - before: map[ChunkIdx][]BitRange{ + beforeAlloc: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{0, 32}, {33, 31}, {96, 32}}, }, - scav: map[ChunkIdx][]BitRange{ + beforeScav: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{1, 4}, {31, 5}, {66, 2}}, }, hits: []PageCache{ NewPageCache(PageBase(BaseChunkIdx, 0), 1<<32, 1<<32), NewPageCache(PageBase(BaseChunkIdx, 64), (uint64(1)<<32)-1, 0x3<<2), }, - after: map[ChunkIdx][]BitRange{ + afterAlloc: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{0, 128}}, }, }, "Fail": { - before: map[ChunkIdx][]BitRange{ + beforeAlloc: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{0, PallocChunkPages}}, }, hits: []PageCache{ @@ -345,10 +350,27 @@ func TestPageAllocAllocToCache(t *testing.T) { NewPageCache(0, 0, 0), NewPageCache(0, 0, 0), }, - after: map[ChunkIdx][]BitRange{ + afterAlloc: map[ChunkIdx][]BitRange{ BaseChunkIdx: {{0, PallocChunkPages}}, }, }, + "RetainScavBits": { + beforeAlloc: map[ChunkIdx][]BitRange{ + BaseChunkIdx: {{0, 1}, {10, 2}}, + }, + beforeScav: map[ChunkIdx][]BitRange{ + BaseChunkIdx: {{0, 4}, {11, 1}}, + }, + hits: []PageCache{ + NewPageCache(PageBase(BaseChunkIdx, 0), ^uint64(0x1|(0x3<<10)), 0x7<<1), + }, + afterAlloc: map[ChunkIdx][]BitRange{ + BaseChunkIdx: {{0, 64}}, + }, + afterScav: map[ChunkIdx][]BitRange{ + BaseChunkIdx: {{0, 1}, {11, 1}}, + }, + }, } if PageAlloc64Bit != 0 { const chunkIdxBigJump = 0x100000 // chunk index offset which translates to O(TiB) @@ -359,11 +381,11 @@ func TestPageAllocAllocToCache(t *testing.T) { sumsPerPhysPage := ChunkIdx(PhysPageSize / PallocSumBytes) baseChunkIdx := BaseChunkIdx &^ (sumsPerPhysPage - 1) tests["DiscontiguousMappedSumBoundary"] = test{ - before: map[ChunkIdx][]BitRange{ + beforeAlloc: map[ChunkIdx][]BitRange{ baseChunkIdx + sumsPerPhysPage - 1: {{0, PallocChunkPages - 1}}, baseChunkIdx + chunkIdxBigJump: {{1, PallocChunkPages - 1}}, }, - scav: map[ChunkIdx][]BitRange{ + beforeScav: map[ChunkIdx][]BitRange{ baseChunkIdx + sumsPerPhysPage - 1: {}, baseChunkIdx + chunkIdxBigJump: {}, }, @@ -372,7 +394,7 @@ func TestPageAllocAllocToCache(t *testing.T) { NewPageCache(PageBase(baseChunkIdx+chunkIdxBigJump, 0), 1, 0), NewPageCache(0, 0, 0), }, - after: map[ChunkIdx][]BitRange{ + afterAlloc: map[ChunkIdx][]BitRange{ baseChunkIdx + sumsPerPhysPage - 1: {{0, PallocChunkPages}}, baseChunkIdx + chunkIdxBigJump: {{0, PallocChunkPages}}, }, @@ -381,7 +403,7 @@ func TestPageAllocAllocToCache(t *testing.T) { for name, v := range tests { v := v t.Run(name, func(t *testing.T) { - b := NewPageAlloc(v.before, v.scav) + b := NewPageAlloc(v.beforeAlloc, v.beforeScav) defer FreePageAlloc(b) for _, expect := range v.hits { @@ -390,7 +412,7 @@ func TestPageAllocAllocToCache(t *testing.T) { return } } - want := NewPageAlloc(v.after, v.scav) + want := NewPageAlloc(v.afterAlloc, v.afterScav) defer FreePageAlloc(want) checkPageAlloc(t, want, b) diff --git a/src/runtime/mpallocbits.go b/src/runtime/mpallocbits.go index ff112300c3..f63164becd 100644 --- a/src/runtime/mpallocbits.go +++ b/src/runtime/mpallocbits.go @@ -57,6 +57,12 @@ func (b *pageBits) setAll() { } } +// setBlock64 sets the 64-bit aligned block of bits containing the i'th bit that +// are set in v. +func (b *pageBits) setBlock64(i uint, v uint64) { + b[i/64] |= v +} + // clear clears bit i of pageBits. func (b *pageBits) clear(i uint) { b[i/64] &^= 1 << (i % 64) @@ -93,6 +99,12 @@ func (b *pageBits) clearAll() { } } +// clearBlock64 clears the 64-bit aligned block of bits containing the i'th bit that +// are set in v. +func (b *pageBits) clearBlock64(i uint, v uint64) { + b[i/64] &^= v +} + // popcntRange counts the number of set bits in the // range [i, i+n). func (b *pageBits) popcntRange(i, n uint) (s uint) { @@ -367,6 +379,12 @@ func (b *pallocBits) pages64(i uint) uint64 { return (*pageBits)(b).block64(i) } +// allocPages64 allocates a 64-bit block of 64 pages aligned to 64 pages according +// to the bits set in alloc. The block set is the one containing the i'th page. +func (b *pallocBits) allocPages64(i uint, alloc uint64) { + (*pageBits)(b).setBlock64(i, alloc) +} + // findBitRange64 returns the bit index of the first set of // n consecutive 1 bits. If no consecutive set of 1 bits of // size n may be found in c, then it returns an integer >= 64. From 99699d14fe538f6886948ee6d3cc57f7f2a9bff7 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Thu, 4 Nov 2021 11:59:17 -0700 Subject: [PATCH 381/406] cmd/compile: fix TypeDefn to deal with node with no Ntype set Adjust TypeDefn(), which is used by reportTypeLoop(), to work for nodes with no Ntype set (which are all nodes in -G=3 mode). Normally, reportTypeLoop() would not be called, because the types2 typechecker would have already caught it. This is a possible way to report an unusual type loop involving type params, which is not being caught by the types2 type checker. Updates #48962 Change-Id: I55edee46026eece2e8647c5b5b4d8dfb39eeb5f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/361398 Trust: Dan Scales Reviewed-by: Matthew Dempsky Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/ir/name.go | 5 ++++- test/typeparam/issue48962.go | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/typeparam/issue48962.go diff --git a/src/cmd/compile/internal/ir/name.go b/src/cmd/compile/internal/ir/name.go index dcfff7deba..1d4110c73c 100644 --- a/src/cmd/compile/internal/ir/name.go +++ b/src/cmd/compile/internal/ir/name.go @@ -146,7 +146,10 @@ func (n *Name) editChildren(edit func(Node) Node) {} // That is, given "type T Defn", it returns Defn. // It is used by package types. func (n *Name) TypeDefn() *types.Type { - return n.Ntype.Type() + if n.Ntype != nil { + return n.Ntype.Type() + } + return n.Type() } // RecordFrameOffset records the frame offset for the name. diff --git a/test/typeparam/issue48962.go b/test/typeparam/issue48962.go new file mode 100644 index 0000000000..de9a23cdd2 --- /dev/null +++ b/test/typeparam/issue48962.go @@ -0,0 +1,15 @@ +// errorcheck -G=3 + +// Copyright 2021 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 p + +type T0[P any] struct { // ERROR "invalid recursive type" + f P +} + +type T1 struct { + _ T0[T1] +} From 978e39e9e647d7359a41ac32992ef6ff5380be08 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Thu, 4 Nov 2021 16:08:08 -0400 Subject: [PATCH 382/406] crypto/elliptic: tolerate large inputs to IsOnCurve methods The behavior of all Curve methods and package functions when provided an off-curve point is undefined, except for IsOnCurve which should really always return false, not panic. Change-Id: I52f65df25c5af0314fef2c63d0778db72c0f1313 Reviewed-on: https://go-review.googlesource.com/c/go/+/361402 Trust: Filippo Valsorda Run-TryBot: Filippo Valsorda Reviewed-by: Roland Shoemaker TryBot-Result: Go Bot --- src/crypto/elliptic/elliptic_test.go | 10 ++++++++++ src/crypto/elliptic/p224.go | 4 ++++ src/crypto/elliptic/p521.go | 16 +++++++++++----- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/crypto/elliptic/elliptic_test.go b/src/crypto/elliptic/elliptic_test.go index c9744b5a51..d30a6939a4 100644 --- a/src/crypto/elliptic/elliptic_test.go +++ b/src/crypto/elliptic/elliptic_test.go @@ -241,6 +241,16 @@ func testMarshalCompressed(t *testing.T, curve Curve, x, y *big.Int, want []byte } } +func TestLargeIsOnCurve(t *testing.T) { + testAllCurves(t, func(t *testing.T, curve Curve) { + large := big.NewInt(1) + large.Lsh(large, 1000) + if curve.IsOnCurve(large, large) { + t.Errorf("(2^1000, 2^1000) is reported on the curve") + } + }) +} + func benchmarkAllCurves(t *testing.B, f func(*testing.B, Curve)) { tests := []struct { name string diff --git a/src/crypto/elliptic/p224.go b/src/crypto/elliptic/p224.go index 8f3622c89c..34079d14b1 100644 --- a/src/crypto/elliptic/p224.go +++ b/src/crypto/elliptic/p224.go @@ -50,6 +50,10 @@ func (curve p224Curve) Params() *CurveParams { } func (curve p224Curve) IsOnCurve(bigX, bigY *big.Int) bool { + if bigX.BitLen() > 224 || bigY.BitLen() > 224 { + return false + } + var x, y p224FieldElement p224FromBig(&x, bigX) p224FromBig(&y, bigY) diff --git a/src/crypto/elliptic/p521.go b/src/crypto/elliptic/p521.go index 4cc5f86d6d..e64007dfe3 100644 --- a/src/crypto/elliptic/p521.go +++ b/src/crypto/elliptic/p521.go @@ -55,19 +55,25 @@ func (curve p521Curve) Params() *CurveParams { } func (curve p521Curve) IsOnCurve(x, y *big.Int) bool { - // IsOnCurve is documented to reject (0, 0), so we don't use - // p521PointFromAffine, but let SetBytes reject the invalid Marshal output. - _, err := nistec.NewP521Point().SetBytes(Marshal(curve, x, y)) - return err == nil + // IsOnCurve is documented to reject (0, 0), the conventional point at + // infinity, which however is accepted by p521PointFromAffine. + if x.Sign() == 0 && y.Sign() == 0 { + return false + } + _, ok := p521PointFromAffine(x, y) + return ok } func p521PointFromAffine(x, y *big.Int) (p *nistec.P521Point, ok bool) { // (0, 0) is by convention the point at infinity, which can't be represented // in affine coordinates. Marshal incorrectly encodes it as an uncompressed - // point, which SetBytes correctly rejects. See Issue 37294. + // point, which SetBytes would correctly reject. See Issue 37294. if x.Sign() == 0 && y.Sign() == 0 { return nistec.NewP521Point(), true } + if x.BitLen() > 521 || y.BitLen() > 521 { + return nil, false + } p, err := nistec.NewP521Point().SetBytes(Marshal(P521(), x, y)) if err != nil { return nil, false From 1f9dce749db804a8cce767adde3701378db1461c Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 20 Oct 2021 14:02:24 -0400 Subject: [PATCH 383/406] cmd/go: download fewer dependencies in 'go mod download' In modules that specify 'go 1.17' or higher, the go.mod file explicitly requires modules for all packages transitively imported by the main module. Users tend to use 'go mod download' to prepare for testing the main module itself, so we should only download those relevant modules. In 'go 1.16' and earlier modules, we continue to download all modules in the module graph (because we cannot in general tell which ones are relevant without loading the full package import graph). 'go mod download all' continues to download every module in 'go list all', as it did before. Fixes #44435 Change-Id: I3f286c0e2549d6688b3832ff116e6cd77a19401c Reviewed-on: https://go-review.googlesource.com/c/go/+/357310 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Michael Matloob --- doc/go1.18.html | 13 +++++ src/cmd/go/alldocs.go | 7 ++- src/cmd/go/internal/modcmd/download.go | 61 ++++++++++++++++----- src/cmd/go/internal/modload/buildlist.go | 2 +- src/cmd/go/internal/modload/modfile.go | 6 +- src/cmd/go/testdata/script/mod_download.txt | 44 +++++++++++++++ 6 files changed, 113 insertions(+), 20 deletions(-) diff --git a/doc/go1.18.html b/doc/go1.18.html index 171cc3cb22..385a1ae804 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -90,6 +90,19 @@ Do not send CLs removing the interior tags from such phrases. package.

+

+ If the main module's go.mod file + specifies go 1.17 + or higher, go mod download without + arguments now downloads source code for only the modules + explicitly required in the main + module's go.mod file. (In a go 1.17 or + higher module, that set already includes all dependencies needed to build the + packages and tests in the main module.) + To also download source code for transitive dependencies, use + go mod download all. +

+

TODO: complete this section, or delete if not needed

diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 0dcb317995..4420073e52 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -1074,8 +1074,11 @@ // // Download downloads the named modules, which can be module patterns selecting // dependencies of the main module or module queries of the form path@version. -// With no arguments, download applies to all dependencies of the main module -// (equivalent to 'go mod download all'). +// +// With no arguments, download applies to the modules needed to build and test +// the packages in the main module: the modules explicitly required by the main +// module if it is at 'go 1.17' or higher, or all transitively-required modules +// if at 'go 1.16' or lower. // // The go command will automatically download modules as needed during ordinary // execution. The "go mod download" command is useful mainly for pre-filling diff --git a/src/cmd/go/internal/modcmd/download.go b/src/cmd/go/internal/modcmd/download.go index 5ea56c34bd..f252133762 100644 --- a/src/cmd/go/internal/modcmd/download.go +++ b/src/cmd/go/internal/modcmd/download.go @@ -16,6 +16,7 @@ import ( "cmd/go/internal/modload" "golang.org/x/mod/module" + "golang.org/x/mod/semver" ) var cmdDownload = &base.Command{ @@ -24,8 +25,11 @@ var cmdDownload = &base.Command{ Long: ` Download downloads the named modules, which can be module patterns selecting dependencies of the main module or module queries of the form path@version. -With no arguments, download applies to all dependencies of the main module -(equivalent to 'go mod download all'). + +With no arguments, download applies to the modules needed to build and test +the packages in the main module: the modules explicitly required by the main +module if it is at 'go 1.17' or higher, or all transitively-required modules +if at 'go 1.16' or lower. The go command will automatically download modules as needed during ordinary execution. The "go mod download" command is useful mainly for pre-filling @@ -87,13 +91,8 @@ func runDownload(ctx context.Context, cmd *base.Command, args []string) { // Check whether modules are enabled and whether we're in a module. modload.ForceUseModules = true modload.ExplicitWriteGoMod = true - if !modload.HasModRoot() && len(args) == 0 { - base.Fatalf("go: no modules specified (see 'go help mod download')") - } haveExplicitArgs := len(args) > 0 - if !haveExplicitArgs { - args = []string{"all"} - } + if modload.HasModRoot() { modload.LoadModFile(ctx) // to fill MainModules @@ -102,16 +101,50 @@ func runDownload(ctx context.Context, cmd *base.Command, args []string) { } mainModule := modload.MainModules.Versions()[0] - targetAtUpgrade := mainModule.Path + "@upgrade" - targetAtPatch := mainModule.Path + "@patch" - for _, arg := range args { - switch arg { - case mainModule.Path, targetAtUpgrade, targetAtPatch: - os.Stderr.WriteString("go: skipping download of " + arg + " that resolves to the main module\n") + if haveExplicitArgs { + targetAtUpgrade := mainModule.Path + "@upgrade" + targetAtPatch := mainModule.Path + "@patch" + for _, arg := range args { + switch arg { + case mainModule.Path, targetAtUpgrade, targetAtPatch: + os.Stderr.WriteString("go: skipping download of " + arg + " that resolves to the main module\n") + } + } + } else { + modFile := modload.MainModules.ModFile(mainModule) + if modFile.Go == nil || semver.Compare("v"+modFile.Go.Version, modload.ExplicitIndirectVersionV) < 0 { + if len(modFile.Require) > 0 { + args = []string{"all"} + } + } else { + // As of Go 1.17, the go.mod file explicitly requires every module + // that provides any package imported by the main module. + // 'go mod download' is typically run before testing packages in the + // main module, so by default we shouldn't download the others + // (which are presumed irrelevant to the packages in the main module). + // See https://golang.org/issue/44435. + // + // However, we also need to load the full module graph, to ensure that + // we have downloaded enough of the module graph to run 'go list all', + // 'go mod graph', and similar commands. + _ = modload.LoadModGraph(ctx, "") + + for _, m := range modFile.Require { + args = append(args, m.Mod.Path) + } } } } + if len(args) == 0 { + if modload.HasModRoot() { + os.Stderr.WriteString("go: no module dependencies to download\n") + } else { + base.Errorf("go: no modules specified (see 'go help mod download')") + } + base.Exit() + } + downloadModule := func(m *moduleJSON) { var err error m.Info, err = modfetch.InfoFile(m.Path, m.Version) diff --git a/src/cmd/go/internal/modload/buildlist.go b/src/cmd/go/internal/modload/buildlist.go index 4634ad009d..27cab0b9c8 100644 --- a/src/cmd/go/internal/modload/buildlist.go +++ b/src/cmd/go/internal/modload/buildlist.go @@ -236,7 +236,7 @@ func (rs *Requirements) IsDirect(path string) bool { // A ModuleGraph represents the complete graph of module dependencies // of a main module. // -// If the main module is lazily loaded, the graph does not include +// If the main module supports module graph pruning, the graph does not include // transitive dependencies of non-root (implicit) dependencies. type ModuleGraph struct { g *mvs.Graph diff --git a/src/cmd/go/internal/modload/modfile.go b/src/cmd/go/internal/modload/modfile.go index 87e8a5e83d..1672d563b7 100644 --- a/src/cmd/go/internal/modload/modfile.go +++ b/src/cmd/go/internal/modload/modfile.go @@ -33,13 +33,13 @@ const ( // tests outside of the main module. narrowAllVersionV = "v1.16" - // explicitIndirectVersionV is the Go version (plus leading "v") at which a + // ExplicitIndirectVersionV is the Go version (plus leading "v") at which a // module's go.mod file is expected to list explicit requirements on every // module that provides any package transitively imported by that module. // // Other indirect dependencies of such a module can be safely pruned out of // the module graph; see https://golang.org/ref/mod#graph-pruning. - explicitIndirectVersionV = "v1.17" + ExplicitIndirectVersionV = "v1.17" // separateIndirectVersionV is the Go version (plus leading "v") at which // "// indirect" dependencies are added in a block separate from the direct @@ -123,7 +123,7 @@ const ( ) func pruningForGoVersion(goVersion string) modPruning { - if semver.Compare("v"+goVersion, explicitIndirectVersionV) < 0 { + if semver.Compare("v"+goVersion, ExplicitIndirectVersionV) < 0 { // The go.mod file does not duplicate relevant information about transitive // dependencies, so they cannot be pruned out. return unpruned diff --git a/src/cmd/go/testdata/script/mod_download.txt b/src/cmd/go/testdata/script/mod_download.txt index 89e58a2cfd..154e68338b 100644 --- a/src/cmd/go/testdata/script/mod_download.txt +++ b/src/cmd/go/testdata/script/mod_download.txt @@ -128,6 +128,50 @@ rm go.sum go mod download all cmp go.mod.update go.mod grep '^rsc.io/sampler v1.3.0 ' go.sum + +# https://golang.org/issue/44435: At go 1.17 or higher, 'go mod download' +# (without arguments) should only download the modules explicitly required in +# the go.mod file, not (presumed-irrelevant) transitive dependencies. +# +# (If the go.mod file is inconsistent, the version downloaded should be the +# selected version from the broader graph, but the go.mod file will also be +# updated to list the correct versions. If at some point we change 'go mod +# download' to stop updating for consistency, then it should fail if the +# requirements are inconsistent.) + +rm go.sum +cp go.mod.orig go.mod +go mod edit -go=1.17 +cp go.mod.update go.mod.go117 +go mod edit -go=1.17 go.mod.go117 + +go clean -modcache +go mod download +cmp go.mod go.mod.go117 + +go list -e -m all +stdout '^rsc.io/quote v1.5.2$' +exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip +stdout '^rsc.io/sampler v1.3.0$' +! exists $GOPATH/pkg/mod/cache/download/rsc.io/sampler/@v/v1.2.1.zip +exists $GOPATH/pkg/mod/cache/download/rsc.io/sampler/@v/v1.3.0.zip +stdout '^golang\.org/x/text v0.0.0-20170915032832-14c0d48ead0c$' +! exists $GOPATH/pkg/mod/cache/download/golang.org/x/text/@v/v0.0.0-20170915032832-14c0d48ead0c.zip +cmp go.mod go.mod.go117 + +# However, 'go mod download all' continues to download the selected version +# of every module reported by 'go list -m all'. + +cp go.mod.orig go.mod +go mod edit -go=1.17 +go clean -modcache +go mod download all +exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip +! exists $GOPATH/pkg/mod/cache/download/rsc.io/sampler/@v/v1.2.1.zip +exists $GOPATH/pkg/mod/cache/download/rsc.io/sampler/@v/v1.3.0.zip +exists $GOPATH/pkg/mod/cache/download/golang.org/x/text/@v/v0.0.0-20170915032832-14c0d48ead0c.zip +cmp go.mod go.mod.go117 + cd .. # allow go mod download without go.mod From 82481525280e4d0c74cb3f6341ce2f4653a165b8 Mon Sep 17 00:00:00 2001 From: Simon Law Date: Thu, 4 Nov 2021 11:14:59 -0700 Subject: [PATCH 384/406] test: fix indentation for -shuffle help text The help text for the go test -shuffle flag is not indented like the other flags. This patch brings it into alignment. Fixes #49357 Change-Id: I3f18dc7cd84d5f23099262acf6e2fedccb11379c Reviewed-on: https://go-review.googlesource.com/c/go/+/361395 Reviewed-by: Bryan C. Mills Trust: Bryan C. Mills Trust: Michael Matloob Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot --- src/cmd/go/alldocs.go | 10 +++++----- src/cmd/go/internal/test/test.go | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 4420073e52..c9426801c5 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -2854,11 +2854,11 @@ // exhaustive tests. // // -shuffle off,on,N -// Randomize the execution order of tests and benchmarks. -// It is off by default. If -shuffle is set to on, then it will seed -// the randomizer using the system clock. If -shuffle is set to an -// integer N, then N will be used as the seed value. In both cases, -// the seed will be reported for reproducibility. +// Randomize the execution order of tests and benchmarks. +// It is off by default. If -shuffle is set to on, then it will seed +// the randomizer using the system clock. If -shuffle is set to an +// integer N, then N will be used as the seed value. In both cases, +// the seed will be reported for reproducibility. // // -timeout d // If a test binary runs longer than duration d, panic. diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index 7dca6b531c..de6525d541 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -307,11 +307,11 @@ control the execution of any test: exhaustive tests. -shuffle off,on,N - Randomize the execution order of tests and benchmarks. - It is off by default. If -shuffle is set to on, then it will seed - the randomizer using the system clock. If -shuffle is set to an - integer N, then N will be used as the seed value. In both cases, - the seed will be reported for reproducibility. + Randomize the execution order of tests and benchmarks. + It is off by default. If -shuffle is set to on, then it will seed + the randomizer using the system clock. If -shuffle is set to an + integer N, then N will be used as the seed value. In both cases, + the seed will be reported for reproducibility. -timeout d If a test binary runs longer than duration d, panic. From 71fc881cff79d0f3b352c20b947f4911892864fa Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 3 Nov 2021 10:39:54 -0400 Subject: [PATCH 385/406] cmd/go: ensure that 'go test' prints the FAIL line for a package on a new line Fixes #49317 Change-Id: I4038fd4c1d845d54ecbbf82bf73060db1b44c9bc Reviewed-on: https://go-review.googlesource.com/c/go/+/361095 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/cmd/go/internal/test/test.go | 14 +++- .../go/testdata/script/test_fail_newline.txt | 65 +++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/cmd/go/testdata/script/test_fail_newline.txt diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index de6525d541..7361c11786 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -1405,15 +1405,25 @@ func (c *runCache) builderRunTest(b *work.Builder, ctx context.Context, a *work. if bytes.HasPrefix(out, tooManyTargetsToFuzz[1:]) || bytes.Contains(out, tooManyTargetsToFuzz) { norun = " [will not fuzz, -fuzz matches more than one target]" } + if len(out) > 0 && !bytes.HasSuffix(out, []byte("\n")) { + // Ensure that the output ends with a newline before the "ok" + // line we're about to print (https://golang.org/issue/49317). + cmd.Stdout.Write([]byte("\n")) + } fmt.Fprintf(cmd.Stdout, "ok \t%s\t%s%s%s\n", a.Package.ImportPath, t, coveragePercentage(out), norun) c.saveOutput(a) } else { base.SetExitStatus(1) - // If there was test output, assume we don't need to print the exit status. - // Buf there's no test output, do print the exit status. if len(out) == 0 { + // If there was no test output, print the exit status so that the reason + // for failure is clear. fmt.Fprintf(cmd.Stdout, "%s\n", err) + } else if !bytes.HasSuffix(out, []byte("\n")) { + // Otherwise, ensure that the output ends with a newline before the FAIL + // line we're about to print (https://golang.org/issue/49317). + cmd.Stdout.Write([]byte("\n")) } + // NOTE(golang.org/issue/37555): test2json reports that a test passes // unless "FAIL" is printed at the beginning of a line. The test may not // actually print that if it panics, exits, or terminates abnormally, diff --git a/src/cmd/go/testdata/script/test_fail_newline.txt b/src/cmd/go/testdata/script/test_fail_newline.txt new file mode 100644 index 0000000000..43cee565a1 --- /dev/null +++ b/src/cmd/go/testdata/script/test_fail_newline.txt @@ -0,0 +1,65 @@ +[short] skip + +# In package list mode, output is buffered. +# Check that a newline is printed after the buffer's contents. +cd fail +! go test . +! stderr . +stdout '^exitcode=1\n' +stdout '^FAIL\s+example/fail' + +# In local directory mode output is streamed, so we don't know +# whether the test printed anything at all, so we print the exit code +# (just in case it failed without emitting any output at all), +# and that happens to add the needed newline as well. +! go test +! stderr . +stdout '^exitcode=1exit status 1\n' +stdout '^FAIL\s+example/fail' + +# In package list mode, if the test passes the 'ok' message appears +# on its own line. +cd ../skip +go test -v . +! stderr . +stdout '^skipping\n' +stdout '^ok\s+example/skip' + +# If the output is streamed and the test passes, we can't tell whether it ended +# in a partial line, and don't want to emit any extra output in the +# overwhelmingly common case that it did not. +# (In theory we could hook the 'os' package to report whether output +# was emitted and whether it ended in a newline, but that seems too invasive.) +go test +! stderr . +stdout '^skippingok\s+example/skip' + + +-- go.mod -- +module example + +go 1.18 +-- fail/fail_test.go -- +package fail + +import ( + "os" + "testing" +) + +func TestMain(m *testing.M) { + os.Stderr.WriteString("exitcode=1") + os.Exit(1) +} +-- skip/skip_test.go -- +package skip + +import ( + "os" + "testing" +) + +func TestMain(m *testing.M) { + os.Stderr.WriteString("skipping") + os.Exit(0) +} From 2c32f29f2f88e56f329547467090e7315cd3c1e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20D=C3=B6tsch?= Date: Fri, 29 Oct 2021 03:23:15 +0000 Subject: [PATCH 386/406] cmd/go: clarify errors for pseudo-version commit length These error messages contain the expected shortened revision in braces, but don't explicitly tell the user that this is the expected one. Just unified it with the "does not match version-control timestamp" error which does the same... Change-Id: I8e07df7bd776fd1b39c4c90c4788cb3d626ea00b GitHub-Last-Rev: d14681ad086790f4e43c312c8a328d588acc6ec4 GitHub-Pull-Request: golang/go#42578 Reviewed-on: https://go-review.googlesource.com/c/go/+/269877 Trust: Bryan C. Mills Trust: Jay Conrod Reviewed-by: Jay Conrod --- src/cmd/go/internal/modfetch/coderepo.go | 6 +++--- src/cmd/go/testdata/script/mod_invalid_version.txt | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cmd/go/internal/modfetch/coderepo.go b/src/cmd/go/internal/modfetch/coderepo.go index dfef9f73c2..df835c3d7e 100644 --- a/src/cmd/go/internal/modfetch/coderepo.go +++ b/src/cmd/go/internal/modfetch/coderepo.go @@ -567,11 +567,11 @@ func (r *codeRepo) validatePseudoVersion(info *codehost.RevInfo, version string) if rev != info.Short { switch { case strings.HasPrefix(rev, info.Short): - return fmt.Errorf("revision is longer than canonical (%s)", info.Short) + return fmt.Errorf("revision is longer than canonical (expected %s)", info.Short) case strings.HasPrefix(info.Short, rev): - return fmt.Errorf("revision is shorter than canonical (%s)", info.Short) + return fmt.Errorf("revision is shorter than canonical (expected %s)", info.Short) default: - return fmt.Errorf("does not match short name of revision (%s)", info.Short) + return fmt.Errorf("does not match short name of revision (expected %s)", info.Short) } } diff --git a/src/cmd/go/testdata/script/mod_invalid_version.txt b/src/cmd/go/testdata/script/mod_invalid_version.txt index f9317b676d..428b8aa60e 100644 --- a/src/cmd/go/testdata/script/mod_invalid_version.txt +++ b/src/cmd/go/testdata/script/mod_invalid_version.txt @@ -57,20 +57,20 @@ cp go.mod.orig go.mod go mod edit -require golang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0 cd outside ! go list -m golang.org/x/text -stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0: invalid pseudo-version: revision is shorter than canonical \(14c0d48ead0c\)' +stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0: invalid pseudo-version: revision is shorter than canonical \(expected 14c0d48ead0c\)' cd .. ! go list -m golang.org/x/text -stderr 'golang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0: invalid pseudo-version: revision is shorter than canonical \(14c0d48ead0c\)' +stderr 'golang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0: invalid pseudo-version: revision is shorter than canonical \(expected 14c0d48ead0c\)' # A pseudo-version with more than 12 digits of SHA-1 prefix is invalid. cp go.mod.orig go.mod go mod edit -require golang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0cd47e3104ada247d91be04afc7a5a cd outside ! go list -m golang.org/x/text -stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0cd47e3104ada247d91be04afc7a5a: invalid pseudo-version: revision is longer than canonical \(14c0d48ead0c\)' +stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0cd47e3104ada247d91be04afc7a5a: invalid pseudo-version: revision is longer than canonical \(expected 14c0d48ead0c\)' cd .. ! go list -m golang.org/x/text -stderr 'golang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0cd47e3104ada247d91be04afc7a5a: invalid pseudo-version: revision is longer than canonical \(14c0d48ead0c\)' +stderr 'golang.org/x/text@v0.1.1-0.20170915032832-14c0d48ead0cd47e3104ada247d91be04afc7a5a: invalid pseudo-version: revision is longer than canonical \(expected 14c0d48ead0c\)' # A pseudo-version that does not match the commit timestamp is invalid. cp go.mod.orig go.mod From 156abe51221c5723c3ff524ea0fcbe65d8272bfa Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Thu, 4 Nov 2021 21:09:34 +0000 Subject: [PATCH 387/406] runtime: fix hard goal calculation The new GC pacer has a bug where the hard goal isn't set in relation to the original heap goal, but rather to the one already extrapolated for overshoot. In practice, I have never once seen this case arise because the extrapolated goal used for overshoot is conservative. No test because writing a test for this case is impossible in the idealized model the pacer tests create. It is possible to simulate but will take more work. For now, just leave a TODO. Change-Id: I24ff710016cd8100fad54f71b2c8cdea0f7dfa79 Reviewed-on: https://go-review.googlesource.com/c/go/+/361435 Reviewed-by: Michael Pratt Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot --- src/runtime/mgcpacer.go | 7 ++++--- src/runtime/mgcpacer_test.go | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index f886a07da1..230e78b000 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -517,7 +517,7 @@ func (c *gcControllerState) revise() { // growths. It's OK to use more memory this cycle to scan all the live heap, // because the next GC cycle is inevitably going to use *at least* that much // memory anyway. - heapGoal = int64(float64(heapGoal-int64(c.trigger))/float64(scanWorkExpected)*float64(maxScanWork)) + int64(c.trigger) + extHeapGoal := int64(float64(heapGoal-int64(c.trigger))/float64(scanWorkExpected)*float64(maxScanWork)) + int64(c.trigger) scanWorkExpected = maxScanWork // hardGoal is a hard limit on the amount that we're willing to push back the @@ -528,9 +528,10 @@ func (c *gcControllerState) revise() { // This maintains the invariant that we use no more memory than the next GC cycle // will anyway. hardGoal := int64((1.0 + float64(gcPercent)/100.0) * float64(heapGoal)) - if heapGoal > hardGoal { - heapGoal = hardGoal + if extHeapGoal > hardGoal { + extHeapGoal = hardGoal } + heapGoal = extHeapGoal } if int64(live) > heapGoal { // We're already past our heap goal, even the extrapolated one. diff --git a/src/runtime/mgcpacer_test.go b/src/runtime/mgcpacer_test.go index d2707ca5a1..9ec0e5172b 100644 --- a/src/runtime/mgcpacer_test.go +++ b/src/runtime/mgcpacer_test.go @@ -302,6 +302,12 @@ func TestGcPacer(t *testing.T) { } }, }, + // TODO(mknyszek): Write a test that exercises the pacer's hard goal. + // This is difficult in the idealized model this testing framework places + // the pacer in, because the calculated overshoot is directly proportional + // to the runway for the case of the expected work. + // However, it is still possible to trigger this case if something exceptional + // happens between calls to revise; the framework just doesn't support this yet. } { e := e t.Run(e.name, func(t *testing.T) { From bfd74fd4228009bb9243c1836f9886ba1ad56e15 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 3 Nov 2021 14:08:43 -0700 Subject: [PATCH 388/406] net: remove the alloc from WriteMsgUDPAddrPort MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit name old time/op new time/op delta ReadWriteMsgUDPAddrPort-8 5.12µs ± 8% 4.59µs ± 3% -10.19% (p=0.000 n=10+9) name old alloc/op new alloc/op delta ReadWriteMsgUDPAddrPort-8 64.0B ± 0% 32.0B ± 0% -50.00% (p=0.000 n=10+10) name old allocs/op new allocs/op delta ReadWriteMsgUDPAddrPort-8 2.00 ± 0% 1.00 ± 0% -50.00% (p=0.000 n=10+10) Change-Id: Idf540b2f9f8035660305a0ab1cfc3e162569db63 Reviewed-on: https://go-review.googlesource.com/c/go/+/361257 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/internal/poll/fd_unix.go | 52 ++++++++++++++++++ src/internal/poll/fd_windows.go | 84 +++++++++++++++++++++++------ src/internal/syscall/unix/net.go | 8 +++ src/internal/syscall/unix/net_js.go | 8 +++ src/net/fd_posix.go | 12 +++++ src/net/net_fake.go | 8 +++ src/net/udpsock_posix.go | 6 +-- src/syscall/syscall_unix.go | 16 ++++++ 8 files changed, 175 insertions(+), 19 deletions(-) diff --git a/src/internal/poll/fd_unix.go b/src/internal/poll/fd_unix.go index fd5ac85850..b090e5b6bd 100644 --- a/src/internal/poll/fd_unix.go +++ b/src/internal/poll/fd_unix.go @@ -485,6 +485,58 @@ func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, err } } +// WriteMsgInet4 is WriteMsg specialized for syscall.SockaddrInet4. +func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa syscall.SockaddrInet4) (int, int, error) { + if err := fd.writeLock(); err != nil { + return 0, 0, err + } + defer fd.writeUnlock() + if err := fd.pd.prepareWrite(fd.isFile); err != nil { + return 0, 0, err + } + for { + n, err := unix.SendmsgNInet4(fd.Sysfd, p, oob, sa, 0) + if err == syscall.EINTR { + continue + } + if err == syscall.EAGAIN && fd.pd.pollable() { + if err = fd.pd.waitWrite(fd.isFile); err == nil { + continue + } + } + if err != nil { + return n, 0, err + } + return n, len(oob), err + } +} + +// WriteMsgInet6 is WriteMsg specialized for syscall.SockaddrInet6. +func (fd *FD) WriteMsgInet6(p []byte, oob []byte, sa syscall.SockaddrInet6) (int, int, error) { + if err := fd.writeLock(); err != nil { + return 0, 0, err + } + defer fd.writeUnlock() + if err := fd.pd.prepareWrite(fd.isFile); err != nil { + return 0, 0, err + } + for { + n, err := unix.SendmsgNInet6(fd.Sysfd, p, oob, sa, 0) + if err == syscall.EINTR { + continue + } + if err == syscall.EAGAIN && fd.pd.pollable() { + if err = fd.pd.waitWrite(fd.isFile); err == nil { + continue + } + } + if err != nil { + return n, 0, err + } + return n, len(oob), err + } +} + // Accept wraps the accept network call. func (fd *FD) Accept() (int, syscall.Sockaddr, string, error) { if err := fd.readLock(); err != nil { diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go index 139f78a7c1..f8fc4de75d 100644 --- a/src/internal/poll/fd_windows.go +++ b/src/internal/poll/fd_windows.go @@ -1128,25 +1128,35 @@ func (fd *FD) RawWrite(f func(uintptr) bool) error { return syscall.EWINDOWS } +func sockaddrInet4ToRaw(sa syscall.SockaddrInet4) (unsafe.Pointer, int32) { + var raw syscall.RawSockaddrInet4 + raw.Family = syscall.AF_INET + p := (*[2]byte)(unsafe.Pointer(&raw.Port)) + p[0] = byte(sa.Port >> 8) + p[1] = byte(sa.Port) + raw.Addr = sa.Addr + return unsafe.Pointer(&raw), int32(unsafe.Sizeof(raw)) +} + +func sockaddrInet6ToRaw(sa syscall.SockaddrInet6) (unsafe.Pointer, int32) { + var raw syscall.RawSockaddrInet6 + raw.Family = syscall.AF_INET6 + p := (*[2]byte)(unsafe.Pointer(&raw.Port)) + p[0] = byte(sa.Port >> 8) + p[1] = byte(sa.Port) + raw.Scope_id = sa.ZoneId + raw.Addr = sa.Addr + return unsafe.Pointer(&raw), int32(unsafe.Sizeof(raw)) +} + func sockaddrToRaw(sa syscall.Sockaddr) (unsafe.Pointer, int32, error) { switch sa := sa.(type) { case *syscall.SockaddrInet4: - var raw syscall.RawSockaddrInet4 - raw.Family = syscall.AF_INET - p := (*[2]byte)(unsafe.Pointer(&raw.Port)) - p[0] = byte(sa.Port >> 8) - p[1] = byte(sa.Port) - raw.Addr = sa.Addr - return unsafe.Pointer(&raw), int32(unsafe.Sizeof(raw)), nil + ptr, sz := sockaddrInet4ToRaw(*sa) + return ptr, sz, nil case *syscall.SockaddrInet6: - var raw syscall.RawSockaddrInet6 - raw.Family = syscall.AF_INET6 - p := (*[2]byte)(unsafe.Pointer(&raw.Port)) - p[0] = byte(sa.Port >> 8) - p[1] = byte(sa.Port) - raw.Scope_id = sa.ZoneId - raw.Addr = sa.Addr - return unsafe.Pointer(&raw), int32(unsafe.Sizeof(raw)), nil + ptr, sz := sockaddrInet6ToRaw(*sa) + return ptr, sz, nil default: return nil, 0, syscall.EWINDOWS } @@ -1206,3 +1216,47 @@ func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, err }) return n, int(o.msg.Control.Len), err } + +// WriteMsgInet4 is WriteMsg specialized for syscall.SockaddrInet4. +func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa syscall.SockaddrInet4) (int, int, error) { + if len(p) > maxRW { + return 0, 0, errors.New("packet is too large (only 1GB is allowed)") + } + + if err := fd.writeLock(); err != nil { + return 0, 0, err + } + defer fd.writeUnlock() + + o := &fd.wop + o.InitMsg(p, oob) + rsa, len := sockaddrInet4ToRaw(sa) + o.msg.Name = (syscall.Pointer)(rsa) + o.msg.Namelen = len + n, err := execIO(o, func(o *operation) error { + return windows.WSASendMsg(o.fd.Sysfd, &o.msg, 0, &o.qty, &o.o, nil) + }) + return n, int(o.msg.Control.Len), err +} + +// WriteMsgInet6 is WriteMsg specialized for syscall.SockaddrInet6. +func (fd *FD) WriteMsgInet6(p []byte, oob []byte, sa syscall.SockaddrInet6) (int, int, error) { + if len(p) > maxRW { + return 0, 0, errors.New("packet is too large (only 1GB is allowed)") + } + + if err := fd.writeLock(); err != nil { + return 0, 0, err + } + defer fd.writeUnlock() + + o := &fd.wop + o.InitMsg(p, oob) + rsa, len := sockaddrInet6ToRaw(sa) + o.msg.Name = (syscall.Pointer)(rsa) + o.msg.Namelen = len + n, err := execIO(o, func(o *operation) error { + return windows.WSASendMsg(o.fd.Sysfd, &o.msg, 0, &o.qty, &o.o, nil) + }) + return n, int(o.msg.Control.Len), err +} diff --git a/src/internal/syscall/unix/net.go b/src/internal/syscall/unix/net.go index 773cf34d96..71e50f54c3 100644 --- a/src/internal/syscall/unix/net.go +++ b/src/internal/syscall/unix/net.go @@ -26,3 +26,11 @@ func SendtoInet4(fd int, p []byte, flags int, to syscall.SockaddrInet4) (err err //go:linkname SendtoInet6 syscall.sendtoInet6 //go:noescape func SendtoInet6(fd int, p []byte, flags int, to syscall.SockaddrInet6) (err error) + +//go:linkname SendmsgNInet4 syscall.sendmsgNInet4 +//go:noescape +func SendmsgNInet4(fd int, p, oob []byte, to syscall.SockaddrInet4, flags int) (n int, err error) + +//go:linkname SendmsgNInet6 syscall.sendmsgNInet6 +//go:noescape +func SendmsgNInet6(fd int, p, oob []byte, to syscall.SockaddrInet6, flags int) (n int, err error) diff --git a/src/internal/syscall/unix/net_js.go b/src/internal/syscall/unix/net_js.go index 3fc5a66470..35bc687b58 100644 --- a/src/internal/syscall/unix/net_js.go +++ b/src/internal/syscall/unix/net_js.go @@ -26,3 +26,11 @@ func SendtoInet4(fd int, p []byte, flags int, to syscall.SockaddrInet4) (err err func SendtoInet6(fd int, p []byte, flags int, to syscall.SockaddrInet6) (err error) { return syscall.ENOSYS } + +func SendmsgNInet4(fd int, p, oob []byte, to syscall.SockaddrInet4, flags int) (n int, err error) { + return 0, syscall.ENOSYS +} + +func SendmsgNInet6(fd int, p, oob []byte, to syscall.SockaddrInet6, flags int) (n int, err error) { + return 0, syscall.ENOSYS +} diff --git a/src/net/fd_posix.go b/src/net/fd_posix.go index 1887a45186..edcef1f2e1 100644 --- a/src/net/fd_posix.go +++ b/src/net/fd_posix.go @@ -110,6 +110,18 @@ func (fd *netFD) writeMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oob return n, oobn, wrapSyscallError(writeMsgSyscallName, err) } +func (fd *netFD) writeMsgInet4(p []byte, oob []byte, sa syscall.SockaddrInet4) (n int, oobn int, err error) { + n, oobn, err = fd.pfd.WriteMsgInet4(p, oob, sa) + runtime.KeepAlive(fd) + return n, oobn, wrapSyscallError(writeMsgSyscallName, err) +} + +func (fd *netFD) writeMsgInet6(p []byte, oob []byte, sa syscall.SockaddrInet6) (n int, oobn int, err error) { + n, oobn, err = fd.pfd.WriteMsgInet6(p, oob, sa) + runtime.KeepAlive(fd) + return n, oobn, wrapSyscallError(writeMsgSyscallName, err) +} + func (fd *netFD) SetDeadline(t time.Time) error { return fd.pfd.SetDeadline(t) } diff --git a/src/net/net_fake.go b/src/net/net_fake.go index d58bd82029..2ade9f7774 100644 --- a/src/net/net_fake.go +++ b/src/net/net_fake.go @@ -279,6 +279,14 @@ func (fd *netFD) readMsg(p []byte, oob []byte, flags int) (n, oobn, retflags int return 0, 0, 0, nil, syscall.ENOSYS } +func (fd *netFD) writeMsgInet4(p []byte, oob []byte, sa syscall.SockaddrInet4) (n int, oobn int, err error) { + return 0, 0, syscall.ENOSYS +} + +func (fd *netFD) writeMsgInet6(p []byte, oob []byte, sa syscall.SockaddrInet6) (n int, oobn int, err error) { + return 0, 0, syscall.ENOSYS +} + func (fd *netFD) writeTo(p []byte, sa syscall.Sockaddr) (n int, err error) { return 0, syscall.ENOSYS } diff --git a/src/net/udpsock_posix.go b/src/net/udpsock_posix.go index c93994f836..468afbc4dc 100644 --- a/src/net/udpsock_posix.go +++ b/src/net/udpsock_posix.go @@ -188,15 +188,13 @@ func (c *UDPConn) writeMsgAddrPort(b, oob []byte, addr netip.AddrPort) (n, oobn if err != nil { return 0, 0, err } - // TODO: Implement writeMsgInet4 to avoid allocation converting sa to an interface. - return c.fd.writeMsg(b, oob, &sa) + return c.fd.writeMsgInet4(b, oob, sa) case syscall.AF_INET6: sa, err := addrPortToSockaddrInet6(addr) if err != nil { return 0, 0, err } - // TODO: Implement writeMsgInet6 to avoid allocation converting sa to an interface. - return c.fd.writeMsg(b, oob, &sa) + return c.fd.writeMsgInet6(b, oob, sa) default: return 0, 0, &AddrError{Err: "invalid address family", Addr: addr.Addr().String()} } diff --git a/src/syscall/syscall_unix.go b/src/syscall/syscall_unix.go index d1ecc361c6..8692a65794 100644 --- a/src/syscall/syscall_unix.go +++ b/src/syscall/syscall_unix.go @@ -351,6 +351,22 @@ func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) return sendmsgN(fd, p, oob, ptr, salen, flags) } +func sendmsgNInet4(fd int, p, oob []byte, to SockaddrInet4, flags int) (n int, err error) { + ptr, salen, err := to.sockaddr() + if err != nil { + return 0, err + } + return sendmsgN(fd, p, oob, ptr, salen, flags) +} + +func sendmsgNInet6(fd int, p, oob []byte, to SockaddrInet6, flags int) (n int, err error) { + ptr, salen, err := to.sockaddr() + if err != nil { + return 0, err + } + return sendmsgN(fd, p, oob, ptr, salen, flags) +} + func sendtoInet4(fd int, p []byte, flags int, to SockaddrInet4) (err error) { ptr, n, err := to.sockaddr() if err != nil { From 37634eeff9b7510d2eb224397c2bc8c806da83e1 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 3 Nov 2021 14:42:52 -0700 Subject: [PATCH 389/406] net: remove the alloc from ReadMsgUDPAddrPort MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit name old time/op new time/op delta ReadWriteMsgUDPAddrPort-8 4.95µs ± 5% 4.55µs ± 1% -7.96% (p=0.016 n=5+4) name old alloc/op new alloc/op delta ReadWriteMsgUDPAddrPort-8 32.0B ± 0% 0.0B -100.00% (p=0.008 n=5+5) name old allocs/op new allocs/op delta ReadWriteMsgUDPAddrPort-8 1.00 ± 0% 0.00 -100.00% (p=0.008 n=5+5) Change-Id: Ib968c6f2968926ec9a364dd52063cd0d7c29b10c Reviewed-on: https://go-review.googlesource.com/c/go/+/360862 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/internal/poll/fd_unix.go | 54 ++++++++++++++++++++ src/internal/poll/fd_windows.go | 79 ++++++++++++++++++++++++++--- src/internal/syscall/unix/net.go | 8 +++ src/internal/syscall/unix/net_js.go | 8 +++ src/net/fd_posix.go | 12 +++++ src/net/net_fake.go | 8 +++ src/net/udpsock_posix.go | 12 +++-- src/syscall/syscall_unix.go | 27 ++++++++++ 8 files changed, 195 insertions(+), 13 deletions(-) diff --git a/src/internal/poll/fd_unix.go b/src/internal/poll/fd_unix.go index b090e5b6bd..45d4ce07b2 100644 --- a/src/internal/poll/fd_unix.go +++ b/src/internal/poll/fd_unix.go @@ -311,6 +311,60 @@ func (fd *FD) ReadMsg(p []byte, oob []byte, flags int) (int, int, int, syscall.S } } +// ReadMsgInet4 is ReadMsg, but specialized for syscall.SockaddrInet4. +func (fd *FD) ReadMsgInet4(p []byte, oob []byte, flags int, sa4 *syscall.SockaddrInet4) (int, int, int, error) { + if err := fd.readLock(); err != nil { + return 0, 0, 0, err + } + defer fd.readUnlock() + if err := fd.pd.prepareRead(fd.isFile); err != nil { + return 0, 0, 0, err + } + for { + n, oobn, sysflags, err := unix.RecvmsgInet4(fd.Sysfd, p, oob, flags, sa4) + if err != nil { + if err == syscall.EINTR { + continue + } + // TODO(dfc) should n and oobn be set to 0 + if err == syscall.EAGAIN && fd.pd.pollable() { + if err = fd.pd.waitRead(fd.isFile); err == nil { + continue + } + } + } + err = fd.eofError(n, err) + return n, oobn, sysflags, err + } +} + +// ReadMsgInet6 is ReadMsg, but specialized for syscall.SockaddrInet6. +func (fd *FD) ReadMsgInet6(p []byte, oob []byte, flags int, sa6 *syscall.SockaddrInet6) (int, int, int, error) { + if err := fd.readLock(); err != nil { + return 0, 0, 0, err + } + defer fd.readUnlock() + if err := fd.pd.prepareRead(fd.isFile); err != nil { + return 0, 0, 0, err + } + for { + n, oobn, sysflags, err := unix.RecvmsgInet6(fd.Sysfd, p, oob, flags, sa6) + if err != nil { + if err == syscall.EINTR { + continue + } + // TODO(dfc) should n and oobn be set to 0 + if err == syscall.EAGAIN && fd.pd.pollable() { + if err = fd.pd.waitRead(fd.isFile); err == nil { + continue + } + } + } + err = fd.eofError(n, err) + return n, oobn, sysflags, err + } +} + // Write implements io.Writer. func (fd *FD) Write(p []byte) (int, error) { if err := fd.writeLock(); err != nil { diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go index f8fc4de75d..4dd5986efd 100644 --- a/src/internal/poll/fd_windows.go +++ b/src/internal/poll/fd_windows.go @@ -620,10 +620,7 @@ func (fd *FD) ReadFromInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error) if err != nil { return n, err } - sa, _ := o.rsa.Sockaddr() - if sa != nil { - *sa4 = *(sa.(*syscall.SockaddrInet4)) - } + rawToSockaddrInet4(o.rsa, sa4) return n, err } @@ -652,10 +649,7 @@ func (fd *FD) ReadFromInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error) if err != nil { return n, err } - sa, _ := o.rsa.Sockaddr() - if sa != nil { - *sa6 = *(sa.(*syscall.SockaddrInet6)) - } + rawToSockaddrInet6(o.rsa, sa6) return n, err } @@ -1149,6 +1143,21 @@ func sockaddrInet6ToRaw(sa syscall.SockaddrInet6) (unsafe.Pointer, int32) { return unsafe.Pointer(&raw), int32(unsafe.Sizeof(raw)) } +func rawToSockaddrInet4(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet4) { + pp := (*syscall.RawSockaddrInet4)(unsafe.Pointer(rsa)) + p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + sa.Port = int(p[0])<<8 + int(p[1]) + sa.Addr = pp.Addr +} + +func rawToSockaddrInet6(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet6) { + pp := (*syscall.RawSockaddrInet6)(unsafe.Pointer(rsa)) + p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + sa.Port = int(p[0])<<8 + int(p[1]) + sa.ZoneId = pp.Scope_id + sa.Addr = pp.Addr +} + func sockaddrToRaw(sa syscall.Sockaddr) (unsafe.Pointer, int32, error) { switch sa := sa.(type) { case *syscall.SockaddrInet4: @@ -1190,6 +1199,60 @@ func (fd *FD) ReadMsg(p []byte, oob []byte, flags int) (int, int, int, syscall.S return n, int(o.msg.Control.Len), int(o.msg.Flags), sa, err } +// ReadMsgInet4 is ReadMsg, but specialized to return a syscall.SockaddrInet4. +func (fd *FD) ReadMsgInet4(p []byte, oob []byte, flags int, sa4 *syscall.SockaddrInet4) (int, int, int, error) { + if err := fd.readLock(); err != nil { + return 0, 0, 0, err + } + defer fd.readUnlock() + + if len(p) > maxRW { + p = p[:maxRW] + } + + o := &fd.rop + o.InitMsg(p, oob) + o.rsa = new(syscall.RawSockaddrAny) + o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) + o.msg.Namelen = int32(unsafe.Sizeof(*o.rsa)) + o.msg.Flags = uint32(flags) + n, err := execIO(o, func(o *operation) error { + return windows.WSARecvMsg(o.fd.Sysfd, &o.msg, &o.qty, &o.o, nil) + }) + err = fd.eofError(n, err) + if err == nil { + rawToSockaddrInet4(o.rsa, sa4) + } + return n, int(o.msg.Control.Len), int(o.msg.Flags), err +} + +// ReadMsgInet6 is ReadMsg, but specialized to return a syscall.SockaddrInet6. +func (fd *FD) ReadMsgInet6(p []byte, oob []byte, flags int, sa6 *syscall.SockaddrInet6) (int, int, int, error) { + if err := fd.readLock(); err != nil { + return 0, 0, 0, err + } + defer fd.readUnlock() + + if len(p) > maxRW { + p = p[:maxRW] + } + + o := &fd.rop + o.InitMsg(p, oob) + o.rsa = new(syscall.RawSockaddrAny) + o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) + o.msg.Namelen = int32(unsafe.Sizeof(*o.rsa)) + o.msg.Flags = uint32(flags) + n, err := execIO(o, func(o *operation) error { + return windows.WSARecvMsg(o.fd.Sysfd, &o.msg, &o.qty, &o.o, nil) + }) + err = fd.eofError(n, err) + if err == nil { + rawToSockaddrInet6(o.rsa, sa6) + } + return n, int(o.msg.Control.Len), int(o.msg.Flags), err +} + // WriteMsg wraps the WSASendMsg network call. func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, error) { if len(p) > maxRW { diff --git a/src/internal/syscall/unix/net.go b/src/internal/syscall/unix/net.go index 71e50f54c3..87ce89b57f 100644 --- a/src/internal/syscall/unix/net.go +++ b/src/internal/syscall/unix/net.go @@ -34,3 +34,11 @@ func SendmsgNInet4(fd int, p, oob []byte, to syscall.SockaddrInet4, flags int) ( //go:linkname SendmsgNInet6 syscall.sendmsgNInet6 //go:noescape func SendmsgNInet6(fd int, p, oob []byte, to syscall.SockaddrInet6, flags int) (n int, err error) + +//go:linkname RecvmsgInet4 syscall.recvmsgInet4 +//go:noescape +func RecvmsgInet4(fd int, p, oob []byte, flags int, from *syscall.SockaddrInet4) (n, oobn int, recvflags int, err error) + +//go:linkname RecvmsgInet6 syscall.recvmsgInet6 +//go:noescape +func RecvmsgInet6(fd int, p, oob []byte, flags int, from *syscall.SockaddrInet6) (n, oobn int, recvflags int, err error) diff --git a/src/internal/syscall/unix/net_js.go b/src/internal/syscall/unix/net_js.go index 35bc687b58..defc3f6fb2 100644 --- a/src/internal/syscall/unix/net_js.go +++ b/src/internal/syscall/unix/net_js.go @@ -34,3 +34,11 @@ func SendmsgNInet4(fd int, p, oob []byte, to syscall.SockaddrInet4, flags int) ( func SendmsgNInet6(fd int, p, oob []byte, to syscall.SockaddrInet6, flags int) (n int, err error) { return 0, syscall.ENOSYS } + +func RecvmsgInet4(fd int, p, oob []byte, flags int, from *syscall.SockaddrInet4) (n, oobn int, recvflags int, err error) { + return 0, 0, 0, syscall.ENOSYS +} + +func RecvmsgInet6(fd int, p, oob []byte, flags int, from *syscall.SockaddrInet6) (n, oobn int, recvflags int, err error) { + return 0, 0, 0, syscall.ENOSYS +} diff --git a/src/net/fd_posix.go b/src/net/fd_posix.go index edcef1f2e1..d12dbeebd2 100644 --- a/src/net/fd_posix.go +++ b/src/net/fd_posix.go @@ -80,6 +80,18 @@ func (fd *netFD) readMsg(p []byte, oob []byte, flags int) (n, oobn, retflags int return n, oobn, retflags, sa, wrapSyscallError(readMsgSyscallName, err) } +func (fd *netFD) readMsgInet4(p []byte, oob []byte, flags int, sa *syscall.SockaddrInet4) (n, oobn, retflags int, err error) { + n, oobn, retflags, err = fd.pfd.ReadMsgInet4(p, oob, flags, sa) + runtime.KeepAlive(fd) + return n, oobn, retflags, wrapSyscallError(readMsgSyscallName, err) +} + +func (fd *netFD) readMsgInet6(p []byte, oob []byte, flags int, sa *syscall.SockaddrInet6) (n, oobn, retflags int, err error) { + n, oobn, retflags, err = fd.pfd.ReadMsgInet6(p, oob, flags, sa) + runtime.KeepAlive(fd) + return n, oobn, retflags, wrapSyscallError(readMsgSyscallName, err) +} + func (fd *netFD) Write(p []byte) (nn int, err error) { nn, err = fd.pfd.Write(p) runtime.KeepAlive(fd) diff --git a/src/net/net_fake.go b/src/net/net_fake.go index 2ade9f7774..8da9d15bb2 100644 --- a/src/net/net_fake.go +++ b/src/net/net_fake.go @@ -279,6 +279,14 @@ func (fd *netFD) readMsg(p []byte, oob []byte, flags int) (n, oobn, retflags int return 0, 0, 0, nil, syscall.ENOSYS } +func (fd *netFD) readMsgInet4(p []byte, oob []byte, flags int, sa *syscall.SockaddrInet4) (n, oobn, retflags int, err error) { + return 0, 0, 0, syscall.ENOSYS +} + +func (fd *netFD) readMsgInet6(p []byte, oob []byte, flags int, sa *syscall.SockaddrInet6) (n, oobn, retflags int, err error) { + return 0, 0, 0, syscall.ENOSYS +} + func (fd *netFD) writeMsgInet4(p []byte, oob []byte, sa syscall.SockaddrInet4) (n int, oobn int, err error) { return 0, 0, syscall.ENOSYS } diff --git a/src/net/udpsock_posix.go b/src/net/udpsock_posix.go index 468afbc4dc..2bf6568a95 100644 --- a/src/net/udpsock_posix.go +++ b/src/net/udpsock_posix.go @@ -95,13 +95,15 @@ func (c *UDPConn) readFromAddrPort(b []byte) (n int, addr netip.AddrPort, err er } func (c *UDPConn) readMsg(b, oob []byte) (n, oobn, flags int, addr netip.AddrPort, err error) { - var sa syscall.Sockaddr - n, oobn, flags, sa, err = c.fd.readMsg(b, oob, 0) - switch sa := sa.(type) { - case *syscall.SockaddrInet4: + switch c.fd.family { + case syscall.AF_INET: + var sa syscall.SockaddrInet4 + n, oobn, flags, err = c.fd.readMsgInet4(b, oob, 0, &sa) ip := netip.AddrFrom4(sa.Addr) addr = netip.AddrPortFrom(ip, uint16(sa.Port)) - case *syscall.SockaddrInet6: + case syscall.AF_INET6: + var sa syscall.SockaddrInet6 + n, oobn, flags, err = c.fd.readMsgInet6(b, oob, 0, &sa) ip := netip.AddrFrom16(sa.Addr).WithZone(zoneCache.name(int(sa.ZoneId))) addr = netip.AddrPortFrom(ip, uint16(sa.Port)) } diff --git a/src/syscall/syscall_unix.go b/src/syscall/syscall_unix.go index 8692a65794..56d3cad1d0 100644 --- a/src/syscall/syscall_unix.go +++ b/src/syscall/syscall_unix.go @@ -324,6 +324,33 @@ func recvfromInet6(fd int, p []byte, flags int, from *SockaddrInet6) (n int, err return } +func recvmsgInet4(fd int, p, oob []byte, flags int, from *SockaddrInet4) (n, oobn int, recvflags int, err error) { + var rsa RawSockaddrAny + n, oobn, recvflags, err = recvmsgRaw(fd, p, oob, flags, &rsa) + if err != nil { + return + } + pp := (*RawSockaddrInet4)(unsafe.Pointer(&rsa)) + port := (*[2]byte)(unsafe.Pointer(&pp.Port)) + from.Port = int(port[0])<<8 + int(port[1]) + from.Addr = pp.Addr + return +} + +func recvmsgInet6(fd int, p, oob []byte, flags int, from *SockaddrInet6) (n, oobn int, recvflags int, err error) { + var rsa RawSockaddrAny + n, oobn, recvflags, err = recvmsgRaw(fd, p, oob, flags, &rsa) + if err != nil { + return + } + pp := (*RawSockaddrInet6)(unsafe.Pointer(&rsa)) + port := (*[2]byte)(unsafe.Pointer(&pp.Port)) + from.Port = int(port[0])<<8 + int(port[1]) + from.ZoneId = pp.Scope_id + from.Addr = pp.Addr + return +} + func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { var rsa RawSockaddrAny n, oobn, recvflags, err = recvmsgRaw(fd, p, oob, flags, &rsa) From 8ad0a7e7853ffea6140e942ea5f553061d3423c2 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 3 Nov 2021 16:28:47 -0700 Subject: [PATCH 390/406] net: pass around pointers to SockaddrInetN ...instead of the structs themselves. Escape analysis can handle this, and it'll avoid a bunch of large struct copies. Change-Id: Ia9c6064ed32a4c26d5a96dae2ed7d7ece6d38704 Reviewed-on: https://go-review.googlesource.com/c/go/+/361264 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/internal/poll/fd_unix.go | 8 +++--- src/internal/poll/fd_windows.go | 30 +++++++++------------ src/internal/syscall/unix/net.go | 8 +++--- src/internal/syscall/unix/net_js.go | 8 +++--- src/internal/syscall/windows/net_windows.go | 4 +-- src/net/fd_posix.go | 8 +++--- src/net/net_fake.go | 8 +++--- src/net/udpsock_posix.go | 12 ++++----- src/syscall/syscall_unix.go | 8 +++--- src/syscall/syscall_windows.go | 4 +-- 10 files changed, 46 insertions(+), 52 deletions(-) diff --git a/src/internal/poll/fd_unix.go b/src/internal/poll/fd_unix.go index 45d4ce07b2..85971a16cd 100644 --- a/src/internal/poll/fd_unix.go +++ b/src/internal/poll/fd_unix.go @@ -436,7 +436,7 @@ func (fd *FD) Pwrite(p []byte, off int64) (int, error) { } // WriteToInet4 wraps the sendto network call for IPv4 addresses. -func (fd *FD) WriteToInet4(p []byte, sa syscall.SockaddrInet4) (int, error) { +func (fd *FD) WriteToInet4(p []byte, sa *syscall.SockaddrInet4) (int, error) { if err := fd.writeLock(); err != nil { return 0, err } @@ -462,7 +462,7 @@ func (fd *FD) WriteToInet4(p []byte, sa syscall.SockaddrInet4) (int, error) { } // WriteToInet6 wraps the sendto network call for IPv6 addresses. -func (fd *FD) WriteToInet6(p []byte, sa syscall.SockaddrInet6) (int, error) { +func (fd *FD) WriteToInet6(p []byte, sa *syscall.SockaddrInet6) (int, error) { if err := fd.writeLock(); err != nil { return 0, err } @@ -540,7 +540,7 @@ func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, err } // WriteMsgInet4 is WriteMsg specialized for syscall.SockaddrInet4. -func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa syscall.SockaddrInet4) (int, int, error) { +func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa *syscall.SockaddrInet4) (int, int, error) { if err := fd.writeLock(); err != nil { return 0, 0, err } @@ -566,7 +566,7 @@ func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa syscall.SockaddrInet4) (int } // WriteMsgInet6 is WriteMsg specialized for syscall.SockaddrInet6. -func (fd *FD) WriteMsgInet6(p []byte, oob []byte, sa syscall.SockaddrInet6) (int, int, error) { +func (fd *FD) WriteMsgInet6(p []byte, oob []byte, sa *syscall.SockaddrInet6) (int, int, error) { if err := fd.writeLock(); err != nil { return 0, 0, err } diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go index 4dd5986efd..94cdfca601 100644 --- a/src/internal/poll/fd_windows.go +++ b/src/internal/poll/fd_windows.go @@ -79,8 +79,6 @@ type operation struct { buf syscall.WSABuf msg windows.WSAMsg sa syscall.Sockaddr - sa4 syscall.SockaddrInet4 - sa6 syscall.SockaddrInet6 rsa *syscall.RawSockaddrAny rsan int32 handle syscall.Handle @@ -852,7 +850,7 @@ func (fd *FD) WriteTo(buf []byte, sa syscall.Sockaddr) (int, error) { } // WriteToInet4 is WriteTo, specialized for syscall.SockaddrInet4. -func (fd *FD) WriteToInet4(buf []byte, sa4 syscall.SockaddrInet4) (int, error) { +func (fd *FD) WriteToInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error) { if err := fd.writeLock(); err != nil { return 0, err } @@ -862,9 +860,8 @@ func (fd *FD) WriteToInet4(buf []byte, sa4 syscall.SockaddrInet4) (int, error) { // handle zero-byte payload o := &fd.wop o.InitBuf(buf) - o.sa4 = sa4 n, err := execIO(o, func(o *operation) error { - return windows.WSASendtoInet4(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa4, &o.o, nil) + return windows.WSASendtoInet4(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, sa4, &o.o, nil) }) return n, err } @@ -877,9 +874,8 @@ func (fd *FD) WriteToInet4(buf []byte, sa4 syscall.SockaddrInet4) (int, error) { } o := &fd.wop o.InitBuf(b) - o.sa4 = sa4 n, err := execIO(o, func(o *operation) error { - return windows.WSASendtoInet4(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa4, &o.o, nil) + return windows.WSASendtoInet4(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, sa4, &o.o, nil) }) ntotal += int(n) if err != nil { @@ -891,7 +887,7 @@ func (fd *FD) WriteToInet4(buf []byte, sa4 syscall.SockaddrInet4) (int, error) { } // WriteToInet6 is WriteTo, specialized for syscall.SockaddrInet6. -func (fd *FD) WriteToInet6(buf []byte, sa6 syscall.SockaddrInet6) (int, error) { +func (fd *FD) WriteToInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error) { if err := fd.writeLock(); err != nil { return 0, err } @@ -901,9 +897,8 @@ func (fd *FD) WriteToInet6(buf []byte, sa6 syscall.SockaddrInet6) (int, error) { // handle zero-byte payload o := &fd.wop o.InitBuf(buf) - o.sa6 = sa6 n, err := execIO(o, func(o *operation) error { - return windows.WSASendtoInet6(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa6, &o.o, nil) + return windows.WSASendtoInet6(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, sa6, &o.o, nil) }) return n, err } @@ -916,9 +911,8 @@ func (fd *FD) WriteToInet6(buf []byte, sa6 syscall.SockaddrInet6) (int, error) { } o := &fd.wop o.InitBuf(b) - o.sa6 = sa6 n, err := execIO(o, func(o *operation) error { - return windows.WSASendtoInet6(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa6, &o.o, nil) + return windows.WSASendtoInet6(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, sa6, &o.o, nil) }) ntotal += int(n) if err != nil { @@ -1122,7 +1116,7 @@ func (fd *FD) RawWrite(f func(uintptr) bool) error { return syscall.EWINDOWS } -func sockaddrInet4ToRaw(sa syscall.SockaddrInet4) (unsafe.Pointer, int32) { +func sockaddrInet4ToRaw(sa *syscall.SockaddrInet4) (unsafe.Pointer, int32) { var raw syscall.RawSockaddrInet4 raw.Family = syscall.AF_INET p := (*[2]byte)(unsafe.Pointer(&raw.Port)) @@ -1132,7 +1126,7 @@ func sockaddrInet4ToRaw(sa syscall.SockaddrInet4) (unsafe.Pointer, int32) { return unsafe.Pointer(&raw), int32(unsafe.Sizeof(raw)) } -func sockaddrInet6ToRaw(sa syscall.SockaddrInet6) (unsafe.Pointer, int32) { +func sockaddrInet6ToRaw(sa *syscall.SockaddrInet6) (unsafe.Pointer, int32) { var raw syscall.RawSockaddrInet6 raw.Family = syscall.AF_INET6 p := (*[2]byte)(unsafe.Pointer(&raw.Port)) @@ -1161,10 +1155,10 @@ func rawToSockaddrInet6(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet6) func sockaddrToRaw(sa syscall.Sockaddr) (unsafe.Pointer, int32, error) { switch sa := sa.(type) { case *syscall.SockaddrInet4: - ptr, sz := sockaddrInet4ToRaw(*sa) + ptr, sz := sockaddrInet4ToRaw(sa) return ptr, sz, nil case *syscall.SockaddrInet6: - ptr, sz := sockaddrInet6ToRaw(*sa) + ptr, sz := sockaddrInet6ToRaw(sa) return ptr, sz, nil default: return nil, 0, syscall.EWINDOWS @@ -1281,7 +1275,7 @@ func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, err } // WriteMsgInet4 is WriteMsg specialized for syscall.SockaddrInet4. -func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa syscall.SockaddrInet4) (int, int, error) { +func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa *syscall.SockaddrInet4) (int, int, error) { if len(p) > maxRW { return 0, 0, errors.New("packet is too large (only 1GB is allowed)") } @@ -1303,7 +1297,7 @@ func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa syscall.SockaddrInet4) (int } // WriteMsgInet6 is WriteMsg specialized for syscall.SockaddrInet6. -func (fd *FD) WriteMsgInet6(p []byte, oob []byte, sa syscall.SockaddrInet6) (int, int, error) { +func (fd *FD) WriteMsgInet6(p []byte, oob []byte, sa *syscall.SockaddrInet6) (int, int, error) { if len(p) > maxRW { return 0, 0, errors.New("packet is too large (only 1GB is allowed)") } diff --git a/src/internal/syscall/unix/net.go b/src/internal/syscall/unix/net.go index 87ce89b57f..85632e1c03 100644 --- a/src/internal/syscall/unix/net.go +++ b/src/internal/syscall/unix/net.go @@ -21,19 +21,19 @@ func RecvfromInet6(fd int, p []byte, flags int, from *syscall.SockaddrInet6) (n //go:linkname SendtoInet4 syscall.sendtoInet4 //go:noescape -func SendtoInet4(fd int, p []byte, flags int, to syscall.SockaddrInet4) (err error) +func SendtoInet4(fd int, p []byte, flags int, to *syscall.SockaddrInet4) (err error) //go:linkname SendtoInet6 syscall.sendtoInet6 //go:noescape -func SendtoInet6(fd int, p []byte, flags int, to syscall.SockaddrInet6) (err error) +func SendtoInet6(fd int, p []byte, flags int, to *syscall.SockaddrInet6) (err error) //go:linkname SendmsgNInet4 syscall.sendmsgNInet4 //go:noescape -func SendmsgNInet4(fd int, p, oob []byte, to syscall.SockaddrInet4, flags int) (n int, err error) +func SendmsgNInet4(fd int, p, oob []byte, to *syscall.SockaddrInet4, flags int) (n int, err error) //go:linkname SendmsgNInet6 syscall.sendmsgNInet6 //go:noescape -func SendmsgNInet6(fd int, p, oob []byte, to syscall.SockaddrInet6, flags int) (n int, err error) +func SendmsgNInet6(fd int, p, oob []byte, to *syscall.SockaddrInet6, flags int) (n int, err error) //go:linkname RecvmsgInet4 syscall.recvmsgInet4 //go:noescape diff --git a/src/internal/syscall/unix/net_js.go b/src/internal/syscall/unix/net_js.go index defc3f6fb2..622fc8eb14 100644 --- a/src/internal/syscall/unix/net_js.go +++ b/src/internal/syscall/unix/net_js.go @@ -19,19 +19,19 @@ func RecvfromInet6(fd int, p []byte, flags int, from *syscall.SockaddrInet6) (n return 0, syscall.ENOSYS } -func SendtoInet4(fd int, p []byte, flags int, to syscall.SockaddrInet4) (err error) { +func SendtoInet4(fd int, p []byte, flags int, to *syscall.SockaddrInet4) (err error) { return syscall.ENOSYS } -func SendtoInet6(fd int, p []byte, flags int, to syscall.SockaddrInet6) (err error) { +func SendtoInet6(fd int, p []byte, flags int, to *syscall.SockaddrInet6) (err error) { return syscall.ENOSYS } -func SendmsgNInet4(fd int, p, oob []byte, to syscall.SockaddrInet4, flags int) (n int, err error) { +func SendmsgNInet4(fd int, p, oob []byte, to *syscall.SockaddrInet4, flags int) (n int, err error) { return 0, syscall.ENOSYS } -func SendmsgNInet6(fd int, p, oob []byte, to syscall.SockaddrInet6, flags int) (n int, err error) { +func SendmsgNInet6(fd int, p, oob []byte, to *syscall.SockaddrInet6, flags int) (n int, err error) { return 0, syscall.ENOSYS } diff --git a/src/internal/syscall/windows/net_windows.go b/src/internal/syscall/windows/net_windows.go index 1fccd55e4b..3d3df7161c 100644 --- a/src/internal/syscall/windows/net_windows.go +++ b/src/internal/syscall/windows/net_windows.go @@ -11,8 +11,8 @@ import ( //go:linkname WSASendtoInet4 syscall.wsaSendtoInet4 //go:noescape -func WSASendtoInet4(s syscall.Handle, bufs *syscall.WSABuf, bufcnt uint32, sent *uint32, flags uint32, to syscall.SockaddrInet4, overlapped *syscall.Overlapped, croutine *byte) (err error) +func WSASendtoInet4(s syscall.Handle, bufs *syscall.WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *syscall.SockaddrInet4, overlapped *syscall.Overlapped, croutine *byte) (err error) //go:linkname WSASendtoInet6 syscall.wsaSendtoInet6 //go:noescape -func WSASendtoInet6(s syscall.Handle, bufs *syscall.WSABuf, bufcnt uint32, sent *uint32, flags uint32, to syscall.SockaddrInet6, overlapped *syscall.Overlapped, croutine *byte) (err error) +func WSASendtoInet6(s syscall.Handle, bufs *syscall.WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *syscall.SockaddrInet6, overlapped *syscall.Overlapped, croutine *byte) (err error) diff --git a/src/net/fd_posix.go b/src/net/fd_posix.go index d12dbeebd2..1845c173bb 100644 --- a/src/net/fd_posix.go +++ b/src/net/fd_posix.go @@ -104,13 +104,13 @@ func (fd *netFD) writeTo(p []byte, sa syscall.Sockaddr) (n int, err error) { return n, wrapSyscallError(writeToSyscallName, err) } -func (fd *netFD) writeToInet4(p []byte, sa syscall.SockaddrInet4) (n int, err error) { +func (fd *netFD) writeToInet4(p []byte, sa *syscall.SockaddrInet4) (n int, err error) { n, err = fd.pfd.WriteToInet4(p, sa) runtime.KeepAlive(fd) return n, wrapSyscallError(writeToSyscallName, err) } -func (fd *netFD) writeToInet6(p []byte, sa syscall.SockaddrInet6) (n int, err error) { +func (fd *netFD) writeToInet6(p []byte, sa *syscall.SockaddrInet6) (n int, err error) { n, err = fd.pfd.WriteToInet6(p, sa) runtime.KeepAlive(fd) return n, wrapSyscallError(writeToSyscallName, err) @@ -122,13 +122,13 @@ func (fd *netFD) writeMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oob return n, oobn, wrapSyscallError(writeMsgSyscallName, err) } -func (fd *netFD) writeMsgInet4(p []byte, oob []byte, sa syscall.SockaddrInet4) (n int, oobn int, err error) { +func (fd *netFD) writeMsgInet4(p []byte, oob []byte, sa *syscall.SockaddrInet4) (n int, oobn int, err error) { n, oobn, err = fd.pfd.WriteMsgInet4(p, oob, sa) runtime.KeepAlive(fd) return n, oobn, wrapSyscallError(writeMsgSyscallName, err) } -func (fd *netFD) writeMsgInet6(p []byte, oob []byte, sa syscall.SockaddrInet6) (n int, oobn int, err error) { +func (fd *netFD) writeMsgInet6(p []byte, oob []byte, sa *syscall.SockaddrInet6) (n int, oobn int, err error) { n, oobn, err = fd.pfd.WriteMsgInet6(p, oob, sa) runtime.KeepAlive(fd) return n, oobn, wrapSyscallError(writeMsgSyscallName, err) diff --git a/src/net/net_fake.go b/src/net/net_fake.go index 8da9d15bb2..ee5644c67f 100644 --- a/src/net/net_fake.go +++ b/src/net/net_fake.go @@ -287,11 +287,11 @@ func (fd *netFD) readMsgInet6(p []byte, oob []byte, flags int, sa *syscall.Socka return 0, 0, 0, syscall.ENOSYS } -func (fd *netFD) writeMsgInet4(p []byte, oob []byte, sa syscall.SockaddrInet4) (n int, oobn int, err error) { +func (fd *netFD) writeMsgInet4(p []byte, oob []byte, sa *syscall.SockaddrInet4) (n int, oobn int, err error) { return 0, 0, syscall.ENOSYS } -func (fd *netFD) writeMsgInet6(p []byte, oob []byte, sa syscall.SockaddrInet6) (n int, oobn int, err error) { +func (fd *netFD) writeMsgInet6(p []byte, oob []byte, sa *syscall.SockaddrInet6) (n int, oobn int, err error) { return 0, 0, syscall.ENOSYS } @@ -299,11 +299,11 @@ func (fd *netFD) writeTo(p []byte, sa syscall.Sockaddr) (n int, err error) { return 0, syscall.ENOSYS } -func (fd *netFD) writeToInet4(p []byte, sa syscall.SockaddrInet4) (n int, err error) { +func (fd *netFD) writeToInet4(p []byte, sa *syscall.SockaddrInet4) (n int, err error) { return 0, syscall.ENOSYS } -func (fd *netFD) writeToInet6(p []byte, sa syscall.SockaddrInet6) (n int, err error) { +func (fd *netFD) writeToInet6(p []byte, sa *syscall.SockaddrInet6) (n int, err error) { return 0, syscall.ENOSYS } diff --git a/src/net/udpsock_posix.go b/src/net/udpsock_posix.go index 2bf6568a95..6544397673 100644 --- a/src/net/udpsock_posix.go +++ b/src/net/udpsock_posix.go @@ -124,13 +124,13 @@ func (c *UDPConn) writeTo(b []byte, addr *UDPAddr) (int, error) { if err != nil { return 0, err } - return c.fd.writeToInet4(b, sa) + return c.fd.writeToInet4(b, &sa) case syscall.AF_INET6: sa, err := ipToSockaddrInet6(addr.IP, addr.Port, addr.Zone) if err != nil { return 0, err } - return c.fd.writeToInet6(b, sa) + return c.fd.writeToInet6(b, &sa) default: return 0, &AddrError{Err: "invalid address family", Addr: addr.IP.String()} } @@ -150,13 +150,13 @@ func (c *UDPConn) writeToAddrPort(b []byte, addr netip.AddrPort) (int, error) { if err != nil { return 0, err } - return c.fd.writeToInet4(b, sa) + return c.fd.writeToInet4(b, &sa) case syscall.AF_INET6: sa, err := addrPortToSockaddrInet6(addr) if err != nil { return 0, err } - return c.fd.writeToInet6(b, sa) + return c.fd.writeToInet6(b, &sa) default: return 0, &AddrError{Err: "invalid address family", Addr: addr.Addr().String()} } @@ -190,13 +190,13 @@ func (c *UDPConn) writeMsgAddrPort(b, oob []byte, addr netip.AddrPort) (n, oobn if err != nil { return 0, 0, err } - return c.fd.writeMsgInet4(b, oob, sa) + return c.fd.writeMsgInet4(b, oob, &sa) case syscall.AF_INET6: sa, err := addrPortToSockaddrInet6(addr) if err != nil { return 0, 0, err } - return c.fd.writeMsgInet6(b, oob, sa) + return c.fd.writeMsgInet6(b, oob, &sa) default: return 0, 0, &AddrError{Err: "invalid address family", Addr: addr.Addr().String()} } diff --git a/src/syscall/syscall_unix.go b/src/syscall/syscall_unix.go index 56d3cad1d0..5ee938115d 100644 --- a/src/syscall/syscall_unix.go +++ b/src/syscall/syscall_unix.go @@ -378,7 +378,7 @@ func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) return sendmsgN(fd, p, oob, ptr, salen, flags) } -func sendmsgNInet4(fd int, p, oob []byte, to SockaddrInet4, flags int) (n int, err error) { +func sendmsgNInet4(fd int, p, oob []byte, to *SockaddrInet4, flags int) (n int, err error) { ptr, salen, err := to.sockaddr() if err != nil { return 0, err @@ -386,7 +386,7 @@ func sendmsgNInet4(fd int, p, oob []byte, to SockaddrInet4, flags int) (n int, e return sendmsgN(fd, p, oob, ptr, salen, flags) } -func sendmsgNInet6(fd int, p, oob []byte, to SockaddrInet6, flags int) (n int, err error) { +func sendmsgNInet6(fd int, p, oob []byte, to *SockaddrInet6, flags int) (n int, err error) { ptr, salen, err := to.sockaddr() if err != nil { return 0, err @@ -394,7 +394,7 @@ func sendmsgNInet6(fd int, p, oob []byte, to SockaddrInet6, flags int) (n int, e return sendmsgN(fd, p, oob, ptr, salen, flags) } -func sendtoInet4(fd int, p []byte, flags int, to SockaddrInet4) (err error) { +func sendtoInet4(fd int, p []byte, flags int, to *SockaddrInet4) (err error) { ptr, n, err := to.sockaddr() if err != nil { return err @@ -402,7 +402,7 @@ func sendtoInet4(fd int, p []byte, flags int, to SockaddrInet4) (err error) { return sendto(fd, p, flags, ptr, n) } -func sendtoInet6(fd int, p []byte, flags int, to SockaddrInet6) (err error) { +func sendtoInet6(fd int, p []byte, flags int, to *SockaddrInet6) (err error) { ptr, n, err := to.sockaddr() if err != nil { return err diff --git a/src/syscall/syscall_windows.go b/src/syscall/syscall_windows.go index 69e163e00f..ecb1eeecf6 100644 --- a/src/syscall/syscall_windows.go +++ b/src/syscall/syscall_windows.go @@ -922,7 +922,7 @@ func WSASendto(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32 return err } -func wsaSendtoInet4(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to SockaddrInet4, overlapped *Overlapped, croutine *byte) (err error) { +func wsaSendtoInet4(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *SockaddrInet4, overlapped *Overlapped, croutine *byte) (err error) { rsa, len, err := to.sockaddr() if err != nil { return err @@ -938,7 +938,7 @@ func wsaSendtoInet4(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags u return err } -func wsaSendtoInet6(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to SockaddrInet6, overlapped *Overlapped, croutine *byte) (err error) { +func wsaSendtoInet6(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *SockaddrInet6, overlapped *Overlapped, croutine *byte) (err error) { rsa, len, err := to.sockaddr() if err != nil { return err From 1e0c3b28777420e5af73f40d4cad691ad8c43513 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Thu, 4 Nov 2021 12:19:04 -0700 Subject: [PATCH 391/406] internal/poll: re-use RawSockaddrAny buffers across requests on windows We were re-allocating a new RawSockaddrAny on every UDP read/write. We can re-use them instead. This reduces the number of allocs for UDP read/write on windows to zero. Co-authored-by: David Crawshaw Change-Id: I2f05c974e2e7b4f67937ae4e1c99583e81d140af Reviewed-on: https://go-review.googlesource.com/c/go/+/361404 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/internal/poll/fd_windows.go | 59 +++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go index 94cdfca601..0d8bf87992 100644 --- a/src/internal/poll/fd_windows.go +++ b/src/internal/poll/fd_windows.go @@ -1116,25 +1116,27 @@ func (fd *FD) RawWrite(f func(uintptr) bool) error { return syscall.EWINDOWS } -func sockaddrInet4ToRaw(sa *syscall.SockaddrInet4) (unsafe.Pointer, int32) { - var raw syscall.RawSockaddrInet4 +func sockaddrInet4ToRaw(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet4) int32 { + *rsa = syscall.RawSockaddrAny{} + raw := (*syscall.RawSockaddrInet4)(unsafe.Pointer(rsa)) raw.Family = syscall.AF_INET p := (*[2]byte)(unsafe.Pointer(&raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) raw.Addr = sa.Addr - return unsafe.Pointer(&raw), int32(unsafe.Sizeof(raw)) + return int32(unsafe.Sizeof(*raw)) } -func sockaddrInet6ToRaw(sa *syscall.SockaddrInet6) (unsafe.Pointer, int32) { - var raw syscall.RawSockaddrInet6 +func sockaddrInet6ToRaw(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet6) int32 { + *rsa = syscall.RawSockaddrAny{} + raw := (*syscall.RawSockaddrInet6)(unsafe.Pointer(rsa)) raw.Family = syscall.AF_INET6 p := (*[2]byte)(unsafe.Pointer(&raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) raw.Scope_id = sa.ZoneId raw.Addr = sa.Addr - return unsafe.Pointer(&raw), int32(unsafe.Sizeof(raw)) + return int32(unsafe.Sizeof(*raw)) } func rawToSockaddrInet4(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet4) { @@ -1152,16 +1154,16 @@ func rawToSockaddrInet6(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet6) sa.Addr = pp.Addr } -func sockaddrToRaw(sa syscall.Sockaddr) (unsafe.Pointer, int32, error) { +func sockaddrToRaw(rsa *syscall.RawSockaddrAny, sa syscall.Sockaddr) (int32, error) { switch sa := sa.(type) { case *syscall.SockaddrInet4: - ptr, sz := sockaddrInet4ToRaw(sa) - return ptr, sz, nil + sz := sockaddrInet4ToRaw(rsa, sa) + return sz, nil case *syscall.SockaddrInet6: - ptr, sz := sockaddrInet6ToRaw(sa) - return ptr, sz, nil + sz := sockaddrInet6ToRaw(rsa, sa) + return sz, nil default: - return nil, 0, syscall.EWINDOWS + return 0, syscall.EWINDOWS } } @@ -1178,7 +1180,9 @@ func (fd *FD) ReadMsg(p []byte, oob []byte, flags int) (int, int, int, syscall.S o := &fd.rop o.InitMsg(p, oob) - o.rsa = new(syscall.RawSockaddrAny) + if o.rsa == nil { + o.rsa = new(syscall.RawSockaddrAny) + } o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) o.msg.Namelen = int32(unsafe.Sizeof(*o.rsa)) o.msg.Flags = uint32(flags) @@ -1206,7 +1210,9 @@ func (fd *FD) ReadMsgInet4(p []byte, oob []byte, flags int, sa4 *syscall.Sockadd o := &fd.rop o.InitMsg(p, oob) - o.rsa = new(syscall.RawSockaddrAny) + if o.rsa == nil { + o.rsa = new(syscall.RawSockaddrAny) + } o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) o.msg.Namelen = int32(unsafe.Sizeof(*o.rsa)) o.msg.Flags = uint32(flags) @@ -1233,7 +1239,9 @@ func (fd *FD) ReadMsgInet6(p []byte, oob []byte, flags int, sa6 *syscall.Sockadd o := &fd.rop o.InitMsg(p, oob) - o.rsa = new(syscall.RawSockaddrAny) + if o.rsa == nil { + o.rsa = new(syscall.RawSockaddrAny) + } o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) o.msg.Namelen = int32(unsafe.Sizeof(*o.rsa)) o.msg.Flags = uint32(flags) @@ -1261,11 +1269,14 @@ func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, err o := &fd.wop o.InitMsg(p, oob) if sa != nil { - rsa, len, err := sockaddrToRaw(sa) + if o.rsa == nil { + o.rsa = new(syscall.RawSockaddrAny) + } + len, err := sockaddrToRaw(o.rsa, sa) if err != nil { return 0, 0, err } - o.msg.Name = (syscall.Pointer)(rsa) + o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) o.msg.Namelen = len } n, err := execIO(o, func(o *operation) error { @@ -1287,8 +1298,11 @@ func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa *syscall.SockaddrInet4) (in o := &fd.wop o.InitMsg(p, oob) - rsa, len := sockaddrInet4ToRaw(sa) - o.msg.Name = (syscall.Pointer)(rsa) + if o.rsa == nil { + o.rsa = new(syscall.RawSockaddrAny) + } + len := sockaddrInet4ToRaw(o.rsa, sa) + o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) o.msg.Namelen = len n, err := execIO(o, func(o *operation) error { return windows.WSASendMsg(o.fd.Sysfd, &o.msg, 0, &o.qty, &o.o, nil) @@ -1309,8 +1323,11 @@ func (fd *FD) WriteMsgInet6(p []byte, oob []byte, sa *syscall.SockaddrInet6) (in o := &fd.wop o.InitMsg(p, oob) - rsa, len := sockaddrInet6ToRaw(sa) - o.msg.Name = (syscall.Pointer)(rsa) + if o.rsa == nil { + o.rsa = new(syscall.RawSockaddrAny) + } + len := sockaddrInet6ToRaw(o.rsa, sa) + o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) o.msg.Namelen = len n, err := execIO(o, func(o *operation) error { return windows.WSASendMsg(o.fd.Sysfd, &o.msg, 0, &o.qty, &o.o, nil) From 76c48e9346bba98689e059aaee5952c17d45a48c Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Thu, 4 Nov 2021 11:33:39 -0700 Subject: [PATCH 392/406] net: add UDP allocs test Change-Id: Ibefd1ca0236d17d57fc5aa5938a56ae92272ca60 Reviewed-on: https://go-review.googlesource.com/c/go/+/361396 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/net/udpsock_test.go | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/net/udpsock_test.go b/src/net/udpsock_test.go index 7eef6f64af..518c66c331 100644 --- a/src/net/udpsock_test.go +++ b/src/net/udpsock_test.go @@ -474,6 +474,59 @@ func TestUDPReadTimeout(t *testing.T) { } } +func TestAllocs(t *testing.T) { + conn, err := ListenUDP("udp4", &UDPAddr{IP: IPv4(127, 0, 0, 1)}) + if err != nil { + t.Fatal(err) + } + defer conn.Close() + addr := conn.LocalAddr() + addrPort := addr.(*UDPAddr).AddrPort() + buf := make([]byte, 8) + + allocs := testing.AllocsPerRun(1000, func() { + _, _, err := conn.WriteMsgUDPAddrPort(buf, nil, addrPort) + if err != nil { + t.Fatal(err) + } + _, _, _, _, err = conn.ReadMsgUDPAddrPort(buf, nil) + if err != nil { + t.Fatal(err) + } + }) + if got := int(allocs); got != 0 { + t.Errorf("WriteMsgUDPAddrPort/ReadMsgUDPAddrPort allocated %d objects", got) + } + + allocs = testing.AllocsPerRun(1000, func() { + _, err := conn.WriteToUDPAddrPort(buf, addrPort) + if err != nil { + t.Fatal(err) + } + _, _, err = conn.ReadFromUDPAddrPort(buf) + if err != nil { + t.Fatal(err) + } + }) + if got := int(allocs); got != 0 { + t.Errorf("WriteToUDPAddrPort/ReadFromUDPAddrPort allocated %d objects", got) + } + + allocs = testing.AllocsPerRun(1000, func() { + _, err := conn.WriteTo(buf, addr) + if err != nil { + t.Fatal(err) + } + _, _, err = conn.ReadFromUDP(buf) + if err != nil { + t.Fatal(err) + } + }) + if got := int(allocs); got != 1 { + t.Errorf("WriteTo/ReadFromUDP allocated %d objects", got) + } +} + func BenchmarkReadWriteMsgUDPAddrPort(b *testing.B) { conn, err := ListenUDP("udp4", &UDPAddr{IP: IPv4(127, 0, 0, 1)}) if err != nil { From 256a8fc6ef297f2a2cec0cb7c918f61706b6f9a3 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Thu, 4 Nov 2021 23:13:12 +0000 Subject: [PATCH 393/406] sync/atomic: disable GC during TestHammerStoreLoad TestHammerStoreLoad involves a stress test of StorePointer, which has a write barrier. The "pointer" that is being written is not a real value, which is generally fine (though not *really* safe) on 64-bit systems because they never point to an actual object. On 32-bit systems, however, this is much more likely. Because I can't figure out how to rewrite the test such that it still is testing the same conditions but is also using real pointers, just disable the GC during the test, and make sure there isn't one currently in progress. Fixes #49362. Change-Id: If81883fedf06568132e6484f40c820aa69027a9c Reviewed-on: https://go-review.googlesource.com/c/go/+/361455 Trust: Michael Knyszek Run-TryBot: Michael Knyszek Reviewed-by: Ian Lance Taylor TryBot-Result: Go Bot --- src/sync/atomic/atomic_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sync/atomic/atomic_test.go b/src/sync/atomic/atomic_test.go index eadc962f70..4b8c2a58f3 100644 --- a/src/sync/atomic/atomic_test.go +++ b/src/sync/atomic/atomic_test.go @@ -7,6 +7,7 @@ package atomic_test import ( "fmt" "runtime" + "runtime/debug" "strings" . "sync/atomic" "testing" @@ -1196,6 +1197,11 @@ func TestHammerStoreLoad(t *testing.T) { } const procs = 8 defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(procs)) + // Disable the GC because hammerStoreLoadPointer invokes + // write barriers on values that aren't real pointers. + defer debug.SetGCPercent(debug.SetGCPercent(-1)) + // Ensure any in-progress GC is finished. + runtime.GC() for _, tt := range tests { c := make(chan int) var val uint64 From 0e5f287fde7b2cf11c8cffb7839f970a8f3e2f9b Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 5 Nov 2021 00:10:31 +0100 Subject: [PATCH 394/406] runtime: use correct constant when computing nsec remainder A code comment on amd64 for windows and plan9 contained a snippet for splitting apart the sec and nsec components of a unix timestamp, with produced assembly below, which was then cleaned up by hand. When arm64 was ported, that code snippet in the comment went through the compiler to produce some code that was then pasted and cleaned up. Unfortunately, the comment had a typo in it, containing 8 zeros instead of 9. This resulted in the constant used in the assembly being wrong, spotted by @bufflig's eagle eyes. So, this commit fixes the comment on all three platforms, and the assembly on windows/arm64. Fixes #48072. Change-Id: I786fe89147328b0d25544f52c927ddfdb9f6f1cf Reviewed-on: https://go-review.googlesource.com/c/go/+/361474 Trust: Jason A. Donenfeld Run-TryBot: Jason A. Donenfeld Reviewed-by: Patrik Nyblom TryBot-Result: Go Bot --- src/runtime/sys_plan9_amd64.s | 2 +- src/runtime/time_windows_amd64.s | 2 +- src/runtime/time_windows_arm64.s | 9 +++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/runtime/sys_plan9_amd64.s b/src/runtime/sys_plan9_amd64.s index 39fc4c68e4..638300dfb9 100644 --- a/src/runtime/sys_plan9_amd64.s +++ b/src/runtime/sys_plan9_amd64.s @@ -94,7 +94,7 @@ TEXT runtime·walltime(SB),NOSPLIT,$8-12 MOVQ 0(SP), AX // generated code for - // func f(x uint64) (uint64, uint64) { return x/1000000000, x%100000000 } + // func f(x uint64) (uint64, uint64) { return x/1000000000, x%1000000000 } // adapted to reduce duplication MOVQ AX, CX MOVQ $1360296554856532783, AX diff --git a/src/runtime/time_windows_amd64.s b/src/runtime/time_windows_amd64.s index 045f64eb46..70f6a008cd 100644 --- a/src/runtime/time_windows_amd64.s +++ b/src/runtime/time_windows_amd64.s @@ -25,7 +25,7 @@ TEXT time·now(SB),NOSPLIT,$0-24 IMULQ $100, AX // generated code for - // func f(x uint64) (uint64, uint64) { return x/1000000000, x%100000000 } + // func f(x uint64) (uint64, uint64) { return x/1000000000, x%1000000000 } // adapted to reduce duplication MOVQ AX, CX MOVQ $1360296554856532783, AX diff --git a/src/runtime/time_windows_arm64.s b/src/runtime/time_windows_arm64.s index e8a0eb2f93..ef5b848473 100644 --- a/src/runtime/time_windows_arm64.s +++ b/src/runtime/time_windows_arm64.s @@ -32,17 +32,14 @@ TEXT time·now(SB),NOSPLIT|NOFRAME,$0-24 // Code stolen from compiler output for: // // var x uint64 - // func f() (sec uint64, nsec uint32) { return x / 1000000000, uint32(x % 100000000) } + // func f() (sec uint64, nsec uint32) { return x / 1000000000, uint32(x % 1000000000) } // LSR $1, R0, R1 MOVD $-8543223759426509416, R2 - UMULH R2, R1, R1 + UMULH R1, R2, R1 LSR $28, R1, R1 MOVD R1, sec+0(FP) - MOVD $-6067343680855748867, R1 - UMULH R0, R1, R1 - LSR $26, R1, R1 - MOVD $100000000, R2 + MOVD $1000000000, R2 MSUB R1, R0, R2, R0 MOVW R0, nsec+8(FP) RET From 1c4cfd80109da81a2c6cf49b4d3ff49c45af8e03 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 17 Sep 2021 10:07:41 -0400 Subject: [PATCH 395/406] cmd/compile,cmd/internal/objabi: move -d flag parser to objabi This moves and slightly generalizes the -d debug flag parser from cmd/compile/internal/base to cmd/internal/objabi so that we can use the same debug flag syntax in other tools. This makes a few minor tweaks to implementation details. The flag itself is now just a flag.Value that gets constructed explicitly, rather than at init time, and we've cleaned up the implementation a little (e.g., using a map instead of a linear search of a slice). The help text is now automatically alphabetized. Rather than describing the values of some flags in the help text footer, we simply include it in the flags' help text and make sure multi-line help text renders sensibly. For #48297. Change-Id: Id373ee3b767e456be483fb28c110d025149be532 Reviewed-on: https://go-review.googlesource.com/c/go/+/359956 Trust: Austin Clements Run-TryBot: Austin Clements TryBot-Result: Go Bot Reviewed-by: David Chase Reviewed-by: Cherry Mui --- src/cmd/compile/internal/base/debug.go | 146 +--------------------- src/cmd/compile/internal/base/flag.go | 36 +++--- src/cmd/internal/objabi/flag.go | 164 +++++++++++++++++++++++++ 3 files changed, 187 insertions(+), 159 deletions(-) diff --git a/src/cmd/compile/internal/base/debug.go b/src/cmd/compile/internal/base/debug.go index e2245e1c26..37e345bd7f 100644 --- a/src/cmd/compile/internal/base/debug.go +++ b/src/cmd/compile/internal/base/debug.go @@ -6,15 +6,6 @@ package base -import ( - "fmt" - "log" - "os" - "reflect" - "strconv" - "strings" -) - // Debug holds the parsed debugging configuration values. var Debug DebugFlags @@ -26,7 +17,7 @@ var Debug DebugFlags // Each setting is name=value; for ints, name is short for name=1. type DebugFlags struct { Append int `help:"print information about append compilation"` - Checkptr int `help:"instrument unsafe pointer conversions"` + Checkptr int `help:"instrument unsafe pointer conversions\n0: instrumentation disabled\n1: conversions involving unsafe.Pointer are instrumented\n2: conversions to unsafe.Pointer force heap allocation"` Closure int `help:"print information about closure compilation"` DclStack int `help:"run internal dclstack check"` Defer int `help:"print information about defer compilation"` @@ -40,7 +31,7 @@ type DebugFlags struct { LocationLists int `help:"print information about DWARF location list creation"` Nil int `help:"print information about nil checks"` NoOpenDefer int `help:"disable open-coded defers"` - PCTab string `help:"print named pc-value table"` + PCTab string `help:"print named pc-value table\nOne of: pctospadj, pctofile, pctoline, pctoinline, pctopcdata"` Panic int `help:"show all compiler panics"` Slice int `help:"print information about slice compilation"` SoftFloat int `help:"force compiler to emit soft-float code"` @@ -52,141 +43,10 @@ type DebugFlags struct { WB int `help:"print information about write barriers"` ABIWrap int `help:"print information about ABI wrapper generation"` - any bool // set when any of the values have been set -} - -// Any reports whether any of the debug flags have been set. -func (d *DebugFlags) Any() bool { return d.any } - -type debugField struct { - name string - help string - val interface{} // *int or *string -} - -var debugTab []debugField - -func init() { - v := reflect.ValueOf(&Debug).Elem() - t := v.Type() - for i := 0; i < t.NumField(); i++ { - f := t.Field(i) - if f.Name == "any" { - continue - } - name := strings.ToLower(f.Name) - help := f.Tag.Get("help") - if help == "" { - panic(fmt.Sprintf("base.Debug.%s is missing help text", f.Name)) - } - ptr := v.Field(i).Addr().Interface() - switch ptr.(type) { - default: - panic(fmt.Sprintf("base.Debug.%s has invalid type %v (must be int or string)", f.Name, f.Type)) - case *int, *string: - // ok - } - debugTab = append(debugTab, debugField{name, help, ptr}) - } + Any bool // set when any of the debug flags have been set } // DebugSSA is called to set a -d ssa/... option. // If nil, those options are reported as invalid options. // If DebugSSA returns a non-empty string, that text is reported as a compiler error. var DebugSSA func(phase, flag string, val int, valString string) string - -// parseDebug parses the -d debug string argument. -func parseDebug(debugstr string) { - // parse -d argument - if debugstr == "" { - return - } - Debug.any = true -Split: - for _, name := range strings.Split(debugstr, ",") { - if name == "" { - continue - } - // display help about the -d option itself and quit - if name == "help" { - fmt.Print(debugHelpHeader) - maxLen := len("ssa/help") - for _, t := range debugTab { - if len(t.name) > maxLen { - maxLen = len(t.name) - } - } - for _, t := range debugTab { - fmt.Printf("\t%-*s\t%s\n", maxLen, t.name, t.help) - } - // ssa options have their own help - fmt.Printf("\t%-*s\t%s\n", maxLen, "ssa/help", "print help about SSA debugging") - fmt.Print(debugHelpFooter) - os.Exit(0) - } - val, valstring, haveInt := 1, "", true - if i := strings.IndexAny(name, "=:"); i >= 0 { - var err error - name, valstring = name[:i], name[i+1:] - val, err = strconv.Atoi(valstring) - if err != nil { - val, haveInt = 1, false - } - } - for _, t := range debugTab { - if t.name != name { - continue - } - switch vp := t.val.(type) { - case nil: - // Ignore - case *string: - *vp = valstring - case *int: - if !haveInt { - log.Fatalf("invalid debug value %v", name) - } - *vp = val - default: - panic("bad debugtab type") - } - continue Split - } - // special case for ssa for now - if DebugSSA != nil && strings.HasPrefix(name, "ssa/") { - // expect form ssa/phase/flag - // e.g. -d=ssa/generic_cse/time - // _ in phase name also matches space - phase := name[4:] - flag := "debug" // default flag is debug - if i := strings.Index(phase, "/"); i >= 0 { - flag = phase[i+1:] - phase = phase[:i] - } - err := DebugSSA(phase, flag, val, valstring) - if err != "" { - log.Fatalf(err) - } - continue Split - } - log.Fatalf("unknown debug key -d %s\n", name) - } -} - -const debugHelpHeader = `usage: -d arg[,arg]* and arg is [=] - - is one of: - -` - -const debugHelpFooter = ` - is key-specific. - -Key "checkptr" supports values: - "0": instrumentation disabled - "1": conversions involving unsafe.Pointer are instrumented - "2": conversions to unsafe.Pointer force heap allocation - -Key "pctab" supports values: - "pctospadj", "pctofile", "pctoline", "pctoinline", "pctopcdata" -` diff --git a/src/cmd/compile/internal/base/flag.go b/src/cmd/compile/internal/base/flag.go index 9d630ce97a..f38eaa91c0 100644 --- a/src/cmd/compile/internal/base/flag.go +++ b/src/cmd/compile/internal/base/flag.go @@ -64,19 +64,19 @@ type CmdFlags struct { // V is added by objabi.AddVersionFlag W CountFlag "help:\"debug parse tree after type checking\"" - LowerC int "help:\"concurrency during compilation (1 means no concurrency)\"" - LowerD func(string) "help:\"enable debugging settings; try -d help\"" - LowerE CountFlag "help:\"no limit on number of errors reported\"" - LowerH CountFlag "help:\"halt on error\"" - LowerJ CountFlag "help:\"debug runtime-initialized variables\"" - LowerL CountFlag "help:\"disable inlining\"" - LowerM CountFlag "help:\"print optimization decisions\"" - LowerO string "help:\"write output to `file`\"" - LowerP *string "help:\"set expected package import `path`\"" // &Ctxt.Pkgpath, set below - LowerR CountFlag "help:\"debug generated wrappers\"" - LowerT bool "help:\"enable tracing for debugging the compiler\"" - LowerW CountFlag "help:\"debug type checking\"" - LowerV *bool "help:\"increase debug verbosity\"" + LowerC int "help:\"concurrency during compilation (1 means no concurrency)\"" + LowerD flag.Value "help:\"enable debugging settings; try -d help\"" + LowerE CountFlag "help:\"no limit on number of errors reported\"" + LowerH CountFlag "help:\"halt on error\"" + LowerJ CountFlag "help:\"debug runtime-initialized variables\"" + LowerL CountFlag "help:\"disable inlining\"" + LowerM CountFlag "help:\"print optimization decisions\"" + LowerO string "help:\"write output to `file`\"" + LowerP *string "help:\"set expected package import `path`\"" // &Ctxt.Pkgpath, set below + LowerR CountFlag "help:\"debug generated wrappers\"" + LowerT bool "help:\"enable tracing for debugging the compiler\"" + LowerW CountFlag "help:\"debug type checking\"" + LowerV *bool "help:\"increase debug verbosity\"" // Special characters Percent int "flag:\"%\" help:\"debug non-static initializers\"" @@ -145,7 +145,7 @@ func ParseFlags() { Flag.I = addImportDir Flag.LowerC = 1 - Flag.LowerD = parseDebug + Flag.LowerD = objabi.NewDebugFlag(&Debug, DebugSSA) Flag.LowerP = &Ctxt.Pkgpath Flag.LowerV = &Ctxt.Debugvlog @@ -331,7 +331,11 @@ func registerFlags() { f := v.Field(i).Interface().(func(string)) objabi.Flagfn1(name, help, f) default: - panic(fmt.Sprintf("base.Flag.%s has unexpected type %s", f.Name, f.Type)) + if val, ok := v.Field(i).Interface().(flag.Value); ok { + flag.Var(val, name, help) + } else { + panic(fmt.Sprintf("base.Flag.%s has unexpected type %s", f.Name, f.Type)) + } } } } @@ -359,7 +363,7 @@ func concurrentBackendAllowed() bool { // while writing the object file, and that is non-concurrent. // Adding Debug_vlog, however, causes Debug.S to also print // while flushing the plist, which happens concurrently. - if Ctxt.Debugvlog || Debug.Any() || Flag.Live > 0 { + if Ctxt.Debugvlog || Debug.Any || Flag.Live > 0 { return false } // TODO: Test and delete this condition. diff --git a/src/cmd/internal/objabi/flag.go b/src/cmd/internal/objabi/flag.go index e41fc570b0..f75c054fcb 100644 --- a/src/cmd/internal/objabi/flag.go +++ b/src/cmd/internal/objabi/flag.go @@ -13,6 +13,8 @@ import ( "io/ioutil" "log" "os" + "reflect" + "sort" "strconv" "strings" ) @@ -202,3 +204,165 @@ func DecodeArg(arg string) string { } return b.String() } + +type debugField struct { + name string + help string + val interface{} // *int or *string +} + +type DebugFlag struct { + tab map[string]debugField + any *bool + + debugSSA DebugSSA +} + +// A DebugSSA function is called to set a -d ssa/... option. +// If nil, those options are reported as invalid options. +// If DebugSSA returns a non-empty string, that text is reported as a compiler error. +// If phase is "help", it should print usage information and terminate the process. +type DebugSSA func(phase, flag string, val int, valString string) string + +// NewDebugFlag constructs a DebugFlag for the fields of debug, which +// must be a pointer to a struct. +// +// Each field of *debug is a different value, named for the lower-case of the field name. +// Each field must be an int or string and must have a `help` struct tag. +// There may be an "Any bool" field, which will be set if any debug flags are set. +// +// The returned flag takes a comma-separated list of settings. +// Each setting is name=value; for ints, name is short for name=1. +// +// If debugSSA is non-nil, any debug flags of the form ssa/... will be +// passed to debugSSA for processing. +func NewDebugFlag(debug interface{}, debugSSA DebugSSA) *DebugFlag { + flag := &DebugFlag{ + tab: make(map[string]debugField), + debugSSA: debugSSA, + } + + v := reflect.ValueOf(debug).Elem() + t := v.Type() + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + ptr := v.Field(i).Addr().Interface() + if f.Name == "Any" { + switch ptr := ptr.(type) { + default: + panic("debug.Any must have type bool") + case *bool: + flag.any = ptr + } + continue + } + name := strings.ToLower(f.Name) + help := f.Tag.Get("help") + if help == "" { + panic(fmt.Sprintf("debug.%s is missing help text", f.Name)) + } + switch ptr.(type) { + default: + panic(fmt.Sprintf("debug.%s has invalid type %v (must be int or string)", f.Name, f.Type)) + case *int, *string: + // ok + } + flag.tab[name] = debugField{name, help, ptr} + } + + return flag +} + +func (f *DebugFlag) Set(debugstr string) error { + if debugstr == "" { + return nil + } + if f.any != nil { + *f.any = true + } + for _, name := range strings.Split(debugstr, ",") { + if name == "" { + continue + } + // display help about the debug option itself and quit + if name == "help" { + fmt.Print(debugHelpHeader) + maxLen, names := 0, []string{} + if f.debugSSA != nil { + maxLen = len("ssa/help") + } + for name := range f.tab { + if len(name) > maxLen { + maxLen = len(name) + } + names = append(names, name) + } + sort.Strings(names) + // Indent multi-line help messages. + nl := fmt.Sprintf("\n\t%-*s\t", maxLen, "") + for _, name := range names { + help := f.tab[name].help + fmt.Printf("\t%-*s\t%s\n", maxLen, name, strings.Replace(help, "\n", nl, -1)) + } + if f.debugSSA != nil { + // ssa options have their own help + fmt.Printf("\t%-*s\t%s\n", maxLen, "ssa/help", "print help about SSA debugging") + } + os.Exit(0) + } + + val, valstring, haveInt := 1, "", true + if i := strings.IndexAny(name, "=:"); i >= 0 { + var err error + name, valstring = name[:i], name[i+1:] + val, err = strconv.Atoi(valstring) + if err != nil { + val, haveInt = 1, false + } + } + + if t, ok := f.tab[name]; ok { + switch vp := t.val.(type) { + case nil: + // Ignore + case *string: + *vp = valstring + case *int: + if !haveInt { + log.Fatalf("invalid debug value %v", name) + } + *vp = val + default: + panic("bad debugtab type") + } + } else if f.debugSSA != nil && strings.HasPrefix(name, "ssa/") { + // expect form ssa/phase/flag + // e.g. -d=ssa/generic_cse/time + // _ in phase name also matches space + phase := name[4:] + flag := "debug" // default flag is debug + if i := strings.Index(phase, "/"); i >= 0 { + flag = phase[i+1:] + phase = phase[:i] + } + err := f.debugSSA(phase, flag, val, valstring) + if err != "" { + log.Fatalf(err) + } + } else { + return fmt.Errorf("unknown debug key %s\n", name) + } + } + + return nil +} + +const debugHelpHeader = `usage: -d arg[,arg]* and arg is [=] + + is one of: + +` + +func (f *DebugFlag) String() string { + return "" +} From 3839b6001470f7bc73c9a80f6458f7111ae3d9cc Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 20 Aug 2019 17:39:09 -0400 Subject: [PATCH 396/406] cmd/{asm,compile,internal/obj}: add "maymorestack" support This adds a debugging hook for optionally calling a "maymorestack" function in the prologue of any function that might call morestack (whether it does at run time or not). The maymorestack function will let us improve lock checking and add debugging modes that stress function preemption and stack growth. Passes toolstash-check -all (except on js/wasm, where toolstash appears to be broken) Fixes #48297. Change-Id: I27197947482b329af75dafb9971fc0d3a52eaf31 Reviewed-on: https://go-review.googlesource.com/c/go/+/359795 Trust: Austin Clements Run-TryBot: Austin Clements Reviewed-by: Cherry Mui --- src/cmd/asm/internal/flags/flags.go | 5 ++ src/cmd/asm/main.go | 1 + src/cmd/compile/internal/base/debug.go | 1 + src/cmd/compile/internal/base/flag.go | 1 + src/cmd/internal/obj/arm/obj5.go | 57 ++++++++++++++- src/cmd/internal/obj/arm64/obj7.go | 87 ++++++++++++++++++++++- src/cmd/internal/obj/link.go | 3 +- src/cmd/internal/obj/mips/obj0.go | 79 ++++++++++++++++++++- src/cmd/internal/obj/ppc64/obj9.go | 93 +++++++++++++++++++++++- src/cmd/internal/obj/riscv/obj.go | 58 ++++++++++++++- src/cmd/internal/obj/s390x/objz.go | 81 ++++++++++++++++++--- src/cmd/internal/obj/wasm/wasmobj.go | 56 ++++++++++++++- src/cmd/internal/obj/x86/obj6.go | 97 +++++++++++++++++++------- test/maymorestack.go | 47 +++++++++++++ 14 files changed, 620 insertions(+), 46 deletions(-) create mode 100644 test/maymorestack.go diff --git a/src/cmd/asm/internal/flags/flags.go b/src/cmd/asm/internal/flags/flags.go index dd947c7b5b..607166e664 100644 --- a/src/cmd/asm/internal/flags/flags.go +++ b/src/cmd/asm/internal/flags/flags.go @@ -28,6 +28,10 @@ var ( CompilingRuntime = flag.Bool("compiling-runtime", false, "source to be compiled is part of the Go runtime") ) +var DebugFlags struct { + MayMoreStack string `help:"call named function before all stack growth checks"` +} + var ( D MultiFlag I MultiFlag @@ -39,6 +43,7 @@ func init() { flag.Var(&D, "D", "predefined symbol with optional simple value -D=identifier=value; can be set multiple times") flag.Var(&I, "I", "include directory; can be set multiple times") flag.BoolVar(&DebugV, "v", false, "print debug output") + flag.Var(objabi.NewDebugFlag(&DebugFlags, nil), "d", "enable debugging settings; try -d help") objabi.AddVersionFlag() // -V objabi.Flagcount("S", "print assembly and machine code", &PrintOut) } diff --git a/src/cmd/asm/main.go b/src/cmd/asm/main.go index 3e32aa3d7d..3683527f5b 100644 --- a/src/cmd/asm/main.go +++ b/src/cmd/asm/main.go @@ -42,6 +42,7 @@ func main() { ctxt.Flag_dynlink = *flags.Dynlink ctxt.Flag_linkshared = *flags.Linkshared ctxt.Flag_shared = *flags.Shared || *flags.Dynlink + ctxt.Flag_maymorestack = flags.DebugFlags.MayMoreStack ctxt.IsAsm = true ctxt.Pkgpath = *flags.Importpath switch *flags.Spectre { diff --git a/src/cmd/compile/internal/base/debug.go b/src/cmd/compile/internal/base/debug.go index 37e345bd7f..b105e46e35 100644 --- a/src/cmd/compile/internal/base/debug.go +++ b/src/cmd/compile/internal/base/debug.go @@ -42,6 +42,7 @@ type DebugFlags struct { UnifiedQuirks int `help:"enable unified IR construction's quirks mode"` WB int `help:"print information about write barriers"` ABIWrap int `help:"print information about ABI wrapper generation"` + MayMoreStack string `help:"call named function before all stack growth checks"` Any bool // set when any of the debug flags have been set } diff --git a/src/cmd/compile/internal/base/flag.go b/src/cmd/compile/internal/base/flag.go index f38eaa91c0..d78f93b343 100644 --- a/src/cmd/compile/internal/base/flag.go +++ b/src/cmd/compile/internal/base/flag.go @@ -192,6 +192,7 @@ func ParseFlags() { Ctxt.Flag_shared = Ctxt.Flag_dynlink || Ctxt.Flag_shared Ctxt.Flag_optimize = Flag.N == 0 Ctxt.Debugasm = int(Flag.S) + Ctxt.Flag_maymorestack = Debug.MayMoreStack if flag.NArg() < 1 { usage() diff --git a/src/cmd/internal/obj/arm/obj5.go b/src/cmd/internal/obj/arm/obj5.go index 1454d8a7c9..38aa11cde9 100644 --- a/src/cmd/internal/obj/arm/obj5.go +++ b/src/cmd/internal/obj/arm/obj5.go @@ -634,6 +634,61 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { } func (c *ctxt5) stacksplit(p *obj.Prog, framesize int32) *obj.Prog { + if c.ctxt.Flag_maymorestack != "" { + // Save LR and make room for REGCTXT. + const frameSize = 8 + // MOVW.W R14,$-8(SP) + p = obj.Appendp(p, c.newprog) + p.As = AMOVW + p.Scond |= C_WBIT + p.From.Type = obj.TYPE_REG + p.From.Reg = REGLINK + p.To.Type = obj.TYPE_MEM + p.To.Offset = -frameSize + p.To.Reg = REGSP + p.Spadj = frameSize + + // MOVW REGCTXT, 4(SP) + p = obj.Appendp(p, c.newprog) + p.As = AMOVW + p.From.Type = obj.TYPE_REG + p.From.Reg = REGCTXT + p.To.Type = obj.TYPE_MEM + p.To.Offset = 4 + p.To.Reg = REGSP + + // CALL maymorestack + p = obj.Appendp(p, c.newprog) + p.As = obj.ACALL + p.To.Type = obj.TYPE_BRANCH + // See ../x86/obj6.go + p.To.Sym = c.ctxt.LookupABI(c.ctxt.Flag_maymorestack, c.cursym.ABI()) + + // Restore REGCTXT and LR. + + // MOVW 4(SP), REGCTXT + p = obj.Appendp(p, c.newprog) + p.As = AMOVW + p.From.Type = obj.TYPE_MEM + p.From.Offset = 4 + p.From.Reg = REGSP + p.To.Type = obj.TYPE_REG + p.To.Reg = REGCTXT + + // MOVW.P 8(SP), R14 + p.As = AMOVW + p.Scond |= C_PBIT + p.From.Type = obj.TYPE_MEM + p.From.Offset = frameSize + p.From.Reg = REGSP + p.To.Type = obj.TYPE_REG + p.To.Reg = REGLINK + p.Spadj = -frameSize + } + + // Jump back to here after morestack returns. + startPred := p + // MOVW g_stackguard(g), R1 p = obj.Appendp(p, c.newprog) @@ -761,7 +816,7 @@ func (c *ctxt5) stacksplit(p *obj.Prog, framesize int32) *obj.Prog { b := obj.Appendp(pcdata, c.newprog) b.As = obj.AJMP b.To.Type = obj.TYPE_BRANCH - b.To.SetTarget(c.cursym.Func().Text.Link) + b.To.SetTarget(startPred.Link) b.Spadj = +framesize return end diff --git a/src/cmd/internal/obj/arm64/obj7.go b/src/cmd/internal/obj/arm64/obj7.go index ae8deede3a..e9eb786cb2 100644 --- a/src/cmd/internal/obj/arm64/obj7.go +++ b/src/cmd/internal/obj/arm64/obj7.go @@ -58,6 +58,91 @@ var noZRreplace = map[obj.As]bool{ } func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog { + if c.ctxt.Flag_maymorestack != "" { + p = c.cursym.Func().SpillRegisterArgs(p, c.newprog) + + // Save LR and make room for FP, REGCTXT. Leave room + // for caller's saved FP. + const frameSize = 32 + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From.Type = obj.TYPE_REG + p.From.Reg = REGLINK + p.To.Type = obj.TYPE_MEM + p.Scond = C_XPRE + p.To.Offset = -frameSize + p.To.Reg = REGSP + p.Spadj = frameSize + + // Save FP. + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From.Type = obj.TYPE_REG + p.From.Reg = REGFP + p.To.Type = obj.TYPE_MEM + p.To.Reg = REGSP + p.To.Offset = -8 + + p = obj.Appendp(p, c.newprog) + p.As = ASUB + p.From.Type = obj.TYPE_CONST + p.From.Offset = 8 + p.Reg = REGSP + p.To.Type = obj.TYPE_REG + p.To.Reg = REGFP + + // Save REGCTXT (for simplicity we do this whether or + // not we need it.) + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From.Type = obj.TYPE_REG + p.From.Reg = REGCTXT + p.To.Type = obj.TYPE_MEM + p.To.Reg = REGSP + p.To.Offset = 8 + + // BL maymorestack + p = obj.Appendp(p, c.newprog) + p.As = ABL + p.To.Type = obj.TYPE_BRANCH + // See ../x86/obj6.go + p.To.Sym = c.ctxt.LookupABI(c.ctxt.Flag_maymorestack, c.cursym.ABI()) + + // Restore REGCTXT. + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From.Type = obj.TYPE_MEM + p.From.Reg = REGSP + p.From.Offset = 8 + p.To.Type = obj.TYPE_REG + p.To.Reg = REGCTXT + + // Restore FP. + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From.Type = obj.TYPE_MEM + p.From.Reg = REGSP + p.From.Offset = -8 + p.To.Type = obj.TYPE_REG + p.To.Reg = REGFP + + // Restore LR and SP. + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From.Type = obj.TYPE_MEM + p.Scond = C_XPOST + p.From.Offset = frameSize + p.From.Reg = REGSP + p.To.Type = obj.TYPE_REG + p.To.Reg = REGLINK + p.Spadj = -frameSize + + p = c.cursym.Func().UnspillRegisterArgs(p, c.newprog) + } + + // Jump back to here after morestack returns. + startPred := p + // MOV g_stackguard(g), RT1 p = obj.Appendp(p, c.newprog) @@ -212,7 +297,7 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog { jmp := obj.Appendp(pcdata, c.newprog) jmp.As = AB jmp.To.Type = obj.TYPE_BRANCH - jmp.To.SetTarget(c.cursym.Func().Text.Link) + jmp.To.SetTarget(startPred.Link) jmp.Spadj = +framesize return end diff --git a/src/cmd/internal/obj/link.go b/src/cmd/internal/obj/link.go index 4bcfb05a5e..11af143f22 100644 --- a/src/cmd/internal/obj/link.go +++ b/src/cmd/internal/obj/link.go @@ -880,7 +880,8 @@ type Link struct { Flag_linkshared bool Flag_optimize bool Flag_locationlists bool - Retpoline bool // emit use of retpoline stubs for indirect jmp/call + Retpoline bool // emit use of retpoline stubs for indirect jmp/call + Flag_maymorestack string // If not "", call this function before stack checks Bso *bufio.Writer Pathname string Pkgpath string // the current package's import path, "" if unknown diff --git a/src/cmd/internal/obj/mips/obj0.go b/src/cmd/internal/obj/mips/obj0.go index 1f31d0c4cd..9e2ccc1929 100644 --- a/src/cmd/internal/obj/mips/obj0.go +++ b/src/cmd/internal/obj/mips/obj0.go @@ -658,6 +658,82 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog { mov = AMOVW } + if c.ctxt.Flag_maymorestack != "" { + // Save LR and REGCTXT. + frameSize := 2 * c.ctxt.Arch.PtrSize + + p = c.ctxt.StartUnsafePoint(p, c.newprog) + + // MOV REGLINK, -8/-16(SP) + p = obj.Appendp(p, c.newprog) + p.As = mov + p.From.Type = obj.TYPE_REG + p.From.Reg = REGLINK + p.To.Type = obj.TYPE_MEM + p.To.Offset = int64(-frameSize) + p.To.Reg = REGSP + + // MOV REGCTXT, -4/-8(SP) + p = obj.Appendp(p, c.newprog) + p.As = mov + p.From.Type = obj.TYPE_REG + p.From.Reg = REGCTXT + p.To.Type = obj.TYPE_MEM + p.To.Offset = -int64(c.ctxt.Arch.PtrSize) + p.To.Reg = REGSP + + // ADD $-8/$-16, SP + p = obj.Appendp(p, c.newprog) + p.As = add + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(-frameSize) + p.To.Type = obj.TYPE_REG + p.To.Reg = REGSP + p.Spadj = int32(frameSize) + + // JAL maymorestack + p = obj.Appendp(p, c.newprog) + p.As = AJAL + p.To.Type = obj.TYPE_BRANCH + // See ../x86/obj6.go + p.To.Sym = c.ctxt.LookupABI(c.ctxt.Flag_maymorestack, c.cursym.ABI()) + p.Mark |= BRANCH + + // Restore LR and REGCTXT. + + // MOV 0(SP), REGLINK + p = obj.Appendp(p, c.newprog) + p.As = mov + p.From.Type = obj.TYPE_MEM + p.From.Offset = 0 + p.From.Reg = REGSP + p.To.Type = obj.TYPE_REG + p.To.Reg = REGLINK + + // MOV 4/8(SP), REGCTXT + p = obj.Appendp(p, c.newprog) + p.As = mov + p.From.Type = obj.TYPE_MEM + p.From.Offset = int64(c.ctxt.Arch.PtrSize) + p.From.Reg = REGSP + p.To.Type = obj.TYPE_REG + p.To.Reg = REGCTXT + + // ADD $8/$16, SP + p = obj.Appendp(p, c.newprog) + p.As = add + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(frameSize) + p.To.Type = obj.TYPE_REG + p.To.Reg = REGSP + p.Spadj = int32(-frameSize) + + p = c.ctxt.EndUnsafePoint(p, c.newprog, -1) + } + + // Jump back to here after morestack returns. + startPred := p + // MOV g_stackguard(g), R1 p = obj.Appendp(p, c.newprog) @@ -787,7 +863,8 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog { p.As = AJMP p.To.Type = obj.TYPE_BRANCH - p.To.SetTarget(c.cursym.Func().Text.Link) + p.To.SetTarget(startPred.Link) + startPred.Link.Mark |= LABEL p.Mark |= BRANCH // placeholder for q1's jump target diff --git a/src/cmd/internal/obj/ppc64/obj9.go b/src/cmd/internal/obj/ppc64/obj9.go index ee93fe048b..7ac6465a72 100644 --- a/src/cmd/internal/obj/ppc64/obj9.go +++ b/src/cmd/internal/obj/ppc64/obj9.go @@ -1048,7 +1048,96 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { } */ func (c *ctxt9) stacksplit(p *obj.Prog, framesize int32) *obj.Prog { - p0 := p // save entry point, but skipping the two instructions setting R2 in shared mode + if c.ctxt.Flag_maymorestack != "" { + if c.ctxt.Flag_shared || c.ctxt.Flag_dynlink { + // See the call to morestack for why these are + // complicated to support. + c.ctxt.Diag("maymorestack with -shared or -dynlink is not supported") + } + + // Spill arguments. This has to happen before we open + // any more frame space. + p = c.cursym.Func().SpillRegisterArgs(p, c.newprog) + + // Save LR and REGCTXT + frameSize := 8 + c.ctxt.FixedFrameSize() + + // MOVD LR, REGTMP + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From.Type = obj.TYPE_REG + p.From.Reg = REG_LR + p.To.Type = obj.TYPE_REG + p.To.Reg = REGTMP + // MOVDU REGTMP, -16(SP) + p = obj.Appendp(p, c.newprog) + p.As = AMOVDU + p.From.Type = obj.TYPE_REG + p.From.Reg = REGTMP + p.To.Type = obj.TYPE_MEM + p.To.Offset = -frameSize + p.To.Reg = REGSP + p.Spadj = int32(frameSize) + + // MOVD REGCTXT, 8(SP) + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From.Type = obj.TYPE_REG + p.From.Reg = REGCTXT + p.To.Type = obj.TYPE_MEM + p.To.Offset = 8 + p.To.Reg = REGSP + + // BL maymorestack + p = obj.Appendp(p, c.newprog) + p.As = ABL + p.To.Type = obj.TYPE_BRANCH + // See ../x86/obj6.go + p.To.Sym = c.ctxt.LookupABI(c.ctxt.Flag_maymorestack, c.cursym.ABI()) + + // Restore LR and REGCTXT + + // MOVD 8(SP), REGCTXT + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From.Type = obj.TYPE_MEM + p.From.Offset = 8 + p.From.Reg = REGSP + p.To.Type = obj.TYPE_REG + p.To.Reg = REGCTXT + + // MOVD 0(SP), REGTMP + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From.Type = obj.TYPE_MEM + p.From.Offset = 0 + p.From.Reg = REGSP + p.To.Type = obj.TYPE_REG + p.To.Reg = REGTMP + + // MOVD REGTMP, LR + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From.Type = obj.TYPE_REG + p.From.Reg = REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = REG_LR + + // ADD $16, SP + p = obj.Appendp(p, c.newprog) + p.As = AADD + p.From.Type = obj.TYPE_CONST + p.From.Offset = frameSize + p.To.Type = obj.TYPE_REG + p.To.Reg = REGSP + p.Spadj = -int32(frameSize) + + // Unspill arguments. + p = c.cursym.Func().UnspillRegisterArgs(p, c.newprog) + } + + // save entry point, but skipping the two instructions setting R2 in shared mode and maymorestack + startPred := p // MOVD g_stackguard(g), R22 p = obj.Appendp(p, c.newprog) @@ -1262,7 +1351,7 @@ func (c *ctxt9) stacksplit(p *obj.Prog, framesize int32) *obj.Prog { p = obj.Appendp(p, c.newprog) p.As = ABR p.To.Type = obj.TYPE_BRANCH - p.To.SetTarget(p0.Link) + p.To.SetTarget(startPred.Link) // placeholder for q1's jump target p = obj.Appendp(p, c.newprog) diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go index c27ad99b2d..5755b118db 100644 --- a/src/cmd/internal/obj/riscv/obj.go +++ b/src/cmd/internal/obj/riscv/obj.go @@ -722,6 +722,62 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, cursym *obj.LSym, newprog obj.ProgA return p } + if ctxt.Flag_maymorestack != "" { + // Save LR and REGCTXT + const frameSize = 16 + p = ctxt.StartUnsafePoint(p, newprog) + // MOV LR, -16(SP) + p = obj.Appendp(p, newprog) + p.As = AMOV + p.From = obj.Addr{Type: obj.TYPE_REG, Reg: REG_LR} + p.To = obj.Addr{Type: obj.TYPE_MEM, Reg: REG_SP, Offset: -frameSize} + // ADDI $-16, SP + p = obj.Appendp(p, newprog) + p.As = AADDI + p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: -frameSize} + p.Reg = REG_SP + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: REG_SP} + p.Spadj = frameSize + // MOV REGCTXT, 8(SP) + p = obj.Appendp(p, newprog) + p.As = AMOV + p.From = obj.Addr{Type: obj.TYPE_REG, Reg: REG_CTXT} + p.To = obj.Addr{Type: obj.TYPE_MEM, Reg: REG_SP, Offset: 8} + + // CALL maymorestack + p = obj.Appendp(p, newprog) + p.As = obj.ACALL + p.To.Type = obj.TYPE_BRANCH + // See ../x86/obj6.go + p.To.Sym = ctxt.LookupABI(ctxt.Flag_maymorestack, cursym.ABI()) + jalToSym(ctxt, p, REG_X5) + + // Restore LR and REGCTXT + + // MOV 8(SP), REGCTXT + p = obj.Appendp(p, newprog) + p.As = AMOV + p.From = obj.Addr{Type: obj.TYPE_MEM, Reg: REG_SP, Offset: 8} + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: REG_CTXT} + // MOV (SP), LR + p = obj.Appendp(p, newprog) + p.As = AMOV + p.From = obj.Addr{Type: obj.TYPE_MEM, Reg: REG_SP, Offset: 0} + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: REG_LR} + // ADDI $16, SP + p = obj.Appendp(p, newprog) + p.As = AADDI + p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: frameSize} + p.Reg = REG_SP + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: REG_SP} + p.Spadj = -frameSize + + p = ctxt.EndUnsafePoint(p, newprog, -1) + } + + // Jump back to here after morestack returns. + startPred := p + // MOV g_stackguard(g), X10 p = obj.Appendp(p, newprog) p.As = AMOV @@ -821,7 +877,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, cursym *obj.LSym, newprog obj.ProgA p.As = AJAL p.To = obj.Addr{Type: obj.TYPE_BRANCH} p.From = obj.Addr{Type: obj.TYPE_REG, Reg: REG_ZERO} - p.To.SetTarget(cursym.Func().Text.Link) + p.To.SetTarget(startPred.Link) // placeholder for to_done's jump target p = obj.Appendp(p, newprog) diff --git a/src/cmd/internal/obj/s390x/objz.go b/src/cmd/internal/obj/s390x/objz.go index 201163b015..de40ff05af 100644 --- a/src/cmd/internal/obj/s390x/objz.go +++ b/src/cmd/internal/obj/s390x/objz.go @@ -294,6 +294,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { var pLast *obj.Prog var pPre *obj.Prog var pPreempt *obj.Prog + var pCheck *obj.Prog wasSplit := false for p := c.cursym.Func().Text; p != nil; p = p.Link { pLast = p @@ -323,7 +324,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { q := p if !p.From.Sym.NoSplit() { - p, pPreempt = c.stacksplitPre(p, autosize) // emit pre part of split check + p, pPreempt, pCheck = c.stacksplitPre(p, autosize) // emit pre part of split check pPre = p p = c.ctxt.EndUnsafePoint(p, c.newprog, -1) wasSplit = true //need post part of split @@ -563,14 +564,69 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { } } if wasSplit { - c.stacksplitPost(pLast, pPre, pPreempt, autosize) // emit post part of split check + c.stacksplitPost(pLast, pPre, pPreempt, pCheck, autosize) // emit post part of split check } } -func (c *ctxtz) stacksplitPre(p *obj.Prog, framesize int32) (*obj.Prog, *obj.Prog) { +// stacksplitPre generates the function stack check prologue following +// Prog p (which should be the TEXT Prog). It returns one or two +// branch Progs that must be patched to jump to the morestack epilogue, +// and the Prog that starts the morestack check. +func (c *ctxtz) stacksplitPre(p *obj.Prog, framesize int32) (pPre, pPreempt, pCheck *obj.Prog) { + if c.ctxt.Flag_maymorestack != "" { + // Save LR and REGCTXT + const frameSize = 16 + p = c.ctxt.StartUnsafePoint(p, c.newprog) + // MOVD LR, -16(SP) + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From = obj.Addr{Type: obj.TYPE_REG, Reg: REG_LR} + p.To = obj.Addr{Type: obj.TYPE_MEM, Reg: REGSP, Offset: -frameSize} + // MOVD $-16(SP), SP + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From = obj.Addr{Type: obj.TYPE_ADDR, Offset: -frameSize, Reg: REGSP} + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: REGSP} + p.Spadj = frameSize + // MOVD REGCTXT, 8(SP) + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From = obj.Addr{Type: obj.TYPE_REG, Reg: REGCTXT} + p.To = obj.Addr{Type: obj.TYPE_MEM, Reg: REGSP, Offset: 8} + + // BL maymorestack + p = obj.Appendp(p, c.newprog) + p.As = ABL + // See ../x86/obj6.go + sym := c.ctxt.LookupABI(c.ctxt.Flag_maymorestack, c.cursym.ABI()) + p.To = obj.Addr{Type: obj.TYPE_BRANCH, Sym: sym} + + // Restore LR and REGCTXT + + // MOVD REGCTXT, 8(SP) + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From = obj.Addr{Type: obj.TYPE_MEM, Reg: REGSP, Offset: 8} + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: REGCTXT} + // MOVD (SP), LR + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From = obj.Addr{Type: obj.TYPE_MEM, Reg: REGSP, Offset: 0} + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: REG_LR} + // MOVD $16(SP), SP + p = obj.Appendp(p, c.newprog) + p.As = AMOVD + p.From = obj.Addr{Type: obj.TYPE_CONST, Reg: REGSP, Offset: frameSize} + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: REGSP} + p.Spadj = -frameSize + + p = c.ctxt.EndUnsafePoint(p, c.newprog, -1) + } // MOVD g_stackguard(g), R3 p = obj.Appendp(p, c.newprog) + // Jump back to here after morestack returns. + pCheck = p p.As = AMOVD p.From.Type = obj.TYPE_MEM @@ -599,12 +655,11 @@ func (c *ctxtz) stacksplitPre(p *obj.Prog, framesize int32) (*obj.Prog, *obj.Pro p.As = ACMPUBGE p.To.Type = obj.TYPE_BRANCH - return p, nil + return p, nil, pCheck } // large stack: SP-framesize < stackguard-StackSmall - var q *obj.Prog offset := int64(framesize) - objabi.StackSmall if framesize > objabi.StackBig { // Such a large stack we need to protect against underflow. @@ -625,7 +680,7 @@ func (c *ctxtz) stacksplitPre(p *obj.Prog, framesize int32) (*obj.Prog, *obj.Pro p.To.Reg = REG_R4 p = obj.Appendp(p, c.newprog) - q = p + pPreempt = p p.As = ACMPUBLT p.From.Type = obj.TYPE_REG p.From.Reg = REGSP @@ -651,10 +706,16 @@ func (c *ctxtz) stacksplitPre(p *obj.Prog, framesize int32) (*obj.Prog, *obj.Pro p.As = ACMPUBGE p.To.Type = obj.TYPE_BRANCH - return p, q + return p, pPreempt, pCheck } -func (c *ctxtz) stacksplitPost(p *obj.Prog, pPre *obj.Prog, pPreempt *obj.Prog, framesize int32) *obj.Prog { +// stacksplitPost generates the function epilogue that calls morestack +// and returns the new last instruction in the function. +// +// p is the last Prog in the function. pPre and pPreempt, if non-nil, +// are the instructions that branch to the epilogue. This will fill in +// their branch targets. pCheck is the Prog that begins the stack check. +func (c *ctxtz) stacksplitPost(p *obj.Prog, pPre, pPreempt, pCheck *obj.Prog, framesize int32) *obj.Prog { // Now we are at the end of the function, but logically // we are still in function prologue. We need to fix the // SP data and PCDATA. @@ -692,12 +753,12 @@ func (c *ctxtz) stacksplitPost(p *obj.Prog, pPre *obj.Prog, pPreempt *obj.Prog, p = c.ctxt.EndUnsafePoint(p, c.newprog, -1) - // BR start + // BR pCheck p = obj.Appendp(p, c.newprog) p.As = ABR p.To.Type = obj.TYPE_BRANCH - p.To.SetTarget(c.cursym.Func().Text.Link) + p.To.SetTarget(pCheck) return p } diff --git a/src/cmd/internal/obj/wasm/wasmobj.go b/src/cmd/internal/obj/wasm/wasmobj.go index 4d276db678..1c726f77d3 100644 --- a/src/cmd/internal/obj/wasm/wasmobj.go +++ b/src/cmd/internal/obj/wasm/wasmobj.go @@ -243,6 +243,51 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { p.Spadj = int32(framesize) } + needMoreStack := !s.Func().Text.From.Sym.NoSplit() + + // If the maymorestack debug option is enabled, insert the + // call to maymorestack *before* processing resume points so + // we can construct a resume point after maymorestack for + // morestack to resume at. + var pMorestack = s.Func().Text + if needMoreStack && ctxt.Flag_maymorestack != "" { + p := pMorestack + + // Save REGCTXT on the stack. + const tempFrame = 8 + p = appendp(p, AGet, regAddr(REG_SP)) + p = appendp(p, AI32Const, constAddr(tempFrame)) + p = appendp(p, AI32Sub) + p = appendp(p, ASet, regAddr(REG_SP)) + p.Spadj = tempFrame + ctxtp := obj.Addr{ + Type: obj.TYPE_MEM, + Reg: REG_SP, + Offset: 0, + } + p = appendp(p, AMOVD, regAddr(REGCTXT), ctxtp) + + // maymorestack must not itself preempt because we + // don't have full stack information, so this can be + // ACALLNORESUME. + p = appendp(p, ACALLNORESUME, constAddr(0)) + // See ../x86/obj6.go + sym := ctxt.LookupABI(ctxt.Flag_maymorestack, s.ABI()) + p.To = obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_EXTERN, Sym: sym} + + // Restore REGCTXT. + p = appendp(p, AMOVD, ctxtp, regAddr(REGCTXT)) + p = appendp(p, AGet, regAddr(REG_SP)) + p = appendp(p, AI32Const, constAddr(tempFrame)) + p = appendp(p, AI32Add) + p = appendp(p, ASet, regAddr(REG_SP)) + p.Spadj = -tempFrame + + // Add an explicit ARESUMEPOINT after maymorestack for + // morestack to resume at. + pMorestack = appendp(p, ARESUMEPOINT) + } + // Introduce resume points for CALL instructions // and collect other explicit resume points. numResumePoints := 0 @@ -303,8 +348,8 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { tableIdxs = append(tableIdxs, uint64(numResumePoints)) s.Size = pc + 1 - if !s.Func().Text.From.Sym.NoSplit() { - p := s.Func().Text + if needMoreStack { + p := pMorestack if framesize <= objabi.StackSmall { // small stack: SP <= stackguard @@ -341,6 +386,13 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { // TODO(neelance): handle wraparound case p = appendp(p, AIf) + // This CALL does *not* have a resume point after it + // (we already inserted all of the resume points). As + // a result, morestack will resume at the *previous* + // resume point (typically, the beginning of the + // function) and perform the morestack check again. + // This is why we don't need an explicit loop like + // other architectures. p = appendp(p, obj.ACALL, constAddr(0)) if s.Func().Text.From.Sym.NeedCtxt() { p.To = obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_EXTERN, Sym: morestack} diff --git a/src/cmd/internal/obj/x86/obj6.go b/src/cmd/internal/obj/x86/obj6.go index 183ca2ebe9..a82285a0d3 100644 --- a/src/cmd/internal/obj/x86/obj6.go +++ b/src/cmd/internal/obj/x86/obj6.go @@ -644,19 +644,6 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { } } - var regg int16 - if !p.From.Sym.NoSplit() || p.From.Sym.Wrapper() { - if ctxt.Arch.Family == sys.AMD64 && cursym.ABI() == obj.ABIInternal { - regg = REGG // use the g register directly in ABIInternal - } else { - p = obj.Appendp(p, newprog) - regg = REG_CX - if ctxt.Arch.Family == sys.AMD64 { - regg = REGG // == REG_R14 - } - p = load_g(ctxt, p, newprog, regg) // load g into regg - } - } var regEntryTmp0, regEntryTmp1 int16 if ctxt.Arch.Family == sys.AMD64 { regEntryTmp0, regEntryTmp1 = REGENTRYTMP0, REGENTRYTMP1 @@ -664,8 +651,13 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { regEntryTmp0, regEntryTmp1 = REG_BX, REG_DI } - if !cursym.Func().Text.From.Sym.NoSplit() { - p = stacksplit(ctxt, cursym, p, newprog, autoffset, int32(textarg), regg) // emit split check + var regg int16 + if !p.From.Sym.NoSplit() { + // Emit split check and load G register + p, regg = stacksplit(ctxt, cursym, p, newprog, autoffset, int32(textarg)) + } else if p.From.Sym.Wrapper() { + // Load G register for the wrapper code + p, regg = loadG(ctxt, cursym, p, newprog) } // Delve debugger would like the next instruction to be noted as the end of the function prologue. @@ -973,12 +965,21 @@ func indir_cx(ctxt *obj.Link, a *obj.Addr) { a.Reg = REG_CX } -// Append code to p to load g into cx. -// Overwrites p with the first instruction (no first appendp). -// Overwriting p is unusual but it lets use this in both the -// prologue (caller must call appendp first) and in the epilogue. -// Returns last new instruction. -func load_g(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc, rg int16) *obj.Prog { +// loadG ensures the G is loaded into a register (either CX or REGG), +// appending instructions to p if necessary. It returns the new last +// instruction and the G register. +func loadG(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgAlloc) (*obj.Prog, int16) { + if ctxt.Arch.Family == sys.AMD64 && cursym.ABI() == obj.ABIInternal { + // Use the G register directly in ABIInternal + return p, REGG + } + + var regg int16 = REG_CX + if ctxt.Arch.Family == sys.AMD64 { + regg = REGG // == REG_R14 + } + + p = obj.Appendp(p, newprog) p.As = AMOVQ if ctxt.Arch.PtrSize == 4 { p.As = AMOVL @@ -987,8 +988,9 @@ func load_g(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc, rg int16) *obj.P p.From.Reg = REG_TLS p.From.Offset = 0 p.To.Type = obj.TYPE_REG - p.To.Reg = rg + p.To.Reg = regg + // Rewrite TLS instruction if necessary. next := p.Link progedit(ctxt, p, newprog) for p.Link != next { @@ -1000,24 +1002,26 @@ func load_g(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc, rg int16) *obj.P p.From.Scale = 2 } - return p + return p, regg } // Append code to p to check for stack split. // Appends to (does not overwrite) p. // Assumes g is in rg. -// Returns last new instruction. -func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgAlloc, framesize int32, textarg int32, rg int16) *obj.Prog { +// Returns last new instruction and G register. +func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgAlloc, framesize int32, textarg int32) (*obj.Prog, int16) { cmp := ACMPQ lea := ALEAQ mov := AMOVQ sub := ASUBQ + push, pop := APUSHQ, APOPQ if ctxt.Arch.Family == sys.I386 { cmp = ACMPL lea = ALEAL mov = AMOVL sub = ASUBL + push, pop = APUSHL, APOPL } tmp := int16(REG_AX) // use AX for 32-bit @@ -1026,6 +1030,45 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA tmp = int16(REGENTRYTMP0) } + if ctxt.Flag_maymorestack != "" { + p = cursym.Func().SpillRegisterArgs(p, newprog) + + if cursym.Func().Text.From.Sym.NeedCtxt() { + p = obj.Appendp(p, newprog) + p.As = push + p.From.Type = obj.TYPE_REG + p.From.Reg = REGCTXT + } + + // We call maymorestack with an ABI matching the + // caller's ABI. Since this is the first thing that + // happens in the function, we have to be consistent + // with the caller about CPU state (notably, + // fixed-meaning registers). + + p = obj.Appendp(p, newprog) + p.As = obj.ACALL + p.To.Type = obj.TYPE_BRANCH + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ctxt.LookupABI(ctxt.Flag_maymorestack, cursym.ABI()) + + if cursym.Func().Text.From.Sym.NeedCtxt() { + p = obj.Appendp(p, newprog) + p.As = pop + p.To.Type = obj.TYPE_REG + p.To.Reg = REGCTXT + } + + p = cursym.Func().UnspillRegisterArgs(p, newprog) + } + + // Jump back to here after morestack returns. + startPred := p + + // Load G register + var rg int16 + p, rg = loadG(ctxt, cursym, p, newprog) + var q1 *obj.Prog if framesize <= objabi.StackSmall { // small stack: SP <= stackguard @@ -1171,7 +1214,7 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA jmp := obj.Appendp(pcdata, newprog) jmp.As = obj.AJMP jmp.To.Type = obj.TYPE_BRANCH - jmp.To.SetTarget(cursym.Func().Text.Link) + jmp.To.SetTarget(startPred.Link) jmp.Spadj = +framesize jls.To.SetTarget(spill) @@ -1179,7 +1222,7 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA q1.To.SetTarget(spill) } - return end + return end, rg } func isR15(r int16) bool { diff --git a/test/maymorestack.go b/test/maymorestack.go new file mode 100644 index 0000000000..ec84ad44bc --- /dev/null +++ b/test/maymorestack.go @@ -0,0 +1,47 @@ +// run -gcflags=-d=maymorestack=main.mayMoreStack + +// Copyright 2021 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. + +// Test the maymorestack testing hook by injecting a hook that counts +// how many times it is called and checking that count. + +package main + +import "runtime" + +var count uint32 + +//go:nosplit +func mayMoreStack() { + count++ +} + +func main() { + const wantCount = 128 + + anotherFunc(wantCount - 1) // -1 because the call to main already counted + + if count == 0 { + panic("mayMoreStack not called") + } else if count != wantCount { + println(count, "!=", wantCount) + panic("wrong number of calls to mayMoreStack") + } +} + +//go:noinline +func anotherFunc(n int) { + // Trigger a stack growth on at least some calls to + // anotherFunc to test that mayMoreStack is called outside the + // morestack loop. It's also important that it is called + // before (not after) morestack, but that's hard to test. + var x [1 << 10]byte + + if n > 1 { + anotherFunc(n - 1) + } + + runtime.KeepAlive(x) +} From 35c7234601c409a1d1595e4eb9fe72e8ba4e6464 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 15 Sep 2021 17:14:21 -0400 Subject: [PATCH 397/406] runtime: add always-preempt maymorestack hook This adds a maymorestack hook that forces a preemption at every possible cooperative preemption point. This would have helped us catch several recent preemption-related bugs earlier, including #47302, #47304, and #47441. For #48297. Change-Id: Ib82c973589c8a7223900e1842913b8591938fb9f Reviewed-on: https://go-review.googlesource.com/c/go/+/359796 Trust: Austin Clements Run-TryBot: Austin Clements TryBot-Result: Go Bot Reviewed-by: Cherry Mui Reviewed-by: Michael Pratt Reviewed-by: David Chase --- src/runtime/debug.go | 34 ++++++++++++++++++++++++++++++++++ src/runtime/stack.go | 3 +++ 2 files changed, 37 insertions(+) diff --git a/src/runtime/debug.go b/src/runtime/debug.go index 82deefa200..c343f430cc 100644 --- a/src/runtime/debug.go +++ b/src/runtime/debug.go @@ -61,3 +61,37 @@ func NumGoroutine() int { func debug_modinfo() string { return modinfo } + +// mayMoreStackPreempt is a maymorestack hook that forces a preemption +// at every possible cooperative preemption point. +// +// This is valuable to apply to the runtime, which can be sensitive to +// preemption points. To apply this to all preemption points in the +// runtime and runtime-like code, use the following in bash or zsh: +// +// X=(-{gc,asm}flags={runtime/...,reflect,sync}=-d=maymorestack=runtime.mayMoreStackPreempt) GOFLAGS=${X[@]} +// +// This must be deeply nosplit because it is called from a function +// prologue before the stack is set up and because the compiler will +// call it from any splittable prologue (leading to infinite +// recursion). +// +// Ideally it should also use very little stack because the linker +// doesn't currently account for this in nosplit stack depth checking. +// +//go:nosplit +// +// Ensure mayMoreStackPreempt can be called for all ABIs. +// +//go:linkname mayMoreStackPreempt +func mayMoreStackPreempt() { + // Don't do anything on the g0 or gsignal stack. + g := getg() + if g == g.m.g0 || g == g.m.gsignal { + return + } + // Force a preemption, unless the stack is already poisoned. + if g.stackguard0 < stackPoisonMin { + g.stackguard0 = stackPreempt + } +} diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 52d21e4ee4..7d9ae1e9d2 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -144,6 +144,9 @@ const ( // Force a stack movement. Used for debugging. // 0xfffffeed in hex. stackForceMove = uintptrMask & -275 + + // stackPoisonMin is the lowest allowed stack poison value. + stackPoisonMin = uintptrMask & -4096 ) // Global pool of spans that have free stacks. From bd580a0d10729553a7905481d17eed0436198866 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Mon, 27 Sep 2021 10:05:13 -0400 Subject: [PATCH 398/406] runtime: add a maymorestack hook that moves the stack This adds a maymorestack hook that moves the stack at every cooperative preemption point. For #48297. Change-Id: Ic15f9bcbc163345e6422586302d57fda4744caec Reviewed-on: https://go-review.googlesource.com/c/go/+/359797 Trust: Austin Clements Run-TryBot: Austin Clements TryBot-Result: Go Bot Reviewed-by: Cherry Mui Reviewed-by: Michael Pratt Reviewed-by: David Chase --- src/runtime/debug.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/runtime/debug.go b/src/runtime/debug.go index c343f430cc..2703a0ce01 100644 --- a/src/runtime/debug.go +++ b/src/runtime/debug.go @@ -95,3 +95,22 @@ func mayMoreStackPreempt() { g.stackguard0 = stackPreempt } } + +// mayMoreStackMove is a maymorestack hook that forces stack movement +// at every possible point. +// +// See mayMoreStackPreempt. +// +//go:nosplit +//go:linkname mayMoreStackMove +func mayMoreStackMove() { + // Don't do anything on the g0 or gsignal stack. + g := getg() + if g == g.m.g0 || g == g.m.gsignal { + return + } + // Force stack movement, unless the stack is already poisoned. + if g.stackguard0 < stackPoisonMin { + g.stackguard0 = stackForceMove + } +} From 0a5ca2422f14f9c17a017207feb9f83f94ce0e89 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Mon, 27 Sep 2021 14:40:06 -0400 Subject: [PATCH 399/406] crypto/ecdsa: draw a fixed amount of entropy while signing The current code, introduced in CL 2422, mixes K bits of entropy with the private key and message digest to generate the signature nonce, where K is half the bit size of the curve. While the ECDLP complexity (and hence security level) of a curve is half its bit size, the birthday bound on K bits is only K/2. For P-224, this means we should expect a collision after 2^56 signatures over the same message with the same key. A collision, which is unlikely, would still not be a major practical concern, because the scheme would fall back to a secure deterministic signature scheme, and simply leak the fact that the two signed messages are the same (which is presumably already public). Still, we can simplify the code and remove the eventuality by always drawing 256 bits of entropy. Change-Id: I58097bd3cfc9283503e38751c924c53d271af92b Reviewed-on: https://go-review.googlesource.com/c/go/+/352530 Trust: Filippo Valsorda Run-TryBot: Filippo Valsorda TryBot-Result: Go Bot Reviewed-by: Roland Shoemaker --- src/crypto/ecdsa/ecdsa.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/crypto/ecdsa/ecdsa.go b/src/crypto/ecdsa/ecdsa.go index 219436935f..282596d2d2 100644 --- a/src/crypto/ecdsa/ecdsa.go +++ b/src/crypto/ecdsa/ecdsa.go @@ -200,12 +200,8 @@ var errZeroParam = errors.New("zero parameter") func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err error) { randutil.MaybeReadByte(rand) - // Get min(log2(q) / 2, 256) bits of entropy from rand. - entropylen := (priv.Curve.Params().BitSize + 7) / 16 - if entropylen > 32 { - entropylen = 32 - } - entropy := make([]byte, entropylen) + // Get 256 bits of entropy from rand. + entropy := make([]byte, 32) _, err = io.ReadFull(rand, entropy) if err != nil { return From 3b5add5d683572a81ed57007612bc2c712aa7789 Mon Sep 17 00:00:00 2001 From: lgbgbl Date: Fri, 5 Nov 2021 04:57:59 +0000 Subject: [PATCH 400/406] bufio: fix typo in comment Change-Id: I6074334bc73ee1773fc83d049142ad764e39e5a9 GitHub-Last-Rev: 6a8789318ab132a169a89be807394af55c855ce9 GitHub-Pull-Request: golang/go#49373 Reviewed-on: https://go-review.googlesource.com/c/go/+/361413 Reviewed-by: Brad Fitzpatrick Reviewed-by: Ian Lance Taylor --- src/bufio/bufio_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bufio/bufio_test.go b/src/bufio/bufio_test.go index 66b3e70053..4dddfa9085 100644 --- a/src/bufio/bufio_test.go +++ b/src/bufio/bufio_test.go @@ -1520,7 +1520,7 @@ func TestReaderDiscard(t *testing.T) { wantBuffered: 0, }, // Any error from filling shouldn't show up until we - // get past the valid bytes. Here we return we return 5 valid bytes at the same time + // get past the valid bytes. Here we return 5 valid bytes at the same time // as an error, but test that we don't see the error from Discard. { name: "fill error, discard less", From b68c02e2919aec347438a7ec6512b0d2accd163f Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Fri, 5 Nov 2021 10:40:31 +0800 Subject: [PATCH 401/406] internal/poll: fix the wrong function names in comments Change-Id: Ib17df2751209129ad6d1c148829625b347b702a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/361514 Reviewed-by: Brad Fitzpatrick Reviewed-by: Ian Lance Taylor Trust: Brad Fitzpatrick --- src/internal/poll/fd_windows.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go index 0d8bf87992..1ca281b2a4 100644 --- a/src/internal/poll/fd_windows.go +++ b/src/internal/poll/fd_windows.go @@ -593,7 +593,7 @@ func (fd *FD) ReadFrom(buf []byte) (int, syscall.Sockaddr, error) { return n, sa, nil } -// ReadFrom wraps the recvfrom network call for IPv4. +// ReadFromInet4 wraps the recvfrom network call for IPv4. func (fd *FD) ReadFromInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error) { if len(buf) == 0 { return 0, nil @@ -622,7 +622,7 @@ func (fd *FD) ReadFromInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error) return n, err } -// ReadFrom wraps the recvfrom network call for IPv6. +// ReadFromInet6 wraps the recvfrom network call for IPv6. func (fd *FD) ReadFromInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error) { if len(buf) == 0 { return 0, nil From 6fefb7f9f3b632bdd0c3997ecc5b1096a5077cdf Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Thu, 4 Nov 2021 13:28:25 -0700 Subject: [PATCH 402/406] cmd/compile: gracefully fallback when inline bodies are missing Currently, we rely on a "crawling" step during export to identify function and method bodies that need to be exported or re-exported so we can trim out unnecessary ones and reduce build artifact sizes. To catch cases where we expect a function to be inlinable but we failed to export its body, we made this condition a fatal compiler error. However, with generics, it's much harder to perfectly identify all function bodies that need to be exported; and several attempts at tweaking the algorithm have resulted in still having failure cases. So for now, this CL changes a missing inline body into a graceful failure instead. Change-Id: I04b0872d0dcaae9c3de473e92ce584e4ec6fd782 Reviewed-on: https://go-review.googlesource.com/c/go/+/361403 Trust: Matthew Dempsky Trust: Dan Scales Run-TryBot: Matthew Dempsky Reviewed-by: Dan Scales --- src/cmd/compile/internal/inline/inl.go | 4 ++-- src/cmd/compile/internal/typecheck/crawler.go | 2 +- src/cmd/compile/internal/typecheck/iimport.go | 21 +++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index b764aed534..47b895f7e3 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -309,7 +309,7 @@ func (v *hairyVisitor) doNode(n ir.Node) bool { break } - if fn := inlCallee(n.X); fn != nil && fn.Inl != nil { + if fn := inlCallee(n.X); fn != nil && typecheck.HaveInlineBody(fn) { v.budget -= fn.Inl.Cost break } @@ -585,7 +585,7 @@ func inlnode(n ir.Node, maxCost int32, inlMap map[*ir.Func]bool, edit func(ir.No if ir.IsIntrinsicCall(call) { break } - if fn := inlCallee(call.X); fn != nil && fn.Inl != nil { + if fn := inlCallee(call.X); fn != nil && typecheck.HaveInlineBody(fn) { n = mkinlcall(call, fn, maxCost, inlMap, edit) } } diff --git a/src/cmd/compile/internal/typecheck/crawler.go b/src/cmd/compile/internal/typecheck/crawler.go index ae2b3b1df4..ae6542d071 100644 --- a/src/cmd/compile/internal/typecheck/crawler.go +++ b/src/cmd/compile/internal/typecheck/crawler.go @@ -207,7 +207,7 @@ func (p *crawler) markInlBody(n *ir.Name) { if fn == nil { base.Fatalf("markInlBody: missing Func on %v", n) } - if fn.Inl == nil { + if !HaveInlineBody(fn) { return } diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index 7c6c23e737..26bc838ed9 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -81,6 +81,27 @@ func ImportBody(fn *ir.Func) { inimport = false } +// HaveInlineBody reports whether we have fn's inline body available +// for inlining. +func HaveInlineBody(fn *ir.Func) bool { + if fn.Inl == nil { + return false + } + + // Unified IR is much more conservative about pruning unreachable + // methods (at the cost of increased build artifact size). + if base.Debug.Unified != 0 { + return true + } + + if fn.Inl.Body != nil { + return true + } + + _, ok := inlineImporter[fn.Nname.Sym()] + return ok +} + func importReaderFor(sym *types.Sym, importers map[*types.Sym]iimporterAndOffset) *importReader { x, ok := importers[sym] if !ok { From a0d661ab0ff896abe45d6d4e79cb71df233c5319 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 5 Nov 2021 08:18:57 -0700 Subject: [PATCH 403/406] net: skip new alloc test on some builders Change-Id: Ib785212eb9e035a10d327696c180caf730d2e5e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/361634 Run-TryBot: Brad Fitzpatrick TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills Trust: Brad Fitzpatrick --- src/net/udpsock_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/net/udpsock_test.go b/src/net/udpsock_test.go index 518c66c331..9fe74f47a2 100644 --- a/src/net/udpsock_test.go +++ b/src/net/udpsock_test.go @@ -475,6 +475,17 @@ func TestUDPReadTimeout(t *testing.T) { } func TestAllocs(t *testing.T) { + switch runtime.GOOS { + case "plan9": + // Plan9 wasn't optimized. + t.Skipf("skipping on %v", runtime.GOOS) + } + builder := os.Getenv("GO_BUILDER_NAME") + switch builder { + case "linux-amd64-noopt": + // Optimizations are required to remove the allocs. + t.Skipf("skipping on %v", builder) + } conn, err := ListenUDP("udp4", &UDPAddr{IP: IPv4(127, 0, 0, 1)}) if err != nil { t.Fatal(err) From f249fa27a9117dd5986f35463fc6a1467ecc72bb Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Fri, 5 Nov 2021 20:30:38 +0700 Subject: [PATCH 404/406] cmd/compile: only update source type when processing struct/array CL 360057 fixed missing update source type in storeArgOrLoad. However, we should only update the type when processing struct/array. If we update the type right before calling storeArgOrLoad, we may generate a value with invalid type, e.g, OpStructSelect with non-struct type. Fixes #49378 Change-Id: Ib7e10f72f818880f550aae5c9f653db463ce29b0 Reviewed-on: https://go-review.googlesource.com/c/go/+/361594 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: David Chase --- src/cmd/compile/internal/ssa/expand_calls.go | 4 ++-- test/fixedbugs/issue49378.go | 25 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 test/fixedbugs/issue49378.go diff --git a/src/cmd/compile/internal/ssa/expand_calls.go b/src/cmd/compile/internal/ssa/expand_calls.go index 91ff9f87f9..a3cea855f2 100644 --- a/src/cmd/compile/internal/ssa/expand_calls.go +++ b/src/cmd/compile/internal/ssa/expand_calls.go @@ -954,11 +954,11 @@ func (x *expandState) storeArgOrLoad(pos src.XPos, b *Block, source, mem *Value, elt := t.Elem() if source.Type != t && t.NumElem() == 1 && elt.Size() == t.Size() && t.Size() == x.regSize { t = removeTrivialWrapperTypes(t) - source.Type = t // it could be a leaf type, but the "leaf" could be complex64 (for example) return x.storeArgOrLoad(pos, b, source, mem, t, storeOffset, loadRegOffset, storeRc) } eltRO := x.regWidth(elt) + source.Type = t for i := int64(0); i < t.NumElem(); i++ { sel := source.Block.NewValue1I(pos, OpArraySelect, elt, i, source) mem = x.storeArgOrLoad(pos, b, sel, mem, elt, storeOffset+i*elt.Size(), loadRegOffset, storeRc.at(t, 0)) @@ -988,11 +988,11 @@ func (x *expandState) storeArgOrLoad(pos src.XPos, b *Block, source, mem *Value, // v139 is later stored as an intVal == struct{val *big.Int} which naively requires the fields of // of a *uint8, which does not succeed. t = removeTrivialWrapperTypes(t) - source.Type = t // it could be a leaf type, but the "leaf" could be complex64 (for example) return x.storeArgOrLoad(pos, b, source, mem, t, storeOffset, loadRegOffset, storeRc) } + source.Type = t for i := 0; i < t.NumFields(); i++ { fld := t.Field(i) sel := source.Block.NewValue1I(pos, OpStructSelect, fld.Type, int64(i), source) diff --git a/test/fixedbugs/issue49378.go b/test/fixedbugs/issue49378.go new file mode 100644 index 0000000000..70f466c929 --- /dev/null +++ b/test/fixedbugs/issue49378.go @@ -0,0 +1,25 @@ +// compile + +// Copyright 2021 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 p + +func f(i int) { + var s1 struct { + s struct{ s struct{ i int } } + } + var s2, s3 struct { + a struct{ i int } + b int + } + func() { + i = 1 + 2*i + s3.a.i + func() int { + s2.a, s2.b = s3.a, s3.b + return 0 + }() + func(*int) int { + return s1.s.s.i + }(new(int)) + }() +} From c58417b97f2b8d16176ddd294ae4471f834ab4d6 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Thu, 4 Nov 2021 16:53:30 -0400 Subject: [PATCH 405/406] runtime: mark TestTracebackArgs test functions nosplit The argument liveness tests expect outputs where a dead stack slot has a poisoned value. If the test function is preempted at the prologue, it will go with the morestack code path which will spill all the argument registers. Mark them nosplit to avoid that. Should fix #49354. Change-Id: I3b13e72e925748687a53c494bfaa70f07d9496fa Reviewed-on: https://go-review.googlesource.com/c/go/+/361211 Trust: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Go Bot Reviewed-by: Austin Clements --- src/runtime/traceback_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/runtime/traceback_test.go b/src/runtime/traceback_test.go index 0333b85c56..7d8b04e14b 100644 --- a/src/runtime/traceback_test.go +++ b/src/runtime/traceback_test.go @@ -353,6 +353,9 @@ func testTracebackArgs8d(a testArgsType8d) int { return n } +// nosplit to avoid preemption or morestack spilling registers. +// +//go:nosplit //go:noinline func testTracebackArgs9(a int64, b int32, c int16, d int8, x [2]int, y int) int { if a < 0 { @@ -366,6 +369,9 @@ func testTracebackArgs9(a int64, b int32, c int16, d int8, x [2]int, y int) int return n } +// nosplit to avoid preemption or morestack spilling registers. +// +//go:nosplit //go:noinline func testTracebackArgs10(a, b, c, d, e int32) int { // no use of any args @@ -373,8 +379,10 @@ func testTracebackArgs10(a, b, c, d, e int32) int { } // norace to avoid race instrumentation changing spill locations. +// nosplit to avoid preemption or morestack spilling registers. // //go:norace +//go:nosplit //go:noinline func testTracebackArgs11a(a, b, c int32) int { if a < 0 { @@ -387,8 +395,10 @@ func testTracebackArgs11a(a, b, c int32) int { } // norace to avoid race instrumentation changing spill locations. +// nosplit to avoid preemption or morestack spilling registers. // //go:norace +//go:nosplit //go:noinline func testTracebackArgs11b(a, b, c, d int32) int { var x int32 From 3796df1b13c6be62ca28244dcd6121544770e371 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 4 Nov 2021 21:35:55 -0700 Subject: [PATCH 406/406] net/netip: don't accept ParseAddr with leading zeros Fixes #49365 Updates #30999 Change-Id: Ic92bce01b435baf70574c65524bde82f9cee3d8d Reviewed-on: https://go-review.googlesource.com/c/go/+/361534 Run-TryBot: Brad Fitzpatrick TryBot-Result: Go Bot Reviewed-by: Josh Bleecher Snyder Trust: Josh Bleecher Snyder Trust: Brad Fitzpatrick --- src/net/netip/netip.go | 6 ++++++ src/net/netip/netip_test.go | 32 +++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/net/netip/netip.go b/src/net/netip/netip.go index 02a4aa0452..b0c13b81fc 100644 --- a/src/net/netip/netip.go +++ b/src/net/netip/netip.go @@ -155,9 +155,14 @@ func (err parseAddrError) Error() string { func parseIPv4(s string) (ip Addr, err error) { var fields [4]uint8 var val, pos int + var digLen int // number of digits in current octet for i := 0; i < len(s); i++ { if s[i] >= '0' && s[i] <= '9' { + if digLen == 1 && val == 0 { + return Addr{}, parseAddrError{in: s, msg: "IPv4 field has octet with leading zero"} + } val = val*10 + int(s[i]) - '0' + digLen++ if val > 255 { return Addr{}, parseAddrError{in: s, msg: "IPv4 field has value >255"} } @@ -175,6 +180,7 @@ func parseIPv4(s string) (ip Addr, err error) { fields[pos] = uint8(val) pos++ val = 0 + digLen = 0 } else { return Addr{}, parseAddrError{in: s, msg: "unexpected character", at: s[i:]} } diff --git a/src/net/netip/netip_test.go b/src/net/netip/netip_test.go index 5d935c8fd3..241a71bb83 100644 --- a/src/net/netip/netip_test.go +++ b/src/net/netip/netip_test.go @@ -29,9 +29,10 @@ var ( func TestParseAddr(t *testing.T) { var validIPs = []struct { - in string - ip Addr // output of ParseAddr() - str string // output of String(). If "", use in. + in string + ip Addr // output of ParseAddr() + str string // output of String(). If "", use in. + wantErr string }{ // Basic zero IPv4 address. { @@ -45,15 +46,18 @@ func TestParseAddr(t *testing.T) { }, // IPv4 address in windows-style "print all the digits" form. { - in: "010.000.015.001", - ip: MkAddr(Mk128(0, 0xffff0a000f01), Z4), - str: "10.0.15.1", + in: "010.000.015.001", + wantErr: `ParseAddr("010.000.015.001"): IPv4 field has octet with leading zero`, }, // IPv4 address with a silly amount of leading zeros. { - in: "000001.00000002.00000003.000000004", - ip: MkAddr(Mk128(0, 0xffff01020304), Z4), - str: "1.2.3.4", + in: "000001.00000002.00000003.000000004", + wantErr: `ParseAddr("000001.00000002.00000003.000000004"): IPv4 field has octet with leading zero`, + }, + // 4-in-6 with octet with leading zero + { + in: "::ffff:1.2.03.4", + wantErr: `ParseAddr("::ffff:1.2.03.4"): ParseAddr("1.2.03.4"): IPv4 field has octet with leading zero (at "1.2.03.4")`, }, // Basic zero IPv6 address. { @@ -121,10 +125,16 @@ func TestParseAddr(t *testing.T) { t.Run(test.in, func(t *testing.T) { got, err := ParseAddr(test.in) if err != nil { + if err.Error() == test.wantErr { + return + } t.Fatal(err) } + if test.wantErr != "" { + t.Fatalf("wanted error %q; got none", test.wantErr) + } if got != test.ip { - t.Errorf("ParseAddr(%q) got %#v, want %#v", test.in, got, test.ip) + t.Errorf("got %#v, want %#v", got, test.ip) } // Check that ParseAddr is a pure function. @@ -963,7 +973,7 @@ func TestIs4In6(t *testing.T) { {mustIP("::ffff:192.0.2.128"), true, mustIP("192.0.2.128")}, {mustIP("::ffff:192.0.2.128%eth0"), true, mustIP("192.0.2.128")}, {mustIP("::fffe:c000:0280"), false, mustIP("::fffe:c000:0280")}, - {mustIP("::ffff:127.001.002.003"), true, mustIP("127.1.2.3")}, + {mustIP("::ffff:127.1.2.3"), true, mustIP("127.1.2.3")}, {mustIP("::ffff:7f01:0203"), true, mustIP("127.1.2.3")}, {mustIP("0:0:0:0:0000:ffff:127.1.2.3"), true, mustIP("127.1.2.3")}, {mustIP("0:0:0:0:000000:ffff:127.1.2.3"), true, mustIP("127.1.2.3")},