1
0
mirror of https://github.com/golang/go synced 2024-11-11 23:20:24 -07:00

[dev.typeparams] all: merge master (c8f4e61) into dev.typeparams

Conflicts:

- src/runtime/internal/sys/zgoarch_386.go
- src/runtime/internal/sys/zgoarch_amd64.go
- src/runtime/internal/sys/zgoarch_arm.go
- src/runtime/internal/sys/zgoarch_arm64.go
- src/runtime/internal/sys/zgoarch_arm64be.go
- src/runtime/internal/sys/zgoarch_armbe.go
- src/runtime/internal/sys/zgoarch_mips.go
- src/runtime/internal/sys/zgoarch_mips64.go
- src/runtime/internal/sys/zgoarch_mips64le.go
- src/runtime/internal/sys/zgoarch_mips64p32.go
- src/runtime/internal/sys/zgoarch_mips64p32le.go
- src/runtime/internal/sys/zgoarch_mipsle.go
- src/runtime/internal/sys/zgoarch_ppc.go
- src/runtime/internal/sys/zgoarch_ppc64.go
- src/runtime/internal/sys/zgoarch_ppc64le.go
- src/runtime/internal/sys/zgoarch_riscv.go
- src/runtime/internal/sys/zgoarch_riscv64.go
- src/runtime/internal/sys/zgoarch_s390.go
- src/runtime/internal/sys/zgoarch_s390x.go
- src/runtime/internal/sys/zgoarch_sparc.go
- src/runtime/internal/sys/zgoarch_sparc64.go
- src/runtime/internal/sys/zgoarch_wasm.go

  On dev.typeparams, CL 328336 moved these files to internal/goarch;
  whereas on master, CL 333909 reserved GOARCH=loong64. For this CL,
  I resolved the conflict by simply running "go generate internal/goarch".

Merge List:

+ 2021-07-19 c8f4e6152d spec: correct example comment in Conversions from slice to array
+ 2021-07-19 1d91551b73 time: correct typo in documentation for UnixMicro
+ 2021-07-19 404127c30f cmd/compile: fix off-by-one error in traceback argument counting
+ 2021-07-19 6298cfe672 cmd/compile: fix typo in fatal message of builtinCall
+ 2021-07-19 49402bee36 cmd/{compile,link}: fix bug in map.zero handling
+ 2021-07-18 a66190ecee test/bench/go1: fix size for RegexpMatchMedium_32
+ 2021-07-18 650fc2117a text/scanner: use Go convention in Position doc comment
+ 2021-07-16 aa4e0f528e net/http:  correct capitalization in cancelTimeBody comment
+ 2021-07-15 0941dbca6a testing: clarify in docs that TestMain is advanced
+ 2021-07-15 69728ead87 cmd/go: update error messages in tests to match CL 332573
+ 2021-07-15 c1cc9f9c3d cmd/compile: fix lookup package of redeclared dot import symbol
+ 2021-07-15 21a04e3335 doc/go1.17: mention GOARCH=loong64
+ 2021-07-14 2b00a54baf go/build, runtime/internal/sys: reserve GOARCH=loong64
+ 2021-07-14 60ddf42b46 cmd/go: change link in error message from /wiki to /doc.
+ 2021-07-13 d8f348a589 cmd/go: remove a duplicated word from 'go help mod graph'
+ 2021-07-12 a98589711d crypto/tls: test key type when casting
+ 2021-07-12 cfbd73ba33 doc/go1.17: editing pass over the "Compiler" section
+ 2021-07-09 ab4085ce84 runtime/pprof: call runtime.GC twice in memory profile test

Change-Id: I1490a4c7e4c560659c21a4eb67d243f35d1f908e
This commit is contained in:
Matthew Dempsky 2021-07-20 12:46:13 -07:00
commit e4994e71fb
53 changed files with 486 additions and 75 deletions

View File

@ -119,6 +119,17 @@ Do not send CLs removing the interior tags from such phrases.
stack frame pointers only on Linux, macOS, and iOS.
</p>
<h3 id="loong64">loong64 GOARCH value reserved</h3>
<p><!-- CL 333909 -->
The main Go compiler does not yet support the LoongArch
architecture, but we've reserved the <code>GOARCH</code> value
"<code>loong64</code>".
This means that Go files named <code>*_loong64.go</code> will now
be <a href="/pkg/go/build/#hdr-Build_Constraints">ignored by Go
tools</a> except when that GOARCH value is being used.
</p>
<h2 id="tools">Tools</h2>
<h3 id="go-command">Go command</h3>
@ -401,30 +412,37 @@ func Foo() bool {
<p><!-- golang.org/issue/40724 -->
Go 1.17 implements a new way of passing function arguments and results using
registers instead of the stack. This work is enabled for Linux, macOS, and
Windows on the 64-bit x86 architecture (the <code>linux/amd64</code>,
<code>darwin/amd64</code>, <code>windows/amd64</code> ports). For a
representative set of Go packages and programs, benchmarking has shown
performance improvements of about 5%, and a typical reduction in binary size
of about 2%.
registers instead of the stack.
Benchmarks for a representative set of Go packages and programs show
performance improvements of about 5%, and a typical reduction in
binary size of about 2%.
This is currently enabled for Linux, macOS, and Windows on the
64-bit x86 architecture (the <code>linux/amd64</code>,
<code>darwin/amd64</code>, and <code>windows/amd64</code> ports).
</p>
<p>
This change does not affect the functionality of any safe Go code. It can affect
code outside the <a href="/doc/go1compat">compatibility guidelines</a> with
minimal impact. To maintain compatibility with existing assembly functions,
adapter functions converting between the new register-based calling convention
and the previous stack-based calling convention (also known as ABI wrappers)
are sometimes used. This is mostly invisible to users, except for assembly
functions that have their addresses taken in Go. Using <code>reflect.ValueOf(fn).Pointer()</code>
(or similar approaches such as via <code>unsafe.Pointer</code>) to get the address
of an assembly function will now return the address of the ABI wrapper. This is
mostly harmless, except for special-purpose assembly code (such as accessing
thread-local storage or requiring a special stack alignment). Assembly functions
called indirectly from Go via <code>func</code> values will now be made through
ABI wrappers, which may cause a very small performance overhead. Also, calling
Go functions from assembly may now go through ABI wrappers, with a very small
performance overhead.
This change does not affect the functionality of any safe Go code
and is designed to have no impact on most assembly code.
It may affect code that violates
the <a href="/pkg/unsafe#Pointer"><code>unsafe.Pointer</code></a>
rules when accessing function arguments, or that depends on
undocumented behavior involving comparing function code pointers.
To maintain compatibility with existing assembly functions, the
compiler generates adapter functions that convert between the new
register-based calling convention and the previous stack-based
calling convention.
These adapters are typically invisible to users, except that taking
the address of a Go function in assembly code or taking the address
of an assembly function in Go code
using <code>reflect.ValueOf(fn).Pointer()</code>
or <code>unsafe.Pointer</code> will now return the address of the
adapter.
Code that depends on the value of these code pointers may no longer
behave as expected.
Adapters also may cause a very small performance overhead in two
cases: calling an assembly function indirectly from Go via
a <code>func</code> value, and calling Go functions from assembly.
</p>
<p><!-- CL 304470 -->
@ -440,11 +458,14 @@ func Foo() bool {
</p>
<p><!-- CL 283112, golang.org/issue/28727 -->
Functions containing closures can now be inlined. One effect of this change is
that a function with a closure may actually produce a distinct closure function
for each place that the function is inlined. Hence, this change could reveal
bugs where Go functions are compared (incorrectly) by pointer value. Go
functions are by definition not comparable.
Functions containing closures can now be inlined.
One effect of this change is that a function with a closure may
produce a distinct closure code pointer for each place that the
function is inlined.
Go function values are not directly comparable, but this change
could reveal bugs in code that uses <code>reflect</code>
or <code>unsafe.Pointer</code> to bypass this language restriction
and compare functions by code pointer.
</p>
<h2 id="library">Core library</h2>

View File

@ -4334,7 +4334,7 @@ s4 := (*[4]byte)(s) // panics: len([4]byte) > len(s)
var t []string
t0 := (*[0]string)(t) // t0 == nil
t1 := (*[1]string)(t) // panics: len([1]string) > len(s)
t1 := (*[1]string)(t) // panics: len([1]string) > len(t)
</pre>
<h3 id="Constant_expressions">Constant expressions</h3>

View File

@ -149,7 +149,7 @@ func dumpdata() {
if reflectdata.ZeroSize > 0 {
zero := base.PkgLinksym("go.map", "zero", obj.ABI0)
objw.Global(zero, int32(reflectdata.ZeroSize), obj.DUPOK|obj.RODATA)
zero.Set(obj.AttrContentAddressable, true)
zero.Set(obj.AttrStatic, true)
}
staticdata.WriteFuncSyms()

View File

@ -6434,6 +6434,7 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
x := base.Ctxt.Lookup(fmt.Sprintf("%s.arginfo%d", f.LSym.Name, f.ABI))
PtrSize := int64(types.PtrSize)
uintptrTyp := types.Types[types.TUINTPTR]
isAggregate := func(t *types.Type) bool {
return t.IsStruct() || t.IsArray() || t.IsComplex() || t.IsInterface() || t.IsString() || t.IsSlice()
@ -6477,12 +6478,8 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
n := 0
writebyte := func(o uint8) { wOff = objw.Uint8(x, wOff, o) }
// Write one non-aggrgate arg/field/element if there is room.
// Returns whether to continue.
write1 := func(sz, offset int64) bool {
if n >= limit {
return false
}
// Write one non-aggrgate arg/field/element.
write1 := func(sz, offset int64) {
if offset >= _special {
writebyte(_offsetTooLarge)
} else {
@ -6490,7 +6487,6 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
writebyte(uint8(sz))
}
n++
return true
}
// Visit t recursively and write it out.
@ -6498,10 +6494,12 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
var visitType func(baseOffset int64, t *types.Type, depth int) bool
visitType = func(baseOffset int64, t *types.Type, depth int) bool {
if n >= limit {
writebyte(_dotdotdot)
return false
}
if !isAggregate(t) {
return write1(t.Size(), baseOffset)
write1(t.Size(), baseOffset)
return true
}
writebyte(_startAgg)
depth++
@ -6511,58 +6509,47 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
n++
return true
}
var r bool
switch {
case t.IsInterface(), t.IsString():
r = write1(PtrSize, baseOffset) &&
write1(PtrSize, baseOffset+PtrSize)
_ = visitType(baseOffset, uintptrTyp, depth) &&
visitType(baseOffset+PtrSize, uintptrTyp, depth)
case t.IsSlice():
r = write1(PtrSize, baseOffset) &&
write1(PtrSize, baseOffset+PtrSize) &&
write1(PtrSize, baseOffset+PtrSize*2)
_ = visitType(baseOffset, uintptrTyp, depth) &&
visitType(baseOffset+PtrSize, uintptrTyp, depth) &&
visitType(baseOffset+PtrSize*2, uintptrTyp, depth)
case t.IsComplex():
r = write1(t.Size()/2, baseOffset) &&
write1(t.Size()/2, baseOffset+t.Size()/2)
_ = visitType(baseOffset, types.FloatForComplex(t), depth) &&
visitType(baseOffset+t.Size()/2, types.FloatForComplex(t), depth)
case t.IsArray():
r = true
if t.NumElem() == 0 {
n++ // {} counts as a component
break
}
for i := int64(0); i < t.NumElem(); i++ {
if !visitType(baseOffset, t.Elem(), depth) {
r = false
break
}
baseOffset += t.Elem().Size()
}
case t.IsStruct():
r = true
if t.NumFields() == 0 {
n++ // {} counts as a component
break
}
for _, field := range t.Fields().Slice() {
if !visitType(baseOffset+field.Offset, field.Type, depth) {
r = false
break
}
}
}
if !r {
writebyte(_dotdotdot)
}
writebyte(_endAgg)
return r
return true
}
c := true
for _, a := range abiInfo.InParams() {
if !c {
writebyte(_dotdotdot)
if !visitType(a.FrameOffset(abiInfo), a.Type, 0) {
break
}
c = visitType(a.FrameOffset(abiInfo), a.Type, 0)
}
writebyte(_endSeq)
if wOff > maxLen {

View File

@ -106,7 +106,17 @@ func Export(n *ir.Name) {
// Redeclared emits a diagnostic about symbol s being redeclared at pos.
func Redeclared(pos src.XPos, s *types.Sym, where string) {
if !s.Lastlineno.IsKnown() {
pkgName := DotImportRefs[s.Def.(*ir.Ident)]
var pkgName *ir.PkgName
if s.Def == nil {
for id, pkg := range DotImportRefs {
if id.Sym().Name == s.Name {
pkgName = pkg
break
}
}
} else {
pkgName = DotImportRefs[s.Def.(*ir.Ident)]
}
base.ErrorfAt(pos, "%v redeclared %s\n"+
"\t%v: previous declaration during import %q", s, where, base.FmtPos(pkgName.Pos()), pkgName.Pkg.Path)
} else {

View File

@ -1741,7 +1741,7 @@ func (r *importReader) exprsOrNil() (a, b ir.Node) {
func builtinCall(pos src.XPos, op ir.Op) *ir.CallExpr {
if go117ExportTypes {
// These should all be encoded as direct ops, not OCALL.
base.Fatalf("builtinCall should not be invoked when types are included in inport/export")
base.Fatalf("builtinCall should not be invoked when types are included in import/export")
}
return ir.NewCallExpr(pos, ir.OCALL, ir.NewIdent(base.Pos, types.BuiltinPkg.Lookup(ir.OpNames[op])), nil)
}

View File

@ -1193,7 +1193,7 @@
// and one of its requirements. Each module is identified as a string of the form
// path@version, except for the main module, which has no @version suffix.
//
// The -go flag causes graph to report the module graph as loaded by by the
// The -go flag causes graph to report the module graph as loaded by the
// given Go version, instead of the version indicated by the 'go' directive
// in the go.mod file.
//

View File

@ -26,7 +26,7 @@ in text form. Each line in the output has two space-separated fields: a module
and one of its requirements. Each module is identified as a string of the form
path@version, except for the main module, which has no @version suffix.
The -go flag causes graph to report the module graph as loaded by by the
The -go flag causes graph to report the module graph as loaded by the
given Go version, instead of the version indicated by the 'go' directive
in the go.mod file.

View File

@ -1808,7 +1808,7 @@ func (ld *loader) checkTidyCompatibility(ctx context.Context, rs *Requirements)
fmt.Fprintf(os.Stderr, "If reproducibility with go %s is not needed:\n\tgo mod tidy%s -compat=%s\n", ld.TidyCompatibleVersion, goFlag, ld.GoVersion)
// TODO(#46141): Populate the linked wiki page.
fmt.Fprintf(os.Stderr, "For other options, see:\n\thttps://golang.org/wiki/PruningModules\n")
fmt.Fprintf(os.Stderr, "For other options, see:\n\thttps://golang.org/doc/modules/pruning\n")
}
mg, err := rs.Graph(ctx)

View File

@ -23,7 +23,7 @@ cp go.mod go.mod.orig
stderr '^example\.com/m imports\n\texample\.net/indirect imports\n\texample\.net/ambiguous/nested/pkg loaded from example\.net/ambiguous/nested@v0\.1\.0,\n\tbut go 1.16 would fail to locate it:\n\tambiguous import: found package example\.net/ambiguous/nested/pkg in multiple modules:\n\texample\.net/ambiguous v0.1.0 \(.*\)\n\texample\.net/ambiguous/nested v0.1.0 \(.*\)\n\n'
stderr '\n\nTo proceed despite packages unresolved in go 1\.16:\n\tgo mod tidy -e\nIf reproducibility with go 1.16 is not needed:\n\tgo mod tidy -compat=1\.17\nFor other options, see:\n\thttps://golang\.org/wiki/PruningModules\n'
stderr '\n\nTo proceed despite packages unresolved in go 1\.16:\n\tgo mod tidy -e\nIf reproducibility with go 1.16 is not needed:\n\tgo mod tidy -compat=1\.17\nFor other options, see:\n\thttps://golang\.org/doc/modules/pruning\n'
cmp go.mod go.mod.orig

View File

@ -19,7 +19,7 @@ cp go.mod go.mod.orig
stderr '^example\.com/m imports\n\texample\.net/deleted loaded from example\.net/deleted@v0\.1\.0,\n\tbut go 1\.16 would fail to locate it in example\.net/deleted@v0\.2\.0\n\n'
stderr '\n\nTo upgrade to the versions selected by go 1.16, leaving some packages unresolved:\n\tgo mod tidy -e -go=1\.16 && go mod tidy -e -go=1\.17\nIf reproducibility with go 1.16 is not needed:\n\tgo mod tidy -compat=1\.17\nFor other options, see:\n\thttps://golang\.org/wiki/PruningModules\n'
stderr '\n\nTo upgrade to the versions selected by go 1.16, leaving some packages unresolved:\n\tgo mod tidy -e -go=1\.16 && go mod tidy -e -go=1\.17\nIf reproducibility with go 1.16 is not needed:\n\tgo mod tidy -compat=1\.17\nFor other options, see:\n\thttps://golang\.org/doc/modules/pruning\n'
# The suggested 'go mod tidy -e' command should proceed anyway.

View File

@ -33,7 +33,7 @@ env MODFMT='{{with .Module}}{{.Path}} {{.Version}}{{end}}'
cp go.mod go.mod.orig
! go mod tidy
stderr '^example\.com/m imports\n\texample\.net/lazy tested by\n\texample\.net/lazy.test imports\n\texample\.com/retract/incompatible loaded from example\.com/retract/incompatible@v1\.0\.0,\n\tbut go 1\.16 would select v2\.0\.0\+incompatible\n\n'
stderr '\n\nTo upgrade to the versions selected by go 1\.16:\n\tgo mod tidy -go=1\.16 && go mod tidy -go=1\.17\nIf reproducibility with go 1.16 is not needed:\n\tgo mod tidy -compat=1.17\nFor other options, see:\n\thttps://golang\.org/wiki/PruningModules\n'
stderr '\n\nTo upgrade to the versions selected by go 1\.16:\n\tgo mod tidy -go=1\.16 && go mod tidy -go=1\.17\nIf reproducibility with go 1.16 is not needed:\n\tgo mod tidy -compat=1.17\nFor other options, see:\n\thttps://golang\.org/doc/modules/pruning\n'
cmp go.mod go.mod.orig

View File

@ -33,7 +33,7 @@ env MODFMT='{{with .Module}}{{.Path}} {{.Version}}{{end}}'
cp go.mod go.mod.orig
! go mod tidy
stderr '^example\.com/m imports\n\texample\.net/lazy imports\n\texample\.com/retract/incompatible loaded from example\.com/retract/incompatible@v1\.0\.0,\n\tbut go 1\.16 would select v2\.0\.0\+incompatible\n\n'
stderr '\n\nTo upgrade to the versions selected by go 1\.16:\n\tgo mod tidy -go=1\.16 && go mod tidy -go=1\.17\nIf reproducibility with go 1\.16 is not needed:\n\tgo mod tidy -compat=1.17\nFor other options, see:\n\thttps://golang\.org/wiki/PruningModules\n'
stderr '\n\nTo upgrade to the versions selected by go 1\.16:\n\tgo mod tidy -go=1\.16 && go mod tidy -go=1\.17\nIf reproducibility with go 1\.16 is not needed:\n\tgo mod tidy -compat=1.17\nFor other options, see:\n\thttps://golang\.org/doc/modules/pruning\n'
cmp go.mod go.mod.orig

View File

@ -459,6 +459,15 @@ func (st *loadState) addSym(name string, ver int, r *oReader, li uint32, kind in
if l.flags&FlagStrictDups != 0 {
l.checkdup(name, r, li, oldi)
}
// Fix for issue #47185 -- given two dupok symbols with
// different sizes, favor symbol with larger size. See
// also issue #46653.
szdup := l.SymSize(oldi)
sz := int64(r.Sym(li).Siz())
if szdup < sz {
// new symbol overwrites old symbol.
l.objSyms[oldi] = objSym{r.objidx, li}
}
return oldi
}
oldr, oldli := l.toLocal(oldi)

View File

@ -86,7 +86,11 @@ func (ka rsaKeyAgreement) generateClientKeyExchange(config *Config, clientHello
return nil, nil, err
}
encrypted, err := rsa.EncryptPKCS1v15(config.rand(), cert.PublicKey.(*rsa.PublicKey), preMasterSecret)
rsaKey, ok := cert.PublicKey.(*rsa.PublicKey)
if !ok {
return nil, nil, errors.New("tls: server certificate contains incorrect key type for selected ciphersuite")
}
encrypted, err := rsa.EncryptPKCS1v15(config.rand(), rsaKey, preMasterSecret)
if err != nil {
return nil, nil, err
}

View File

@ -8,4 +8,4 @@ package build
// Do not remove from this list, as these are used for go/build filename matching.
const goosList = "aix android darwin dragonfly freebsd hurd illumos ios js linux nacl netbsd openbsd plan9 solaris windows zos "
const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc riscv riscv64 s390 s390x sparc sparc64 wasm "
const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 ppc64le loong64 mips mipsle mips64 mips64le mips64p32 mips64p32le ppc riscv riscv64 s390 s390x sparc sparc64 wasm "

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 1
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 1
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -0,0 +1,33 @@
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
//go:build loong64
// +build loong64
package goarch
const GOARCH = `loong64`
const Is386 = 0
const IsAmd64 = 0
const IsAmd64p32 = 0
const IsArm = 0
const IsArmbe = 0
const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 1
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0
const IsMips64le = 0
const IsMips64p32 = 0
const IsMips64p32le = 0
const IsPpc = 0
const IsRiscv = 0
const IsRiscv64 = 0
const IsS390 = 0
const IsS390x = 0
const IsSparc = 0
const IsSparc64 = 0
const IsWasm = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 1
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 1

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 1
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 1
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 1
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -16,6 +16,7 @@ const IsArm64 = 0
const IsArm64be = 0
const IsPpc64 = 0
const IsPpc64le = 0
const IsLoong64 = 0
const IsMips = 0
const IsMipsle = 0
const IsMips64 = 0

View File

@ -951,7 +951,7 @@ func (c *Client) CloseIdleConnections() {
}
// cancelTimerBody is an io.ReadCloser that wraps rc with two features:
// 1) on Read error or close, the stop func is called.
// 1) On Read error or close, the stop func is called.
// 2) On Read failure, if reqDidTimeout is true, the error is wrapped and
// marked as net.Error that hit its timeout.
type cancelTimerBody struct {

View File

@ -86,6 +86,17 @@ 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 {

View File

@ -19,8 +19,8 @@ func TestTracebackArgs(t *testing.T) {
}{
// simple ints
{
func() int { return testTracebackArgs1(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) },
"testTracebackArgs1(0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, ...)",
func() int { return testTracebackArgs1(1, 2, 3, 4, 5) },
"testTracebackArgs1(0x1, 0x2, 0x3, 0x4, 0x5)",
},
// some aggregates
{
@ -53,6 +53,58 @@ func TestTracebackArgs(t *testing.T) {
},
"testTracebackArgs5(0x0, {0x1, {}, {{}, {}}}, {}, {}, {}, {}, {}, ...)",
},
// edge cases for ...
// no ... for 10 args
{
func() int { return testTracebackArgs6a(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) },
"testTracebackArgs6a(0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa)",
},
// has ... for 11 args
{
func() int { return testTracebackArgs6b(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) },
"testTracebackArgs6b(0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, ...)",
},
// no ... for aggregates with 10 words
{
func() int { return testTracebackArgs7a([10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) },
"testTracebackArgs7a({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa})",
},
// has ... for aggregates with 11 words
{
func() int { return testTracebackArgs7b([11]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}) },
"testTracebackArgs7b({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, ...})",
},
// no ... for aggregates, but with more args
{
func() int { return testTracebackArgs7c([10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 11) },
"testTracebackArgs7c({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa}, ...)",
},
// has ... for aggregates and also for more args
{
func() int { return testTracebackArgs7d([11]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 12) },
"testTracebackArgs7d({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, ...}, ...)",
},
// nested aggregates, no ...
{
func() int { return testTracebackArgs8a(testArgsType8a{1, 2, 3, 4, 5, 6, 7, 8, [2]int{9, 10}}) },
"testTracebackArgs8a({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, {0x9, 0xa}})",
},
// nested aggregates, ... in inner but not outer
{
func() int { return testTracebackArgs8b(testArgsType8b{1, 2, 3, 4, 5, 6, 7, 8, [3]int{9, 10, 11}}) },
"testTracebackArgs8b({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, {0x9, 0xa, ...}})",
},
// nested aggregates, ... in outer but not inner
{
func() int { return testTracebackArgs8c(testArgsType8c{1, 2, 3, 4, 5, 6, 7, 8, [2]int{9, 10}, 11}) },
"testTracebackArgs8c({0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, {0x9, 0xa}, ...})",
},
// nested aggregates, ... in both inner and outer
{
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, ...}, ...})",
},
}
for _, test := range tests {
n := test.fn()
@ -64,11 +116,11 @@ func TestTracebackArgs(t *testing.T) {
}
//go:noinline
func testTracebackArgs1(a, b, c, d, e, f, g, h, i, j, k, l int) int {
func testTracebackArgs1(a, b, c, d, e int) int {
n := runtime.Stack(testTracebackArgsBuf[:], false)
if a < 0 {
// use in-reg args to keep them alive
return a + b + c + d + e + f + g + h + i + j + k + l
return a + b + c + d + e
}
return n
}
@ -119,3 +171,122 @@ func testTracebackArgs5(a bool, x struct {
}
return n
}
//go:noinline
func testTracebackArgs6a(a, b, c, d, e, f, g, h, i, j int) int {
n := runtime.Stack(testTracebackArgsBuf[:], false)
if a < 0 {
// use in-reg args to keep them alive
return a + b + c + d + e + f + g + h + i + j
}
return n
}
//go:noinline
func testTracebackArgs6b(a, b, c, d, e, f, g, h, i, j, k int) int {
n := runtime.Stack(testTracebackArgsBuf[:], false)
if a < 0 {
// use in-reg args to keep them alive
return a + b + c + d + e + f + g + h + i + j + k
}
return n
}
//go:noinline
func testTracebackArgs7a(a [10]int) int {
n := runtime.Stack(testTracebackArgsBuf[:], false)
if a[0] < 0 {
// use in-reg args to keep them alive
return a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]
}
return n
}
//go:noinline
func testTracebackArgs7b(a [11]int) int {
n := runtime.Stack(testTracebackArgsBuf[:], false)
if a[0] < 0 {
// use in-reg args to keep them alive
return a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9] + a[10]
}
return n
}
//go:noinline
func testTracebackArgs7c(a [10]int, b int) int {
n := runtime.Stack(testTracebackArgsBuf[:], false)
if a[0] < 0 {
// use in-reg args to keep them alive
return a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9] + b
}
return n
}
//go:noinline
func testTracebackArgs7d(a [11]int, b int) int {
n := runtime.Stack(testTracebackArgsBuf[:], false)
if a[0] < 0 {
// use in-reg args to keep them alive
return a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9] + a[10] + b
}
return n
}
type testArgsType8a struct {
a, b, c, d, e, f, g, h int
i [2]int
}
type testArgsType8b struct {
a, b, c, d, e, f, g, h int
i [3]int
}
type testArgsType8c struct {
a, b, c, d, e, f, g, h int
i [2]int
j int
}
type testArgsType8d struct {
a, b, c, d, e, f, g, h int
i [3]int
j int
}
//go:noinline
func testTracebackArgs8a(a testArgsType8a) int {
n := runtime.Stack(testTracebackArgsBuf[:], false)
if a.a < 0 {
// use in-reg args to keep them alive
return a.b + a.c + a.d + a.e + a.f + a.g + a.h + a.i[0] + a.i[1]
}
return n
}
//go:noinline
func testTracebackArgs8b(a testArgsType8b) int {
n := runtime.Stack(testTracebackArgsBuf[:], false)
if a.a < 0 {
// use in-reg args to keep them alive
return a.b + a.c + a.d + a.e + a.f + a.g + a.h + a.i[0] + a.i[1] + a.i[2]
}
return n
}
//go:noinline
func testTracebackArgs8c(a testArgsType8c) int {
n := runtime.Stack(testTracebackArgsBuf[:], false)
if a.a < 0 {
// use in-reg args to keep them alive
return a.b + a.c + a.d + a.e + a.f + a.g + a.h + a.i[0] + a.i[1] + a.j
}
return n
}
//go:noinline
func testTracebackArgs8d(a testArgsType8d) int {
n := runtime.Stack(testTracebackArgsBuf[:], false)
if a.a < 0 {
// use in-reg args to keep them alive
return a.b + a.c + a.d + a.e + a.f + a.g + a.h + a.i[0] + a.i[1] + a.i[2] + a.j
}
return n
}

View File

@ -233,6 +233,8 @@
// os.Exit(m.Run())
// }
//
// TestMain is a low-level primitive and should not be necessary for casual
// testing needs, where ordinary test functions suffice.
package testing
import (

View File

@ -23,7 +23,7 @@ import (
"unicode/utf8"
)
// A source position is represented by a Position value.
// Position is a value that represents a source position.
// A position is valid if Line > 0.
type Position struct {
Filename string // filename, if any

View File

@ -1334,7 +1334,7 @@ func UnixMilli(msec int64) Time {
}
// UnixMicro returns the local Time corresponding to the given Unix time,
// usec milliseconds since January 1, 1970 UTC.
// usec microseconds since January 1, 1970 UTC.
func UnixMicro(usec int64) Time {
return Unix(usec/1e6, (usec%1e6)*1e3)
}

View File

@ -53,7 +53,7 @@ func BenchmarkRegexpMatchEasy0_32(b *testing.B) { benchmark(b, easy0, 32<<0) }
func BenchmarkRegexpMatchEasy0_1K(b *testing.B) { benchmark(b, easy0, 1<<10) }
func BenchmarkRegexpMatchEasy1_32(b *testing.B) { benchmark(b, easy1, 32<<0) }
func BenchmarkRegexpMatchEasy1_1K(b *testing.B) { benchmark(b, easy1, 1<<10) }
func BenchmarkRegexpMatchMedium_32(b *testing.B) { benchmark(b, medium, 1<<0) }
func BenchmarkRegexpMatchMedium_32(b *testing.B) { benchmark(b, medium, 32<<0) }
func BenchmarkRegexpMatchMedium_1K(b *testing.B) { benchmark(b, medium, 1<<10) }
func BenchmarkRegexpMatchHard_32(b *testing.B) { benchmark(b, hard, 32<<0) }
func BenchmarkRegexpMatchHard_1K(b *testing.B) { benchmark(b, hard, 1<<10) }

View File

@ -0,0 +1,72 @@
// 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
// Note that the use of CGO here is solely to trigger external
// linking, since that is required to trigger that bad behavior
// in this bug.
// #include <stdlib.h>
import "C"
func Bad() {
m := make(map[int64]A)
a := m[0]
if len(a.B.C1.D2.E2.F1) != 0 ||
len(a.B.C1.D2.E2.F2) != 0 ||
len(a.B.C1.D2.E2.F3) != 0 ||
len(a.B.C1.D2.E2.F4) != 0 ||
len(a.B.C1.D2.E2.F5) != 0 ||
len(a.B.C1.D2.E2.F6) != 0 ||
len(a.B.C1.D2.E2.F7) != 0 ||
len(a.B.C1.D2.E2.F8) != 0 ||
len(a.B.C1.D2.E2.F9) != 0 ||
len(a.B.C1.D2.E2.F10) != 0 ||
len(a.B.C1.D2.E2.F11) != 0 ||
len(a.B.C1.D2.E2.F16) != 0 {
panic("bad")
}
C.malloc(100)
}
type A struct {
B
}
type B struct {
C1 C
C2 C
}
type C struct {
D1 D
D2 D
}
type D struct {
E1 E
E2 E
E3 E
E4 E
}
type E struct {
F1 string
F2 string
F3 string
F4 string
F5 string
F6 string
F7 string
F8 string
F9 string
F10 string
F11 string
F12 string
F13 string
F14 string
F15 string
F16 string
}

View File

@ -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
import (
bad "issue47185.dir/bad"
)
func main() {
another()
bad.Bad()
}
func another() L {
m := make(map[string]L)
return m[""]
}
type L struct {
A Data
B Data
}
type Data struct {
F1 [22][]string
}

View File

@ -0,0 +1,11 @@
// +build cgo
// runindir
// 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.
// Another test to verify compiler and linker handling of multiple
// competing map.zero symbol definitions.
package ignored

View File

@ -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 main
import (
. "fmt"
)
func test() {
Println("foo")
}

View File

@ -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 main
func Println() {} // ERROR "Println redeclared in this block"
func main() {}

View File

@ -0,0 +1,7 @@
// errorcheckdir
// 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

View File

@ -2151,6 +2151,7 @@ var types2Failures = setOf(
"fixedbugs/issue4232.go", // types2 reports (correct) extra errors
"fixedbugs/issue4452.go", // types2 reports (correct) extra errors
"fixedbugs/issue4510.go", // types2 reports different (but ok) line numbers
"fixedbugs/issue47201.go", // types2 spells the error message differently
"fixedbugs/issue5609.go", // types2 needs a better error message
"fixedbugs/issue7525b.go", // types2 reports init cycle error on different line - ok otherwise
"fixedbugs/issue7525c.go", // types2 reports init cycle error on different line - ok otherwise