summaryrefslogtreecommitdiff
path: root/src/internal
Commit message (Collapse)AuthorAgeFilesLines
* os: if descriptor is non-blocking, retain that in Fd methodIan Lance Taylor2023-05-174-0/+16
| | | | | | | | | | | | | | For #58408 Fixes #60211 Change-Id: I30f5678b46e15121865b19d1c0f82698493fad4e Reviewed-on: https://go-review.googlesource.com/c/go/+/495079 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
* cmd/link, internal/abi: minor follow-up cleanupsDavid Chase2023-05-171-2/+2
| | | | | | | | | | | | these address comments on CLs in the large refactoring stack recently submitted. Change-Id: Ic9023c32aafe4dda953b42c9a36834d3ab3432eb Reviewed-on: https://go-review.googlesource.com/c/go/+/495835 Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* internal/abi: update type name in commentIan Lance Taylor2023-05-171-1/+1
| | | | | | | | | | | | | | | method -> Method For #59670 Change-Id: I78e0410f3d5094aa12b2f3ccd6735fec0d696190 Reviewed-on: https://go-review.googlesource.com/c/go/+/494795 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
* go/types, types2: permit partially instantiated functions as function argumentsRobert Griesemer2023-05-162-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL changes Checker.genericExprList such that it collects partially instantiated generic functions together with their (partial) type argument (and corresponding) expression lists, instead of trying to infer the missing type arguments in place or to report an error. Special care is being taken to explictly record expression types where needed (because we can't use one of the usual expr evaluators which takes care of that), or to track the correct instance expression for later recording with Checker.arguments. The resulting generic expression list is passed to Checker.arguments which is changed to accept explicit partial type argument (and corresponding) expression lists. The provided type arguments are fed into type inference, matching up with their respective type parameters (which were collected already, before this CL). If type inference is successful, the instantiated functions are recorded as needed. For now, the type argument expression lists are collected and passed along but not yet used. We may use them eventually for better error reporting. Fixes #59958. For #59338. Change-Id: I26db47ef3546e64553da49d62b23cd3ef9e2b549 Reviewed-on: https://go-review.googlesource.com/c/go/+/494116 Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@google.com>
* go/types, types2: remove superfluous argument test in Checker.argumentsRobert Griesemer2023-05-162-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | There's only two places which call Checker.arguments: Checker.callExpr and Checker.builtin. Both ensure that the passed argument list doesn't contain type expressions, so we don't need that extra check at the start of Checker.arguments. The remaining check causes Checker.arguments to exit early if any of the passed arguments is invalid. This reduces the number of reported errors in rare cases but is executed all the time. If the extra errors are a problem, it would be better to not call Checker.arguments in the first place, or only do the extra check before Checker.arguments reports an error. Removing this code for now. Removes a long-standing TODO. Change-Id: Ief654b680eb6b6a768bb1b4c621d3c8169953f17 Reviewed-on: https://go-review.googlesource.com/c/go/+/495395 Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
* net: use and assert correct res state size at compile time when cgo ↵Mateusz Poliwczak2023-05-161-1/+1
| | | | | | | | | | | | | | | available on darwin Change-Id: I961bb18604dd1568ea21431545f43aa6a417b3d9 GitHub-Last-Rev: 735f3364a4f2182f3e3e1b84f39a042e86987967 GitHub-Pull-Request: golang/go#60046 Reviewed-on: https://go-review.googlesource.com/c/go/+/493415 Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
* os, syscall: support ill-formed UTF-16 strings on Windowsqmuntal2023-05-153-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Windows UTF-16 strings can contain unpaired surrogates, which can't be decoded into a valid UTF-8 string. This file defines a set of functions that can be used to encode and decode potentially ill-formed UTF-16 strings by using the [the WTF-8 encoding](https://simonsapin.github.io/wtf-8/). WTF-8 is a strict superset of UTF-8, i.e. any string that is well-formed in UTF-8 is also well-formed in WTF-8 and the content is unchanged. Also, the conversion never fails and is lossless. The benefit of using WTF-8 instead of UTF-8 when decoding a UTF-16 string is that the conversion is lossless even for ill-formed UTF-16 strings. This property allows to read an ill-formed UTF-16 string, convert it to a Go string, and convert it back to the same original UTF-16 string. Fixes #59971 Change-Id: Id6007f6e537844913402b233e73d698688cd5ba6 Reviewed-on: https://go-review.googlesource.com/c/go/+/493036 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Paul Hampson <Paul.Hampson@Pobox.com>
* internal/testdir: move to cmd/internal/testdirDmitri Shuralyov2023-05-121-1939/+0
| | | | | | | | | | | | | | | | | | The effect and motivation is for the test to be selected when doing 'go test cmd' and not when doing 'go test std' since it's primarily about testing the Go compiler and linker. Other than that, it's run by all.bash and 'go test std cmd' as before. For #56844. Fixes #60059. Change-Id: I2d499af013f9d9b8761fdf4573f8d27d80c1fccf Reviewed-on: https://go-review.googlesource.com/c/go/+/493876 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
* go/types, types2: be sure to type-check wrong methods in missingMethodRob Findley2023-05-121-0/+10
| | | | | | | | | | | | | | | | In the case of a wrong method, we were not ensuring that it was type-checked before passing it to funcString. Formatting the missing method error message requires a fully set-up signature. Fixes #59848 Change-Id: I1467e036afbbbdd00899bfd627a945500dc709c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/494615 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
* cmd/dist,internal/testdir: more cooperative host test mechanismAustin Clements2023-05-121-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | On cross-compiling builder machines, we run internal/testdir on the host, where it can access the Go toolchain to build binaries for the guest and run them through an exec wrapper. Currently this uses dist test's existing host test mechanism, which is quite complicated and we are planning to eliminate (#59999). Switch internal/testdir to use a more cooperative mechanism. With this CL, dist still understands that it has to build and run the test using the host GOOS/GOARCH, but rather than doing complicated manipulation of environment variables itself, it passes the guest GOOS/GOARCH to the test, which can easily inject it into its environment. This means dist test can use "go test" directly, rather than having to split up the build and run steps. For #37486. Change-Id: I556938c0b641960bb778b88b13f2b26256edc7c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/492985 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* test,internal/testdir: don't set GOOS/GOARCHAustin Clements2023-05-121-8/+0
| | | | | | | | | | | | | | | | | | The test directory driver currently sets the GOOS/GOARCH environment variables if they aren't set. This appears to be in service of a single test, test/env.go, which was introduced in September 2008 along with os.Getenv. It's not entirely clear what that test is even trying to check, since runtime.GOOS isn't necessarily the same as $GOOS. We keep the test around because golang.org/x/tools/go/ssa/interp uses it as a test case, but we simplify the test and eliminate the need for the driver to set GOOS/GOARCH. Change-Id: I5acc0093b557c95d1f0a526d031210256a68222d Reviewed-on: https://go-review.googlesource.com/c/go/+/493601 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* syscall: implement wasip1 SetNonblock and IsNonblockChris O'Hara2023-05-111-1/+17
| | | | | | | | | | | | | | | | | | | | | Allows for the NONBLOCK file descriptor flag to be set and queried on wasip1. syscall.SetNonblock uses the fd_fdstat_set_flags WASI system call and unix.IsNonblock uses the fd_fdstat_get system call. This is a prerequisite for non-blocking I/O support. Change-Id: I2bf79fd57142b2ec53eed3977d9aac8c6337eb80 Reviewed-on: https://go-review.googlesource.com/c/go/+/493356 Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Julien Fabre <ju.pryz@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Achille Roussel <achille.roussel@gmail.com>
* os: make Chtimes accept empty time values to skip file time modificationConstantin Konstantinidis2023-05-1110-0/+41
| | | | | | | | | | | | | | | | Empty time value time.Time{} leaves the corresponding time of the file unchanged. Fixes #32558 Change-Id: I1aff42f30668ff505ecec2e9509d8f2b8e4b1b6a Reviewed-on: https://go-review.googlesource.com/c/go/+/219638 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* internal/reflectlite: common up types, remove codeDavid Chase2023-05-114-261/+160
| | | | | | | | | Change-Id: I4d3ef025b935e52c47896f69814ba2f1a504d749 Reviewed-on: https://go-review.googlesource.com/c/go/+/489375 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: David Chase <drchase@google.com>
* internal/bisect: copy parser changes from CL 494177Russ Cox2023-05-111-2/+21
| | | | | | | | | | | x/tools/cmd/bisect is changing to emit hex skips for robustness. Update this copy of internal/bisect to understand them. Change-Id: Ie9445714e8e9fb594e656db2f94dcde9b6ce82d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/494178 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* reflect: replacing almost all use of *rtype with *abi.TypeDavid Chase2023-05-111-2/+2
| | | | | | | | | Change-Id: I3601525b10237d828c449c62a3447f66cb6f025e Reviewed-on: https://go-review.googlesource.com/c/go/+/487557 Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* reflect: prepare fieldnames for moving to abi/type.goDavid Chase2023-05-101-0/+2
| | | | | | | | | Change-Id: Ia8e88029d29a1210dc7a321578e61336e235f35a Reviewed-on: https://go-review.googlesource.com/c/go/+/487555 Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org>
* internal/abi,reflectlite,reflect,runtime: common up chan typeDavid Chase2023-05-101-7/+3
| | | | | | | | | Change-Id: I085b61c544b85d70fabb1c0d9fe91207826dd21a Reviewed-on: https://go-review.googlesource.com/c/go/+/484858 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@google.com>
* internal/reflectlite, runtime: move more constants and types into internal/abiDavid Chase2023-05-104-193/+76
| | | | | | | | | Change-Id: If5da1057ead34eb3e4c7f42bbe6ad3d350b97725 Reviewed-on: https://go-review.googlesource.com/c/go/+/484856 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* internal/abi: common up ArrayTypeDavid Chase2023-05-102-9/+4
| | | | | | | | | | | | | | | | This refactoring is more problematic because the client package wrap abi.Type, thus the self-referential fields within ArrayType need to be downcast to the client wrappers in several places. It's not clear to me this is worthwhile; this CL is for additional comment, before I attempt similar changes for other self-referential types. Change-Id: I41e517e6d851b32560c41676b91b76d7eb17c951 Reviewed-on: https://go-review.googlesource.com/c/go/+/466236 Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
* internal/abi: common up Method, Imethod, UncommonType typesDavid Chase2023-05-102-51/+17
| | | | | | | | | | | | was two commits, the first contained a lot of intermediate work, better this way. Change-Id: I7c5b79ef78b21a85828c8aaf9baeae86bb144db7 Reviewed-on: https://go-review.googlesource.com/c/go/+/463118 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* internal/godebug: make test godebug calls not varyDavid Chase2023-05-101-5/+13
| | | | | | | | | | | | | I think there may be an issue in bisect search with change set elements not actually being independent, to be explored later. For now, modify the test to remove that property. Change-Id: I4b171bc024795d950cf4663374ad1dfc4e2952fc Reviewed-on: https://go-review.googlesource.com/c/go/+/494036 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
* all: fix a lot of commentscui fliter2023-05-101-1/+1
| | | | | | | | | | | | | Fix comments, including duplicate is, wrong phrases and articles, misspellings, etc. Change-Id: I8bfea53b9b275e649757cc4bee6a8a026ed9c7a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/493035 Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* syscall,internal/poll: move pipe check from syscall.Seek to callersqmuntal2023-05-092-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Windows, syscall.Seek is a thin wrapper over SetFilePointerEx [1], which does not work on pipes, although it doesn't return an error on that case. To avoid this undefined behavior, Seek defensively calls GetFileType and errors if the type is FILE_TYPE_PIPE. The problem with this approach is that Seek is a low level foundational function that can be called many times for the same file, and the additional cgo call (GetFileType) will artificially slow down seek operations. I've seen GetFileType to account for 10% of cpu time in seek-intensive workloads. A better approach, implemented in this CL, would be to move the check one level up, where many times the file type is already known so the GetFileType is unnecessary. The drawback is that syscall.Seek has had this behavior since pipes where first introduced to Windows in https://codereview.appspot.com/1715046 and someone could be relying on it. On the other hand, this behavior is not documented, so we couldn't be breaking any contract. [1] https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfilepointerex Change-Id: I7602182f9d08632e22a8a1635bc8ad9ad35a5056 Reviewed-on: https://go-review.googlesource.com/c/go/+/493626 Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* internal/bisect: adjust stack PCs relative to Callers[2]David Chase2023-05-091-3/+14
| | | | | | | | | | | This is necessary to make hashes be consistent across runs, otherwise ASLR messes up search. Change-Id: Icf668dfe4c2008709f7767397b6700d0d5439287 Reviewed-on: https://go-review.googlesource.com/c/go/+/493857 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: David Chase <drchase@google.com>
* internal/godebug: add bisect supportRuss Cox2023-05-094-77/+395
| | | | | | | | | | | | | | | | | | | | CL 491875 introduces a new bisect command, which we plan to document for use by end users to debug semantic changes in the compiler and in GODEBUGs. This CL adds bisect support to GODEBUGs, at least the ones used via internal/godebug. Support for runtime-internal GODEBUGs like panicnil will take a bit more work in followup CLs. The new API in internal/bisect to support stack-based bisecting should be easily reusable in non-GODEBUG settings as well, once we finalize and export the API. Change-Id: I6cf779c775329aceb3f3b2b2b2f221ce8a67deee Reviewed-on: https://go-review.googlesource.com/c/go/+/491975 Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
* go/types, types2: infer minimum default type for untyped argumentsRobert Griesemer2023-05-081-0/+22
| | | | | | | | | | | | | | | This implements the proposal #58671. Must be explicitly enabled and requires proposal approval. For #58671. Change-Id: I150e78f4f3282d6b7cf9d90feeb5f1c5a36d8c38 Reviewed-on: https://go-review.googlesource.com/c/go/+/492835 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@google.com>
* internal/testenv: reduce init-time work for MustHaveExecBryan C. Mills2023-05-051-20/+15
| | | | | | | | | | | | | | | | | | | | In CL 486275 I added a somewhat complex init function that sets up a callback to probe for exec support. A lot of the complexity was simply to avoid an unnecessary call to os.Environ during init. In CL 491660, I made the os.Environ call unconditional on all platforms anyway in order to make HasGoBuild more robust. Since the init-function indirection no longer serves a useful purpose, I would like to simplify it to a package-level function, avoiding the complexity of changing package variables at init time. Change-Id: Ie0041d52cbde06ff14540192c8fba869a851158e Reviewed-on: https://go-review.googlesource.com/c/go/+/492977 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/types, types2: better error message for bad assignmentRobert Griesemer2023-05-051-0/+13
| | | | | | | | | | | | | | | | If the LHS of an assignment is neither addressable nor a map expression (and not the blank identifier), explicitly say so for a better error message. For #3117. Change-Id: I4bffc35574fe390a0567e89182b23585eb5a90de Reviewed-on: https://go-review.googlesource.com/c/go/+/492875 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
* internal/coverage/encodecounter: followup changes from code reviewThan McIntosh2023-05-051-6/+12
| | | | | | | | | | | | | | | | | This patch contains a small set of changes with fixes for some issues that surfaced during the code review for CL 484535. Due to an error on my part, these never got included in the final version that was checked in (I rebased, mailed the rebase, but then never mailed the final patch set with the changes). This patch sends the remaining bits and pieces. Updates #59563. Change-Id: I87dc05a83f8e44c8bfe7203bc2b035defc817af9 Reviewed-on: https://go-review.googlesource.com/c/go/+/492981 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* internal/bisect: copy from golang.org/x/tools/bisectRuss Cox2023-05-052-0/+538
| | | | | | | | | | | | | We don't want std to depend on x/tools, so just as we did with txtar, copy the bisect package into internal rather than using a require + vendor. Change-Id: Id775254f7c765a9244ba6eaf041c13e6e5c5e9f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/492595 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* internal/abi: refactor (basic) type struct into one definitionDavid Chase2023-05-057-76/+952
| | | | | | | | | | | | | | | This touches a lot of files, which is bad, but it is also good, since there's N copies of this information commoned into 1. The new files in internal/abi are copied from the end of the stack; ultimately this will all end up being used. Change-Id: Ia252c0055aaa72ca569411ef9f9e96e3d610889e Reviewed-on: https://go-review.googlesource.com/c/go/+/462995 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org>
* testenv: allow HasGoBuild to be false on -noopt buildersBryan C. Mills2023-05-041-0/+8
| | | | | | | | | | | | -noopt uses GO_GCFLAGS to disable optimization, and GO_GCFLAGS has caused HasGoBuild to be false since CL 74470. Change-Id: Iadcd15d412c05aec11e9a23b86d7b24af79d73bf Reviewed-on: https://go-review.googlesource.com/c/go/+/492795 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
* internal/testenv: remove HasExec and simplify other support checks againBryan C. Mills2023-05-043-89/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HasExec is an attractive nuisance: it is tempting to check in a TestMain function, but TestMain really shouldn't be running subprocesses eagerly anyway (they add needless overhead for operations like 'go test -list=.'), and the trick of re-executing the test binary to determine whether 'exec' works ends up in infinite recursion if TestMain itself calls HasExec. Instead, tests that need to execute a subprocess should call MustHaveExec or MustHaveExecPath from within a specific test, or just try to exec the program and check its error status (perhaps using testenv.SyscallIsNotSupported). While I'm in here and testing on the SlowBots anyway, a few other cleanups relating to subprocesses: - Add more t.Helper calls to support checks where appropriate. - Remove findGoTool, which can be simplified to exec.LookPath as of CL 404134. - Add tests confirming the expected behavior of the support functions on the Go project's builders. Change-Id: I163c701b2dd6eb6b7a036c6848f99b64dd9f0838 Reviewed-on: https://go-review.googlesource.com/c/go/+/491660 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
* go/types, types2: remove Config.EnableReverseTypeInference flagRobert Griesemer2023-05-047-11/+5
| | | | | | | | | | | | | | | | | | | | Proposal #59338 has been accepted and we expect this feature to be available starting with Go 1.21. Remove the flag to explicitly enable it through the API and enable by default. For now keep an internal constant enableReverseTypeInference to guard and mark the respective code, so we can disable it for debugging purposes. For #59338. Change-Id: Ia1bf3032483ae603017a0f459417ec73837e2891 Reviewed-on: https://go-review.googlesource.com/c/go/+/491798 Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/types, types2: consider generic functions in inference simplify stepRobert Griesemer2023-05-041-0/+11
| | | | | | | | | | | | | | | | | | | | | After type arguments for all type parameters have been determined, the type arguments are "simplified" by substituting any type parameters that might occur in them with their corresponding type arguments until all type parameters have been removed. If in this process a (formerly) generic function signature becomes non-generic, make sure to nil out its (declared) type parameters. Fixes #59953. For #59338. Change-Id: Ie16bffd7b0a8baed18e76e5532cdfaecd26e4278 Reviewed-on: https://go-review.googlesource.com/c/go/+/491797 Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
* go/types, types2: rename generic function argumentsRobert Griesemer2023-05-042-3/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For correct inference, if the same generic function is provided more than once as an argument to another function, the argument function's type parameters must be unique for each argument so that the type parameters can be correctly inferred. Example: func f(func(int), func(string)) {} func g[P any](P) {} func _() { f(g, g) } Here the type parameter P for the first g argument resolves to int and the type parameter P for the second g argument resolves to string. Fixes #59956. For #59338. Change-Id: I10ce0ea08c2033722dd7c7c976b2a5448b2ee2d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/492516 Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
* go/types, types2: combine version check with version error reportingRobert Griesemer2023-05-031-2/+2
| | | | | | | | | | | | | | | | | | This removes the duplicate (and possible error-prone) versions (once for test and once for error message) and simplifies code. Adjusted multiple go/types call sites to match types2. Renamed posFor to atPos in types2, for closer match with go/types and to keep automatic generation of instantiate.go working. Change-Id: Iff428fc742f305a65bb7d077b7e31b66df3b706d Reviewed-on: https://go-review.googlesource.com/c/go/+/491715 Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/types, types2: implement reverse type inference for function argumentsRobert Griesemer2023-05-033-5/+68
| | | | | | | | | | | | | | | | | | | | | | | | | Allow function-typed function arguments to be generic and collect their type parameters together with the callee's type parameters (if any). Use a single inference step to infer the type arguments for all type parameters simultaneously. Requires Go 1.21 and that Config.EnableReverseTypeInference is set. Does not yet support partially instantiated generic function arguments. Not yet enabled in the compiler. Known bug: inference may produce an incorrect result is the same generic function is passed twice in the same function call. For #59338. Change-Id: Ia1faa27a28c6353f0bbfd7f81feafc21bd36652c Reviewed-on: https://go-review.googlesource.com/c/go/+/483935 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com>
* cmd/compile,cmd/link: skip tests that require DWARF symbols on iosBryan C. Mills2023-05-031-1/+11
| | | | | | | | | | | | | | | The linker does not combine DWARF information into the binary on ios. This generalizes test skips that were already present for a similar reason on plan9. Fixes #59939. Change-Id: Ideda07c9f9a69fd102a7d9a83ea8e7b7c29d0da2 Reviewed-on: https://go-review.googlesource.com/c/go/+/491835 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Bypass: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
* cmd/link: generate .xdata PE sectionqmuntal2023-05-022-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | This CL adds a .xdata section to the PE file generated by the Go linker. It is also the first CL of the SEH chain that adds effective support for unwinding the Go stack, as demonstrated by the newly added tests. The .xdata section is a standard PE section that contains an array of unwind data info structures. This structures are used to record the effects a function has on the stack pointer, and where the nonvolatile registers are saved on the stack [1]. Note that this CL still does not support unwinding the cgo stack. Updates #57302 [1] https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64#struct-unwind_info Change-Id: I6f305a51ed130b758ff9ca7b90c091e50a109a6f Reviewed-on: https://go-review.googlesource.com/c/go/+/457455 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Davis Goodin <dagood@microsoft.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
* cmd/link: generate .pdata PE sectionqmuntal2023-05-022-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds a .pdata section to the PE file generated by the Go linker. The .pdata section is a standard section [1] that contains an array of function table entries that are used for stack unwinding. The table entries layout is taken from [2]. This CL just generates the table entries without any unwinding information, which is enough to start doing some E2E tests between the Go linker and the Win32 APIs. The goal of the .pdata table is to allow Windows retrieve unwind information for a function at a given PC. It does so by doing a binary search on the table, looking for an entry that meets BeginAddress >= PC < EndAddress. Each table entry takes 12 bytes and only non-leaf functions with frame pointer needs an entry on the .pdata table. The result is that PE binaries will be ~0.7% bigger due to the unwind information, a reasonable amount considering the benefits in debuggability. Updates #57302 [1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#the-pdata-section [2] https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64#struct-runtime_function Change-Id: If675d10c64452946dbab76709da20569651e3e9f Reviewed-on: https://go-review.googlesource.com/c/go/+/461738 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* internal/testenv: probe for symlink on wasip1Johan Brandhorst-Satzkorn2023-05-023-3/+30
| | | | | | | | | | | | | | | | | | | | | Certain WASI runtimes do not support generic symlinks, and instead return permission errors when they are attempted. Perform a runtime probe of symlink support in hasSymlink on wasip1 to determine whether the runtime supports generic symlinks. Also perform the same probe on android. For #59583 Change-Id: Iae5b704e670650d38ee350a5a98f99dcce8b5b28 Reviewed-on: https://go-review.googlesource.com/c/go/+/490115 Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Achille Roussel <achille.roussel@gmail.com> TryBot-Bypass: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* go/types, types2: isParameterized must be able to handle tuplesRobert Griesemer2023-05-011-0/+17
| | | | | | | | | | | | | | | | | CL 484615 rewrote isParameterized by handling tuple types only where they occur (function signatures). However, isParameterized is also called from Checker.callExpr, with a result parameter list which is a tuple. This CL handles tuples again. Fixes #59890. Change-Id: I35159ff65f23322432557e6abcab939933933d40 Reviewed-on: https://go-review.googlesource.com/c/go/+/490695 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Griesemer <gri@google.com>
* internal/testenv: allow 'go build' on android when supportedBryan C. Mills2023-04-281-5/+58
| | | | | | | | | | | | | | | | | As of CL 472096, it should work on android/arm64 always (because internal linking is supported on that platform), and on other android platforms when a C toolchain is present in the test environment. Updates #58775. Change-Id: Ifa38dc69b258b38dcc341979dcbf8cd61265c787 Reviewed-on: https://go-review.googlesource.com/c/go/+/475456 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Changkun Ou <mail@changkun.de>
* cmd/dist,internal: enable buildmode=c-archive for linux/loong64Guoqi Chen2023-04-271-1/+1
| | | | | | | | | | | | | | | | Now the shared flag is supported on the linux/loong64 platform and misc/cgo/testcarchive has been passed, buildmode=c-archive can be used. Change-Id: Ice450dc11fcb91942fdf2ddd34bb163853267e01 Reviewed-on: https://go-review.googlesource.com/c/go/+/489576 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: WANG Xuerui <git@xen0n.name> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: WANG Xuerui <git@xen0n.name>
* all: remove repeated definite articlescui fliter2023-04-272-2/+2
| | | | | | | | | | | Change-Id: Idea3e6ca6e62bd5a5ff6e6d5c3f39efb7628f0ec Reviewed-on: https://go-review.googlesource.com/c/go/+/489635 Run-TryBot: Michael Pratt <mpratt@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
* coverage: fix count vs emit discrepancy in coverage counter data writingThan McIntosh2023-04-262-35/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch revises the way coverage counter data writing takes place to avoid problems where useful counter data (for user-written functions) is skipped in favor of counter data from stdlib functions that are executed "late in the game", during the counter writing process itself. Reading counter values from a running "--coverpkg=all" program is an inherently racy operation; while the the code that scans the coverage counter segment is reading values, the program is still executing, potentially updating those values, and updates can include execution of previously un-executed functions. The existing counter data writing code was using a two-pass model (initial sweep over the counter segment to count live functions, second sweep to actually write data), and wasn't properly accounting for the fact that the second pass could see more functions than the first. In the bug in question, the first pass discovered an initial set of 1240 functions, but by the time the second pass kicked in, several additional new functions were also live. The second pass scanned the counter segment again to write out exactly 1240 functions, but since some of the counters for the newly executed functions were earlier in the segment (due to linker layout quirks) than the user's selected function, the sweep terminated before writing out counters for the function of interest. The fix rewrites the counter data file encoder to make a single sweep over the counter segment instead of using a two-pass scheme. Fixes #59563. Change-Id: I5e908e226bb224adb90a2fb783013e52deb341da Reviewed-on: https://go-review.googlesource.com/c/go/+/484535 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Than McIntosh <thanm@google.com>
* internal/coverage/slicewriter: fix off-by-1 error in seek utilitiesThan McIntosh2023-04-262-7/+10
| | | | | | | | | | | | The slicewriter Seek method was being too restrictive on offsets accepted, due to an off-by-one problem in the error checking code. This fixes the problem and touches up the unit tests. Change-Id: I75d6121551de19ec9275f0e331810db231db6ea9 Reviewed-on: https://go-review.googlesource.com/c/go/+/488116 Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* internal/cpu: add a detection for Neoverse(N2, V2) coresfanzha022023-04-253-23/+23
| | | | | | | | | | | | | | | | | | | | The memmove implementation relies on the variable runtime.arm64UseAlignedLoads to select fastest code path. Considering Neoverse N2 and V2 cores prefer aligned loads, this patch adds code to detect them for memmove performance. And this patch uses a new variable ARM64.IsNeoverse to represent all Neoverse cores, removing the more specific versions. Change-Id: I9e06eae01a0325a0b604ac6af1e55711dd6133f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/487815 Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Fannie Zhang <Fannie.Zhang@arm.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>