summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
| * cmd/compile/internal/types2: use []*TypeParam rather than []*TypeName for ↵Robert Griesemer2021-08-2417-81/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | type param lists This is a port of CL 343932 from go/types, with the necessary adjustments to the compiler. This change improves type safety slightly, avoids many internal type assertions, and simplifies some code paths. Change-Id: Ie9c4734814f49cd248927152d7b3264d3578428c Reviewed-on: https://go-review.googlesource.com/c/go/+/344614 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dan Scales <danscales@google.com>
| * cmd/compile/internal/types2: use an opaque environment for InstantiateRobert Griesemer2021-08-242-4/+24
| | | | | | | | | | | | | | | | | | | | | | | | This is a port of CL 343930 from go/types, adjusted to work for the compiler: here Environment carries a *Checker, if available. Change-Id: I44544fad7da870fa0c02832baa6abd2909d50304 Reviewed-on: https://go-review.googlesource.com/c/go/+/344612 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
| * cmd/compile/internal/types2: don't export TypeSetRobert Griesemer2021-08-245-29/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For now don't export TypeSet in the interest of keeping the types2 API surface small(er). This is a clean port of CL 341289 from go/types. Change-Id: I50c747629f25472f2ec5ba59d7f543ee3c1c423b Reviewed-on: https://go-review.googlesource.com/c/go/+/344610 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dan Scales <danscales@google.com>
| * embed: document the maximum file size supportedkorzhao2021-08-241-2/+6
| | | | | | | | | | | | | | | | | | Fixes #47627 Change-Id: Ia1edfb6249863ab055fab68a35666bc2bdf21dcb Reviewed-on: https://go-review.googlesource.com/c/go/+/341689 Reviewed-by: Jay Conrod <jayconrod@google.com> Trust: Michael Matloob <matloob@golang.org>
| * go/token: match the implementation of index selection with sort.Searchsubham sarkar2021-08-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | name old time/op new time/op delta SearchInts-8 15.5ns ± 2% 13.7ns ± 4% -11.87% (p=0.008 n=5+5) (see CL 36332 for the original change to sort.Search) Change-Id: If452818185b92b8b3548b066f475e493d604ea29 GitHub-Last-Rev: 32dd3cffa6b54b332948ac6a2929458defd4838f GitHub-Pull-Request: golang/go#47293 Reviewed-on: https://go-review.googlesource.com/c/go/+/335809 Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Robert Griesemer <gri@golang.org> Trust: Than McIntosh <thanm@google.com>
| * cmd/compile: reuse same node for global dictionariesDan Scales2021-08-243-12/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change stencil.go:getDictionaryValue() and reflect.go:getDictionary() to reuse any existing name node that has been created for the needed global dictionary. Otherwise, these functions may set the Def on a specific dictionary sym to two different name nodes, which means the first node will not satisfy the invariant 'n.Sym().Def.(*ir.Name) == n' (which is the assertion in this issue). Fixes #47896 Change-Id: I1e7ae1efd077a83c7878b4342feb6d28d52476cc Reviewed-on: https://go-review.googlesource.com/c/go/+/344609 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
| * cmd/compile: fixes for non-constant Sizeof/Alignof/OffsetofDan Scales2021-08-236-5/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Includes Robert's suggested fix in validate.go to not fail on non-constant alignof/offsetof/sizeof calls. Further changes to wait on transforming these calls until stenciling time, when we can call EvalConst() to evaluate them once all the relevant types are known. Added a bunch of new tests for non-constant Sizeof/Alignof/Offsetof. Fixes #47716 Change-Id: I469af888eb9ce3a853124d919eda753971009b3e Reviewed-on: https://go-review.googlesource.com/c/go/+/344250 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com>
| * all: replace runtime SSE2 detection with GO386 settingMartin Möhrmann2021-08-2315-60/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When GO386=sse2 we can assume sse2 to be present without a runtime check. If GO386=softfloat is set we can avoid the usage of SSE2 even if detected. This might cause a memcpy, memclr and bytealg slowdown of Go binaries compiled with softfloat on machines that support SSE2. Such setups are rare and should use GO386=sse2 instead if performance matters. On targets that support SSE2 we avoid the runtime overhead of dynamic cpu feature dispatch. The removal of runtime sse2 checks also allows to simplify internal/cpu further by removing handling of the required feature option as a followup after this CL. Change-Id: I90a853a8853a405cb665497c6d1a86556947ba17 Reviewed-on: https://go-review.googlesource.com/c/go/+/344350 Trust: Martin Möhrmann <martin@golang.org> Run-TryBot: Martin Möhrmann <martin@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
| * runtime: use RDTSCP for instruction stream serialized read of TSCMartin Möhrmann2021-08-236-28/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To measure all instructions having been completed before reading the time stamp counter with RDTSC an instruction sequence that has instruction stream serializing properties which guarantee waiting until all previous instructions have been executed is needed. This does not necessary mean to wait for all stores to be globally visible. This CL aims to remove vendor specific logic for determining the instruction sequence with CPU feature flag checks that are CPU vendor independent. For intel LFENCE has the wanted properties at least since it was introduced together with SSE2 support. On AMD instruction stream serializing LFENCE is supported by setting an MSR C001_1029[1]=1 on AMD family 10h/12h/14h/15h/16h/17h processors. AMD family 0Fh/11h processors support LFENCE as serializing always. AMD plans support for this MSR and access to this bit for all future processors. Source: https://developer.amd.com/wp-content/resources/Managing-Speculation-on-AMD-Processors.pdf Reading the MSR to determine LFENCE properties is not always possible or reliable (hypervisors). The Linux kernel is relying on serializing LFENCE on AMD CPUs since a commit in July 2019: https://lkml.org/lkml/2019/7/22/295 and the MSR C001_1029 to enable serialization has been set by default with the Spectre v1 mitigations. Using an MFENCE on AMD is waiting on previous instructions having been executed but in addition also flushes store buffers. To align the serialization properties without runtime detection of CPU manufacturers we can use the newer RDTSCP instruction which waits until all previous instructions have been executed. RDTSCP is available on Intel since around 2008 and on AMD CPUs since around 2006. Support for RDTSCP can be checked independently of manufacturer by checking CPUID bits. Using RDTSCP is the default in Linux to read TSC in program order when the instruction is available. https://github.com/torvalds/linux/blob/e22ce8eb631bdc47a4a4ea7ecf4e4ba499db4f93/arch/x86/include/asm/msr.h#L231 Change-Id: Ifa841843b9abb2816f8f0754a163ebf01385306d Reviewed-on: https://go-review.googlesource.com/c/go/+/344429 Reviewed-by: Keith Randall <khr@golang.org> Trust: Martin Möhrmann <martin@golang.org> Run-TryBot: Martin Möhrmann <martin@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
| * internal/buildcfg: change GOEXPERIMENT to always return non-empty stringMatthew Dempsky2021-08-231-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than returning "", we now return "," (which is a no-op). This ensures that the returned string always overrides DefaultGOEXPERIMENT. This fixes a bootstrapping issue where GOROOT_BOOTSTRAP was built with "GOEXPERIMENT=fieldtrack ./make.bash". cmd/dist sets GOEXPERIMENT=none during bootstrapping, which was causing cmd/go to set GOEXPERIMENT="" when executing cmd/compile; but then cmd/compile ignores the environment variable (because it's empty) and instead uses DefaultGOEXPERIMENT. Fixes #47921. Change-Id: I657ff6cdfb294a94f6a2f58c306ceed7f104416b Reviewed-on: https://go-review.googlesource.com/c/go/+/344511 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
| * cmd/compile: do not mark arrays used for map initialization noalgMartin Möhrmann2021-08-235-2/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Arrays marked noalg are created by the compiler to hold keys and values to initialize map literals. The ssa backend creates a pointer type for the array type when creating an OpAddr while processing the loop that initializes the map from the arrays. The pointer type does not inherit the noalg property but points to the noalg array type. This causes values created through reflect of types that should be equal to compare unequal because the noalg and alg type might be compared and these are not the same. A similar problem occurred in #32595 for argument arrays of defer structs. Created #47904 to track improve noalg handling to be able to reintroduce this optimization again. Fixes #47068 Change-Id: I87549342bd404b98d71a3c0f33e3c169e9d4efc8 Reviewed-on: https://go-review.googlesource.com/c/go/+/344349 Trust: Martin Möhrmann <martin@golang.org> Run-TryBot: Martin Möhrmann <martin@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
| * cmd/compile: don't emit write barriers for offsets of global addresseszikaeroh2021-08-232-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, write barriers aren't emitted for global addresses, but they are emitted for addresses offset of global addresses. This CL changes IsGlobalAddr to recognize offsets of global addresses as globals too, removing write barriers for staticuint64s based addresses. The logic added is the same as used in IsStackAddr. Updates #37612 Change-Id: I537579f85b9ad02987d94f3ee0b4508b90097959 Reviewed-on: https://go-review.googlesource.com/c/go/+/342129 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
| * cmd/compile: always remove receiver type from instantiated method valuesKeith Randall2021-08-236-5/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a type T has a method foo, then var t T var i interface{} = t.foo The type of foo is a method type, but the type of t.foo should be a standard function type. Make sure we always do that conversion. Fixes #47775 Change-Id: I464ec792196b050aba1914e070a4ede34bfd0bfa Reviewed-on: https://go-review.googlesource.com/c/go/+/343881 Trust: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dan Scales <danscales@google.com>
| * cmd/compile: copy captured dictionary var to local varKeith Randall2021-08-233-5/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When starting a closure that needs a dictionary, copy the closure variable to a local variable. This lets child closures capture that dictionary variable correctly. This is a better fix for #47684, which does not cause problems like #47723. Fixes #47723 Update #47684 Change-Id: Ib5d9ffc68a5142e28daa7d0d75683e7a35508540 Reviewed-on: https://go-review.googlesource.com/c/go/+/343871 Trust: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
| * spec: add example for method value in case of embedded methodCuong Manh Le2021-08-231-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So it's clear to the reader that if "M" is a promoted method from embedded field "T", then "x.M" will be expanded to "x.T.M" during the evaluation of the method value. Fixes #47863 Change-Id: Id3b82127a2054584b6842c487f6e15c3102dc9fe Reviewed-on: https://go-review.googlesource.com/c/go/+/344209 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
| * cmd/compile: fixing 15.go for -G=3Dan Scales2021-08-233-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Required two changes: - avoid creating a closure in the case where the actual receiver of an embedded method is not generic even though the base operand of the selector is generic. This is similar to the test suggested by wayne zuo - I thought it was clear in buildClosure, and easier to comment. - Propagate //go:nointerface to base generic methods and then to instantiations. Change-Id: If30c834e4223c2639b7f7e74d44e6087aa9ccd76 Reviewed-on: https://go-review.googlesource.com/c/go/+/344251 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Wayne Zuo <wdvxdr1123@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Trust: Dan Scales <danscales@google.com>
| * reflect: fix memmove for big endian cases with new ABILynn Boger2021-08-231-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some memmoves in reflect/value.go for copying arguments related to the new ABI were using the address of the target or source instead of using IntArgRegAddr or FloatArgRegAddr to adjust the address for big endian. This was found when testing patches for ppc64 and fixes the failures that were found. Change-Id: I119aa090a2a8eb859020ff1a1736107a6d0b76f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/343869 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Trust: Michael Knyszek <mknyszek@google.com> Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
| * go/types: use TypeList in the Inferred structRobert Findley2021-08-233-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | This is for consistency with how we report TArgs elsewhere, and in case we ever want to share an internal slice with inference reporting. Change-Id: Ia8b705a155f4f82bd8da8dc2457289810f875f5e Reviewed-on: https://go-review.googlesource.com/c/go/+/343934 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
| * go/types: use a TypeList type to hold type argumentsRobert Findley2021-08-2311-69/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This resolves an asymmetry between the TParams and TArgs APIs, and reduces the size of the Named struct at the cost of some additional nil checks. While at it, move TParamList and TypeList to a new file:typelists.go, and change TParamList to access the tparams slice directly in At. There is no reason to guard against a nil receiver, as accessing an index on the empty slice will panic anyway. Change-Id: I9b65247e06c697a57a4efe40c3390e0faff91441 Reviewed-on: https://go-review.googlesource.com/c/go/+/343933 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
| * go/types: use []*TypeParam rather than []*TypeName type param listsRobert Findley2021-08-2311-59/+57
| | | | | | | | | | | | | | | | | | | | | | | | Making this change improves type safety slightly, and avoids many internal type assertions. Change-Id: I26519b0e57068e944e8243983ae90553d79e59c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/343932 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
| * go/types: add the TypeParam.Obj methodRobert Findley2021-08-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | Users should be able to access the type name associated with a type parameter. Change-Id: I495c3b4377f9d4807b1e78ad341e573d4d3c7bff Reviewed-on: https://go-review.googlesource.com/c/go/+/343931 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
| * go/types: move to an opaque environment for InstantiateRobert Findley2021-08-231-5/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | To match the API proposal, switch the first argument to Instantiate to an opaque Environment handle, though for now this handle is unimplemented. Change-Id: I6207f0beafdf8497587abdad37db92f927db29b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/343930 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
| * go/types: return an error from InstantiateRobert Findley2021-08-238-133/+203
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a port of CL 342152 to go/types. Additionally, a panic was removed from interface substitution, which is a fix from CL 333155 that was previously missed. A check for a nil Checker was also removed from types2.instantiate, since check must not be nil in that method. Change-Id: I4ea6bdccbd50ea2008ee6d870f702bee5cdd5a8e Reviewed-on: https://go-review.googlesource.com/c/go/+/342671 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
| * runtime: remove unused cpu architecture feature variables from binariesMartin Möhrmann2021-08-231-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | On amd64 this reduces go binary sizes by 176 bytes due to not referencing internal/cpu.ARM64 and internal/cpu.ARM. Change-Id: I8e4f31e2b1939b05eec2148b44d7cff7e0aeb30e Reviewed-on: https://go-review.googlesource.com/c/go/+/344329 Trust: Martin Möhrmann <martin@golang.org> Run-TryBot: Martin Möhrmann <martin@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
| * cmd/go: fix long test buildersCuong Manh Le2021-08-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CL 343732 enabled -G=3 by default. The types2 typechecker uses slighly different error message format for language feature constraint. The old typechecker format: vendor/example.net/need117/need117.go:5:16: cannot convert s (type []byte) to type *[4]byte: conversion of slices to array pointers only supported as of -lang=go1.17 The new format: vendor/example.net/need117/need117.go:5:17: conversion of slices to array pointers only supported as of -lang=go1.17 caused the long test builders failed. This CL fixes the test by relaxing the regext pattern a bit, so it can match both the format. Change-Id: I1c4acaa9e34b6c08dccbbc3ce7a99d4cd79f748a Reviewed-on: https://go-review.googlesource.com/c/go/+/344212 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
| * strings: smarter growth of temporal buffer and avoid copying on returnIgnacio Hagopian2021-08-221-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation for single strings had two optimization opportunities: 1. Grow the temporary buffer by known size before appending. 2. Avoid a full copy of the result since the underlying buffer won't be mutated afterward. Both things were leveraged by using a Builder instead of a byte slice. Relevant benchmark results: name old time/op new time/op delta SingleMatch-8 32.0µs ± 3% 26.1µs ± 3% -18.41% (p=0.000 n=9+10) name old speed new speed delta SingleMatch-8 469MB/s ± 3% 574MB/s ± 3% +22.56% (p=0.000 n=9+10) name old alloc/op new alloc/op delta SingleMatch-8 81.3kB ± 0% 49.0kB ± 0% -39.67% (p=0.000 n=10+10) name old allocs/op new allocs/op delta SingleMatch-8 19.0 ± 0% 11.0 ± 0% -42.11% (p=0.000 n=10+10) Change-Id: I23af56a15875206c0ff4ce29a51bec95fd48bb11 GitHub-Last-Rev: 403cfc3c2794b5da27792c51999417a2a052b365 GitHub-Pull-Request: golang/go#47766 Reviewed-on: https://go-review.googlesource.com/c/go/+/343089 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Robert Griesemer <gri@golang.org>
| * go/types: report argument type for unsafe.OffsetOfRobert Griesemer2021-08-222-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a clean port of CL 344252 to go/types. For #47895. Change-Id: I48cbb97ec28fcfb4fdf483594be9d29426c117ac Reviewed-on: https://go-review.googlesource.com/c/go/+/344254 Trust: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
| * cmd/compile/internal/types2: enable TestSelection API testRobert Griesemer2021-08-221-22/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This test was never fully ported from go/types. Implement a conversion function from syntax.Pos to string index so that the test can be enabled again. Also renamed the local variable syntax to segment to avoid confusion with the syntax package. Change-Id: I1b34e50ec138403798efb14c828545780f565507 Reviewed-on: https://go-review.googlesource.com/c/go/+/344253 Trust: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
| * os/user: simplify test skip for plan9Kir Kolyshkin2021-08-222-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | There's no need to specifically check for runtime.GOOS as there's already a generic mechanism for that. Change-Id: I7125443ead456548bd503c5e71cd56e9eb30b446 Reviewed-on: https://go-review.googlesource.com/c/go/+/330750 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
| * cmd/compile/internal/types2: report argument type for unsafe.OffsetOfRobert Griesemer2021-08-222-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before parameterized types, unsafe.OffsetOf was always evaluating to a constant. With parameterized types, the result may be a run-time value, and unsafe.OffsetOf(x.f) is a call that is recorded. Also record the argument x.f. Fixes #47895. Change-Id: Ia3da25028d4865d7295ce7990c7216bffe9e7c72 Reviewed-on: https://go-review.googlesource.com/c/go/+/344252 Trust: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
| * math/big: clarified doc string for SetMantExpRobert Griesemer2021-08-221-1/+3
| | | | | | | | | | | | | | | | | | | | | | Fixes #47879. Change-Id: I35efb5fc65c4f1eb1b45918f95bbe1ff4039950e Reviewed-on: https://go-review.googlesource.com/c/go/+/344249 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
| * runtime: use asmcgocall_no_g when calling sigprocmask on openbsdJoel Sing2021-08-221-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | sigprocmask is called from sigsave, which is called from needm. As such, sigprocmask has to be able to run with no g. For some reason we do not currently trip this on current libc platforms, but we do hit it on openbsd/mips64 with external linking. Updates #36435 Change-Id: I4dfae924245c5f68cc012755d6485939014898a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/334879 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Ian Lance Taylor <iant@golang.org>
| * reflect: add example for FieldByIndexMostafa Solati2021-08-221-0/+28
| | | | | | | | | | | | | | | | | | Change-Id: I539453e50ab85ec1b023bc9e329e6451c674e0c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/236937 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org>
| * runtime: fix buckHashSize duplicationDmitry Vyukov2021-08-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | We have a constant for 179999, don't duplicate it. Change-Id: Iefb9c4746f6dda2e08b42e3c978963198469ee8c Reviewed-on: https://go-review.googlesource.com/c/go/+/277375 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Pratt <mpratt@google.com>
| * strconv: reject surrogate halves in UnquoteJoe Tsai2021-08-212-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unquote implements unescaping a "single-quoted, doubled-quoted, or backquoted Go string literal". Therefore, it should reject anything that the Go specification explicitly forbids. The section on "Rune literals" explicitly rejects rune values "above 0x10FFFF and surrogate halves". We properly checked for the previous condition, but were failing to check for the latter. In general, "r > utf8.MaxRune" is probably the wrong check, while !utf8.ValidRune(r) is the more correct check. We make changes to both UnquoteChar and appendEscapedRune to use the correct check. The change to appendEscapedRune is technically a noop since callers of that function already guarantee that the provided rune is valid. Fixes #47853 Change-Id: Ib8977e56b91943ec8ada821b8d217b5e9a66f950 Reviewed-on: https://go-review.googlesource.com/c/go/+/343877 Trust: Joe Tsai <joetsai@digital-static.net> Run-TryBot: Joe Tsai <joetsai@digital-static.net> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
| * cmd/compile: absorb NEG into branch when possible on riscv64Joel Sing2021-08-212-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can end up with this situation due to our equality tests being based on 'SEQZ (SUB x y)' - if x is a zero valued constant, 'SUB x y' can be converted to 'NEG x'. When used with a branch the SEQZ can be absorbed, leading to 'BNEZ (NEG x)' where the NEG is redundant. Removes around 1700 instructions from the go binary on riscv64. Change-Id: I947a080d8bf7d2d6378ab114172e2342ce2c51db Reviewed-on: https://go-review.googlesource.com/c/go/+/342850 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
| * cmd/compile: convert branch with zero to more optimal branch zero on riscv64Joel Sing2021-08-212-1/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert BLT and BGE with a zero valued constant to BGTZ/BLTZ/BLEZ/BGEZ as appropriate. Removes over 4,500 instructions from the go binary on riscv64. Change-Id: Icc266e968b126ba04863ec88529630a9dd44498b Reviewed-on: https://go-review.googlesource.com/c/go/+/342849 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
| * cmd/compile: sort regalloc switch by architectureJoel Sing2021-08-211-8/+8
| | | | | | | | | | | | | | | | | | | | Also tweak comment for the arm64 case. Change-Id: I073405bd2acf901dcaaf33a034a84b6a09dd4a83 Reviewed-on: https://go-review.googlesource.com/c/go/+/334869 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
| * go/types: don't override x.mode before using itRobert Griesemer2021-08-211-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changing the mode of x before using the old value is clearly wrong. And x is not needed anymore afterward so besides being misplaced, the assignment is not needed in the first place. Tested manually as it's a bit complicated to set up a test. Needs to be back-ported to 1.17. Fixes #47777. Change-Id: I06f1fa9443eb98009b4276f566d557fd52f1d6d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/343809 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
| * cmd/compile: enable -G=3 by defaultMatthew Dempsky2021-08-213-14/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL changes cmd/compile's -G flag's default from 0 to 3, which enables use of the new types2 type checker and support for type parameters. The old type checker is still available with -gcflags=all=-G=0. The CL also updates the regress test harness to account for the change in default behavior (e.g., to expect known types2 changes/failures). However, the -G=0 mode is still being tested for now. Copy of CL 340914 by danscales@, minus the cmd/internal/objabi.AbsFile change (handled instead by CL 343731) and rebased to master branch. Updates #43651. Change-Id: I1f62d6c0a3ff245e15c5c0e8f3d922129fdd4f29 Reviewed-on: https://go-review.googlesource.com/c/go/+/343732 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
| * test/typeparam: add a test case for issue46591korzhao2021-08-201-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #46591 Change-Id: I4875092ecd7760b0cd487e793576ef7a9a569a0e Reviewed-on: https://go-review.googlesource.com/c/go/+/343970 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
| * cmd/internal/buildid: reject empty idRuss Cox2021-08-202-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The loop that makes progress assumes that after matching an id you should advance len(id) bytes in the file. If id is the empty string, then it will match and advance 0 bytes repeatedly. 0-byte ids are not really build IDs, so just reject it outright. Fixes #47852. Change-Id: Ie44a3a51dec22e2f68fb72d54ead91be98000cfe Reviewed-on: https://go-review.googlesource.com/c/go/+/344049 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org>
| * test: enable regabi test on arm64Cuong Manh Le2021-08-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | CL 324890 turned on register ABI by default on ARM64, causing neither live.go nor live_regabi.go is run on ARM64. This CL enables live_regabi.go test for ARM64. Change-Id: I0c483a38b761c5a6f1fa9a5b3324b5da64907e61 Reviewed-on: https://go-review.googlesource.com/c/go/+/343531 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
| * cmd/compile/internal/syntax: add PosBase.TrimmedMatthew Dempsky2021-08-208-27/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With types2, some syntax.PosBases need to be constructed from export data, which must only contain "trimmed" filenames (i.e., that they've already been made absolute and undergone -trimpath processing). However, it's not safe to apply trimming to a filename multiple times, and in general we can't distinguish trimmed from untrimmed filenames. This CL resolves this by adding a PosBase.Trimmed boolean so we can distinguish whether the associated filename has been trimmed yet. This is a bit hacky, but is the least bad solution I've come up with so far. This unblocks enabling -G=3 by default. Change-Id: I7383becfb704680a36f7603e3246af38b21f100b Reviewed-on: https://go-review.googlesource.com/c/go/+/343731 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Trust: Dan Scales <danscales@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
| * net/http: fix typo in header.goHuanCheng2021-08-201-1/+1
| | | | | | | | | | | | | | | | Change-Id: Ia6df881badf9a704c7f56967404d37e230b88a09 Reviewed-on: https://go-review.googlesource.com/c/go/+/343969 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Damien Neil <dneil@google.com>
| * go/types: change Checker.verify to return an errorRobert Findley2021-08-202-36/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a port of CL 342151 to go/types, adjusted for errors and positions. Checker.sprintf was refactored to facilitate formatting error messages with a nil Checker. Change-Id: Ib2e5c942e55edaff7b5e77cf68a72bad70fea0b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/342670 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
| * go/types: no need to validate substituted instancesRobert Findley2021-08-201-3/+8
| | | | | | | | | | | | | | | | | | | | | | This is a straightforward port of CL 342150 to go/types. Change-Id: I7363e4642ade7ab30ca822a2be71f4d2804cc4a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/342669 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
| * go/types: consolidate verification logicRobert Findley2021-08-202-25/+26
| | | | | | | | | | | | | | | | | | | | | | This is a straightforward port of CL 342149 to go/types. Change-Id: I468c5154b7545b7816bb3f240b8db91e7a1fd3f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/342488 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
| * go/types: clean up panics in instantiationRobert Findley2021-08-202-23/+29
| | | | | | | | | | | | | | | | | | | | This is a straightforward port of CL 341862 to go/types. Change-Id: I4214c08d2889e2daf40254385656c6beed79571d Reviewed-on: https://go-review.googlesource.com/c/go/+/342487 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
| * archive/zip: prevent preallocation check from overflowingRoland Shoemaker2021-08-202-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the indicated directory size in the archive header is so large that subtracting it from the archive size overflows a uint64, the check that the indicated number of files in the archive can be effectively bypassed. Prevent this from happening by checking that the indicated directory size is less than the size of the archive. Thanks to the OSS-Fuzz project for discovering this issue and to Emmanuel Odeke for reporting it. Fixes #47801 Fixes CVE-2021-39293 Change-Id: Ifade26b98a40f3b37398ca86bd5252d12394dd24 Reviewed-on: https://go-review.googlesource.com/c/go/+/343434 Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>