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

29140 Commits

Author SHA1 Message Date
Josh Bleecher Snyder
88858fa58f container/list: silence vet warnings
container/list/list_test.go:274: self-assignment of e1 to e1
container/list/list_test.go:274: self-assignment of e4 to e4
container/list/list_test.go:282: self-assignment of e1 to e1
container/list/list_test.go:286: self-assignment of e1 to e1
container/list/list_test.go:286: self-assignment of e4 to e4

Updates #11041

Change-Id: Ibd90cf6a924e93497908f437b814c3fc82937f4a
Reviewed-on: https://go-review.googlesource.com/27114
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 14:35:37 +00:00
Cherry Zhang
4c4ca83120 cmd/compile: remove nil check in accessing PAUTOHEAP variable
CL 23393 introduces PAUTOHEAP, and access of PAUTOHEAP variable is
rewritten to indirection of a PAUTO variable. Mark this variable
non-nil, so this indirection does not introduce extra nil checks.

Change-Id: I31853eed5e60238b6c5bc0546e2e9ab340dcddd9
Reviewed-on: https://go-review.googlesource.com/26831
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-16 14:32:13 +00:00
Josh Bleecher Snyder
40cf4ad0ef all: fix "result not used" vet warnings
For tests, assign to _.
For benchmarks, assign to a sink.

Updates #11041

Change-Id: I87c5543245c7bc74dceb38902f4551768dd37948
Reviewed-on: https://go-review.googlesource.com/27116
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 14:15:10 +00:00
Josh Bleecher Snyder
c70bdd3788 cmd/compile: fix bad generated format strings in test
We were generating format strings containing
a lone %. Vet legitimately complains:

cmd/compile/internal/gc/constFold_test.go:339: unrecognized printf verb ' '

The fix doesn't make for very readable code,
but it is simple and obviously correct.

Updates #11041

Change-Id: I90bd2d1d140887f5229752a279f7e46921472fbb
Reviewed-on: https://go-review.googlesource.com/27115
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 14:14:51 +00:00
Josh Bleecher Snyder
2cbe735366 syscall: unify unix/amd64 asm implementations
Updates #11041

Change-Id: I77e5ca0b61ffc530ee46848721a177867c81d548
Reviewed-on: https://go-review.googlesource.com/25116
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 14:12:58 +00:00
Josh Bleecher Snyder
a5464af554 syscall: split out unix Syscall9 asm support
This is preliminary work to unifying them.
Aside from Syscall9, all are identical.
Syscall9 has a netbsd/openbsd variant
and a dragonfly/freebsd variant.

Updates #11041

Change-Id: Ia5ce95d5e9115d4c0492d5e53aa7a4316deafd1f
Reviewed-on: https://go-review.googlesource.com/25115
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 14:12:40 +00:00
Josh Bleecher Snyder
33f95ec4ec syscall: superficial cleanup of amd64 unix assembly
This is preliminary work to unifying them.

Updates #11041

Change-Id: Ibe83da3d626f1da9e8888e26cedd3af2152b42e6
Reviewed-on: https://go-review.googlesource.com/25114
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 14:12:29 +00:00
Josh Bleecher Snyder
856342d844 syscall: fix dragonfly/amd64 assembly argument sizes
This is preliminary work to unifying the
unix amd64 assembly implementations,
which is preliminary work to making the
assembly vet-friendly.

Updates #11041

Change-Id: Ic64985124f8fb86cc08898be2ec7fca972ced4ca
Reviewed-on: https://go-review.googlesource.com/25113
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 14:12:16 +00:00
Josh Bleecher Snyder
b173298c89 syscall: unify unix 386 implementations
They were identical.

This will allow us to do the TODO at the top
of the file only once.

Updates #11041

Change-Id: I07aaca27ae46b66b65780082988bdc7546ed534b
Reviewed-on: https://go-review.googlesource.com/25112
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 14:12:02 +00:00
Cherry Zhang
1e94d79f9d cmd/compile: disable Duff's device on darwin/arm64
Darwin linker does not support BR26 reloc with non-zero addend.

Fixes #16724.

Change-Id: I1b5b4dc7159141bde3e273490f435c08c583afaf
Reviewed-on: https://go-review.googlesource.com/27081
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-08-16 10:41:53 +00:00
Brad Fitzpatrick
6fd2d2cf16 net/http: make Transport retry non-idempotent requests if no bytes written
If the server failed on us before we even tried to write any bytes,
it's safe to retry the request on a new connection, regardless of the
HTTP method/idempotence.

Fixes #15723

Change-Id: I25360f82aac530d12d2b3eef02c43ced86e62906
Reviewed-on: https://go-review.googlesource.com/27117
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 06:20:12 +00:00
Josh Bleecher Snyder
fe27291c00 cmd/compile: reduce garbage from autolabel
Follow-up to CL 26661

Change-Id: I67c58d17313094675cf0f30ce50d486818ae0dcb
Reviewed-on: https://go-review.googlesource.com/27113
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 04:29:32 +00:00
Gyu-Ho Lee
77e68ea78a archive/tar: preallocate slice from paxHeaders
Preallocate keys slice with the length of paxHeaders map
to prevent slice growth with append operations.

Change-Id: Ic9a927c4eaa775690a4ef912d61dd06f38e11510
Reviewed-on: https://go-review.googlesource.com/23782
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 02:46:50 +00:00
Mikio Hara
2cb471e40d crypto/tls: gofmt -w -s
Change-Id: Iedf9000e3bb1fa73b4c3669eae846e85f1f5fdfe
Reviewed-on: https://go-review.googlesource.com/24489
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 02:30:53 +00:00
Brad Fitzpatrick
5a59516dd7 net/http: deflake BenchmarkClient and its use of a fixed port for testing
Let the kernel pick a port for testing, and have the server in the
child process tell the parent (benchmarking) process the port that
was selected.

Fixes flakes like seen in https://golang.org/cl/27050 (and previously)

Change-Id: Ia2b705dc4152f70e0a5725015bdae09984d09d53
Reviewed-on: https://go-review.googlesource.com/27051
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-16 01:46:41 +00:00
Jan Mercl
52fcff3ec1 go/token: Fix race in FileSet.PositionFor.
Methods of FileSet are documented to be safe for concurrent use by
multiple goroutines, so FileSet is protected by a mutex and all its
methods use it to prevent concurrent mutations. All methods of File that
mutate the respective FileSet, including AddLine, do also lock its
mutex, but that does not help when PositionFor is invoked concurrently
and reads without synchronization what AddLine mutates.

The change adds acquiring a RLock around the racy call of File.position
and the respective test.

Fixes #16548

Change-Id: Iecaaa02630b2532cb29ab555376633ee862315dd
Reviewed-on: https://go-review.googlesource.com/25345
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 01:45:25 +00:00
Carlos C
14e446d909 bytes: add examples
`bytes` and `strings` are pretty similar to each other, this commit
brings `strings` examples to its counter-part.

Partially addresses #16360

Change-Id: I551320eaa78be9df69012035f1c3333f500e04c9
Reviewed-on: https://go-review.googlesource.com/25062
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 01:33:32 +00:00
Chris Broadfoot
35f5517ce9 doc: add 1.7 to golang.org/project
Change-Id: Ib17f6643efd49e2bca188c4faa505f79832d18b1
Reviewed-on: https://go-review.googlesource.com/27110
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 01:04:17 +00:00
Mikio Hara
7c31043cca os/exec: fix nit found by vet
Change-Id: I8085ed43d63215237a4871cc1e44257132a7f5de
Reviewed-on: https://go-review.googlesource.com/27130
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 00:44:45 +00:00
Sina Siadat
b98d8cd5ce container/heap: remove one unnecessary comparison in Fix
The heap.Fix function calls both down and up.  If the element is moved
down, we don't need to call up and we could save a comparison.

(per suggestion by Radu Berinde)

Fixes #16098.

Change-Id: I83a74710e66cf0d274d8c0743338c26f89f31afe
Reviewed-on: https://go-review.googlesource.com/24273
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-16 00:40:03 +00:00
Michael Hudson-Doyle
b5e43e669a cmd/link: when dynlinking, do not mangle short symbol names
When dynamically linking, a type symbol's name is replaced with a name based on
the SHA1 of the name as type symbol's names can be very long.  However, this
can make a type's symbol name longer in some cases. So skip it in that case.
One of the symbols this changes the treatment of is 'type.string' and that fixes a
bug where -X doesn't work when dynamically linking.

Fixes #16671

Change-Id: If5269038261b76fb0ec52e25a9c1d64129631e3c
Reviewed-on: https://go-review.googlesource.com/26890
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-16 00:37:09 +00:00
Brad Fitzpatrick
3ddc9ad916 strings: add special cases for Join of 2 and 3 strings
We already had special cases for 0 and 1. Add 2 and 3 for now too.
To be removed if the compiler is improved later (#6714).

This halves the number of allocations and total bytes allocated via
common filepath.Join calls, improving filepath.Walk performance.

Noticed as part of investigating filepath.Walk in #16399.

Change-Id: If7b1bb85606d4720f3ebdf8de7b1e12ad165079d
Reviewed-on: https://go-review.googlesource.com/25005
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 00:33:15 +00:00
Josh Bleecher Snyder
c88e868030 cmd/internal/obj: add generated String method for AddrType
Generated with:

stringer -type AddrType cmd/internal/obj

Change-Id: I74509cffab774035c5ca2ac0634638d73dbd33f3
Reviewed-on: https://go-review.googlesource.com/26657
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 00:28:57 +00:00
Josh Bleecher Snyder
a9ed47735f cmd/compile: move auto label gen variables to local function
This still depends on Curfn, but it's progress.

Updates #15756

Change-Id: Ic32fe56f44fcfbc023e7668d4dee07f8b47bf3a4
Reviewed-on: https://go-review.googlesource.com/26661
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-16 00:28:22 +00:00
Josh Bleecher Snyder
d94409d651 go/types: fix bad printf verbs
This fixes the following vet warnings:

go/types/builtins.go:437: arg call for printf verb %s of wrong type: *go/ast.CallExpr
go/types/builtins.go:598: arg call for printf verb %s of wrong type: *go/ast.CallExpr

Updates #11041

Change-Id: I746d054e8e49b330fbdf961912a98f55dd5f3ff9
Reviewed-on: https://go-review.googlesource.com/26997
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-16 00:24:37 +00:00
Josh Bleecher Snyder
e0d8064ed4 go/types: fix multiword data structure alignment on nacl
Fixes #16464

Change-Id: Ibf5625c1b5fa3abd18623023f18664e8f81fa45a
Reviewed-on: https://go-review.googlesource.com/26996
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-16 00:24:16 +00:00
Carlos C
7a974a4c60 encoding/json: add example for RawMessage marshalling
Fixes #16648

Change-Id: I3ab21ab33ca3f41219de9518ac6a39f49131e5e5
Reviewed-on: https://go-review.googlesource.com/26692
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 00:22:47 +00:00
Josh Bleecher Snyder
3357a02b74 math/big: use array instead of slice for deBruijn lookups
This allows the compiler to remove a bounds check.

math/big/nat.go:681: index bounds check elided
math/big/nat.go:683: index bounds check elided

Change-Id: Ieecb89ec5e988761b06764bd671672015cd58e9d
Reviewed-on: https://go-review.googlesource.com/26663
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 00:22:13 +00:00
Ilya Tocar
4e24e1d999 cmd/internal/obj/x86: VPSHUFD takes an unsigned byte.
VPSHUFD should take an unsigned argument to be consistent with
PSHUFD. Also fix all usage.

Fixes #16499

Change-Id: Ie699c102afed0379445914a251710365b14d89b6
Reviewed-on: https://go-review.googlesource.com/25383
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 00:21:50 +00:00
Josh Bleecher Snyder
df9eeb1922 go/types: remove struct Sizeof cache
It was not responsive to the sizes param.
Remove it, and unwind the extra layers.

Fixes #16316

Change-Id: I940a57184a1601f52348d4bff8638f3f7462f5cd
Reviewed-on: https://go-review.googlesource.com/26995
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-16 00:21:27 +00:00
Brad Fitzpatrick
133d231a89 cmd/compile/internal/gc: get rid of useless autopkg variable
autopkg == localpkg, so it appears to be a remnant of earlier code.

Change-Id: I65b6c074535e877317cbf9f1f35e94890f0ebf14
Reviewed-on: https://go-review.googlesource.com/26662
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-16 00:19:16 +00:00
Robert Griesemer
3dc082f8fe go/types: minor cleanups
1) Removed mark field from declInfo struct. Instead use a visited map
   in ordering.go which was the only use place for the mark field.

2) Introduced objSet type for the common map[Object]bool type.

3) Improved comments.

Change-Id: I7544e7458d844b0ca08193f11de6238d317eaf2d
Reviewed-on: https://go-review.googlesource.com/24153
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-08-16 00:18:34 +00:00
Robert Griesemer
5c84441d88 go/types: fix computation of initialization order
The old algorithm operated on a dependency graph that included
all objects (including functions) for simplicity: it was based
directly on the dependencies collected for each object during
type checking an object's initialization expression. It also
used that graph to compute the objects involved in an erroneous
initialization cycle.

Cycles that consist only of (mutually recursive) functions are
permitted in initialization code; so those cycles were silently
ignored if encountered. However, such cycles still inflated the
number of dependencies a variable might have (due to the cycle),
which in some cases lead to the wrong variable being scheduled
for initialization before the one with the inflated dependency
count.

Correcting for the cycle when it is found is too late since at
that point another variable may have already been scheduled.

The new algorithm computes the initialization dependency graph as
before but adds an extra pass during which functions are eliminated
from the graph (and their dependencies are "back-propagated").
This eliminates the problem of cycles only involving functions
(there are no functions).

When a cycle is found, the new code computes the cycle path from
the original object dependencies so it can still include functions
on the path as before, for the same detailed error message.

The new code also more clearly distinguishes between objects that
can be in the dependency graph (constants, variables, functions),
and objects that cannot, by introducing the dependency type, a new
subtype of Object. As a consequence, the dependency graph is smaller.

Fixes #10709.

Change-Id: Ib58d6ea65cfb279041a0286a2c8e865f11d244eb
Reviewed-on: https://go-review.googlesource.com/24131
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-08-16 00:18:06 +00:00
Brad Fitzpatrick
66da885594 syscall: test Gettimeofday everywhere, not just on Darwin
The Darwin-only restriction was because we were late in the Go 1.7
cycle when the test was added.

In the process, I noticed Gettimeofday wasn't in the "unimplemented
midden heap" section of syscall_nacl.go, despite this line in the
original go1.txt:

pkg syscall, func Gettimeofday(*Timeval) error

So, add it, returning ENOSYS like the others.

Change-Id: Id7e02e857b753f8d079bee335c22368734e92254
Reviewed-on: https://go-review.googlesource.com/26772
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-08-16 00:17:21 +00:00
Hiroshi Ioka
664c4a1f87 os: consolidate files
Code movement only.

If someone finds function 'foo' in "foo_linux.go",
they will expect that the Window version of 'foo' exists in "foo_windows.go".

Current code doesn't follow this manner.

For example, 'sameFile' exists in "file_unix.go",
"stat_plan9.go" and "types_windows.go".

The CL address that problem by following rules:

* readdir family => dir.go, dir_$GOOS.go
* stat family => stat.go, stat_$GOOS.go
* path-functions => path_$GOOS.go
* sameFile => types.go, types_$GOOS.go
* process-functions => exec.go, exec_$GOOS.go
* hostname => sys.go, sys_$GOOS.go

Change-Id: Ic3c64663ce0b2a364d7a414351cd3c772e70187b
Reviewed-on: https://go-review.googlesource.com/27035
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 00:15:36 +00:00
Gerrit Code Review
c307e1628c Merge "Merge remote-tracking branch 'origin/dev.ssa' into merge" 2016-08-16 00:10:35 +00:00
Keith Randall
88c8b7c7f9 Merge remote-tracking branch 'origin/dev.ssa' into merge
Merging from dev.ssa back into master.

Contains complete SSA backends for arm, arm64, 386, amd64p32.
Work in progress for PPC64.

Change-Id: Ifd7075e3ec6f88f776e29f8c7fd55830328897fd
2016-08-15 17:07:16 -07:00
Chris Broadfoot
d47bcd157c doc: document go1.7
Change-Id: Ieae5831b35768a625bf735a38f3d938f23f0b77b
Reviewed-on: https://go-review.googlesource.com/27057
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-15 20:10:28 +00:00
Chris Broadfoot
1003b3e1f0 doc: update version tag in source install instructions
Change-Id: Id83e0371b7232b01be83640ef1e47f9026cf2a23
Reviewed-on: https://go-review.googlesource.com/27055
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-15 19:42:55 +00:00
Chris Broadfoot
c6f19fe1ea doc/go1.7.html: remove DRAFT
Fixes #15820.

Change-Id: Ia5d5237754e77774a3a6049765eea163911f41c9
Reviewed-on: https://go-review.googlesource.com/25592
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-15 18:46:52 +00:00
David Chase
d08010f94e [dev.ssa] cmd/compile: PPC64, FP to/from int conversions.
Passes ssa_test.

Requires a few new instructions and some scratchpad
memory to move data between G and F registers.

Also fixed comparisons to be correct in case of NaN.
Added missing instructions for run.bash.
Removed some FP registers that are apparently "reserved"
(but that are also apparently also unused except for a
gratuitous multiplication by two when y = x+x would work
just as well).

Currently failing stack splits.

Updates #16010.

Change-Id: I73b161bfff54445d72bd7b813b1479f89fc72602
Reviewed-on: https://go-review.googlesource.com/26813
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-08-15 14:47:49 +00:00
Cherry Zhang
d99cee79b9 [dev.ssa] cmd/compile, etc.: more ARM64 optimizations, and enable SSA by default
Add more ARM64 optimizations:
- use hardware zero register when it is possible.
- use shifted ops.
  The assembler supports shifted ops but not documented, nor knows
  how to print it. This CL adds them.
- enable fast division.
  This was disabled because it makes the old backend generate slower
  code. But with SSA it generates faster code.

Turn on SSA by default, also adjust tests.

Change-Id: I7794479954c83bb65008dcb457bc1e21d7496da6
Reviewed-on: https://go-review.googlesource.com/26950
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-08-15 03:37:34 +00:00
Keith Randall
94c8e59ae1 [dev.ssa] cmd/compile: simplify 386+PIC+globals a bit
We shouldn't issue instructions like MOVL foo(SB), AX directly from the
SSA backend.  Instead we should do LEAL foo(SB), AX; MOVL (AX), AX.

This simplifies obj logic because now only LEAL needs to be treated
specially.  The register allocator uses the LEAL to in effect allocate
the temporary register required for the shared library thunk calls.

Also, the LEALs can now be CSEd.  So code like
    var g int
    func f() { g += 5 }
Requires only one thunk call instead of 2.

Change-Id: Ib87d465f617f73af437445871d0ea91a630b2355
Reviewed-on: https://go-review.googlesource.com/26814
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-08-11 20:34:47 +00:00
Keith Randall
8f955d3664 [dev.ssa] cmd/compile: fix fp constant loads for 386+PIC
In position-independent 386 code, loading floating-point constants from
the constant pool requires two steps: materializing the address of
the constant pool entry (requires calling a thunk) and then loading
from that address.

Before this CL, the materializing happened implicitly in CX, which
clobbered that register.

Change-Id: Id094e0fb2d3be211089f299e8f7c89c315de0a87
Reviewed-on: https://go-review.googlesource.com/26811
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-11 19:52:45 +00:00
Cherry Zhang
ed1ad8f56c [dev.ssa] cmd/compile: add some ARM64 optimizations
Mostly mirrors ARM, includes:
- constant folding
- simplification of load, store, extension, and arithmetics
- nilcheck removal

Change-Id: Iffaa5fcdce100fe327429ecab316cb395e543469
Reviewed-on: https://go-review.googlesource.com/26710
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-08-11 18:08:47 +00:00
Cherry Zhang
748aa84424 [dev.ssa] cmd/internal/obj/arm64: fix encoding constant into some instructions
When a constant can be encoded in a logical instruction (BITCON), do
it this way instead of using the constant pool. The BITCON testing
code runs faster than table lookup (using map):

(on AMD64 machine, with pseudo random input)
BenchmarkIsBitcon-4   	300000000	         4.04 ns/op
BenchmarkTable-4      	50000000	        27.3 ns/op

The equivalent C code of BITCON testing is formally verified with
model checker CBMC against linear search of the lookup table.

Also handle cases when a constant can be encoded in a MOV instruction.
In this case, materializa the constant into REGTMP without using the
constant pool.

When constants need to be added to the constant pool, make sure to
check whether it fits in 32-bit. If not, store 64-bit.

Both legacy and SSA compiler backends are happy with this.

Fixes #16226.

Change-Id: I883e3069dee093a1cdc40853c42221a198a152b0
Reviewed-on: https://go-review.googlesource.com/26631
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-10 20:33:11 +00:00
Josh Bleecher Snyder
31ad583ab2 testing: respect benchtime on very fast benchmarks
When ns/op dropped below 1, the old code
ignored benchtime and reverted to 1s.

Change-Id: I59752cef88d8d73bfd5b085f5400ae657f78504e
Reviewed-on: https://go-review.googlesource.com/26664
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
2016-08-10 19:44:08 +00:00
Keith Randall
c069bc4996 [dev.ssa] cmd/compile: implement GO386=387
Last part of the 386 SSA port.

Modify the x86 backend to simulate SSE registers and
instructions with 387 registers and instructions.
The simulation isn't terribly performant, but it works,
and the old implementation wasn't very performant either.
Leaving to people who care about 387 to optimize if they want.

Turn on SSA backend for 386 by default.

Fixes #16358

Change-Id: I678fb59132620b2c47e993c1c10c4c21135f70c0
Reviewed-on: https://go-review.googlesource.com/25271
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-10 17:41:01 +00:00
Keith Randall
77ef597f38 [dev.ssa] cmd/compile: more fixes for 386 shared libraries
Use the destination register for materializing the pc
for GOT references also. See https://go-review.googlesource.com/c/25442/
The SSA backend assumes CX does not get clobbered for these instructions.

Mark duffzero as clobbering CX. The linker needs to clobber CX
to materialize the address to call. (This affects the non-shared-library
duffzero also, but hopefully forbidding one register across duffzero
won't be a big deal.)

Hopefully this is all the cases where the linker is clobbering CX
under the hood and SSA assumes it isn't.

Change-Id: I080c938170193df57cd5ce1f2a956b68a34cc886
Reviewed-on: https://go-review.googlesource.com/26611
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-08-10 17:09:38 +00:00
David Chase
ff37d0e681 [dev.ssa] cmd/compile: PPC: FP load/store/const/cmp/neg; div/mod
FP<->int conversions remain.

Updates #16010.

Change-Id: I38d7a4923e34d0a489935fffc4c96c020cafdba2
Reviewed-on: https://go-review.googlesource.com/25589
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-09 17:13:43 +00:00