The compiler currently has two modes for compilation: one where it
compiles each function as it sees them, and another where it enqueues
them all into a work queue. A subsequent CL is going to reorder
function compilation to ensure that functions are always compiled
before any non-trivial function literals they enclose, and this will
be easier if we always use the compile work queue.
Also, fewer compilation modes makes things simpler to reason about.
Change-Id: Ie090e81f7476c49486296f2b90911fa0a466a5dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/283313
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
InitLSym is where we're now generating ABI wrappers, so it seems as
good a place as any to make sure we're generating the degenerate
closure wrappers for declared functions and methods.
Change-Id: I097f34bbcee65dee87a97f9ed6f3f38e4cf2e2b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/283312
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
For #36460
Updates #36465
Change-Id: Id818dce21d39a48cf5fc9c015b30497dce9cd1ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/278596
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Just directly set Type.Vargen when declaring defined types within a
function.
Change-Id: Idcc0007084a660ce1c39da4a3697e158a1c615b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/283212
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Historically, inline function bodies were exported as plain Go source
code, and symbol mangling was a convenient hack because it allowed
variables to be re-imported with largely the same names as they were
originally exported as.
However, nowadays we use a binary format that's more easily extended,
so we can simply serialize all of a function's declared objects up
front, and then refer to them by index later on. This also allows us
to easily report unmangled names all the time (e.g., error message
from issue7921.go).
Fixes#43633.
Change-Id: I46c88f5a47cb921f70ab140976ba9ddce38df216
Reviewed-on: https://go-review.googlesource.com/c/go/+/283193
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Creating closure vars is subtle and is also needed in both CL 281932
and CL 283112, so refactor out a common implementation that can be
used in all 3 places.
Passes toolstash -cmp.
Change-Id: Ib993eb90c895b52759bfbfbaad88921e391b0b4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/283194
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
This CL refactors noder's package import logic so it's easier to reuse
with types2 and gcimports. In particular, this allows the types2
integration to now support vendored packages.
Change-Id: I1fd98ad612b4683d2e1ac640839e64de1fa7324b
Reviewed-on: https://go-review.googlesource.com/c/go/+/282919
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
This CL extracts and simplifies noder's DWARF scope tracking code to
make it easier for reuse by irgen.
The previous code tried to be really clever about avoid recording
multiple scope boundaries at the same position (as happens at the end
of "if" and "for" statements). I had a really hard time remember how
this code worked exactly, so I've reimplemented a simpler algorithm
that just tracks all scope marks, and then compacts them at the end
before saving them to the ir.Func.
Passes toolstash -cmp.
Change-Id: Ibeb37997b77dc5179360d7db557c82ae1682e127
Reviewed-on: https://go-review.googlesource.com/c/go/+/282918
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Import changes from go2go to automatically discover testdata-driven
check tests.
Tests for generics will be added in a subsequent CL.
Change-Id: I50d55141750caebf15f1f382e139edfe9920c14e
Reviewed-on: https://go-review.googlesource.com/c/go/+/283132
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Escape analysis needs to know the index of result parameters for
recording escape-flow information. It currently relies on Vargen for
this, but it can easily figure this out for itself. So just do that
instead, so that we can remove Vargen.
Passes toolstash -cmp.
For #43633.
Change-Id: I65dedc2d73bc25e85ff400f308e50b73dc503630
Reviewed-on: https://go-review.googlesource.com/c/go/+/283192
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Simplify the code and make it easier to reuse with irgen.
Change-Id: Id477c36e82c7598faa90025b1eed2606a3f82498
Reviewed-on: https://go-review.googlesource.com/c/go/+/282917
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This CL extracts the position mapping logic from noder and moves it
into a new posMap type, which can be more easily reused.
Passes toolstash -cmp.
Change-Id: I87dec3a3d27779c5bcc838f2e36c3aa8fabad155
Reviewed-on: https://go-review.googlesource.com/c/go/+/282916
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This CL adds an implementation of types2.Sizes that calculates sizes
using the same sizing algorithm as cmd/compile. In particular, it
matches how cmd/compile pads structures and includes padding in size
calculations.
Change-Id: I4dd8e51f95c90f9d7bd1e7463e40edcd3955a219
Reviewed-on: https://go-review.googlesource.com/c/go/+/282915
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Rerank editor plugins based on popularity (Go 2019 survey), and remove
Atom, as it is no longer popular.
Change-Id: I06d39b67eec24a920439b9ea1198b6e2a939874e
Reviewed-on: https://go-review.googlesource.com/c/go/+/283073
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This CL implements a number of minor fixes that were discovered in
getting -G=3 working for running all.bash.
1. Field tags were handled incorrectly. If a struct type had some
fields with tags, but later fields without tags, the trailing tag-less
fields would all copy the tag of the last tagged field. Fixed by
simply reinitializing `tag` to "" for each field visited.
2. Change the ending of switch case clause scopes from the end of the
last statement to the next "case" token or the switch-ending "}"
token. I don't think this is strictly necessary, but it matches my
intuition about where case-clause scopes end and cmd/compile's current
scoping logic (admittedly influenced by the former).
3. Change select statements to correctly use the scope of each
individual communication clause, instead of the scope of the entire
select statement. This issue appears to be due to the original
go/types code being written to rebind "s" from the *SelectStmt to the
Stmt in the range loop, and then being further asserted to "clause" of
type *CommClause. In most places within the loop body, "clause" was
used, but the rebound "s" identifier was used for the scope
boundaries.
However, in the syntax AST, SelectStmt directly contains a
[]*CommClause (rather than a *BlockStmt, with []Stmt), so no assertion
is necessary and instead of rebinding "s", the range loop was updated
to directly declare "clause".
4. The end position for increment/decrement statements (x++/x--) was
incorrectly calculated. Within the syntax AST, these are represented
as "x += ImplicitOne", and for AssignStmts types2 calculated the end
position as the end position of the RHS operand. But ImplicitOne
doesn't have any position information.
To workaround this, this CL detects ImplicitOne and then computes the
end position of the LHS operand instead, and then adds 2. In practice
this should be correct, though it could be wrong for ill-formatted
statements like "x ++".
Change-Id: I13d4830af39cb3f3b9f0d996672869d3db047ed2
Reviewed-on: https://go-review.googlesource.com/c/go/+/282914
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
go/types reports `"pkg/path" imported and not used` rather than
`imported and not used: "pkg/path"`, like cmd/compile. Relax the test
expectation to accomodate either.
Change-Id: I318992946160a9090f8991f4c97784ba1d1b78b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/282913
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Walk already explicitly calculates the size of all expression types,
to make sure they're known before SSA generation (which is concurrent,
and thus not safe to modify shared state like types). Might as well
compute all local variable sizes too, to be consistent.
Reduces the burden of the frontend to make sure it's calculated the
size of types that only the backend cares about.
Passes toolstash -cmp.
Change-Id: I68bcca67b4640bfc875467e4ed4d47104b1932f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/282912
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Import logic for typechecking statements involving generics from the
dev.go2go branch. Notably, range type checking was simplified in
dev.go2go, resulting in the removal of the _InvalidChanRange error code.
Change-Id: I84c2665226c2b9b74e85f7fb6df257b0a292e5d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/282120
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
This involved some non-trivial changes from dev.go2go, due to the
refactoring of assignability in master.
Change-Id: I73d99053fc8b184ae79b7b8973bd15e69e50fe6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/282119
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
This change imports assignments.go, builtins.go, call.go,
conversions.go, and expr.go from the dev.go2go branch.
Changes from dev.go2go:
- Update error positions and codes.
- Fix some failing tests due to error message changes.
- Fix a bug in exprInternal where normal IndexExpr checking wasn't
proceeding in the case of a non-generic indexed func.
- Fix the type of the second operand in commaerr expressions to be
universeError. We should add tests in a later CL.
This code was mostly reviewed, but call.go and expr.go were marked
incomplete. Additionally, these two files had notably diverged from
types2, requiring further understanding.
The dev.go2go branch significantly simplified the type checking of
arguments, resulting in the removal of the _InvalidDotDotDot operand
error code.
Change-Id: Iba2cef95e17bfaa6da6d4eb94c2e2ce1c691ac44
Reviewed-on: https://go-review.googlesource.com/c/go/+/282193
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
For some reason (that I didn't look into), externally linked
AIX binaries don't have runtime.symtab symbol. Since recent Go
releases (Go 1.3 maybe?), that symbol is empty and not necessary
anyway. Don't require it.
Fixes#40972.
Change-Id: I73a1f0142195ea6debdba8a4f6e12cadc3980dc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/279995
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
After the previous CLs, all closure reads are handled during SSA
construction.
Change-Id: Iad67b01fa2d3798f50ea647be7ccf8195f189c27
Reviewed-on: https://go-review.googlesource.com/c/go/+/281512
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Similar to with regular closures, we can change method value wrappers
to use ClosureVars and allow SSA construction to take care of wiring
it up appropriately.
Change-Id: I05c0b1bcec4e24305324755df35b7bc5b8a6ce7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/281353
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
For function literals that aren't inlined or directly called, we need
to pass their arguments via a closure struct. This also means we need
to rewrite uses of closure variables to access from this closure
struct.
Currently we do this rewrite in a pass before walking begins. This CL
moves the code to SSA construction instead, alongside binding other
input parameters.
Change-Id: I13538ef3394e2d6f75d5b7b2d0adbb00db812dc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/281352
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Currently, during walk we rewrite PAUTOHEAP uses into derefs of their
corresponding Heapaddr, but we can easily do this instead during SSA
construction. This does involve updating two test cases:
* nilptr3.go
This file had a test that we emit a "removed nil check" diagnostic for
the implicit dereference from accessing a PAUTOHEAP variable. This CL
removes this diagnostic, since it's not really useful to end users:
from the user's point of view, there's no pointer anyway, so they
needn't care about whether we check for nil or not. That's a purely
internal detail. And with the PAUTOHEAP dereference handled during SSA
construction, we can more robustly ensure this happens, rather than
relying on setting a flag in walk and hoping that SSA sees it.
* issue20780.go
Previously, when PAUTOHEAPs were dereferenced during walk, it had a
consequence that when they're passed as a function call argument, they
would first get copied to the stack before being copied to their
actual destination. Moving the dereferencing to SSA had a side-effect
of eliminating this unnecessary temporary, and copying directly to the
destination parameter.
The test is updated to instead call "g(h(), h())" where h() returns a
large value, as the first result will always need to be spilled
somewhere will calling the second function. Maybe eventually we're
smart enough to realize it can be spilled to the heap, but we don't do
that today.
Because I'm concerned that the direct copy-to-parameter optimization
could interfere with race-detector instrumentation (e.g., maybe the
copies were previously necessary to ensure they're not clobbered by
inserted raceread calls?), I've also added issue20780b.go to exercise
this in a few different ways.
Change-Id: I720598cb32b17518bc10a03e555620c0f25fd28d
Reviewed-on: https://go-review.googlesource.com/c/go/+/281293
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
With the recent compiler rewrites and cleanups to gc/fmt.go, the
"safety net" provided by fmt_test has become less important and
the test itself has become a burden (often breaks because of small
format changes elsewhere).
Eventually, the syntax and types2 packages will provide most error
and diagnostic compiler output at which point fmt.go can be further
simplified as well.
Change-Id: Ie93eefd3e1166f3548fed0199b732dbd6c81948a
Reviewed-on: https://go-review.googlesource.com/c/go/+/282560
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Follow-up on feedback by mdempsky@ in https://golang.org/cl/282552 .
Change-Id: I1e5bb2d67cc8ae29fed100b87d18a33b3e2069eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/282672
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>
Module-related help pages now contain a brief summary and point to the
reference documentation at golang.org/ref/mod for details.
Help pages for commands like 'go get' still describe the basic usage
and summarize flags but don't provide as much background detail.
Fixes#41427Fixes#43419
Change-Id: Icacd38e0f33c352c447cc5a496c99674493abde2
Reviewed-on: https://go-review.googlesource.com/c/go/+/282615
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
* All commands the user can run to fix the problem now appear alone on
a separate line after a tab.
* Removed -d from 'go get' commands.
* Replaced 'go mod tidy' with 'go mod download $modpath' when a
package might be provided by a module missing a sum.
* Errors about 'path@version' syntax are more explicit.
Fixes#29415Fixes#42087Fixes#43430Fixes#43523
Change-Id: I4427c2c4506a727a2c727d652fd2d506bb134d3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/282121
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Previously, commands that wrote go.sum (except 'go mod tidy') would
retain sums for zip files of directly required modules. Sums of
indirect dependencies wouldn't be retained unless they were used to
load packages.
With this change, sums for indirect dependencies will be retained if
they're available. This allows users to add missing sums with
'go mod download example.com/mod', which previously only worked for
directly required modules.
Note that 'go mod download' without arguments now adds sums for every
module in the build list. That matches 1.15 behavior.
For #41103
Change-Id: I4cce2bf1c73578dae836bdb5adb32da071554f1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/282692
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
All the current histogram metrics accumulate counts from program start
to infinity, and can be reasonably used to compute rates (also to
generate windowed distributions).
Change-Id: I5196c59867de34fba41bb8552606fa315460cef9
Reviewed-on: https://go-review.googlesource.com/c/go/+/282633
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
This change removes the as-of-yet unused StopTheWorld field in the
Description struct. Adding a new field to a struct is much easier than
removing it, so let's save it for when we actually need it.
Change-Id: I8074b8569187c1a148500575fa8a661534e875d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/282632
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
This moves the Walk visitor from the types2 to the syntax
package. There are no changes but for package name adjustments.
Preparation for a more full-fledged node visitor.
Change-Id: I95217e27ff943ac58a7638fb8d1cd347d0d554b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/282556
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>
This CL moves the exprstring_test.go from the types2
package into the syntax package (which contains the
actual ShortString function). The code is mostly un-
changed but for the updated TestShortString function.
Change-Id: Ib39e3181e643fc0ac96ddf144a3114893a50c2fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/282554
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>
The syntax package has a full-fledged node printer. Use that printer
to create the expression strings needed in error messages, and remove
the local (essentially) duplicate code for creating expression strings.
Change-Id: I03673e5e79b3c1470f8073ebbe840a90fd9053ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/282553
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>
Preparation for using the syntax printer as expression printer in types2.
- Introduced Form to control printing format
- Cleaned up/added String and ShortString convenience functions
- Implemented ShortForm format which prints … for non-empty
function and composite literal bodies
- Added test to check write error handling
Change-Id: Ie86e46d766fb60fcf07ef643c7788b2ef440ffa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/282552
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>
I have a real 7,000-line Go program (not so big)
that took over two minutes to report a trivial init cycle.
I thought the compiler was in an infinite loop but
it was actually just very slow.
CL 170062 rewrote init cycle reporting but replaced
a linear-time algorithm with an exponential one:
it explores all paths through the call graph of functions
involved in the cycle.
The net effect was that Go 1.12 took 0.25 seconds to load,
typecheck, and then diagnose the cycle in my program,
while Go 1.13 takes 600X longer.
This CL makes the new reporting code run in linear time,
restoring the speed of Go 1.12 but preserving the semantic
fixes from CL 170062.
Change-Id: I7d6dc95676d577d9b96f5953b516a64db93249bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/282314
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
When running go tool compile,
go tool is running compile as a subprocess.
Killing go tool with Process.Kill leaves the subprocess behind.
Send an interrupt signal first, which it can forward on
to the compile subprocess.
Also report the timeout in errorcheck -t.
Change-Id: I7ae0029bbe543ed7e60e0fea790dd0739d10bcaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/282313
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This way, if a SIGINT is sent to the go command,
it is forwarded on to the underlying tool.
Otherwise trying to use os.Process.Signal to kill
"go tool compile" only kills the "go tool" not the "compile".
Change-Id: Iac7cd4f06096469f5e76164df813a379c0da3822
Reviewed-on: https://go-review.googlesource.com/c/go/+/282312
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This package implements a parser for the new //go:build constraint lines.
The parser also handles // +build lines, to be able to process legacy files.
This will not be used in the standard library until Go 1.17,
but it seems worth publishing in Go 1.16 so that code that
needs to process both kinds of lines once Go 1.17 comes out
will be able to build using Go 1.16 as well.
For #41184. Design in https://golang.org/design/draft-gobuild.
Change-Id: I756c0de4081c5039e8b7397200e5274f223ab111
Reviewed-on: https://go-review.googlesource.com/c/go/+/240604
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Russ Cox <rsc@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
The testing.TestFS function assumes that the file system it's testing
doesn't change under it. Clarify this in the documentation and fix the
use of os.TestDirFS that's currently susceptible to this race.
Fixes#42637.
Change-Id: Ia7792380726177f8953d150ee87381b66cb01cb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/282452
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
This change modifies the *-by-size metrics' units to be based off the
bucket's unit (bytes) as opposed to the unit of the counts (objects).
This convention is more in-line with distributions in other metrics
systems.
Change-Id: Id3b68a09f52f0e1ff9f4346f613ae1cbd9f52f73
Reviewed-on: https://go-review.googlesource.com/c/go/+/282352
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
The documentation for Glob was copied from filepath.Glob, and needs a bit
of tweaking: paths are not rooted at slash; the separator is always '/'.
Fixes#43537
Change-Id: Id64daa137e2762b66a82a5b9e60bbe603f4e2f5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/282173
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Current optimization: When we copy a->b and then b->c, we might as well
copy a->c instead of b->c (then b might be dead and go away).
*Except* if a is a volatile location (might be clobbered by a call).
In that case, we really do want to copy a immediately, because there
might be a call before we can do the a->c copy.
User calls can't happen in between, because the rule matches up the
memory states. But calls inserted for memory barriers, particularly
runtime.typedmemmove, can.
(I guess we could introduce a register-calling-convention version
of runtime.typedmemmove, but that seems a bigger change than this one.)
Fixes#43570
Change-Id: Ifa518bb1a6f3a8dd46c352d4fd54ea9713b3eb1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/282492
Trust: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This change modifies the semantics of
runtime/metrics.Float64Histogram.Buckets to remove implicit buckets to
that extend to positive and negative infinity and instead defines all
bucket boundaries as explicitly listed.
Bucket boundaries remain the same as before except
/gc/heap/allocs-by-size:objects and /gc/heap/frees-by-size:objects no
longer have a bucket that extends to negative infinity.
This change simplifies the Float64Histogram API, making it both easier
to understand and easier to use.
Also, add a test for allocs-by-size and frees-by-size that checks them
against MemStats.
Fixes#43443.
Change-Id: I5620f15bd084562dadf288f733c4a8cace21910c
Reviewed-on: https://go-review.googlesource.com/c/go/+/281238
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
The findEmbed function looking for comment by readbyte,
however it might have constant or variables that contains
comment.
Maybe we should use ast parser in the future.
Fixes#43373
Change-Id: I92544384fc4c11363d8b2f6b9898c8dea1602767
Reviewed-on: https://go-review.googlesource.com/c/go/+/280332
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>