aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
AgeCommit message (Collapse)Author
2022-01-14cmd/dist: log CPU model when testingMichael Pratt
Knowing whether test failures are correlated with specific CPU models on has proven useful on several issues. Log it for prior to testing so it is always available. internal/sysinfo provides the CPU model, but it is not available in the bootstrap toolchain, so we can't access this unconditionally in cmd/dist. Instead use a build-tagged file, as the final version of cmd/dist will use the final toolchain. The addition of new data to the beginning of cmd/dist output will break x/build/cmd/coordinator's banner parsing, leaving extra lines in the log output, though information will not be lost. https://golang.org/cl/372538 fixes up the coordinator and should be submitted and deployed before this CL is submitted. For #46272. For #49209. For #50146. Change-Id: I515d2ec58e4c0034b76bf624ecaab38f16146074 Reviewed-on: https://go-review.googlesource.com/c/go/+/371474 Trust: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2022-01-14cmd/compile: add call to ImportedBody() when exporting shape inst bodyDan Scales
When we export a shape instantiation, because a particular fully-instantiated type is needed by an inlineable function, we possibly export the body of the instantiation, if it is inlineable. In this case, we should have been calling ImportedBody() to make sure that the function body had already been read in (if it is actually imported from another package). Fixes #50598 Change-Id: I512d2bcc745faa6ff3a97e25bc8f46e2c2643d23 Reviewed-on: https://go-review.googlesource.com/c/go/+/378494 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
2022-01-13cmd/compile: stop interface conversions for generic method calls from allocatingKeith Randall
Let T be a type parameter, and say we instantiate it with S, a type that isn't pointer-like (e.g. a pair of ints, or as in 50182, a slice). Then to call a method m on a variable of type T, the compiler does essentially: var v T = ... i := (interface{m()})(v) i.m() The conversion at that second line allocates, as we need to make the data word for an interface. And in the general case, that interface may live an arbitrarily long time. But in this case, we know it doesn't. The data word of i has type *S. When we call i.m, we can't call S.m directly. It is expecting an S, not a *S. We call through a wrapper defined on *S, which looks like: func (p *S) m() { var s S = *p s.m() } The value passed in for p is exactly the data word mentioned above. It never escapes anywhere - the wrapper copies a type S variable out of *p and p is dead after that. That means that in the situation where we build an interface for the explicit purpose of calling a method on it, and use that built interface nowhere else, the allocation of the data word for that interface is known to die before the call returns and thus can be stack allocated. One tricky case is that although the allocation of the backing store of the interface conversion doesn't escape, pointers we store *inside* that allocation might escape (in fact they definitely will, unless we can devirtualize the receiver). Fixes #50182 Change-Id: I40e893955c2e6871c54ccecf1b9f0cae17871b0d Reviewed-on: https://go-review.googlesource.com/c/go/+/378178 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-13cmd/compile: descend through types to find fully-instantiated typesDan Scales
In order to make sure we export the dictionaries/shape methods for all fully-instantiated types in inlineable functions, we need to descend fully into types. For example, we may have a map type (e.g. map[transactionID]Promise[*ByteBuffer]), where the key or value is a new fully-instantiated type. So, I add a new checkFullyInst() traversal function, which traverses all encountered types, but maintains a map, so it only traverse it type once. We need to descend fully into interfaces, structs, and methods, since a fully-instantiated type make occur in any fields or arguments/results of methods, etc. Fixes #50561 Change-Id: I88681a30384168539ed7229eed709f4e73ff0666 Reviewed-on: https://go-review.googlesource.com/c/go/+/378154 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-13cmd/compile: unique LinkString for renamed, embedded fieldsMatthew Dempsky
Using type aliases, it's possible to create structs with embedded fields that have no corresponding type literal notation. However, we still need to generate a unique name for these types to use for linker symbols. This CL introduces a new "struct{ Name = Type }" syntax for use in LinkString formatting to represent these types. Reattempt at CL 372914, which was rolled back due to race-y LocalPkg.Lookup call that isn't safe for concurrency. Fixes #50190. Change-Id: I0b7fd81e1b0b3199a6afcffde96ade42495ad8d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/378434 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2022-01-13cmd/go: run go install in workspace modeMichael Matloob
It's too confusing to users to run go install in module mode, so run it in workspace mode instead. Fixes #50036 Change-Id: Ia99927bd98f54be4c42224a247543892045e3464 Reviewed-on: https://go-review.googlesource.com/c/go/+/377334 Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-13cmd/go: reset modfetch state between modules in go work syncMichael Matloob
go work sync resets the state in the modload package before each iteration where it updates the workspace modules' go.mod files. But before this change it wasn't resetting the global state in the modfetch package. This is necessary because the modfetch package keeps track of the sums that will be written to go.sum. Further, the fetch caches will update information about which modules are used when fetching packages, and so those caches need to be cleared between each workspace module. Thanks bcmills for helping me debug! Fixes #50038 Change-Id: I5679c18a80feb7c5194c4a5f7e7129c7d198ef7b Reviewed-on: https://go-review.googlesource.com/c/go/+/376655 Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-12cmd/go: enable fuzz testing for FreeBSDAyan George
Add "freebsd" to GOOS for which sys.FuzzSupported() returns true and add freebsd to the build tags to fuzz test source. Fixes #46554 Change-Id: I5f695ecc8f09c0ab4279ced23b4715b788fcade0 Reviewed-on: https://go-review.googlesource.com/c/go/+/377855 Trust: Bryan Mills <bcmills@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org>
2022-01-12go/types, types2: fix tracing output for type and expr listsRobert Griesemer
- support printing of expression and type lists in sprintf - simplified some code in go/types/exprstring.go - fixed a typo in syntax package Change-Id: Ic4bc154200aad95958d5bc2904a9ea17cf518388 Reviewed-on: https://go-review.googlesource.com/c/go/+/377974 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-12go/types, types2: prevent unification from recursing endlesslyRobert Griesemer
This is a stop gap solution to avoid panics due to stack overflow during type unification. While this doesn't address the underlying issues (for which we are still investigating the correct approach), it prevents a panic during compilation and reports a (possibly not quite correct) error message. If the programs are correct in the first place, manually providing the desired type arguments is a viable work-around, resulting in code that will continue to work even when the issues here are fixed satisfactorily. For #48619. For #48656. Change-Id: I13bb14552b38b4170b5a1b820e3172d88ff656ec Reviewed-on: https://go-review.googlesource.com/c/go/+/377954 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-12go/types, types2: make function type inference argument-order independentRobert Griesemer
If we have more than 2 arguments, we may have arguments with named and unnamed types. If that is the case, permutate params and args such that the arguments with named types are first in the list. This doesn't affect type inference if all types are taken as is. But when we have inexact unification enabled (as is the case for function type inference), when a named type is unified with an unnamed type, unification proceeds with the underlying type of the named type because otherwise unification would fail right away. This leads to an asymmetry in type inference: in cases where arguments of named and unnamed types are passed to parameters with identical type, different types (named vs underlying) may be inferred depending on the order of the arguments. By ensuring that named types are seen first, order dependence is avoided and unification succeeds where it can. This CL implements the respectice code but keeps it disabled for now, pending decision whether we want to address this issue in the first place. For #43056. Change-Id: Ibe3b08ec2afe90a24a8c30cd1875d504bcc2ef39 Reviewed-on: https://go-review.googlesource.com/c/go/+/377894 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-12go/types, types2: do not run CTI before FTIRobert Griesemer
Until now, CTI (constraint type inference) was run before FTI (function type inference). This lead to situations where CTI infered a type that is missing necessary methods even though a function argument of correct type was given. This can happen when constraint type inference produces a inferred type that is the structural type of multiple types, which then is an underlying type, possibly without methods. This CL removes the initial CTI step; it is only applied after FTI with type arguments is run, and again after FTI with untyped arguments is run. Various comments are adjusted to reflect the new reality. Fixes #50426. Change-Id: I700ae6e762d7aa00d742943a2880f1a1db33c2b8 Reviewed-on: https://go-review.googlesource.com/c/go/+/377594 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-12cmd/compile/types2, go/types: add position for "have" in failed interface ↵Emmanuel T Odeke
satisfaction With this change, we shall now see: *myS does not implement S (wrong type for DoSomething method) have DoSomething() (string, error) at ./main.go:9:14 want DoSomething() (int, error) instead of previously: *myS does not implement S (wrong type for DoSomething method) have DoSomething() (string, error) want DoSomething() (int, error) Fixes #42841 Fixes #45813 Change-Id: I66990929e39b0d36f2e91da0d92f60586a9b84e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/373634 Trust: Robert Findley <rfindley@google.com> Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2022-01-11cmd/compile: fix the names of methods created during type substitutionDan Scales
The names given to methods of types created during type substitution were possible incorrect when the type parameters themselves were nested types. Fixes #50485 Change-Id: I7e0043ed22c26406a5f9d8d51d9e928770a678f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/377494 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-11cmd/compile: in typ0(), load base type before checking s.DefDan Scales
The loading of the base type in typ0() may cause s.Def to be defined for the instantiated type, so load the base type before checking s.Def. Fixes #50486 Change-Id: Ic039bc8f774dda534f4ccd1f920220b7a10dede6 Reviewed-on: https://go-review.googlesource.com/c/go/+/377094 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2022-01-11cmd/compile: resolve dictionaries/shape methods in markInlBody, if neededDan Scales
Issue #50552 is due to a problem with my recent improvement in the interaction between generics and inlining. In markInlBody(), we now mark dictionaries and shape methods for export, so they will be available for any package that inlines the current inlineable function. But we need to make sure that the dictionary and method symbols have actually been resolved into Nodes (looked up in the import data), if they are not already defined, so we can then mark them for export. Improved header comment on Resolve(). Fixes #50552 Change-Id: I89e52d39d3b9894591d2ad6eb3a8ed3bb5f1e0a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/377714 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
2022-01-11go/types, types2: mention type decl scopes in Info.Scopes documentationRobert Findley
We now may have a scope associated with a type declaration, so need to update our API documentation accordingly. Change-Id: Ic66dc3b7cd1969b25fb7c4bee986d76ab3544042 Reviewed-on: https://go-review.googlesource.com/c/go/+/377655 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-11cmd/compile: print "internal compiler error" message for all compiler panicsDan Scales
Change hidePanic (now renamed handlePanic) to print out the "internal compiler error" message for all panics and runtime exceptions, similar to what we already do for the SSA backend in ssa.Compile(). Previously, hidePanic would not catch panics/exceptions unless it wanted to completely hide the panic because there had already been some compiler errors. Tested by manually inserting a seg fault in the compiler, and verifying that the seg fault is cause and "internal compiler error" message (with stack trace) is displayed proeprly. Updates #50423 Change-Id: Ibe846012e147fcdcc63ac147aae4bdfc47bf5a58 Reviewed-on: https://go-review.googlesource.com/c/go/+/376057 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2022-01-11cmd/go: skip TestScript/test_fuzz_test_race on !raceTobias Klauser
Skip the test on targets which don't support the race detector. This fixes the linux-386-longtest builder after CL 376554. Updates #50488 Change-Id: I08bf6f72cc0731761d49121eb7cfaa8b53906d37 Reviewed-on: https://go-review.googlesource.com/c/go/+/377634 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org>
2022-01-10go/types, types2: refer to type parameter if so for interface pointer errorsRobert Griesemer
Follow-up on comment in CL 376914. Also: - add missing check != nil test in assignableTo - use check.sprintf rather than fmt.Sprintf in missingMethodReason For #48312. Change-Id: Ie209b4101a7f2c279e42a59987d0068079c8b69f Reviewed-on: https://go-review.googlesource.com/c/go/+/377375 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-10go/types, types2: better error message for type parameter field accessRobert Griesemer
Fixes #50516. Also call DefPredeclaredTestFuncs in TestFixedbugs so it can be run independently again. Change-Id: I78d4cc11790b1543a2545a7ab297a223b3d5e3c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/376954 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-10go/types, types2: better error message when using *interface instead of ↵Robert Griesemer
interface - detect *interface case and report specific error - replaced switch with sequence of if's for more clarity - fixed isInterfacePtr: it applies to all interfaces, incl. type parameters - reviewed/fixed all uses of isInterfacePtr - adjusted error messages to be consistently of the format "type %s is pointer to interface, not interface" Fixes #48312. Change-Id: Ic3c8cfcf93ad57ecdb60f6a727cce9e1aa4afb5d Reviewed-on: https://go-review.googlesource.com/c/go/+/376914 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-10testing: only snapshot coverage during fuzzingRoland Shoemaker
Only snapshot/reset coverage counters when we are actually fuzzing. This prevents a race when running corpus/seed values during the testing phase. Fixes #50488 Change-Id: I7dd5a0353a296c0b13eede29ad9af7c78814fa2d Reviewed-on: https://go-review.googlesource.com/c/go/+/376554 Trust: Katie Hockman <katie@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-10cmd/compile: use exact constant in go_asm.hIan Lance Taylor
Fixes #50523 Change-Id: Idab1b44d106250e9301d90ee6571f0ea51242dd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/377074 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Liz Fong-Jones <lizf@honeycomb.io> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-10Revert "cmd/compile: unique LinkString for renamed, embedded fields"Matthew Dempsky
This reverts CL 372914. Reason for revert: missing synchronization Change-Id: I7ebb6de082cebb73741d803ff00e3465bbafab81 Reviewed-on: https://go-review.googlesource.com/c/go/+/377379 Trust: Dan Scales <danscales@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dan Scales <danscales@google.com> Trust: Matthew Dempsky <mdempsky@google.com>
2022-01-10cmd/compile, test: updated comments in crawler.go, added testDan Scales
Added a test to make sure that the private methods of a local generic type are properly exported, if there is a global variable with that type. Added comments in crawler.go, to give more detail and to give more about the overall purpose. Fixed one place where t.isFullyInstantiated() should be replaced by isPtrFullyInstantiated(t), so that we catch pointers to generic types that may be used as a method receiver. Change-Id: I9c42d14eb6ebe14d249df7c8fa39e889f7cd3f22 Reviewed-on: https://go-review.googlesource.com/c/go/+/374754 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-10cmd/compile: unique LinkString for renamed, embedded fieldsMatthew Dempsky
Using type aliases, it's possible to create structs with embedded fields that have no corresponding type literal notation. However, we still need to generate a unique name for these types to use for linker symbols. This CL introduces a new "struct{ Name = Type }" syntax for use in LinkString formatting to represent these types. Fixes #50190. Change-Id: I025ceb09a86e00b7583d3b9885d612f5d6cb44fe Reviewed-on: https://go-review.googlesource.com/c/go/+/372914 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Trust: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Robert Griesemer <gri@golang.org>
2022-01-10cmd/compile: fix interaction between generics and inliningDan Scales
Finally figured out how to deal with the interaction between generics and inlining. The problem has been: what to do if you inline a function that uses a new instantiated type that hasn't been seen in the current package? This might mean that you need to do another round of function/method instantiatiations after inlining, which might lead to more inlining, etc. (which is what we currently do, but it's not clear when you can stop the inlining/instantiation loop). We had thought that one solution was to export instantiated types (even if not marked as exportable) if they are referenced in exported inlineable functions. But that was quite complex and required changing the export format. But I realized that we really only need to make sure the relevant dictionaries and shape instantiations for the instantiated types are exported, not the instantiated type itself and its wrappers. The instantiated type is naturally created as needed, and the wrappers are generated automatically while writing out run-time type (making use of the exported dictionaries and shape instantiations). So, we just have to make sure that those dictionaries and shape instantiations are exported, and then they will be available without any extra round of instantiations after inlining. We now do this in crawler.go. This is especially needed when the instantiated type is only put in an interface, so relevant dictionaries/shape instantiations are not directly referenced and therefore exported, but are still needed for the itab. This fix avoids the phase ordering problem where we might have to keep creating new type instantiations and instantiated methods after each round of inlining we do. Removed the extra round of instantiation/inlining that were added in the previous fix. The existing tests test/typeparam{geninline.go,structinit.go} already test this situation of inlining a function referencing a new instantiated type. Added the original example from issue 50121 as test (has 5 packages), since it found a problem with this code that the current simpler test for 50121 did not find. Change-Id: Iac5d0dddf4be19376f6de36ee20a83f0d8f213b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/375494 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
2022-01-09go/types, types2: better error message for invalid == on type parametersRobert Griesemer
Fixes #48712. Change-Id: I6f214cdfdd1815493f2a04828e8f0097f1d8c124 Reviewed-on: https://go-review.googlesource.com/c/go/+/372734 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-07cmd/compile: accept string|[]byte-constrained 2nd argument in appendRobert Griesemer
Similarly to what we do for the built-in function `copy`, where we allow a string as 2nd argument to append, also permit a type parameter constrained by string|[]byte. While at it, change date in the manual.go2 test files so that we don't need to constantly correct it when copying a test case from that file into a proper test file. Fixes #50281. Change-Id: I23fed66736aa07bb3c481fe97313e828425ac448 Reviewed-on: https://go-review.googlesource.com/c/go/+/376214 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-07cmd/compile: fix conv of slice of user-define byte type to stringDan Scales
types2 allows the conversion of a slice of a user-defined byte type B (not builtin uint8 or byte) to string. But runtime.slicebytetostring requires a []byte argument, so add in a CONVNOP from []B to []byte if needed. Same for the conversion of a slice of user-defined rune types to string. I made the same change in the transformations of the old typechecker, so as to keep tcConv() and transformConv() in sync. That fixes the bug for -G=0 mode as well. Fixes #23536 Change-Id: Ic79364427f27489187f3f8015bdfbf0769a70d69 Reviewed-on: https://go-review.googlesource.com/c/go/+/376056 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-07cmd/compile: fix instantiation of types referenced during inliningCuong Manh Le
CL 352870 added extra phase for instantiation after inlining, to take care of the new fully-instantiated types. However, when fetching inlined body of these types's methods, we need to allow OADDR operations on untyped expressions, the same as what main inlining phase does. The problem does not show up, until CL 371554, which made the compiler do not re-typecheck while importing, thus leaving a OXDOT node to be marked as address taken when it's not safe to do that. Fixes #50437 Change-Id: I20076b872182c520075a4f8b84230f5bcb05b341 Reviewed-on: https://go-review.googlesource.com/c/go/+/375574 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2022-01-07go/types, types2: disallow multiple blank type parametersRobert Griesemer
Work-around for #50481: report an error for multiple blank type parameters. It's always possible to use non-blank names in those cases. We expect to lift this restriction for 1.19. For #50481. Change-Id: Ifdd2d91340aac1da3387f7d80d46e44f5997c2a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/376058 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Dan Scales <danscales@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-06cmd/compile: report type parameter error for methods only onceRobert Griesemer
Move switch to enable method type parameters entirely to the parser, by adding the mode AllowMethodTypeParams. Ensure that the error messages are consistent. Remove unnecessary code in the type checker. Fixes #50317. Change-Id: I4f3958722400bdb919efa4c494b85cf62f4002bb Reviewed-on: https://go-review.googlesource.com/c/go/+/376054 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-06testing: fix deadlock with t.Parallel in testing seed corpusKatie Hockman
The c.startParallel channel on the testContext is stuck in t.Parallel() because c.running starts at 1 for the main fuzz parent test, and is causing a deadlock because it is never released. It would normally be released by tRunner, but needs to instead be released by fRunner instead for fuzz tests. Fixes #50217 Change-Id: I2d010e9adddfd8e8321ff2f9dd2e43daf46c128f Reviewed-on: https://go-review.googlesource.com/c/go/+/374054 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-06go/types, types2: implement field access for struct structural constraintsRobert Griesemer
This change implements field the access p.f where the type of p is a type parameter with a structural constraint that is a struct with a field f. This is only the fix for the type checker. The compiler will need a separate CL. This makes the behavior consistent with the fact that we can write struct composite literals for type parameters with a struct structural type. For #50417. For #50233. Change-Id: I87d07e016f97cbf19c45cde19165eae3ec0bad2b Reviewed-on: https://go-review.googlesource.com/c/go/+/375795 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-06go/types, types2: remove unused code in lookupFieldOrMethodRobert Griesemer
The underlying type of a type parameter is an interface, so we don't need a special case for type parameters anymore. Simply share the (identical) code for interfaces. Adjust code in types.NewMethodSet accordingly. No functional difference. Preparation for fix of issues below. For #50233. For #50417. Change-Id: Ib2deadd12f89e6918dec224b4ce35583001c3101 Reviewed-on: https://go-review.googlesource.com/c/go/+/375514 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-06go/types, types2: ensure that signature type bounds are interfacesRobert Griesemer
Do this by running verification for instantiated signatures later, after the delayed type parameter set-up had a chance to wrap type bounds in implicit interfaces where needed. Fixes #50450 Change-Id: If3ff7dc0be6af14af854830bfddb81112ac575cb Reviewed-on: https://go-review.googlesource.com/c/go/+/375737 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-06go/types, types2: eagerly check that constraints are not type paramsRobert Findley
As a result of the change to the underlying of a type parameter to be its constraint interface, we had couple inaccuracies that combined to cause an infinite recursion when type checking the invalid type parameter list [A A]. - We deferred tpar.iface() using check.later twice: once in newTypeParam, and then again at the end of collectTypeParams. - We deferred the check that type parameter constraints are not type parameters, even though this is unnecessary: the constraint type is known. With these inaccuracies, tpar.iface() was executing before our guard against using type parameters as constraints, causing an infinite recursion through under(). Fix this by eagerly checking whether the constraint is a type parameter, and marking it invalid if so. Also remove the unnecessary calls to tpar.iface() at the end of collectTypeParams, as this will already have been scheduled by newTypeParam. Fixes #50321 Change-Id: I4eecbecf21656615867cb94be65b520e9e795bd1 Reviewed-on: https://go-review.googlesource.com/c/go/+/374294 Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-06cmd/compile/internal/types2: better error message for invalid range clauseRobert Griesemer
Fixes #50372. Change-Id: I8e4c0020dae42744cce016433e398e0b884bb044 Reviewed-on: https://go-review.googlesource.com/c/go/+/375475 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-06doc: improve documentation for GOAMD64Ulrich Kunitz
The change clarifies in the release notes for go1.18 that the variable is for compilation and references the microarchitecture description in the Go Wiki, https://golang.org/wiki/MinimumRequirements#amd64, and references the same information in the output of go help environment. Fixes #50174 Change-Id: I6a7d5a06f48463a810c96cc9c76fe66113d5147c Reviewed-on: https://go-review.googlesource.com/c/go/+/372194 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-05cmd/go: add fuzzing coverage testRoland Shoemaker
Adds a test script for fuzzing coverage instrumentation. Fixes #48654 Change-Id: Ieea7b4146bd5581baae869441cc1c652dd7485f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/375736 Trust: Katie Hockman <katie@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-04cmd/compile: save selector/inst info for generic method/function callsDan Scales
In the dict info, we need to save the SelectorExpr of a generic method call when making its sub-dictionary entry. The generic method call will eventually be transformed into a function call on the method shape instantiation, so we may not always have the selector info available when we need it to create a dictionary. We use this SelectorExpr as needed if the relevant call node has already been transformed. Similarly, we save the InstExpr of generic function calls, since the InstExpr will be dropped when the function call is transformed to a call to a shape instantiation. We use this InstExpr if the relevant function call has already been transformed. Added an extra generic function Some2 and a call to it from Some that exercises the generic function case. The existing test already tests the method call case. Fixes #50264 Change-Id: I2c7c7d79a8e33ca36a5e88e64e913c57500c97f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/373754 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-04cmd/compile: pop instantiations of local types when leaving scopeDan Scales
Since we use existing instantiations from the symbol table when possible (to make sure each instantiation is unique), we need to pop instantiations of local types when leaving the containing scope. g.stmts() now pushes and pops scope, and we do a Pushdcl() in g.typ0() when creating an instantiation of a local type. Non-instantiated local types (generic or not) are translated directly from types2, so they don't need to be pushed/popped. We don't export function bodies with local types, so there is no issue during import. We still don't support local types in generic functions/methods. Fixes #50177 Change-Id: If2d2fe71aec003d13f0338565c7a0da2c9580a14 Reviewed-on: https://go-review.googlesource.com/c/go/+/372654 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-23cmd/go: remove MallocNanoZone environment variable workaroundCherry Mui
We added a workaround in runtime/race. This should not be necessary now. Updates #49138. Change-Id: Ia2010e4acc95c4ddf5f463ab2919401d893c0bac Reviewed-on: https://go-review.googlesource.com/c/go/+/374314 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-23cmd/compile/internal/ir: fix a typo in node.gozhangjian
README.md -> HACKING.md Change-Id: I63909b86b2e6f8d9a34622f5d2b05048c79cd698 GitHub-Last-Rev: afaab8f05eff1d66c796909ccf9912e0f4e99754 GitHub-Pull-Request: golang/go#50326 Reviewed-on: https://go-review.googlesource.com/c/go/+/374274 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-12-21all: update vendored golang.org/x/crypto for cryptobyte fixFilippo Valsorda
Fixes #49678 Change-Id: I47dd959a787180a67856e60dfa6eba3ddd045972 Reviewed-on: https://go-review.googlesource.com/c/go/+/373360 Run-TryBot: Filippo Valsorda <filippo@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Trust: Filippo Valsorda <filippo@golang.org>
2021-12-21cmd/link: use SHT_INIT_ARRAY for .init_array sectionIan Lance Taylor
Fixes #50295 Change-Id: If55ebcd5f2af724da7c9c744458a56d21a7ddde7 Reviewed-on: https://go-review.googlesource.com/c/go/+/373734 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-12-20cmd/doc: don't log on constraint type elementsIan Lance Taylor
Fixes #50256 Change-Id: I2327a0b28f8173c801ed2946bec8083967667027 Reviewed-on: https://go-review.googlesource.com/c/go/+/373314 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-12-20all: fix spelling errors found by misspellDan Kortschak
Change-Id: Icedd0c3d49259d5aee249ecb33374e9b78e0c275 Reviewed-on: https://go-review.googlesource.com/c/go/+/373376 Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>