1
0
mirror of https://github.com/golang/go synced 2024-11-06 13:36:12 -07:00
Commit Graph

45013 Commits

Author SHA1 Message Date
Robert Griesemer
70668a4144 go/types, types2: don't panic with invalid recursive generic type
Add cycle detection to hasVarType to avoid infinite recursions
caused by invalid cyclic types. This catches cases where the
validType check has not yet run or has checked differently
instantiated types.

As an alternative, validType could mark invalid *Named types
by setting their underlying types to Typ[Invalid]. That does
work but discards information which leads to undesired effects
with other errors. A better mechanism might be to explicitly
track in *Named if a type is invalid and why it is invalid,
and connect that with a general validity attribute on types.
That's a more invasive change we might consider down the road.

Fixes #52915.

Change-Id: I9e798b348f4a88b1655e1ff422bd50aaefd9dc50
Reviewed-on: https://go-review.googlesource.com/c/go/+/406849
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-05-24 17:02:34 +00:00
Robert Griesemer
eb3ac1f5a4 cmd/compile/internal/types2: mention go.mod file when using undeclared any
Use the existing versionErrorf mechanism to report use of undeclared
any and comparable.

Also, port versionErrorf mechanism to go/types and use it in this
case as well.

Adjust tests as needed.

For #52880.

Change-Id: I6a646f16a849692ee0cb57e362d5f3d77e2c25f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/407896
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-05-24 16:05:16 +00:00
Guoqi Chen
61fc5df689 runtime: add missing {TOPFRAME,NOFRAME} flag for linux/loong64
Co-authored-by: limeidan <limeidan@loongson.cn>
Change-Id: I0011a10f831e6c2b0da96265682212b0747f0e2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/407774
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-05-24 03:54:13 +00:00
Guoqi Chen
654b03167f cmd/internal/obj: add FuncInfo SPWRITE flag for linux/loong64
Co-authored-by: limeidan <limeidan@loongson.cn>
Change-Id: Iac4f706fc9ff1047f1fa02f7178ebfbe38ad1ec3
Reviewed-on: https://go-review.googlesource.com/c/go/+/407754
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-24 01:08:23 +00:00
Cuong Manh Le
a2bca290e7 cmd/compile: fix loong64 constant folding in division rules
The divisor must be non-zero for the rule to be triggered.

Fixes #53018

Change-Id: Id56b8d986945bbb66e13131d11264ee438de5cb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/407655
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
2022-05-23 23:54:07 +00:00
Robert Griesemer
2138124143 go/types, types2: detect dupl. map keys in comp. literals with generic key type
For map composite literals where the key type is a suitably constrained
type parameter, the existing key duplicate detection mechanism doesn't
work when the keys are numeric values of different types but equal value.
For instance, given

        func _[P int64|float64]() {
                _ = map[P]string{0: "foo", 0.0: "bar"}
        }

the key values 0 and 0.0 have the same numeric value 0 but currently
are treated as different values int64(0) and float64(0.0). For any
valid instantiation of P, the keys will collide.

This CL changes the keyVal function to map numeric types to the
"smallest" numeric type in which a value can be represented. For
instance, float64(0.0) is mapped to int64(0). This ensures that
numerically equal values are always represented the same way so
that they can be detected as duplicates.

Fixes #51610.

Change-Id: I3eb71142bbe6b13453282a7f71ee48950e58ecbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/406555
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-05-23 22:10:24 +00:00
WANG Xuerui
3fa5ab0d83 runtime: fix the vDSO symbol version on loong64
The current value is appropriate for an early in-house version of
Linux/LoongArch, but for the upstream version it is very likely
"LINUX_5.10" instead, per the latest upstream submission [1].

[1]: https://lore.kernel.org/all/20220518095709.1313120-3-chenhuacai@loongson.cn/

Change-Id: Ia97e5cae82a5b306bd3eea86b9e442441da07973
Reviewed-on: https://go-review.googlesource.com/c/go/+/407755
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
2022-05-23 21:58:55 +00:00
Cherry Mui
e6b5949a75 cmd/internal/obj/arm64: fix encoding of ADR/ADRP instruction
The referenced address is p.From, not p.To.

Separate from CL 403980, as this is a bug fix. Also, ADR is used
in CL 387336. This is needed to make it work correctly.

Change-Id: Ie0baaeb359b9a7f233458d2becf25dc6a1f8ecbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/407884
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-23 21:58:35 +00:00
Cherry Mui
74f0ccb68b reflect: store receiver in pointer slot for reflect call
The code comment says that the receiver doesn't need to go into
the pointer slot as it will be kept alive in this frame. But it
doesn't. There is no direct reference of rcvr or v (the receiver)
after storing the arguments. Also, it is clearer to explicitly
keep it alive.

Fixes #52800.

Change-Id: Ie3fa8e83f6ecc69d62e8bfab767314d5181f5dc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/407508
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-23 18:40:59 +00:00
Khaled Yakdan
c1d197a96e cmd/compile: support libFuzzer value profiling mode for integer compares
libFuzzer provides a special mode known as “value profiling” in which it
tracks the bit-wise progress made by the fuzzer in satisfying tracked
comparisons. Furthermore, libFuzzer uses the value of the return address
in its hooks to distinguish the progress for different comparisons.

The original implementation of the interception for integer comparisons
in Go simply called the libFuzzer hooks from a function written in Go
assembly. The libFuzzer hooks thus always see the same return address
(i.e., the address of the call instruction in the assembly snippet) and
thus can’t distinguish individual comparisons anymore. This drastically
reduces the usefulness of value profiling.

This is fixed by using an assembly trampoline that injects synthetic but
valid return addresses on the stack before calling the libFuzzer hook,
otherwise preserving the calling convention of the respective platform
(for starters, x86_64 Windows or Unix). These fake PCs are generated
deterministically based on the location of the compare instruction in
the IR representation.

Change-Id: Iea68057c83aea7f9dc226fba7128708e8637d07a
GitHub-Last-Rev: f9184baafd
GitHub-Pull-Request: golang/go#51321
Reviewed-on: https://go-review.googlesource.com/c/go/+/387336
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-05-23 16:21:22 +00:00
Khaled Yakdan
3f571d1dea cmd/link: set coverage counters as expected by the fuzz package
Set _counters and _ecounters to the start and end locations of
libfuzzer's 8-bit counters section

Change-Id: Icadb503af1ba22495b1d88b69aad26d89843baa4
GitHub-Last-Rev: 4ca6216b76
GitHub-Pull-Request: golang/go#53022
Reviewed-on: https://go-review.googlesource.com/c/go/+/407674
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-23 14:38:06 +00:00
Ian Lance Taylor
0a1a092c4b Revert "cmd/cgo: use --no-gc-sections if available"
This reverts CL 405414.

Reason for revert: Breaks on AIX and iOS.

Change-Id: I4681c6f2fd69616691660916ebf0853e3a6a67ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/407634
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2022-05-20 23:37:43 +00:00
Dan Kortschak
c3470ca83c internal/fuzz: trim carriage return from version line
On windows hosts, when code is checked out using git with the default
setting of autocrlf=true, carriage returns are appended to source lines
which then prevent the version check from being successful. This removes
carriage returns to allow version matching.

Fixes #52268

Change-Id: I9acc4e907c93a20305f8742cc01687a122a88645
Reviewed-on: https://go-review.googlesource.com/c/go/+/402074
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dan Kortschak <dan@kortschak.io>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-20 23:05:38 +00:00
Khaled Yakdan
2b0e457b42 cmd/compile: intercept string compares in libFuzzer mode
IR string compares as well as calls to string comparison functions such
as `strings.EqualFold` are intercepted and the corresponding libFuzzer
callbacks are invoked with the corresponding arguments. As a result, the
compared strings will be added to libFuzzer’s table of recent compares,
which feeds future mutations performed by the fuzzer and thus allow it
to reach into branches guarded by string comparisons.

The list of methods to intercept is maintained in
`cmd/compile/internal/walk/expr.go` and can easily be extended to cover
more standard library functions in the future.

Change-Id: I5c8b89499c4e19459406795dea923bf777779c51
GitHub-Last-Rev: 6b8529b555
GitHub-Pull-Request: golang/go#51319
Reviewed-on: https://go-review.googlesource.com/c/go/+/387335
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
2022-05-20 22:30:37 +00:00
Michael Anthony Knyszek
b58067013e runtime: allocate physical-page-aligned memory differently
Currently, physical-page-aligned allocations for stacks (where the
physical page size is greater than the runtime page size) first
overallocates some memory, then frees the unaligned portions back to the
heap.

However, because allocating via h.pages.alloc causes scavenged bits to
get cleared, we need to account for that memory correctly in heapFree
and heapReleased. Currently that is not the case, leading to throws at
runtime.

Trying to get that accounting right is complicated, because information
about exactly which pages were scavenged needs to get plumbed up.
Instead, find the oversized region first, and then only allocate the
aligned part. This avoids any accounting issues.

However, this does come with some performance cost, because we don't
update searchAddr (which is safe, it just means the next allocation
potentially must look harder) and we skip the fast path that
h.pages.alloc has for simplicity.

Fixes #52682.

Change-Id: Iefa68317584d73b187634979d730eb30db770bb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/407502
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-05-20 21:54:20 +00:00
Khaled Yakdan
7ec6ef432a cmd/compile, cmd/link: use libFuzzer 8-bit instead of extra counters
By using libFuzzer’s 8-bit counters instead of extra counters, the
coverage instrumentation in libFuzzer mode is improved in three ways:
  1- 8-bit counters are supported on all platforms, including macOS and
     Windows, with all relevant versions of libFuzzer, whereas extra
     counters are a Linux-only feature that only recently received
     support on Windows.
  2- Newly covered blocks are now properly reported as new coverage by
     libFuzzer, not only as new features.
  3- The NeverZero strategy is used to ensure that coverage counters
     never become 0 again after having been positive once. This resolves
     issues encountered when fuzzing loops with iteration counts that
     are multiples of 256 (e.g., larger powers of two).

Change-Id: I9021210d7fbffd07c891ad08750402ee91cb3df5
GitHub-Last-Rev: 9057e4b21d
GitHub-Pull-Request: golang/go#51318
Reviewed-on: https://go-review.googlesource.com/c/go/+/387334
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-05-20 21:32:57 +00:00
Alex Brachet
e66f895667 cmd/cgo: allow DW_TAG_variable's with no name
https://reviews.llvm.org/D123534 is emitting DW_TAG_variable's
that don't have a DW_AT_name. This is allowed in the DWARF
standard. It is adding DIE's for string literals for better
symbolization on buffer overlows etc on these strings. They
no associated name because they are not user provided variables.

Fixes #53000

Change-Id: I2cf063160508687067c7672cef0517bccd707d7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/406816
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-20 21:03:28 +00:00
Motiejus Jakštys
4dd9458162 cmd/cgo: use --no-gc-sections if available
zig cc passes `--gc-sections` to the underlying linker, which then
causes undefined symbol errors when compiling with cgo but without C
code. Add `-Wl,--no-gc-sections` to make it work with zig cc. Minimal
example:

**main.go**

    package main
    import _ "runtime/cgo"
    func main() {}

Run (works after the patch, doesn't work before):

    CC="zig cc" go build main.go

Among the existing code, `src/runtime/testdata/testprognet` fails to
build:

    src/runtime/testdata/testprognet$ CC="zig cc" go build .
    net(.text): relocation target __errno_location not defined
    net(.text): relocation target getaddrinfo not defined
    net(.text): relocation target freeaddrinfo not defined
    net(.text): relocation target gai_strerror not defined
    runtime/cgo(.text): relocation target stderr not defined
    runtime/cgo(.text): relocation target fwrite not defined
    runtime/cgo(.text): relocation target vfprintf not defined
    runtime/cgo(.text): relocation target fputc not defined
    runtime/cgo(.text): relocation target abort not defined
    runtime/cgo(.text): relocation target pthread_create not defined
    runtime/cgo(.text): relocation target nanosleep not defined
    runtime/cgo(.text): relocation target pthread_detach not defined
    runtime/cgo(.text): relocation target stderr not defined
    runtime/cgo(.text): relocation target strerror not defined
    runtime/cgo(.text): relocation target fprintf not defined
    runtime/cgo(.text): relocation target abort not defined
    runtime/cgo(.text): relocation target pthread_mutex_lock not defined
    runtime/cgo(.text): relocation target pthread_cond_wait not defined
    runtime/cgo(.text): relocation target pthread_mutex_unlock not defined
    runtime/cgo(.text): relocation target pthread_cond_broadcast not defined
    runtime/cgo(.text): relocation target malloc not defined

With the patch both examples build as expected.

@ianlancetaylor suggested:

> It would be fine with me if somebody wants to send a cgo patch that
passes -Wl,--no-gc-sections, with a fallback if that option is not
supported.

... and this is what we are doing. Tested with zig
0.10.0-dev.2252+a4369918b

Fixes #52690

Change-Id: Ib6d1b2bd59335e9663afefd360ddad7da358a938
GitHub-Last-Rev: 58406b36ca
GitHub-Pull-Request: golang/go#52815
Reviewed-on: https://go-review.googlesource.com/c/go/+/405414
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-20 21:03:26 +00:00
Matthew Dempsky
69b412b7d6 internal/pkgbits: better documentation
Change-Id: I3f96a6e8a43faa5c8111b9d979aa37822c1dce06
Reviewed-on: https://go-review.googlesource.com/c/go/+/407434
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-05-20 19:01:40 +00:00
Xiaodong Liu
ec464edb22 cmd/dist: port to linux/loong64 completed
For #46229

Change-Id: I5c207482d0a2cfb3a66f7e293cf413a5b54daa26
Reviewed-on: https://go-review.googlesource.com/c/go/+/397074
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-20 16:17:43 +00:00
Wang Deyu
22a3209bc6 runtime: update description of GODEBUG=scavtrace=1
For #48409.

Change-Id: I056afcdbc417ce633e48184e69336213750aae28
Reviewed-on: https://go-review.googlesource.com/c/go/+/406575
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-20 15:17:29 +00:00
Xiaodong Liu
1371339530 go, math, os, reflect: support standard library for loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I2ad9ed01fc913b90e75023ac0fa70de87a9f5de1
Reviewed-on: https://go-review.googlesource.com/c/go/+/342324
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-20 15:12:52 +00:00
Xiaodong Liu
ae3ee9a7ec syscall: add syscall support for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: Ia676bd2875701639314cadbd39d97620afb3f0a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/342317
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-05-20 15:12:49 +00:00
Xiaodong Liu
ed7c487178 runtime: add loong64 to architectures known to TestGCInfo
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I61bef32b38ab07543a147cf172b169eae21b26cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/368082
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-05-20 15:12:39 +00:00
Xiaodong Liu
0811559ddd runtime: add build tag for common support on linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: Ide01fb8a39fe3e890f6cbc5d28f4a1d47eb5d79b
Reviewed-on: https://go-review.googlesource.com/c/go/+/368081
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-05-20 15:12:37 +00:00
Xiaodong Liu
2a5ceaaa78 runtime: implement runtime entry for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I252ecd0b13580c5e71723715023b1951985045f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/342322
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-20 15:12:31 +00:00
nimelehin
5370494577 runtime: add BenchmarkMemclrRange
This benchmark is added to test improvements in memclr_amd64.
As it is stated in Intel Optimization Manual 15.16.3.3, AVX2-implemented
memclr can produce a skewed result with the branch predictor being
trained by the large loop iteration count.

This benchmark generates sizes between some specified range. This should
help to measure how memclr works when branch predictors may be incorrectly
trained.

Change-Id: I14d173cafe43ca47198ed920e655547a66b3909f
Reviewed-on: https://go-review.googlesource.com/c/go/+/373362
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2022-05-20 13:51:52 +00:00
Keith Randall
d8762b2f45 runtime: fix overflow in PingPongHog test
On 32-bit systems the result of hogCount*factor can overflow.
Use division instead to do comparison.

Update #52207

Change-Id: I429fb9dc009af645acb535cee5c70887527ba207
Reviewed-on: https://go-review.googlesource.com/c/go/+/407415
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-05-19 21:33:15 +00:00
Ian Lance Taylor
dd83fd8a70 cmd/dist: pass a -test.timeout option to a host test
For a host test we build the test using "go test -c" and then run the
test binary. A test binary run in this way has no default timeout.
This CL gives it a timeout of 5 minutes, scaled for the target.
We can adjust the timeout if necessary.

For #52998

Change-Id: Ib759142f3e71cbb37ec858182998fc5d4fba7ab6
Reviewed-on: https://go-review.googlesource.com/c/go/+/407374
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-05-19 21:32:46 +00:00
Xiaodong Liu
34507e879d runtime/cgo: add cgo function call support for loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I8ef0e7f17d6ada3d2f07c81524136b78457e7795
Reviewed-on: https://go-review.googlesource.com/c/go/+/342319
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-05-19 21:15:04 +00:00
Xiaodong Liu
a7cc865edb runtime/internal/atomic: add atomic support for loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I0333503db044c6f39df2d7f8d9dff213b1361d6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/342320
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-19 21:14:49 +00:00
Daniel Martí
87039c7d34 cmd/go: reference BuildID field from list's -export docs
In https://golang.org/cl/263542 we added BuildID to the Package struct
in the docs for "go list", correctly pointing out that it's only set
when -export is used.

Further down, the doc details the -export flag on its own.
It already mentioned the Export field, and we forgot to add a mention to
BuildID as well. Do that.

Change-Id: I5838a8900edae8012fe333937d86baea3066c5f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/392114
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
2022-05-19 20:54:47 +00:00
Tobias Klauser
a1ceacedd8 net/netip: fix receiver name in Addr.{has,without}Zone comments
Change-Id: I851900cb52abfe75224a9dd9b9760eafd2cfc85f
Reviewed-on: https://go-review.googlesource.com/c/go/+/407175
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-19 20:31:45 +00:00
Jinzhu
29057b707d database/sql: fix close rows error ignored in Next
Change-Id: I19f0d764e2a6122307f3f26a6dd3be7b1155c73b
GitHub-Last-Rev: 9f1f883c45
GitHub-Pull-Request: golang/go#52756
Reviewed-on: https://go-review.googlesource.com/c/go/+/404794
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-19 20:21:12 +00:00
Mostafa Solati
97ce98ac20 cmd/go: do not ignore flags option with bad quoting
Fixes #43177

Change-Id: I7d8ef8dee0dcade3cc88fc6423e23f41d1f8ffb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/339289
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-05-19 20:20:43 +00:00
Keith Randall
6b6813fdb7 runtime: test alignment of fields targeted by 64-bit atomics
Make sure that all the targets of 64-bit atomic operations
are actually aligned to 8 bytes. This has been a source of
bugs on 32-bit systems. (e.g. CL 399754)

The strategy is to have a simple test that just checks the
alignment of some explicitly listed fields and global variables.

Then there's a more complicated test that makes sure the list
used in the simple test is exhaustive. That test has some
limitations, but it should catch most cases, particularly new
uses of atomic operations on new or existing fields.

Unlike a runtime assert, this check is free and will catch
accesses that occur even in very unlikely code paths.

Change-Id: I25ac78df471ac33b57cb91375bd8453d6ce2814f
Reviewed-on: https://go-review.googlesource.com/c/go/+/407034
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-19 20:10:40 +00:00
Daniel Martí
9b89c38020 cmd/gofmt: use SkipObjectResolution with -s as well
The "simplify" feature used go/ast's object tracking in only one place -
to replace s[a:len(s)] with s[a:].
Using go/ast.Object did allow us to not simplify code like:

	len := func(s []int) int { ... }
	s = s[a:len(s)]

The existing code already noted the limitation with that approach,
such as "len" being redeclared in a different file in the same package.
Since go/ast's object tracking is file-based and very basic,
it wouldn't work with edge cases like those.

The reasoning is that redeclaring len and abusing it that way is
extremely unlikely, and hasn't been a problem in about a decade now.
I reason that the same applies to len being redeclared in the same file,
so we should be able to safely remove the use of go/ast.Object here.

Per https://go.dev/cl/401454, this makes "gofmt -s" about 5% faster.
If we ever wanted to truly get rid of false positive simplifications,
I imagine we'd want to reimplement the feature under go/analysis,
which is able to fully typecheck packages and suggest edits.
That seems unnecessary at this point, but we can always course correct
in the presumably unlikely scenario that users start reporting bugs.

See #46485.
For #52463.

Change-Id: I77fc97adceafde8f0fe6887ace83ae325bfa7416
Reviewed-on: https://go-review.googlesource.com/c/go/+/401875
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-19 20:06:14 +00:00
Mostafa Solati
81a9a7f4c2 reflect: add example for FieldByName
Change-Id: I47e1cc261fdcd6f83a8593893b979d130150d0b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/407174
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-19 20:04:36 +00:00
Michael Anthony Knyszek
a6c75aa5c3 runtime: use correct heap goal in GC traces
Currently gctrace and gcpacertrace recompute the heap goal for
end-of-cycle information but this is incorrect.

Because both of these traces are printing stats from the previous cycle
in this case, they should print the heap goal at the end of the previous
cycle.

Change-Id: I967621cbaff9f331cd3e361de8850ddfe0cfc099
Reviewed-on: https://go-review.googlesource.com/c/go/+/407138
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-05-19 19:57:28 +00:00
Xiaodong Liu
8542bd8938 runtime: support vdso for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: Ie9bb5ccfc28e65036e2088c232bb333dcb259a60
Reviewed-on: https://go-review.googlesource.com/c/go/+/368076
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2022-05-19 19:32:35 +00:00
Xiaodong Liu
0084706528 runtime: implement signal for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: Ifa0229d2044dd53683de4a2b3ab965b16263f267
Reviewed-on: https://go-review.googlesource.com/c/go/+/368075
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-05-19 19:32:33 +00:00
Xiaodong Liu
c8de7628cb runtime: implement syscalls for runtime bootstrap on linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I848608267932717895d5cff9e33040029c3f3c4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/368080
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2022-05-19 19:28:24 +00:00
Xiaodong Liu
96a10b9c84 runtime: implement duffzero/duffcopy for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: Ida040e76dc8172f60e6aee1ea2b5bce13ab3581e
Reviewed-on: https://go-review.googlesource.com/c/go/+/368077
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-05-19 19:13:17 +00:00
Xiaodong Liu
2a5114f49a runtime: support memclr/memmove for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I7c1f39670034db6714630d479bc41b6620ba2b1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/368079
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-19 19:13:01 +00:00
Russ Cox
946b4baaf6 all: gofmt main repo
Excluding vendor and testdata.
CL 384268 already reformatted most, but these slipped past.

The struct in the doc comment in debug/dwarf/type.go
was fixed up by hand to indent the first and last lines as well.

For #51082.

Change-Id: Iad020f83aafd671ff58238fe491907e85923d0c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/407137
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-19 15:49:05 +00:00
Russ Cox
0aa8a87b5d syscall: make //sys lines not doc comments
If they are doc comments then gofmt will put a space between // and sys.
Most of syscall was already this way, following CL 7324056 (in 2013).
These were not.

Change-Id: Ie6ebf82809c199d0d06b87c86045bbb62b687d5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/407136
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2022-05-19 15:32:36 +00:00
Michael Anthony Knyszek
b93ceefa7b runtime: use osyield in runqgrab on netbsd
NetBSD appears to have the same issue OpenBSD had in runqgrab. See
issue #52475 for more details.

For #35166.

Change-Id: Ie53192d26919b4717bc0d61cadd88d688ff38bb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/407139
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-05-19 14:18:41 +00:00
Joel Sing
128279e503 cmd/compile: regenerate ssa
This is the result of running `go run *.go` in src/cmd/compile/internal/ssa/gen,
which should be a no-op - it would seem that it may not have been regenerated
before CL 367039 landed.

Updates #46229

Change-Id: I4d6b6e8425948429ede509682c7e997edbb905e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/406474
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
2022-05-19 07:13:47 +00:00
Xiaodong Liu
740b0ebb76 runtime: implement asyncPreempt for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I7a64e38b15a99816bd74262c02f62dad021cc166
Reviewed-on: https://go-review.googlesource.com/c/go/+/368078
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-19 02:40:14 +00:00
Cherry Mui
c087121daf runtime: relax the threshold for TestPingPongHog
The test checks that the scheduling of the goroutines are within
a small factor, to ensure the scheduler handing off the P
correctly. There have been flaky failures on the builder (probably
due to OS scheduling delays). Increase the threshold to make it
less flaky. The gap would be much bigger if the scheduler doesn't
work correctly.

For the long term maybe it is better to test it more directly
with the scheduler, e.g. with scheduler instrumentation.

May fix #52207.

Change-Id: I50278b70ab21b7f04761fdc8b38dd13304c67879
Reviewed-on: https://go-review.googlesource.com/c/go/+/407134
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-18 19:52:53 +00:00