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

31695 Commits

Author SHA1 Message Date
Robert Griesemer
2123a6c644 cmd/compile: fix recorded export data position info
The position information recorded now consists of the line-
directive relative filename and line number. It would be
relatively easy to also encode absolute position information
as necessary (by serializing src.PosBase data).

For example, given $GOROOT/src/tmp/x.go:

	package p

	const C0 = 0

	//line c.go:10
	const C1 = 1

	//line t.go:20
	type T int

	//line v.go:30
	var V T

	//line f.go:40
	func F() {}

The recorded positions for the exported entities are:

	C0 $GOROOT/src/tmp/x.go 3
	C1 c.go 10
	T t.go 20
	V v.go 30
	F f.go 40

Fix verified by manual inspection. There's currently no easy way
to test this, but it will eventually be tested when we fix #7311.

Fixes #19391.

Change-Id: I6269067ea58358250fe6dd1f73bdf9e5d2adfe3d
Reviewed-on: https://go-review.googlesource.com/37936
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-08 18:26:16 +00:00
Sarah Adams
82e1732f14 database/sql: proper prepared statement support in transactions
This change was originally written by Marko Tiikkaja <marko@joh.to>.
https://go-review.googlesource.com/#/c/2035/

Previously *Tx.Stmt always prepared a new statement, even if an
existing one was available on the connection the transaction was on.
Now we first see if the statement is already available on the
connection and only prepare if it isn't. Additionally, when we do
need to prepare one, we store it in the parent *Stmt to allow it to be
later reused by other calls to *Tx.Stmt on that statement or just
straight up by *Stmt.Exec et al.

To make sure that the statement doesn't disappear unexpectedly, we
record a dependency from the statement returned by *Tx.Stmt to the
*Stmt it came from and set a new field, parentStmt, to point to the
originating *Stmt. When the transaction's *Stmt is closed, we remove
the dependency. This way the "parent" *Stmt can be closed by the user
without her having to know whether any transactions are still using it
or not.

Fixes #15606

Change-Id: I41b5056847e117ac61130328b0239d1e000a4a08
Reviewed-on: https://go-review.googlesource.com/35476
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2017-03-08 17:32:12 +00:00
Johan Brandhorst
3b988eb643 net/http: use httptest.Server Client in tests
After merging https://go-review.googlesource.com/c/34639/,
it was pointed out to me that a lot of tests under net/http
could use the new functionality to simplify and unify testing.

Using the httptest.Server provided Client removes the need to
call CloseIdleConnections() on all Transports created, as it
is automatically called on the Transport associated with the
client when Server.Close() is called.

Change the transport used by the non-TLS
httptest.Server to a new *http.Transport rather than using
http.DefaultTransport implicitly. The TLS version already
used its own *http.Transport. This change is to prevent
concurrency problems with using DefaultTransport implicitly
across several httptest.Server's.

Add tests to ensure the httptest.Server.Client().Transport
RoundTripper interface is implemented by a *http.Transport,
as is now assumed across large parts of net/http tests.

Change-Id: I9f9d15f59d72893deead5678d314388718c91821
Reviewed-on: https://go-review.googlesource.com/37771
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-08 15:51:48 +00:00
Hiroshi Ioka
2bd6360e3b net/mail: fix wrong error message in consumePhrase
Fixes #19415

Change-Id: I6414f82e42bd09f1793156befce326aeac919ea2
Reviewed-on: https://go-review.googlesource.com/37911
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-08 03:24:44 +00:00
Russ Cox
c797256a8f runtime/pprof: add GNU build IDs to Mappings recorded from /proc/self/maps
This helps systems that maintain an external database mapping
build ID to symbol information for the given binary, especially
in the case where /proc/self/maps lists many different files
(for example, many shared libraries).

Avoid importing debug/elf to avoid dragging in that whole
package (and its dependencies like debug/dwarf) into the
build of every program that generates a profile.

Fixes #19431.

Change-Id: I6d4362a79fe23e4f1726dffb0661d20bb57f766f
Reviewed-on: https://go-review.googlesource.com/37855
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-03-08 01:09:18 +00:00
Robert Griesemer
752d7bad4f cmd/internal/src: fix Pos.String() for positions after line directives
The old code simply printed the position of the line directive in
square brackets for a position modified by a line directive. Now
we print the corresponding actual source file position instead.

Fixes #19392.

Change-Id: I933f3e435d03a6ee8269df36ae35f9202b7b2e76
Reviewed-on: https://go-review.googlesource.com/37932
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07 23:06:58 +00:00
Mikio Hara
38409f5f35 internal/poll: code cleanup
This change adds missing docs, collapses single-line import paths,
removes unsed method placeholders and renames str.go to strconv.go.

Change-Id: I2d155c838935cd8427abd142a462ff4c56829703
Reviewed-on: https://go-review.googlesource.com/37814
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-03-07 21:54:36 +00:00
Austin Clements
d50f892abc runtime: join selectgo and selectgoImpl
Currently selectgo is just a wrapper around selectgoImpl. This keeps
the hard-coded frame skip counts for tracing the same between the
channel implementation and the select implementation.

However, this is fragile and confusing, so pass a skip parameter to
send and recv, join selectgo and selectgoImpl into one function, and
use decrease all of the skips in selectgo by one.

Change-Id: I11b8cbb7d805b55f5dc6ab4875ac7dde79412ff2
Reviewed-on: https://go-review.googlesource.com/37860
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-07 21:19:38 +00:00
Matthew Dempsky
5e4a958351 cmd/compile: refactor portable SSA Op handling
Several SSA ops will always behave identically regardless of target
architecture, so handle those within gc/ssa.go instead.

Passes toolstash-check -all.

Change-Id: I54d514e80ab86723e44332a5a38e3054cbca8c5d
Reviewed-on: https://go-review.googlesource.com/37931
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07 21:17:03 +00:00
Austin Clements
b992c2649e runtime: print SP/FP on bad pointer crashes
If the bad pointer is on a stack, this makes it possible to find the
frame containing the bad pointer.

Change-Id: Ieda44e054aa9ebf22d15d184457c7610b056dded
Reviewed-on: https://go-review.googlesource.com/37858
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07 20:46:54 +00:00
Austin Clements
caa7dacfd2 runtime: honor GOTRACEBACK=crash even if _g_.m.traceback != 0
Change-Id: I6de1ef8f67bde044b8706c01e98400e266e1f8f0
Reviewed-on: https://go-review.googlesource.com/37857
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-03-07 20:46:52 +00:00
Matthew Dempsky
c310c688ff cmd/compile, runtime: simplify multiway select implementation
This commit reworks multiway select statements to use normal control
flow primitives instead of the previous setjmp/longjmp-like behavior.
This simplifies liveness analysis and should prevent issues around
"returns twice" function calls within SSA passes.

test/live.go is updated because liveness analysis's CFG is more
representative of actual control flow. The case bodies are the only
real successors of the selectgo call, but previously the selectsend,
selectrecv, etc. calls were included in the successors list too.

Updates #19331.

Change-Id: I7f879b103a4b85e62fc36a270d812f54c0aa3e83
Reviewed-on: https://go-review.googlesource.com/37661
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-03-07 20:14:17 +00:00
Daniel Martí
5ed952368e runtime/pprof: actually use tag parameter
It's only ever called with the value it was using, but the code was
counterintuitive. Use the parameter instead, like the other funcs near
it.

Found by github.com/mvdan/unparam.

Change-Id: I45855e11d749380b9b2a28e6dd1d5dedf119a19b
Reviewed-on: https://go-review.googlesource.com/37893
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07 20:01:05 +00:00
Elias Naur
143fd8ef2a os/user: use the stubs fallback for Android
Using the stubs, user.Current will no longer fail on Android, fixing
the os/exec.TestCredentialNoSetGroups test.

Change-Id: I8b9842aa6704c0cde383c549a614bab0a0ed7695
Reviewed-on: https://go-review.googlesource.com/37765
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-07 19:38:24 +00:00
Alberto Donizetti
e99dafc4a8 cmd/compile: fix misleading "truncated to int" messages
When defining an int const, the compiler tries to cast the RHS
expression to int. The cast may fail for three reasons:

  1. expr is an integer constant that overflows int
  2. expr is a floating point constant
  3. expr is a complex constant, or not a number

In the second case, in order to print a sensible error message, we
must distinguish between a floating point constant that should be
included in the error message and a floating point constant that
cannot be reasonably formatted for inclusion in an error message.

For example, in:

  const a int = 1.1
  const b int = 1 + 1e-100

a is in the former group, while b is in the latter, since the floating
point value resulting from the evaluation of the rhs of the assignment
(1.00...01) is too long to be fully printed in an error message, and
cannot be shortened without making the error message misleading
(rounding or truncating it would result in a "1", which looks like an
integer constant, and it makes little sense in an error message about
an invalid floating point expression).

To fix this problem, we try to format the float value using fconv
(which is used by the error reporting mechanism to format float
arguments), and then parse the resulting string back to a
big.Float. If the result is an integer, we assume that expr is a float
value that cannot be reasonably be formatted as a string, and we emit
an error message that does not include its string representation.

Also, change the error message for overflows to a more conservative
"integer too large", which does not mention overflows that are only
caused by an internal implementation restriction.

Also, change (*Mpint) SetFloat so that it returns a bool (instead of
0/-1 for success/failure).

Fixes #11371

Change-Id: Ibbc73e2ed2eaf41f07827b0649d0eb637150ecaa
Reviewed-on: https://go-review.googlesource.com/35411
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-07 19:34:22 +00:00
Matthew Dempsky
527f3518da cmd/compile/internal/gc: skip autotmp vars in gc again
Instead of skipping them based on string matching much later in the
compilation process, skip them up front using the proper API.

Passes toolstash-check.

Change-Id: Ibd4c0448a0701ba0de3235d4689ef300235fa1d9
Reviewed-on: https://go-review.googlesource.com/37930
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07 19:23:25 +00:00
Matthew Dempsky
b1a4424a52 cmd/internal/obj: change started to bool
Change-Id: I90143e3c6e95a1495f300ffeb10de554aa41f56a
Reviewed-on: https://go-review.googlesource.com/37889
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-07 19:23:06 +00:00
Elias Naur
b91b694b37 runtime/pprof: fix the protobuf tests on Android
Change-Id: I5f85a7980b9a18d3641c4ee8b0992671a8421bb0
Reviewed-on: https://go-review.googlesource.com/37896
Run-TryBot: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07 19:18:04 +00:00
Kevin Burke
c5cdda401e encoding/base64, html/template: fix grammar mistakes
Replace 'does not contains' with 'does not contain' where it appears
in the source code.

Change-Id: Ie7266347c429512c8a41a7e19142afca7ead3922
Reviewed-on: https://go-review.googlesource.com/37887
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-07 17:42:45 +00:00
Hiroshi Ioka
f639353330 mime: fix panic parsing 'encoded-word', be stricter
Fixes #19416

Change-Id: I23c69ff637abaa202909f1cba6ed41b3cfe3d117
Reviewed-on: https://go-review.googlesource.com/37812
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07 17:38:24 +00:00
Matthew Dempsky
68177d9ec0 cmd/internal/obj: move dwarf.Var generation into compiler
Passes toolstash -cmp.

Change-Id: I4bd60f7ebba5457e7b3ece688fee2351bfeeb59a
Reviewed-on: https://go-review.googlesource.com/37874
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2017-03-07 17:32:54 +00:00
Matthew Dempsky
e577a55b78 cmd/compile: change signatlist to []*Type
No need to keep as Nodes when they're all Types anyway.

Change-Id: I8157914ba5b09cadf2263247844680a60233a0f2
Reviewed-on: https://go-review.googlesource.com/37886
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-07 16:53:36 +00:00
Andrew Benton
2a26f5809e crypto/x509: rename and reposition rsaPublicKey struct declaration
For consistency with the other named types in this package, this
change renames the unexported rsaPublicKey struct to pkcs1PublicKey
and positions the declaration up with the other similarly-named
types in pkcs1.go.

See the final comment of #19355 for discussion.

Change-Id: I1fa0366a8efa01602b81bc69287ef747abce84f5
Reviewed-on: https://go-review.googlesource.com/37885
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07 16:49:28 +00:00
Daniel Martí
aeac77dce6 net: remove unused Interface parameter
Found by github.com/mvdan/unparam.

Change-Id: I4795dd0221784d10cf7c9f7b84ea00787d5789f2
Reviewed-on: https://go-review.googlesource.com/37892
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07 16:37:07 +00:00
Alex Brainman
d3f5e36917 cmd/link: use IMAGE_SYM_CLASS_STATIC for local symbols
Sometimes asm code in 2 different packages name its global
symbols with the same name. When these symbols are passed
to gcc, it refuses to link them thinking they are duplicate.
Mark these symbols with IMAGE_SYM_CLASS_STATIC.

Fixes #19198.

Change-Id: Ia5f59ede47354a2b48ce60b7d406c9f097ff2000
Reviewed-on: https://go-review.googlesource.com/37810
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07 03:26:47 +00:00
Hiroshi Ioka
6491496d10 net/mail: ignore whitespace between adjacent 'encoded-word's
rfc2047 says:
  White space between adjacent 'encoded-word's is not displayed.

Although, mime package already have that feature,
we cannot simply reuse that code,
because there is a subtle difference in quoted-string handling.

Fixes #19363

Change-Id: I754201aa3c6b701074ad78fe46818af5b96cbd00
Reviewed-on: https://go-review.googlesource.com/37811
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07 02:54:40 +00:00
Josselin Costanzi
9207a7437e encoding/base64: add alphabet and padding restrictions
Document and check that the alphabet cannot contain '\n' or '\r'.
Document that the alphabet cannot contain the padding character.
Document that the padding character must be equal or bellow '\xff'.
Document that the padding character must not be '\n' or '\r'.

Fixes #19343
Fixes #19318

Change-Id: I6de0034d347ffdf317d7ea55d6fe38b01c2c4c03
Reviewed-on: https://go-review.googlesource.com/37838
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07 02:53:23 +00:00
Michael Munday
8d3f29577d cmd/compile: regenerate knownFormats
Should fix the build dashboard.

Change-Id: Id4c8a996d9f689e1fa865a9cff9a7f52c700c691
Reviewed-on: https://go-review.googlesource.com/37877
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-07 01:09:50 +00:00
Jaana Burcu Dogan
29be580395 doc: add link to the setting GOPATH guide
Change-Id: I4718c82540ef214728393824b89c8c7f6656823b
Reviewed-on: https://go-review.googlesource.com/36210
Reviewed-by: Russ Cox <rsc@golang.org>
2017-03-07 00:59:54 +00:00
Robert Griesemer
cf710949a9 Revert "cmd/compile: improve error message if init is directly invoked"
This reverts commit cb6e0639fb.

The fix is incorrect as it's perfectly fine to refer to an
identifier 'init' inside a function, and 'init' may even be
a variable of function value. Misspelling 'init' in that
context would lead to an incorrect error message.

Reopened #8481.

Change-Id: I49787fdf7738213370ae6f0cab54013e9e3394a8
Reviewed-on: https://go-review.googlesource.com/37876
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-06 23:48:37 +00:00
philhofer
a6bd42f263 cmd/compile: emit OffPtr for first field in SSA'd structs
Given

  (Store [c] (OffPtr <T1> [0] (Addr <T> _)) _
    (Store [c] (Addr <T> _) _ _))

dead store elimination doesn't eliminate the inner
Store, because it addresses a type of a different width
than the first store.

When decomposing StructMake operations, always generate
an OffPtr to address struct fields so that dead stores to
the first field of the struct can be optimized away.

benchmarks affected on darwin/amd64:
HTTPClientServer-8        73.2µs ± 1%    72.7µs ± 1%  -0.69%  (p=0.022 n=9+10)
TimeParse-8                304ns ± 1%     300ns ± 0%  -1.61%  (p=0.000 n=9+9)
RegexpMatchEasy1_32-8     80.1ns ± 0%    79.5ns ± 1%  -0.84%  (p=0.000 n=8+9)
GobDecode-8               6.78ms ± 0%    6.81ms ± 1%  +0.46%  (p=0.000 n=9+10)
Gunzip-8                  36.1ms ± 1%    36.2ms ± 0%  +0.37%  (p=0.019 n=10+10)
JSONEncode-8              15.6ms ± 0%    15.7ms ± 0%  +0.69%  (p=0.000 n=9+10)

Change-Id: Ia80d73fd047f9400c616ca64fdee4f438a0e7f21
Reviewed-on: https://go-review.googlesource.com/37769
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-03-06 23:47:59 +00:00
Daniel Martí
cd6f18779f net/http: remove unused ResponseWriter params
Found by github.com/mvdan/unparam.

Change-Id: I66f5a191cf9c9a11a7c3c4d7ee0a02e2c185f019
Reviewed-on: https://go-review.googlesource.com/37841
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-06 23:46:56 +00:00
Robert Griesemer
d10b50dc34 cmd/compile/internal/syntax: print position info for names in tree dump
Debugging support.

Change-Id: Ia518aaed36eaba76e6233306f718ad8aff3ce744
Reviewed-on: https://go-review.googlesource.com/37875
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-06 23:45:14 +00:00
Matthew Dempsky
1874d4a883 cmd/internal/obj, cmd/compile: rip off some toolstash bandaids
Change-Id: I402383e893223facae451adbd640113126d5edd9
Reviewed-on: https://go-review.googlesource.com/37873
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-06 23:29:36 +00:00
Matthew Dempsky
9cb2ee0ff2 cmd/internal/obj: move STEXT-only LSym fields into new FuncInfo struct
Shrinks LSym somewhat for non-STEXT LSyms, which are much more common.

While here, switch to tracking Automs in a slice instead of a linked
list. (Previously, this would have made LSyms larger.)

Passes toolstash-check.

Change-Id: I082e50e1d1f1b544c9e06b6e412a186be6a4a2b5
Reviewed-on: https://go-review.googlesource.com/37872
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-03-06 22:17:23 +00:00
Matthew Dempsky
7a98bdf1c2 cmd/internal/obj: remove AUSEFIELD pseudo-op
Instead, cmd/compile can directly emit R_USEFIELD relocations.

Manually verified rsc.io/tmp/fieldtrack still passes.

Change-Id: Ib1fb5ab902ff0ad17ef6a862a9a5692caf7f87d1
Reviewed-on: https://go-review.googlesource.com/37871
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-03-06 22:16:13 +00:00
Matthew Dempsky
5d0c20efc7 cmd/compile: preserve Type.nod in copytype
By clearing out t.nod in copytype, we effectively lose the reference
from a Type back to its declaring OTYPE Node. This means later in
typenamesym when we add typenod(t) to signatlist, we end up creating a
new OTYPE Node. Moreover, this Node's position information will depend
on whatever context it happens be needed, and will be used for the
Type's position in the export data.

Updates #19391.

Change-Id: Ied93126449f75d7c5e3275cbdcc6fa657a8aa21d
Reviewed-on: https://go-review.googlesource.com/37870
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-06 22:16:05 +00:00
Quentin Smith
4b261a1410 test/fixedbugs: add test for #19403
Change-Id: Ie52dac8eb4daed95e049ad74d5ae101e8a5cb854
Reviewed-on: https://go-review.googlesource.com/37725
Run-TryBot: Quentin Smith <quentin@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-03-06 21:39:00 +00:00
Austin Clements
e4f73769bc runtime: strongly encourage CallersFrames with the result of Callers
For historical reasons, it's still commonplace to iterate over the
slice returned by runtime.Callers and call FuncForPC on each PC. This
is broken in gccgo and somewhat broken in gc and will become more
broken in gc with mid-stack inlining.

In Go 1.7, we introduced runtime.CallersFrames to deal with these
problems, but didn't strongly direct people toward using it. Reword
the documentation on runtime.Callers to more strongly encourage people
to use CallersFrames and explicitly discourage them from iterating
over the PCs or using FuncForPC on the results.

Fixes #19426.

Change-Id: Id0d14cb51a0e9521c8fdde9612610f2c2b9383c4
Reviewed-on: https://go-review.googlesource.com/37726
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-03-06 20:52:00 +00:00
Daniel Martí
1fa063cbb6 go/internal/gccimporter: actually use pkg parameter
We're passed a pkg, so it makes little sense to not use it. This was
probably a typo and not the intended behaviour.

Fixes #19407.

Change-Id: Ia1c9130c0e474daf47753cf51914a2d7db272c96
Reviewed-on: https://go-review.googlesource.com/37839
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-06 20:34:15 +00:00
Ian Lance Taylor
61d9cd73fb internal/poll: only start Windows goroutines when we need them
We don't need to start the goroutines if the program isn't going to do
any I/O.

Fixes #19390.

Change-Id: I47eef992d3ad05ed5f3150f4d6e5b3e0cb16a551
Reviewed-on: https://go-review.googlesource.com/37762
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-03-06 19:57:39 +00:00
Josselin Costanzi
5ce06cf71d encoding/base64: fix decode reports incorrect index
Fix Decode to return the correct illegal data index from a corrupted
input that contains whitespaces.

Fixes #19406

Change-Id: Ib2b2b6ed7e41f024d0da2bd035caec4317c2869c
Reviewed-on: https://go-review.googlesource.com/37837
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-06 19:28:03 +00:00
Austin Clements
0efc8b2188 runtime: avoid repeated findmoduledatap calls
Currently almost every function that deals with a *_func has to first
look up the *moduledata for the module containing the function's entry
point. This means we almost always do at least two identical module
lookups whenever we deal with a *_func (one to get the *_func and
another to get something from its module data) and sometimes several
more.

Fix this by making findfunc return a new funcInfo type that embeds
*_func, but also includes the *moduledata, and making all of the
functions that currently take a *_func instead take a funcInfo and use
the already-found *moduledata.

This transformation is trivial for the most part, since the *_func
type is usually inferred. The annoying part is that we can no longer
use nil to indicate failure, so this introduces a funcInfo.valid()
method and replaces nil checks with calls to valid.

Change-Id: I9b8075ef1c31185c1943596d96dec45c7ab5100f
Reviewed-on: https://go-review.googlesource.com/37331
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2017-03-06 19:17:24 +00:00
Matthew Dempsky
6533cc1ce8 cmd/internal/goobj: update to support go19ld
Updates the disassembler to support the same object file version used
by the assembler and linker.

Related #14782.

Change-Id: I4cd7560c4e4e1350cfb27ca9cbe0fde25fe693cc
Reviewed-on: https://go-review.googlesource.com/37797
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2017-03-06 19:14:02 +00:00
Matthew Dempsky
7c84dc79fd cmd/internal/obj, cmd/link: bump magic string to go19ld
golang.org/cl/37231 changed the object file format, but forgot to bump
the version string.

Change-Id: I8351ec8ed55e65479006e7c0df20254d0e31015f
Reviewed-on: https://go-review.googlesource.com/37798
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-06 19:13:57 +00:00
Daniel Martí
ad74e450ca regexp/syntax: remove unused flags parameter
Found by github.com/mvdan/unparam.

Change-Id: I186d2afd067e97eb05d65c4599119b347f82867d
Reviewed-on: https://go-review.googlesource.com/37840
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-06 19:11:09 +00:00
Robert Griesemer
d8485ee2e7 go/internal/gcimporter: return (possibly incomplete) package in case of error
For #16088.

Change-Id: Ib38bda06a5c5d110ca86510043775c5cf229e6a8
Reviewed-on: https://go-review.googlesource.com/37756
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-03-06 18:51:31 +00:00
Robert Griesemer
63f8cca95b go/internal/srcimporter: return (possibly incomplete) package in case of error
For #16088.

Change-Id: I0ff480e95ef5af375be2ccc655f8b233a7bcd39d
Reviewed-on: https://go-review.googlesource.com/37755
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-03-06 18:51:17 +00:00
Robert Griesemer
2ad7453bf4 go/types: continue type-checking with fake packages if imports failed
This will make type-checking more robust in the presence of import errors.

Also:
- import is now relative to directory containing teh file containing the import
  (matters for relative imports)
- factored out package import code from main resolver loop
- fixed a couple of minor bugs

Fixes #16088.

Change-Id: I1ace45c13cd0fa675d1762877cec0a30afd9ecdc
Reviewed-on: https://go-review.googlesource.com/37697
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-06 18:50:56 +00:00
Austin Clements
2ef88f7fcf runtime: lock-free fast path for mark bits allocation
Currently we acquire a global lock for every newMarkBits call. This is
unfortunate since every span sweep operation calls newMarkBits.

However, most allocations are simply linear allocations from the
current arena. Take advantage of this to add a lock-free fast path for
allocating from the current arena. With this change, the global lock
only protects the lists of arenas, not the free offset in the current
arena.

Change-Id: I6cf6182af8492c8bfc21276114c77275fe3d7826
Reviewed-on: https://go-review.googlesource.com/34595
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2017-03-06 18:40:26 +00:00