1
0
mirror of https://github.com/golang/go synced 2024-09-30 09:28:33 -06:00
Commit Graph

31858 Commits

Author SHA1 Message Date
Josh Bleecher Snyder
0dafb7d962 cmd/compile: check for missing function body earlier
Tested by fixedbugs/issue3705.go.

This removes a dependency on lineno
from near the backend.

Change-Id: I228bd0ad7295cf881b9bdeb0df9d18483fb96821
Reviewed-on: https://go-review.googlesource.com/38382
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-21 04:04:46 +00:00
Josh Bleecher Snyder
49a533e212 cmd/compile: use autogenerated position for init functions
This eliminates an old TODO,
and stabilizes the position information
for init functions.

Change-Id: Idf2d9a16a60e097ee08f42541b87e170da2f9d3a
Reviewed-on: https://go-review.googlesource.com/38388
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-21 03:59:54 +00:00
Daniel Martí
346d5883eb go/build: remove unused returnImports parameter
The code uses the filename suffix instead of the bool parameter to
determine what to do.

Fixes #19474.

Change-Id: Ic552a54e50194592a4b4ae7f74d3109af54e6d36
Reviewed-on: https://go-review.googlesource.com/38265
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-03-21 02:47:36 +00:00
Matthew Dempsky
80c4b53e1e cmd/compile/internal/gc: remove unneeded Type.Pos field
Change-Id: I9ab650d9d2d0a99186009362454e1eabc9f6bad6
Reviewed-on: https://go-review.googlesource.com/38393
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-21 02:44:40 +00:00
Matthew Dempsky
ee272bbf36 cmd/compile/internal/gc: export interface embedding information
Fixes #16369.

Change-Id: I23f8c36370d0da37ac5b5126d012d22f78782782
Reviewed-on: https://go-review.googlesource.com/38392
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-21 02:35:40 +00:00
Matthew Dempsky
07de3465be cmd/compile/internal/gc: handle recursive interfaces better
Previously, we handled recursive interfaces by deferring typechecking
of interface methods, while eagerly expanding interface embeddings.

This CL switches to eagerly evaluating interface methods, and
deferring expanding interface embeddings to dowidth. This allows us to
detect recursive interface embeddings with the same mechanism used for
detecting recursive struct embeddings.

Updates #16369.

Change-Id: If4c0320058047f8a2d9b52b9a79de47eb9887f95
Reviewed-on: https://go-review.googlesource.com/38391
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-21 01:56:25 +00:00
Jakob Borg
4e35e5fcab net/http: fix ProxyFromEnvironment panic on invalid $NO_PROXY value
Given an entry in $no_proxy like ":1" we would interpret it as an empty
host name and a port number, then check the first character of the host
name for dots. This would then cause an index out of range panic. This
change simply skips these entries, as the following checks would anyway
have returned false.

Fixes #19536

Change-Id: Iafe9c7a77ad4a6278c8ccb00a1575b56e4bdcd79
Reviewed-on: https://go-review.googlesource.com/38067
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-21 01:16:37 +00:00
Pascal S. de Kloe
df68afd07c encoding/json: reduce unmarshal mallocs for unmapped fields
JSON decoding performs poorly for unmapped and ignored fields. We noticed better
performance when unmarshalling unused fields. The loss comes mostly from calls
to scanner.error as described at #17914.

benchmark                 old ns/op     new ns/op     delta
BenchmarkIssue10335-8     431           408           -5.34%
BenchmarkUnmapped-8       1744          1314          -24.66%

benchmark                 old allocs     new allocs     delta
BenchmarkIssue10335-8     4              3              -25.00%
BenchmarkUnmapped-8       18             4              -77.78%

benchmark                 old bytes     new bytes     delta
BenchmarkIssue10335-8     320           312           -2.50%
BenchmarkUnmapped-8       568           344           -39.44%

Fixes #17914, improves #10335

Change-Id: I7d4258a94eb287c0fe49e7334795209b90434cd0
Reviewed-on: https://go-review.googlesource.com/33276
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-20 23:58:56 +00:00
Matthew Dempsky
7bb5b2d33a cmd/internal/obj: remove unneeded Addr.Node and Prog.Opt fields
Change-Id: I218b241c32a5948b66ad0d95ecc368648cf4ddf5
Reviewed-on: https://go-review.googlesource.com/38130
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-03-20 23:49:29 +00:00
Matthew Dempsky
cce4c319d6 cmd/internal/obj: remove unneeded AVARFOO ops
Change-Id: I10e36046ebce8a8741ef019cfe266b9ac9fa322d
Reviewed-on: https://go-review.googlesource.com/38088
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-03-20 23:40:09 +00:00
Matthew Dempsky
8ada52228c cmd/compile: remove ProgInfo tables
Change-Id: Id807c702ad71edddd23f2eb6f5e69e9a62e60bcd
Reviewed-on: https://go-review.googlesource.com/38089
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-03-20 23:29:51 +00:00
Ian Lance Taylor
5dc14af682 runtime: clear signal stack on main thread
This is a workaround for a FreeBSD kernel bug. It can be removed when
we are confident that all people are using the fixed kernel. See #15658.

Updates #15658.

Change-Id: I0ecdccb77ddd0c270bdeac4d3a5c8abaf0449075
Reviewed-on: https://go-review.googlesource.com/38325
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-20 22:59:26 +00:00
Matthew Dempsky
325904fe6a cmd/compile: port liveness analysis to SSA
Passes toolstash-check -all.

Change-Id: I92c3c25d6c053f971f346f4fa3bbc76419b58183
Reviewed-on: https://go-review.googlesource.com/38087
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-03-20 22:58:50 +00:00
Matthew Dempsky
ea8c7dae4f cmd/compile: sort CFG blocks in PC order during liveness
This CL changes the order that liveness analysis visits CFG blocks to
PC order, rather than RPO. This doesn't meaningfully change anything
except that the PCDATA_StackMapIndex values will be assigned in PC
order too.

However, this does have the benefit that the subsequent CL to port
liveness analysis to the SSA CFG (which has blocks in PC order) will
now pass toolstash-check.

Change-Id: I1de5a2eecb8027723a6e422d46186d0c63d48c8d
Reviewed-on: https://go-review.googlesource.com/38086
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-03-20 22:58:45 +00:00
Josh Bleecher Snyder
42a915c933 cmd/internal/obj: convert Debug* Link fields into bools
Change-Id: I9ac274dbfe887675a7820d2f8f87b5887b1c9b0e
Reviewed-on: https://go-review.googlesource.com/38383
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-20 22:08:41 +00:00
Matthew Dempsky
236ef852be cmd/compile/internal/gc: split SetInterface from SetFields
Change-Id: I4e568414faf64d3d47b1795382f0615f6caf53bc
Reviewed-on: https://go-review.googlesource.com/38390
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-20 22:00:14 +00:00
Michael Munday
df47b82174 cmd/internal/obj/s390x: cleanup objz.go
This CL deletes some unnecessary code in objz.go that existed to
support instruction scheduling. It's likely instruction scheduling
will never be done in this part of the backend so this code can
just be deleted.

This file can probably be cleaned up a bit more, but I think this
is a good start.

Passes: go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I1645632ac551a90a4f4be418045c046b488e9469
Reviewed-on: https://go-review.googlesource.com/38394
Run-TryBot: Michael Munday <munday@ca.ibm.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-20 21:58:27 +00:00
philhofer
d68bb16b1e cmd/compile/internal/ssa: recognize constant pointer comparison
Teach the backend to recognize that the address of a symbol
is equal with itself, and that the addresses of two different
symbols are different.

Some examples of where this rule hits in the standard library:

 - inlined uses of (*time.Time).setLoc (e.g. time.UTC)
 - inlined uses of bufio.NewReader (via type assertion)

Change-Id: I23dcb068c2ec333655c1292917bec13bbd908c24
Reviewed-on: https://go-review.googlesource.com/38338
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-20 21:04:44 +00:00
Josh Bleecher Snyder
f8b0231639 cmd/go, cmd/compile: always optimize when building runtime
When optimizations are disabled, the compiler
cannot eliminate enough write barriers to satisfy
the runtime's nowritebarrier and nowritebarrierrec
annotations.

Enforce that requirement, and for convenience,
have cmd/go elide -N when compiling the runtime.

This came up in practice for me when running
toolstash -cmp. When toolstash -cmp detected
mismatches, it recompiled with -N, which caused
runtime compilation failures.

Change-Id: Ifcdef22c725baf2c59a09470f00124361508a8f3
Reviewed-on: https://go-review.googlesource.com/38380
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-20 20:54:19 +00:00
Josh Bleecher Snyder
a955ece6cd cmd/internal/obj: reduce variable scope
Minor cleanup, to make it clearer
that the two p's are unrelated.

Change-Id: Icb6386c626681f60e5e631b33aa3a0fc84f40e4a
Reviewed-on: https://go-review.googlesource.com/38381
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-20 20:32:52 +00:00
Matthew Dempsky
07af21308c cmd/compile/internal/gc: eliminate two uses of Type.Pos
Instead we can use t.nod.Pos.

Change-Id: I643ee3226e402e38d4c77e8f328cbe83e55eac5c
Reviewed-on: https://go-review.googlesource.com/38309
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-20 20:24:35 +00:00
Josh Bleecher Snyder
e22ba7f0fb cmd/compile: enable CSE of constant strings
CL 27254 changed a constant string to a byte array
in encoding/hex and got significant performance
improvements.

hex.Encode used the string twice in a single function.
The rewrite rules lower constant strings into components.
The pointer component requires an aux symbol.
The existing implementation created a new aux symbol every time.
As a result, constant string pointers were never CSE'd.
Tighten then moved the pointer calculation next to the uses, i.e.
into the loop.

The re-use of aux syms enabled by this CL
occurs 3691 times during make.bash.

This CL should not go in without CL 38338
or something like it.

Change-Id: Ibbf5b17283c0e31821d04c7e08d995c654de5663
Reviewed-on: https://go-review.googlesource.com/28219
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-03-20 20:22:26 +00:00
Robert Griesemer
25b5181001 cmd/gofmt: clarify doc string even more
Since "columns of alignment" are terminated whenever indentation
changes from one line to the next, alignment with spaces will work
independent of the actually chosen tab width. Don't mention tab width
anymore.

Follow-up on https://golang.org/cl/38374/.

For #19618.

Change-Id: I58e47dfde57834f56a98d9119670757a12fb9c41
Reviewed-on: https://go-review.googlesource.com/38379
Reviewed-by: Rob Pike <r@golang.org>
2017-03-20 20:13:34 +00:00
Robert Griesemer
422c7fea70 cmd/compile: don't permit declarations in post statement of for loop
Report syntax error that was missed when moving to new parser.

Fixes #19610.

Change-Id: Ie5625f907a84089dc56fcccfd4f24df546042783
Reviewed-on: https://go-review.googlesource.com/38375
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-20 20:02:34 +00:00
Michael Munday
17570a9afb cmd/compile: emit fused multiply-{add,subtract} on ppc64x
A follow on to CL 36963 adding support for ppc64x.

Performance changes (as posted on the issue):

poly1305:
benchmark               old ns/op new ns/op delta
Benchmark64-16          172       151       -12.21%
Benchmark1K-16          1828      1523      -16.68%
Benchmark64Unaligned-16 172       151       -12.21%
Benchmark1KUnaligned-16 1827      1523      -16.64%

math:
BenchmarkAcos-16        43.9      39.9      -9.11%
BenchmarkAcosh-16       57.0      45.8      -19.65%
BenchmarkAsin-16        35.8      33.0      -7.82%
BenchmarkAsinh-16       68.6      60.8      -11.37%
BenchmarkAtan-16        19.8      16.2      -18.18%
BenchmarkAtanh-16       65.5      57.5      -12.21%
BenchmarkAtan2-16       45.4      34.2      -24.67%
BenchmarkGamma-16       37.6      26.0      -30.85%
BenchmarkLgamma-16      40.0      28.2      -29.50%
BenchmarkLog1p-16       35.1      29.1      -17.09%
BenchmarkSin-16         22.7      18.4      -18.94%
BenchmarkSincos-16      31.7      23.7      -25.24%
BenchmarkSinh-16        146       131       -10.27%
BenchmarkY0-16          130       107       -17.69%
BenchmarkY1-16          127       107       -15.75%
BenchmarkYn-16          278       235       -15.47%

Updates #17895.

Change-Id: I1c16199715d20c9c4bd97c4a950bcfa69eb688c1
Reviewed-on: https://go-review.googlesource.com/38095
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2017-03-20 20:01:29 +00:00
Robert Griesemer
01ac5b8dcf cmd/gofmt: clarify documentation re: tab width
Fixes #19618.

Change-Id: I0ac450ff717ec1f16eb12758c6bf5e98b5de20e8
Reviewed-on: https://go-review.googlesource.com/38374
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-20 18:03:55 +00:00
Brad Fitzpatrick
eb6c1dd7eb net/http: deflake TestServerAllowsBlockingRemoteAddr more
As noted in https://github.com/golang/go/issues/19161#issuecomment-287554171,
CL 37771 (adding use of the new httptest.Server.Client to all net/http
tests) accidentally reverted DisableKeepAlives for this test. For
many tests, DisableKeepAlives was just present to prevent goroutines
from staying active after the test exited.  In this case it might
actually be important. (We'll see)

Updates #19161

Change-Id: I11f889f86c932b51b11846560b68dbe5993cdfc3
Reviewed-on: https://go-review.googlesource.com/38373
Reviewed-by: Michael Munday <munday@ca.ibm.com>
2017-03-20 17:32:16 +00:00
Martin Lindhe
d80166ebbe crypto/*: fix spelling of 'below'
Change-Id: Ic9d65206ec27f6d54bb71395802929e9c769e80a
Reviewed-on: https://go-review.googlesource.com/38355
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-20 16:03:18 +00:00
Austin Clements
df6025bc0d runtime: disallow malloc or panic in scavenge
Mallocs and panics in the scavenge path are particularly nasty because
they're likely to silently self-deadlock on the mheap.lock. Avoid
sinking lots of time into debugging these issues in the future by
turning these into immediate throws.

Change-Id: Ib36fdda33bc90b21c32432b03561630c1f3c69bc
Reviewed-on: https://go-review.googlesource.com/38293
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2017-03-19 22:42:28 +00:00
Austin Clements
13ae271d5d runtime: introduce a type for lfstacks
The lfstack API is still a C-style API: lfstacks all have unhelpful
type uint64 and the APIs are package-level functions. Make the code
more readable and Go-style by creating an lfstack type with methods
for push, pop, and empty.

Change-Id: I64685fa3be0e82ae2d1a782a452a50974440a827
Reviewed-on: https://go-review.googlesource.com/38290
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2017-03-19 22:42:24 +00:00
Martin Möhrmann
2805d20689 cmd/compile: replace all uses of ptrto by typPtr
This makes the overall naming and use of the functions
to create a Type more consistent.

Passes toolstash -cmp.

Change-Id: Ie0d40b42cc32b5ecf5f20502675a225038ea40e4
Reviewed-on: https://go-review.googlesource.com/38354
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-19 14:29:53 +00:00
Martin Möhrmann
00f4cacb49 cmd/compile: reduce allocs when appending to Node slices
Rewrite Append function such that the *Node slice argument does not escape.

Passes toolstash -cmp.

name      old alloc/op    new alloc/op    delta
Template     40.8MB ± 0%     40.8MB ± 0%  -0.17%  (p=0.000 n=20+19)
Unicode      30.3MB ± 0%     30.2MB ± 0%  -0.11%  (p=0.000 n=19+20)
GoTypes       115MB ± 0%      115MB ± 0%  -0.20%  (p=0.000 n=20+20)
Compiler      492MB ± 0%      491MB ± 0%  -0.25%  (p=0.000 n=20+20)
SSA           858MB ± 0%      858MB ± 0%  -0.08%  (p=0.000 n=20+20)
Flate        26.2MB ± 0%     26.2MB ± 0%  -0.13%  (p=0.000 n=20+19)
GoParser     32.5MB ± 0%     32.4MB ± 0%  -0.14%  (p=0.000 n=20+20)
Reflect      80.6MB ± 0%     80.4MB ± 0%  -0.27%  (p=0.000 n=20+20)
Tar          27.3MB ± 0%     27.3MB ± 0%  -0.12%  (p=0.000 n=20+19)
XML          43.1MB ± 0%     43.0MB ± 0%  -0.14%  (p=0.000 n=20+20)

name      old allocs/op   new allocs/op   delta
Template       400k ± 1%       397k ± 0%  -0.81%  (p=0.000 n=20+18)
Unicode        321k ± 1%       320k ± 0%  -0.43%  (p=0.000 n=20+20)
GoTypes       1.17M ± 0%      1.16M ± 0%  -0.89%  (p=0.000 n=20+20)
Compiler      4.59M ± 0%      4.54M ± 0%  -1.26%  (p=0.000 n=20+19)
SSA           7.68M ± 0%      7.65M ± 0%  -0.37%  (p=0.000 n=18+18)
Flate          242k ± 1%       240k ± 1%  -0.70%  (p=0.000 n=20+20)
GoParser       323k ± 1%       321k ± 1%  -0.64%  (p=0.000 n=20+20)
Reflect       1.01M ± 0%      1.00M ± 0%  -0.92%  (p=0.000 n=20+19)
Tar            258k ± 1%       256k ± 1%  -0.60%  (p=0.000 n=20+19)
XML            403k ± 1%       400k ± 0%  -0.78%  (p=0.000 n=20+20)

Change-Id: Ie1eb603dc46f729574f6a76c08085b2619249be4
Reviewed-on: https://go-review.googlesource.com/37437
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-19 06:30:46 +00:00
Michel Lespinasse
81bcc47041 cmd/pprof: use proxy from environment
See #18736

Change-Id: I9c16357c05c16db677125d3077ee466b71559c7a
Reviewed-on: https://go-review.googlesource.com/38343
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-19 05:45:51 +00:00
Josh Bleecher Snyder
a68e5d94fa cmd/compile: clean up SSA test API
I noted in CL 38327 that the SSA test API felt a bit
clunky after the ssa.Func/ssa.Cache/ssa.Config refactoring,
and promised to clean it up once the dust settled.
The dust has settled.

Along the way, this CL fixes a potential latent bug,
in which the amd64 test context was used for all dummy Syslook calls.
The lone SSA test using the s390x context did not depend on the
Syslook context being correct, so the bug did not arise in practice.

Change-Id: If964251d1807976073ad7f47da0b1f1f77c58413
Reviewed-on: https://go-review.googlesource.com/38346
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-19 05:37:39 +00:00
Josh Bleecher Snyder
62947bedd2 cmd/compile: canonicalize empty interface types
Mapping all empty interfaces onto the same Type
allows better reuse of the ptrTo and sliceOf
Type caches for *interface{} and []interface{}.

This has little compiler performance impact now,
but it will be helpful in the future,
when we will eagerly populate some of those caches.

Passes toolstash-check.

Change-Id: I17daee599a129b0b2f5f3025c1be43d569d6782c
Reviewed-on: https://go-review.googlesource.com/38344
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-19 05:02:07 +00:00
Josh Bleecher Snyder
872db79989 cmd/compile: add more types to ssa.Types
This reduces the number of calls back into the
gc Type routines, which will help performance
in a concurrent backend.
It also reduces the number of callsites
that must be considered in making the transition.

Passes toolstash-check -all. No compiler performance changes.

Updates #15756

Change-Id: Ic7a8f1daac7e01a21658ae61ac118b2a70804117
Reviewed-on: https://go-review.googlesource.com/38340
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-19 02:03:44 +00:00
Josh Bleecher Snyder
aea3aff669 cmd/compile: separate ssa.Frontend and ssa.TypeSource
Prior to this CL, the ssa.Frontend field was responsible
for providing types to the backend during compilation.
However, the types needed by the backend are few and static.
It makes more sense to use a struct for them
and to hang that struct off the ssa.Config,
which is the correct home for readonly data.
Now that Types is a struct, we can clean up the names a bit as well.

This has the added benefit of allowing early construction
of all types needed by the backend.
This will be useful for concurrent backend compilation.

Passes toolstash-check -all. No compiler performance change.

Updates #15756

Change-Id: I021658c8cf2836d6a22bbc20cc828ac38c7da08a
Reviewed-on: https://go-review.googlesource.com/38336
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-19 00:21:23 +00:00
Damien Lespiau
2c397c7a75 cmd/gofmt: unindent the second line of a BUG note
Currently, this second line is treated a pre-formatted text as it's
indented relatively to the BUG() line.

The current state can be seen at:

  https://golang.org/cmd/gofmt/#pkg-note-BUG

Unindenting makes the rest of the sentence part of the same paragraph.

Change-Id: I6dee55c9c321b1a03b41c7124c6a1ea15772c878
Reviewed-on: https://go-review.googlesource.com/38353
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-18 23:33:31 +00:00
Alberto Donizetti
32cb0ce65b encoding/gob: speedup floats encoding and decoding
By replacing bytes-reversing routines with bits.ReverseBytes64 calls.

name                     old time/op  new time/op  delta
EncodeComplex128Slice-4  35.1µs ± 1%  23.2µs ± 2%  -33.94%  (p=0.000 n=20+20)
EncodeFloat64Slice-4     17.9µs ± 1%  11.0µs ± 1%  -38.36%  (p=0.000 n=17+18)

name                     old time/op  new time/op  delta
DecodeComplex128Slice-4  79.7µs ± 0%  69.9µs ± 1%  -12.31%  (p=0.000 n=20+20)
DecodeFloat64Slice-4     47.3µs ± 1%  42.2µs ± 1%  -10.65%  (p=0.000 n=17+17)

Change-Id: I91a6401c6009b5712fca6258dd1e57c6fe68ea64
Reviewed-on: https://go-review.googlesource.com/38352
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-18 18:30:41 +00:00
Josh Bleecher Snyder
b6074a417d cmd/compile: use testConfig consistently in SSA tests
Change-Id: Iae41e14ee55eb4068fcb2189a77b345a7c5468b4
Reviewed-on: https://go-review.googlesource.com/38333
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-18 00:40:40 +00:00
Matthew Dempsky
3928e847bd net: fix tests for /etc/hosts with entries named "test"
Fixes #19592.

Change-Id: I8946b33fd36ae1f39bdcc4bf0bd4b5b99618efe8
Reviewed-on: https://go-review.googlesource.com/38300
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-18 00:02:34 +00:00
Josh Bleecher Snyder
dc4434a0c0 cmd/compile: make stkptrsize local
While we're here, also eliminate a few more Curfn uses.

Passes toolstash -cmp. No compiler performance impact.

Updates #15756

Change-Id: Ib8db9e23467bbaf16cc44bf62d604910f733d6b8
Reviewed-on: https://go-review.googlesource.com/38331
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-17 23:57:27 +00:00
Josh Bleecher Snyder
758b5b3284 cmd/compile: make Stksize local
Passes toolstash -cmp. No compiler performance impact.

Updates #15756

Change-Id: I85b45244453ae28d4da76be4313badddcbf3f5dc
Reviewed-on: https://go-review.googlesource.com/38330
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-17 23:57:15 +00:00
Josh Bleecher Snyder
e0a5e69be2 cmd/compile: make Maxarg local
Passes toolstash -cmp. No compiler performance impact.

Updates #15756

Change-Id: I1294058716d83dd1be495d399ed7ab2277754dc6
Reviewed-on: https://go-review.googlesource.com/38329
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-17 23:57:03 +00:00
Josh Bleecher Snyder
174b858f78 cmd/compile: pass frame size to defframe
Preparation for de-globalizing Stksize and MaxArg.

Passes toolstash -cmp. No compiler performance impact.

Updates #15756

Change-Id: I312f0bbd15587a6aebf472cd66c8e62b89e55c8a
Reviewed-on: https://go-review.googlesource.com/38328
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-17 23:56:22 +00:00
Brad Fitzpatrick
d83af90a89 Revert "go/types: enforce Check path restrictions via panics"
This reverts commit b744a11a96.

Reason for revert: Broke trybots. (misc-vetall builder is busted)

Change-Id: I651d1c18db2fb3cb6ec12c2ae62024627baf8d77
Reviewed-on: https://go-review.googlesource.com/38332
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-17 23:53:27 +00:00
Josh Bleecher Snyder
da8e939ba9 cmd/compile: thread Curfn through SSA
This is a first step towards eliminating the
Curfn global in the backend.
There's more to do.

Passes toolstash -cmp. No compiler performance impact.

Updates #15756

Change-Id: Ib09f550a001e279a5aeeed0f85698290f890939c
Reviewed-on: https://go-review.googlesource.com/38232
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-17 23:45:22 +00:00
Cherry Zhang
ce584e516e cmd/compile: using a single Store op for non-pointer non-skip store
This makes fewer Values around until decomposing, reducing
allocation in compiler.

name       old alloc/op    new alloc/op    delta
Template      41.4MB ± 0%     40.8MB ± 0%  -1.29%  (p=0.000 n=10+10)
Unicode       30.3MB ± 0%     30.2MB ± 0%  -0.24%  (p=0.000 n=10+10)
GoTypes        118MB ± 0%      115MB ± 0%  -2.23%  (p=0.000 n=10+10)
Compiler       505MB ± 0%      493MB ± 0%  -2.47%  (p=0.000 n=10+10)
SSA            881MB ± 0%      872MB ± 0%  -1.03%  (p=0.000 n=10+10)

name       old allocs/op   new allocs/op   delta
Template        401k ± 1%       400k ± 1%    ~     (p=0.631 n=10+10)
Unicode         321k ± 0%       321k ± 1%    ~     (p=0.684 n=10+10)
GoTypes        1.18M ± 0%      1.17M ± 0%  -0.34%  (p=0.000 n=10+10)
Compiler       4.63M ± 0%      4.61M ± 0%  -0.43%  (p=0.000 n=10+10)
SSA            7.83M ± 0%      7.82M ± 0%  -0.13%  (p=0.000 n=10+10)

Change-Id: I8f736396294444248a439bd4c90be1357024ce88
Reviewed-on: https://go-review.googlesource.com/38294
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-03-17 23:21:45 +00:00
Josh Bleecher Snyder
2cdb7f118a cmd/compile: move Frontend field from ssa.Config to ssa.Func
Suggested by mdempsky in CL 38232.
This allows us to use the Frontend field
to associate frontend state and information
with a function.
See the following CL in the series for examples.

This is a giant CL, but it is almost entirely routine refactoring.

The ssa test API is starting to feel a bit unwieldy.
I will clean it up separately, once the dust has settled.

Passes toolstash -cmp.

Updates #15756

Change-Id: I71c573bd96ff7251935fce1391b06b1f133c3caf
Reviewed-on: https://go-review.googlesource.com/38327
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-17 23:18:57 +00:00
Josh Bleecher Snyder
193510f2f6 cmd/compile: evaluate config as needed in rewrite rules
Prior to this CL, config was an explicit argument
to the SSA rewrite rules, and rules that needed
a Frontend got at it via config.
An upcoming CL moves Frontend from Config to Func,
so rules can no longer reach Frontend via Config.
Passing a Frontend as an argument to the rewrite rules
causes a 2-3% regression in compile times.
This CL takes a different approach:
It treats the variable names "config" and "fe"
as special and calculates them as needed.
The "as needed part" is also important to performance:
If they are calculated eagerly, the nilchecks themselves
cause a regression.

This introduces a little bit of magic into the rewrite
generator. However, from the perspective of the rules,
the config variable was already more or less magic.
And it makes the upcoming changes much clearer.

Passes toolstash -cmp.

Change-Id: I173f2bcc124cba43d53138bfa3775e21316a9107
Reviewed-on: https://go-review.googlesource.com/38326
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-17 22:35:29 +00:00