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

37028 Commits

Author SHA1 Message Date
Emmanuel T Odeke
1988b3ed0e net/http: avoid deferred unlock in ServeMux.shouldRedirect
CL 96575 introduced concurrency protection for
ServeMux.shouldRedirect with a read lock and deferred unlock.
However, the change produced a noticeable regression.
Instead add the suffix "RLocked" to the function name to
declare that we should hold the read lock as a pre-requisite
before calling it, hence avoiding the defer altogether.

Benchmarks:
name                  old time/op    new time/op    delta
ServeMux-8              63.3µs ± 0%    54.6µs ± 0%  -13.74%  (p=0.000 n=9+9)
ServeMux_SkipServe-8    41.4µs ± 2%    32.7µs ± 1%  -21.05%  (p=0.000 n=10+10)

name                  old alloc/op   new alloc/op   delta
ServeMux-8              17.3kB ± 0%    17.3kB ± 0%     ~     (all equal)
ServeMux_SkipServe-8     0.00B          0.00B          ~     (all equal)

name                  old allocs/op  new allocs/op  delta
ServeMux-8                 360 ± 0%       360 ± 0%     ~     (all equal)
ServeMux_SkipServe-8      0.00           0.00          ~     (all equal)

Updates #25383
Updates #25482

Change-Id: I2ffa4eafe165faa961ce23bd29b5653a89facbc2
Reviewed-on: https://go-review.googlesource.com/113996
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-21 12:53:33 +00:00
Tobias Klauser
85e38cccb4 syscall: check faccessat flags parameter on Linux
Port CL 119495 from golang.org/x/sys/unix to the syscall package.

Currently Linux faccessat(2) syscall implementation doesn't support the
flags parameter. As per the discussion in #25845, permit the same flags
as glibc [1].

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/faccessat.c;h=ea42b2303ff4b2d2d6548ea04376fb265f773436;hb=HEAD

Updates #25845

Change-Id: I132b33275a9cc72b3a97acea5482806c7f47d7f7
Reviewed-on: https://go-review.googlesource.com/120015
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-21 06:47:46 +00:00
Brad Fitzpatrick
feeff23556 mime: change *.js mime type to application/javascript, not x-javascript
We delayed doing this for 4 years for fear that it might break something,
but it was standardized (RFC 4329) 12 years ago, and the default in Debian
and other places is correct:

   $ cat /etc/mime.types  | grep js$
   application/javascript                          js

Time for us to change too.

I doubt there will be problems, but we'll see during the Go 1.11 beta.

Fixes #7498

Change-Id: Iba0bf8a6e707a64dd63317e1c0d6dd9a18634527
Reviewed-on: https://go-review.googlesource.com/120058
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-20 22:20:41 +00:00
Agniva De Sarker
f3f7bd5558 cmd/go/internal: add a note about GOCACHE=off
Fixes #25928

Change-Id: I1401ecc54af26eeeee648bb8eeb5d2d3566fa60c
Reviewed-on: https://go-review.googlesource.com/119695
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-20 20:29:55 +00:00
Stephen Lewis
ee9c9392b8 doc: fix spelling of G Suite
'G Suite' seems to be the preferred spelling according to
https://gsuite.google.com/

Change-Id: Ica60938cf942594157bba84ef205e1cdcb8c1b08
Reviewed-on: https://go-review.googlesource.com/120132
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2018-06-20 18:43:22 +00:00
Wayne Ashley Berry
dd0e7a9534 doc: change git clone url
The git clone url should be a Gerrit host and not Github, otherwise the
codereview command will fail.

	git-codereview: failed to load Gerrit origin: git origin must be a Gerrit host, not GitHub: https://github.com/golang/go

Change-Id: I62f62c86ee6dce0720a844fc56340135dfae8405
Reviewed-on: https://go-review.googlesource.com/117178
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-20 17:17:37 +00:00
Peter Wu
c89d75f981 crypto/tls: consolidate signatures handling in SKE and CV
ServerKeyExchange and CertificateVerify can share the same logic for
picking a signature algorithm (based on the certificate public key and
advertised algorithms), selecting a hash algorithm (depending on TLS
version) and signature verification.

Refactor the code to achieve code reuse, have common error checking
(especially for intersecting supported signature algorithms) and to
prepare for addition of new signature algorithms. Code should be easier
to read since version-dependent logic is concentrated at one place.

Change-Id: I978dec3815d28e33c3cfbc85f0c704b1894c25a3
Reviewed-on: https://go-review.googlesource.com/79735
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-20 17:15:50 +00:00
Ian Lance Taylor
3ca5b7c5b2 internal/poll: better panic message for lock overflow
Instead of "inconsistent poll.fdMutex", panic with
"too many concurrent operations on a single file or socket (max 1048575)".

Fixes #25558

Change-Id: I5cad3633aa539fb6f48cca236c6656c86acfb663
Reviewed-on: https://go-review.googlesource.com/119956
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2018-06-20 16:55:30 +00:00
LE Manh Cuong
578e066862 make.bash: don't pass GOOS and GOARCH to cmd/go when finding GOROOT_BOOTSTRAP
Fixes #25962

Change-Id: I10d41713f6aef100d7b2c8c976f22d1c8ac376d5
Reviewed-on: https://go-review.googlesource.com/119937
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-20 16:04:33 +00:00
Brad Fitzpatrick
f549af6f0a crypto/rand: make documentation consistent between package comment and Reader
Updates #25959

Change-Id: I9ae64b216ab5807718db0db98b32de1dc5fa4bec
Reviewed-on: https://go-review.googlesource.com/119875
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-06-20 15:07:49 +00:00
Agniva De Sarker
e4a50ce97a cmd/go: remove inadvertent comment for vgo
This change was introduced while adding the dark copy
of golang.org/x/vgo in CL 118095.

While the comment made sense in a separate vgo repo, when it is
merged with the main repo, this should not remain.

Found while running mkalldocs.sh in CL 119695.

Change-Id: I112a4629c415032bd29e165ac1c27a0f3cabeede
Reviewed-on: https://go-review.googlesource.com/119938
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-20 14:45:17 +00:00
Ian Lance Taylor
0c9be48a90 go/internal/gccgoimporter: read export data from archives
When used with the go tool, gccgo will normally generate archive files.
This change teaches the gccgoimporter package how to read the export
data from an archive.

This is needed by, for example, cmd/vet, when typechecking packages.

Change-Id: I21267949a7808cd81c0042af425c774a4ff7d82f
Reviewed-on: https://go-review.googlesource.com/119895
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-20 04:38:48 +00:00
Ian Lance Taylor
29673a4be6 misc/cgo/test: avoid duplicate definition with gccgo
Current versions of gccgo issue a duplicate definition error when both
a definition and an empty declaration occur. Use build tags to avoid
that case for the issue9400 subdirectory.

Change-Id: I18517af87bab05e9ca43f2f295459cf34347c317
Reviewed-on: https://go-review.googlesource.com/119896
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-20 02:52:44 +00:00
David Carlier
65d55a13a9 runtime: fix FreeBSDNumCPU test
num cpu unit test fixes for FreeBSD.
cpuset -g can possibly output more
data than expected.

Fixes #25924

Change-Id: Iec45a919df68648759331da7cd1fa3b9f3ca4241
GitHub-Last-Rev: 4cc275b519
GitHub-Pull-Request: golang/go#25931
Reviewed-on: https://go-review.googlesource.com/119376
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-19 22:19:28 +00:00
Heschi Kreinick
2036f16247 debug/elf,macho,pe: support compressed DWARF
Since we're going to start compressing DWARF on Windows and maybe
Darwin, copy the ELF support for .zdebug sections to macho and pe. The
code is almost completely the same across the three.

While I was here I added support for compressed .debug_type sections,
which I presume were overlooked before.

Tests will come in a later CL once we can actually generate compressed
PE/Mach-O binaries, since there's no other good way to get test data.

Updates #25927, #11799

Change-Id: Ie920b6a16e9270bc3df214ce601a263837810376
Reviewed-on: https://go-review.googlesource.com/119815
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-06-19 22:13:51 +00:00
Heschi Kreinick
83515df3f3 cmd/link: enable DWARF compression on Windows
Simple follow-on to CL 118276. Everything worked except that the
compressed sections need to be aligned at PEFILEALIGN.

Fixes #25927
Updates #11799

Change-Id: Iec871defe30e3e66055d64a5ae77d5a7aca355f5
Reviewed-on: https://go-review.googlesource.com/119816
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-06-19 22:13:43 +00:00
Dmitri Shuralyov
500293d8dc doc: update "Mac OS X", "OS X" to macOS; bump up to 10.10
The name was "Mac OS X" during versions 10.0 to 10.7.
It was renamed to "OS X" starting from 10.8 until 10.11.
The current name is "macOS" starting with 10.12. [1]

Previous changes (e.g., CL 47252) updated "Mac OS X" to macOS
in some places, but not everywhere. This CL updates remaining
instances for consistency.

Only the pages that display current information were updated;
historical pages such as release notes for older Go releases,
past articles, blog posts, etc., were left in original form.

Rename the "#osx" anchor to "#macos" on /doc/install page,
along with the single reference to it on the same page.
Add an empty div with id="osx" to not break old links.

Update minimum macOS version from 10.8 to 10.10 per #23122.

[1]: https://en.wikipedia.org/wiki/macOS#History

Updates #23122.

Change-Id: I69fe4b85e83265b9d99f447e3cc5230dde094869
Reviewed-on: https://go-review.googlesource.com/119855
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-19 21:36:56 +00:00
Filippo Valsorda
75d15a2082 crypto: panic on illegal input and output overlap
Normalized all panic checks and added inexact aliasing panics across
Stream, Block, BlockMode and AEAD implementations.

Also, tweaked the aliasing docs of cipher.AEAD, as they did not account
for the append nature of the API.

Fixes #21624

Change-Id: I075c4415f59b3c06e3099bd9f76de6d12af086bf
Reviewed-on: https://go-review.googlesource.com/109697
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-19 21:06:50 +00:00
David Chase
c6e455bb11 cmd/compile: conditional on -race, disable inline of go:norace
Adds the appropriate check to inl.go.
Includes tests of both -race+go:norace and plain go:norace.

Fixes #24651.

Change-Id: Id806342430c20baf4679a985d12eea3b677092e0
Reviewed-on: https://go-review.googlesource.com/119195
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-06-19 20:59:10 +00:00
Robert Griesemer
707ca18d97 cmd/compile: more accurate position for select case error message
Fixes #25958.

Change-Id: I1f4808a70c20334ecfc4eb1789f5389d94dcf00e
Reviewed-on: https://go-review.googlesource.com/119755
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-19 17:52:23 +00:00
Carlos Eduardo Seo
1caa06299c runtime: implement procyield properly for ppc64x
The procyield() function should yield the processor as in other
architectures. On ppc64x, this is achieved by setting the Program
Priority Register to 'low priority' prior to the spin loop, and
setting it back to 'medium-low priority' afterwards.

benchmark                          old ns/op     new ns/op     delta
BenchmarkMakeChan/Byte-8           87.7          86.6          -1.25%
BenchmarkMakeChan/Int-8            107           106           -0.93%
BenchmarkMakeChan/Ptr-8            201           204           +1.49%
BenchmarkMakeChan/Struct/0-8       78.2          79.7          +1.92%
BenchmarkMakeChan/Struct/32-8      196           200           +2.04%
BenchmarkMakeChan/Struct/40-8      236           230           -2.54%
BenchmarkChanNonblocking-8         8.64          8.85          +2.43%
BenchmarkChanUncontended-8         5577          5598          +0.38%
BenchmarkChanContended-8           66106         51529         -22.05%
BenchmarkChanSync-8                451           441           -2.22%
BenchmarkChanSyncWork-8            9155          9170          +0.16%
BenchmarkChanProdCons0-8           1585          1083          -31.67%
BenchmarkChanProdCons10-8          1094          838           -23.40%
BenchmarkChanProdCons100-8         831           657           -20.94%
BenchmarkChanProdConsWork0-8       1471          941           -36.03%
BenchmarkChanProdConsWork10-8      1033          721           -30.20%
BenchmarkChanProdConsWork100-8     730           511           -30.00%
BenchmarkChanCreation-8            135           128           -5.19%
BenchmarkChanSem-8                 602           463           -23.09%
BenchmarkChanPopular-8             3017466       2188441       -27.47%

Fixes #25625

Change-Id: Iacb1c888d3c066902152b8367500348fb631c5f9
Reviewed-on: https://go-review.googlesource.com/115376
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-19 16:39:52 +00:00
Robert Griesemer
f125052ad5 cmd/compile: fix exporting of 'for' loops
The existing code for encoding 'for' loops in exported, inlineable
functions incorrectly assumed that the 'Right' field points to an
'expression' node. Adjusted the code to be able to handle any kind
of node. Made matching changes for the binary and indexed exporter.

This only shows up together with other pending compiler changes that
enable exporting of such functions which contain for loops.

No tests yet because we can't test this w/o those pending compiler
changes. Once those changes are in, this code will be tested implicitly.
However, the changes were tested manually together with the patches
described in the issue.

Fixes #25222.

Change-Id: I54babb87e5d665d2c1ef6116c1de1b8c50b1138e
Reviewed-on: https://go-review.googlesource.com/119595
Reviewed-by: David Chase <drchase@google.com>
2018-06-19 16:35:58 +00:00
Heschi Kreinick
c99300229d runtime: fix lldb test after DWARF compression
Most (all?) released versions of lldb don't support compressed DWARF.
For now, skip the test if lldb can't find where to put the breakpoint.

This is the best I could think of -- there is no explicit error that I
can find that indicates it couldn't load the DWARF.

Fixes #25925.

Change-Id: Ib8fa486a04940cee5959ba7aab7bdbbaa3b2974e
Reviewed-on: https://go-review.googlesource.com/119535
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-06-18 23:20:57 +00:00
Heschi Kreinick
17a4e0475d runtime: skip gdb tests on mips after DWARF compression
DWARF compression appears to break GDB on mips for reasons unknown. Skip
the GDB tests there.

Fixes #25939.

Change-Id: Id76860d3a2ff8055999ac12ea891c37565bb6685
Reviewed-on: https://go-review.googlesource.com/119539
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-06-18 22:03:17 +00:00
Hana Kim
88b442f5c0 runtime/pprof: fix incorrect assumption in TestMapping
TestMapping assumed that there was only one mapping entry corresponding
to /exe/main, but that is not always true.
This CL changes the test logic to examine whether all referenced mappings
are symbolized. Based on the result, the test determines whether the
corresponding mapping entries' HasFunctions fields to be true or false.

I initially attempted to create two mappings for referenced locations
(one for symbolized and another for unsymbolized) as described in the
TODO in proto.go as part of fixing this bug. But that change requires
non-trivial modification in the upstream profile package so I decided
to just fix the test for now.

Fixes #25891

Change-Id: Id27a5b07bb5b59e133755a0f863bf56c0a4f7f2b
Reviewed-on: https://go-review.googlesource.com/119455
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-18 19:09:37 +00:00
Hiroshi Ioka
741dad28cb cmd/cgo: avoid name confliction for C functions
Use more cryptic names for local variables inside C function wrappers.

Fixes #23356

Change-Id: Ia6a0218f27a13be14f589b1a0facc9683d22ff56
Reviewed-on: https://go-review.googlesource.com/86495
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-18 18:28:02 +00:00
Rob Pike
b7d9e6e149 cmd/cover: fix off-by-one in test error message
Drive-by after previous CL.

Change-Id: I87db65b65745a0d76500cce06ac276b0d7928404
Reviewed-on: https://go-review.googlesource.com/119395
Reviewed-by: Ralph Corderoy <ralph@inputplus.co.uk>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-18 11:53:40 +00:00
Mostyn Bramley-Moore
187c3a65a6 doc: update more stale pprof links
Related to #25477.

Change-Id: I11261c6055b446ceca1b3acc538ab00fec4b47ca
Reviewed-on: https://go-review.googlesource.com/119321
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-17 21:35:39 +00:00
Brad Fitzpatrick
9a91713090 cmd/dist: don't test Examples for js/wasm
Fixes #25913

Change-Id: I4701ec94fa4b07211a8beed85c02ee5aa4fe3eb3
Reviewed-on: https://go-review.googlesource.com/119377
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
2018-06-17 20:45:54 +00:00
Brad Fitzpatrick
05f8b44d5e unicode: fix SpecialCase to follow its docs & respect explict no-op mappings
If SpecialCase contains an explicit CaseRange with zero deltas,
respect those and don't fall back to the default behavior.

Fixes #25636

Change-Id: Ic554c6b3dd462b1b39c75194eec469b6ff4aa55b
Reviewed-on: https://go-review.googlesource.com/117155
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
2018-06-17 08:48:39 +00:00
Yury Smolsky
b459e00454 cmd/compile: add more color choices to ssa.html
It is possible to highlight up to 12 SSA values
and outlinte up to 11 SSA blocks.

Change-Id: Ifefb813ba07ee8856681552b77199f409e03d74d
Reviewed-on: https://go-review.googlesource.com/119318
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2018-06-16 13:35:45 +00:00
Elias Naur
cdffe9b1e3 runtime: move semaphore ops from system calls to libc calls on iOS
Change-Id: I1c7a12497c47dd166cc41230d6e5e005edcbc848
Reviewed-on: https://go-review.googlesource.com/118819
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-06-16 00:58:45 +00:00
Keith Randall
5b5473c6bf runtime: move semaphore ops from system calls to libc calls on Darwin
This CL removes the last of the direct system calls in the runtime package.
This is the last CL for 1.11.

Use libcCall instead of asmcgocall in a few places I accidentally used
the wrong one.

For 1.12, we need to think about whether/how the syscall package
should be moved over to libc.

Update #17490

Change-Id: I4f0bd9cd6023f662f2e29588266fdfae5233898f
Reviewed-on: https://go-review.googlesource.com/118736
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-16 00:58:37 +00:00
Brad Fitzpatrick
c34381a658 net/http: document how Hijack and Request.Context interact, take two
Second try. The previous version (CL 115039 in git rev 3988863) wasn't
accurate.

Fixes #22347

Change-Id: I473165f308c730f50b14ba787cb215f7cb9ea364
Reviewed-on: https://go-review.googlesource.com/119235
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-15 21:18:10 +00:00
Brad Fitzpatrick
ad7320acc4 net/http: document that Handlers are resposible for validating Host headers
Fixes #23993

Change-Id: I112415c894e8c680bfc17d53772275430e46794b
Reviewed-on: https://go-review.googlesource.com/115116
Reviewed-by: Tim Cooper <tim.cooper@layeh.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-15 21:18:01 +00:00
Heschi Kreinick
594eae5ad0 cmd/link: compress DWARF sections in ELF binaries
Forked from CL 111895.

The trickiest part of this is that the binary layout code (blk,
elfshbits, and various other things) assumes a constant offset between
symbols' and sections' file locations and their virtual addresses.
Compression, of course, breaks this constant offset. But we need to
assign virtual addresses to everything before compression in order to
resolve relocations before compression. As a result, compression needs
to re-compute the "address" of the DWARF sections and symbols based on
their compressed size. Luckily, these are at the end of the file, so
this doesn't perturb any other sections or symbols. (And there is, of
course, a surprising amount of code that assumes the DWARF segment
comes last, so what's one more place?)

Relevant benchmarks:
name        old time/op     new time/op     delta
StdCmd          10.3s ± 2%      10.8s ± 1%   +5.43%  (p=0.000 n=30+30)

name        old text-bytes  new text-bytes  delta
HelloSize       746kB ± 0%      746kB ± 0%     ~     (all equal)
CmdGoSize      8.41MB ± 0%     8.41MB ± 0%     ~     (all equal)
[Geo mean]     2.50MB          2.50MB        +0.00%

name        old data-bytes  new data-bytes  delta
HelloSize      10.6kB ± 0%     10.6kB ± 0%     ~     (all equal)
CmdGoSize       252kB ± 0%      252kB ± 0%     ~     (all equal)
[Geo mean]     51.5kB          51.5kB        +0.00%

name        old bss-bytes   new bss-bytes   delta
HelloSize       125kB ± 0%      125kB ± 0%     ~     (all equal)
CmdGoSize       145kB ± 0%      145kB ± 0%     ~     (all equal)
[Geo mean]      135kB           135kB        +0.00%

name        old exe-bytes   new exe-bytes   delta
HelloSize      1.60MB ± 0%     1.05MB ± 0%  -34.39%  (p=0.000 n=30+30)
CmdGoSize      16.5MB ± 0%     11.3MB ± 0%  -31.76%  (p=0.000 n=30+30)
[Geo mean]     5.14MB          3.44MB       -33.08%

Fixes #11799.
Updates #6853.

Change-Id: I64197afe4c01a237523a943088051ee056331c6f
Reviewed-on: https://go-review.googlesource.com/118276
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-15 20:01:53 +00:00
Heschi Kreinick
b397f633ca cmd/link: compress debug sections in external linking mode
Forked from CL 111895.

For #11799.

Change-Id: Ie1346ac2c9122de494823b9058df3a0971e9dfe1
Reviewed-on: https://go-review.googlesource.com/118277
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-06-15 19:28:14 +00:00
Brad Fitzpatrick
3b0b3a0223 cmd/link: add buildid to wasm modules
Add Go buildids into a custom wasm section ("go.buildid", arbitrarily)
early in the wasm module, right after the magic & version.

Fixes #25910

Change-Id: If3f7cb267bf8c7beb6fa8d8b7a4829419720bbd8
Reviewed-on: https://go-review.googlesource.com/119175
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2018-06-15 19:25:02 +00:00
Russ Cox
5756895877 cmd/go: add dark copy of golang.org/x/vgo
This CL corresponds to golang.org/cl/118096 (7fbc8df48a7)
in the vgo repo.

It copies the bulk of the code from vgo back into the main repo,
but completely disabled - vgo.Init is a no-op and vgo.Enabled
returns false unconditionally.

The point of this CL is to make the two trees easier to diff and
to make future syncs smaller.

Change-Id: Ic34fd5ddd8272a70c5a3b3437b5169e967d0ed03
Reviewed-on: https://go-review.googlesource.com/118095
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-06-15 18:57:58 +00:00
Misty De Meo
1a92cdbfc1 ld/macho: add all missing load commands
The ld/macho code currently understands a subset of the mach-o load
commands. I've encountered one of these in the wild in a Go-produced
binary, which tripped up the Go linker because its switch statement
expects its list of load commands to be exhaustive; the rest I've
added for the sake of completion.

The ruby-macho library is a good non-Darwin header resource for these:
https://github.com/homebrew/ruby-macho

Fixes #25908

Change-Id: Ib54c065d27e87d8726a9870df05a2bae24828b98
GitHub-Last-Rev: 655e3f488a
GitHub-Pull-Request: golang/go#25906
Reviewed-on: https://go-review.googlesource.com/119115
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-15 18:18:40 +00:00
Yasuhiro Matsumoto
534ddf741f mime: add .wasm for builtin
Change-Id: I9d9189ae7882164246abcc4b22d49c26d4a3f201
Reviewed-on: https://go-review.googlesource.com/118937
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-15 14:44:04 +00:00
Fangming.Fang
ed99fcf1cf cmd/dist: run msan test only in testsanitizer on arm64
With latest gcc (7.3.0), misc/cgo/testsanitizer test will fail with reporting sigmentation
fault when running tsan test. On arm64, tsan is not supported currently and only msan test
can be run. So skip tsan test on arm64.

What needs to be pointed out is that msan test can be really run when setting clang
as c/c++ complier.

Fixes #25601

Change-Id: I6ab1a8d9edd243e2ee00ee40bc0abd6a0e6a125c
Reviewed-on: https://go-review.googlesource.com/114857
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-15 14:04:32 +00:00
Richard Musiol
4eb1c84752 cmd/link: fix name section of WebAssembly binary
Chrome and Node.js were not showing the names of WebAssembly
functions any more. This was due to the name section containing
names also for import functions, which is redundant.

Change-Id: I2f2b2d0b5bd7a59b34f108d2fd7b6ba2eb26f9c9
Reviewed-on: https://go-review.googlesource.com/118976
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-15 02:09:44 +00:00
Richard Musiol
2809b339b5 syscall/js: improve import functions
1. Make import functions not use the js.Value type directly,
but only the ref field. This gives more flexibility on the Go side
for the js.Value type, which is a preparation for adding
garbage collection of js.Value.

2. Turn import functions which are methods of js.Value into
package-level functions. This is necessary to make vet happy.

Change-Id: I69959bf1fbea0a0b99a552a1112ffcd0c024e9b8
Reviewed-on: https://go-review.googlesource.com/118656
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-15 02:09:34 +00:00
Brad Fitzpatrick
f70d1e76cc net/http: ensure that Listener.Close is called only once in Server.Serve
Fixes #24803

Change-Id: I8b1e7c5a74018a0c333f8c38a7ec5f5827ab1606
Reviewed-on: https://go-review.googlesource.com/106715
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2018-06-15 02:07:23 +00:00
Austin Clements
8998c55ec0 cmd/link: separate virtual address layout from file layout
Currently these two forms of layout are done in a single pass. This
makes it difficult to compress DWARF sections because that must be
done after relocations are applied, which must happen after virtual
address layout, but we can't layout the file until we've compressed
the DWARF sections.

Fix this by separating the two layout steps. In the process, we can
also unify the copy-pasted code in Link.address to compute file
offsets, which currently has some unnecessary variation.

Unlike the current file offset computation, which depends on virtual
addresses, the new computation only uses file offsets and sizes. This
will let us compress the file representation of a segment and create
the file layout based on its on-disk size rather than its original
in-memory size.

Tested by comparing the test binary for the "strings" package on all
supported GOOS/GOARCH combinations. All binaries are identical
(except, of course, their build IDs).

This is a second attempt at CL 111682.

For #11799.
Fixes #25863.

Change-Id: If09f28771bb4d78dd392fd58b8d7c9d5f22b0b9e
Reviewed-on: https://go-review.googlesource.com/118716
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-15 02:01:04 +00:00
Richard Musiol
c12399fffb all: enable vet/all for js/wasm and fix vet issues
This commit enables vet/all for the js/wasm architecture. It got
skipped initially because the codebase did not fully compile yet
for js/wasm, which made vet/all fail.

startTimer and stopTimer are not needed in the syscall package.
Removed their assembly code since their Go stubs were already gone.

Change-Id: Icaeb6d903876e51ceb1edff7631f715a98c28696
Reviewed-on: https://go-review.googlesource.com/118657
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-15 00:05:22 +00:00
Richard Musiol
adf72bbc9a misc/wasm: add stub for fs.openSync for browsers
This stub is necessary so the time package can fail to load
the timezone files in a nice way. It transitively makes the
log package work in browsers.

Change-Id: I4d360df82989d9b40cd31bb4508a6d057534443e
Reviewed-on: https://go-review.googlesource.com/118977
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-15 00:04:15 +00:00
Brian Kessler
30b045d4d1 math/big: handle negative exponents in Exp
For modular exponentiation, negative exponents can be handled using
the following relation.

for y < 0: x**y mod m == (x**(-1))**|y| mod m

First compute ModInverse(x, m) and then compute the exponentiation
with the absolute value of the exponent.  Non-modular exponentiation
with a negative exponent still returns 1.

Fixes #25865

Change-Id: I2a35986a24794b48e549c8de935ac662d217d8a0
Reviewed-on: https://go-review.googlesource.com/118562
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-14 22:26:30 +00:00
Richard Musiol
e083dc6307 runtime, sycall/js: add support for callbacks from JavaScript
This commit adds support for JavaScript callbacks back into
WebAssembly. This is experimental API, just like the rest of the
syscall/js package. The time package now also uses this mechanism
to properly support timers without resorting to a busy loop.

JavaScript code can call into the same entry point multiple times.
The new RUN register is used to keep track of the program's
run state. Possible values are: starting, running, paused and exited.
If no goroutine is ready any more, the scheduler can put the
program into the "paused" state and the WebAssembly code will
stop running. When a callback occurs, the JavaScript code puts
the callback data into a queue and then calls into WebAssembly
to allow the Go code to continue running.

Updates #18892
Updates #25506

Change-Id: Ib8701cfa0536d10d69bd541c85b0e2a754eb54fb
Reviewed-on: https://go-review.googlesource.com/114197
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-14 21:50:53 +00:00