Commit graph

39145 commits

Author SHA1 Message Date
Cherry Zhang 7e987b7b33 reflect: eliminate write barrier for copying result in callReflect
We are copying the results to uninitialized stack space. Write
barrier is not needed.

Fixes #30041.

Change-Id: Ia91d74dbafd96dc2bd92de0cb479808991dda03e
Reviewed-on: https://go-review.googlesource.com/c/160737
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2019-02-01 19:23:02 +00:00
Ian Lance Taylor 03a9f5a192 doc: go1.12: update notes on go directive
Fixes #30043

Change-Id: I4ecfff7d8a9432240c1927f7484786fe1182b773
Reviewed-on: https://go-review.googlesource.com/c/160797
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-01 15:26:48 +00:00
Yuval Pavel Zholkover 6f4dc1ccf9 cmd/cgo: ignore unrecognized GCC warning group pragmas
CL 159859 causes build failure with old clang versions (3.4.1) on FreeBSD 10.3/10.4.

Update #29962
Update #27619

Change-Id: I78264ac5d8d17eeae89a982e89aac988eb22b286
Reviewed-on: https://go-review.googlesource.com/c/160777
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-02-01 14:34:33 +00:00
Michael Anthony Knyszek faf187fb8e runtime: add credit system for scavenging
When scavenging small amounts it's possible we over-scavenge by a
significant margin since we choose to scavenge the largest spans first.
This over-scavenging is never accounted for.

With this change, we add a scavenge credit pool, similar to the reclaim
credit pool. Any time scavenging triggered by RSS growth starts up, it
checks if it can cash in some credit first. If after using all the
credit it still needs to scavenge, then any extra it does it adds back
into the credit pool.

This change mitigates the performance impact of golang.org/cl/159500 on
the Garbage benchmark. On Go1 it suggests some improvements, but most of
that is within the realm of noise (Revcomp seems very sensitive to
GC-related changes, both postively and negatively).

Garbage: https://perf.golang.org/search?q=upload:20190131.5
Go1:     https://perf.golang.org/search?q=upload:20190131.4

Performance change with both changes:

Garbage: https://perf.golang.org/search?q=upload:20190131.7
Go1:     https://perf.golang.org/search?q=upload:20190131.6

Change-Id: I87bd3c183e71656fdafef94714194b9fdbb77aa2
Reviewed-on: https://go-review.googlesource.com/c/160297
Reviewed-by: Austin Clements <austin@google.com>
2019-01-31 16:55:43 +00:00
Michael Anthony Knyszek 8e093e7a1c runtime: scavenge memory upon allocating from scavenged memory
Because scavenged and unscavenged spans no longer coalesce, memory that
is freed no longer has a high likelihood of being re-scavenged. As a
result, if an application is allocating at a fast rate, it may work fast
enough to undo all the scavenging work performed by the runtime's
current scavenging mechanisms. This behavior is exacerbated by the
global best-fit allocation policy the runtime uses, since scavenged
spans are just as likely to be chosen as unscavenged spans on average.

To remedy that, we treat each allocation of scavenged space as a heap
growth, and scavenge other memory to make up for the allocation.

This change makes performance of the runtime slightly worse, as now
we're scavenging more often during allocation. The regression is
particularly obvious with the garbage benchmark (3%) but most of the Go1
benchmarks are within the margin of noise. A follow-up change should
help.

Garbage: https://perf.golang.org/search?q=upload:20190131.3
Go1:     https://perf.golang.org/search?q=upload:20190131.2

Updates #14045.

Change-Id: I44a7e6586eca33b5f97b6d40418db53a8a7ae715
Reviewed-on: https://go-review.googlesource.com/c/159500
Reviewed-by: Austin Clements <austin@google.com>
2019-01-31 16:54:41 +00:00
Ian Lance Taylor f2a416b90a cmd/cgo: disable GCC 9 warnings triggered by cgo code
GCC 9 has started emitting warnings when taking the address of a field
in a packed struct may cause a misaligned pointer. We use packed
structs in cgo to ensure that our field layout matches the C
compiler's layout. Our pointers are always aligned, so disable the warning

Fixes #29962

Change-Id: I7e290a7cf694a2c2958529e340ebed9fcd62089c
Reviewed-on: https://go-review.googlesource.com/c/159859
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-01-30 22:25:36 +00:00
Dmitri Shuralyov 737695231d CONTRIBUTORS: second round of updates for Go 1.12
This update has been automatically generated using the updatecontrib
command at CL 160277:

	cd gotip
	go run golang.org/x/build/cmd/updatecontrib

Actions taken (relative to CONTRIBUTORS at origin/master):

	Added Aaron Cannon <cannona@fireantproductions.com>
	Added Andzej Maciusovic <andzej.maciusovic@gmail.com>
	Added Douglas Danger Manley <doug.manley@gmail.com>
	Added Federico Bond <federicobond@gmail.com>
	Added Frew Schmidt <github@frew.co>
	Added GitHub User @saitarunreddy (21041941) <saitarunreddypalla@gmail.com>
	Added GitHub User @tell-k (26263) <ffk2005@gmail.com>
	Added Guilherme Caruso <gui.martinscaruso@gmail.com>
	Added Jay Taylor <outtatime@gmail.com>
	Added Juan Pablo Civile <elementohb@gmail.com>
	Added Julien Kauffmann <julien.kauffmann@freelan.org>
	Added Maya Rashish <maya@NetBSD.org>
	Added Parminder Singh <parmsingh101@gmail.com>
	Added Peter Dotchev <dotchev@gmail.com>
	Added Quinten Yearsley <qyearsley@chromium.org>
	Added Ross Smith II <ross@smithii.com>
	Added Sean Chen <oohcode@gmail.com>
	Added Sebastiaan van Stijn <github@gone.nl>
	Added Sebastian Schmidt <yath@google.com>
	Added Sebastien Williams-Wynn <sebastien@cytora.com>
	Added Viacheslav Poturaev <vearutop@gmail.com>
	Added Yohei Takeda <yo.tak0812@gmail.com>
	Used GitHub User @saitarunreddy (21041941) form for saitarunreddy <saitarunreddypalla@gmail.com> https://github.com/golang/build/commit/269e03a [build]
	Used GitHub User @tell-k (26263) form for tell-k <ffk2005@gmail.com> https://github.com/golang/tools/commit/85a87a81 [tools]
	Used GitHub name "Akhil Indurti" for smasher164 <aindurti@gmail.com> https://github.com/golang/go/commit/a7af474359 [build go]
	Used GitHub name "Guilherme Caruso" for GuilhermeCaruso <gui.martinscaruso@gmail.com> https://github.com/golang/go/commit/5fae09b738 [go]
	Used GitHub name "Ivan Markin" for nogoegst <nogoegst@users.noreply.github.com> https://github.com/golang/go/commit/a1addf15df [go]
	Used GitHub name "Keiji Yoshida" for yosssi <yoshida.keiji.84@gmail.com> https://github.com/golang/lint/commit/ac6833c [lint]
	Used GitHub name "Marwan Sulaiman" for marwan-at-work <marwan.sameer@gmail.com> https://github.com/golang/go/commit/92caeef892 [go]
	Used GitHub name "Michalis Kargakis" for kargakis <mkargaki@redhat.com> https://github.com/golang/go/commit/e243d242d7 [go]
	Used GitHub name "Robin Eklind" for mewmew <rnd0x00@gmail.com> https://github.com/golang/go/commit/b8620afb8d [go proposal.git]
	Used GitHub name "Sean Chen" for two <oohcode@gmail.com> https://github.com/golang/sys/commit/302c3dd [sys]
	Used GitHub name "Sebastien Williams-Wynn" for GiantsLoveDeathMetal <sebastien@cytora.com> https://github.com/golang/go/commit/4e056ade24 [go]
	Used GitHub name "Yohei Takeda" for yo-tak <yo.tak0812@gmail.com> https://github.com/golang/go/commit/8b7cf898af [go]

Given that the scope of updatecontrib is only to add contributors to
CONTRIBUTORS file, without having to check CLAs or deal with legal
matters, we can relax the requirement of having a space in the name
before it gets added to the CONTRIBUTORS file. That will be done
in a later change.

Updates #12042

Change-Id: I70248f3c82a836ee829256898e931e638ee45eb4
Reviewed-on: https://go-review.googlesource.com/c/160261
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-30 18:01:19 +00:00
Alberto Donizetti 3a91061504 doc: note go tool tour removal in 1.12 release notes
Note the removal of the go tool tour command in the Go 1.12 release
notes.

Updates #24819

Change-Id: I258ab9401ea2cc06a83328c67299376fcf23c980
Reviewed-on: https://go-review.googlesource.com/c/158618
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2019-01-30 17:54:01 +00:00
Ian Lance Taylor 56c9f8e8cf os: treat EACCES as a permission error in RemoveAll
Fixes #29983

Change-Id: I24077bde991e621c23d00973b2a77bb3a18e4ae7
Reviewed-on: https://go-review.googlesource.com/c/160180
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-30 01:56:14 +00:00
Ian Lance Taylor ea27cd35fa os: restore RemoveAll docs by making a single copy
Updates #29983

Change-Id: Ifdf8aa9c92e053374e301a4268d85e277c15f0b5
Reviewed-on: https://go-review.googlesource.com/c/160182
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-30 01:39:37 +00:00
Ian Lance Taylor da648eac67 doc: remove meaningless word from Go 1.12 release notes
Change-Id: I744940e2bbde19ccec53af6c5469d46ba9161f01
Reviewed-on: https://go-review.googlesource.com/c/160179
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-01-30 01:38:43 +00:00
Ian Lance Taylor eb72a30f87 os: make openFdAt act like openFileNolog
- add EINTR loop on Darwin
- return PathError on error
- call newFile rather than NewFile

This tries to minimize the possibility of any future changes.
It would be nice to put openFdAt in the same file as openFileNolog,
but build tags forbid.

Updates #29983

Change-Id: I866002416d6473fbfd80ff6ef09b2bc4607f2934
Reviewed-on: https://go-review.googlesource.com/c/160181
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2019-01-30 01:07:50 +00:00
Brad Fitzpatrick f1d662f347 net/url, net/http: relax CTL-in-URL validation to only ASCII CTLs
CL 159157 was doing UTF-8 decoding of URLs. URLs aren't really UTF-8,
even if sometimes they are in some contexts.

Instead, only reject ASCII CTLs.

Updates #27302
Updates #22907

Change-Id: Ibd64efa5d3a93263d175aadf1c9f87deb4670c62
Reviewed-on: https://go-review.googlesource.com/c/160178
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-29 20:42:54 +00:00
kim yongbin d34c0dbc17 doc/go1.12: add notes about 'go doc -src'
Change-Id: Iaf67fcbb145277327e24150b29ff38f6c65f6a03
Reviewed-on: https://go-review.googlesource.com/c/155781
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-29 14:54:34 +00:00
Ian Lance Taylor df719d9809 doc: go1.12: mention change in text/template user function panic
Updates #28242

Change-Id: Ib717b64f1f368cc889895a2437ff2943ed4eab0d
Reviewed-on: https://go-review.googlesource.com/c/159998
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-01-29 14:52:45 +00:00
Austin Clements 66065c3115 cmd/link: fix confusing error on unresolved symbol
Currently, if an assembly file includes a static reference to an
undefined symbol, and another package also has an undefined reference
to that symbol, the linker can report an error like:

  x: relocation target zero not defined for ABI0 (but is defined for ABI0)

Since the symbol is referenced in another package, the code in
ErrorUnresolved that looks for alternative ABI symbols finds that
symbol in the symbol table, but doesn't check that it's actually
defined, which is where the "but is defined for ABI0" comes from. The
"not defined for ABI0" is because ErrorUnresolved failed to turn the
static symbol's version back into an ABI, and it happened to print the
zero value for an ABI.

This CL fixes both of these problems. It explicitly maps the
relocation version back to an ABI and detects if it can't be mapped
back (e.g., because it's a static reference). Then, if it finds a
symbol with a different ABI in the symbol table, it checks to make
sure it's a definition, and not simply an unresolved reference.

Fixes #29852.

Change-Id: Ice45cc41c1907919ce5750f74588e8047eaa888c
Reviewed-on: https://go-review.googlesource.com/c/159518
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-29 02:01:16 +00:00
Ian Lance Taylor c00595cec5 doc: mention init traceback change in Go 1.12 release notes
Updates #29919

Change-Id: Ibf92c9957f71394f08c1203a29eae35a12021585
Reviewed-on: https://go-review.googlesource.com/c/159877
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-01-28 20:35:33 +00:00
Keith Randall c53aecaaea doc: describe change to eliminate method expression wrappers from stack traces
Change-Id: I824b42a1c1fdcee8712681ffc6316470761be065
Reviewed-on: https://go-review.googlesource.com/c/159858
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-28 19:53:34 +00:00
Alex Brainman 447965d4e0 path/filepath: skip TestIssue29372 on windows, if /tmp has symilinks
TestIssue29372 is broken on windows when temporary directory has
symlink in its path.

Adjust the test to use filepath.EvalSymlinks of temporary directory,
instead of temporary directory on windows. This change is not a
proper fix, but at least it makes TestIssue29372 pass on windows-arm.

See issue for details.

Updates #29746

Change-Id: I2af8ebb89da7cb9daf027a5e49e32ee22dbd0e3d
Reviewed-on: https://go-review.googlesource.com/c/159578
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-27 04:18:10 +00:00
Keith Randall eafe9a186c cmd/compile: hide init functions in tracebacks
Treat compiler-generated init functions as wrappers, so they will not
be shown in tracebacks.

The exception to this rule is that we'd like to show the line number
of initializers for global variables in tracebacks. In order to
preserve line numbers for those cases, separate out the code for those
initializers into a separate function (which is not marked as
autogenerated).

This CL makes the go binary 0.2% bigger.

Fixes #29919

Change-Id: I0f1fbfc03d10d764ce3a8ddb48fb387ca8453386
Reviewed-on: https://go-review.googlesource.com/c/159717
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-27 04:02:46 +00:00
Ian Lance Taylor d585f04fd3 cmd/compile: base PPC64 trunc rules on final type, not op type
Whether a truncation should become a MOVWreg or a MOVWZreg doesn't
depend on the type of the operand, it depends on the type of the final
result.  If the final result is unsigned, we can use MOVWZreg.  If the
final result is signed, we can use MOVWreg.  Checking the type of the
operand does the wrong thing if truncating an unsigned value to a
signed value, or vice-versa.

Fixes #29943

Change-Id: Ia6fc7d006486fa02cffd0bec4d910bdd5b6365f8
Reviewed-on: https://go-review.googlesource.com/c/159760
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-01-27 01:43:05 +00:00
GiantsLoveDeathMetal 4e056ade24 sort: change let to let's
Trivial typo

Change-Id: I3804f365519453bfa19997f55ead34742ac1a9db
GitHub-Last-Rev: 0e04e928d0
GitHub-Pull-Request: golang/go#29930
Reviewed-on: https://go-review.googlesource.com/c/159479
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-01-27 01:34:56 +00:00
Ian Lance Taylor 8c10ce164f cmd/go: mention that binary packages are going away
Updates #28152
Fixes #29927

Change-Id: Iea692c90074d057a1733e98bca3928e8f3569585
Reviewed-on: https://go-review.googlesource.com/c/159557
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-25 15:16:56 +00:00
yo-tak 8b7cf898af cmd/compile, cmd/link: document more flags
Fixes #26533

Change-Id: I5a48d667d474f3f222f9055e51131561a0cf45b6
Reviewed-on: https://go-review.googlesource.com/c/138757
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-25 04:57:20 +00:00
Bryan C. Mills 9d23975d89 cmd/go/internal/modload: ensure that __debug_modinfo__ is not discarded during linking
Fixes #28753
Updates #29628

Change-Id: I4a561be7d491a0d088e656b00151ae1bdbd16a84
Reviewed-on: https://go-review.googlesource.com/c/158357
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2019-01-23 23:13:03 +00:00
Filippo Valsorda 193c16a364 crypto/elliptic: reduce subtraction term to prevent long busy loop
If beta8 is unusually large, the addition loop might take a very long
time to bring x3-beta8 back positive.

This would lead to a DoS vulnerability in the implementation of the
P-521 and P-384 elliptic curves that may let an attacker craft inputs
to ScalarMult that consume excessive amounts of CPU.

This fixes CVE-2019-6486.

Fixes #29903

Change-Id: Ia969e8b5bf5ac4071a00722de9d5e4d856d8071a
Reviewed-on: https://team-review.git.corp.google.com/c/399777
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-on: https://go-review.googlesource.com/c/159218
Reviewed-by: Julie Qiu <julie@golang.org>
2019-01-23 22:01:56 +00:00
Brad Fitzpatrick 1e450aa2f2 net/http: update bundled http2
Updates bundled http2 to x/net git rev ed066c81e7 for:

    http2: Revert a closed stream cannot receive data
    https://golang.org/cl/153977

Updates golang/go#28204

Change-Id: I0a489e4e8a581a107970199f64f0fa9281982efe
Reviewed-on: https://go-review.googlesource.com/c/159179
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-01-23 21:33:28 +00:00
Brad Fitzpatrick 829c5df586 net/url, net/http: reject control characters in URLs
This is a more conservative version of the reverted CL 99135 (which
was reverted in CL 137716)

The net/url part rejects URLs with ASCII CTLs from being parsed and
the net/http part rejects writing them if a bogus url.URL is
constructed otherwise.

Updates #27302
Updates #22907

Change-Id: I09a2212eb74c63db575223277aec363c55421ed8
Reviewed-on: https://go-review.googlesource.com/c/159157
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2019-01-23 19:31:46 +00:00
Daniel Martí 4edea0f0a7 doc: mention 'go get golang.org/dl/...' in install
I needed Go 1.10 to debug and fix a test failure on that Go version in
x/tools, but I forgot what the magic 'go get' command for this was.

Googling "download specific golang version" and similar keywords showed
no results, presumably because the golang.org/dl subrepo isn't
prominently recommended nor documented anywhere.

The most appropriate documentation page to add this to is doc/install,
since it goes into some detail and is well indexed. We only need a short
section to introduce the trick.

The example does mention a specific version, Go 1.10.7, but I couldn't
imagine a way to make it version-agnostic while still being clear on
what the commands effectively do.

Change-Id: I13158564d76d95caec412cdb35a50a4356df5863
Reviewed-on: https://go-review.googlesource.com/c/157457
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-01-23 16:07:39 +00:00
Elias Naur cd06b2d00d A+C: change email address for Elias Naur
Change-Id: I0eefaed645d5d1f56c408af496c92dbb799977c8
Reviewed-on: https://go-review.googlesource.com/c/159037
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-23 15:05:26 +00:00
Keith Randall 1fb596143c cmd/compile: don't bother compiling functions named "_"
They can't be used, so we don't need code generated for them. We just
need to report errors in their bodies.

This is the minimal CL for 1.12. For 1.13, CL 158845 will remove
a bunch of special cases sprinkled about the compiler to handle "_"
functions, which should (after this CL) be unnecessary.

Update #29870

Change-Id: Iaa1c194bd0017dffdce86589fe2d36726ee83c13
Reviewed-on: https://go-review.googlesource.com/c/158820
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-22 22:06:11 +00:00
Filippo Valsorda ef82ecd0f6 crypto/subtle: normalize constant time ops docs
ConstantTimeCompare is fairly useless if you can't rely on it being zero
when the slices are different, but thankfully it has that property
thanks to the final ConstantTimeByteEq.

Change-Id: Id51100ed7d8237abbbb15778a259065b162a48ad
Reviewed-on: https://go-review.googlesource.com/c/158643
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2019-01-22 19:40:30 +00:00
Dmitri Shuralyov 8d2e65d224 cmd/go: copy missing bit of documentation about code generated comment
This CL attempts to restore the clarity of the original specification
at https://golang.org/s/generatedcode that the line may appear
anywhere. It is preferable (for human readability), and most common
for it to be early in the file, but that is merely a convention, not
a strict well-specified requirement. Document it as so.

Background

Issue #13560 was a proposal define a standard for marking files as
generated, one that is suitable to be recognized both by humans
and machine tools. It was accepted, and the final specification
was documented at https://golang.org/s/generatedcode. Its text,
copied exactly:

	Generated files are marked by a line of text that matches
	the regular expression, in Go syntax:

		^// Code generated .* DO NOT EDIT\.$

	The .* means the tool can put whatever folderol it wants in there,
	but the comment must be a single line and must start with Code generated
	and end with DO NOT EDIT., with a period.

	The text may appear anywhere in the file.

The https://golang.org/s/generatedcode link points to a comment
in a very large GitHub issue. That makes it harder to find.
Issue #25433 was opened about moving that information somewhere else.
It was resolved via CL 118756, which added text to cmd/go documentation
at https://golang.org/cmd/go/#hdr-Generate_Go_files_by_processing_source:

	To convey to humans and machine tools that code is generated,
	generated source should have a line early in the file that
	matches the following regular expression (in Go syntax):

		^// Code generated .* DO NOT EDIT\.$

The CL description noted that "This change merely moves that
information to a more visible place." The intention was to preserve
the specification unmodified.

The original specification was very clear that "The text may appear
anywhere in the file." The new text in cmd/go documentation wasn't
very clear. "A line early in the file" is not a precise enough criteria
to be recognized by a machine tool, because there isn't a precise
definition of what lines are "early in the file".

Updates #13560
Updates #25433
Updates #28089

Change-Id: I4e374163b16c3f972f9591ec2647fd3d5a2dd5ae
Reviewed-on: https://go-review.googlesource.com/c/158817
Reviewed-by: Rob Pike <r@golang.org>
2019-01-22 16:23:41 +00:00
Elias Naur cad6d1fef5 doc/go1.12.html: document rejection of mangled C names
Change-Id: I27ef49815f55a36379b730b77f7e9a4dd5341507
Reviewed-on: https://go-review.googlesource.com/c/158777
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-21 23:31:09 +00:00
Tobias Klauser 8e50e48f4d cmd/cgo: remove duplicate entry from gofmtLineReplacer
CL 158457 added a duplicate entry for the ",\n" -> "," replacement to
gofmtLineReplacer. Remove the duplicate.

Change-Id: I17684fcd19cbc96fa7a7b53bf7c1a6382bf1114f
Reviewed-on: https://go-review.googlesource.com/c/158619
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-21 07:14:48 +00:00
Aaron Cannon e308807f65 flag: improve docs for PrintDefaults; clarify how to change output destination
The existing docs only mention that it is possible to change the output
destination of PrintDefaults from the default of standard error, but fail to
mention how to actually do so. This change fixes this lack by directing users
to CommandLine.SetOutput.

Fixes #15024

Change-Id: Ieaa7edbebd23d4ea6fa7e53d97a87143d590bdb3
Reviewed-on: https://go-review.googlesource.com/c/145203
Reviewed-by: Rob Pike <r@golang.org>
2019-01-21 05:30:12 +00:00
Filippo Valsorda 6718bb22fe crypto/tls: send a "handshake failure" alert if the RSA key is too small
Fixes #29779

Change-Id: I7eb8b4db187597e07d8ec7d3ff651f008e2ca433
Reviewed-on: https://go-review.googlesource.com/c/158639
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-20 20:01:48 +00:00
Ian Lance Taylor a15a013772 cmd/cgo: print the right error if mangling detection gccgo fails
Change-Id: I2324f6f51d2bf8a4ae1b139b3933bc78dfa75835
Reviewed-on: https://go-review.googlesource.com/c/158718
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-01-20 19:20:04 +00:00
Filippo Valsorda 5538a9a34f doc/go1.12: mention small RSA keys will cause some TLS handshakes to fail
Updates #29779

Change-Id: I9becaba41ab4cd0bac25b4bedf3f8b19761d8158
Reviewed-on: https://go-review.googlesource.com/c/158638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-18 22:41:47 +00:00
Filippo Valsorda 6f93f86498 crypto/tls: expand Config.CipherSuites docs
Fixes #29349

Change-Id: Iec16eb2b20b43250249ec85c3d78fd64d1b6e3f3
Reviewed-on: https://go-review.googlesource.com/c/158637
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-18 22:41:42 +00:00
Hana (Hyang-Ah) Kim 1e49021f89 doc/go1.12: mention heap sampling change
This is about a minor change but worthy of note because this
may affect the profile results users will see.

Change-Id: Ie2c4358b248f868662dbc71db587576481aa7238
Reviewed-on: https://go-review.googlesource.com/c/158577
Reviewed-by: Raul Silvera <rauls5382@gmail.com>
Reviewed-by: Austin Clements <austin@google.com>
2019-01-18 20:47:38 +00:00
tkivisik bcd3a58d46 A+C: add author, rename contributor to a real name
Renamed from github user to use my real name in CONTRIBUTORS, added my name
to AUTHORS.

Change-Id: I671638f1525d44bcc2b0a08d0dcff6adb1717510
GitHub-Last-Rev: b989e185de
GitHub-Pull-Request: golang/go#29823
Reviewed-on: https://go-review.googlesource.com/c/158540
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-18 20:46:19 +00:00
Raul Silvera dc889025c7 runtime: sample large heap allocations correctly
Remove an unnecessary check on the heap sampling code that forced sampling
of all heap allocations larger than the sampling rate. This need to follow
a poisson process so that they can be correctly unsampled. Maintain a check
for MemProfileRate==1 to provide a mechanism for full sampling, as
documented in https://golang.org/pkg/runtime/#pkg-variables.

Additional testing for this change is on cl/129117.

Fixes #26618

Change-Id: I7802bde2afc655cf42cffac34af9bafeb3361957
GitHub-Last-Rev: 471f747af8
GitHub-Pull-Request: golang/go#29791
Reviewed-on: https://go-review.googlesource.com/c/158337
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-01-18 15:29:32 +00:00
Ian Lance Taylor c077c74312 cmd/go: don't modify GOROOT in TestNewReleaseRebuildsStalePackagesInGOPATH
Fixes #29263

Change-Id: I06ba135dc491fd01fc06ccaad4ef98103d4b86c4
Reviewed-on: https://go-review.googlesource.com/c/154460
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-01-18 03:50:05 +00:00
Ian Lance Taylor dd1889cb22 cmd/cgo: don't replace newlines with semicolons in expressions
Fixes #29781

Change-Id: Id032d07a54b8c24f0c6d3f6e512932f76920ee04
Reviewed-on: https://go-review.googlesource.com/c/158457
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-18 03:25:40 +00:00
Brad Fitzpatrick 246e6ceb3b net/http: clarify Transport connection reuse docs a bit
Updates #26095 (or fixes it)

Change-Id: I92488dabe823b82e1ba534648fe6d63d25d0ae9f
Reviewed-on: https://go-review.googlesource.com/c/158417
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-18 02:38:08 +00:00
Robert Griesemer 33caf3be83 math/big: document that Rat.SetString accepts _decimal_ float representations
Updates #29799.

Change-Id: I267c2c3ba3964e96903954affc248d0c52c4916c
Reviewed-on: https://go-review.googlesource.com/c/158397
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-17 23:04:06 +00:00
Michael Anthony Knyszek 6e9f664b9a runtime: don't coalesce scavenged spans with unscavenged spans
As a result of changes earlier in Go 1.12, the scavenger became much
more aggressive. In particular, when scavenged and unscavenged spans
coalesced, they would always become scavenged. This resulted in most
spans becoming scavenged over time. While this is good for keeping the
RSS of the program low, it also causes many more undue page faults and
many more calls to madvise.

For most applications, the impact of this was negligible. But for
applications that repeatedly grow and shrink the heap by large amounts,
the overhead can be significant. The overhead was especially obvious on
older versions of Linux where MADV_FREE isn't available and
MADV_DONTNEED must be used.

This change makes it so that scavenged spans will never coalesce with
unscavenged spans. This  results in fewer page faults overall. Aside
from this, the expected impact of this change is more heap growths on
average, as span allocations will be less likely to be fulfilled. To
mitigate this slightly, this change also coalesces spans eagerly after
scavenging, to at least ensure that all scavenged spans and all
unscavenged spans are coalesced with each other.

Also, this change adds additional logic in the case where two adjacent
spans cannot coalesce. In this case, on platforms where the physical
page size is larger than the runtime's page size, we realign the
boundary between the two adjacent spans to a physical page boundary. The
advantage of this approach is that "unscavengable" spans, that is, spans
which cannot be scavenged because they don't cover at least a single
physical page are grown to a size where they have a higher likelihood of
being discovered by the runtime's scavenging mechanisms when they border
a scavenged span. This helps prevent the runtime from accruing pockets
of "unscavengable" memory in between scavenged spans, preventing them
from coalescing.

We specifically choose to apply this logic to all spans because it
simplifies the code, even though it isn't strictly necessary. The
expectation is that this change will result in a slight loss in
performance on platforms where the physical page size is larger than the
runtime page size.

Update #14045.

Change-Id: I64fd43eac1d6de6f51d7a2ecb72670f10bb12589
Reviewed-on: https://go-review.googlesource.com/c/158078
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-01-17 17:07:23 +00:00
Michael Anthony Knyszek 2f99e889f0 runtime: de-duplicate coalescing code
Currently the code surrounding coalescing is duplicated between merging
with the span before the span considered for coalescing and merging with
the span after. This change factors out the shared portions of these
codepaths into a local closure which acts as a helper.

Change-Id: I7919fbed3f9a833eafb324a21a4beaa81f2eaa91
Reviewed-on: https://go-review.googlesource.com/c/158077
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-01-17 17:05:37 +00:00
Michael Anthony Knyszek 79ac638e41 runtime: refactor coalescing into its own method
The coalescing process is complex and in a follow-up change we'll need
to do it in more than one place, so this change factors out the
coalescing code in freeSpanLocked into a method on mheap.

Change-Id: Ia266b6cb1157c1b8d3d8a4287b42fbcc032bbf3a
Reviewed-on: https://go-review.googlesource.com/c/157838
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-01-17 16:59:49 +00:00