1
0
mirror of https://github.com/golang/go synced 2024-11-14 09:20:28 -07:00
Commit Graph

33947 Commits

Author SHA1 Message Date
Marvin Stenger
f22ba1f247 all: prefer strings.IndexByte over strings.Index
strings.IndexByte was introduced in go1.2 and it can be used
effectively wherever the second argument to strings.Index is
exactly one byte long.

This avoids generating unnecessary string symbols and saves
a few calls to strings.Index.

Change-Id: I1ab5edb7c4ee9058084cfa57cbcc267c2597e793
Reviewed-on: https://go-review.googlesource.com/65930
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-25 17:35:41 +00:00
Alessandro Arzilli
5e92c41128 runtime: fix TestGdbConst on windows
Some (all?) versions of gdb on windows output "\r\n" as line ending
instead of "\n".

Fixes #22012

Change-Id: I798204fd9f616d6d2c9c28eb5227fadfc63c0d45
Reviewed-on: https://go-review.googlesource.com/65850
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-25 11:34:24 +00:00
griesemer
45395b5ad6 go/types: don't accept incorrect shift expression arguments
Under certain circumstances involving shifts, go/types didn't verify
that untyped constant values were representable by the relevant type,
leading to the acceptance of incorrect programs (see the issue).

Fixing this code exposed another problem with int-to-string conversions
which suddenly failed because now the type-checker complained that a
(constant) integer argument wasn't representable as a string. Fixed that
as well.

Added many additional tests covering the various scenarious.

Found two cmd/compile bugs in the process (#21979, #21981) and filed
a go/types TODO (#21982).

Fixes #21727.

Change-Id: If443ee0230979cd7d45d2fc669e623648caa70da
Reviewed-on: https://go-review.googlesource.com/65370
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-09-25 08:54:28 +00:00
Daniel Martí
6945c67e10 cmd/compile: merge bytes inline test with the rest
In golang.org/cl/42813, a test was added in the bytes package to check
if a Buffer method was being inlined, using 'go tool nm'.

Now that we have a compiler test that verifies that certain funcs are
inlineable, merge it there. Knowing whether the funcs are inlineable is
also more reliable than whether or not their symbol appears in the
binary, too. For example, under some circumstances, inlineable funcs
can't be inlined, such as if closures are used.

While at it, add a few more bytes.Buffer methods that are currently
inlined and should clearly stay that way.

Updates #21851.

Change-Id: I62066e32ef5542d37908bd64f90bda51276da4de
Reviewed-on: https://go-review.googlesource.com/65658
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-25 06:52:31 +00:00
Daniel Martí
0168fdb552 cmd/compile: refactor some more gotos away
The ones in racewalk.go are almost all useless, since they were just
breaks.

typecheck.go wasn't trivial, but still doable with an if/else chain.

Also remove a single silly goto in const.go, while at it.

Change-Id: I776a78df6bb3b6bd4f7e5feec546c772baf4e02e
Reviewed-on: https://go-review.googlesource.com/65652
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-09-25 06:51:53 +00:00
Minaev Mike
8598396d81 net/mail: skip trailing comment while parsing email
The existing implementation doesn't handle
comment constructions in email address.
So addresses that are consistent with RFC 5322
don't parse at all.

Fixes #21257

Change-Id: Iae3ba951dfb26b7cf0e1885a680bbceb9123d6d5
Reviewed-on: https://go-review.googlesource.com/53550
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-24 23:26:13 +00:00
Agniva De Sarker
ff3123d1f6 sort: update main example to use Slice along with Sort
This is to let sort.Slice get more prominence since
it's the most common use case.

Fixes #21989

Change-Id: I0b180cc20256f5f09065b722e191c508c872f4f7
Reviewed-on: https://go-review.googlesource.com/65710
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-24 14:40:37 +00:00
Daniel Martí
48ec5122ff cmd/go: move GOOS/GOARCH and tags checks to Init
They were in Do, which is the method that actually starts the build.
However, we can already run these checks in Init, since we already have
all the information necessary to do the checks.

More importantly, some work happens between Init and Do, namely package
loading. That may exit with an error, meaning that in some cases the
user gets a confusing error instead of the correct one.

For example, using a GOOS typo, before showed:

	$ GOOS=windwos go build
	can't load package: package p: build constraints exclude all Go files in ...

And now:

	$ GOOS=windwos go build
	cmd/go: unsupported GOOS/GOARCH pair windwos/amd64

Also had to tweak TestGoEnv to modify GOOS as well as GOARCH. Otherwise,
on windows this would result in the invalid GOOS/GOARCH pair
windows/arm, which would error given that we now check that in non-build
commands such as "go env".

Fixes #21999.

Change-Id: Iff9890dea472bff0179a9d703d6f698a0e3187c1
Reviewed-on: https://go-review.googlesource.com/65656
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-09-24 14:32:38 +00:00
Ian Lance Taylor
9f7fd893dc os: don't refer directly to Sysfd in epipecheck
Instead record in the File whether it is stdout/stderr. This avoids a
race between a call to epipecheck and closing the file.

Fixes #21994

Change-Id: Ic3d552ffa83402136276bcb5029ec3e6691042c2
Reviewed-on: https://go-review.googlesource.com/65750
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-09-24 14:25:50 +00:00
Daniel Theophanes
14a1d934b6 database/sql: update minor sql docs
Replace the work "session" with "connection" in docs. Fix
The ErrConnDone documentation. Clarify what the context is used
for in StmtContext.

Change-Id: I2f07e58d0cd6321b386a73b038cf6070cb8e2572
Reviewed-on: https://go-review.googlesource.com/65732
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-24 13:58:38 +00:00
Daniel Martí
24ca86f308 cmd/compile: fix invalid switch case value panic
This is a regression introduced by myself in golang.org/cl/41852,
confirmed by the program that reproduces the crash that can be seen in
the added test.

Fixes #21988.

Change-Id: I18d5b2b3de63ced84db705b18490b00b16b59e02
Reviewed-on: https://go-review.googlesource.com/65655
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-24 10:15:52 +00:00
Alex Brainman
7739b8a97f path/filepath: simplify TestEvalSymlinks
Change-Id: I4a747fca0db3cbd4972feaddcb625041b648620b
Reviewed-on: https://go-review.googlesource.com/56710
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-24 01:58:24 +00:00
Alex Brainman
18b49db18e cmd/go: ignore empty path elements in GOPATH
go command refuses to use GOPATH with empty path elements
(like %GOPATH%=C:\go;). But environment variable change dialog
on Windows 10 produces strings ending with ; (see issue #21928
for a picture). Just accept GOPATH with empty path elements,
and ignore all empty path elements.

Fixes #21928

Change-Id: I1d3c3a19274ed69204d29ae06c3e8ff8c57c1ca0
Reviewed-on: https://go-review.googlesource.com/65151
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-24 01:41:21 +00:00
James Lawrence
e6358c798b database/sql: add OpenDB to directly create a *DB without a DSN.
The current Open method limits the ability for driver maintainers
to expose options for their drivers by forcing all the configuration
to pass through the DSN in order to create a *DB.

This CL allows driver maintainers to write their own initialization
functions that return a *DB making configuration of the underlying
drivers easier.

Fixes #20268

Change-Id: Ib10b794f36a201bbb92c23999c8351815d38eedb
Reviewed-on: https://go-review.googlesource.com/53430
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-23 20:47:06 +00:00
Daniel Martí
6936671ed1 cmd/compile: clarify adjustctxt inlining comment
The reason why adjustctxt wasn't being inlined was reported as:

	function too complex: cost 92 exceeds budget 80

However, after tweaking the code to be under the budget limit, we see
the real blocker:

	non-leaf function

There is little we can do about this one in particular at the moment.
Create a section with funcs that will need mid-stack inlining to be
inlineable, since this will likely come up again in other cases.

Change-Id: I3a8eb1546b289a060ac896506a007b0496946e84
Reviewed-on: https://go-review.googlesource.com/65650
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-09-23 20:24:10 +00:00
Hajime Hoshi
7537bb7b30 cmd/compile/internal/gc: unexport global constants
Change-Id: Ib292ef3b0a31b2c7bdd77519324362667f30389c
Reviewed-on: https://go-review.googlesource.com/44393
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-23 20:11:30 +00:00
Giovanni Bajo
2f8b555de2 archive/tar: fix sparse files support on Darwin
Apple defined the SEEK_HOLE/SEEK_DATA constants in unistd.h
with swapped values, compared to all other UNIX systems.

Fixes #21970

Change-Id: I84a33e0741f0f33a2e04898e96b788b87aa9890f
Reviewed-on: https://go-review.googlesource.com/65570
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-23 16:53:28 +00:00
Shawn Smith
6171d055dc cmd/vet: remove extraneous "//" in dead.go so its comment does not
appear at the top of vet's godoc output

Change-Id: I2593d294b0497aeb9e8c54a4dad052b5c33ecaee
Reviewed-on: https://go-review.googlesource.com/65630
Reviewed-by: Rob Pike <r@golang.org>
2017-09-23 09:24:02 +00:00
Joe Tsai
6872a8e1c9 encoding/json: cleanup detection of unexported embedded fields
CL 60410 fixes the compiler such that reflect.StructField.PkgPath
is non-empty if and only if the field is unexported.
Given that property, we can cleanup the logic in the json encoder
to avoid parsing the field name to detect export properties.

Updates #21122

Change-Id: Ic01b9c4ca76386774846b742b0c1b9b948f53e7c
Reviewed-on: https://go-review.googlesource.com/65550
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-09-23 00:33:34 +00:00
Austin Clements
e97209515a runtime: hide <autogenerated> methods from call stack
The compiler generates wrapper methods to forward interface method
calls (which are always pointer-based) to value methods. These
wrappers appear in the call stack even though they are an
implementation detail. This leaves ugly "<autogenerated>" functions in
stack traces and can throw off skip counts for stack traces.

Fix this by considering these runtime frames in printed stack traces
so they will only be printed if runtime frames are being printed, and
by eliding them from the call stack expansion used by CallersFrames
and Caller.

This removes the test for issue 4388 since that was checking that
"<autogenerated>" appeared in the stack trace instead of something
even weirder. We replace it with various runtime package tests.

Fixes #16723.

Change-Id: Ice3f118c66f254bb71478a664d62ab3fc7125819
Reviewed-on: https://go-review.googlesource.com/45412
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-22 22:17:20 +00:00
Austin Clements
354fa9a84f runtime: simplify stack walk in panicwrap
panicwrap currently uses runtime.Callers and runtime.CallersFrames to
find the name of its caller. Simplify this by using getcallerpc.

This will be important for #16723, since to fix that we're going to
make CallersFrames skip the wrapper method, which is exactly what
panicwrap needs to see.

Change-Id: Icb0776d399966e31595f3ee44f980290827e32a6
Reviewed-on: https://go-review.googlesource.com/45411
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-22 22:17:17 +00:00
Austin Clements
229aaac19e runtime: remove getcallerpc argument
Now that getcallerpc is a compiler intrinsic on x86 and non-x86
platforms don't need the argument, we can drop it.

Sadly, this doesn't let us remove any dummy arguments since all of
those cases also use getcallersp, which still takes the argument
pointer, but this is at least an improvement.

Change-Id: I9c34a41cf2c18cba57f59938390bf9491efb22d2
Reviewed-on: https://go-review.googlesource.com/65474
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2017-09-22 22:17:15 +00:00
Ian Lance Taylor
8cb2952f2f os/exec: remove protection against simultaneous Wait/Write
CL 31148 added code to protect again simultaneous calls to Close and
Wait when using the standard input pipe, to fix the race condition
described in issue #9307. That issue is a special case of the race
between Close and Write described by issue #7970. Since issue #7970
was not fixed, CL 31148 fixed the problem specific to os/exec.

Since then, issue #7970 has been fixed, so the specific fix in os/exec
is no longer necessary. Remove it, effectively reverting CL 31148 and
followup CL 33298.

Updates #7970
Updates #9307
Updates #17647

Change-Id: Ic0b62569cb0aba44b32153cf5f9632bd1f1b411a
Reviewed-on: https://go-review.googlesource.com/65490
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Miguel Bernabeu <miguelbernadi@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Joe Tsai <joetsai@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-22 21:10:07 +00:00
Austin Clements
4c02eaf77e runtime: re-add sanity check for GCCPUFraction
This no longer appears to be reproducible on windows/386. Try putting
it back and we'll see if the builders still don't like it.

Fixes #19319.

Change-Id: Ia47b034e18d0a5a1951125c00542b021aacd5e8d
Reviewed-on: https://go-review.googlesource.com/47936
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-09-22 20:05:37 +00:00
David Chase
6cac100eef cmd/compile: add intrinsic for reading caller's pc
First step towards removing the mandatory argument for
getcallerpc, which solves certain problems for the runtime.
This might also slightly improve performance.

Intrinsic enabled on 386, amd64, amd64p32,
runtime asm implementation removed on those architectures.

Now-superfluous argument remains in getcallerpc signature
(for a future CL; non-386/amd64 asm funcs ignore it).

Added getcallerpc to the "not a real function" test
in dcl.go, that story is a little odd with respect to
unexported functions but that is not this CL.

Fixes #17327.

Change-Id: I5df1ad91f27ee9ac1f0dd88fa48f1329d6306c3e
Reviewed-on: https://go-review.googlesource.com/31851
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2017-09-22 18:37:03 +00:00
Ian Lance Taylor
332719f7ce runtime: don't call lockOSThread for every cgo call
For a trivial benchmark with a do-nothing cgo call:

name    old time/op  new time/op  delta
Call-4  64.5ns ± 7%  63.0ns ± 6%  -2.25%  (p=0.027 n=20+16)

Because Windows uses the cgocall mechanism to make system calls,
and passes arguments in a struct held in the m,
we need to do the lockOSThread/unlockOSThread in that code.

Because deferreturn was getting a nosplit stack overflow error,
change it to avoid calling typedmemmove.

Updates #21827.

Change-Id: I9b1d61434c44faeb29805b46b409c812c9acadc2
Reviewed-on: https://go-review.googlesource.com/64070
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-09-22 18:17:13 +00:00
Alessandro Arzilli
9daee93121 cmd/compile,cmd/link: export int global consts to DWARF
Updates #14517

Change-Id: I23ef88e71c89da12dffcadf5562ea2d7557b62cf
Reviewed-on: https://go-review.googlesource.com/61019
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-22 17:44:50 +00:00
Daniel Martí
f366379d84 cmd/compile: add more runtime funcs to inline test
This is based from a list that Keith Randall provided in mid-2016. These
are all funcs that, at the time, were important and small enough that
they should be clearly inlined.

The runtime has changed a bit since then. Ctz16 and Ctz8 were removed,
so don't add them. stringtoslicebytetmp was moved to the backend, so
it's no longer a Go function. And itabhash was moved to itabHashFunc.

The only other outlier is adjustctxt, which is not inlineable at the
moment. I've added a TODO and will address it myself in a separate
commit.

While at it, error if any funcs in the input table are duplicated.
They're never useful and typos could lead to unintentionally thinking a
function is inlineable when it actually isn't.

And, since the lists are getting long, start sorting alphabetically.

Finally, rotl_31 is only defined on 64-bit architectures, and the added
runtime/internal/sys funcs are assembly on 386 and thus non-inlineable
in that case.

Updates #21851.

Change-Id: Ib99ab53d777860270e8fd4aefc41adb448f13662
Reviewed-on: https://go-review.googlesource.com/65351
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-22 17:19:01 +00:00
Daniel Martí
6db697950e cmd/compile: remove unused cases from switch
The first just falls through, and the default case does nothing. They
can be deleted.

Change-Id: I82ab1ce3acde0b8423334cfbf35f9e0c806cd494
Reviewed-on: https://go-review.googlesource.com/65410
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-22 17:15:31 +00:00
Daniel Martí
83f0af1742 cmd/compile: remove a few unnecessary gotos
Rework the logic to remove them. These were the low hanging fruit,
with labels that were used only once and logic that was fairly
straightforward.

Change-Id: I02a01c59c247b8b2972d8d73ff23f96f271de038
Reviewed-on: https://go-review.googlesource.com/63410
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-09-22 16:55:47 +00:00
Matthew Dempsky
f260ae6523 cmd/compile/internal/types: unexport Type.Copy
It's only used/needed by SubstAny.

CL prepared with gorename.

Change-Id: I243138f9dcc4e6af9b81a7746414e6d7b3ba10a2
Reviewed-on: https://go-review.googlesource.com/65311
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
2017-09-22 16:42:43 +00:00
David du Colombier
d83b23fd4f archive/tar: skip TestSparseFiles on Plan 9
CL 60871 added TestSparseFiles. This test is succeeding
on Plan 9 when executed on the ramfs file system, but
is failing when executed on the Fossil file system.

This may be due to an issue in the handling of sparse
files in the Fossil file system on Plan 9 that should
be investigated.

Updates #21977.

Change-Id: I177afff519b862a5c548e094203c219504852006
Reviewed-on: https://go-review.googlesource.com/65352
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-22 13:50:50 +00:00
Tobias Klauser
5993a75869 runtime: fix typo in the word "preceding"
Change-Id: I6d8c8ca0dee972cabfcc95fda23aea25692633a5
Reviewed-on: https://go-review.googlesource.com/65350
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2017-09-22 12:51:56 +00:00
Daniel Martí
57e7d62455 all: use sort.Slice in a few more places
Do the low-hanging fruit - tiny Less functions that are used exactly
once. This reduces the amount of code and puts the logic in a single
place.

Change-Id: I9d4544cd68de5a95e55019bdad1fca0a1dbfae9c
Reviewed-on: https://go-review.googlesource.com/63171
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-22 12:39:14 +00:00
Carlos Eduardo Seo
67a0c78312 syscall: update syscall.Select to use newselect on ppc64x
Analog to the runtime package, syscall.Select should be using
newselect instead of select. This change addresses this problem and
regenerates zsyscall_linux_* for ppc64 and ppc64le.

Updates #21946

Change-Id: I5dc3bf9e7f0b1172d6cce30ddf3bb1e3c95ec8e9
Reviewed-on: https://go-review.googlesource.com/65090
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2017-09-22 12:35:32 +00:00
Michael Munday
28aaa0bd1b crypto/elliptic: gofmt
Change-Id: Ia4b49736d3b33cddf58905c6b19febbca45b2ad2
Reviewed-on: https://go-review.googlesource.com/64270
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-22 11:43:45 +00:00
Daniel Martí
3d741349f5 cmd/compile: collect reasons in inlining test
If we use -gcflags='-m -m', the compiler should give us a reason why a
func couldn't be inlined. Add the extra -m necessary for that extra info
and use it to give better test failures. For example, for the func in
the TODO:

	--- FAIL: TestIntendedInlining (1.53s)
		inl_test.go:104: runtime.nextFreeFast was not inlined: function too complex

We might increase the number of -m flags to get more information at some
later point, such as getting details on how close the func was to the
inlining budget.

Also started using regexes, as the output parsing is getting a bit too
complex for manual string handling.

While at it, also refactored the test to not buffer the entire output
into memory. This is fine in practice, but it won't scale well as we add
more packages or we depend more on the compiler's debugging output.

For example, "go build -a -gcflags='-m -m' std" prints nearly 40MB of
plaintext - and we only need to see the output line by line anyway.

Updates #21851.

Change-Id: I00986ff360eb56e4e9737b65a6be749ef8540643
Reviewed-on: https://go-review.googlesource.com/63810
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-09-22 10:59:14 +00:00
Marvin Stenger
7a5d76fa62 math/big: delete solved TODO
The TODO is no longer needed as it was solved by a previous CL.
See https://go-review.googlesource.com/14995.

Change-Id: If62d1b296f35758ad3d18d28c8fbb95e797f4464
Reviewed-on: https://go-review.googlesource.com/65232
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-09-22 10:21:46 +00:00
Joe Tsai
718d9de60f archive/tar: perform test for hole-detection on specific builders
The test for hole-detection is heavily dependent on whether the
OS and underlying FS provides support for it.
Even on Linux, which has support for SEEK_HOLE and SEEK_DATA,
the underlying filesystem may not have support for it.
In order to avoid an ever-changing game of whack-a-mole,
we whitelist the specific builders that we expect the test to pass on.

Updates #21964

Change-Id: I7334e8532c96cc346ea83aabbb81b719685ad7e5
Reviewed-on: https://go-review.googlesource.com/65270
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-21 20:42:11 +00:00
Hiroshi Ioka
2f7b57e9d8 cmd/nm: accept macho files which don't have symbol table in the archive
After https://golang.org/cl/64793, we started to include Mach-O object
files which don't have symbol table into cgo archive.
However, toolchains didn't handle those files yet.

Fixes #21959

Change-Id: Ibb2f6492f1fa59368f2dfd4cff19783997539875
Reviewed-on: https://go-review.googlesource.com/65170
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-21 19:17:33 +00:00
Gabriel Aszalos
dd5a86f18c bytes: add documentation to reader methods
Some methods that were used to implement various `io` interfaces in the
Reader were documented, whereas others were not. This change adds
documentation to all the missing methods used to implement these
interfaces.

Change-Id: I2dac6e328542de3cd87e89510651cd6ba74a7b7d
Reviewed-on: https://go-review.googlesource.com/65231
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-21 18:57:04 +00:00
Joe Tsai
fdecab6ef0 archive/tar: make check for hole detection support more liberal
On most Unix OSes, lseek reports EINVAL when lacking SEEK_HOLE support.
However, there are reports that ENOTTY is reported instead.
Rather than tracking down every possible errno that may be used to
represent "not supported", just treat any non-nil error as meaning
that there is no support. This is the same strategy taken by the
GNU and BSD tar tools.

Fixes #21958

Change-Id: Iae68afdc934042f52fa914fca45f0ca89220c383
Reviewed-on: https://go-review.googlesource.com/65191
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-21 17:49:35 +00:00
Ben Shi
9732485851 cmd/compile: optimized ARM code with BFX/BFXU
BFX&BFXU were introduced in ARMv6T2. A single BFX or BFXU is
more efficiently than a pair of left-shift/right-shift in bit
field extraction.

This patch implements this optimization. And the benchmark tests
show big improvement in special cases and little change in total.

1. There is big improvement in a special test case.
name                     old time/op    new time/op    delta
BFX-4                       665µs ± 1%     595µs ± 0%  -10.61%  (p=0.000 n=20+20)
(The test case: https://github.com/benshi001/ugo1/blob/master/bfx_test.go)

2. The compilecmp benchmark shows no regression.
name        old time/op       new time/op       delta
Template          2.33s ± 2%        2.34s ± 2%    ~     (p=0.356 n=9+10)
Unicode           1.32s ± 2%        1.30s ± 2%    ~     (p=0.139 n=9+8)
GoTypes           7.77s ± 1%        7.76s ± 1%    ~     (p=0.780 n=10+9)
Compiler          37.3s ± 1%        37.1s ± 1%    ~     (p=0.211 n=10+9)
SSA               84.3s ± 2%        84.3s ± 2%    ~     (p=0.842 n=10+9)
Flate             1.45s ± 1%        1.45s ± 3%    ~     (p=0.853 n=10+10)
GoParser          1.83s ± 2%        1.83s ± 2%    ~     (p=0.739 n=10+10)
Reflect           5.08s ± 2%        5.09s ± 2%    ~     (p=0.720 n=9+10)
Tar               2.44s ± 1%        2.44s ± 2%    ~     (p=0.684 n=10+10)
XML               2.62s ± 2%        2.62s ± 2%    ~     (p=0.529 n=10+10)
[Geo mean]        4.80s             4.79s       -0.06%

name        old user-time/op  new user-time/op  delta
Template          2.76s ± 2%        2.75s ± 3%    ~     (p=0.893 n=10+10)
Unicode           1.63s ± 1%        1.60s ± 1%  -2.07%  (p=0.000 n=8+9)
GoTypes           9.54s ± 1%        9.52s ± 1%    ~     (p=0.215 n=10+10)
Compiler          46.0s ± 1%        46.0s ± 1%    ~     (p=0.853 n=10+10)
SSA                110s ± 1%         110s ± 1%    ~     (p=0.838 n=10+10)
Flate             1.69s ± 3%        1.69s ± 5%    ~     (p=0.957 n=10+10)
GoParser          2.15s ± 2%        2.15s ± 2%    ~     (p=0.749 n=10+10)
Reflect           6.03s ± 1%        5.99s ± 2%    ~     (p=0.060 n=9+10)
Tar               3.02s ± 2%        2.99s ± 2%    ~     (p=0.214 n=10+10)
XML               3.10s ± 2%        3.08s ± 2%    ~     (p=0.732 n=9+10)
[Geo mean]        5.82s             5.79s       -0.41%

name        old text-bytes    new text-bytes    delta
HelloSize         589kB ± 0%        589kB ± 0%    ~     (all equal)

name        old data-bytes    new data-bytes    delta
HelloSize        5.46kB ± 0%       5.46kB ± 0%    ~     (all equal)

name        old bss-bytes     new bss-bytes     delta
HelloSize        76.9kB ± 0%       76.9kB ± 0%    ~     (all equal)

name        old exe-bytes     new exe-bytes     delta
HelloSize        1.03MB ± 0%       1.03MB ± 0%    ~     (all equal)

3. The go1 benchmark shows little change in total. (excluding noise)
name                     old time/op    new time/op    delta
BinaryTree17-4              41.5s ± 1%     41.6s ± 1%    ~     (p=0.373 n=30+26)
Fannkuch11-4                23.6s ± 1%     23.6s ± 1%  +0.28%  (p=0.003 n=29+30)
FmtFprintfEmpty-4           826ns ± 1%     827ns ± 1%    ~     (p=0.155 n=30+30)
FmtFprintfString-4         1.35µs ± 1%    1.35µs ± 1%    ~     (p=0.499 n=30+30)
FmtFprintfInt-4            1.43µs ± 1%    1.41µs ± 1%  -1.19%  (p=0.000 n=30+30)
FmtFprintfIntInt-4         2.15µs ± 1%    2.11µs ± 1%  -1.78%  (p=0.000 n=30+30)
FmtFprintfPrefixedInt-4    2.21µs ± 1%    2.21µs ± 1%    ~     (p=0.881 n=30+30)
FmtFprintfFloat-4          4.41µs ± 1%    4.44µs ± 0%  +0.64%  (p=0.000 n=30+30)
FmtManyArgs-4              8.06µs ± 1%    8.06µs ± 0%    ~     (p=0.871 n=30+30)
GobDecode-4                 103ms ± 1%     104ms ± 2%  +0.54%  (p=0.013 n=28+29)
GobEncode-4                92.4ms ± 1%    92.6ms ± 1%    ~     (p=0.447 n=30+29)
Gzip-4                      4.17s ± 1%     4.06s ± 1%  -2.56%  (p=0.000 n=29+30)
Gunzip-4                    603ms ± 1%     602ms ± 1%    ~     (p=0.423 n=30+30)
HTTPClientServer-4          688µs ± 2%     674µs ± 3%  -2.09%  (p=0.000 n=29+30)
JSONEncode-4                237ms ± 1%     237ms ± 1%    ~     (p=0.061 n=29+30)
JSONDecode-4                907ms ± 1%     910ms ± 1%    ~     (p=0.061 n=30+30)
Mandelbrot200-4            41.7ms ± 0%    41.7ms ± 0%  +0.19%  (p=0.000 n=24+20)
GoParse-4                  45.7ms ± 2%    45.5ms ± 2%  -0.29%  (p=0.005 n=30+30)
RegexpMatchEasy0_32-4      1.27µs ± 0%    1.27µs ± 0%  +0.12%  (p=0.031 n=30+30)
RegexpMatchEasy0_1K-4      7.77µs ± 4%    7.73µs ± 3%    ~     (p=0.169 n=30+30)
RegexpMatchEasy1_32-4      1.29µs ± 1%    1.29µs ± 1%    ~     (p=0.126 n=30+30)
RegexpMatchEasy1_1K-4      10.4µs ± 3%    10.3µs ± 2%  -1.32%  (p=0.004 n=30+29)
RegexpMatchMedium_32-4     2.06µs ± 0%    2.06µs ± 0%    ~     (p=0.071 n=30+30)
RegexpMatchMedium_1K-4      531µs ± 1%     530µs ± 0%    ~     (p=0.121 n=30+23)
RegexpMatchHard_32-4       28.7µs ± 1%    28.6µs ± 1%  -0.21%  (p=0.001 n=30+27)
RegexpMatchHard_1K-4        860µs ± 1%     857µs ± 1%    ~     (p=0.105 n=30+27)
Revcomp-4                  67.3ms ± 2%    67.3ms ± 2%    ~     (p=0.805 n=29+29)
Template-4                  1.08s ± 1%     1.08s ± 1%    ~     (p=0.260 n=30+30)
TimeParse-4                7.04µs ± 0%    7.04µs ± 0%    ~     (p=0.315 n=30+30)
TimeFormat-4               13.2µs ± 1%    13.2µs ± 1%    ~     (p=0.077 n=30+30)
[Geo mean]                  715µs          713µs       -0.30%

name                     old speed      new speed      delta
GobDecode-4              7.42MB/s ± 1%  7.38MB/s ± 2%  -0.54%  (p=0.011 n=28+29)
GobEncode-4              8.30MB/s ± 1%  8.29MB/s ± 1%    ~     (p=0.484 n=30+29)
Gzip-4                   4.65MB/s ± 2%  4.78MB/s ± 1%  +2.73%  (p=0.000 n=30+30)
Gunzip-4                 32.2MB/s ± 1%  32.2MB/s ± 1%    ~     (p=0.357 n=30+30)
JSONEncode-4             8.18MB/s ± 1%  8.19MB/s ± 1%    ~     (p=0.052 n=29+30)
JSONDecode-4             2.14MB/s ± 1%  2.13MB/s ± 1%    ~     (p=0.074 n=30+29)
GoParse-4                1.27MB/s ± 1%  1.27MB/s ± 2%    ~     (p=0.618 n=24+30)
RegexpMatchEasy0_32-4    25.2MB/s ± 0%  25.2MB/s ± 0%  -0.12%  (p=0.031 n=30+30)
RegexpMatchEasy0_1K-4     132MB/s ± 5%   132MB/s ± 2%    ~     (p=0.171 n=30+30)
RegexpMatchEasy1_32-4    24.8MB/s ± 1%  24.9MB/s ± 1%    ~     (p=0.106 n=30+30)
RegexpMatchEasy1_1K-4    98.4MB/s ± 3%  99.6MB/s ± 4%  +1.19%  (p=0.011 n=30+30)
RegexpMatchMedium_32-4    483kB/s ± 1%   484kB/s ± 1%    ~     (p=0.426 n=30+30)
RegexpMatchMedium_1K-4   1.93MB/s ± 1%  1.93MB/s ± 0%    ~     (p=0.157 n=30+17)
RegexpMatchHard_32-4     1.12MB/s ± 1%  1.12MB/s ± 0%  +0.33%  (p=0.001 n=30+24)
RegexpMatchHard_1K-4     1.19MB/s ± 1%  1.19MB/s ± 1%    ~     (p=0.290 n=30+30)
Revcomp-4                37.8MB/s ± 2%  37.8MB/s ± 1%    ~     (p=0.815 n=29+29)
Template-4               1.80MB/s ± 1%  1.80MB/s ± 1%    ~     (p=0.586 n=30+30)
[Geo mean]               6.80MB/s       6.81MB/s       +0.25%

fixes #20966

Change-Id: Idb5567bbe988c875315b8c98c128957cd474ccc5
Reviewed-on: https://go-review.googlesource.com/64950
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
2017-09-21 12:41:04 +00:00
Michael Darakananda
eca45997df context: fix references to "d" in WithDeadline docs
Docs of WithDeadline refers to variable "d" which does not exist
in the docs.

This commit renames the time argument to "d" to make the doc work.

Change-Id: Ifd2c1be7d2e3f7dfb21cd9bb8ff7fc5039c8d3bd
Reviewed-on: https://go-review.googlesource.com/65130
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-21 03:00:51 +00:00
Hiroshi Ioka
589ea93678 cmd/nm: handle cgo archive
This CL also make cmd/nm accept PE object file.

Fixes #21706

Change-Id: I4a528b7d53da1082e61523ebeba02c4c514a43a7
Reviewed-on: https://go-review.googlesource.com/64890
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-21 01:01:44 +00:00
Avelino
6a537c1d47 cmd/link: Grouping declaration of variables on ld/pe.go
Change-Id: I33284d3154db43b2b89418c5076df79407e7cf41
Reviewed-on: https://go-review.googlesource.com/60931
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-21 01:01:13 +00:00
Cherry Zhang
99c757adb5 cmd/compile: use a counter to track whether writebarrier rewriting is done
Use a counter, instead of a loop, to see whether there are more
writebarrier ops in the current block that need to be rewritten.

No visible change in normal compiler speed benchmarks.

Passes toolstash -cmp on std cmd.

Fixes #20416.

Change-Id: Ifbbde23611cd668c35b8a4a3e9a92726bfe19956
Reviewed-on: https://go-review.googlesource.com/60310
Reviewed-by: David Chase <drchase@google.com>
2017-09-20 23:57:19 +00:00
Matthew Dempsky
93e97ef066 cmd/compile/internal/gc: update comment in plive.go
onebitwalktype1 no longer appears to be a bottleneck for the mentioned
test case. In fact, we appear to compile it significantly faster now
than Go 1.4 did (~1.8s vs ~3s).

Fixes #21951.

Change-Id: I315313e906092a7d6ff4ff60a918d80a4cff7a7f
Reviewed-on: https://go-review.googlesource.com/65110
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-20 23:07:40 +00:00
Joe Tsai
1eacf78858 archive/tar: add Header.DetectSparseHoles and Header.PunchSparseHoles
To support the detection and creation of sparse files,
add two new methods:
	func Header.DetectSparseHoles(*os.File) error
	func Header.PunchSparseHoles(*os.File) error

DetectSparseHoles is intended to be used after FileInfoHeader
prior to serializing the Header with WriteHeader.
For each OS, it uses specialized logic to detect
the location of sparse holes. On most Unix systems, it uses
SEEK_HOLE and SEEK_DATA to query for the holes.
On Windows, it uses a specialized the FSCTL_QUERY_ALLOCATED_RANGES
syscall to query for all the holes.

PunchSparseHoles is intended to be used after Reader.Next
prior to populating the file with Reader.WriteTo.
On Windows, this uses the FSCTL_SET_ZERO_DATA syscall.
On other operating systems it simply truncates the file
to the end-offset of SparseHoles.

DetectSparseHoles and PunchSparseHoles are added as methods on
Header because they are heavily tied to the operating system,
for which there is already an existing precedence for
(since FileInfoHeader makes uses of OS-specific details).

Fixes #13548

Change-Id: I98a321dd1ce0165f3d143d4edadfda5e7db67746
Reviewed-on: https://go-review.googlesource.com/60871
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-20 22:12:38 +00:00
Agniva De Sarker
d2f317218b math: implement fast path for Exp
- using FMA and AVX instructions if available to speed-up
Exp calculation on amd64

- using a data table instead of #define'ed constants because
these instructions do not support loading floating point immediates.
One has to use a memory operand / register.

- Benchmark results on Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz:

Original vs New (non-FMA path)
name  old time/op    new time/op    delta
Exp     16.0ns ± 1%    16.1ns ± 3%   ~     (p=0.308 n=9+10)

Original vs New (FMA path)
name  old time/op    new time/op    delta
Exp     16.0ns ± 1%    13.7ns ± 2%  -14.80%  (p=0.000 n=9+10)

Change-Id: I3d8986925d82b39b95ee979ae06f59d7e591d02e
Reviewed-on: https://go-review.googlesource.com/62590
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-20 21:43:00 +00:00