Skip to content

Commit

Permalink
[dev.unified] all: merge master (5a1c5b8) into dev.unified
Browse files Browse the repository at this point in the history
Conflicts:

- test/run.go

  Textual conflict adding to the known failures list for the nounified
  frontend.

Merge List:

+ 2022-06-24 5a1c5b8 cmd/go: add per-package indexing for modules outside mod cache
+ 2022-06-24 b9c4d94 cmd/go/internal/list: update help info with Deprecated field
+ 2022-06-24 73475ef go/types, types2: print qualified object names in cycle errors
+ 2022-06-24 3e58ef6 go/types, types2: better errors for == when type sets are empty
+ 2022-06-24 d38f1d1 doc/go1.19: Linux race detector now requires glibc 2.17
+ 2022-06-23 de5329f debug/dwarf: handle malformed line table with bad program offset
+ 2022-06-23 15605ca embed: document additional file name restrictions
+ 2022-06-22 2e773a3 test: add test that causes gofrontend crash
+ 2022-06-22 ff17b7d cmd/compile: don't use dictionary convert to shaped empty interface
+ 2022-06-22 2a3b467 cmd/go: make module .zip files group/world readable
+ 2022-06-22 bdab4cf cmd/go, cmd/link: support failure to create _cgo_import.go
+ 2022-06-22 aca37d1 cmd/go: avoid indexing modules in GOROOT
+ 2022-06-22 111cdb5 all: update to current golang.org/x/sys revision
+ 2022-06-22 4045b1b cmd/compile: fix assert condition in generic method call
+ 2022-06-22 6bad7e8 compress/gzip: always close bodyReader in Example_compressingReader
+ 2022-06-22 606c6c3 encoding/xml: check nil pointer in DecodeElement
+ 2022-06-22 f571518 cmd/cgo: dont override declared struct type
+ 2022-06-22 92c9b81 net: don't set netGo = true on Windows with no cgo
+ 2022-06-22 be0b2a3 cmd/trace: add basic documentation to main page
+ 2022-06-22 b004c73 go/types, types2: fix parameter order dependence in type inference
+ 2022-06-21 f2c7e78 spec: document operations which accept []byte|string constrained types
+ 2022-06-21 ab422f2 runtime/trace: ignore fallback stacks in test
+ 2022-06-21 66685fb doc/go1.19: use correct link to sync/atomic docs
+ 2022-06-21 4b236b4 runtime: convert flaky semaphore linearity test into benchmark
+ 2022-06-21 530511b cmd/go/internal/modindex: avoid walking modules when not needed
+ 2022-06-21 c2d373d cmd/compile: allow 128-bit values to be spilled
+ 2022-06-21 19ed442 test: add regress test for #53477
+ 2022-06-20 3fcbfb0 doc/go1.19: fix HTML validation issues
+ 2022-06-18 527ace0 cmd/compile: skip substituting closures in unsafe builtins arguments
+ 2022-06-17 ec58e3f test: add regress test for #53419
+ 2022-06-17 103cc66 cmd/go/internal/modfetch: prevent duplicate hashes in go.sum
+ 2022-06-17 d42a488 sync: add more notes about Cond behavior
+ 2022-06-17 9e2f289 cmd/go/internal/work: log clearer detail for subprocess errors in (*Builder).toolID
+ 2022-06-17 dd2d00f net: fix flaky *TimeoutMustNotReturn tests
+ 2022-06-17 6c25ba6 go/token: delete unused File.set field
+ 2022-06-16 9068c68 cmd/dist: add package . to 'go test' commands
+ 2022-06-16 7bad615 runtime: write much more direct test for semaphore waiter scalability
+ 2022-06-16 f38a580 cmd/go: add more tracing

Change-Id: I912c5879165e03f4d7f8ac3ee9241d50fc92a419
  • Loading branch information
mdempsky committed Jun 24, 2022
2 parents 09a838a + 5a1c5b8 commit e7100ad
Show file tree
Hide file tree
Showing 129 changed files with 1,505 additions and 815 deletions.
6 changes: 3 additions & 3 deletions doc/go1.19.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2 id="mem">Memory Model</h2>
the memory model used by C, C++, Java, JavaScript, Rust, and Swift.
Go only provides sequentially consistent atomics, not any of the more relaxed forms found in other languages.
Along with the memory model update,
Go 1.19 introduces <a href="#sync/atomic">new types in the <code>sync/atomic</code> package</a>
Go 1.19 introduces <a href="#atomic_types">new types in the <code>sync/atomic</code> package</a>
that make it easier to use atomic values, such as
<a href="/pkg/sync/atomic/#Int64">atomic.Int64</a>
and
Expand Down Expand Up @@ -741,7 +741,7 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
</dd>
</dl><!-- regexp -->

<dl id="runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
<dl id="pkg-runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
<dd>
<p><!-- https://go.dev/issue/51461 -->
The <a href="/pkg/runtime/#GOROOT"><code>GOROOT</code></a> function now returns the empty string
Expand Down Expand Up @@ -807,6 +807,7 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
Compared to v2, it is now typically 1.5x to 2x faster, uses half
as much memory, and it supports an unlimited number of
goroutines.
On Linux, the race detector now requires at least glibc version 2.17.
</p>

<p><!-- CL 336549 -->
Expand Down Expand Up @@ -847,7 +848,6 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
but often easier to use: it returns an additional boolean reporting whether an equal value was found.
</p>
</dd>
</dd>
</dl><!-- sort -->

<dl id="strconv"><dt><a href="/pkg/strconv/">strconv</a></dt>
Expand Down
44 changes: 36 additions & 8 deletions doc/go_spec.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Version of June 14, 2022",
"Subtitle": "Version of June 21, 2022",
"Path": "/ref/spec"
}-->

Expand Down Expand Up @@ -1811,6 +1811,31 @@ <h3 id="Core_types">Core types</h3>
interface{ &lt;-chan int | chan&lt;- int } // directional channels have different directions
</pre>

<p>
Some operations (<a href="#Slice_expressions">slice expressions</a>,
<a href="#Appending_and_copying_slices"><code>append</code> and <code>copy</code></a>)
rely on a slightly more loose form of core types which accept byte slices and strings.
Specifically, if there are exactly two types, <code>[]byte</code> and <code>string</code>,
which are the underlying types of all types in the type set of interface <code>T</code>,
the core type of <code>T</code> is called <code>bytestring</code>.
</p>

<p>
Examples of interfaces with <code>bytestring</code> core types:
</p>

<pre>
interface{ int } // int (same as ordinary core type)
interface{ []byte | string } // bytestring
interface{ ~[]byte | myString } // bytestring
</pre>

<p>
Note that <code>bytestring</code> is not a real type; it cannot be used to declare
variables are compose other types. It exists solely to describe the behavior of some
operations that read from a sequence of bytes, which may be a byte slice or a string.
</p>

<h3 id="Type_identity">Type identity</h3>

<p>
Expand Down Expand Up @@ -3837,7 +3862,8 @@ <h4>Simple slice expressions</h4>

<p>
constructs a substring or slice. The <a href="#Core_types">core type</a> of
<code>a</code> must be a string, array, pointer to array, or slice.
<code>a</code> must be a string, array, pointer to array, slice, or a
<a href="#Core_types"><code>bytestring</code></a>.
The <i>indices</i> <code>low</code> and
<code>high</code> select which elements of operand <code>a</code> appear
in the result. The result has indices starting at 0 and length equal to
Expand Down Expand Up @@ -5469,7 +5495,7 @@ <h4 id="Conversions_to_and_from_a_string_type">Conversions to and from a string

type myRune rune
string([]myRune{0x266b, 0x266c}) // "\u266b\u266c" == "♫♬"
myString([]myRune{0x1F30E}) // "\U0001f30e" == "🌎"
myString([]myRune{0x1f30e}) // "\U0001f30e" == "🌎"
</pre>
</li>

Expand Down Expand Up @@ -7197,8 +7223,9 @@ <h3 id="Appending_and_copying_slices">Appending to and copying slices</h3>
and the respective <a href="#Passing_arguments_to_..._parameters">parameter
passing rules</a> apply.
As a special case, if the core type of <code>s</code> is <code>[]byte</code>,
<code>append</code> also accepts a second argument with core type <code>string</code>
followed by <code>...</code>. This form appends the bytes of the string.
<code>append</code> also accepts a second argument with core type
<a href="#Core_types"><code>bytestring</code></a> followed by <code>...</code>.
This form appends the bytes of the byte slice or string.
</p>

<pre class="grammar">
Expand Down Expand Up @@ -7235,8 +7262,9 @@ <h3 id="Appending_and_copying_slices">Appending to and copying slices</h3>
The number of elements copied is the minimum of
<code>len(src)</code> and <code>len(dst)</code>.
As a special case, if the destination's core type is <code>[]byte</code>,
<code>copy</code> also accepts a source argument with core type <code>string</code>.
This form copies the bytes from the string into the byte slice.
<code>copy</code> also accepts a source argument with core type
</a> <a href="#Core_types"><code>bytestring</code></a>.
This form copies the bytes from the byte slice or string into the byte slice.
</p>

<pre class="grammar">
Expand Down Expand Up @@ -7550,7 +7578,7 @@ <h3 id="Import_declarations">Import declarations</h3>
</p>

<p>
Assume we have compiled a package containing the package clause
Consider a compiled a package containing the package clause
<code>package math</code>, which exports function <code>Sin</code>, and
installed the compiled package in the file identified by
<code>"lib/math"</code>.
Expand Down
13 changes: 13 additions & 0 deletions misc/cgo/test/testdata/issue52611.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Issue 52611: inconsistent compiler behaviour when compiling a C.struct.
// No runtime test; just make sure it compiles.

package cgotest

import (
_ "cgotest/issue52611a"
_ "cgotest/issue52611b"
)
16 changes: 16 additions & 0 deletions misc/cgo/test/testdata/issue52611a/a.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package issue52611a

/*
typedef struct Foo {
int X;
} Foo;
*/
import "C"

func GetX1(foo *C.struct_Foo) int32 {
return int32(foo.X)
}
11 changes: 11 additions & 0 deletions misc/cgo/test/testdata/issue52611a/b.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package issue52611a

import "C"

func GetX2(foo *C.struct_Foo) int32 {
return int32(foo.X)
}
11 changes: 11 additions & 0 deletions misc/cgo/test/testdata/issue52611b/a.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package issue52611b

import "C"

func GetX1(bar *C.struct_Bar) int32 {
return int32(bar.X)
}
16 changes: 16 additions & 0 deletions misc/cgo/test/testdata/issue52611b/b.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package issue52611b

/*
typedef struct Bar {
int X;
} Bar;
*/
import "C"

func GetX2(bar *C.struct_Bar) int32 {
return int32(bar.X)
}
10 changes: 10 additions & 0 deletions src/cmd/cgo/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,16 @@ presented to cmd/link as part of a larger program, contains:
_go_.o # gc-compiled object for _cgo_gotypes.go, _cgo_import.go, *.cgo1.go
_all.o # gcc-compiled object for _cgo_export.c, *.cgo2.c
If there is an error generating the _cgo_import.go file, then, instead
of adding _cgo_import.go to the package, the go tool adds an empty
file named dynimportfail. The _cgo_import.go file is only needed when
using internal linking mode, which is not the default when linking
programs that use cgo (as described below). If the linker sees a file
named dynimportfail it reports an error if it has been told to use
internal linking mode. This approach is taken because generating
_cgo_import.go requires doing a full C link of the package, which can
fail for reasons that are irrelevant when using external linking mode.
The final program will be a dynamic executable, so that cmd/link can avoid
needing to process arbitrary .o files. It only needs to process the .o
files generated from C files that cgo writes, and those are much more
Expand Down
5 changes: 5 additions & 0 deletions src/cmd/cgo/gcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2551,6 +2551,11 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
t.Go = name // publish before recursive calls
goIdent[name.Name] = name
if dt.ByteSize < 0 {
// Don't override old type
if _, ok := typedef[name.Name]; ok {
break
}

// Size calculation in c.Struct/c.Opaque will die with size=-1 (unknown),
// so execute the basic things that the struct case would do
// other than try to determine a Go representation.
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/compile/internal/amd64/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func storeByType(t *types.Type) obj.As {
return x86.AMOVL
case 8:
return x86.AMOVQ
case 16:
return x86.AMOVUPS
}
}
panic(fmt.Sprintf("bad store type %v", t))
Expand Down
5 changes: 5 additions & 0 deletions src/cmd/compile/internal/dwarfgen/dwarf.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ func Info(fnsym *obj.LSym, infosym *obj.LSym, curfn interface{}) ([]dwarf.Scope,
continue
}
apdecls = append(apdecls, n)
if n.Type().Kind() == types.TSSA {
// Can happen for TypeInt128 types. This only happens for
// spill locations, so not a huge deal.
continue
}
fnsym.Func().RecordAutoType(reflectdata.TypeLinksym(n.Type()))
}
}
Expand Down
43 changes: 33 additions & 10 deletions src/cmd/compile/internal/noder/stencil.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,15 @@ func (g *genInst) scanForGenCalls(decl ir.Node) {

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)
if hasShapeTypes(targs) {
// We have to be using a subdictionary, since this is
// a generic method call.
assert(usingSubdict)
} else {
// We should use main dictionary, because the receiver is
// an instantiation already, see issue #53406.
assert(!usingSubdict)
}

// Transform to a function call, by appending the
// dictionary and the receiver to the args.
Expand Down Expand Up @@ -721,11 +727,12 @@ func (g *genInst) getInstantiation(nameNode *ir.Name, shapes []*types.Type, isMe
// 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 *genInst
isMethod bool // If a method is being instantiated
newf *ir.Func // Func node for the new stenciled function
ts typecheck.Tsubster
info *instInfo // Place to put extra info in the instantiation
g *genInst
isMethod bool // If a method is being instantiated
newf *ir.Func // Func node for the new stenciled function
ts typecheck.Tsubster
info *instInfo // Place to put extra info in the instantiation
skipClosure bool // Skip substituting closures

// Map from non-nil, non-ONAME node n to slice of all m, where m.Defn = n
defnMap map[ir.Node][]**ir.Name
Expand Down Expand Up @@ -978,7 +985,20 @@ func (subst *subster) node(n ir.Node) ir.Node {
}
}

old := subst.skipClosure
// For unsafe.{Alignof,Offsetof,Sizeof}, subster will transform them to OLITERAL nodes,
// and discard their arguments. However, their children nodes were already process before,
// thus if they contain any closure, the closure was still be added to package declarations
// queue for processing later. Thus, genInst will fail to generate instantiation for the
// closure because of lacking dictionary information, see issue #53390.
if call, ok := m.(*ir.CallExpr); ok && call.X.Op() == ir.ONAME {
switch call.X.Name().BuiltinOp {
case ir.OALIGNOF, ir.OOFFSETOF, ir.OSIZEOF:
subst.skipClosure = true
}
}
ir.EditChildren(m, edit)
subst.skipClosure = old

m.SetTypecheck(1)

Expand Down Expand Up @@ -1123,6 +1143,9 @@ func (subst *subster) node(n ir.Node) ir.Node {
}

case ir.OCLOSURE:
if subst.skipClosure {
break
}
// We're going to create a new closure from scratch, so clear m
// to avoid using the ir.Copy by accident until we reassign it.
m = nil
Expand Down Expand Up @@ -1326,7 +1349,7 @@ func (g *genInst) dictPass(info *instInfo) {
mce := m.(*ir.ConvExpr)
// Note: x's argument is still typed as a type parameter.
// m's argument now has an instantiated type.
if mce.X.Type().HasShape() || m.Type().HasShape() {
if mce.X.Type().HasShape() || (m.Type().HasShape() && !m.Type().IsEmptyInterface()) {
m = convertUsingDictionary(info, info.dictParam, m.Pos(), mce.X, m, m.Type())
}
case ir.ODOTTYPE, ir.ODOTTYPE2:
Expand Down Expand Up @@ -1423,7 +1446,7 @@ func findDictType(info *instInfo, t *types.Type) int {
// instantiated node of the CONVIFACE node or XDOT node (for a bound method call) that is causing the
// conversion.
func convertUsingDictionary(info *instInfo, dictParam *ir.Name, pos src.XPos, v ir.Node, in ir.Node, dst *types.Type) ir.Node {
assert(v.Type().HasShape() || in.Type().HasShape())
assert(v.Type().HasShape() || (in.Type().HasShape() && !in.Type().IsEmptyInterface()))
assert(dst.IsInterface())

if v.Type().IsInterface() {
Expand Down
6 changes: 6 additions & 0 deletions src/cmd/compile/internal/types/size.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,12 @@ func PtrDataSize(t *Type) int64 {
}
return 0

case TSSA:
if t != TypeInt128 {
base.Fatalf("PtrDataSize: unexpected ssa type %v", t)
}
return 0

default:
base.Fatalf("PtrDataSize: unexpected type, %v", t)
return 0
Expand Down
5 changes: 5 additions & 0 deletions src/cmd/compile/internal/types/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,11 @@ var (
TypeResultMem = newResults([]*Type{TypeMem})
)

func init() {
TypeInt128.width = 16
TypeInt128.align = 8
}

// NewNamed returns a new named type for the given type name. obj should be an
// ir.Name. The new type is incomplete (marked as TFORW kind), and the underlying
// type should be set later via SetUnderlying(). References to the type are
Expand Down
Loading

0 comments on commit e7100ad

Please sign in to comment.