Compare commits

...

53 Commits

Author SHA1 Message Date
Chris Broadfoot
c8aec4095e [release-branch.go1.9] go1.9
Change-Id: I0899ec0150f2a051b7572879b446a8548f742ae0
Reviewed-on: https://go-review.googlesource.com/58731
Run-TryBot: Chris Broadfoot <cbro@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-24 20:52:14 +00:00
Chris Broadfoot
b8c9ef9f09 [release-branch.go1.9] doc: add go1.9 to golang.org/project
Pre-emptive. Go 1.9 is expected to be released in August.

Change-Id: I0f58c012c4110bf490022dc2c1d69c0988d73bfa
Reviewed-on: https://go-review.googlesource.com/52351
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/58730
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2017-08-24 19:57:08 +00:00
Chris Broadfoot
136f4a6b2a [release-branch.go1.9] doc: document go1.9
Change-Id: I97075f24319a4b96cbeb9e3ff2e7b2056ff59e32
Reviewed-on: https://go-review.googlesource.com/58651
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/58710
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2017-08-24 19:55:44 +00:00
Ryuji IWATA
867be4c60c [release-branch.go1.9] doc/go1.9: fix typo in Moved GOROOT
Change-Id: I71bfff6a3462e6dfd7a65ef76ec56644bae37c34
Reviewed-on: https://go-review.googlesource.com/57272
Reviewed-by: Avelino <t@avelino.xxx>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-on: https://go-review.googlesource.com/58650
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-24 19:54:21 +00:00
Josh Bleecher Snyder
9a4e7942ea [release-branch.go1.9] cmd/compile: remove gc.Sysfunc calls from 387 backend
[This is a cherry-pick of CL 54090 to the 1.9 release branch.]

gc.Sysfunc must not be called concurrently.
We set up runtime routines used by the backend
prior to doing any backend compilation.
I missed the 387 ones; fix that.

Sysfunc should have been unexported during 1.9.
I will rectify that in a subsequent CL.

Fixes #21352

Change-Id: I485bb1867b46d8e5cf64bc820b8963576dc16174
Reviewed-on: https://go-review.googlesource.com/55970
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-08-22 18:24:54 +00:00
Ian Lance Taylor
ff38035a62 [release-branch.go1.9] doc/go1.9: fix typo in crypto/x509 of "Minor changes to the library".
Backport of https://golang.org/cl/57390 to 1.9 release branch.

Change-Id: Ieea5a048732db7ee5dc5cf13f06e11ca4f5313cc
Reviewed-on: https://go-review.googlesource.com/57450
Reviewed-by: Keith Randall <khr@golang.org>
2017-08-22 18:21:23 +00:00
Austin Clements
42046e8989 [release-branch.go1.9] runtime: fix false positive race in profile label reading
Because profile labels are copied from the goroutine into the tag
buffer by the signal handler, there's a carefully-crafted set of race
detector annotations to create the necessary happens-before edges
between setting a goroutine's profile label and retrieving it from the
profile tag buffer.

Given the constraints of the signal handler, we have to approximate
the true synchronization behavior. Currently, that approximation is
too weak.

Ideally, runtime_setProfLabel would perform a store-release on
&getg().labels and copying each label into the profile would perform a
load-acquire on &getg().labels. This would create the necessary
happens-before edges through each individual g.labels object.

Since we can't do this in the signal handler, we instead synchronize
on a "labelSync" global. The problem occurs with the following
sequence:

1. Goroutine 1 calls setProfLabel, which does a store-release on
   labelSync.

2. Goroutine 2 calls setProfLabel, which does a store-release on
   labelSync.

3. Goroutine 3 reads the profile, which does a load-acquire on
   labelSync.

The problem is that the load-acquire only synchronizes with the *most
recent* store-release to labelSync, and the two store-releases don't
synchronize with each other. So, once goroutine 3 touches the label
set by goroutine 1, we report a race.

The solution is to use racereleasemerge. This is like a
read-modify-write, rather than just a store-release. Each RMW of
labelSync in runtime_setProfLabel synchronizes with the previous RMW
of labelSync, and this ultimately carries forward to the load-acquire,
so it synchronizes with *all* setProfLabel operations, not just the
most recent.

Change-Id: Iab58329b156122002fff12cfe64fbeacb31c9613
Reviewed-on: https://go-review.googlesource.com/57190
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-18 23:07:14 +00:00
Ian Lance Taylor
fbf7e1f295 [release-branch.go1.9] testing: don't fail all tests after racy test failure
The code was adding race.Errors to t.raceErrors before checking
Failed, but Failed was using t.raceErrors+race.Errors. We don't want
to change Failed, since that would affect tests themselves, so modify
the harness to not unnecessarily change t.raceErrors.

Updates #19851
Fixes #21338

Change-Id: I483f27c68c340928f1cbdef160abc0a5716efb5d
Reviewed-on: https://go-review.googlesource.com/57151
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-18 21:10:46 +00:00
Ian Lance Taylor
21312a4b5e [release-branch.go1.9] cmd/dist: update deps.go for current dependencies
Fixes #21456

Change-Id: I7841d816e8c1c581e61db4f24124f99f5184fead
Reviewed-on: https://go-review.googlesource.com/57170
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-18 21:10:29 +00:00
Cherry Zhang
5927854f7d [release-branch.go1.9] cmd/compile: add rules handling unsigned div/mod by constant 1<<63
Cherry-pick CL 56890.

Normally 64-bit div/mod is turned into runtime calls on 32-bit
arch, but the front end leaves power-of-two constant division
and hopes the SSA backend turns into a shift or AND. The SSA rule is

(Mod64u <t> n (Const64 [c])) && isPowerOfTwo(c) -> (And64 n (Const64 <t> [c-1]))

But isPowerOfTwo returns true only for positive int64, which leaves
out 1<<63 unhandled. Add a special case for 1<<63.

Fixes #21517.

Change-Id: Ic91f86fd5e035a8bb64b937c15cb1c38fec917d6
Reviewed-on: https://go-review.googlesource.com/57070
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-18 18:43:00 +00:00
pvoicu
65717b2dca [release-branch.go1.9] runtime: fix usleep by correctly setting nanoseconds parameter for pselect6
Fixes #21518

Change-Id: Idd67e3f0410d0ce991b34dcc0c8f15e0d5c529c9
Reviewed-on: https://go-review.googlesource.com/56891
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Petrica Voicu <pvoicu@paypal.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-18 14:14:39 +00:00
Chris Broadfoot
048c9cfaac [release-branch.go1.9] go1.9rc2
Change-Id: If95cec0ec7e32cdb450818c4c55e2d03b847ab65
Reviewed-on: https://go-review.googlesource.com/53630
Reviewed-by: Austin Clements <austin@google.com>
2017-08-07 20:29:01 +00:00
Chris Broadfoot
cff0de3da3 [release-branch.go1.9] all: merge master into release-branch.go1.9
579120323f runtime: mapassign_* should use typedmemmove to update keys
380525598c all: remove some manual hyphenation
f096b5b340 runtime: mark activeModules nosplit/nowritebarrier
3e3da54633 math/bits: fix example for OnesCount64
9b1e7cf2ac math/bits: add examples for OnesCount functions
b01db023b1 misc/cgo/testsanitizers: also skip tsan11/tsan12 when using GCC
a279b53a18 reflect: document how DeepEqual handles cycles
909f409a8d doc: mention handling of moved GOROOT in 1.9 release notes
58ad0176ca doc: use better wording to explain type-aware completion
92dac21d29 doc: replace paid with commercial
9bb98e02de doc/1.9: add CL 43712, ReverseProxy of HTTP/2 trailers to the release notes.
78d74fc2cd doc: clarify that Gogland is for paid IntelliJ platform IDEs
5495047223 doc/1.9: fix broken html link in CL 53030/53210
890e0e862f doc: fix bad link in go1.9 release notes
be596f049a doc/1.9: fix stray html in CL 53030
0173631d53 encoding/binary: add examples for varint functions
ac0ccf3cd2 doc/1.9: add CL 36696 for crypto/x509 to the release notes
cc402c2c4d doc: hide blog content for golang.google.cn
f396fa4285 internal/poll: don't add non-sockets to runtime poller
664cd26c89 cmd/vet: don't exit with failure on type checking error
a8730cd93a doc: hide video and share if being served from CN
b63db76c4a testsanitizers: check that tsan program runs, skip tsan10 on gcc
193eda7291 time: skip ZoneAbbr test in timezones with no abbreviation
6f08c935a9 cmd/go: show examples with empty output in go test -list
f20944de78 cmd/compile: set/unset base register for better assembly print
623e2c4603 runtime: map bitmap and spans during heap initialization
780249eed4 runtime: fall back to small mmaps if we fail to grow reservation
31b2c4cc25 .github: add .md extension to SUPPORT file
ac29f30dbb plugin: mention that there are known bugs with plugins
45a4609c0a cmd/dist: skip moved GOROOT on Go's Windows builders when not sharding tests
e157fac02d test: add README
835dfef939 runtime/pprof: prevent a deadlock that SIGPROF might create on mips{,le}
df91b8044d doc: list editor options by name, not plugin name
3d9475c04b doc: cleanup editor page
b9661a14ea doc: add Atom to editor guide
ee392ac10c cmd/compile: consider exported flag in namedata

Change-Id: I3a48493e8c05d97cb3b61635503ef0ccd646e5cb
2017-08-07 10:28:35 -07:00
Keith Randall
579120323f runtime: mapassign_* should use typedmemmove to update keys
We need to make sure that when the key contains a pointer, we use
a write barrier to update the key.

Also mapdelete_* should use typedmemclr.

Fixes #21297

Change-Id: I63dc90bec1cb909c2c6e08676c9ec853d736cdf8
Reviewed-on: https://go-review.googlesource.com/53414
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-07 06:24:42 +00:00
Josh Bleecher Snyder
380525598c all: remove some manual hyphenation
Manual hyphenation doesn't work well when text gets reflown,
for example by godoc.

There are a few other manual hyphenations in the tree,
but they are in local comments or comments for unexported functions.

Change-Id: I17c9b1fee1def650da48903b3aae2fa1e1119a65
Reviewed-on: https://go-review.googlesource.com/53510
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-06 16:14:46 +00:00
Ian Lance Taylor
f096b5b340 runtime: mark activeModules nosplit/nowritebarrier
The activeModules function is called by the cgo pointer checking code,
which is called by the write barrier (when GODEBUG=cgocheck=2), and as
such must be nosplit/nowritebarrier.

Fixes #21306

Change-Id: I57f2124f14de7f3872b2de9532abab15df95d45a
Reviewed-on: https://go-review.googlesource.com/53352
Reviewed-by: Austin Clements <austin@google.com>
2017-08-05 18:05:41 +00:00
Francesc Campoy Flores
3e3da54633 math/bits: fix example for OnesCount64
Erroneously called OnesCount instead of OnesCount64

Change-Id: Ie877e43f213253e45d31f64931c4a15915849586
Reviewed-on: https://go-review.googlesource.com/53410
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2017-08-05 00:20:37 +00:00
Francesc Campoy
9b1e7cf2ac math/bits: add examples for OnesCount functions
Change-Id: Ie673f9665825a40281c2584d478ba1260f725856
Reviewed-on: https://go-review.googlesource.com/53357
Run-TryBot: Chris Broadfoot <cbro@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2017-08-04 23:24:07 +00:00
Ian Lance Taylor
b01db023b1 misc/cgo/testsanitizers: also skip tsan11/tsan12 when using GCC
Updates #21196

Change-Id: I307cacc963448b90a23f633bec15498ba7bf1937
Reviewed-on: https://go-review.googlesource.com/53356
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-04 23:05:00 +00:00
Ian Lance Taylor
a279b53a18 reflect: document how DeepEqual handles cycles
Fixes #20428

Change-Id: Ia450e615728efd4ccb6e42117b547cac162f13a3
Reviewed-on: https://go-review.googlesource.com/52931
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2017-08-04 22:22:03 +00:00
Ian Lance Taylor
909f409a8d doc: mention handling of moved GOROOT in 1.9 release notes
Updates #20587

Change-Id: Ia131b9a4dc4986950d9ecbfcbd6b026ade234fc0
Reviewed-on: https://go-review.googlesource.com/53370
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-04 22:14:38 +00:00
Jaana Burcu Dogan
58ad0176ca doc: use better wording to explain type-aware completion
Some editors can filter the autocompletion suggestions based on
whether the code will compile once autocompleted. Explain this
feature with better wording.

Change-Id: I29e4b0396878f18c79208915402c0a209a813b04
Reviewed-on: https://go-review.googlesource.com/53355
Reviewed-by: Florin Patan <florinpatan@gmail.com>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2017-08-04 20:18:16 +00:00
Jaana Burcu Dogan
92dac21d29 doc: replace paid with commercial
Change-Id: I3e6de4da0648f61e254c7597f316df3e5791321a
Reviewed-on: https://go-review.googlesource.com/53354
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2017-08-04 19:55:05 +00:00
Tristan Colgate
9bb98e02de doc/1.9: add CL 43712, ReverseProxy of HTTP/2 trailers to the release notes.
Add https://go-review.googlesource.com/c/43712,
"net/http/httputil: ReverseProxy should pass on unannounced Trailers"
to the relase notes.

Fixes #21307

Change-Id: I52c126987a5d0abc4153c0e71b535529c46cd457
Reviewed-on: https://go-review.googlesource.com/53290
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-04 18:36:20 +00:00
Jaana Burcu Dogan
78d74fc2cd doc: clarify that Gogland is for paid IntelliJ platform IDEs
Fixes #21213.

Change-Id: I7b8a84de92bbd1d3f78f8a9612f3af8cd092cb94
Reviewed-on: https://go-review.googlesource.com/53351
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2017-08-04 16:53:33 +00:00
Dmitry Savintsev
5495047223 doc/1.9: fix broken html link in CL 53030/53210
Change-Id: I7176becd10ad84cbfc3fb9427e190028626e5baf
Reviewed-on: https://go-review.googlesource.com/53291
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-04 14:49:52 +00:00
Alberto Donizetti
890e0e862f doc: fix bad link in go1.9 release notes
Change-Id: I64ba37428f5cc560f0f20fe039feaecf5fcda93e
Reviewed-on: https://go-review.googlesource.com/53330
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-04 13:23:09 +00:00
Dmitry Savintsev
be596f049a doc/1.9: fix stray html in CL 53030
Change-Id: Ib4102b1e2a8863712f725c4d1e37fdbe3dfe3c07
Reviewed-on: https://go-review.googlesource.com/53210
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-03 21:30:23 +00:00
Axel Wagner
0173631d53 encoding/binary: add examples for varint functions
Change-Id: I191f6e46b452fadde9f641140445d843b0c7d534
Reviewed-on: https://go-review.googlesource.com/48604
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-03 21:00:45 +00:00
Dmitry Savintsev
ac0ccf3cd2 doc/1.9: add CL 36696 for crypto/x509 to the release notes
add https://go-review.googlesource.com/c/36696
"crypto/x509: ignore CN if SAN extension present"
to the release notes.

Fixes #21289

Change-Id: Ifa184d3816806a8da3c67b68476c923329acf13e
Reviewed-on: https://go-review.googlesource.com/53030
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-03 18:22:36 +00:00
Andrew Bonventre
cc402c2c4d doc: hide blog content for golang.google.cn
/blog redirects to blog.golang.org (currently blocked in China)
unless there is a local checkout of golang.org/x/blog, which is
not possible on App Engine Classic.

Change-Id: Ia695e663c9bebcc6c3bedea324c630299eaad4dc
Reviewed-on: https://go-review.googlesource.com/53051
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2017-08-03 17:32:52 +00:00
Ian Lance Taylor
f396fa4285 internal/poll: don't add non-sockets to runtime poller
Updates #21172

Change-Id: I0fec6e645328bbc85f3e47f4f71dd8d1d68c75ab
Reviewed-on: https://go-review.googlesource.com/52551
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-08-03 04:22:44 +00:00
Ian Lance Taylor
664cd26c89 cmd/vet: don't exit with failure on type checking error
The vet tool only reports a type checking error when invoked with -v.
Don't let that by itself cause vet to exit with an error exit status.

Updates #21188

Change-Id: I172c13d46c35d49e229e96e833683d8c82a77de7
Reviewed-on: https://go-review.googlesource.com/52851
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
2017-08-03 04:22:02 +00:00
Andrew Bonventre
a8730cd93a doc: hide video and share if being served from CN
In the case where requests are coming from mainland China, hide
links to locations that are blocked and functionality that is
not permitted.

Additionally, some very small cleanup of the JS.

This change requires https://go-review.googlesource.com/c/52873

Change-Id: I7fc68748e629dbe5b966d6bf117e7f7b546966eb
Reviewed-on: https://go-review.googlesource.com/52872
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2017-08-02 21:09:49 +00:00
Ian Lance Taylor
b63db76c4a testsanitizers: check that tsan program runs, skip tsan10 on gcc
Check not only that a tsan program can be built, but also that it runs.
This fails with some installations of GCC 7.

Skip the tsan10 program when using GCC, as it reportedly hangs.

This is a patch to help people build 1.9; we may be able to do a
better fix for 1.10.

Updates #21196

Change-Id: Icd1ffbd018dc65a97ff45cab1264b9b0c7fa0ab2
Reviewed-on: https://go-review.googlesource.com/52790
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-02 18:32:24 +00:00
Alberto Donizetti
193eda7291 time: skip ZoneAbbr test in timezones with no abbreviation
The testZoneAbbr assumes that

  Parse(RFC1123, t1.Format(RFC1123))

will always succeed. This is not true because Format will fall back to
the numeric zone (ex. -07) for timezones with no abbreviation, but
Parse won't accept the numeric zone when the layout specifies 'MST'
(an abbreviation).

Skip the zone abbreviation test in timezones with no abbreviation.

Fixes #21183

Change-Id: If04691cc23ae1075d8a953733024e17f5a7646de
Reviewed-on: https://go-review.googlesource.com/52430
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-02 16:22:49 +00:00
Seiji Takahashi
6f08c935a9 cmd/go: show examples with empty output in go test -list
Fixes #21205

Change-Id: I81b001eb42cbf2a5d5b7b82eb63548b22f501be5
Reviewed-on: https://go-review.googlesource.com/52110
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2017-08-02 14:30:08 +00:00
Cherry Zhang
f20944de78 cmd/compile: set/unset base register for better assembly print
For address of an auto or arg, on all non-x86 architectures
the assembler backend encodes the actual SP offset in the
instruction but leaves the offset in Prog unchanged. When the
assembly is printed in compile -S, it shows an offset
relative to pseudo FP/SP with an actual hardware SP base
register (e.g. R13 on ARM). This is confusing. Unset the
base register if it is indeed SP, so the assembly output is
consistent. If the base register isn't SP, it should be an
error and the error output contains the actual base register.

For address loading instructions, the base register isn't set
in the compiler on non-x86 architectures. Set it. Normally it
is SP and will be unset in the change mentioned above for
printing. If it is not, it will be an error and the error
output contains the actual base register.

No change in generated binary, only printed assembly. Passes
"go build -a -toolexec 'toolstash -cmp' std cmd" on all
architectures.

Fixes #21064.

Change-Id: Ifafe8d5f9b437efbe824b63b3cbc2f5f6cdc1fd5
Reviewed-on: https://go-review.googlesource.com/49432
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2017-08-02 12:24:02 +00:00
Austin Clements
196492a299 [release-branch.go1.9] runtime: map bitmap and spans during heap initialization
We lazily map the bitmap and spans areas as the heap grows. However,
right now we're very slightly too lazy. Specifically, the following
can happen on 32-bit:

1. mallocinit fails to allocate any heap arena, so
   arena_used == arena_alloc == arena_end == bitmap.

2. There's less than 256MB between the end of the bitmap mapping and
   the next mapping.

3. On the first allocation, mheap.sysAlloc sees that there's not
   enough room in [arena_alloc, arena_end) because there's no room at
   all. It gets a 256MB mapping from somewhere *lower* in the address
   space than arena_used and sets arena_alloc and arena_end to this
   hole.

4. Since the new arena_alloc is lower than arena_used, mheap.sysAlloc
   doesn't bother to call mheap.setArenaUsed, so we still don't have a
   bitmap mapping or a spans array mapping.

5. mheap.grow, which called mheap.sysAlloc, attempts to fill in the
   spans array and crashes.

Fix this by mapping the metadata regions for the initial arena_used
when the heap is initialized, rather than trying to wait for an
allocation. This maintains the intended invariant that the structures
are always mapped for [arena_start, arena_used).

Fixes #21044.

Cherry-pick of CL 51714. Fixes #21234.

Change-Id: I4422375a6e234b9f979d22135fc63ae3395946b0
Reviewed-on: https://go-review.googlesource.com/52191
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-07-31 17:46:03 +00:00
Austin Clements
1a6d87d4bf [release-branch.go1.9] runtime: fall back to small mmaps if we fail to grow reservation
Right now, if it's possible to grow the arena reservation but
mheap.sysAlloc fails to get 256MB more of memory, it simply fails.
However, on 32-bit we have a fallback path that uses much smaller
mmaps that could take in this situation, but fail to.

This commit fixes mheap.sysAlloc to use a common failure path in case
it can't grow the reservation. On 32-bit, this path includes the
fallback.

Ideally, mheap.sysAlloc would attempt smaller reservation growths
first, but taking the fallback path is a simple change for Go 1.9.

Updates #21044 (fixes one of two issues).

Cherry-pick of CL 51713. Updates #21234.

Change-Id: I1e0035ffba986c3551479d5742809e43da5e7c73
Reviewed-on: https://go-review.googlesource.com/52190
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-07-31 17:45:59 +00:00
Austin Clements
623e2c4603 runtime: map bitmap and spans during heap initialization
We lazily map the bitmap and spans areas as the heap grows. However,
right now we're very slightly too lazy. Specifically, the following
can happen on 32-bit:

1. mallocinit fails to allocate any heap arena, so
   arena_used == arena_alloc == arena_end == bitmap.

2. There's less than 256MB between the end of the bitmap mapping and
   the next mapping.

3. On the first allocation, mheap.sysAlloc sees that there's not
   enough room in [arena_alloc, arena_end) because there's no room at
   all. It gets a 256MB mapping from somewhere *lower* in the address
   space than arena_used and sets arena_alloc and arena_end to this
   hole.

4. Since the new arena_alloc is lower than arena_used, mheap.sysAlloc
   doesn't bother to call mheap.setArenaUsed, so we still don't have a
   bitmap mapping or a spans array mapping.

5. mheap.grow, which called mheap.sysAlloc, attempts to fill in the
   spans array and crashes.

Fix this by mapping the metadata regions for the initial arena_used
when the heap is initialized, rather than trying to wait for an
allocation. This maintains the intended invariant that the structures
are always mapped for [arena_start, arena_used).

Fixes #21044.

Change-Id: I4422375a6e234b9f979d22135fc63ae3395946b0
Reviewed-on: https://go-review.googlesource.com/51714
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-07-31 16:52:36 +00:00
Austin Clements
780249eed4 runtime: fall back to small mmaps if we fail to grow reservation
Right now, if it's possible to grow the arena reservation but
mheap.sysAlloc fails to get 256MB more of memory, it simply fails.
However, on 32-bit we have a fallback path that uses much smaller
mmaps that could take in this situation, but fail to.

This commit fixes mheap.sysAlloc to use a common failure path in case
it can't grow the reservation. On 32-bit, this path includes the
fallback.

Ideally, mheap.sysAlloc would attempt smaller reservation growths
first, but taking the fallback path is a simple change for Go 1.9.

Updates #21044 (fixes one of two issues).

Change-Id: I1e0035ffba986c3551479d5742809e43da5e7c73
Reviewed-on: https://go-review.googlesource.com/51713
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-31 14:05:58 +00:00
Gustav Westling
31b2c4cc25 .github: add .md extension to SUPPORT file
This makes GitHub render the markdown file automatically
on their web UI.

SUPPORT.md is the recommended file name according to the GitHub
documentation:
https://help.github.com/articles/adding-support-resources-to-your-project/

Fixes #21223

Change-Id: I9f9b9daced9c29a16850e8c446656f353f50b1ae
Reviewed-on: https://go-review.googlesource.com/52013
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-30 21:46:28 +00:00
Ian Lance Taylor
ac29f30dbb plugin: mention that there are known bugs with plugins
Change-Id: I9e63661cac2bebc41d7aa3cd80e1920eec22b894
Reviewed-on: https://go-review.googlesource.com/51250
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-07-28 00:29:08 +00:00
Brad Fitzpatrick
7320506bc5 [release-branch.go1.9] cmd/dist: skip moved GOROOT on Go's Windows builders when not sharding tests
Change-Id: I0bcae339624e7d61037d9ea0885b7bd07491bbb6
Reviewed-on: https://go-review.googlesource.com/51430
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 4833e920c1d7f6b23458e6ff3c73951fcf754219)
Reviewed-on: https://go-review.googlesource.com/51450
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-27 05:56:03 +00:00
Brad Fitzpatrick
45a4609c0a cmd/dist: skip moved GOROOT on Go's Windows builders when not sharding tests
Change-Id: I0bcae339624e7d61037d9ea0885b7bd07491bbb6
Reviewed-on: https://go-review.googlesource.com/51430
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-07-27 05:04:28 +00:00
Josh Bleecher Snyder
e157fac02d test: add README
Updates #21034

Change-Id: I951fb48ab3b9ed54d225c11879db8f09048a36a3
Reviewed-on: https://go-review.googlesource.com/50950
Reviewed-by: Rob Pike <r@golang.org>
2017-07-26 23:37:25 +00:00
Vladimir Stefanovic
835dfef939 runtime/pprof: prevent a deadlock that SIGPROF might create on mips{,le}
64bit atomics on mips/mipsle are implemented using spinlocks. If SIGPROF
is received while the program is in the critical section, it will try to
write the sample using the same spinlock, creating a deadloop.
Prevent it by creating a counter of SIGPROFs during atomic64 and
postpone writing the sample(s) until called from elsewhere, with
pc set to _LostSIGPROFDuringAtomic64.

Added a test case, per Cherry's suggestion. Works around #20146.

Change-Id: Icff504180bae4ee83d78b19c0d9d6a80097087f9
Reviewed-on: https://go-review.googlesource.com/42652
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-07-26 13:29:59 +00:00
Jaana Burcu Dogan
df91b8044d doc: list editor options by name, not plugin name
So the users can recognize their option by their editor's name.

Fixes #20398.

Change-Id: Id314d4dbe26f40231a479b179620d7e66512b506
Reviewed-on: https://go-review.googlesource.com/51114
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2017-07-25 20:31:25 +00:00
Zac Bergquist
3d9475c04b doc: cleanup editor page
Fix some UI issues introduced with CL50952:
- increase header colspan to account for additional column
- remove ':' character from footnotes

Change-Id: I56f59b8e4b2852612b3c6c7c0dfe99125dd8b57b
Reviewed-on: https://go-review.googlesource.com/51113
Reviewed-by: Jaana Burcu Dogan <jbd@google.com>
2017-07-25 18:32:59 +00:00
Zac Bergquist
b9661a14ea doc: add Atom to editor guide
Fixes #20569

Change-Id: I752a49ed50c1567f8db7112859ac073f37dd77dc
Reviewed-on: https://go-review.googlesource.com/50952
Reviewed-by: Jaana Burcu Dogan <jbd@google.com>
2017-07-25 17:20:27 +00:00
Chris Broadfoot
65c6c88a94 [release-branch.go1.9] go1.9rc1
Change-Id: I6251fc128990f9494a0b037cabb24ada5eabb6b5
Reviewed-on: https://go-review.googlesource.com/50951
Run-TryBot: Chris Broadfoot <cbro@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2017-07-24 19:35:04 +00:00
Ian Lance Taylor
fbc9b49790 [release-branch.go1.9] cmd/compile: consider exported flag in namedata
It is possible to have an unexported name with a nil package,
for an embedded field whose type is a pointer to an unexported type.
We must encode that fact in the type..namedata symbol name,
to avoid incorrectly merging an unexported name with an exported name.

Fixes #21120

Change-Id: I2e3879d77fa15c05ad92e0bf8e55f74082db5111
Reviewed-on: https://go-review.googlesource.com/50710
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-on: https://go-review.googlesource.com/50970
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2017-07-24 18:12:06 +00:00
60 changed files with 1508 additions and 159 deletions

1
VERSION Normal file
View File

@@ -0,0 +1 @@
go1.9

View File

@@ -34,6 +34,7 @@ We encourage all Go users to subscribe to
<p>A <a href="/doc/devel/release.html">summary</a> of the changes between Go releases. Notes for the major releases:</p>
<ul>
<li><a href="/doc/go1.9">Go 1.9</a> <small>(August 2017)</small></li>
<li><a href="/doc/go1.8">Go 1.8</a> <small>(February 2017)</small></li>
<li><a href="/doc/go1.7">Go 1.7</a> <small>(August 2016)</small></li>
<li><a href="/doc/go1.6">Go 1.6</a> <small>(February 2016)</small></li>

View File

@@ -20,7 +20,14 @@ For example, Go 1.8 is supported until Go 1.10 is released,
and Go 1.9 is supported until Go 1.11 is released.
We fix critical problems, including <a href="/security">critical security problems</a>,
in supported releases as needed by issuing minor revisions
(for example, Go 1.8.1, Go 1.8.2, and so on).
(for example, Go 1.9.1, Go 1.9.2, and so on).
</p>
<h2 id="go1.9">go1.9 (released 2017/08/24)</h2>
<p>
Go 1.9 is a major release of Go.
Read the <a href="/doc/go1.9">Go 1.9 Release Notes</a> for more information.
</p>
<h2 id="go1.8">go1.8 (released 2017/02/16)</h2>

View File

@@ -19,11 +19,12 @@ editing, navigation, testing, and debugging experience.
</p>
<ul>
<li><a href="https://github.com/fatih/vim-go">Vim Go</a>: a plugin for Vim to provide Go programming language support</li>
<li><a href="https://marketplace.visualstudio.com/items?itemName=lukehoban.Go">Visual Studio Code Go</a>:
an extension for Visual Studio Code to provide support for the Go programming language</li>
<li><a href="https://github.com/fatih/vim-go">vim</a>: vim-go plugin provides Go programming language support</li>
<li><a href="https://marketplace.visualstudio.com/items?itemName=lukehoban.Go">Visual Studio Code</a>:
Go extension provides support for the Go programming language</li>
<li><a href="https://www.jetbrains.com/go">Gogland</a>: Gogland is distributed either as a standalone IDE
or as a plugin for the IntelliJ Platform IDEs</li>
or as a plugin for the commercial IntelliJ Platform IDEs</li>
<li><a href="https://atom.io/packages/go-plus">Atom</a>: Go-Plus is an Atom package that provides enhanced Go support</li>
</ul>
<p>
@@ -41,133 +42,155 @@ The following feature matrix lists and compares the most significant features.
<table class="features-matrix">
<tr>
<th></th>
<th><img title="Vim Go" src="/doc/editors/vimgo.png"><br>Vim Go</th>
<th><img title="Visual Studio Code" src="/doc/editors/vscodego.png"><br>Visual Studio Code Go</th>
<th><img title="Vim Go" src="/doc/editors/vimgo.png"><br>vim</th>
<th><img title="Visual Studio Code" src="/doc/editors/vscodego.png"><br>Visual Studio Code</th>
<th><img title="Gogland" src="/doc/editors/gogland.png"><br>Gogland</th>
<th><img title="Go-Plus" src="/doc/editors/go-plus.png"><br>Atom</th>
</tr>
<tr>
<td class="feature-row" colspan="4">Editing features</td>
<td class="feature-row" colspan="5">Editing features</td>
</tr>
<tr>
<td>Build and run from the editor/IDE</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
</tr>
<tr>
<td>Autocompletion of identifers (variable, method, and function names)</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
</tr>
<tr>
<td>Autocompletion based on type</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="yes">Yes</td>
</tr>
<tr>
<td>Type-aware autocompletion</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="yes">Yes</td>
<td class="no">No</td>
</tr>
<tr>
<td>Rename identifiers</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
</tr>
<tr>
<td>Auto format, build, vet, and lint on save</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes<sup>1</sup></td>
<td class="yes">Yes</td>
</tr>
<tr>
<td>Auto insert import paths and remove unused on save</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes<sup>2</sup></td>
<td class="yes">Yes</td>
</tr>
<tr>
<td>Auto generate JSON, XML tags for struct fields</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
</tr>
<tr>
<td class="feature-row" colspan="4">Navigation features</td>
<td class="feature-row" colspan="5">Navigation features</td>
</tr>
<tr>
<td>Display documentation inline, or open godoc in browser</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
</tr>
<tr>
<td>Switch between <code>*.go</code> and <code>*_test.go</code> file</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">No</td>
</tr>
<tr>
<td>Jump to definition and referees</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
</tr>
<tr>
<td>Look up for interface implementations</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
</tr>
<tr>
<td>Search for callers and callees</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
</tr>
<tr>
<td class="feature-row" colspan="4">Testing and debugging features</td>
<td class="feature-row" colspan="5">Testing and debugging features</td>
</tr>
<tr>
<td>Debugger support</td>
<td class="no">No</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes<sup>3</sup></td>
</tr>
<tr>
<td>Run a single test case, all tests from file, or all tests from a package</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="no">No</td>
</tr>
<tr>
<td>Auto generate tests for packages, files and identifiers</td>
<td class="no">No</td>
<td class="yes">Yes</td>
<td class="no">No</td>
<td class="no">No</td>
</tr>
<tr>
<td>Debug tests</td>
<td class="no">No</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes<sup>3</sup></td>
</tr>
<tr>
<td>Display test coverage</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
</tr>
<tr class="download">
<td></td>
<td><a href="https://github.com/fatih/vim-go">Install<a/></td>
<td><a href="https://marketplace.visualstudio.com/items?itemName=lukehoban.Go">Install<a/></td>
<td><a href="https://www.jetbrains.com/go">Install<a/></td>
<td><a href="https://atom.io/packages/go-plus">Install</a></td>
</tr>
</table>
<p>
<sup>1</sup>: Possible when enabled via Settings &gt; Go &gt; On Save, <code>go</code> <code>vet</code> and <code>golint</code> are available via plugins. Also runs tests on save if configured.
<sup>1</sup>Possible when enabled via Settings &gt; Go &gt; On Save, <code>go</code> <code>vet</code> and <code>golint</code> are available via plugins. Also runs tests on save if configured.
<br>
<sup>2</sup>: Additionally, user input can disambiguate when two or more options are available.
<sup>2</sup>Additionally, user input can disambiguate when two or more options are available.
<br>
<sup>3</sup>Available if the <a href="https://atom.io/packages/go-debug">go-debug</a> package is installed.
</p>
</div>
@@ -206,5 +229,3 @@ The following feature matrix lists and compares the most significant features.
font-weight: bold;
}
</style>
<!--TODO(jbd): Add the Atom comparison-->

BIN
doc/editors/go-plus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -15,12 +15,7 @@ Do not send CLs removing the interior tags from such phrases.
ul li { margin: 0.5em 0; }
</style>
<h2 id="introduction">DRAFT RELEASE NOTES - Introduction to Go 1.9</h2>
<p><strong>
Go 1.9 is not yet released. These are work-in-progress
release notes. Go 1.9 is expected to be released in August 2017.
</strong></p>
<h2 id="introduction">Introduction to Go 1.9</h2>
<p>
The latest Go release, version 1.9, arrives six months
@@ -156,6 +151,21 @@ type T1 = T2
directories, write <code>./vendor/...</code>.
</p>
<h3 id="goroot">Moved GOROOT</h3>
<p><!-- CL 42533 -->
The <a href="/cmd/go/">go tool</a> will now use the path from which it
was invoked to attempt to locate the root of the Go install tree.
This means that if the entire Go installation is moved to a new
location, the go tool should continue to work as usual.
This may be overridden by setting <code>GOROOT</code> in the environment,
which should only be done in unusual circumstances.
Note that this does not affect the result of
the <a href="/pkg/runtime/#GOROOT">runtime.GOROOT</a> function, which
will continue to report the original installation location;
this may be fixed in later releases.
</p>
<h3 id="compiler">Compiler Toolchain</h3>
<p><!-- CL 37441 -->
@@ -473,6 +483,15 @@ version of gccgo.
populated.
</p>
<p><!-- CL 36696 -->
If any SAN extension, including with no DNS names, is present
in the certificate, then the Common Name from
<a href="/pkg/crypto/x509/#Certificate.Subject"><code>Subject</code></a> is ignored.
In previous releases, the code tested only whether DNS-name SANs were
present in a certificate.
</p>
</dl><!-- crypto/x509 -->
<dl id="database/sql"><dt><a href="/pkg/database/sql/">database/sql</a></dt>
@@ -728,7 +747,7 @@ version of gccgo.
<li><!-- CL 35488 -->
The <a href="/pkg/net/http/#Transport"><code>Transport</code></a>
now supports making requests via SOCKS5 proxy when the URL returned by
<a href="/net/http/#Transport.Proxy"><code>Transport.Proxy</code></a>
<a href="/pkg/net/http/#Transport.Proxy"><code>Transport.Proxy</code></a>
has the scheme <code>socks5</code>.
</li>
</ul>
@@ -764,6 +783,16 @@ version of gccgo.
</dl><!-- net/http/httptest -->
<dl id="net/http/httputil"><dt><a href="/pkg/net/http/httputil/">net/http/httputil</a></dt>
<dd>
<p><!-- CL 43712 -->
The <a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a>
now proxies all HTTP/2 response trailers, even those not declared in the initial response
header. Such undeclared trailers are used by the gRPC protocol.
</p>
</dl><!-- net/http/httputil -->
<dl id="os"><dt><a href="/pkg/os/">os</a></dt>
<dd>
<p><!-- CL 36800 -->

View File

@@ -221,7 +221,7 @@ To build without <code>cgo</code>, set the environment variable
Change to the directory that will be its parent
and make sure the <code>go</code> directory does not exist.
Then clone the repository and check out the latest release tag
(<code class="versionTag">go1.8.1</code>, for example):</p>
(<code class="versionTag">go1.9</code>, for example):</p>
<pre>
$ git clone https://go.googlesource.com/go
@@ -409,7 +409,7 @@ New releases are announced on the
<a href="//groups.google.com/group/golang-announce">golang-announce</a>
mailing list.
Each announcement mentions the latest release tag, for instance,
<code class="versionTag">go1.8.1</code>.
<code class="versionTag">go1.9</code>.
</p>
<p>

View File

@@ -6,7 +6,9 @@
<div class="left">
<div id="learn">
{{if not $.GoogleCN}}
<a class="popout share">Pop-out</a>
{{end}}
<div class="rootHeading">Try Go</div>
<div class="input">
<textarea spellcheck="false" class="code">// You can edit this code!
@@ -26,10 +28,10 @@ Hello, 世界
</div>
<div class="buttons">
<a class="run" href="#" title="Run this code [shift-enter]">Run</a>
{{if $.Share}}
{{if not $.GoogleCN}}
<a class="share" href="#" title="Share this code">Share</a>
{{end}}
<a class="tour" href="//tour.golang.org/" title="Learn Go from your browser">Tour</a>
{{end}}
</div>
<div class="toys">
<select>
@@ -68,85 +70,91 @@ Linux, Mac OS X, Windows, and more.
<div style="clear: both"></div>
{{if not $.GoogleCN}}
<div class="left">
<div id="video">
<div class="rootHeading">Featured video</div>
<iframe width="415" height="241" src="//www.youtube.com/embed/ytEkHepK08c" frameborder="0" allowfullscreen></iframe>
</div>
<div id="video">
<div class="rootHeading">Featured video</div>
<iframe width="415" height="241" src="//www.youtube.com/embed/ytEkHepK08c" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<div class="right">
<div id="blog">
<div class="rootHeading">Featured articles</div>
<div class="read"><a href="//blog.golang.org/">Read more</a></div>
</div>
<div id="blog">
<div class="rootHeading">Featured articles</div>
<div class="read"><a href="//blog.golang.org/">Read more</a></div>
</div>
</div>
{{end}}
<div style="clear: both;"></div>
<script type="text/javascript">
<script>
(function() {
'use strict';
function readableTime(t) {
var m = ["January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"];
var p = t.substring(0, t.indexOf("T")).split("-");
var d = new Date(p[0], p[1]-1, p[2]);
return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear();
}
window.initFuncs.push(function() {
// Set up playground if enabled.
if (window.playground) {
window.playground({
"codeEl": "#learn .code",
"outputEl": "#learn .output",
"runEl": "#learn .run",
"shareEl": "#learn .share",
"shareRedirect": "//play.golang.org/p/",
"toysEl": "#learn .toys select"
});
} else {
$('#learn').hide()
}
});
function feedLoaded(result) {
var blog = document.getElementById("blog");
var read = blog.getElementsByClassName("read")[0];
for (var i = 0; i < result.length && i < 2; i++) {
var entry = result[i];
var title = document.createElement("a");
title.className = "title";
title.href = entry.Link;
title.innerHTML = entry.Title;
blog.insertBefore(title, read);
var extract = document.createElement("div");
extract.className = "extract";
extract.innerHTML = entry.Summary;
blog.insertBefore(extract, read);
var when = document.createElement("div");
when.className = "when";
when.innerHTML = "Published " + readableTime(entry.Time);
blog.insertBefore(when, read);
}
}
{{if not $.GoogleCN}}
window.initFuncs.push(function() {
// Set up playground if enabled.
if (window.playground) {
window.playground({
"codeEl": "#learn .code",
"outputEl": "#learn .output",
"runEl": "#learn .run",
"shareEl": "#learn .share",
"shareRedirect": "//play.golang.org/p/",
"toysEl": "#learn .toys select"
});
} else {
$('#learn').hide()
function readableTime(t) {
var m = ["January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"];
var p = t.substring(0, t.indexOf("T")).split("-");
var d = new Date(p[0], p[1]-1, p[2]);
return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear();
}
// Load blog feed.
$('<script/>').attr('text', 'text/javascript')
.attr('src', '//blog.golang.org/.json?jsonp=feedLoaded')
.appendTo('body');
window.feedLoaded = function(result) {
var blog = document.getElementById("blog");
var read = blog.getElementsByClassName("read")[0];
for (var i = 0; i < result.length && i < 2; i++) {
var entry = result[i];
var title = document.createElement("a");
title.className = "title";
title.href = entry.Link;
title.innerHTML = entry.Title;
blog.insertBefore(title, read);
var extract = document.createElement("div");
extract.className = "extract";
extract.innerHTML = entry.Summary;
blog.insertBefore(extract, read);
var when = document.createElement("div");
when.className = "when";
when.innerHTML = "Published " + readableTime(entry.Time);
blog.insertBefore(when, read);
}
}
// Set the video at random.
var videos = [
{h: 241, s: "//www.youtube.com/embed/ytEkHepK08c"}, // Tour of Go
{h: 241, s: "//www.youtube.com/embed/f6kdp27TYZs"}, // Concurrency Patterns
{h: 233, s: "//player.vimeo.com/video/69237265"} // Simple environment
];
var v = videos[Math.floor(Math.random()*videos.length)];
$('#video iframe').attr('height', v.h).attr('src', v.s);
});
window.initFuncs.push(function() {
// Load blog feed.
$('<script/>').attr('text', 'text/javascript')
.attr('src', '//blog.golang.org/.json?jsonp=feedLoaded')
.appendTo('body');
// Set the video at random.
var videos = [
{h: 241, s: "//www.youtube.com/embed/ytEkHepK08c"}, // Tour of Go
{h: 241, s: "//www.youtube.com/embed/f6kdp27TYZs"}, // Concurrency Patterns
{h: 233, s: "//player.vimeo.com/video/69237265"} // Simple environment
];
var v = videos[Math.floor(Math.random()*videos.length)];
$('#video iframe').attr('height', v.h).attr('src', v.s);
});
{{end}}
})();
</script>

View File

@@ -343,6 +343,14 @@ var ptrTests = []ptrTest{
body: `var b C.char; p := &b; C.f((*C.u)(unsafe.Pointer(&p)))`,
fail: false,
},
{
// Issue #21306.
name: "preempt-during-call",
c: `void f() {}`,
imports: []string{"runtime", "sync"},
body: `var wg sync.WaitGroup; wg.Add(100); for i := 0; i < 100; i++ { go func(i int) { for j := 0; j < 100; j++ { C.f(); runtime.GOMAXPROCS(i) }; wg.Done() }(i) }; wg.Wait()`,
fail: false,
},
}
func main() {

View File

@@ -156,15 +156,18 @@ if test "$tsan" = "yes"; then
if ! $CC -fsanitize=thread ${TMPDIR}/testsanitizers$$.c -o ${TMPDIR}/testsanitizers$$ &> ${TMPDIR}/testsanitizers$$.err; then
ok=no
fi
if grep "unrecognized" ${TMPDIR}/testsanitizers$$.err >& /dev/null; then
if grep "unrecognized" ${TMPDIR}/testsanitizers$$.err >& /dev/null; then
echo "skipping tsan tests: -fsanitize=thread not supported"
tsan=no
elif test "$ok" != "yes"; then
cat ${TMPDIR}/testsanitizers$$.err
echo "skipping tsan tests: -fsanitizer=thread build failed"
tsan=no
fi
rm -f ${TMPDIR}/testsanitizers$$*
elif test "$ok" != "yes"; then
cat ${TMPDIR}/testsanitizers$$.err
echo "skipping tsan tests: -fsanitizer=thread build failed"
tsan=no
elif ! ${TMPDIR}/testsanitizers$$ 2>&1; then
echo "skipping tsan tests: running tsan program failed"
tsan=no
fi
rm -f ${TMPDIR}/testsanitizers$$*
fi
# Run a TSAN test.
@@ -196,8 +199,10 @@ if test "$tsan" = "yes"; then
# These tests are only reliable using clang or GCC version 7 or later.
# Otherwise runtime/cgo/libcgo.h can't tell whether TSAN is in use.
ok=false
clang=false
if ${CC} --version | grep clang >/dev/null 2>&1; then
ok=true
clang=true
else
ver=$($CC -dumpversion)
major=$(echo $ver | sed -e 's/\([0-9]*\).*/\1/')
@@ -213,9 +218,13 @@ if test "$tsan" = "yes"; then
testtsan tsan5.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
testtsan tsan6.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
testtsan tsan7.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
testtsan tsan10.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
testtsan tsan11.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
testtsan tsan12.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
# The remaining tests reportedly hang when built with GCC; issue #21196.
if test "$clang" = "true"; then
testtsan tsan10.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
testtsan tsan11.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
testtsan tsan12.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
fi
testtsanshared
fi

View File

@@ -464,6 +464,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case ssa.OpARMMOVWaddr:
p := s.Prog(arm.AMOVW)
p.From.Type = obj.TYPE_ADDR
p.From.Reg = v.Args[0].Reg()
p.To.Type = obj.TYPE_REG
p.To.Reg = v.Reg()
@@ -485,7 +486,6 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case nil:
// No sym, just MOVW $off(SP), R
wantreg = "SP"
p.From.Reg = arm.REGSP
p.From.Offset = v.AuxInt
}
if reg := v.Args[0].RegName(); reg != wantreg {

View File

@@ -260,6 +260,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case ssa.OpARM64MOVDaddr:
p := s.Prog(arm64.AMOVD)
p.From.Type = obj.TYPE_ADDR
p.From.Reg = v.Args[0].Reg()
p.To.Type = obj.TYPE_REG
p.To.Reg = v.Reg()
@@ -281,7 +282,6 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case nil:
// No sym, just MOVD $off(SP), R
wantreg = "SP"
p.From.Reg = arm64.REGSP
p.From.Offset = v.AuxInt
}
if reg := v.Args[0].RegName(); reg != wantreg {

View File

@@ -898,6 +898,17 @@ var linuxAMD64Tests = []*asmTest{
}`,
[]string{"\tCMPL\t[A-Z]"},
},
{
// make sure assembly output has matching offset and base register.
`
func f72(a, b int) int {
var x [16]byte // use some frame
_ = x
return b
}
`,
[]string{"b\\+40\\(SP\\)"},
},
}
var linux386Tests = []*asmTest{
@@ -1302,6 +1313,17 @@ var linuxARMTests = []*asmTest{
`,
[]string{"\tCLZ\t"},
},
{
// make sure assembly output has matching offset and base register.
`
func f13(a, b int) int {
var x [16]byte // use some frame
_ = x
return b
}
`,
[]string{"b\\+4\\(FP\\)"},
},
}
var linuxARM64Tests = []*asmTest{
@@ -1473,7 +1495,7 @@ var linuxARM64Tests = []*asmTest{
return
}
`,
[]string{"\tMOVD\t\"\"\\.a\\+[0-9]+\\(RSP\\), R[0-9]+", "\tMOVD\tR[0-9]+, \"\"\\.b\\+[0-9]+\\(RSP\\)"},
[]string{"\tMOVD\t\"\"\\.a\\+[0-9]+\\(FP\\), R[0-9]+", "\tMOVD\tR[0-9]+, \"\"\\.b\\+[0-9]+\\(FP\\)"},
},
}

View File

@@ -293,4 +293,8 @@ var (
typedmemmove,
typedmemclr,
Udiv *obj.LSym
// GO386=387
ControlWord64trunc,
ControlWord32 *obj.LSym
)

View File

@@ -92,6 +92,10 @@ func initssaconfig() {
typedmemmove = Sysfunc("typedmemmove")
typedmemclr = Sysfunc("typedmemclr")
Udiv = Sysfunc("udiv")
// GO386=387 runtime functions
ControlWord64trunc = Sysfunc("controlWord64trunc")
ControlWord32 = Sysfunc("controlWord32")
}
// buildssa builds an SSA function for fn.

View File

@@ -35,6 +35,16 @@ func add_4294967296_uint64_ssa(a uint64) uint64 {
return 4294967296 + a
}
//go:noinline
func add_uint64_9223372036854775808_ssa(a uint64) uint64 {
return a + 9223372036854775808
}
//go:noinline
func add_9223372036854775808_uint64_ssa(a uint64) uint64 {
return 9223372036854775808 + a
}
//go:noinline
func add_uint64_18446744073709551615_ssa(a uint64) uint64 {
return a + 18446744073709551615
@@ -75,6 +85,16 @@ func sub_4294967296_uint64_ssa(a uint64) uint64 {
return 4294967296 - a
}
//go:noinline
func sub_uint64_9223372036854775808_ssa(a uint64) uint64 {
return a - 9223372036854775808
}
//go:noinline
func sub_9223372036854775808_uint64_ssa(a uint64) uint64 {
return 9223372036854775808 - a
}
//go:noinline
func sub_uint64_18446744073709551615_ssa(a uint64) uint64 {
return a - 18446744073709551615
@@ -110,6 +130,16 @@ func div_4294967296_uint64_ssa(a uint64) uint64 {
return 4294967296 / a
}
//go:noinline
func div_uint64_9223372036854775808_ssa(a uint64) uint64 {
return a / 9223372036854775808
}
//go:noinline
func div_9223372036854775808_uint64_ssa(a uint64) uint64 {
return 9223372036854775808 / a
}
//go:noinline
func div_uint64_18446744073709551615_ssa(a uint64) uint64 {
return a / 18446744073709551615
@@ -150,6 +180,16 @@ func mul_4294967296_uint64_ssa(a uint64) uint64 {
return 4294967296 * a
}
//go:noinline
func mul_uint64_9223372036854775808_ssa(a uint64) uint64 {
return a * 9223372036854775808
}
//go:noinline
func mul_9223372036854775808_uint64_ssa(a uint64) uint64 {
return 9223372036854775808 * a
}
//go:noinline
func mul_uint64_18446744073709551615_ssa(a uint64) uint64 {
return a * 18446744073709551615
@@ -190,6 +230,16 @@ func lsh_4294967296_uint64_ssa(a uint64) uint64 {
return 4294967296 << a
}
//go:noinline
func lsh_uint64_9223372036854775808_ssa(a uint64) uint64 {
return a << uint64(9223372036854775808)
}
//go:noinline
func lsh_9223372036854775808_uint64_ssa(a uint64) uint64 {
return 9223372036854775808 << a
}
//go:noinline
func lsh_uint64_18446744073709551615_ssa(a uint64) uint64 {
return a << uint64(18446744073709551615)
@@ -230,6 +280,16 @@ func rsh_4294967296_uint64_ssa(a uint64) uint64 {
return 4294967296 >> a
}
//go:noinline
func rsh_uint64_9223372036854775808_ssa(a uint64) uint64 {
return a >> uint64(9223372036854775808)
}
//go:noinline
func rsh_9223372036854775808_uint64_ssa(a uint64) uint64 {
return 9223372036854775808 >> a
}
//go:noinline
func rsh_uint64_18446744073709551615_ssa(a uint64) uint64 {
return a >> uint64(18446744073709551615)
@@ -265,6 +325,16 @@ func mod_4294967296_uint64_ssa(a uint64) uint64 {
return 4294967296 % a
}
//go:noinline
func mod_uint64_9223372036854775808_ssa(a uint64) uint64 {
return a % 9223372036854775808
}
//go:noinline
func mod_9223372036854775808_uint64_ssa(a uint64) uint64 {
return 9223372036854775808 % a
}
//go:noinline
func mod_uint64_18446744073709551615_ssa(a uint64) uint64 {
return a % 18446744073709551615
@@ -2319,6 +2389,16 @@ func main() {
failed = true
}
if got := add_0_uint64_ssa(9223372036854775808); got != 9223372036854775808 {
fmt.Printf("add_uint64 0%s9223372036854775808 = %d, wanted 9223372036854775808\n", `+`, got)
failed = true
}
if got := add_uint64_0_ssa(9223372036854775808); got != 9223372036854775808 {
fmt.Printf("add_uint64 9223372036854775808%s0 = %d, wanted 9223372036854775808\n", `+`, got)
failed = true
}
if got := add_0_uint64_ssa(18446744073709551615); got != 18446744073709551615 {
fmt.Printf("add_uint64 0%s18446744073709551615 = %d, wanted 18446744073709551615\n", `+`, got)
failed = true
@@ -2359,6 +2439,16 @@ func main() {
failed = true
}
if got := add_1_uint64_ssa(9223372036854775808); got != 9223372036854775809 {
fmt.Printf("add_uint64 1%s9223372036854775808 = %d, wanted 9223372036854775809\n", `+`, got)
failed = true
}
if got := add_uint64_1_ssa(9223372036854775808); got != 9223372036854775809 {
fmt.Printf("add_uint64 9223372036854775808%s1 = %d, wanted 9223372036854775809\n", `+`, got)
failed = true
}
if got := add_1_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("add_uint64 1%s18446744073709551615 = %d, wanted 0\n", `+`, got)
failed = true
@@ -2399,6 +2489,16 @@ func main() {
failed = true
}
if got := add_4294967296_uint64_ssa(9223372036854775808); got != 9223372041149743104 {
fmt.Printf("add_uint64 4294967296%s9223372036854775808 = %d, wanted 9223372041149743104\n", `+`, got)
failed = true
}
if got := add_uint64_4294967296_ssa(9223372036854775808); got != 9223372041149743104 {
fmt.Printf("add_uint64 9223372036854775808%s4294967296 = %d, wanted 9223372041149743104\n", `+`, got)
failed = true
}
if got := add_4294967296_uint64_ssa(18446744073709551615); got != 4294967295 {
fmt.Printf("add_uint64 4294967296%s18446744073709551615 = %d, wanted 4294967295\n", `+`, got)
failed = true
@@ -2409,6 +2509,56 @@ func main() {
failed = true
}
if got := add_9223372036854775808_uint64_ssa(0); got != 9223372036854775808 {
fmt.Printf("add_uint64 9223372036854775808%s0 = %d, wanted 9223372036854775808\n", `+`, got)
failed = true
}
if got := add_uint64_9223372036854775808_ssa(0); got != 9223372036854775808 {
fmt.Printf("add_uint64 0%s9223372036854775808 = %d, wanted 9223372036854775808\n", `+`, got)
failed = true
}
if got := add_9223372036854775808_uint64_ssa(1); got != 9223372036854775809 {
fmt.Printf("add_uint64 9223372036854775808%s1 = %d, wanted 9223372036854775809\n", `+`, got)
failed = true
}
if got := add_uint64_9223372036854775808_ssa(1); got != 9223372036854775809 {
fmt.Printf("add_uint64 1%s9223372036854775808 = %d, wanted 9223372036854775809\n", `+`, got)
failed = true
}
if got := add_9223372036854775808_uint64_ssa(4294967296); got != 9223372041149743104 {
fmt.Printf("add_uint64 9223372036854775808%s4294967296 = %d, wanted 9223372041149743104\n", `+`, got)
failed = true
}
if got := add_uint64_9223372036854775808_ssa(4294967296); got != 9223372041149743104 {
fmt.Printf("add_uint64 4294967296%s9223372036854775808 = %d, wanted 9223372041149743104\n", `+`, got)
failed = true
}
if got := add_9223372036854775808_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("add_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 0\n", `+`, got)
failed = true
}
if got := add_uint64_9223372036854775808_ssa(9223372036854775808); got != 0 {
fmt.Printf("add_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 0\n", `+`, got)
failed = true
}
if got := add_9223372036854775808_uint64_ssa(18446744073709551615); got != 9223372036854775807 {
fmt.Printf("add_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 9223372036854775807\n", `+`, got)
failed = true
}
if got := add_uint64_9223372036854775808_ssa(18446744073709551615); got != 9223372036854775807 {
fmt.Printf("add_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 9223372036854775807\n", `+`, got)
failed = true
}
if got := add_18446744073709551615_uint64_ssa(0); got != 18446744073709551615 {
fmt.Printf("add_uint64 18446744073709551615%s0 = %d, wanted 18446744073709551615\n", `+`, got)
failed = true
@@ -2439,6 +2589,16 @@ func main() {
failed = true
}
if got := add_18446744073709551615_uint64_ssa(9223372036854775808); got != 9223372036854775807 {
fmt.Printf("add_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 9223372036854775807\n", `+`, got)
failed = true
}
if got := add_uint64_18446744073709551615_ssa(9223372036854775808); got != 9223372036854775807 {
fmt.Printf("add_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 9223372036854775807\n", `+`, got)
failed = true
}
if got := add_18446744073709551615_uint64_ssa(18446744073709551615); got != 18446744073709551614 {
fmt.Printf("add_uint64 18446744073709551615%s18446744073709551615 = %d, wanted 18446744073709551614\n", `+`, got)
failed = true
@@ -2479,6 +2639,16 @@ func main() {
failed = true
}
if got := sub_0_uint64_ssa(9223372036854775808); got != 9223372036854775808 {
fmt.Printf("sub_uint64 0%s9223372036854775808 = %d, wanted 9223372036854775808\n", `-`, got)
failed = true
}
if got := sub_uint64_0_ssa(9223372036854775808); got != 9223372036854775808 {
fmt.Printf("sub_uint64 9223372036854775808%s0 = %d, wanted 9223372036854775808\n", `-`, got)
failed = true
}
if got := sub_0_uint64_ssa(18446744073709551615); got != 1 {
fmt.Printf("sub_uint64 0%s18446744073709551615 = %d, wanted 1\n", `-`, got)
failed = true
@@ -2519,6 +2689,16 @@ func main() {
failed = true
}
if got := sub_1_uint64_ssa(9223372036854775808); got != 9223372036854775809 {
fmt.Printf("sub_uint64 1%s9223372036854775808 = %d, wanted 9223372036854775809\n", `-`, got)
failed = true
}
if got := sub_uint64_1_ssa(9223372036854775808); got != 9223372036854775807 {
fmt.Printf("sub_uint64 9223372036854775808%s1 = %d, wanted 9223372036854775807\n", `-`, got)
failed = true
}
if got := sub_1_uint64_ssa(18446744073709551615); got != 2 {
fmt.Printf("sub_uint64 1%s18446744073709551615 = %d, wanted 2\n", `-`, got)
failed = true
@@ -2559,6 +2739,16 @@ func main() {
failed = true
}
if got := sub_4294967296_uint64_ssa(9223372036854775808); got != 9223372041149743104 {
fmt.Printf("sub_uint64 4294967296%s9223372036854775808 = %d, wanted 9223372041149743104\n", `-`, got)
failed = true
}
if got := sub_uint64_4294967296_ssa(9223372036854775808); got != 9223372032559808512 {
fmt.Printf("sub_uint64 9223372036854775808%s4294967296 = %d, wanted 9223372032559808512\n", `-`, got)
failed = true
}
if got := sub_4294967296_uint64_ssa(18446744073709551615); got != 4294967297 {
fmt.Printf("sub_uint64 4294967296%s18446744073709551615 = %d, wanted 4294967297\n", `-`, got)
failed = true
@@ -2569,6 +2759,56 @@ func main() {
failed = true
}
if got := sub_9223372036854775808_uint64_ssa(0); got != 9223372036854775808 {
fmt.Printf("sub_uint64 9223372036854775808%s0 = %d, wanted 9223372036854775808\n", `-`, got)
failed = true
}
if got := sub_uint64_9223372036854775808_ssa(0); got != 9223372036854775808 {
fmt.Printf("sub_uint64 0%s9223372036854775808 = %d, wanted 9223372036854775808\n", `-`, got)
failed = true
}
if got := sub_9223372036854775808_uint64_ssa(1); got != 9223372036854775807 {
fmt.Printf("sub_uint64 9223372036854775808%s1 = %d, wanted 9223372036854775807\n", `-`, got)
failed = true
}
if got := sub_uint64_9223372036854775808_ssa(1); got != 9223372036854775809 {
fmt.Printf("sub_uint64 1%s9223372036854775808 = %d, wanted 9223372036854775809\n", `-`, got)
failed = true
}
if got := sub_9223372036854775808_uint64_ssa(4294967296); got != 9223372032559808512 {
fmt.Printf("sub_uint64 9223372036854775808%s4294967296 = %d, wanted 9223372032559808512\n", `-`, got)
failed = true
}
if got := sub_uint64_9223372036854775808_ssa(4294967296); got != 9223372041149743104 {
fmt.Printf("sub_uint64 4294967296%s9223372036854775808 = %d, wanted 9223372041149743104\n", `-`, got)
failed = true
}
if got := sub_9223372036854775808_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("sub_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 0\n", `-`, got)
failed = true
}
if got := sub_uint64_9223372036854775808_ssa(9223372036854775808); got != 0 {
fmt.Printf("sub_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 0\n", `-`, got)
failed = true
}
if got := sub_9223372036854775808_uint64_ssa(18446744073709551615); got != 9223372036854775809 {
fmt.Printf("sub_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 9223372036854775809\n", `-`, got)
failed = true
}
if got := sub_uint64_9223372036854775808_ssa(18446744073709551615); got != 9223372036854775807 {
fmt.Printf("sub_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 9223372036854775807\n", `-`, got)
failed = true
}
if got := sub_18446744073709551615_uint64_ssa(0); got != 18446744073709551615 {
fmt.Printf("sub_uint64 18446744073709551615%s0 = %d, wanted 18446744073709551615\n", `-`, got)
failed = true
@@ -2599,6 +2839,16 @@ func main() {
failed = true
}
if got := sub_18446744073709551615_uint64_ssa(9223372036854775808); got != 9223372036854775807 {
fmt.Printf("sub_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 9223372036854775807\n", `-`, got)
failed = true
}
if got := sub_uint64_18446744073709551615_ssa(9223372036854775808); got != 9223372036854775809 {
fmt.Printf("sub_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 9223372036854775809\n", `-`, got)
failed = true
}
if got := sub_18446744073709551615_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("sub_uint64 18446744073709551615%s18446744073709551615 = %d, wanted 0\n", `-`, got)
failed = true
@@ -2619,6 +2869,11 @@ func main() {
failed = true
}
if got := div_0_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("div_uint64 0%s9223372036854775808 = %d, wanted 0\n", `/`, got)
failed = true
}
if got := div_0_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("div_uint64 0%s18446744073709551615 = %d, wanted 0\n", `/`, got)
failed = true
@@ -2649,6 +2904,16 @@ func main() {
failed = true
}
if got := div_1_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("div_uint64 1%s9223372036854775808 = %d, wanted 0\n", `/`, got)
failed = true
}
if got := div_uint64_1_ssa(9223372036854775808); got != 9223372036854775808 {
fmt.Printf("div_uint64 9223372036854775808%s1 = %d, wanted 9223372036854775808\n", `/`, got)
failed = true
}
if got := div_1_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("div_uint64 1%s18446744073709551615 = %d, wanted 0\n", `/`, got)
failed = true
@@ -2684,6 +2949,16 @@ func main() {
failed = true
}
if got := div_4294967296_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("div_uint64 4294967296%s9223372036854775808 = %d, wanted 0\n", `/`, got)
failed = true
}
if got := div_uint64_4294967296_ssa(9223372036854775808); got != 2147483648 {
fmt.Printf("div_uint64 9223372036854775808%s4294967296 = %d, wanted 2147483648\n", `/`, got)
failed = true
}
if got := div_4294967296_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("div_uint64 4294967296%s18446744073709551615 = %d, wanted 0\n", `/`, got)
failed = true
@@ -2694,6 +2969,51 @@ func main() {
failed = true
}
if got := div_uint64_9223372036854775808_ssa(0); got != 0 {
fmt.Printf("div_uint64 0%s9223372036854775808 = %d, wanted 0\n", `/`, got)
failed = true
}
if got := div_9223372036854775808_uint64_ssa(1); got != 9223372036854775808 {
fmt.Printf("div_uint64 9223372036854775808%s1 = %d, wanted 9223372036854775808\n", `/`, got)
failed = true
}
if got := div_uint64_9223372036854775808_ssa(1); got != 0 {
fmt.Printf("div_uint64 1%s9223372036854775808 = %d, wanted 0\n", `/`, got)
failed = true
}
if got := div_9223372036854775808_uint64_ssa(4294967296); got != 2147483648 {
fmt.Printf("div_uint64 9223372036854775808%s4294967296 = %d, wanted 2147483648\n", `/`, got)
failed = true
}
if got := div_uint64_9223372036854775808_ssa(4294967296); got != 0 {
fmt.Printf("div_uint64 4294967296%s9223372036854775808 = %d, wanted 0\n", `/`, got)
failed = true
}
if got := div_9223372036854775808_uint64_ssa(9223372036854775808); got != 1 {
fmt.Printf("div_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 1\n", `/`, got)
failed = true
}
if got := div_uint64_9223372036854775808_ssa(9223372036854775808); got != 1 {
fmt.Printf("div_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 1\n", `/`, got)
failed = true
}
if got := div_9223372036854775808_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("div_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 0\n", `/`, got)
failed = true
}
if got := div_uint64_9223372036854775808_ssa(18446744073709551615); got != 1 {
fmt.Printf("div_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 1\n", `/`, got)
failed = true
}
if got := div_uint64_18446744073709551615_ssa(0); got != 0 {
fmt.Printf("div_uint64 0%s18446744073709551615 = %d, wanted 0\n", `/`, got)
failed = true
@@ -2719,6 +3039,16 @@ func main() {
failed = true
}
if got := div_18446744073709551615_uint64_ssa(9223372036854775808); got != 1 {
fmt.Printf("div_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 1\n", `/`, got)
failed = true
}
if got := div_uint64_18446744073709551615_ssa(9223372036854775808); got != 0 {
fmt.Printf("div_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 0\n", `/`, got)
failed = true
}
if got := div_18446744073709551615_uint64_ssa(18446744073709551615); got != 1 {
fmt.Printf("div_uint64 18446744073709551615%s18446744073709551615 = %d, wanted 1\n", `/`, got)
failed = true
@@ -2759,6 +3089,16 @@ func main() {
failed = true
}
if got := mul_0_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("mul_uint64 0%s9223372036854775808 = %d, wanted 0\n", `*`, got)
failed = true
}
if got := mul_uint64_0_ssa(9223372036854775808); got != 0 {
fmt.Printf("mul_uint64 9223372036854775808%s0 = %d, wanted 0\n", `*`, got)
failed = true
}
if got := mul_0_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("mul_uint64 0%s18446744073709551615 = %d, wanted 0\n", `*`, got)
failed = true
@@ -2799,6 +3139,16 @@ func main() {
failed = true
}
if got := mul_1_uint64_ssa(9223372036854775808); got != 9223372036854775808 {
fmt.Printf("mul_uint64 1%s9223372036854775808 = %d, wanted 9223372036854775808\n", `*`, got)
failed = true
}
if got := mul_uint64_1_ssa(9223372036854775808); got != 9223372036854775808 {
fmt.Printf("mul_uint64 9223372036854775808%s1 = %d, wanted 9223372036854775808\n", `*`, got)
failed = true
}
if got := mul_1_uint64_ssa(18446744073709551615); got != 18446744073709551615 {
fmt.Printf("mul_uint64 1%s18446744073709551615 = %d, wanted 18446744073709551615\n", `*`, got)
failed = true
@@ -2839,6 +3189,16 @@ func main() {
failed = true
}
if got := mul_4294967296_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("mul_uint64 4294967296%s9223372036854775808 = %d, wanted 0\n", `*`, got)
failed = true
}
if got := mul_uint64_4294967296_ssa(9223372036854775808); got != 0 {
fmt.Printf("mul_uint64 9223372036854775808%s4294967296 = %d, wanted 0\n", `*`, got)
failed = true
}
if got := mul_4294967296_uint64_ssa(18446744073709551615); got != 18446744069414584320 {
fmt.Printf("mul_uint64 4294967296%s18446744073709551615 = %d, wanted 18446744069414584320\n", `*`, got)
failed = true
@@ -2849,6 +3209,56 @@ func main() {
failed = true
}
if got := mul_9223372036854775808_uint64_ssa(0); got != 0 {
fmt.Printf("mul_uint64 9223372036854775808%s0 = %d, wanted 0\n", `*`, got)
failed = true
}
if got := mul_uint64_9223372036854775808_ssa(0); got != 0 {
fmt.Printf("mul_uint64 0%s9223372036854775808 = %d, wanted 0\n", `*`, got)
failed = true
}
if got := mul_9223372036854775808_uint64_ssa(1); got != 9223372036854775808 {
fmt.Printf("mul_uint64 9223372036854775808%s1 = %d, wanted 9223372036854775808\n", `*`, got)
failed = true
}
if got := mul_uint64_9223372036854775808_ssa(1); got != 9223372036854775808 {
fmt.Printf("mul_uint64 1%s9223372036854775808 = %d, wanted 9223372036854775808\n", `*`, got)
failed = true
}
if got := mul_9223372036854775808_uint64_ssa(4294967296); got != 0 {
fmt.Printf("mul_uint64 9223372036854775808%s4294967296 = %d, wanted 0\n", `*`, got)
failed = true
}
if got := mul_uint64_9223372036854775808_ssa(4294967296); got != 0 {
fmt.Printf("mul_uint64 4294967296%s9223372036854775808 = %d, wanted 0\n", `*`, got)
failed = true
}
if got := mul_9223372036854775808_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("mul_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 0\n", `*`, got)
failed = true
}
if got := mul_uint64_9223372036854775808_ssa(9223372036854775808); got != 0 {
fmt.Printf("mul_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 0\n", `*`, got)
failed = true
}
if got := mul_9223372036854775808_uint64_ssa(18446744073709551615); got != 9223372036854775808 {
fmt.Printf("mul_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 9223372036854775808\n", `*`, got)
failed = true
}
if got := mul_uint64_9223372036854775808_ssa(18446744073709551615); got != 9223372036854775808 {
fmt.Printf("mul_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 9223372036854775808\n", `*`, got)
failed = true
}
if got := mul_18446744073709551615_uint64_ssa(0); got != 0 {
fmt.Printf("mul_uint64 18446744073709551615%s0 = %d, wanted 0\n", `*`, got)
failed = true
@@ -2879,6 +3289,16 @@ func main() {
failed = true
}
if got := mul_18446744073709551615_uint64_ssa(9223372036854775808); got != 9223372036854775808 {
fmt.Printf("mul_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 9223372036854775808\n", `*`, got)
failed = true
}
if got := mul_uint64_18446744073709551615_ssa(9223372036854775808); got != 9223372036854775808 {
fmt.Printf("mul_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 9223372036854775808\n", `*`, got)
failed = true
}
if got := mul_18446744073709551615_uint64_ssa(18446744073709551615); got != 1 {
fmt.Printf("mul_uint64 18446744073709551615%s18446744073709551615 = %d, wanted 1\n", `*`, got)
failed = true
@@ -2919,6 +3339,16 @@ func main() {
failed = true
}
if got := lsh_0_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("lsh_uint64 0%s9223372036854775808 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_uint64_0_ssa(9223372036854775808); got != 9223372036854775808 {
fmt.Printf("lsh_uint64 9223372036854775808%s0 = %d, wanted 9223372036854775808\n", `<<`, got)
failed = true
}
if got := lsh_0_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("lsh_uint64 0%s18446744073709551615 = %d, wanted 0\n", `<<`, got)
failed = true
@@ -2959,6 +3389,16 @@ func main() {
failed = true
}
if got := lsh_1_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("lsh_uint64 1%s9223372036854775808 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_uint64_1_ssa(9223372036854775808); got != 0 {
fmt.Printf("lsh_uint64 9223372036854775808%s1 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_1_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("lsh_uint64 1%s18446744073709551615 = %d, wanted 0\n", `<<`, got)
failed = true
@@ -2999,6 +3439,16 @@ func main() {
failed = true
}
if got := lsh_4294967296_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("lsh_uint64 4294967296%s9223372036854775808 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_uint64_4294967296_ssa(9223372036854775808); got != 0 {
fmt.Printf("lsh_uint64 9223372036854775808%s4294967296 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_4294967296_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("lsh_uint64 4294967296%s18446744073709551615 = %d, wanted 0\n", `<<`, got)
failed = true
@@ -3009,6 +3459,56 @@ func main() {
failed = true
}
if got := lsh_9223372036854775808_uint64_ssa(0); got != 9223372036854775808 {
fmt.Printf("lsh_uint64 9223372036854775808%s0 = %d, wanted 9223372036854775808\n", `<<`, got)
failed = true
}
if got := lsh_uint64_9223372036854775808_ssa(0); got != 0 {
fmt.Printf("lsh_uint64 0%s9223372036854775808 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_9223372036854775808_uint64_ssa(1); got != 0 {
fmt.Printf("lsh_uint64 9223372036854775808%s1 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_uint64_9223372036854775808_ssa(1); got != 0 {
fmt.Printf("lsh_uint64 1%s9223372036854775808 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_9223372036854775808_uint64_ssa(4294967296); got != 0 {
fmt.Printf("lsh_uint64 9223372036854775808%s4294967296 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_uint64_9223372036854775808_ssa(4294967296); got != 0 {
fmt.Printf("lsh_uint64 4294967296%s9223372036854775808 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_9223372036854775808_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("lsh_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_uint64_9223372036854775808_ssa(9223372036854775808); got != 0 {
fmt.Printf("lsh_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_9223372036854775808_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("lsh_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_uint64_9223372036854775808_ssa(18446744073709551615); got != 0 {
fmt.Printf("lsh_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_18446744073709551615_uint64_ssa(0); got != 18446744073709551615 {
fmt.Printf("lsh_uint64 18446744073709551615%s0 = %d, wanted 18446744073709551615\n", `<<`, got)
failed = true
@@ -3039,6 +3539,16 @@ func main() {
failed = true
}
if got := lsh_18446744073709551615_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("lsh_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_uint64_18446744073709551615_ssa(9223372036854775808); got != 0 {
fmt.Printf("lsh_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 0\n", `<<`, got)
failed = true
}
if got := lsh_18446744073709551615_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("lsh_uint64 18446744073709551615%s18446744073709551615 = %d, wanted 0\n", `<<`, got)
failed = true
@@ -3079,6 +3589,16 @@ func main() {
failed = true
}
if got := rsh_0_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("rsh_uint64 0%s9223372036854775808 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_uint64_0_ssa(9223372036854775808); got != 9223372036854775808 {
fmt.Printf("rsh_uint64 9223372036854775808%s0 = %d, wanted 9223372036854775808\n", `>>`, got)
failed = true
}
if got := rsh_0_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("rsh_uint64 0%s18446744073709551615 = %d, wanted 0\n", `>>`, got)
failed = true
@@ -3119,6 +3639,16 @@ func main() {
failed = true
}
if got := rsh_1_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("rsh_uint64 1%s9223372036854775808 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_uint64_1_ssa(9223372036854775808); got != 4611686018427387904 {
fmt.Printf("rsh_uint64 9223372036854775808%s1 = %d, wanted 4611686018427387904\n", `>>`, got)
failed = true
}
if got := rsh_1_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("rsh_uint64 1%s18446744073709551615 = %d, wanted 0\n", `>>`, got)
failed = true
@@ -3159,6 +3689,16 @@ func main() {
failed = true
}
if got := rsh_4294967296_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("rsh_uint64 4294967296%s9223372036854775808 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_uint64_4294967296_ssa(9223372036854775808); got != 0 {
fmt.Printf("rsh_uint64 9223372036854775808%s4294967296 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_4294967296_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("rsh_uint64 4294967296%s18446744073709551615 = %d, wanted 0\n", `>>`, got)
failed = true
@@ -3169,6 +3709,56 @@ func main() {
failed = true
}
if got := rsh_9223372036854775808_uint64_ssa(0); got != 9223372036854775808 {
fmt.Printf("rsh_uint64 9223372036854775808%s0 = %d, wanted 9223372036854775808\n", `>>`, got)
failed = true
}
if got := rsh_uint64_9223372036854775808_ssa(0); got != 0 {
fmt.Printf("rsh_uint64 0%s9223372036854775808 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_9223372036854775808_uint64_ssa(1); got != 4611686018427387904 {
fmt.Printf("rsh_uint64 9223372036854775808%s1 = %d, wanted 4611686018427387904\n", `>>`, got)
failed = true
}
if got := rsh_uint64_9223372036854775808_ssa(1); got != 0 {
fmt.Printf("rsh_uint64 1%s9223372036854775808 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_9223372036854775808_uint64_ssa(4294967296); got != 0 {
fmt.Printf("rsh_uint64 9223372036854775808%s4294967296 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_uint64_9223372036854775808_ssa(4294967296); got != 0 {
fmt.Printf("rsh_uint64 4294967296%s9223372036854775808 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_9223372036854775808_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("rsh_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_uint64_9223372036854775808_ssa(9223372036854775808); got != 0 {
fmt.Printf("rsh_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_9223372036854775808_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("rsh_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_uint64_9223372036854775808_ssa(18446744073709551615); got != 0 {
fmt.Printf("rsh_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_18446744073709551615_uint64_ssa(0); got != 18446744073709551615 {
fmt.Printf("rsh_uint64 18446744073709551615%s0 = %d, wanted 18446744073709551615\n", `>>`, got)
failed = true
@@ -3199,6 +3789,16 @@ func main() {
failed = true
}
if got := rsh_18446744073709551615_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("rsh_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_uint64_18446744073709551615_ssa(9223372036854775808); got != 0 {
fmt.Printf("rsh_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 0\n", `>>`, got)
failed = true
}
if got := rsh_18446744073709551615_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("rsh_uint64 18446744073709551615%s18446744073709551615 = %d, wanted 0\n", `>>`, got)
failed = true
@@ -3219,6 +3819,11 @@ func main() {
failed = true
}
if got := mod_0_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("mod_uint64 0%s9223372036854775808 = %d, wanted 0\n", `%`, got)
failed = true
}
if got := mod_0_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("mod_uint64 0%s18446744073709551615 = %d, wanted 0\n", `%`, got)
failed = true
@@ -3249,6 +3854,16 @@ func main() {
failed = true
}
if got := mod_1_uint64_ssa(9223372036854775808); got != 1 {
fmt.Printf("mod_uint64 1%s9223372036854775808 = %d, wanted 1\n", `%`, got)
failed = true
}
if got := mod_uint64_1_ssa(9223372036854775808); got != 0 {
fmt.Printf("mod_uint64 9223372036854775808%s1 = %d, wanted 0\n", `%`, got)
failed = true
}
if got := mod_1_uint64_ssa(18446744073709551615); got != 1 {
fmt.Printf("mod_uint64 1%s18446744073709551615 = %d, wanted 1\n", `%`, got)
failed = true
@@ -3284,6 +3899,16 @@ func main() {
failed = true
}
if got := mod_4294967296_uint64_ssa(9223372036854775808); got != 4294967296 {
fmt.Printf("mod_uint64 4294967296%s9223372036854775808 = %d, wanted 4294967296\n", `%`, got)
failed = true
}
if got := mod_uint64_4294967296_ssa(9223372036854775808); got != 0 {
fmt.Printf("mod_uint64 9223372036854775808%s4294967296 = %d, wanted 0\n", `%`, got)
failed = true
}
if got := mod_4294967296_uint64_ssa(18446744073709551615); got != 4294967296 {
fmt.Printf("mod_uint64 4294967296%s18446744073709551615 = %d, wanted 4294967296\n", `%`, got)
failed = true
@@ -3294,6 +3919,51 @@ func main() {
failed = true
}
if got := mod_uint64_9223372036854775808_ssa(0); got != 0 {
fmt.Printf("mod_uint64 0%s9223372036854775808 = %d, wanted 0\n", `%`, got)
failed = true
}
if got := mod_9223372036854775808_uint64_ssa(1); got != 0 {
fmt.Printf("mod_uint64 9223372036854775808%s1 = %d, wanted 0\n", `%`, got)
failed = true
}
if got := mod_uint64_9223372036854775808_ssa(1); got != 1 {
fmt.Printf("mod_uint64 1%s9223372036854775808 = %d, wanted 1\n", `%`, got)
failed = true
}
if got := mod_9223372036854775808_uint64_ssa(4294967296); got != 0 {
fmt.Printf("mod_uint64 9223372036854775808%s4294967296 = %d, wanted 0\n", `%`, got)
failed = true
}
if got := mod_uint64_9223372036854775808_ssa(4294967296); got != 4294967296 {
fmt.Printf("mod_uint64 4294967296%s9223372036854775808 = %d, wanted 4294967296\n", `%`, got)
failed = true
}
if got := mod_9223372036854775808_uint64_ssa(9223372036854775808); got != 0 {
fmt.Printf("mod_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 0\n", `%`, got)
failed = true
}
if got := mod_uint64_9223372036854775808_ssa(9223372036854775808); got != 0 {
fmt.Printf("mod_uint64 9223372036854775808%s9223372036854775808 = %d, wanted 0\n", `%`, got)
failed = true
}
if got := mod_9223372036854775808_uint64_ssa(18446744073709551615); got != 9223372036854775808 {
fmt.Printf("mod_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 9223372036854775808\n", `%`, got)
failed = true
}
if got := mod_uint64_9223372036854775808_ssa(18446744073709551615); got != 9223372036854775807 {
fmt.Printf("mod_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 9223372036854775807\n", `%`, got)
failed = true
}
if got := mod_uint64_18446744073709551615_ssa(0); got != 0 {
fmt.Printf("mod_uint64 0%s18446744073709551615 = %d, wanted 0\n", `%`, got)
failed = true
@@ -3319,6 +3989,16 @@ func main() {
failed = true
}
if got := mod_18446744073709551615_uint64_ssa(9223372036854775808); got != 9223372036854775807 {
fmt.Printf("mod_uint64 18446744073709551615%s9223372036854775808 = %d, wanted 9223372036854775807\n", `%`, got)
failed = true
}
if got := mod_uint64_18446744073709551615_ssa(9223372036854775808); got != 9223372036854775808 {
fmt.Printf("mod_uint64 9223372036854775808%s18446744073709551615 = %d, wanted 9223372036854775808\n", `%`, got)
failed = true
}
if got := mod_18446744073709551615_uint64_ssa(18446744073709551615); got != 0 {
fmt.Printf("mod_uint64 18446744073709551615%s18446744073709551615 = %d, wanted 0\n", `%`, got)
failed = true

View File

@@ -31,7 +31,7 @@ type szD struct {
}
var szs = []szD{
{name: "uint64", sn: "64", u: []uint64{0, 1, 4294967296, 0xffffFFFFffffFFFF}},
{name: "uint64", sn: "64", u: []uint64{0, 1, 4294967296, 0x8000000000000000, 0xffffFFFFffffFFFF}},
{name: "int64", sn: "64", i: []int64{-0x8000000000000000, -0x7FFFFFFFFFFFFFFF,
-4294967296, -1, 0, 1, 4294967296, 0x7FFFFFFFFFFFFFFE, 0x7FFFFFFFFFFFFFFF}},

View File

@@ -273,6 +273,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case ssa.OpMIPSMOVWaddr:
p := s.Prog(mips.AMOVW)
p.From.Type = obj.TYPE_ADDR
p.From.Reg = v.Args[0].Reg()
var wantreg string
// MOVW $sym+off(base), R
// the assembler expands it as the following:
@@ -291,7 +292,6 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case nil:
// No sym, just MOVW $off(SP), R
wantreg = "SP"
p.From.Reg = mips.REGSP
p.From.Offset = v.AuxInt
}
if reg := v.Args[0].RegName(); reg != wantreg {

View File

@@ -247,6 +247,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case ssa.OpMIPS64MOVVaddr:
p := s.Prog(mips.AMOVV)
p.From.Type = obj.TYPE_ADDR
p.From.Reg = v.Args[0].Reg()
var wantreg string
// MOVV $sym+off(base), R
// the assembler expands it as the following:
@@ -265,7 +266,6 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case nil:
// No sym, just MOVV $off(SP), R
wantreg = "SP"
p.From.Reg = mips.REGSP
p.From.Offset = v.AuxInt
}
if reg := v.Args[0].RegName(); reg != wantreg {

View File

@@ -638,6 +638,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case ssa.OpPPC64MOVDaddr:
p := s.Prog(ppc64.AMOVD)
p.From.Type = obj.TYPE_ADDR
p.From.Reg = v.Args[0].Reg()
p.To.Type = obj.TYPE_REG
p.To.Reg = v.Reg()
@@ -660,7 +661,6 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case nil:
// No sym, just MOVD $off(SP), R
wantreg = "SP"
p.From.Reg = ppc64.REGSP
p.From.Offset = v.AuxInt
}
if reg := v.Args[0].RegName(); reg != wantreg {

View File

@@ -945,6 +945,7 @@
(Div16u n (Const16 [c])) && isPowerOfTwo(c&0xffff) -> (Rsh16Ux64 n (Const64 <typ.UInt64> [log2(c&0xffff)]))
(Div32u n (Const32 [c])) && isPowerOfTwo(c&0xffffffff) -> (Rsh32Ux64 n (Const64 <typ.UInt64> [log2(c&0xffffffff)]))
(Div64u n (Const64 [c])) && isPowerOfTwo(c) -> (Rsh64Ux64 n (Const64 <typ.UInt64> [log2(c)]))
(Div64u n (Const64 [-1<<63])) -> (Rsh64Ux64 n (Const64 <typ.UInt64> [63]))
// Unsigned divide, not a power of 2. Strength reduce to a multiply.
// For 8-bit divides, we just do a direct 9-bit by 8-bit multiply.
@@ -1177,6 +1178,7 @@
(Mod16u <t> n (Const16 [c])) && isPowerOfTwo(c&0xffff) -> (And16 n (Const16 <t> [(c&0xffff)-1]))
(Mod32u <t> n (Const32 [c])) && isPowerOfTwo(c&0xffffffff) -> (And32 n (Const32 <t> [(c&0xffffffff)-1]))
(Mod64u <t> n (Const64 [c])) && isPowerOfTwo(c) -> (And64 n (Const64 <t> [c-1]))
(Mod64u <t> n (Const64 [-1<<63])) -> (And64 n (Const64 <t> [1<<63-1]))
// Signed mod by negative constant.
(Mod8 <t> n (Const8 [c])) && c < 0 && c != -1<<7 -> (Mod8 <t> n (Const8 <t> [-c]))

View File

@@ -7240,6 +7240,26 @@ func rewriteValuegeneric_OpDiv64u_0(v *Value) bool {
v.AddArg(v0)
return true
}
// match: (Div64u n (Const64 [-1<<63]))
// cond:
// result: (Rsh64Ux64 n (Const64 <typ.UInt64> [63]))
for {
_ = v.Args[1]
n := v.Args[0]
v_1 := v.Args[1]
if v_1.Op != OpConst64 {
break
}
if v_1.AuxInt != -1<<63 {
break
}
v.reset(OpRsh64Ux64)
v.AddArg(n)
v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64)
v0.AuxInt = 63
v.AddArg(v0)
return true
}
// match: (Div64u x (Const64 [c]))
// cond: umagicOK(64, c) && config.RegSize == 8 && umagic(64,c).m&1 == 0
// result: (Rsh64Ux64 <typ.UInt64> (Hmul64u <typ.UInt64> (Const64 <typ.UInt64> [int64(1<<63+umagic(64,c).m/2)]) x) (Const64 <typ.UInt64> [umagic(64,c).s-1]))
@@ -12061,6 +12081,27 @@ func rewriteValuegeneric_OpMod64u_0(v *Value) bool {
v.AddArg(v0)
return true
}
// match: (Mod64u <t> n (Const64 [-1<<63]))
// cond:
// result: (And64 n (Const64 <t> [1<<63-1]))
for {
t := v.Type
_ = v.Args[1]
n := v.Args[0]
v_1 := v.Args[1]
if v_1.Op != OpConst64 {
break
}
if v_1.AuxInt != -1<<63 {
break
}
v.reset(OpAnd64)
v.AddArg(n)
v0 := b.NewValue0(v.Pos, OpConst64, t)
v0.AuxInt = 1<<63 - 1
v.AddArg(v0)
return true
}
// match: (Mod64u <t> x (Const64 [c]))
// cond: x.Op != OpConst64 && c > 0 && umagicOK(64,c)
// result: (Sub64 x (Mul64 <t> (Div64u <t> x (Const64 <t> [c])) (Const64 <t> [c])))

View File

@@ -120,7 +120,7 @@ func ssaGenValue387(s *gc.SSAGenState, v *ssa.Value) {
p = s.Prog(x86.AFLDCW)
p.From.Type = obj.TYPE_MEM
p.From.Name = obj.NAME_EXTERN
p.From.Sym = gc.Sysfunc("controlWord32")
p.From.Sym = gc.ControlWord32
}
var op obj.As
@@ -210,7 +210,7 @@ func ssaGenValue387(s *gc.SSAGenState, v *ssa.Value) {
p = s.Prog(x86.AFLDCW)
p.From.Type = obj.TYPE_MEM
p.From.Name = obj.NAME_EXTERN
p.From.Sym = gc.Sysfunc("controlWord64trunc")
p.From.Sym = gc.ControlWord64trunc
// Now do the conversion.
p = s.Prog(x86.AFMOVLP)

18
src/cmd/dist/deps.go vendored
View File

@@ -31,8 +31,8 @@ var builddeps = map[string][]string{
"cmd/internal/objabi": {"errors", "flag", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "log", "math", "os", "path/filepath", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"compress/flate": {"bufio", "bytes", "errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "math/bits", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"compress/zlib": {"bufio", "bytes", "compress/flate", "errors", "fmt", "hash", "hash/adler32", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "math/bits", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"container/heap": {"errors", "internal/cpu", "internal/race", "math", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "sync", "sync/atomic", "unicode/utf8"},
"context": {"errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "syscall", "time", "unicode/utf16", "unicode/utf8"},
"container/heap": {"errors", "internal/cpu", "internal/race", "math", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "sync", "sync/atomic", "unicode", "unicode/utf8"},
"context": {"errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"crypto": {"errors", "hash", "internal/cpu", "internal/race", "io", "math", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "unicode/utf8"},
"crypto/sha1": {"crypto", "errors", "hash", "internal/cpu", "internal/race", "io", "math", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "unicode/utf8"},
"debug/dwarf": {"encoding/binary", "errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "path", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
@@ -40,18 +40,18 @@ var builddeps = map[string][]string{
"debug/macho": {"bytes", "debug/dwarf", "encoding/binary", "errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "path", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"encoding": {"runtime", "runtime/internal/atomic", "runtime/internal/sys"},
"encoding/base64": {"errors", "internal/cpu", "internal/race", "io", "math", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "unicode/utf8"},
"encoding/binary": {"errors", "internal/cpu", "internal/race", "io", "math", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "unicode/utf8"},
"encoding/binary": {"errors", "internal/cpu", "internal/race", "io", "math", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "unicode", "unicode/utf8"},
"encoding/json": {"bytes", "encoding", "encoding/base64", "errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"encoding/xml": {"bufio", "bytes", "encoding", "errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "strings", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"errors": {"runtime", "runtime/internal/atomic", "runtime/internal/sys"},
"flag": {"errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "sync", "sync/atomic", "syscall", "time", "unicode/utf16", "unicode/utf8"},
"fmt": {"errors", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "syscall", "time", "unicode/utf16", "unicode/utf8"},
"flag": {"errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"fmt": {"errors", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"go/ast": {"bytes", "errors", "fmt", "go/scanner", "go/token", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "path/filepath", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"go/build": {"bufio", "bytes", "errors", "fmt", "go/ast", "go/doc", "go/parser", "go/scanner", "go/token", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"go/doc": {"bytes", "errors", "fmt", "go/ast", "go/scanner", "go/token", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "math", "net/url", "os", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"go/parser": {"bytes", "errors", "fmt", "go/ast", "go/scanner", "go/token", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "math", "os", "path/filepath", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"go/scanner": {"bytes", "errors", "fmt", "go/token", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "path/filepath", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"go/token": {"errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "sync", "sync/atomic", "syscall", "time", "unicode/utf16", "unicode/utf8"},
"go/token": {"errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"hash": {"errors", "internal/race", "io", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sync", "sync/atomic"},
"hash/adler32": {"errors", "hash", "internal/race", "io", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sync", "sync/atomic"},
"internal/cpu": {"runtime", "runtime/internal/atomic", "runtime/internal/sys"},
@@ -63,7 +63,7 @@ var builddeps = map[string][]string{
"internal/syscall/windows/sysdll": {"runtime", "runtime/internal/atomic", "runtime/internal/sys"},
"io": {"errors", "internal/race", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sync", "sync/atomic"},
"io/ioutil": {"bytes", "errors", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "path/filepath", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"log": {"errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "syscall", "time", "unicode/utf16", "unicode/utf8"},
"log": {"errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"math": {"internal/cpu", "runtime", "runtime/internal/atomic", "runtime/internal/sys"},
"math/bits": {"runtime", "runtime/internal/atomic", "runtime/internal/sys"},
"net/url": {"bytes", "errors", "fmt", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
@@ -72,13 +72,13 @@ var builddeps = map[string][]string{
"os/signal": {"errors", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "os", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sync", "sync/atomic", "syscall", "time", "unicode/utf16", "unicode/utf8"},
"path": {"errors", "internal/cpu", "internal/race", "io", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strings", "sync", "sync/atomic", "unicode", "unicode/utf8"},
"path/filepath": {"errors", "internal/cpu", "internal/poll", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "math", "os", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf16", "unicode/utf8"},
"reflect": {"errors", "internal/cpu", "internal/race", "math", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "unicode/utf8"},
"reflect": {"errors", "internal/cpu", "internal/race", "math", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "unicode", "unicode/utf8"},
"regexp": {"bytes", "errors", "internal/cpu", "internal/race", "io", "math", "reflect", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "unicode", "unicode/utf8"},
"regexp/syntax": {"bytes", "errors", "internal/cpu", "internal/race", "io", "math", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "unicode", "unicode/utf8"},
"runtime": {"runtime/internal/atomic", "runtime/internal/sys"},
"runtime/internal/atomic": {"runtime/internal/sys"},
"runtime/internal/sys": {},
"sort": {"errors", "internal/cpu", "internal/race", "math", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "unicode/utf8"},
"sort": {"errors", "internal/cpu", "internal/race", "math", "reflect", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "strconv", "sync", "sync/atomic", "unicode", "unicode/utf8"},
"strconv": {"errors", "internal/cpu", "math", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "unicode/utf8"},
"strings": {"errors", "internal/cpu", "internal/race", "io", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sync", "sync/atomic", "unicode", "unicode/utf8"},
"sync": {"internal/race", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sync/atomic"},

11
src/cmd/dist/test.go vendored
View File

@@ -447,6 +447,17 @@ func (t *tester) registerTests() {
t.runPending(dt)
moved := t.goroot + "-moved"
if err := os.Rename(t.goroot, moved); err != nil {
if t.goos == "windows" {
// Fails on Windows (with "Access is denied") if a process
// or binary is in this directory. For instance, using all.bat
// when run from c:\workdir\go\src fails here
// if GO_BUILDER_NAME is set. Our builders invoke tests
// a different way which happens to work when sharding
// tests, but we should be tolerant of the non-sharded
// all.bat case.
log.Printf("skipping test on Windows")
return nil
}
return err
}

View File

@@ -4314,3 +4314,20 @@ func TestTestRegexps(t *testing.T) {
t.Errorf("reduced output:<<<\n%s>>> want:<<<\n%s>>>", have, want)
}
}
func TestListTests(t *testing.T) {
var tg *testgoData
testWith := func(listName, expected string) func(*testing.T) {
return func(t *testing.T) {
tg = testgo(t)
defer tg.cleanup()
tg.run("test", "./testdata/src/testlist/...", fmt.Sprintf("-list=%s", listName))
tg.grepStdout(expected, fmt.Sprintf("-test.list=%s returned %q, expected %s", listName, tg.getStdout(), expected))
}
}
t.Run("Test", testWith("Test", "TestSimple"))
t.Run("Bench", testWith("Benchmark", "BenchmarkSimple"))
t.Run("Example1", testWith("Example", "ExampleSimple"))
t.Run("Example2", testWith("Example", "ExampleWithEmptyOutput"))
}

View File

@@ -0,0 +1,14 @@
package testlist
import (
"fmt"
"testing"
)
func BenchmarkSimplefunc(b *testing.B) {
b.StopTimer()
b.StartTimer()
for i := 0; i < b.N; i++ {
_ = fmt.Sprint("Test for bench")
}
}

View File

@@ -0,0 +1,21 @@
package testlist
import (
"fmt"
)
func ExampleSimple() {
fmt.Println("Test with Output.")
// Output: Test with Output.
}
func ExampleWithEmptyOutput() {
fmt.Println("")
// Output:
}
func ExampleNoOutput() {
_ = fmt.Sprint("Test with no output")
}

View File

@@ -0,0 +1,10 @@
package testlist
import (
"fmt"
"testing"
)
func TestSimple(t *testing.T) {
_ = fmt.Sprint("Test simple")
}

View File

@@ -1167,6 +1167,11 @@ func (c *ctxt5) aclass(a *obj.Addr) int {
return C_ADDR
case obj.NAME_AUTO:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-SP.
a.Reg = obj.REG_NONE
}
c.instoffset = c.autosize + a.Offset
if t := immaddr(int32(c.instoffset)); t != 0 {
if immhalf(int32(c.instoffset)) {
@@ -1185,6 +1190,11 @@ func (c *ctxt5) aclass(a *obj.Addr) int {
return C_LAUTO
case obj.NAME_PARAM:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-FP.
a.Reg = obj.REG_NONE
}
c.instoffset = c.autosize + a.Offset + 4
if t := immaddr(int32(c.instoffset)); t != 0 {
if immhalf(int32(c.instoffset)) {
@@ -1285,10 +1295,20 @@ func (c *ctxt5) aclass(a *obj.Addr) int {
return C_LCONADDR
case obj.NAME_AUTO:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-SP.
a.Reg = obj.REG_NONE
}
c.instoffset = c.autosize + a.Offset
return c.aconsize()
case obj.NAME_PARAM:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-FP.
a.Reg = obj.REG_NONE
}
c.instoffset = c.autosize + a.Offset + 4
return c.aconsize()
}

View File

@@ -1149,10 +1149,20 @@ func (c *ctxt7) aclass(a *obj.Addr) int {
return C_GOTADDR
case obj.NAME_AUTO:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-SP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset
return autoclass(c.instoffset)
case obj.NAME_PARAM:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-FP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset + 8
return autoclass(c.instoffset)
@@ -1228,10 +1238,20 @@ func (c *ctxt7) aclass(a *obj.Addr) int {
return C_VCONADDR
case obj.NAME_AUTO:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-SP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset
goto aconsize
case obj.NAME_PARAM:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-FP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset + 8
goto aconsize
}

View File

@@ -556,6 +556,11 @@ func (c *ctxt0) aclass(a *obj.Addr) int {
return C_LEXT
case obj.NAME_AUTO:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-SP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset
if c.instoffset >= -BIG && c.instoffset < BIG {
return C_SAUTO
@@ -563,6 +568,11 @@ func (c *ctxt0) aclass(a *obj.Addr) int {
return C_LAUTO
case obj.NAME_PARAM:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-FP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset + c.ctxt.FixedFrameSize()
if c.instoffset >= -BIG && c.instoffset < BIG {
return C_SAUTO
@@ -616,6 +626,11 @@ func (c *ctxt0) aclass(a *obj.Addr) int {
return C_LECON
case obj.NAME_AUTO:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-SP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset
if c.instoffset >= -BIG && c.instoffset < BIG {
return C_SACON
@@ -623,6 +638,11 @@ func (c *ctxt0) aclass(a *obj.Addr) int {
return C_LACON
case obj.NAME_PARAM:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-FP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset + c.ctxt.FixedFrameSize()
if c.instoffset >= -BIG && c.instoffset < BIG {
return C_SACON

View File

@@ -758,6 +758,11 @@ func (c *ctxt9) aclass(a *obj.Addr) int {
return C_GOTADDR
case obj.NAME_AUTO:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-SP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset
if c.instoffset >= -BIG && c.instoffset < BIG {
return C_SAUTO
@@ -765,6 +770,11 @@ func (c *ctxt9) aclass(a *obj.Addr) int {
return C_LAUTO
case obj.NAME_PARAM:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-FP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset + c.ctxt.FixedFrameSize()
if c.instoffset >= -BIG && c.instoffset < BIG {
return C_SAUTO
@@ -817,6 +827,11 @@ func (c *ctxt9) aclass(a *obj.Addr) int {
return C_LCON
case obj.NAME_AUTO:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-SP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset
if c.instoffset >= -BIG && c.instoffset < BIG {
return C_SACON
@@ -824,6 +839,11 @@ func (c *ctxt9) aclass(a *obj.Addr) int {
return C_LACON
case obj.NAME_PARAM:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-FP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset + c.ctxt.FixedFrameSize()
if c.instoffset >= -BIG && c.instoffset < BIG {
return C_SACON

View File

@@ -505,6 +505,11 @@ func (c *ctxtz) aclass(a *obj.Addr) int {
return C_GOTADDR
case obj.NAME_AUTO:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-SP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset
if c.instoffset >= -BIG && c.instoffset < BIG {
return C_SAUTO
@@ -512,6 +517,11 @@ func (c *ctxtz) aclass(a *obj.Addr) int {
return C_LAUTO
case obj.NAME_PARAM:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-FP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset + c.ctxt.FixedFrameSize()
if c.instoffset >= -BIG && c.instoffset < BIG {
return C_SAUTO
@@ -567,6 +577,11 @@ func (c *ctxtz) aclass(a *obj.Addr) int {
return C_SYMADDR
case obj.NAME_AUTO:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-SP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset
if c.instoffset >= -BIG && c.instoffset < BIG {
return C_SACON
@@ -574,6 +589,11 @@ func (c *ctxtz) aclass(a *obj.Addr) int {
return C_LACON
case obj.NAME_PARAM:
if a.Reg == REGSP {
// unset base register for better printing, since
// a.Offset is still relative to pseudo-FP.
a.Reg = obj.REG_NONE
}
c.instoffset = int64(c.autosize) + a.Offset + c.ctxt.FixedFrameSize()
if c.instoffset >= -BIG && c.instoffset < BIG {
return C_SACON

View File

@@ -349,8 +349,9 @@ func doPackage(directory string, names []string, basePkg *Package) *Package {
pkg.files = files
// Type check the package.
err := pkg.check(fs, astFiles)
if err != nil && *verbose {
warnf("%s", err)
if err != nil {
// Note that we only report this error when *verbose.
Println(err)
}
// Check.

13
src/cmd/vet/testdata/cgo/cgo3.go vendored Normal file
View File

@@ -0,0 +1,13 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Used by TestVetVerbose to test that vet -v doesn't fail because it
// can't find "C".
package testdata
import "C"
func F() {
}

View File

@@ -205,3 +205,15 @@ func TestTags(t *testing.T) {
})
}
}
// Issue #21188.
func TestVetVerbose(t *testing.T) {
t.Parallel()
Build(t)
cmd := exec.Command("./"+binary, "-v", "-all", "testdata/cgo/cgo3.go")
out, err := cmd.CombinedOutput()
if err != nil {
t.Logf("%s", out)
t.Error(err)
}
}

View File

@@ -68,3 +68,94 @@ func ExampleByteOrder_get() {
// Output:
// 0x03e8 0x07d0
}
func ExamplePutUvarint() {
buf := make([]byte, binary.MaxVarintLen64)
for _, x := range []uint64{1, 2, 127, 128, 255, 256} {
n := binary.PutUvarint(buf, x)
fmt.Printf("%x\n", buf[:n])
}
// Output:
// 01
// 02
// 7f
// 8001
// ff01
// 8002
}
func ExamplePutVarint() {
buf := make([]byte, binary.MaxVarintLen64)
for _, x := range []int64{-65, -64, -2, -1, 0, 1, 2, 63, 64} {
n := binary.PutVarint(buf, x)
fmt.Printf("%x\n", buf[:n])
}
// Output:
// 8101
// 7f
// 03
// 01
// 00
// 02
// 04
// 7e
// 8001
}
func ExampleUvarint() {
inputs := [][]byte{
[]byte{0x01},
[]byte{0x02},
[]byte{0x7f},
[]byte{0x80, 0x01},
[]byte{0xff, 0x01},
[]byte{0x80, 0x02},
}
for _, b := range inputs {
x, n := binary.Uvarint(b)
if n != len(b) {
fmt.Println("Uvarint did not consume all of in")
}
fmt.Println(x)
}
// Output:
// 1
// 2
// 127
// 128
// 255
// 256
}
func ExampleVarint() {
inputs := [][]byte{
[]byte{0x81, 0x01},
[]byte{0x7f},
[]byte{0x03},
[]byte{0x01},
[]byte{0x00},
[]byte{0x02},
[]byte{0x04},
[]byte{0x7e},
[]byte{0x80, 0x01},
}
for _, b := range inputs {
x, n := binary.Varint(b)
if n != len(b) {
fmt.Println("Varint did not consume all of in")
}
fmt.Println(x)
}
// Output:
// -65
// -64
// -2
// -1
// 0
// 1
// 2
// 63
// 64
}

View File

@@ -969,14 +969,14 @@ func (*FuncDecl) declNode() {}
//
// For correct printing of source code containing comments (using packages
// go/format and go/printer), special care must be taken to update comments
// when a File's syntax tree is modified: For printing, comments are inter-
// spersed between tokens based on their position. If syntax tree nodes are
// when a File's syntax tree is modified: For printing, comments are interspersed
// between tokens based on their position. If syntax tree nodes are
// removed or moved, relevant comments in their vicinity must also be removed
// (from the File.Comments list) or moved accordingly (by updating their
// positions). A CommentMap may be used to facilitate some of these operations.
//
// Whether and how a comment is associated with a node depends on the inter-
// pretation of the syntax tree by the manipulating program: Except for Doc
// Whether and how a comment is associated with a node depends on the
// interpretation of the syntax tree by the manipulating program: Except for Doc
// and Comment comments directly associated with nodes, the remaining comments
// are "free-floating" (see also issues #18593, #20744).
//

View File

@@ -1707,8 +1707,8 @@ func (p *parser) parseSimpleStmt(mode int) (ast.Stmt, bool) {
}
// The label declaration typically starts at x[0].Pos(), but the label
// declaration may be erroneous due to a token after that position (and
// before the ':'). If SpuriousErrors is not set, the (only) error re-
// ported for the line is the illegal label error instead of the token
// before the ':'). If SpuriousErrors is not set, the (only) error
// reported for the line is the illegal label error instead of the token
// before the ':' that caused the problem. Thus, use the (latest) colon
// position for error reporting.
p.error(colon, "illegal label declaration")

View File

@@ -154,6 +154,10 @@ func (s *ioSrv) ProcessRemoteIO() {
// is available. Alternatively, it passes the request onto
// runtime netpoll and waits for completion or cancels request.
func (s *ioSrv) ExecIO(o *operation, submit func(o *operation) error) (int, error) {
if o.fd.pd.runtimeCtx == 0 {
return 0, errors.New("internal error: polling on unsupported descriptor type")
}
if !canCancelIO {
onceStartServer.Do(startServer)
}
@@ -315,8 +319,21 @@ func (fd *FD) Init(net string) (string, error) {
return "", errors.New("internal error: unknown network type " + net)
}
if err := fd.pd.init(fd); err != nil {
return "", err
if !fd.isFile && !fd.isConsole && !fd.isDir {
// Only call init for a network socket.
// This means that we don't add files to the runtime poller.
// Adding files to the runtime poller can confuse matters
// if the user is doing their own overlapped I/O.
// See issue #21172.
//
// In general the code below avoids calling the ExecIO
// method for non-network sockets. If some method does
// somehow call ExecIO, then ExecIO, and therefore the
// calling method, will return an error, because
// fd.pd.runtimeCtx will be 0.
if err := fd.pd.init(fd); err != nil {
return "", err
}
}
if hasLoadSetFileCompletionNotificationModes {
// We do not use events, so we can skip them always.

View File

@@ -40,8 +40,8 @@ func (z *Rat) Scan(s fmt.ScanState, ch rune) error {
// SetString sets z to the value of s and returns z and a boolean indicating
// success. s can be given as a fraction "a/b" or as a floating-point number
// optionally followed by an exponent. The entire string (not just a prefix)
// must be valid for success. If the operation failed, the value of z is un-
// defined but the returned value is nil.
// must be valid for success. If the operation failed, the value of z is
// undefined but the returned value is nil.
func (z *Rat) SetString(s string) (*Rat, bool) {
if len(s) == 0 {
return nil, false

View File

@@ -36,3 +36,43 @@ func ExampleLeadingZeros64() {
// 64
// 63
}
func ExampleOnesCount() {
fmt.Printf("%b\n", 14)
fmt.Println(bits.OnesCount(14))
// Output:
// 1110
// 3
}
func ExampleOnesCount8() {
fmt.Printf("%b\n", 14)
fmt.Println(bits.OnesCount8(14))
// Output:
// 1110
// 3
}
func ExampleOnesCount16() {
fmt.Printf("%b\n", 14)
fmt.Println(bits.OnesCount16(14))
// Output:
// 1110
// 3
}
func ExampleOnesCount32() {
fmt.Printf("%b\n", 14)
fmt.Println(bits.OnesCount32(14))
// Output:
// 1110
// 3
}
func ExampleOnesCount64() {
fmt.Printf("%b\n", 14)
fmt.Println(bits.OnesCount64(14))
// Output:
// 1110
// 3
}

View File

@@ -4,8 +4,6 @@
// Package plugin implements loading and symbol resolution of Go plugins.
//
// Currently plugins only work on Linux.
//
// A plugin is a Go main package with exported functions and variables that
// has been built with:
//
@@ -14,6 +12,9 @@
// When a plugin is first opened, the init functions of all packages not
// already part of the program are called. The main function is not run.
// A plugin is only initialized once, and cannot be closed.
//
// The plugin support is currently incomplete, only supports Linux,
// and has known bugs. Please report any issues.
package plugin
// Plugin is a loaded Go plugin.

View File

@@ -178,6 +178,12 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool, depth int) bool {
// DeepEqual has been defined so that the same short-cut applies
// to slices and maps: if x and y are the same slice or the same map,
// they are deeply equal regardless of content.
//
// As DeepEqual traverses the data values it may find a cycle. The
// second and subsequent times that DeepEqual compares two pointer
// values that have been compared before, it treats the values as
// equal rather than examining the values to which they point.
// This ensures that DeepEqual terminates.
func DeepEqual(x, y interface{}) bool {
if x == nil || y == nil {
return x == y

View File

@@ -163,6 +163,15 @@ func (p *cpuProfile) addExtra() {
}
}
func (p *cpuProfile) addLostAtomic64(count uint64) {
hdr := [1]uint64{count}
lostStk := [2]uintptr{
funcPC(_LostSIGPROFDuringAtomic64) + sys.PCQuantum,
funcPC(_System) + sys.PCQuantum,
}
cpuprof.log.write(nil, 0, hdr[:], lostStk[:])
}
// CPUProfile panics.
// It formerly provided raw access to chunks of
// a pprof-format profile generated by the runtime.

View File

@@ -495,7 +495,7 @@ again:
}
// store new key/value at insert position
*((*uint32)(insertk)) = key
typedmemmove(t.key, insertk, unsafe.Pointer(&key))
*inserti = top
h.count++
@@ -583,7 +583,7 @@ again:
}
// store new key/value at insert position
*((*uint64)(insertk)) = key
typedmemmove(t.key, insertk, unsafe.Pointer(&key))
*inserti = top
h.count++
@@ -723,7 +723,7 @@ func mapdelete_fast32(t *maptype, h *hmap, key uint32) {
if key != *k {
continue
}
*k = 0
typedmemclr(t.key, unsafe.Pointer(k))
v := unsafe.Pointer(uintptr(unsafe.Pointer(b)) + dataOffset + bucketCnt*4 + i*uintptr(t.valuesize))
typedmemclr(t.elem, v)
b.tophash[i] = empty
@@ -778,7 +778,7 @@ func mapdelete_fast64(t *maptype, h *hmap, key uint64) {
if key != *k {
continue
}
*k = 0
typedmemclr(t.key, unsafe.Pointer(k))
v := unsafe.Pointer(uintptr(unsafe.Pointer(b)) + dataOffset + bucketCnt*8 + i*uintptr(t.valuesize))
typedmemclr(t.elem, v)
b.tophash[i] = empty

View File

@@ -416,7 +416,10 @@ func (h *mheap) sysAlloc(n uintptr) unsafe.Pointer {
var reserved bool
p := uintptr(sysReserve(unsafe.Pointer(h.arena_end), p_size, &reserved))
if p == 0 {
return nil
// TODO: Try smaller reservation
// growths in case we're in a crowded
// 32-bit address space.
goto reservationFailed
}
// p can be just about anywhere in the address
// space, including before arena_end.
@@ -476,6 +479,7 @@ func (h *mheap) sysAlloc(n uintptr) unsafe.Pointer {
return unsafe.Pointer(p)
}
reservationFailed:
// If using 64-bit, our reservation is all we have.
if sys.PtrSize != 4 {
return nil

View File

@@ -503,6 +503,11 @@ func (h *mheap) init(spansStart, spansBytes uintptr) {
sp.array = unsafe.Pointer(spansStart)
sp.len = 0
sp.cap = int(spansBytes / sys.PtrSize)
// Map metadata structures. But don't map race detector memory
// since we're not actually growing the arena here (and TSAN
// gets mad if you map 0 bytes).
h.setArenaUsed(h.arena_used, false)
}
// setArenaUsed extends the usable arena to address arena_used and

View File

@@ -12,6 +12,7 @@ import (
"fmt"
"internal/testenv"
"io"
"io/ioutil"
"math/big"
"os"
"os/exec"
@@ -20,11 +21,12 @@ import (
"runtime/pprof/internal/profile"
"strings"
"sync"
"sync/atomic"
"testing"
"time"
)
func cpuHogger(f func(), dur time.Duration) {
func cpuHogger(f func() int, dur time.Duration) {
// We only need to get one 100 Hz clock tick, so we've got
// a large safety buffer.
// But do at least 500 iterations (which should take about 100ms),
@@ -44,7 +46,7 @@ var (
// The actual CPU hogging function.
// Must not call other functions nor access heap/globals in the loop,
// otherwise under race detector the samples will be in the race runtime.
func cpuHog1() {
func cpuHog1() int {
foo := salt1
for i := 0; i < 1e5; i++ {
if foo > 0 {
@@ -53,10 +55,10 @@ func cpuHog1() {
foo *= foo + 1
}
}
salt1 = foo
return foo
}
func cpuHog2() {
func cpuHog2() int {
foo := salt2
for i := 0; i < 1e5; i++ {
if foo > 0 {
@@ -65,7 +67,7 @@ func cpuHog2() {
foo *= foo + 2
}
}
salt2 = foo
return foo
}
func TestCPUProfile(t *testing.T) {
@@ -93,8 +95,9 @@ func TestCPUProfileInlining(t *testing.T) {
})
}
func inlinedCaller() {
func inlinedCaller() int {
inlinedCallee()
return 0
}
func inlinedCallee() {
@@ -713,3 +716,54 @@ func TestCPUProfileLabel(t *testing.T) {
})
})
}
func TestLabelRace(t *testing.T) {
// Test the race detector annotations for synchronization
// between settings labels and consuming them from the
// profile.
testCPUProfile(t, []string{"runtime/pprof.cpuHogger;key=value"}, func(dur time.Duration) {
start := time.Now()
var wg sync.WaitGroup
for time.Since(start) < dur {
for i := 0; i < 10; i++ {
wg.Add(1)
go func() {
Do(context.Background(), Labels("key", "value"), func(context.Context) {
cpuHogger(cpuHog1, time.Millisecond)
})
wg.Done()
}()
}
wg.Wait()
}
})
}
// Check that there is no deadlock when the program receives SIGPROF while in
// 64bit atomics' critical section. Used to happen on mips{,le}. See #20146.
func TestAtomicLoadStore64(t *testing.T) {
f, err := ioutil.TempFile("", "profatomic")
if err != nil {
t.Fatalf("TempFile: %v", err)
}
defer os.Remove(f.Name())
defer f.Close()
if err := StartCPUProfile(f); err != nil {
t.Fatal(err)
}
defer StopCPUProfile()
var flag uint64
done := make(chan bool, 1)
go func() {
for atomic.LoadUint64(&flag) == 0 {
runtime.Gosched()
}
done <- true
}()
time.Sleep(50 * time.Millisecond)
atomic.StoreUint64(&flag, 1)
<-done
}

View File

@@ -3232,10 +3232,14 @@ var prof struct {
hz int32
}
func _System() { _System() }
func _ExternalCode() { _ExternalCode() }
func _LostExternalCode() { _LostExternalCode() }
func _GC() { _GC() }
func _System() { _System() }
func _ExternalCode() { _ExternalCode() }
func _LostExternalCode() { _LostExternalCode() }
func _GC() { _GC() }
func _LostSIGPROFDuringAtomic64() { _LostSIGPROFDuringAtomic64() }
// Counts SIGPROFs received while in atomic64 critical section, on mips{,le}
var lostAtomic64Count uint64
// Called if we receive a SIGPROF signal.
// Called by the signal handler, may run during STW.
@@ -3245,6 +3249,21 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) {
return
}
// On mips{,le}, 64bit atomics are emulated with spinlocks, in
// runtime/internal/atomic. If SIGPROF arrives while the program is inside
// the critical section, it creates a deadlock (when writing the sample).
// As a workaround, create a counter of SIGPROFs while in critical section
// to store the count, and pass it to sigprof.add() later when SIGPROF is
// received from somewhere else (with _LostSIGPROFDuringAtomic64 as pc).
if GOARCH == "mips" || GOARCH == "mipsle" {
if f := findfunc(pc); f.valid() {
if hasprefix(funcname(f), "runtime/internal/atomic") {
lostAtomic64Count++
return
}
}
}
// Profiling runs concurrently with GC, so it must not allocate.
// Set a trap in case the code does allocate.
// Note that on windows, one thread takes profiles of all the
@@ -3371,6 +3390,10 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) {
}
if prof.hz != 0 {
if (GOARCH == "mips" || GOARCH == "mipsle") && lostAtomic64Count > 0 {
cpuprof.addLostAtomic64(lostAtomic64Count)
lostAtomic64Count = 0
}
cpuprof.add(gp, stk[:n])
}
getg().m.mallocing--

View File

@@ -545,7 +545,7 @@ Read:
b.rNext = br.addCountsAndClearFlags(skip+di, ti)
if raceenabled {
// Match racewritepc in runtime_setProfLabel,
// Match racereleasemerge in runtime_setProfLabel,
// so that the setting of the labels in runtime_setProfLabel
// is treated as happening before any use of the labels
// by our caller. The synchronization on labelSync itself is a fiction

View File

@@ -13,8 +13,23 @@ func runtime_setProfLabel(labels unsafe.Pointer) {
// Introduce race edge for read-back via profile.
// This would more properly use &getg().labels as the sync address,
// but we do the read in a signal handler and can't call the race runtime then.
//
// This uses racereleasemerge rather than just racerelease so
// the acquire in profBuf.read synchronizes with *all* prior
// setProfLabel operations, not just the most recent one. This
// is important because profBuf.read will observe different
// labels set by different setProfLabel operations on
// different goroutines, so it needs to synchronize with all
// of them (this wouldn't be an issue if we could synchronize
// on &getg().labels since we would synchronize with each
// most-recent labels write separately.)
//
// racereleasemerge is like a full read-modify-write on
// labelSync, rather than just a store-release, so it carries
// a dependency on the previous racereleasemerge, which
// ultimately carries forward to the acquire in profBuf.read.
if raceenabled {
racerelease(unsafe.Pointer(&labelSync))
racereleasemerge(unsafe.Pointer(&labelSync))
}
getg().labels = labels
}

View File

@@ -259,4 +259,25 @@ Goroutine [0-9] \(running\) created at:
runtime\.newextram\(\)
.*/runtime/proc.go:[0-9]+ \+0x[0-9,a-f]+
==================`},
{"second_test_passes", "test", "", "atexit_sleep_ms=0", `
package main_test
import "testing"
func TestFail(t *testing.T) {
done := make(chan bool)
x := 0
go func() {
x = 42
done <- true
}()
x = 43
<-done
}
func TestPass(t *testing.T) {
}
`, `
==================
--- FAIL: TestFail \(0...s\)
.*testing.go:.*: race detected during execution of test
FAIL`},
}

View File

@@ -409,6 +409,11 @@ var modulesSlice unsafe.Pointer // see activeModules
//
// A module is active once its gcdatamask and gcbssmask have been
// assembled and it is usable by the GC.
//
// This is nosplit/nowritebarrier because it is called by the
// cgo pointer checking code.
//go:nosplit
//go:nowritebarrier
func activeModules() []*moduledata {
p := (*[]*moduledata)(atomic.Loadp(unsafe.Pointer(&modulesSlice)))
if p == nil {

View File

@@ -100,7 +100,7 @@ TEXT runtime·usleep(SB),NOSPLIT,$8
MOVL AX, 0(SP)
MOVL $1000, AX // usec to nsec
MULL DX
MOVL DX, 4(SP)
MOVL AX, 4(SP)
// pselect6(0, 0, 0, 0, &ts, 0)
MOVL $308, AX

View File

@@ -695,8 +695,7 @@ func tRunner(t *T, fn func(t *T)) {
// a call to runtime.Goexit, record the duration and send
// a signal saying that the test is done.
defer func() {
t.raceErrors += race.Errors()
if t.raceErrors > 0 {
if t.raceErrors+race.Errors() > 0 {
t.Errorf("race detected during execution of test")
}
@@ -970,7 +969,7 @@ func listTests(matchString func(pat, str string) (bool, error), tests []Internal
}
}
for _, example := range examples {
if ok, _ := matchString(*matchList, example.Name); ok && example.Output != "" {
if ok, _ := matchString(*matchList, example.Name); ok {
fmt.Println(example.Name)
}
}

View File

@@ -14,6 +14,14 @@ func testZoneAbbr(t *testing.T) {
t1 := Now()
// discard nsec
t1 = Date(t1.Year(), t1.Month(), t1.Day(), t1.Hour(), t1.Minute(), t1.Second(), 0, t1.Location())
// Skip the test if we're in a timezone with no abbreviation.
// Format will fallback to the numeric abbreviation, and
// Parse(RFC1123, ..) will fail (see Issue 21183).
if tz := t1.Format("MST"); tz[0] == '-' || tz[0] == '+' {
t.Skip("No zone abbreviation")
}
t2, err := Parse(RFC1123, t1.Format(RFC1123))
if err != nil {
t.Fatalf("Parse failed: %v", err)

15
test/README.md Normal file
View File

@@ -0,0 +1,15 @@
The test directory contains tests of the Go tool chain and runtime.
It includes black box tests, regression tests, and error output tests.
They are run as part of all.bash.
To run just these tests, execute:
go run run.go
Standard library tests should be written as regular Go tests in the appropriate package.
The tool chain and runtime also have regular Go tests in their packages.
The main reasons to add a new test to this directory are:
* it is most naturally expressed using the test runner; or
* it is also applicable to `gccgo` and other Go tool chains.