1
0
mirror of https://github.com/golang/go synced 2024-10-05 16:41:21 -06:00
Commit Graph

18038 Commits

Author SHA1 Message Date
Austin Clements
028f972847 runtime: make gcDrainN in terms of scan work
Currently, the "n" in gcDrainN is in terms of objects to scan. This is
used by gchelpwork to perform a limited amount of work on allocation,
but is a pretty arbitrary way to bound this amount of work since the
number of objects has little relation to how long they take to scan.

Modify gcDrainN to perform a fixed amount of scan work instead. For
now, gchelpwork still performs a fairly arbitrary amount of scan work,
but at least this is much more closely related to how long the work
will take. Shortly, we'll use this to precisely control the scan work
performed by mutator assists during allocation to achieve the heap
size goal.

Change-Id: I3cd07fe0516304298a0af188d0ccdf621d4651cc
Reviewed-on: https://go-review.googlesource.com/8835
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-04-21 15:35:14 +00:00
Austin Clements
8e24283a28 runtime: track background scan work credit
This tracks scan work done by background GC in a global pool. Mutator
assists will draw on this credit to avoid doing work when background
GC is staying ahead.

Unlike the other GC controller tracking variables, this will be both
written and read throughout the cycle. Hence, we can't arbitrarily
delay updates like we can for scan work and bytes marked. However, we
still want to minimize contention, so this global credit pool is
allowed some error from the "true" amount of credit. Background GC
accumulates credit locally up to a limit and only then flushes to the
global pool. Similarly, mutator assists will draw from the credit pool
in batches.

Change-Id: I1aa4fc604b63bf53d1ee2a967694dffdfc3e255e
Reviewed-on: https://go-review.googlesource.com/8834
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-04-21 15:35:09 +00:00
Austin Clements
4e9fc0df48 runtime: implement GC scan work estimator
This implements tracking the scan work ratio of a GC cycle and using
this to estimate the scan work that will be required by the next GC
cycle. Currently this estimate is unused; it will be used to drive
mutator assists.

Change-Id: I8685b59d89cf1d83eddfc9b30d84da4e3a7f4b72
Reviewed-on: https://go-review.googlesource.com/8833
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-04-21 15:35:04 +00:00
Austin Clements
571ebae6ef runtime: track scan work performed during concurrent mark
This tracks the amount of scan work in terms of scanned pointers
during the concurrent mark phase. We'll use this information to
estimate scan work for the next cycle.

Currently this aggregates the work counter in gcWork and dispose
atomically aggregates this into a global work counter. dispose happens
relatively infrequently, so the contention on the global counter
should be low. If this turns out to be an issue, we can reduce the
number of disposes, and if it's still a problem, we can switch to
per-P counters.

Change-Id: Iac0364c466ee35fab781dbbbe7970a5f3c4e1fc1
Reviewed-on: https://go-review.googlesource.com/8832
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-04-21 15:35:00 +00:00
Austin Clements
fb9fd2bdd7 runtime: atomic ops for int64
These currently use portable implementations in terms of their uint64
counterparts.

Change-Id: Icba5f7134cfcf9d0429edabcdd73091d97e5e905
Reviewed-on: https://go-review.googlesource.com/8831
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-04-21 15:34:54 +00:00
Sebastien Binet
918fdae348 reflect: implement ArrayOf
This change exposes reflect.ArrayOf to create new reflect.Type array
types at runtime, when given a reflect.Type element.

- reflect: implement ArrayOf
- reflect: tests for ArrayOf
- runtime: document that typeAlg is used by reflect and must be kept in
  synchronized

Fixes #5996.

Change-Id: I5d07213364ca915c25612deea390507c19461758
Reviewed-on: https://go-review.googlesource.com/4111
Reviewed-by: Keith Randall <khr@golang.org>
2015-04-21 15:21:09 +00:00
Matthew Dempsky
c0fa9e3f6f runtime/pprof: disable flaky TestTraceFutileWakeup on linux/ppc64le
Update #10512.

Change-Id: Ifdc59c3a5d8aba420b34ae4e37b3c2315dd7c783
Reviewed-on: https://go-review.googlesource.com/9162
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-04-21 10:01:53 +00:00
Mikio Hara
0f6a3ba420 net: fix possible nil pointer dereference on ReadFrom for windows
Fixes #10516.

Change-Id: Ia93f53d4e752bbcca6112bc75f6c3dbe30b90dac
Reviewed-on: https://go-review.googlesource.com/9192
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-21 06:34:44 +00:00
Mikio Hara
0fc582e879 net: fix inconsistent error values on Lookup
This change fixes inconsistent error values on
Lookup{Addr,CNAME,Host,IP.MX,NS,Port,SRV,TXT}.

Updates #4856.

Change-Id: I059bc8ffb96ee74dff8a8c4e8e6ae3e4a462a7ef
Reviewed-on: https://go-review.googlesource.com/9108
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-21 05:16:07 +00:00
Mikio Hara
456cf0f22c net: fix inconsistent error values on Interface
This change fixes inconsistent error values on Interfaces,
InterfaceAddrs, InterfaceBy{Index,Name}, and Addrs and MulticastAddrs
methods of Interface.

Updates #4856.

Change-Id: I09e65522a22f45c641792d774ebf7a0081b874ad
Reviewed-on: https://go-review.googlesource.com/9140
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-21 04:16:14 +00:00
Mikio Hara
2173a27903 net: fix inconsistent error values on setters
This change fixes inconsistent error values on
Set{Deadline,ReadDeadline,WriteDeadline,ReadBuffer,WriteBuffer} for
Conn, Listener and PacketConn, and
Set{KeepAlive,KeepAlivePeriod,Linger,NoDelay} for TCPConn.

Updates #4856.

Change-Id: I34ca5e98f6de72863f85b2527478b20d8d5394dd
Reviewed-on: https://go-review.googlesource.com/9109
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-21 04:05:59 +00:00
Mikio Hara
885111365b net: fix inconsistent error values on File
This change fixes inconsistent error values on
File{Conn,Listener,PacketConn} and File method of Conn, Listener.

Updates #4856.

Change-Id: I3197b9277bef0e034427e3a44fa77523acaa2520
Reviewed-on: https://go-review.googlesource.com/9101
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-21 03:37:41 +00:00
Michael Hudson-Doyle
0088ddc3a0 cmd/6l, cmd/internal/ld, cmd/internal/obj: remove Xsym/Xadd from compiler's Reloc
They don't really make any sense on this side of the compiler/linker divide.

Some of the code touching these fields was the support for R_TLS when
thechar=='6' which turns out to be dead and so I just removed all of that.

Change-Id: I4e265613c4e7fcc30a965fffb7fd5f45017f06f3
Reviewed-on: https://go-review.googlesource.com/9107
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-21 03:00:19 +00:00
Mikio Hara
832c573595 net: add helpers for server testing
Also moves a few server test helpers into mockserver_test.go.

Change-Id: I5a95c9bc6f0c4683751bcca77e26a8586a377466
Reviewed-on: https://go-review.googlesource.com/9106
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-21 01:00:11 +00:00
Michael Hudson-Doyle
f9bc9a7a2e cmd/internal/ld: set moduledatasize correctly when -linkshared
Change-Id: I1ea4175466c9113c1f41b012ba8266ee2b06e3a3
Reviewed-on: https://go-review.googlesource.com/8522
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-20 23:21:38 +00:00
Michael Hudson-Doyle
8a3132dd5e cmd/6g: let the compiler use R15 when it is not needed for GOT indirection
Thanks to Russ for the hints.

Change-Id: Ie35a71d432b9d68bd30c7a364b4dce1bd3db806e
Reviewed-on: https://go-review.googlesource.com/9102
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-20 23:20:15 +00:00
Brad Fitzpatrick
88c08b06b9 cmd/internal: C->Go printf cleanup
Change-Id: I1cf94377c613fb51ae77f4fe1e3439268b1606a9
Reviewed-on: https://go-review.googlesource.com/9161
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-20 22:36:59 +00:00
Rick Hudson
899a4ad47e runtime: Speed up heapBitsForObject
Optimized heapBitsForObject by special casing
objects whose size is a power of two. When a
span holding such objects is initialized I
added a mask that when &ed with an interior pointer
results in the base of the pointer. For the garbage
benchmark this resulted in CPU_CLK_UNHALTED in
heapBitsForObject going from 7.7% down to 5.9%
of the total, INST_RETIRED went from 12.2 -> 8.7.

Here are the benchmarks that were at lease plus or minus 1%.

benchmark                          old ns/op      new ns/op      delta
BenchmarkFmtFprintfString          249            221            -11.24%
BenchmarkFmtFprintfInt             247            223            -9.72%
BenchmarkFmtFprintfEmpty           76.5           69.6           -9.02%
BenchmarkBinaryTree17              4106631412     3744550160     -8.82%
BenchmarkFmtFprintfFloat           424            399            -5.90%
BenchmarkGoParse                   4484421        4242115        -5.40%
BenchmarkGobEncode                 8803668        8449107        -4.03%
BenchmarkFmtManyArgs               1494           1436           -3.88%
BenchmarkGobDecode                 10431051       10032606       -3.82%
BenchmarkFannkuch11                2591306713     2517400464     -2.85%
BenchmarkTimeParse                 361            371            +2.77%
BenchmarkJSONDecode                70620492       68830357       -2.53%
BenchmarkRegexpMatchMedium_1K      54693          53343          -2.47%
BenchmarkTemplate                  90008879       91929940       +2.13%
BenchmarkTimeFormat                380            387            +1.84%
BenchmarkRegexpMatchEasy1_32       111            113            +1.80%
BenchmarkJSONEncode                21359159       21007583       -1.65%
BenchmarkRegexpMatchEasy1_1K       603            613            +1.66%
BenchmarkRegexpMatchEasy0_32       127            129            +1.57%
BenchmarkFmtFprintfIntInt          399            393            -1.50%
BenchmarkRegexpMatchEasy0_1K       373            378            +1.34%

Change-Id: I78e297161026f8b5cc7507c965fd3e486f81ed29
Reviewed-on: https://go-review.googlesource.com/8980
Reviewed-by: Austin Clements <austin@google.com>
2015-04-20 21:39:06 +00:00
Matthew Dempsky
e7ffafdb6e cmd/internal/obj: remove useless Trimpath field and fix users
http://golang.org/cl/7623 refactored how line history works and
introduced a new TrimPathPrefix field to replace the existing Trimpath
field, but never removed the latter or updated its users.

Fixes #10503.

Change-Id: Ief90a55b6cef2e8062b59856a4c7dcc0df01d3f2
Reviewed-on: https://go-review.googlesource.com/9113
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2015-04-20 20:46:06 +00:00
Brad Fitzpatrick
b016eba489 net/http: fix Transport data race, double cancel panic, cancel error message
Fixes #9496
Fixes #9946
Fixes #10474
Fixes #10405

Change-Id: I4e65f1706e46499811d9ebf4ad6d83a5dfb2ddaa
Reviewed-on: https://go-review.googlesource.com/8550
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-20 20:34:43 +00:00
Russ Cox
35b1dcc25f cmd/internal/gc: clean up componentgen
This is primarily about making the code clearer, but as part of the cleanup
componentgen is now much more consistent about what it does and does
not attempt.

The new limit is to 8 move instructions.

The old limit was either 3 or 4 small things but in the details it was
quite inconsistent: ints, interfaces, strings, and slices all counted as small;
it handled a struct containing two ints, but not a struct containing a struct
containing two ints; it handled slices and interfaces and a struct containing
a slice but not a struct containing an interface; and so on.

The new code runs at about the same speed as the old code if limited to 4 moves,
but that's much more restrictive when the pieces are strings or interfaces.
With the limit raised to 8 moves, this CL is sometimes a significant improvement:

benchmark                          old ns/op      new ns/op      delta
BenchmarkBinaryTree17              4361174290     4362870005     +0.04%
BenchmarkFannkuch11                3008201483     2974408533     -1.12%
BenchmarkFmtFprintfEmpty           79.0           79.5           +0.63%
BenchmarkFmtFprintfString          281            261            -7.12%
BenchmarkFmtFprintfInt             264            262            -0.76%
BenchmarkFmtFprintfIntInt          447            443            -0.89%
BenchmarkFmtFprintfPrefixedInt     354            361            +1.98%
BenchmarkFmtFprintfFloat           500            452            -9.60%
BenchmarkFmtManyArgs               1688           1693           +0.30%
BenchmarkGobDecode                 11718456       11741179       +0.19%
BenchmarkGobEncode                 10144620       10161627       +0.17%
BenchmarkGzip                      437631642      435271877      -0.54%
BenchmarkGunzip                    109468858      110173606      +0.64%
BenchmarkHTTPClientServer          76248          75362          -1.16%
BenchmarkJSONEncode                24160474       23753091       -1.69%
BenchmarkJSONDecode                84470041       82902026       -1.86%
BenchmarkMandelbrot200             4676857        4687040        +0.22%
BenchmarkGoParse                   4954602        4923965        -0.62%
BenchmarkRegexpMatchEasy0_32       151            151            +0.00%
BenchmarkRegexpMatchEasy0_1K       450            452            +0.44%
BenchmarkRegexpMatchEasy1_32       131            130            -0.76%
BenchmarkRegexpMatchEasy1_1K       713            695            -2.52%
BenchmarkRegexpMatchMedium_32      227            218            -3.96%
BenchmarkRegexpMatchMedium_1K      63911          62966          -1.48%
BenchmarkRegexpMatchHard_32        3163           3026           -4.33%
BenchmarkRegexpMatchHard_1K        93985          90266          -3.96%
BenchmarkRevcomp                   650697093      649211600      -0.23%
BenchmarkTemplate                  107049170      106804076      -0.23%
BenchmarkTimeParse                 448            452            +0.89%
BenchmarkTimeFormat                468            460            -1.71%

Change-Id: I08563133883e88bb9db9e9e4dee438a5af2787da
Reviewed-on: https://go-review.googlesource.com/9004
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-20 20:26:57 +00:00
Russ Cox
181e26b9fa runtime: replace func-based write barrier skipping with type-based
This CL revises CL 7504 to use explicitly uintptr types for the
struct fields that are going to be updated sometimes without
write barriers. The result is that the fields are now updated *always*
without write barriers.

This approach has two important properties:

1) Now the GC never looks at the field, so if the missing reference
could cause a problem, it will do so all the time, not just when the
write barrier is missed at just the right moment.

2) Now a write barrier never happens for the field, avoiding the
(correct) detection of inconsistent write barriers when GODEBUG=wbshadow=1.

Change-Id: Iebd3962c727c0046495cc08914a8dc0808460e0e
Reviewed-on: https://go-review.googlesource.com/9019
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-20 20:20:09 +00:00
Matthew Dempsky
c776592a4f cmd/internal/ld: prefer constants from cmd/internal/obj
The majority of this CL was prepared via scripted invocations of
`gofmt -w -r "$SYM -> obj.$SYM" cmd/internal/ld/*.go` and `gofmt -w -r
"ld.$SYM -> obj.$SYM" cmd/?l/*.go`.

Because of issue #7417, that was followed by repeatedly running an AWK
script to identify lines that differed other than whitespace changes
or "ld." or "obj." prefixes and manually restoring comments.

Finally, the redundant constants from cmd/internal/ld/link.go were
removed, and "goimports -w" was used to cleanup import lines.

Passes rsc.io/toolstash/buildall, even when modified to also build cmd.

Fixes #10055.

Change-Id: Icd5dbe819a3b6520ce883748e60017dc8e9a2e85
Reviewed-on: https://go-review.googlesource.com/9112
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-20 20:05:13 +00:00
Russ Cox
6e221a9038 cmd/dist: run commands in $GOROOT/src not $GOROOT when possible
The go command prints paths in errors relative to its current directory.
Since all.bash and run.bash are run in $GOROOT/src, prefer to run
the go command, so that the relative paths are correct.

Before this CL, running all.bash in $GOROOT/src:

	##### Testing race detector
	# net/http
	src/net/http/transport.go:1257: cannot take the address of <node EFACE>

This is wrong (or at least less useful) because there is no $GOROOT/src/src/net/http directory.

Change-Id: I0c0d52c22830d79b3715f51a6329a3d33de52a72
Reviewed-on: https://go-review.googlesource.com/9157
Reviewed-by: Rob Pike <r@golang.org>
2015-04-20 19:54:01 +00:00
Ian Lance Taylor
357a013060 runtime: save registers in linux/{386,amd64} lib entry point
The callee-saved registers must be saved because for the c-shared case
this code is invoked from C code in the system library, and that code
expects the registers to be saved.  The tests were passing because in
the normal case the code calls a cgo function that naturally saves
callee-saved registers anyhow.  However, it fails when the code takes
the non-cgo path.

Change-Id: I9c1f5e884f5a72db9614478049b1863641c8b2b9
Reviewed-on: https://go-review.googlesource.com/9114
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-20 18:09:41 +00:00
Ian Lance Taylor
725aa3451a runtime: no deadlock error if buildmode=c-archive or c-shared
Change-Id: I4ee6dac32bd3759aabdfdc92b235282785fbcca9
Reviewed-on: https://go-review.googlesource.com/9083
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-20 17:31:44 +00:00
Brad Fitzpatrick
a13cf8c104 cmd/internal/obj: manual C->Go cleanups
Change-Id: I5964fc55157dc1df7be400dfa0df591d6163e25e
Reviewed-on: https://go-review.googlesource.com/9084
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-20 16:54:22 +00:00
David Crawshaw
3f4de49d0a cmd/dist: enable c-archive test on darwin/arm64
Turns out all the necessary pieces have already been submitted.

Change-Id: I19c8d614cd756821ce400ca7a338029002780b18
Reviewed-on: https://go-review.googlesource.com/9076
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-20 15:56:56 +00:00
David Crawshaw
98f610fe09 misc/cgo/testcarchive: enable test on darwin/arm
Change-Id: I0d3f9841500e0a41f1c427244869bf3736a31e18
Reviewed-on: https://go-review.googlesource.com/9075
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-20 15:16:16 +00:00
Hyang-Ah Hana Kim
983a490ee9 cmd/dist: include misc/cgo/testcshared test for linux/amd64
Change-Id: Ia2c0c617df523482ba1a25b7492267eb80f0819a
Reviewed-on: https://go-review.googlesource.com/9033
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-20 02:27:43 +00:00
Michael Hudson-Doyle
b92a0a8969 cmd/internal/gc, cmd/go: fix value of importpath symbol
In https://golang.org/cl/7797 I attempted to use myimportpath to set the value
of the go.importpath.$foo. symbol for the module being compiled, but I messed
it up and only set the name (which the linker rewrites anyway). This lead to
the importpath for the module being compiled being "". This was hard to notice,
because all modules that import another define the importpath for their
imported modules correctly -- but main is not imported, and this meant that the
reflect module saw all fields of all types defined in the main module as
exported.

The fix is to do what I meant to do the first time, add a test and change the
go tool to compile main packages with -p main and not -p
command-line-arguments.

Fixes #10332

Change-Id: I5fc6e9b1dc2b26f058641e382f9a56a526eca291
Reviewed-on: https://go-review.googlesource.com/8481
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-19 20:14:59 +00:00
Mikio Hara
757f21fd6f net: fix a nit found by vet
Change-Id: Ic965b48bdc0e0ffba9bed5ff6b3d28ff742f8b2d
Reviewed-on: https://go-review.googlesource.com/9100
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-19 10:45:49 +00:00
Mikio Hara
4540e162b1 net: fix inconsistent error values on Accept
This change fixes inconsistent error values on Accept{,TCP,Unix}.

Updates #4856.

Change-Id: Ie3bb534c19a724cacb3ea3f3656e46c810b2123f
Reviewed-on: https://go-review.googlesource.com/8996
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-18 03:38:50 +00:00
Mikio Hara
310db63c5b net: fix inconsistent error values on Close
This change fixes inconsistent error values on Close, CloseRead and
CloseWrite.

Updates #4856.

Change-Id: I3c4d46ccd7d6e1a2f52d8e75b512f62c533a368d
Reviewed-on: https://go-review.googlesource.com/8994
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-18 03:12:04 +00:00
Mikio Hara
11b5f98bf0 net: fix inconsistent error values on Write
This change fixes inconsistent error values on Write,
WriteTo{,UDP,IP,Unix} and WriteMsg{UDP,IP,Unix}.

Updates #4856.

Change-Id: I4208ab6a0650455ad7d70a80a2d6169351d6055f
Reviewed-on: https://go-review.googlesource.com/8993
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-18 02:44:08 +00:00
Mikio Hara
ec1144423f net: fix inconsistent error values on Read
This change fixes inconsistent error values on Read,
ReadFrom{,UDP,IP,Unix} and ReadMsg{UDP,IP,Unix}.

Updates #4856.

Change-Id: I7de5663094e09be2d78cdb18ce6f1e7ec260888d
Reviewed-on: https://go-review.googlesource.com/8992
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-18 02:19:46 +00:00
Josh Bleecher Snyder
951f74c4d0 cmd/...: fix vet issues and cull dead code
Change-Id: Ied0eab872950793b34dd2268055b29c702b07e99
Reviewed-on: https://go-review.googlesource.com/9081
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-18 01:47:28 +00:00
Mikio Hara
d0f3100b47 net: break up TestErrorNil into Test{Dial,Listen,ListenPacket}Error
Change-Id: I7c6c91a0551aacb49e1beb4a39215b93c8c7fcfa
Reviewed-on: https://go-review.googlesource.com/8997
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-18 01:43:35 +00:00
Matthew Dempsky
93402383ea cmd/cgo: more robust detection of clang
Fixes #10453.

Change-Id: I77470279865d4c954df615d6594c69edf68c28ca
Reviewed-on: https://go-review.googlesource.com/9090
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-18 01:11:44 +00:00
Brad Fitzpatrick
05efc18c20 cmd/6g, etc: cleanup, moving code out of near-empty gg.go files
Clear out gg.go files, and move things into consistent places between
the cmd/?g directories.

Change-Id: I81e04180613b806e0bfbb88519e66111ce9f74a3
Reviewed-on: https://go-review.googlesource.com/9080
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-18 00:11:23 +00:00
Mikio Hara
6d3a7e79a4 net: clean up cgo
This change adds a type addrinfoErrno to represent getaddrinfo,
getnameinfo-specific errors, and uses it in cgo-based lookup functions.

Also retags cgo files for clarification and does minor cleanup.

Change-Id: I6db7130ad7bf35bbd4e8839a97759e1364c43828
Reviewed-on: https://go-review.googlesource.com/9020
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-17 23:19:19 +00:00
David Crawshaw
7816a096d9 cmd/internal/ld: replace Diag;Errorexit with Exitf
I have left the Diag calls in place where I believe Ctxt.Cursym != nil
which means this CL is not the improvement I had hoped for. However
it is now safe to call Exitf whereever you are in the linker, which
makes it easier to reason about some code.

Change-Id: I8261e761ca9719f7d216e2747314adfe464e3337
Reviewed-on: https://go-review.googlesource.com/8668
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-17 22:50:25 +00:00
Matthew Dempsky
4d01922e46 encoding/gob: fix hang from skipping large slices
Change-Id: I4e59b5b1702e08d7c6191d0a70fb0a555f3340c8
Reviewed-on: https://go-review.googlesource.com/9061
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Rob Pike <r@golang.org>
2015-04-17 22:04:34 +00:00
Rob Pike
9c3bf097c8 cmd/go: add $GOLINE to generate
Also use os.Expand for variable substitution so ${x}y works.

Fixes #9960.

Change-Id: Ic8239b2e737d1f41910dde8ee9524ac48907cb03
Reviewed-on: https://go-review.googlesource.com/9007
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 20:33:01 +00:00
Josh Bleecher Snyder
13cb62c764 cmd/internal/gc, cmd/6g: generate boolean values without jumps
Use SETcc instructions instead of Jcc to generate boolean values.
This generates shorter, jump-free code, which may in turn enable other
peephole optimizations.

For example, given

func f(i, j int) bool {
	return i == j
}

Before

"".f t=1 size=32 value=0 args=0x18 locals=0x0
	0x0000 00000 (x.go:3)	TEXT	"".f(SB), $0-24
	0x0000 00000 (x.go:3)	FUNCDATA	$0, gclocals·b4c25e9b09fd0cf9bb429dcefe91c353(SB)
	0x0000 00000 (x.go:3)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0000 00000 (x.go:4)	MOVQ	"".i+8(FP), BX
	0x0005 00005 (x.go:4)	MOVQ	"".j+16(FP), BP
	0x000a 00010 (x.go:4)	CMPQ	BX, BP
	0x000d 00013 (x.go:4)	JEQ	21
	0x000f 00015 (x.go:4)	MOVB	$0, "".~r2+24(FP)
	0x0014 00020 (x.go:4)	RET
	0x0015 00021 (x.go:4)	MOVB	$1, "".~r2+24(FP)
	0x001a 00026 (x.go:4)	JMP	20

After

"".f t=1 size=32 value=0 args=0x18 locals=0x0
	0x0000 00000 (x.go:3)	TEXT	"".f(SB), $0-24
	0x0000 00000 (x.go:3)	FUNCDATA	$0, gclocals·b4c25e9b09fd0cf9bb429dcefe91c353(SB)
	0x0000 00000 (x.go:3)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0000 00000 (x.go:4)	MOVQ	"".i+8(FP), BX
	0x0005 00005 (x.go:4)	MOVQ	"".j+16(FP), BP
	0x000a 00010 (x.go:4)	CMPQ	BX, BP
	0x000d 00013 (x.go:4)	SETEQ	"".~r2+24(FP)
	0x0012 00018 (x.go:4)	RET

regexp benchmarks, best of 12 runs:

benchmark                                 old ns/op      new ns/op      delta
BenchmarkNotOnePassShortB                 782            733            -6.27%
BenchmarkLiteral                          180            171            -5.00%
BenchmarkNotLiteral                       2855           2721           -4.69%
BenchmarkMatchHard_32                     2672           2557           -4.30%
BenchmarkMatchHard_1K                     80182          76732          -4.30%
BenchmarkMatchEasy1_32M                   76440180       73304748       -4.10%
BenchmarkMatchEasy1_32K                   68798          66350          -3.56%
BenchmarkAnchoredLongMatch                482            465            -3.53%
BenchmarkMatchEasy1_1M                    2373042        2292692        -3.39%
BenchmarkReplaceAll                       2776           2690           -3.10%
BenchmarkNotOnePassShortA                 1397           1360           -2.65%
BenchmarkMatchClass_InRange               3842           3742           -2.60%
BenchmarkMatchEasy0_32                    125            122            -2.40%
BenchmarkMatchEasy0_32K                   11414          11164          -2.19%
BenchmarkMatchEasy0_1K                    668            654            -2.10%
BenchmarkAnchoredShortMatch               260            255            -1.92%
BenchmarkAnchoredLiteralShortNonMatch     164            161            -1.83%
BenchmarkOnePassShortB                    623            612            -1.77%
BenchmarkOnePassShortA                    801            788            -1.62%
BenchmarkMatchClass                       4094           4033           -1.49%
BenchmarkMatchEasy0_32M                   14078800       13890704       -1.34%
BenchmarkMatchHard_32K                    4095844        4045820        -1.22%
BenchmarkMatchEasy1_1K                    1663           1643           -1.20%
BenchmarkMatchHard_1M                     131261708      129708215      -1.18%
BenchmarkMatchHard_32M                    4210112412     4169292003     -0.97%
BenchmarkMatchMedium_32K                  2460752        2438611        -0.90%
BenchmarkMatchEasy0_1M                    422914         419672         -0.77%
BenchmarkMatchMedium_1M                   78581121       78040160       -0.69%
BenchmarkMatchMedium_32M                  2515287278     2498464906     -0.67%
BenchmarkMatchMedium_32                   1754           1746           -0.46%
BenchmarkMatchMedium_1K                   52105          52106          +0.00%
BenchmarkAnchoredLiteralLongNonMatch      185            185            +0.00%
BenchmarkMatchEasy1_32                    107            107            +0.00%
BenchmarkOnePassLongNotPrefix             505            505            +0.00%
BenchmarkOnePassLongPrefix                147            147            +0.00%

The godoc binary is ~0.12% smaller after this CL.

Updates #5729.

toolstash -cmp passes for all architectures other than amd64 and amd64p32.

Other architectures can be done in follow-up CLs.

Change-Id: I0e167e259274b722958567fc0af83a17ca002da7
Reviewed-on: https://go-review.googlesource.com/2284
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 20:12:18 +00:00
Ian Lance Taylor
9c1868d06d runtime: add -buildmode=c-archive/c-shared support for linux/386
Change-Id: I87147ca6bb53e3121cc4245449c519509f107638
Reviewed-on: https://go-review.googlesource.com/9009
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-17 19:31:37 +00:00
Russ Cox
17228f44b2 cmd/internal/gc: make use of new String methods in prints
$ sam -d cmd/internal/gc/*.{go,y} cmd/?g/*.go
X ,s/, (gc\.)?[BFHNST]conv\(([^()]+), 0\)/, \2/g
X/'/w
q
$

Change-Id: Ic28a4807d237b8ae53ceca1e4e7fdb43580ab560
Reviewed-on: https://go-review.googlesource.com/9032
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-04-17 19:29:25 +00:00
Russ Cox
96c91fa9db cmd/internal/gc: add String methods to *Mpint, *Mpflt, *Node, *NodeList, *Sym, *Type
The next CL will remove unnecessary conv calls.

Change-Id: I0e8dbd1756cdec1ef6095ae67629cd3fae0fb4a4
Reviewed-on: https://go-review.googlesource.com/9031
Reviewed-by: Austin Clements <austin@google.com>
2015-04-17 19:29:15 +00:00
Russ Cox
8e5346571c runtime: leave gccheckmark testing off by default
It's not helping anymore, and it's fooling people who try to
understand performance (like me).

Change-Id: I133a644acae0ddf1bfa17c654cdc01e2089da963
Reviewed-on: https://go-review.googlesource.com/9018
Reviewed-by: Austin Clements <austin@google.com>
2015-04-17 19:29:04 +00:00
Ian Lance Taylor
449969a4ac cmd/internal/ld, cmd/dist: support -buildmode=c-archive on linux
Change-Id: I8c97751a79b57197428b0f0b66fc9575708a2eb0
Reviewed-on: https://go-review.googlesource.com/8979
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-17 18:35:53 +00:00
Austin Clements
c1c667542c runtime: fix dangling pointer in readyExecute
readyExecute passes a closure to mcall that captures an argument to
readyExecute. Since mcall is marked noescape, this closure lives on
the stack of the calling goroutine. However, the closure puts the
calling goroutine on the run queue (and switches to a new
goroutine). If the calling goroutine gets scheduled before the mcall
returns, this stack-allocated closure will become invalid while it's
still executing. One consequence of this we've observed is that the
captured gp variable can get overwritten before the call to
execute(gp), causing execute(gp) to segfault.

Fix this by passing the currently captured gp variable through a field
in the calling goroutine's g struct so that the func is no longer a
closure.

To prevent problems like this in the future, this change also removes
the go:noescape annotation from mcall. Due to a compiler bug, this
will currently cause a func closure passed to mcall to be implicitly
allocated rather than refusing the implicit allocation. However, this
is okay because there are no other closures passed to mcall right now
and the compiler bug will be fixed shortly.

Fixes #10428.

Change-Id: I49b48b85de5643323b89e9eaa4df63854e968c32
Reviewed-on: https://go-review.googlesource.com/8866
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 17:59:14 +00:00
Rob Pike
2807572ab0 cmd/go: implement the long-promised -run flag for go generate
Trivial to do, but overlooked for 1.4, which is good because I prefer
the new design, which is just to match against the source code of
the line rather than the command word alone.

Change-Id: Idcf7c4479e97bb7cd732f0d058012321b6057628
Reviewed-on: https://go-review.googlesource.com/9005
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 17:49:14 +00:00
Brad Fitzpatrick
27067df9db cmd/internal/obj: cleanups from C transition and delete dead code
Change-Id: Id1ecad2565edd5937a764dcf56b89263353f47c2
Reviewed-on: https://go-review.googlesource.com/8947
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-17 17:28:17 +00:00
Michael Matloob
485f348979 regexp: set b.cap[0] and b.cap[1] only when captures requested
Fixes #10319

Change-Id: I96015b0e1dff30a72de11fea3837638b5c672891
Reviewed-on: https://go-review.googlesource.com/8501
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-17 17:10:07 +00:00
Russ Cox
a5e48cf023 cmd/internal/gc: fix node print
Change-Id: I0d2b909ceeba9da86c77de4ce23d7c6063f8f10f
Reviewed-on: https://go-review.googlesource.com/9017
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-17 14:57:51 +00:00
Dave Cheney
7ae9d06880 runtime/pprof: disable TestTraceStressStartStop
Updates #10476

Change-Id: Ic4414f669104905c6004835be5cf0fa873553ea6
Reviewed-on: https://go-review.googlesource.com/8962
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 14:54:25 +00:00
Russ Cox
a2ef54b51e fmt: adjust formatting of invalid reflect.Value, add more tests
Repeat of CL 8951.

Change-Id: I5430e4a9eb5d8b7d0e3963657092bede67439056
Reviewed-on: https://go-review.googlesource.com/9003
Reviewed-by: Rob Pike <r@golang.org>
2015-04-17 14:14:39 +00:00
David Crawshaw
c8aba85e4a runtime: export main.main for android
Previously we started the Go runtime from a JNI function call, which
eventually called the program's main function. Now the runtime is
initialized by an ELF initialization function as a c-shared library,
and the program's main function is not called. So now we export main
so it can be called from JNI.

This is necessary for all-Go apps because unlike a normal shared
library, the program loading the library is not written by or known
to the programmer. As far as they are concerned, the .so is
everything. In fact the same code is compiled for iOS as a normal Go
program.

Change-Id: I61c6a92243240ed229342362231b1bfc7ca526ba
Reviewed-on: https://go-review.googlesource.com/9015
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-17 12:11:04 +00:00
David Crawshaw
5da1c254d5 runtime: do not run main when buildmode=c-shared
Change-Id: Ie7f85873978adf3fd5c739176f501ca219592824
Reviewed-on: https://go-review.googlesource.com/9011
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-17 11:31:01 +00:00
Matthew Dempsky
810bbfe6f8 go/build: deps check all std packages
Instead of only checking packages that are already listed in pkgDeps,
apply deps checks to all standard library packages.

To avoid slowing testing down too much, instead of running "go list
std" in a subprocess like cmd/api or cmd/dist, this test manually
walks the GOROOT src directory to enumerate packages.

Timings on an HP Z620 using linux/amd64:

    	short	full
before	0.092s	4.880s
after	0.137s	5.104s

Additionally, a handful of packages that were previously unchecked are
now listed, along with their current dependencies.  These should
probably eventually be moved elsewhere and assigned appropriate
allowable-dependency sets.  For now, they've been grandfathered in by
simply assigning them their current dependencies, so that followup CLs
can review them individually as appropriate.

Fixes #10475.

Change-Id: I83ffd8ff329092f664bf3e3f2c9e3dad8e77ac02
Reviewed-on: https://go-review.googlesource.com/9001
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 05:37:45 +00:00
Nigel Tao
7f983f2f8e compress/flate: simplify the TestDegenerateHuffmanCoding data.
Change-Id: I223a4bd6e3ee31324b46ac79a4022e40f1868491
Reviewed-on: https://go-review.googlesource.com/8995
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2015-04-17 04:31:48 +00:00
Josh Bleecher Snyder
4a7e5bca3c cmd/internal/gc: clean up bgen
This cleanup is in anticipation of implementing
jump-free booleans (CL 2284) and zero-aware
comparisons (issue 10381).

No functional changes. Passes toolstash -cmp.

Change-Id: I50f394c60fa2927e177d7fc85b75085060a9e912
Reviewed-on: https://go-review.googlesource.com/8738
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 03:25:21 +00:00
Russ Cox
6a2b0c0b6d runtime: delete cgo_allocate
This memory is untyped and can't be used anymore.
The next version of SWIG won't need it.

Change-Id: I592b287c5f5186975ee09a9b28d8efe3b57134e7
Reviewed-on: https://go-review.googlesource.com/8956
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-17 01:30:47 +00:00
Mikio Hara
89b7c66d0d net: fix inconsistent error values on Dial, Listen partially
This change makes TestDialError, TestListenError work without any
external dependency, enables them by default, and removes unnecessary
-run_error_test flag for fixing #4856.

Also fixes inconsistent error values on Dial, Listen partially as a
first stab.

Updates #4856.

Change-Id: Ie10c151ae06759085f352c7db2ca45107a81914f
Reviewed-on: https://go-review.googlesource.com/8903
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-17 00:42:57 +00:00
Mikio Hara
3185cfbfbb net: rename netFD.proto to netFD.net on Plan 9
In followup changes, we'll move OpError around from the netFD layer to
the Conn layer for fixing #4856. Before doing that, this change makes
netFD of Plan 9 match netFD for POSIX platforms to avoid conflict.

Change-Id: Iea7632716d48722a1758e52effefec964a3a9442
Reviewed-on: https://go-review.googlesource.com/8990
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-17 00:09:13 +00:00
Nigel Tao
28388c4eb1 image/color: have Palette.Index honor alpha for closest match, not just
red, green and blue.

Fixes #9902

Change-Id: Ibffd0aa2f98996170e39a919296f69e9d5c71545
Reviewed-on: https://go-review.googlesource.com/8907
Reviewed-by: Rob Pike <r@golang.org>
2015-04-16 23:52:41 +00:00
David Crawshaw
46b4f675bf cmd/internal/ld: use usual flooding for c-archive
I said I removed this from cl/8711 in response to your comment, but
apparently I did not.

misc/cgo/testcarchive continues to pass on darwin/amd64.

Change-Id: I6410782f2a78bf117741628fb71cac56e289b590
Reviewed-on: https://go-review.googlesource.com/9010
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-16 20:01:13 +00:00
David Crawshaw
5b72b8c7a3 runtime: aeshash stubs for arm64
For some reason the absense of an implementation does not stop arm64
binaries being built. However it comes up with -buildmode=c-archive.

Change-Id: Ic0db5fd8fb4fe8252b5aa320818df0c7aec3db8f
Reviewed-on: https://go-review.googlesource.com/8989
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-16 19:49:31 +00:00
Michael Hudson-Doyle
62353ff876 cmd/go: have go run, go list respect -buildmode/-linkshared
Change-Id: I749fd91cd3c7581cdcc97a15e8eeee0c20f0b259
Reviewed-on: https://go-review.googlesource.com/8805
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-16 19:25:32 +00:00
David Crawshaw
e8b7133e9b runtime: darwin/arm64 c-archive entry point
Change-Id: Ib227aa3e14d01a0ab1ad9e53d107858e045d1c42
Reviewed-on: https://go-review.googlesource.com/8984
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-16 18:56:54 +00:00
David du Colombier
3eadc59b0d net: fix typo in comment
Change-Id: I8b2063e65d3454a694a789c1682dacfe0bea2e19
Reviewed-on: https://go-review.googlesource.com/8965
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-16 18:45:05 +00:00
Jonathan Rudenberg
c1e73dd286 crypto/tls: fix test data generation
- Multiple GetCertificate tests shared the same name and were
  overwriting each other, each test now has a unique name.
- expectAlert was not implemented in the data updater, the single
  test that used it has been replaced with a ClientHello failure
  test.

Fixes #10470

Change-Id: I500738f6302ffa863d7ee45d85fa8773155e0614
Reviewed-on: https://go-review.googlesource.com/8959
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
2015-04-16 18:16:37 +00:00
David Crawshaw
9cde36be54 runtime/cgo: enable arm64 EXC_BAD_ACCESS handler
Change-Id: I8e912ff9327a4163b63b8c628aa3546e86ddcc02
Reviewed-on: https://go-review.googlesource.com/8983
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-16 18:00:57 +00:00
Brad Fitzpatrick
db1f9cdd3f Revert "fmt: add a few more reflect.Value tests"
This reverts commit 3e6b7f35de.

Change-Id: Icad2b235b9880729fbdf80d7dfd71e56df4b1231
Reviewed-on: https://go-review.googlesource.com/8944
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-16 16:58:41 +00:00
Shenghou Ma
f633e445c7 crypto/x509: build the builtin root certs also for darwin/arm64
Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237f06
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8785
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-16 16:50:30 +00:00
Brad Fitzpatrick
015c760893 os: clarify that ModePerm permission bits are the Unix ones
Fixes #7075

Change-Id: I57fcebaaef768b00263b6b91211b1434f6a4b229
Reviewed-on: https://go-review.googlesource.com/8919
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-16 16:42:10 +00:00
Russ Cox
3e6b7f35de fmt: add a few more reflect.Value tests
Change-Id: I86530a4fd240f3e056e3277355d2965f6863b852
Reviewed-on: https://go-review.googlesource.com/8951
Reviewed-by: Rob Pike <r@golang.org>
2015-04-16 16:29:58 +00:00
Alexandre Cesaro
6b045d9aef mime/quotedprintable: Return a Reader instead of an io.Reader
It is not needed right now, but it will allow more flexibility in
the future.

Fixes #10472

Change-Id: I2eaea70abeca5ed10f89b0b2dfdabdac376a0a41
Reviewed-on: https://go-review.googlesource.com/8964
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-16 16:18:26 +00:00
Michael Hudson-Doyle
2f0828ef7c reflect, cmd/internal/gc: look for pointer types by string before synthesizing
The ptrto field of the type data cannot be relied on when dynamic linking: a
type T may be defined in a module that makes no use of pointers to that type,
but another module can contain a package that imports the first one and does use
*T pointers.  The second module will end up defining type data for *T and a
type.*T symbol pointing at it. It's important that calling .PtrTo() on the
refect.Type for T returns this type data and not some synthesized object, so we
need reflect to be able to find it!

Fortunately, the reflect package already has a mechanism for doing this sort of
thing: ChanOf/MapOf/etc look for pre-existing type data by name.  So this change
just extends PtrTo() to consult this too, and changes the compiler to include
pointer types in the data consulted when compiling for dynamic linking.

Change-Id: I3773c066fd0679a62e9fc52a84bf64f1d67662b7
Reviewed-on: https://go-review.googlesource.com/8232
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-16 16:11:07 +00:00
Josh Bleecher Snyder
e040fd4654 cmd/internal/gc: registerize more in 7g and 9g
7g and 9g disagree with componentgen
about what type len and cap have.

This results in an etype mismatch,
which inhibits registerization.

Fixing this results in 7406 more registerizations
while building the stdlib.
There are still 1512 missed opportunities.

This should improve the performance benefit
to 7g of enabling componentgen (CL 8636).

This CL reduces the size of godoc by 203k (-1.177%).

This was discovered by using the diagnostics
added in CL 8732 and running:

GOARCH=arm64 GOOS=linux go build -gcflags="-d registerization" std

See CL 91850043 for similar earlier fixes for 6g and 8g.

Change-Id: I57f478228a000ad7529d4136bad94a51343c4daa
Reviewed-on: https://go-review.googlesource.com/8733
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Keith Randall <khr@golang.org>
2015-04-16 15:50:37 +00:00
Aram Hăvărneanu
8262a8fbef cmd/7g: change CHECKNIL sequence
We can use CBNZ instruction and make it one instruction shorter.

Saves 66kB in godoc.

Change-Id: Ie71fe7cf31e7f73644ee926f4f9624c009c3eb1a
Reviewed-on: https://go-review.googlesource.com/8634
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-16 13:31:16 +00:00
Aram Hăvărneanu
a6bade60b0 cmd/7g: remove loads that only load an immediate to be later used by ADD/SUB
Optimize the sequence:
	MOV $imm, Rt
	ADD Rt, Rs, Rd

into:
	ADD $imm, Rs, Rd

Saves 66k in godoc.

Change-Id: I27b4aaa0ec80a59472fe2e5816efdf3db9c901ee
Reviewed-on: https://go-review.googlesource.com/8632
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-16 13:31:02 +00:00
Shenghou Ma
4a71b91d29 runtime: darwin/arm64 support
Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237f03
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8782
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-16 13:01:19 +00:00
David Crawshaw
bfd441f745 iostest.bash: run detect.go as part of iostest
Change-Id: I402629b154ae36c879a8d5088cb0f71b075f31dc
Reviewed-on: https://go-review.googlesource.com/8958
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-16 12:59:54 +00:00
Shenghou Ma
828de09f8b runtime/cgo: darwin/arm64 support
Fixes #10116.

Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237f05
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8784
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-16 12:50:49 +00:00
Shenghou Ma
e2cb9beb90 syscall: darwin/arm64 support
Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237f04
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8783
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-16 12:43:44 +00:00
Matthew Dempsky
5cc8561333 compress/flate: reject invalid Huffman bit sizes
If the requested coding bit sizes don't result in a full binary tree,
then reject the input as invalid.

Exception: We still need to allow degenerate Huffman codings with a
single 1-bit code to be compatible with zlib and files compressed with
Go's compress/flate package.

Update #10426.

Change-Id: I171b98d12e65b4deb9f4031cd802407ebb5e266c
Reviewed-on: https://go-review.googlesource.com/8922
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-04-16 07:34:04 +00:00
Shenghou Ma
4fd9a3fdbb cmd/internal/obj, cmd/internal/ld, cmd/7l: external linking for darwin/arm64
Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237f02
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8781
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-16 05:13:06 +00:00
Shenghou Ma
909bdf56d6 cmd/7g: disable duff's device on darwin
ld64 cannot handle BR26 reloc with non-zero addend. It incorrectly
thinks that non-zero addend for BR26 means the code is not PIC, but
those BR26 relocs should be fully resolved at link time.

Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237f01
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8780
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-16 05:12:45 +00:00
Shenghou Ma
72f8102244 cmd/internal/obj/arm64: add SVC to unary destination list
To support "SVC $0x80", which is needed for darwin/arm64.

Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237f00
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8769
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-16 05:12:28 +00:00
Matthew Dempsky
69d9247705 compress/flate: add optional runtime sanity checks
This code's test coverage is ad hoc at best, and it's easy to make
changes that accidentally regress invariants.  This CL adds a "sanity"
constant that can be changed to "true" during development to add extra
runtime checking that the Huffman decoder tables are sane.

Change-Id: I0d0ca53ad7c9566be18046d9b255e1a30059f28b
Reviewed-on: https://go-review.googlesource.com/8974
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-04-16 04:16:30 +00:00
Matthew Dempsky
5f0ac4a456 compress/flate: reject invalid Huffman encoding sequences
When decoding Huffman codes, if an invalid bit sequence is discovered,
reject the input instead of treating it as a 0-length code.

Fixes #10426.

Change-Id: Ie2f1a3a718afd7c6bee73a67480d4b84936c21c9
Reviewed-on: https://go-review.googlesource.com/8893
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-04-16 04:14:21 +00:00
Dave Day
e1c1fa2919 reflect: add FuncOf function
This also involves adding functions to typelinks along with a minor
change to ensure they are sorted correctly.

Change-Id: I054a79b6498a634cbccce17579f52c299733c2cf
Reviewed-on: https://go-review.googlesource.com/1996
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-16 01:38:50 +00:00
Nigel Tao
f5b5e41814 image: spell coordinate consistently, without the hyphen.
Change-Id: I211c0d33dc292c6a703d788f6d4d286107bcb6b0
Reviewed-on: https://go-review.googlesource.com/8906
Reviewed-by: Rob Pike <r@golang.org>
2015-04-16 01:21:31 +00:00
Mikio Hara
57bc7a0434 net: fix TestDialGoogle with -ipv6 when CGO_ENABLED=0
Under some dial tests that require external network connectivity, we
must prevent application traffic but must not interfere with control
plane traffic such as DNS message exchange. But test helper function
disableSocketConnect prevents both application and control plane traffic
unconditionally and makes some dial tests with -ipv6 fail when
CGO_ENABLED=0.

This change makes disableSocketConnect take a look at not only address
family but socket type for fixing some dial tests with -ipv6 when
CGO_ENBALED=0.

Change-Id: I32241d9592d31483424bb5e69cb4d56f3fc20312
Reviewed-on: https://go-review.googlesource.com/8743
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-16 00:44:52 +00:00
Michael Hudson-Doyle
f616af23e0 cmd/6l: call runtime.addmoduledata from .init_array
Change-Id: I09e84161d106960a69972f5fc845a1e40c28e58f
Reviewed-on: https://go-review.googlesource.com/8331
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-15 23:54:20 +00:00
Michael Hudson-Doyle
725cd2ea72 cmd/go: support -buildmode=shared
You can now do 'go install -buildmode=shared std' and get yourself
a nice (33 meg) libstd.so (which is not useful until there is -linkshared
support as well, of course).

Change-Id: Ie9b7e7f72abc7d369a6e3ecc98903a9d197bd6e6
Reviewed-on: https://go-review.googlesource.com/8300
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-15 23:53:32 +00:00
Ian Lance Taylor
6e83ef6d21 internal/syscall: move to unix subdirectory
Move the single file from internal/syscall to internal/syscall/unix,
to match the golang.org/x/sys layout.

Change-Id: I2fb2832b4cb22efc7666bd276f5401ac3e73dc40
Reviewed-on: https://go-review.googlesource.com/8972
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-04-15 23:51:36 +00:00
David Crawshaw
07f00cf11e cmd/test: require external linking for c-archive
Change-Id: I9ceceb29291ea9f5d7b675dfabd665c5e3618471
Reviewed-on: https://go-review.googlesource.com/8955
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-15 22:46:47 +00:00
Michael Hudson-Doyle
99162ca1c5 go/build: support -installsuffix with gccgo
Fixes #10449

Change-Id: I1dc2d0213e6a46f3609222d5460c1a54081e2471
Reviewed-on: https://go-review.googlesource.com/8931
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-15 22:46:23 +00:00