Olivier Mengué [Tue, 10 Oct 2023 20:54:39 +0000 (22:54 +0200)]
io/fs: add godoc links
Change-Id: Icde42bd33d58f75acdede439f7525f9d06554140
Reviewed-on: https://go-review.googlesource.com/c/go/+/534096 Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Change-Id: I087162f866e781258f9fbb96215c1ff6a5c315a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/507776
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
cui fliter [Tue, 10 Oct 2023 02:51:19 +0000 (10:51 +0800)]
maps: add examples for Clone,Copy and Equal
Change-Id: I72adaf48588e7d6cffbc0ee8005decda06808e84
Reviewed-on: https://go-review.googlesource.com/c/go/+/534055
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Olivier Mengué [Mon, 9 Oct 2023 21:56:48 +0000 (23:56 +0200)]
testing/fstest: add godoc links
Change-Id: I611f04f12bb93197fea5ae40a08e5f60426f1c00
Reviewed-on: https://go-review.googlesource.com/c/go/+/534076 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Olivier Mengué [Sun, 8 Oct 2023 15:51:00 +0000 (17:51 +0200)]
testing/fstest: MapFS: set perm 0555 on synthetized dirs
As MapFS ignores filemodes and always grant read and traverse access on
directories, let's make synthetized directory entries to expose filemode
0555 instead of 0000.
Fixes #63468.
Change-Id: I5d64a6bf2f2ac6082ca5dde55b3062669fb50b8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/534075 Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Austin Clements [Wed, 11 Oct 2023 16:20:19 +0000 (12:20 -0400)]
cmd/go: clean up "cover" debug output
Currently, the two places that run the cover tool manually construct a
terse command description. However, this actually prevents Builder.run
from constructing a more detailed description from the actual command
being run. Fix this by passing "" as the description to get the
default behavior.
Change-Id: I27d42cb1fda9bba70c631dc43417a03b8bddec92
Reviewed-on: https://go-review.googlesource.com/c/go/+/534157
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Cuong Manh Le [Wed, 11 Oct 2023 08:34:09 +0000 (15:34 +0700)]
types2, go/types: remove doc link from Func.Pkg comment
The documentation link only works with exported identifiers. Further,
the built-in error interface lives in pseudo package "builtin" only,
thus it's not a real package that can be referred using doc links.
Change-Id: I2116beb27fc73ba33f8352301fe77b4b6abc3ec1
Reviewed-on: https://go-review.googlesource.com/c/go/+/534436 Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Alan Donovan <adonovan@google.com>
Joel Sing [Fri, 10 Sep 2021 16:03:10 +0000 (02:03 +1000)]
cmd/link/internal/ld: assign temporary addresses to per-package text
If trampolines may be required, the current text addressing second
pass resets all assigned addresses, before assigning addresses and
laying down trampolines in a linear fashion. However, this approach
means that intra-package calls are to a symbol that has not yet
been assigned an address, when the symbol is ahead of the current
function.
In the case of RISC-V the JAL instruction is limited to +/-1MiB.
As such, if a call is to a symbol with no address currently assigned,
we have to assume that a trampoline will be required. During the
relocation phase we can fix up and avoid trampolines in some cases,
however this results in unused trampolines that are still present
in the binary (since removing them would change text addresses).
In order to significantly reduce the number of unused trampolines,
assign temporary addresses to functions within the same package,
based on the maximum number of trampolines that may be required by
a function. This allows for better decisions to be made regarding
the requirement for intra-package trampolines, as we reset the
addressing for a function, assign its final address and lay down
any resulting trampolines.
This results in ~2,300 unused trampolines being removed from the
Go binary and ~5,600 unused trampolines being removed from the
compile binary, on linux/riscv64.
Change-Id: I8a9cf035dea82e1e1e66ae5b1093dce78e4ff0d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/349650
Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Jes Cok [Mon, 9 Oct 2023 16:41:24 +0000 (16:41 +0000)]
runtime: fix some comments
Change-Id: I06403cf217a4d2645e13115e7ca358b7f3d3f2ef
GitHub-Last-Rev: e2b4e5326a6c68d066b637c6add86723e0cefd3b
GitHub-Pull-Request: golang/go#63474
Reviewed-on: https://go-review.googlesource.com/c/go/+/533875
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Ville Skyttä [Mon, 9 Oct 2023 21:03:10 +0000 (21:03 +0000)]
testing: remove unnecessary TempDir implementation detail from its doc
The "by Cleanup" detail about the removal mechanism is not necessary for
users. The previous wording could even cause confusion whether they
should do something for Cleanup to occur.
Change-Id: I617a7a4e118a70a3ad8a83a2d81cd911dde8ee08
GitHub-Last-Rev: fba4cde6362d1f0ea0c730d50fdd3fbaae4e17cf
GitHub-Pull-Request: golang/go#63479
Reviewed-on: https://go-review.googlesource.com/c/go/+/534016
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Jes Cok [Sun, 8 Oct 2023 15:52:43 +0000 (15:52 +0000)]
go/token: use "// Output:" instead of "//Output:" in examples
Change-Id: I86eb365650749bb4f41e9ae62123674581dffe2b
GitHub-Last-Rev: 7a9d6800ab3f2c8e6c738d36c2f882486ce2703a
GitHub-Pull-Request: golang/go#63449
Reviewed-on: https://go-review.googlesource.com/c/go/+/533120
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Change-Id: Id3d92534942d3eb0bdc1d01359324030ad0e434f
Reviewed-on: https://go-review.googlesource.com/c/go/+/533635
Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
cui fliter [Sun, 8 Oct 2023 08:42:26 +0000 (16:42 +0800)]
bytes,strings: add example for ContainsFunc
Change-Id: I340e892aa4ecc780905be984016efc86699a45a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/533556
Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Carlo Alberto Ferraris [Thu, 7 Sep 2023 23:21:58 +0000 (08:21 +0900)]
io: add (*SectionReader).Outer()
Fixes #61870
Updates #61727
Change-Id: Iaef9b59c402d68f6bf64be212db2b6746abe8900
Reviewed-on: https://go-review.googlesource.com/c/go/+/526855 Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Jes Cok [Sat, 7 Oct 2023 16:18:16 +0000 (16:18 +0000)]
reflect: compute the median h uniformly
Like sort.Search, use "h := int(uint(i+j) >> 1)" to compute the median h.
Change-Id: I62c1e67533657e2b56af872676e5dc4ed4d49c55
GitHub-Last-Rev: cbfba7ee9ab0a0bda371db3ad5e8cc4d5ea91579
GitHub-Pull-Request: golang/go#63439
Reviewed-on: https://go-review.googlesource.com/c/go/+/533595 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Austin Clements [Thu, 24 Aug 2023 20:48:14 +0000 (16:48 -0400)]
cmd/go: remove unnecessary b.Print setting
The Builder returned by work.NewBuilder is already setup to print to
os.Stderr, so it's not necessary for runRun to set b.Print to a
different function that does exactly the same thing.
This b.Print assignment was introduced in CL 5591045. At the time, the
builder type defaulted to printing to os.Stdout, so this was necessary
to make "go run" print build errors to stderr.
crypto/aes,crypto/cipher: improve gcm performance on ppc64x
This improves performance for AES-GCM. The function
counterCrypt is written in assembler so the loop can
be unrolled and the stitched approach used for the
encryption.
Cuong Manh Le [Thu, 5 Oct 2023 04:11:51 +0000 (11:11 +0700)]
cmd/compile: fix typecheck range over negative integer
Before range over integer, types2 leaves constant expression in RHS of
non-constant shift untyped, so idealType do the validation to ensure
that constant value must be an int >= 0.
With range over int, the range expression can also be left untyped, and
can be an negative integer, causing the validation false.
Fixing this by relaxing the validation in idealType, and moving the
check to Unified IR reader.
Fixes #63378
Change-Id: I43042536c09afd98d52c5981adff5dbc5e7d882a
Reviewed-on: https://go-review.googlesource.com/c/go/+/532835
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
Alan Donovan [Mon, 9 Oct 2023 17:31:25 +0000 (13:31 -0400)]
go/types: clarify semantics of Selection
This is one of the more complex areas of the (pre-generics)
spec, and I'm probably not the only person who can never
remember all the details each time I need them.
Change-Id: I25b3c46311df4db33357af5601c5e3586327dac2
Reviewed-on: https://go-review.googlesource.com/c/go/+/533736 Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Keith Randall [Sun, 1 Oct 2023 17:02:39 +0000 (10:02 -0700)]
cmd/compile: use internal/abi types in the compiler
It is tricky to use those types directly, because the layout of those
types in the compiler may not be the same as the layout of those
types in target binary (typically because of 32 vs 64 bit differences).
Instead, translate an internal/abi type into a cmd/compile/internal/types
type, which will then be laid out for the target machine.
Along with the translation, keep track of where all the bits of the
type are so we can reference their locations symbolically instead of
hardcoding them.
Change-Id: I2694c58968d4dc7ead63a2b1b29adfedd90ddd2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/532155 Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@google.com>
Cuong Manh Le [Sat, 7 Oct 2023 15:54:50 +0000 (22:54 +0700)]
cmd/compile: fix ICE with parenthesized builtin calls
CL 419456 starts using lookupObj to find types2.Object associated with
builtin functions. However, the new code does not un-parenthesized the
callee expression, causing an ICE because of nil obj returned.
Un-parenthesizing the callee expression fixes the problem.
Fixes #63436
Change-Id: Iebb4fbc08575e7d0b1dbd026c98e8f949ca16460
Reviewed-on: https://go-review.googlesource.com/c/go/+/533476
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Joel Sing [Fri, 6 Oct 2023 05:45:12 +0000 (16:45 +1100)]
cmd/compile/internal: stop lowering OpConvert on riscv64
Lowering for OpConvert was removed for all architectures in CL#108496,
prior to the riscv64 port being upstreamed. Remove lowering of OpConvert
on riscv64, which brings it inline with all other architectures. This
results in 1,600+ instructions being removed from the riscv64 go binary.
Change-Id: Iaaf1f8b397875926604048b66ad8ac91a98c871e
Reviewed-on: https://go-review.googlesource.com/c/go/+/533335
Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
Mark Ryan [Sun, 17 Sep 2023 11:08:55 +0000 (13:08 +0200)]
cmd/compile: optimize right shifts of uint32 on riscv
The compiler is currently zero extending 32 bit unsigned integers to
64 bits before right shifting them using a 64 bit shift instruction.
There's no need to do this as RISC-V has instructions for right
shifting 32 bit unsigned values (srlw and srliw) which zero extend
the result of the shift to 64 bits. Change the compiler so that
it uses srlw and srliw for 32 bit unsigned shifts reducing in most
cases the number of instructions needed to perform the shift.
Here are some examples of code sequences that are changed by this
patch:
srlw x5,x10,x11
sltiu x6,x11,32
neg x6,x6
and x10,x5,x6
bits.RotateLeft32(uint32(a), 1)
before:
sll x5,x10,0x1
sll x6,x10,0x20
srl x7,x6,0x3f
or x5,x5,x7
after:
sll x5,x10,0x1
srlw x6,x10,0x1f
or x10,x5,x6
bits.RotateLeft32(uint32(a), int(b))
before:
and x6,x11,31
sll x7,x10,x6
sll x8,x10,0x20
srl x8,x8,0x20
add x6,x6,-32
neg x6,x6
srl x9,x8,x6
sltiu x6,x6,64
neg x6,x6
and x6,x9,x6
or x6,x6,x7
after:
and x5,x11,31
sll x6,x10,x5
add x5,x5,-32
neg x5,x5
srlw x7,x10,x5
sltiu x5,x5,32
neg x5,x5
and x5,x7,x5
or x10,x6,x5
The one regression observed is the following case, an unbounded right
shift of a uint32 where the value we're shifting by is known to be
< 64 but > 31. As this is an unusual case this commit does not
optimize for it, although the existing code does.
uint32(a) >> (b & 63)
before:
sll x5,x10,0x20
srl x5,x5,0x20
and x6,x11,63
srl x10,x5,x6
after
and x5,x11,63
srlw x6,x10,x5
sltiu x5,x5,32
neg x5,x5
and x10,x6,x5
Here we have one extra instruction.
Some benchmark highlights, generated on a VisionFive2 8GB running
Ubuntu 23.04.
Change-Id: I20483a6668cca1b53fe83944bee3706aadcf8693
Reviewed-on: https://go-review.googlesource.com/c/go/+/528975 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Dmitri Shuralyov [Mon, 2 Oct 2023 13:38:24 +0000 (09:38 -0400)]
cmd/dist: emphasize when all tests are excluded
As observed in https://go.dev/issue/61666#issuecomment-1739476954,
if a -run flag value matches no tests, dist test output doesn't do much
to help users notice that was what happened. It is valid and sometimes
intended¹ to match no tests, so I want to reserve failed status with
exit code 1 to the actionable outcome where at least 1 test failed.
But it seems reasonable to extend the existing "some were excluded"
mechanism of reporting partial testing to be more helpful.
In non-JSON mode, which is more likely to be used manually by humans,
print a special² last line that will hopefully be easier to notice when
matching no tests wasn't intended. Change nothing for -json mode since
that's likely used by machines and they can make sense of 0 JSON events.
The go test command already has this behavior, so this brings dist test
closer³ to it. (Slightly unfortunate duplicate maintenance for us, and
the need for the rare dist test users to learn its CLI quirks; oh well.)
¹ It might seem counter-intuitive at first: what's the point of calling
dist test and asking it to run no tests? One possible answer is that
it permits writing code capable of running N intended tests, where N
is 0 or higher. That is, it allows for 0 to not be a special case that
the caller would have no choice but handle differently.
² I initially considered making it say something like "N of M tests were
excluded", but decided to leave it alone since the current coordinator
code still has that text hardcoded and I don't want to break it. Hence
the new status that I expect only humans will see. And it seems better
this way anyway.
³ In particular, the "matched no tests" and "no tests to run" phrases
were selected precisely because they're already used in cmd/go output.
Change-Id: I6768d9932587195ae6dbc6e2c4742479e265733b
Reviewed-on: https://go-review.googlesource.com/c/go/+/532115 Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
crypto/subtle: improve xorBytes assembler on PPC64
This makes some improvements to the xorBytes assembler
implementation for PPC64 targets.
The loops to process large streams of bytes has been changed to
do 64 bytes at a time. Other changes were made to prevent
degradations in some of the common sizes like 8, 16.
The case for < 8 bytes on power10 has been modified to use
the LXVL and STXVL instructions.
mstmdev [Fri, 6 Oct 2023 19:00:52 +0000 (19:00 +0000)]
sync: use atomic.Uint32 in Once
Change-Id: If9089f8afd78de3e62cd575f642ff96ab69e2099
GitHub-Last-Rev: 14165018d67e84685dcf84be0320623ccb3afc0e
GitHub-Pull-Request: golang/go#63386
Reviewed-on: https://go-review.googlesource.com/c/go/+/532895
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Achille Roussel [Wed, 4 Oct 2023 04:58:03 +0000 (04:58 +0000)]
internal/bytealg: process two AVX2 lanes per Count loop
The branch taken by the bytealg.Count algorithm used to process a single
32 bytes block per loop iteration. Throughput of the algorithm can be
improved by unrolling two iterations per loop: the lack of data
dependencies between each iteration allows for better utilization of the
CPU pipeline. The improvement is most significant on medium size payloads
that fit in the L1 cache; beyond the L1 cache size, memory bandwidth is
likely the bottleneck and the change does not show any measurable
improvements.
Change-Id: I1098228c726a2ee814806dcb438b7e92febf4370
Reviewed-on: https://go-review.googlesource.com/c/go/+/532457 Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Alexander Yastrebov [Thu, 5 Oct 2023 21:55:06 +0000 (21:55 +0000)]
encoding/json: fix appendCompact escaping
CL 469555 changed Compact to use append instead of bytes.Buffer.
appendCompact iterates over input src slice and performs escaping
of certain characters.
To optimize copying it does not copy characters one by one
but keeps track of the start offset of the data to copy when
it reaches next character to escape or the end of the input.
This start offset may become greater than input character offset
so copying of preceding data should check this condition.
CL 469555 removed boundary checks for copying data preceding
escaped characters and this change restores them.
Fixes https://github.com/golang/go/issues/63379
Change-Id: I5b7856239f256c67faf58834705675c0aea08cc2
GitHub-Last-Rev: 661576fb54951a05a8399beb3f9ac2a2f9a340b4
GitHub-Pull-Request: golang/go#63400
Reviewed-on: https://go-review.googlesource.com/c/go/+/533275
Run-TryBot: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Keith Randall [Mon, 11 Sep 2023 21:39:06 +0000 (14:39 -0700)]
cmd/compile: pass only the itab to the assertI2I-style functions
It is currently slightly better to pass the whole interface to these
functions, so that we don't need to spill/restore the data word across
the function call.
I'm adding a cache in front of these calls, which means we'll no longer
need a spill/restore in the common case, so it is better to just pass
the itab word.
It also makes unifying the logic between I2I and I2I2 versions easier.
Change-Id: I3c3e9fbb1e54890482840d76a1df79f4325bb5bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/528075 Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Keith Randall [Wed, 6 Sep 2023 20:59:35 +0000 (13:59 -0700)]
cmd/compile: add a cache to interface type switches
That way we don't need to call into the runtime when the type being
switched on has been seen many times before.
The cache is just a hash table of a sample of all the concrete types
that have been switched on at that source location. We record the
matching case number and the resulting itab for each concrete input
type.
The caches seldom get large. The only two in a run of all.bash that
get more than 100 entries, even with the sampling rate set to 1, are
test/fixedbugs/issue29264.go, with 101
test/fixedbugs/issue29312.go, with 254
Both happen at the type switch in fmt.(*pp).handleMethods, perhaps
unsurprisingly.
name old time/op new time/op delta
SwitchInterfaceTypePredictable-24 25.8ns ± 2% 2.5ns ± 3% -90.43% (p=0.000 n=10+10)
SwitchInterfaceTypeUnpredictable-24 37.5ns ± 2% 11.2ns ± 1% -70.02% (p=0.000 n=10+10)
Change-Id: I4961ac9547b7f15b03be6f55cdcb972d176955eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/526658 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@google.com>
Cuong Manh Le [Tue, 3 Oct 2023 15:51:03 +0000 (22:51 +0700)]
cmd/compile: some cleanup with old irgen code
- Un-export Convertop: it's only used by tcConv.
- Remove AssignOp1: introduced in CL 349614, only used by irgen.
- Un-export Assignop: it was exported to be used by irgen only.
Change-Id: I7e78b35d90f165c537cf32a104156bf2a13ca8b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/532516 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Cuong Manh Le [Tue, 3 Oct 2023 14:54:48 +0000 (21:54 +0700)]
cmd/compile: do not fatal when typechecking conversion expression
The types2 typechecker already reported all invalid conversions required
by the Go language spec. However, the conversion involves go pragma is
not specified in the spec, so is not checked by types2.
Fixing this by handling the error gracefully during typecheck, just like
how old typechecker did before CL 394575.
Fixes #63333
Change-Id: I04c4121971c62d96f75ded1794ab4bdf3a6cd0ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/532515
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Matthew Dempsky [Wed, 4 Oct 2023 22:22:49 +0000 (15:22 -0700)]
cmd/compile/internal/ir: tweak a couple names
CallExpr.X -> CallExpr.Fun
This consistent with go/ast and cmd/compile/internal/syntax.
OPRINTN -> OPRINTLN
This op represents the "println" builtin; might as well spell it the
same way.
Change-Id: Iead1b007776658c717879cf0997b3c48028428f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/532795 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Paul E. Murphy [Tue, 19 Sep 2023 22:01:28 +0000 (17:01 -0500)]
cmd/internal/obj/ppc64: generate MOVD mask constants in register
Add a new form of RLDC which maps directly to the ISA definition
of rldc: RLDC Rs, $sh, $mb, Ra. This is used to generate mask
constants described below.
Using MOVD $-1, Rx; RLDC Rx, $sh, $mb, Rx, any mask constant
can be generated. A mask is a contiguous series of 1 bits, which
may wrap.
Change-Id: Ifcaae1114080ad58b5fdaa3e5fc9019e2051f282
Reviewed-on: https://go-review.googlesource.com/c/go/+/531120 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Roland Shoemaker [Wed, 4 Oct 2023 13:18:08 +0000 (06:18 -0700)]
html/template: only track brace depth when we are in a JS tmpl lit
The change that keeps on giving. Only track brace depth in tJS if we are
already inside of a template literal. If we start tracking depth outside
of nested literals it can cause the parser to think we're still in a JS
context when we've actually closed the string interp.
I believe this _mostly_ captures the expected parsing, but since the
JS parser does not implement proper lexical goal symbols, it may not
be entirely accurate. At some point in the future we may be able to
significantly reduce the complexity of this implementation by
implementing a lexical parser that more closely follows the ECMAScript
specification, and structuring escaping rules based on which symbol an
action appears in. This would also allow us to catch errors, which
we currently cannot reasonable do (although perhaps this is beyond the
scope of what html/template _should_ be doing).
Updates #61619
Change-Id: I56e1dbc0d0705ef8fb7a5454ebe2421d4e162ef6
Reviewed-on: https://go-review.googlesource.com/c/go/+/532595
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
runtime: support SetUnhandledExceptionFilter on Windows
The Windows unhandled exception mechanism fails to call the callback
set in SetUnhandledExceptionFilter if the stack can't be correctly
unwound.
Some cgo glue code was not properly chaining the frame pointer, making
the stack unwind to fail in case of an exception inside a cgo call.
This CL fix that and adds a test case to avoid regressions.
Paul E. Murphy [Mon, 18 Sep 2023 22:14:03 +0000 (17:14 -0500)]
cmd/internal/obj/ppc64: generate small, shifted constants in register
Check for shifted 16b constants, and transform them to avoid the load
penalty. This should be much faster than loading, and reduce binary
size by reducing the constant pool size.
Change-Id: I6834e08be7ca88e3b77449d226d08d199db84299
Reviewed-on: https://go-review.googlesource.com/c/go/+/531119
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Than McIntosh [Wed, 4 Oct 2023 13:29:48 +0000 (09:29 -0400)]
cmd/go: fix objdir for run actions for -cover no-test packages
As of CL 495447 we now synthesize coverage data (including coverage
profiles) for packages that have no tests, if they are included in a
"go test -cover" run. The code that set up the "run" actions for such
tests wasn't setting the objdir for the action, which meant that the
coverage profile temp file fragment ("_cover_.out") was being created
in the dir where the test was run, and in addition the same fragment
could be written to by more than one package (which could lead to a
corrupted file). This CL updates the code to properly set the objdir,
and to create the dir when needed.
edef [Sat, 3 Dec 2022 00:09:22 +0000 (00:09 +0000)]
net/http/cgi: set SERVER_PORT to 443 when req.TLS != nil
A hostname without a port leaves the port implied by the protocol.
For HTTPS, the implied port is 443, not 80.
Change-Id: I873a076068f84c8041abf10a435d9499635730a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/454975
Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Cherry Mui [Wed, 4 Oct 2023 14:21:39 +0000 (10:21 -0400)]
runtime: unlock OS thread after cgocallbackg1
For cgo callbacks, currently cgocallbackg locks the OS thread and
then call cgocallbackg1, which invokes the actual callback, and
then unlocks the OS thread in a deferred call. cgocallback then
continues assuming we are on the same M. This assumes there is no
preemption point between the deferred unlockOSThread and returning
to the caller (cgocallbackg). But this is not always true. E.g.
when open defer is not used (e.g. PIE or shared build mode on 386),
there is a preemption point in deferreturn after invoking the
deferred function (when it checks whether there are still defers
to run).
Instead of relying on and requiring the defer implementation has
no preemption point, we move the unlockOSThread to the caller, and
ensuring no preemption by setting incgo to true before unlocking.
This doesn't cover the panicking path, so we also adds an
unlockOSThread there. There we don't need to worry about preemption,
because we're panicking out of the callback and we have unwound the
g0 stack, instead of reentering cgo.
Fixes #62102.
Change-Id: I0e0b9f9091be88d01675c0acb7339b81402545be
Reviewed-on: https://go-review.googlesource.com/c/go/+/532615
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Alan Donovan [Wed, 4 Oct 2023 14:26:17 +0000 (10:26 -0400)]
go/printer: parenthesize type in <-((<-chan int)(nil))
When printing synthetic syntax (not created by the parser),
the tree for <-((<-chan int)(nil)) without any ParenExpr nodes
was misprinted so that it was parsed back as a receive of
a receive. This changes emits parens around the channel type.
Fixes #63362
Change-Id: I2041ced224f0bca001cee5d37f7a127265d21020
Reviewed-on: https://go-review.googlesource.com/c/go/+/532556
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
David Chase [Tue, 3 Oct 2023 16:14:53 +0000 (12:14 -0400)]
cmd/compile: adjust GOSSAFUNC html dumping to be more ABI-aware
Uses ,ABI instead of <ABI> because of problems with shell escaping
and windows file names, however if someone goes to all the trouble
of escaping the linker syntax and uses that instead, that works too.
Examples:
```
GOSSAFUNC=runtime.exitsyscall go build main.go
\# runtime
dumped SSA for exitsyscall,0 to ../../src/loopvar/ssa.html
dumped SSA for exitsyscall,1 to ../../src/loopvar/ssa.html
GOSSADIR=`pwd` GOSSAFUNC=runtime.exitsyscall go build main.go
\# runtime
dumped SSA for exitsyscall,0 to ../../src/loopvar/runtime.exitsyscall,0.html
dumped SSA for exitsyscall,1 to ../../src/loopvar/runtime.exitsyscall,1.html
GOSSAFUNC=runtime.exitsyscall,0 go build main.go
\# runtime
dumped SSA for exitsyscall,0 to ../../src/loopvar/ssa.html
GOSSAFUNC=runtime.exitsyscall\<1\> go build main.go
\# runtime
dumped SSA for exitsyscall,1 to ../../src/loopvar/ssa.html
```
Change-Id: Ia1138b61c797d0de49dbfae702dc306b9650a7f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/532475
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: David Chase <drchase@google.com>
Joel Sing [Thu, 10 Aug 2023 15:51:53 +0000 (01:51 +1000)]
cmd/go/testdata/mod: add golang toolchain test data for openbsd/riscv64
Updates #55999
Change-Id: I65e3bfb08ed2dd1602531902c7df8232e5151aa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/518628 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Aaron Bieber <deftly@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Joel Sing [Sat, 17 Sep 2022 16:35:40 +0000 (02:35 +1000)]
syscall: add syscall support for openbsd/riscv64 port
Updates #55999
Change-Id: I5b8452207e951e543b9be42ebcb7d62c0c023f08
Reviewed-on: https://go-review.googlesource.com/c/go/+/518627 Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Aaron Bieber <deftly@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Joel Sing [Sat, 17 Sep 2022 16:35:00 +0000 (02:35 +1000)]
runtime: add runtime support for openbsd/riscv64 port
Updates #55999
Change-Id: I0e80f80d49696a00d979f85230d482e24d4c2d7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/518626
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Aaron Bieber <deftly@gmail.com>
Tobias Klauser [Tue, 3 Oct 2023 20:19:42 +0000 (22:19 +0200)]
time: fix Time godoc
The additional empty line was inadvertently introduced by CL 526676,
causing only part of the Time godoc to be rendered on pkg.go.dev.
Change-Id: I868315752eb160ebaab227c8b5369054c557cb7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/531877 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Robert Griesemer [Mon, 2 Oct 2023 22:47:08 +0000 (15:47 -0700)]
go/types, types2: don't implicitly modify an argument function's type
See the comment in the (very small) fix for a detailed description.
Use the opportunity to introduce a generic clone function which may
be useful elsewhere.
Fixes #63260.
Change-Id: Ic63c6b8bc443011b1a201908254f7d062e1aec71
Reviewed-on: https://go-review.googlesource.com/c/go/+/532157
Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
cui fliter [Fri, 26 May 2023 04:02:54 +0000 (12:02 +0800)]
cmd: add a new analyzer for check missing values after append
If there is no second parameter added during append, there will be no prompt when executing go vet. Add an analyzer to detect this situation
Update #60448
Change-Id: If9848835424f310c54e3e9377aaaad4a1516871a
Reviewed-on: https://go-review.googlesource.com/c/go/+/498416
Run-TryBot: shuang cui <imcusg@gmail.com>
Run-TryBot: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Tim King <taking@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
Paul E. Murphy [Tue, 12 Sep 2023 21:06:45 +0000 (16:06 -0500)]
cmd/internal/asm/ppc64: support 34b ADD/MOVD $const, Rx
For constant signed values which require 34b to represent,
the assembler will generate a pli instruction on
linux/power10/PPC64 instead of loading a constant.
Similarly, ADD is extended to support 34b signed constants.
On linux/power10/PPC64, this generates a paddi instruction.
For assembler consistency, a second form is added if paddi
cannot be used. The second form is provided for assembly
writers.
Change-Id: I98144306af766b02fbbe36b72856a23cdf51d247
Reviewed-on: https://go-review.googlesource.com/c/go/+/528317
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Eli Bendersky <eliben@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
qiulaidongfeng [Tue, 3 Oct 2023 14:22:16 +0000 (14:22 +0000)]
regexp/syntax: use min func
Change-Id: I679c906057577d4a795c07a2f572b969c3ee14d5
GitHub-Last-Rev: fba371d2d6bfc7fbf3a93a53bb22039acf65d7cf
GitHub-Pull-Request: golang/go#63350
Reviewed-on: https://go-review.googlesource.com/c/go/+/532218
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
cmd/compile/internal: intrinsify publicationBarrier on riscv64
This enables publicationBarrier to be used as an intrinsic
on riscv64, optimizing the required function call and return
instructions for invoking the "runtime.publicationBarrier"
function.
This function is called by mallocgc. The benchmark results for malloc tested on Lichee-Pi-4A(TH1520, RISC-V 2.0G C910 x4) are as follows.
Change-Id: Ieab6c02309614bac5c1b12b5ee3311f988ff644d
Reviewed-on: https://go-review.googlesource.com/c/go/+/531719 Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: M Zhuo <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joel Sing <joel@sing.id.au>
Change-Id: Ib6a0e1e1583e45e3d239455e8b131c81602b2d5d
GitHub-Last-Rev: dc82635562a7fb4488f374d7a9ed26b29310e918
GitHub-Pull-Request: golang/go#63200
Reviewed-on: https://go-review.googlesource.com/c/go/+/530875 Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Joel Sing [Sat, 17 Sep 2022 16:36:20 +0000 (02:36 +1000)]
cmd/link: enable linking on openbsd/riscv64
Updates #55999
Change-Id: I6e48e6649e19a9b2d776745c05eefb3995b6dd00
Reviewed-on: https://go-review.googlesource.com/c/go/+/518625 Reviewed-by: Aaron Bieber <deftly@gmail.com>
Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Ian Lance Taylor [Mon, 2 Oct 2023 23:26:27 +0000 (16:26 -0700)]
syscall: return pointer from test function OrigRlimitNofile
Change-Id: I8740a2a7ebb3045d8daa97bcb0da7f31f6f7b881
Reviewed-on: https://go-review.googlesource.com/c/go/+/531996
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
time: clarify docs to avoid date calculation pitfalls
I recently reviewed some code that did time calculations using
`time.UnixMicro(0).UTC()`. I commented that because time calculations
are independent of the location, they should drop the `.UTC()`, and they
replied that it made their tests fail.
I looked into it and eventually discovered it was because they were
using AddDate. Dramatically simplified, their code did something like:
got := epoch.AddDate(0, 0, days)
if !got.Equal(want) {
t.Errorf("ay caramba: %v vs %v", got.UTC(), want.UTC())
}
The issue is that their tests run in Pacific time, which is currently
PST (UTC-8) but was PDT (UTC-7) in January 1970.
It turns out they were implementing some business policy that really
cares abut calendar days so AddDate is correct, but it's certainly a bit
confusing!
The idea with this change is to remove the risk that readers make a
false shortcut in their mind: "Locations do not affect time
calculations". To do this we remove some text from the core time.Time
doc and shift it to the areas of the library that deal with these
intrinsically confusing operations.
Change-Id: I8200e9edef7d1cdd8516719e34814eb4b78d30a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/526676 Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
cui fliter [Mon, 2 Oct 2023 07:09:26 +0000 (15:09 +0800)]
cmd: fix mismatched symbols
Change-Id: I6365cdf22ad5e669908519d0ee8b78d76ae8f1b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/532075 Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Daniel Martí [Sat, 30 Sep 2023 08:57:36 +0000 (09:57 +0100)]
make.bash: use [[ rather than [
[[ is a compound command part of the language with structure,
whereas [ is simply a standard program with string arguments.
The former has a few significant advantages over the latter:
* Better syntax, e.g. && and || rather than -a and -o,
as well as == rather than = for comparisons
* No need for fork+exec to evaluate each conditional
* Forgetting the closing token is an early parse error
The only advantage of [ over [[ is that [[ is Bash syntax,
whereas [ and "test" are portable POSIX Shell utilities.
However, this is a Bash script, so that is not a concern.
Change-Id: I8a4bdd16845bd67bf67a348d7d96d45d5b131d85
Reviewed-on: https://go-review.googlesource.com/c/go/+/531875 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Michael Pratt [Mon, 2 Oct 2023 19:55:29 +0000 (15:55 -0400)]
syscall: copy original rlimit before modifying
CL 531516 converted origRlimitNofile from an atomic.Value to
atomic.Pointer[Rlimit]. i.e., it changed from storing a value to storing
a pointer.
After storing a pointer to lim, the remainder of this function
immediately modifies it, thus mutating the value pointer to by
origRlimitNofile (and thus defeating the point of origRlimitNofile).
This broke the android-amd64-emu builder because it is (apparently) the
only builder where the original RLIMIT_NOFILE Cur != Max.
TestRlimitRestored is skipped on every other builder.
Change-Id: I12076350eeddfd221823ad651e7e7eca59d2bdcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/532100
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Roland Shoemaker [Wed, 5 Jul 2023 18:56:03 +0000 (11:56 -0700)]
html/template: support parsing complex JS template literals
This change undoes the restrictions added in CL 482079, which added a
blanket ban on using actions within JS template literal strings, and
adds logic to support actions while properly applies contextual escaping
based on the correct context within the literal.
Since template literals can contain both normal strings, and nested JS
contexts, logic is required to properly track those context switches
during parsing.
ErrJsTmplLit is deprecated, and the GODEBUG flag jstmpllitinterp no
longer does anything.
Fixes #61619
Change-Id: I0338cc6f663723267b8f7aaacc55aa28f60906f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/507995
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Roland Shoemaker <roland@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
Jonathan Amsterdam [Wed, 20 Sep 2023 19:45:08 +0000 (15:45 -0400)]
log/slog: JSONHandler elides empty groups even with replacement
Previously, the built-in handlers assumed a group was empty if and
only if it had no attributes. But a ReplaceAttr function that
returned an empty Attr could produce an empty group even if the group
had attrs prior to replacement.
The obvious solution, doing the replacement first and then checking,
would require allocating storage to hold the replaced Attrs. Instead,
we write to the buffer, and if no attributes were written, we back up
to before the group name.
Fixes #62512.
Change-Id: I140e0901f4b157e36594d8d476f1ab326f8f2c2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/529855
Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Than McIntosh [Thu, 7 Sep 2023 15:06:35 +0000 (11:06 -0400)]
internal,cmd/internal: relocate covcmd package from std to cmd
Relocate the 'covcmd' package from .../internal/coverage to
.../cmd/internal/cov, to reflect the fact that the definitions in this
package are used only in cmd, not in std.
Than McIntosh [Tue, 16 May 2023 17:31:11 +0000 (13:31 -0400)]
cmd/go: fix percent covered problems with -coverpkg
This patch fixes some problems with how "go test -cover" was handling
tests involving A) multiple package tests and B) multiple packages
matched by "-coverpkg". In such scenarios the expectation is that the
percent statements covered metric for each package needs to be
relative to all statements in all packages matched by the -coverpkg
arg (this aspect of the reporting here was broken as part of
GOEXPERIMENT=coverageredesign).
The new scheme works as follows. If -coverpkg is in effect and is
matching multiple packages, and we have multiple test targets, then:
- each time a package is built for coverage, capture a meta-data
file fragment corresponding to just the meta-data for that package.
- create a new "writeCoverMeta" action, and interpose it between the
build actions for the covered packages and the run actions. The
"writeCoverMeta" action at runtime will emit a file
"metafiles.txt" containing a table mapping each covered package
(by import path) to its corresponding meta-data file fragment.
- pass in the "metafiles.txt" file to each run action, so that
when the test finishes running it will have an accurate picture
of _all_ covered packages, permitting it to calculate the correct
percentage.
Concrete example: suppose we have a top level directory with three
package subdirs, "a", "b", and "c", and from the top level, a user
runs "go test -coverpkg=./... ./...". This will result in (roughly)
the following action graph:
A note on init functions: prior to GOEXPERIMENT=coverageredesign
the "-coverpkg=..." flag was implemented by force-importing
all packages matched by "-coverpkg" into each instrumented package.
This meant that for the example above, when executing "a.test",
the init function for package "c" would fire even if package "a"
did not ordinarily import package "c". The new implementation
does not do this sort of forced importing, meaning that the coverage
percentages can be slightly different between 1.21 and 1.19 if
there are user-written init funcs.
Than McIntosh [Tue, 9 May 2023 19:40:41 +0000 (15:40 -0400)]
cmd/go: improve handling of no-test packages for coverage
This patch improves the way the go command handles coverage testing
of packages that have functions but don't have any test files. Up to
this point if you ran "go test -cover" on such a package, you would
see:
? mymod/mypack [no test files]
While "no test files" is true, it is also very unhelpful; if the
package contains functions, it would be better instead to capture the
fact that these functions are not executed when "go test -cover" is
run on the package.
With this patch, for the same no-test package "go test -cover" will
output:
mymod/mypack coverage: 0.0% of statements
The inclusion of such packages in coverage reporting also extends to
"-coverprofile" as well (we'll see entries for the "mypack" functions
in this case.
Note that if a package has no functions at all, then we'll still fall
back to reporting "no test files" in this case; it doesn't make sense
to report "0.0% statements covered" if there are no statements.