1
0
mirror of https://github.com/golang/go synced 2024-11-08 19:46:23 -07:00
Commit Graph

33586 Commits

Author SHA1 Message Date
Lyle Franklin
a35377515f strings: add Examples for TrimFunc and variants during Gophercon!
Change-Id: I6bfe5b914cf11be1cd1f8e61d557cc718725f0be
Reviewed-on: https://go-review.googlesource.com/49013
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-08 14:26:13 +00:00
Alberto Donizetti
d3c0af7a0a cmd/compile: fix ADDSDmem comment and order in list
ADDSDmem comment said f32 (likely a copy-paste mistake).

Also swap ADDSSmem and ADDSDmem positions in the list to uniform the
list order.

Fixes #21225

Change-Id: I26bb116900c1cf4c4e6faeef613d7318c9c85b98
Reviewed-on: https://go-review.googlesource.com/52071
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-08-08 09:21:25 +00:00
Jelte Fennema
403ae5081a math: change oeis.org urls to https
Regular HTTP is insecure, oeis.org supports HTTPS and it is actually
used in some other places in the codebase. This changes these final urls
to use HTTPS.

Change-Id: Ia46410a9c7ce67238a10cb6bfffaceca46112f58
Reviewed-on: https://go-review.googlesource.com/52072
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
2017-08-08 08:56:40 +00:00
David du Colombier
bd3dc9d6da net: fix LookupCNAME on Plan 9
Looking up a nonexistent CNAME record on an existing
domain on Plan 9 can return either a "dns failure"
error or a "resource does not exist" error.

Fixes #21335.

Change-Id: Iead8ed4fe3167db06adb4ab7797c52c7efc3ff89
Reviewed-on: https://go-review.googlesource.com/53670
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Avelino <t@avelino.xxx>
2017-08-08 08:00:09 +00:00
Martin Möhrmann
e0e7c03d14 runtime, internal/cpu: change cache line size for arm64 to 64 bytes
According to http://infocenter.arm.com:
* ARM Cortex-A53 (Raspberry Pi 3, Pine A64)
* ARM Cortex-A57 (Opteron A1100, Tegra X1)
* ARM Cortex-A72
all have a cache line size of 64 bytes.

Change-Id: I4b333e930792fb1a221b3ca6f395bfa1b7762afa
Reviewed-on: https://go-review.googlesource.com/43250
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-08-08 06:49:49 +00:00
Martin Möhrmann
7045e6f6c4 runtime: remove unused prefetch functions
The only non test user of the assembler prefetch functions is the
heapBits.prefetch function which is itself unused.

The runtime prefetch functions have no functionality on most platforms
and are not inlineable since they are written in assembler. The function
call overhead eliminates the performance gains that could be achieved with
prefetching and would degrade performance for platforms where the functions
are no-ops.

If prefetch functions are needed back again later they can be improved
by avoiding the function call overhead and implementing them as intrinsics.

Change-Id: I52c553cf3607ffe09f0441c6e7a0a818cb21117d
Reviewed-on: https://go-review.googlesource.com/44370
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-08 06:43:49 +00:00
Dmitri Shuralyov
fd29d03f70 net/http: set Content-Type header in Redirect
Setting the Content-Type header explicitly allows browsers to know what
the type of the content is. Otherwise, they have to guess the type from
the content itself, which could lead to unpredictable behavior, and
increases CPU usage.

Not setting the Content-Type despite writing a body may also trigger
unwanted warnings in user middleware, and make it more difficult to
resolve valid issues where the user forgets to set Content-Type in
some situations where it should be set.

There is some precedent for doing this in http.FileServer, which
sets "Content-Type" to "text/html; charset=utf-8" before writing
<pre><a href=...></a></pre> HTML.

Change-Id: I24286827bebf4da8adee9238b8c5a94d4069c8db
Reviewed-on: https://go-review.googlesource.com/50510
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-08 06:09:59 +00:00
Ian Lance Taylor
c3c2e453c9 cmd/cgo: document that structs and arrays don't work with //export
Fixes #18412

Change-Id: Ib457eeced7820517aa35df9e7dfda1c0de4ac004
Reviewed-on: https://go-review.googlesource.com/52852
Reviewed-by: Avelino <t@avelino.xxx>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-08 04:39:05 +00:00
Ian Lance Taylor
4fa2674aa7 misc/cgo/errors: update ptr.go comment
Accidentally omitted from submit of CL 53352.

Updates #21306

Change-Id: I022d89c6417fe9371856d49b646eb6294b91657c
Reviewed-on: https://go-review.googlesource.com/53415
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Avelino <t@avelino.xxx>
2017-08-08 04:31:40 +00:00
Dmitri Shuralyov
c4e29bbd38 encoding/json: de-indent raw strings in remaining examples
This change fixes the remaining examples where the raw strings had
suboptimal indentation (one level too many) when viewed in godoc.

Follows CL 48910.
Fixes #21026.

Change-Id: Ifc0dae3fa899a9fff8b1ff958414e2fe6852321d
Reviewed-on: https://go-review.googlesource.com/50990
Run-TryBot: Dmitri Shuralyov <shurcool@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-08 04:30:58 +00:00
Seiji Takahashi
6dae588a06 html: updated entity spec link
Fixes #21194

Change-Id: Iac5187335df67f90f0f47c7ef6574de147c2ac9b
Reviewed-on: https://go-review.googlesource.com/52970
Reviewed-by: Avelino <t@avelino.xxx>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-08 04:29:35 +00:00
Martin Möhrmann
c4ee0e2a8b internal/cpu: fix style nit in variable name
Consistent with similar change of style in the crypto repository:
http://golang.org/cl/43511

Change-Id: Ib158c52a2649dcbbe9eb92f2bdb9d289e0dcc7bf
Reviewed-on: https://go-review.googlesource.com/53474
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Reviewed-by: Avelino <t@avelino.xxx>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-08 04:11:36 +00:00
Brad Fitzpatrick
e1f38ccab1 flag: make default Usage prefer CommandLine's output over just os.Stderr
CommandLine (exported in Go 1.2) has default output of os.Stderr.

Before it was exported, it made sense to have the global Usage func
(the implicit usage func if CommandLine.Usage is nil) hard-code
os.Stderr has its output. But once CommandLine was exported, Usage
should use it if provided.

Fixes #20998

Change-Id: I9e1c0415a563a982634b9808199c9ee175d72f4c
Reviewed-on: https://go-review.googlesource.com/48390
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2017-08-08 01:47:47 +00: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
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
Heschi Kreinick
4c54a047c6 [dev.debug] cmd/compile: better DWARF with optimizations on
Debuggers use DWARF information to find local variables on the
stack and in registers. Prior to this CL, the DWARF information for
functions claimed that all variables were on the stack at all times.
That's incorrect when optimizations are enabled, and results in
debuggers showing data that is out of date or complete gibberish.

After this CL, the compiler is capable of representing variable
locations more accurately, and attempts to do so. Due to limitations of
the SSA backend, it's not possible to be completely correct.

There are a number of problems in the current design. One of the easier
to understand is that variable names currently must be attached to an
SSA value, but not all assignments in the source code actually result
in machine code. For example:

  type myint int
  var a int
  b := myint(int)
and
  b := (*uint64)(unsafe.Pointer(a))

don't generate machine code because the underlying representation is the
same, so the correct value of b will not be set when the user would
expect.

Generating the more precise debug information is behind a flag,
dwarflocationlists. Because of the issues described above, setting the
flag may not make the debugging experience much better, and may actually
make it worse in cases where the variable actually is on the stack and
the more complicated analysis doesn't realize it.

A number of changes are included:
- Add a new pseudo-instruction, RegKill, which indicates that the value
in the register has been clobbered.
- Adjust regalloc to emit RegKills in the right places. Significantly,
this means that phis are mixed with StoreReg and RegKills after
regalloc.
- Track variable decomposition in ssa.LocalSlots.
- After the SSA backend is done, analyze the result and build location
lists for each LocalSlot.
- After assembly is done, update the location lists with the assembled
PC offsets, recompose variables, and build DWARF location lists. Emit the
list as a new linker symbol, one per function.
- In the linker, aggregate the location lists into a .debug_loc section.

TODO:
- currently disabled for non-X86/AMD64 because there are no data tables.

go build -toolexec 'toolstash -cmp' -a std succeeds.

With -dwarflocationlists false:
before: f02812195637909ff675782c0b46836a8ff01976
after:  06f61e8112a42ac34fb80e0c818b3cdb84a5e7ec
benchstat -geomean  /tmp/220352263 /tmp/621364410
completed   15 of   15, estimated time remaining 0s (eta 3:52PM)
name        old time/op       new time/op       delta
Template          199ms ± 3%        198ms ± 2%     ~     (p=0.400 n=15+14)
Unicode          96.6ms ± 5%       96.4ms ± 5%     ~     (p=0.838 n=15+15)
GoTypes           653ms ± 2%        647ms ± 2%     ~     (p=0.102 n=15+14)
Flate             133ms ± 6%        129ms ± 3%   -2.62%  (p=0.041 n=15+15)
GoParser          164ms ± 5%        159ms ± 3%   -3.05%  (p=0.000 n=15+15)
Reflect           428ms ± 4%        422ms ± 3%     ~     (p=0.156 n=15+13)
Tar               123ms ±10%        124ms ± 8%     ~     (p=0.461 n=15+15)
XML               228ms ± 3%        224ms ± 3%   -1.57%  (p=0.045 n=15+15)
[Geo mean]        206ms             377ms       +82.86%

name        old user-time/op  new user-time/op  delta
Template          292ms ±10%        301ms ±12%     ~     (p=0.189 n=15+15)
Unicode           166ms ±37%        158ms ±14%     ~     (p=0.418 n=15+14)
GoTypes           962ms ± 6%        963ms ± 7%     ~     (p=0.976 n=15+15)
Flate             207ms ±19%        200ms ±14%     ~     (p=0.345 n=14+15)
GoParser          246ms ±22%        240ms ±15%     ~     (p=0.587 n=15+15)
Reflect           611ms ±13%        587ms ±14%     ~     (p=0.085 n=15+13)
Tar               211ms ±12%        217ms ±14%     ~     (p=0.355 n=14+15)
XML               335ms ±15%        320ms ±18%     ~     (p=0.169 n=15+15)
[Geo mean]        317ms             583ms       +83.72%

name        old alloc/op      new alloc/op      delta
Template         40.2MB ± 0%       40.2MB ± 0%   -0.15%  (p=0.000 n=14+15)
Unicode          29.2MB ± 0%       29.3MB ± 0%     ~     (p=0.624 n=15+15)
GoTypes           114MB ± 0%        114MB ± 0%   -0.15%  (p=0.000 n=15+14)
Flate            25.7MB ± 0%       25.6MB ± 0%   -0.18%  (p=0.000 n=13+15)
GoParser         32.2MB ± 0%       32.2MB ± 0%   -0.14%  (p=0.003 n=15+15)
Reflect          77.8MB ± 0%       77.9MB ± 0%     ~     (p=0.061 n=15+15)
Tar              27.1MB ± 0%       27.0MB ± 0%   -0.11%  (p=0.029 n=15+15)
XML              42.7MB ± 0%       42.5MB ± 0%   -0.29%  (p=0.000 n=15+15)
[Geo mean]       42.1MB            75.0MB       +78.05%

name        old allocs/op     new allocs/op     delta
Template           402k ± 1%         398k ± 0%   -0.91%  (p=0.000 n=15+15)
Unicode            344k ± 1%         344k ± 0%     ~     (p=0.715 n=15+14)
GoTypes           1.18M ± 0%        1.17M ± 0%   -0.91%  (p=0.000 n=15+14)
Flate              243k ± 0%         240k ± 1%   -1.05%  (p=0.000 n=13+15)
GoParser           327k ± 1%         324k ± 1%   -0.96%  (p=0.000 n=15+15)
Reflect            984k ± 1%         982k ± 0%     ~     (p=0.050 n=15+15)
Tar                261k ± 1%         259k ± 1%   -0.77%  (p=0.000 n=15+15)
XML                411k ± 0%         404k ± 1%   -1.55%  (p=0.000 n=15+15)
[Geo mean]         439k              755k       +72.01%

name        old text-bytes    new text-bytes    delta
HelloSize         694kB ± 0%        694kB ± 0%   -0.00%  (p=0.000 n=15+15)

name        old data-bytes    new data-bytes    delta
HelloSize        5.55kB ± 0%       5.55kB ± 0%     ~     (all equal)

name        old bss-bytes     new bss-bytes     delta
HelloSize         133kB ± 0%        133kB ± 0%     ~     (all equal)

name        old exe-bytes     new exe-bytes     delta
HelloSize        1.04MB ± 0%       1.04MB ± 0%     ~     (all equal)

Change-Id: I991fc553ef175db46bb23b2128317bbd48de70d8
Reviewed-on: https://go-review.googlesource.com/41770
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-07-27 20:19:44 +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
Heschi Kreinick
cd702b171c [dev.debug] cmd/internal/dwarf: add DWARF abbrevs with location lists
Location lists require new DWARF abbrev entries. Add them before
CL 41770 to enable binary comparison.

Change-Id: If99461f6896db902f2774e0718065eb3d3522026
Reviewed-on: https://go-review.googlesource.com/50881
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-07-26 18:39:57 +00:00
Heschi Kreinick
59fe2fbfe5 [dev.debug] cmd/link: let the linker combine .debug_ranges, remove globals
The linker is pretty good at combining a bunch of symbols into a
section, so let it do .debug_ranges the normal way. Along the way,
remove a bunch of globals that were only used by one function that would
only be called once per invocation.

Change-Id: I1a528a438b193c41e7c444e8830516b07f11affc
Reviewed-on: https://go-review.googlesource.com/43890
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-07-26 18:39:50 +00:00
Heschi Kreinick
2d57d94ac3 [dev.debug] cmd/compile: track variable decomposition in LocalSlot
When the compiler decomposes a user variable, track its origin so that
it can be recomposed during DWARF generation.

Change-Id: Ia71c7f8e7f4d65f0652f1c97b0dda5d9cad41936
Reviewed-on: https://go-review.googlesource.com/50878
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-07-26 18:39:39 +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