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

25702 Commits

Author SHA1 Message Date
Michael Hudson-Doyle
3bf61fb2e5 cmd/internal/obj/x86, cmd/link/internal/x86: support IE model TLS on linux/386
This includes the first parts of the general approach to PIC: load PC into CX
whenever it is needed. This is going to lead to large binaries and poor
performance but it's a start and easy to get right.

Change-Id: Ic8bf1d0a74284cca0d94a68cf75024e8ab063b4e
Reviewed-on: https://go-review.googlesource.com/16383
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 01:57:01 +00:00
Michael Hudson-Doyle
61da0e92d0 cmd/compile, cmd/compile/internal/x86: do not let regopt use CX in position independent code
We might be able to do better than this, but it's a start.

Change-Id: I80ebce9094e084a4746039106ccf1ad9c4b8bb7c
Reviewed-on: https://go-review.googlesource.com/16384
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 01:44:32 +00:00
Michael Hudson-Doyle
6056cc5df6 runtime: handle volatility of CX when dynamically linking on linux/386
Mostly by avoiding CX entirely, sometimes by reloading it.

I also vetted the assembly in other packages, it's all fine.

Change-Id: I50059669aaaa04efa303cf22ac228f9d14d83db0
Reviewed-on: https://go-review.googlesource.com/16386
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 01:36:44 +00:00
Michael Hudson-Doyle
c8abb02178 cmd/go: enable -buildmode=pie on linux/386
Change-Id: Ie4cdf50fdaf7b368a189a84f4e2aea4cedd5ca7d
Reviewed-on: https://go-review.googlesource.com/17013
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 01:35:54 +00:00
David Benjamin
a3e7544ea8 encoding/asn1: enforce use of short form lengths.
BER allows the sender to choose either short form or long form where
both are legal, but DER requires the minimal one be used. Enforce this
and add a test. Fix one test which was not minimally-encoded and another
which would not distinguish rejecting the input because the long form
length wasn't minimally-encoded from rejecting it because long form was
chosen when short form was allowed.

Change-Id: I1b56fcca594dcdeddea9378b4fab427cbe7cd26d
Reviewed-on: https://go-review.googlesource.com/16517
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
2015-11-18 00:53:49 +00:00
Edward Muller
f4b4d2f4d9 time: _2006 is a literal _, followed by 2006
Otherwise _2006 is treated as _2 and then an error.

Fixes #11334

Change-Id: I40a385b45e279e9f4538bf419baab72781cdb215
Reviewed-on: https://go-review.googlesource.com/16311
Reviewed-by: Rob Pike <r@golang.org>
2015-11-18 00:06:39 +00:00
Mohit Agarwal
2619dccf3c path/filepath: in Rel use case-insensitive comparison on Windows
Compare basepath and targetpath using strings.EqualFold.  The absence
of this on Windows causes an unterminating condition in `for` statement
later in the function.

Fixes #13258

Change-Id: Ib5a0caba864ee425dc75ece47b9cf6fb626f47f1
Reviewed-on: https://go-review.googlesource.com/16857
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-11-17 23:48:47 +00:00
Matthew Dempsky
4d4a266780 net: fix IPv4 address selection
Only apply RFC 6724's CommonPrefixLen rule for IPv4 source/destination
pairs that are members of the same IPv4 special purpose block.

Fixes #13283.

Change-Id: I2f7c26b408dd4675dfc5c1959e22d05b43bb8241
Reviewed-on: https://go-review.googlesource.com/16995
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-17 23:48:43 +00:00
Mohit Agarwal
e0e4ccb51a path/filepath: include the original paths in error messages
On Windows, Rel emits error messages of the form `Rel: can't make
\windows relative to \windows`. Rather than emitting paths after
stripping volume names, emit the original paths so as to make those of
the form `Rel: can't make d:\windows relative to c:\windows`.  Fixed a
test that expected the error message to emit clean path instead of the
original.

Fixes #13259

Change-Id: I3a9bd5b137205f22794ec8046b4e917ee48cf750
Reviewed-on: https://go-review.googlesource.com/16858
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-11-17 23:46:38 +00:00
Hyang-Ah Hana Kim
888aadfa60 cmd: enable android/386 build (buildmode=pie by default)
no buildmode=c-shared yet.

Update golang/go#9327.

Change-Id: I9989d954d574807bac105da401c3463607fe8a99
Reviewed-on: https://go-review.googlesource.com/16700
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-17 22:37:26 +00:00
Elias Naur
7db77271e4 runtime: use a proper type, sigset, for m.sigmask
Replace the cross platform but unsafe [4]uintptr type with a OS
specific type, sigset. Most OSes already define sigset, and this
change defines a suitable sigset for the OSes that don't (darwin,
openbsd). The OSes that don't use m.sigmask (windows, plan9, nacl)
now defines sigset as the empty type, struct{}.

The gain is strongly typed access to m.sigmask, saving a dynamic
size sanity check and unsafe.Pointer casting. Also, some storage is
saved for each M, since [4]uinptr was conservative for most OSes.

The cost is that OSes that don't need m.sigmask has to define sigset.

completes ./all.bash with GOOS linux, on amd64
completes ./make.bash with GOOSes openbsd, android, plan9, windows,
darwin, solaris, netbsd, freebsd, dragonfly, all amd64.

With GOOS=nacl ./make.bash failed with a seemingly unrelated error.

R=go1.7

Change-Id: Ib460379f063eb83d393e1c5efe7333a643c1595e
Reviewed-on: https://go-review.googlesource.com/16942
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-17 21:23:06 +00:00
Joe Tsai
07d48993f2 cmd/doc: fix strange indentation artifacts with unexported fields
The NamePos value was not being set, and would default to a value
of zero. This would cause the printing logic to get confused as
to where exactly to place the "Has unexported fields" string.

A trivial package changes from

<
type A struct {
	A int // A
	B int
			// B
	// Has unexported fields.
}
>

to

<
type A struct {
	A int // A
	B int // B
	// Has unexported fields.
}
>

Fixes #12971

Change-Id: I53b7799a1f1c0ad7dcaddff83d9aaeb1d6b7823e
Reviewed-on: https://go-review.googlesource.com/16286
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-11-17 20:51:19 +00:00
Michael Hudson-Doyle
90e26f52c6 runtime, syscall: use int $0x80 to invoke syscalls on android/386
golang.org/cl/16796 broke android/386 by assuming behaviour specific to glibc's
dynamic linker. Copy bionic by using int $0x80 to invoke syscalls on
android/386 as the old alternative (CALL *runtime_vdso(SB)) cannot be compiled
without text relocations, which we want to get rid of on android.

Also remove "CALL *runtime_vdso(SB)" variant from the syscall package.

Change-Id: I6c01849f8dcbd073d000ddc8f13948a836b8b261
Reviewed-on: https://go-review.googlesource.com/16996
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-11-17 20:22:47 +00:00
Dan Peterson
f4a9bd87ba net: don't require recursion be available in DNS responses
Fixes #12778

Change-Id: I2ca53180d46180b951749abe453fd560d0f1d9d6
Reviewed-on: https://go-review.googlesource.com/16950
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-17 20:11:22 +00:00
Ian Lance Taylor
a29113f609 go/build: in TestDependencies, crypto/tls does not use cgo
Change-Id: Id164a099e0ac8bd231ee7ed8d7b7a34c91f5f68f
Reviewed-on: https://go-review.googlesource.com/16991
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-17 19:17:48 +00:00
Emmanuel Odeke
8b1152a599 net/http: add/update mp4 sniffing
Completes sniffing for mp4 signature according
to the spec at:
  https://mimesniff.spec.whatwg.org/#signature-for-mp4
Clause 6.2.1

Fixes #8773

Change-Id: Icfc4a23324ae249db52c94a21c0e8509e1833e19
Reviewed-on: https://go-review.googlesource.com/16951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-17 18:00:15 +00:00
David Crawshaw
ce8f49f42f runtime: android/arm64 support
Not all tests passing yet, but a good chunk are.

Change-Id: I5daebaeabf3aecb380674ece8830a86751a8d139
Reviewed-on: https://go-review.googlesource.com/16458
Reviewed-by: Rahul Chaudhry <rahulchaudhry@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-17 16:28:18 +00:00
Caleb Spare
babdb38320 net/http: detect when an HTTPS client contacts an HTTP server
Inspect the crypto/tls error to recognize this case and give a more
helpful error.

Fixes #11111.

Change-Id: I63f6af8c375aa892326ccccbd29655d54d68df0b
Reviewed-on: https://go-review.googlesource.com/16079
Run-TryBot: Caleb Spare <cespare@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-17 04:06:32 +00:00
Robert Griesemer
662ab8be31 cmd/compile/internal/gc: add dropped line correction again
The line correction when reporting a missing package clause
was removed before since it wasn't clear that it was needed.
Added it again because of issue 13267.

No explicit test case has been added to test/fixedbugs because
it would require a file that contains a single byte and such a
file doesn't fit the existing test harness. Instead documented
the problematic line in the parser for future reference.

Fixes #13267.

Change-Id: I590fe8f358042aab73acf16c2ed9567872b174f4
Reviewed-on: https://go-review.googlesource.com/16975
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:06:11 +00:00
Robert Griesemer
48a14663f8 test: add test case for issue #13248
Issue #13248 was fixed by https://go-review.googlesource.com/#/c/16930/.
This is the corresponding test case (original offending program).

Change-Id: I7c99783db74a5422704409cea7e5073094beadd3
Reviewed-on: https://go-review.googlesource.com/16973
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:05:51 +00:00
Robert Griesemer
0133d24c94 cmd/compile/internal/gc: don't ignore EOF in new parser
Fixes #13274.
Fixes #13272.

Change-Id: Ie67a2c4671ee2b49831898fff7677cd65d780942
Reviewed-on: https://go-review.googlesource.com/16972
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:05:39 +00:00
Robert Griesemer
a20556bf56 cmd/compile/internal/gc: correctly use internal call to error reporting
Fixes #13266.

Change-Id: I31da922e0599989e52acf346374c2077b157ebb7
Reviewed-on: https://go-review.googlesource.com/16971
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:05:07 +00:00
Austin Clements
f9357cdec1 runtime: check for updated arena_end overflow
Currently, if an allocation is large enough that arena_end + size
overflows (which is not hard to do on 32-bit), we go ahead and call
sysReserve with the impossible base and length and depend on this to
either directly fail because the kernel can't possibly fulfill the
requested mapping (causing mheap.sysAlloc to return nil) or to succeed
with a mapping at some other address which will then be rejected as
outside the arena.

In order to make this less subtle, less dependent on the kernel
getting all of this right, and to eliminate the hopeless system call,
add an explicit overflow check.

Updates #13143. This real issue has been fixed by 0de59c2, but this is
a belt-and-suspenders improvement on top of that. It was uncovered by
my symbolic modeling of that bug.

Change-Id: I85fa868a33286fdcc23cdd7cdf86b19abf1cb2d1
Reviewed-on: https://go-review.googlesource.com/16961
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-17 00:16:36 +00:00
Robert Griesemer
fbe855ba29 test: fix test case
Issue introduced by https://go-review.googlesource.com/#/c/16920/ .

TBR=rsc

Change-Id: I2a0e0c81f641f869568230837c566913f6538f37
Reviewed-on: https://go-review.googlesource.com/16990
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-11-16 23:49:54 +00:00
Austin Clements
4d39bb6a3a runtime: make mcache.tiny a uintptr
mcache.tiny is in non-GC'd memory, but points to heap memory. As a
result, there may or may not be write barriers when writing to
mcache.tiny. Make it clearer that funny things are going on by making
mcache.tiny a uintptr instead of an unsafe.Pointer.

Change-Id: I732a5b7ea17162f196a9155154bbaff8d4d00eac
Reviewed-on: https://go-review.googlesource.com/16963
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>
2015-11-16 22:07:41 +00:00
Austin Clements
835c83b40d runtime: clear tiny alloc cache in mark term, not sweep term
The tiny alloc cache is maintained in a pointer from non-GC'd memory
(mcache) to heap memory and hence must be handled carefully.

Currently we clear the tiny alloc cache during sweep termination and,
if it is assigned to a non-nil value during concurrent marking, we
depend on a write barrier to keep the new value alive. However, while
the compiler currently always generates this write barrier, we're
treading on thin ice because write barriers may not happen for writes
to non-heap memory (e.g., typedmemmove). Without this lucky write
barrier, the GC may free a current tiny block while it's still
reachable by the tiny allocator, leading to later memory corruption.

Change this code so that, rather than depending on the write barrier,
we simply clear the tiny cache during mark termination when we're
clearing all of the other mcaches. If the current tiny block is
reachable from regular pointers, it will be retained; if it isn't
reachable from regular pointers, it may be freed, but that's okay
because there won't be any pointers in non-GC'd memory to it.

Change-Id: I8230980d8612c35c2997b9705641a1f9f865f879
Reviewed-on: https://go-review.googlesource.com/16962
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>
2015-11-16 22:07:37 +00:00
Caleb Spare
45d1c8ab59 crypto/tls: return a typed error on invalid record headers
The user can inspect the record data to detect that the other side is
not using the TLS protocol.

This will be used by the net/http client (in a follow-on CL) to detect
when an HTTPS client is speaking to an HTTP server.

Updates #11111.

Change-Id: I872f78717aa8e8e98cebd8075436209a52039a73
Reviewed-on: https://go-review.googlesource.com/16078
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-16 21:54:44 +00:00
Marcel van Lohuizen
bf5b4e71be unicode/utf8: table-based algorithm for decoding
This simplifies covering all cases, reducing the number of branches
and making unrolling for simpler functions manageable.
This significantly improves performance of non-ASCII input.

This change will also allow addressing Issue #11733 in an efficient
manner.

RuneCountTenASCIIChars-8             13.7ns ± 4%  13.5ns ± 2%     ~     (p=0.116 n=7+8)
RuneCountTenJapaneseChars-8           153ns ± 3%    74ns ± 2%  -51.42%  (p=0.000 n=8+8)
RuneCountInStringTenASCIIChars-8     13.5ns ± 2%  12.5ns ± 3%   -7.13%  (p=0.000 n=8+7)
RuneCountInStringTenJapaneseChars-8   145ns ± 2%    68ns ± 2%  -53.21%  (p=0.000 n=8+8)
ValidTenASCIIChars-8                 14.1ns ± 3%  12.5ns ± 5%  -11.38%  (p=0.000 n=8+8)
ValidTenJapaneseChars-8               147ns ± 3%    71ns ± 4%  -51.72%  (p=0.000 n=8+8)
ValidStringTenASCIIChars-8           12.5ns ± 3%  12.3ns ± 3%     ~     (p=0.095 n=8+8)
ValidStringTenJapaneseChars-8         146ns ± 4%    70ns ± 2%  -51.62%  (p=0.000 n=8+7)
DecodeASCIIRune-8                    5.91ns ± 2%  4.83ns ± 3%  -18.28%  (p=0.001 n=7+7)
DecodeJapaneseRune-8                 12.2ns ± 7%   8.5ns ± 3%  -29.79%  (p=0.000 n=8+7)
FullASCIIRune-8                      5.95ns ± 3%  4.27ns ± 1%  -28.23%  (p=0.000 n=8+7)
FullJapaneseRune-8                   12.0ns ± 6%   4.3ns ± 3%  -64.39%  (p=0.000 n=8+8)

Change-Id: Iea1d6b0180cbbee1739659a0a38038126beecaca
Reviewed-on: https://go-review.googlesource.com/16940
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-16 21:16:51 +00:00
Russ Cox
2c11164db5 cmd/compile: fix value range check for complex constants
Fixes #11590.

Change-Id: I4144107334604a2cc98c7984df3b5d4cde3d30af
Reviewed-on: https://go-review.googlesource.com/16920
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:48:47 +00:00
Russ Cox
292ad59291 cmd/compile: do not emit args_stackmap for func _
Fixes #11699.

Change-Id: I01bf506d76260bcdf828bbde52791e328aa441a5
Reviewed-on: https://go-review.googlesource.com/16921
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:52 +00:00
Russ Cox
247959d9b8 cmd/compile: reject identifiers beginning with non-ASCII digit
Fixes #11359.

Change-Id: I0fdfa410939f7e42020cbb19d74a67e1cc3cd610
Reviewed-on: https://go-review.googlesource.com/16919
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:42 +00:00
Russ Cox
f2eb3de636 cmd/compile: document -trimpath
Fixes #8999.

Change-Id: I1390605bdf908f59b596975ea51eb04bd03bbae0
Reviewed-on: https://go-review.googlesource.com/16918
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:34 +00:00
Ian Lance Taylor
9aed0b7e3d cmd/compile: add special case for testing first field of struct variable
The change to the write barrier in https://golang.org/cl/16899 means
that the compiler now emits tests of the first field of a struct.  That
was using a register that was not used before.  This change fixes that
for amd64 by adding a special case for the first field of a struct.

Update #12416.

Change-Id: Ia57baa62cd741592fbeb9be82f1e846be73d6edd
Reviewed-on: https://go-review.googlesource.com/16933
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-16 18:39:40 +00:00
Ian Lance Taylor
be1ef46775 runtime: add optional expensive check for invalid cgo pointer passing
If you set GODEBUG=cgocheck=2 the runtime package will use the write
barrier to detect cases where a Go program writes a Go pointer into
non-Go memory.  In conjunction with the existing cgo checks, and the
not-yet-implemented cgo check for exported functions, this should
reliably detect all cases (that do not import the unsafe package) in
which a Go pointer is incorrectly shared with C code.  This check is
optional because it turns on the write barrier at all times, which is
known to be expensive.

Update #12416.

Change-Id: I549d8b2956daa76eac853928e9280e615d6365f4
Reviewed-on: https://go-review.googlesource.com/16899
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-16 18:39:06 +00:00
Ian Lance Taylor
1860a0fa57 cmd/dist: check more GOOS/GOARCH combinations in mkdeps.bash
The current mkdeps.bash just checks for dependencies for GOOS=windows
with the current GOARCH.  This is not always accurate as some package
imports only happen on specific GOOS/GOARCH combinations.  Check a
selected, easily changed, combination of GOOS/GOARCH values.

This generates a deps.go identical to the one in the repository today.

Fixes #13221.

Change-Id: I96d67d49c8c63641d578acedbb28be807607db65
Reviewed-on: https://go-review.googlesource.com/16882
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-16 18:34:48 +00:00
Rahul Chaudhry
f7c7ed7c41 cmd/go: set buildmode=pie default for android/arm64.
Just like android/arm, android/arm64 refuses to execute non-PIE
binaries. In addition, starting from the M release (Marshmallow),
Android refuses to execute binaries with any text relocations
(this was just a warning in the L release). This makes "-shared"
necessary as well when building executables for Android.

Change-Id: Id8802de5be98ff472fc370f8d22ffbde316aaf1e
Reviewed-on: https://go-review.googlesource.com/16744
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 18:32:57 +00:00
Austin Clements
0de59c27eb runtime: handle sysReserve returning a pointer below the arena
In mheap.sysAlloc, if an allocation at arena_used would exceed
arena_end (but wouldn't yet push us past arena_start+_MaxArean32), it
trie to extend the arena reservation by another 256 MB. It extends the
arena by calling sysReserve, which, on 32-bit, calls mmap without
MAP_FIXED, which means the address is just a hint and the kernel can
put the mapping wherever it wants. In particular, mmap may choose an
address below arena_start (the kernel also chose arena_start, so there
could be lots of space below it). Currently, we don't detect this case
and, if it happens, mheap.sysAlloc will corrupt arena_end and
arena_used then return the low pointer to mheap.grow, which will crash
when it attempts to index in to h_spans with an underflowed index.

Fix this by checking not only that that p+p_size isn't too high, but
that p isn't too low.

Fixes #13143.

Change-Id: I8d0f42bd1484460282a83c6f1a6f8f0df7fb2048
Reviewed-on: https://go-review.googlesource.com/16927
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 17:32:40 +00:00
Austin Clements
97dc591534 runtime: avoid stat underflow crash
If the area returned by sysReserve in mheap.sysAlloc is outside the
usable arena, we sysFree it. We pass a fake stat pointer to sysFree
because we haven't added the allocation to any stat at that point.
However, we pass a 0 stat, so sysFree panics when it decrements the
stat because the fake stat underflows.

Fix this by setting the fake stat to the allocation size.

Updates #13143 (this is a prerequisite to fixing that bug).

Change-Id: I61a6c9be19ac1c95863cf6a8435e19790c8bfc9a
Reviewed-on: https://go-review.googlesource.com/16926
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 17:32:29 +00:00
Marcel van Lohuizen
9b299c1efd unicode/utf8: removed uses of ranging over string
Ranging over string is much slower than using DecodeRuneInString.
See golang.org/issue/13162.

Replacing ranging over a string with the implementation of the Bytes
counterpart results in the following performance improvements:

RuneCountInStringTenASCIIChars-8     43.0ns ± 1%  16.4ns ± 2%  -61.80%  (p=0.000 n=7+8)
RuneCountInStringTenJapaneseChars-8   161ns ± 2%   154ns ± 2%   -4.58%  (p=0.000 n=8+8)
ValidStringTenASCIIChars-8           52.2ns ± 1%  13.2ns ± 1%  -74.62%  (p=0.001 n=7+7)
ValidStringTenJapaneseChars-8         173ns ± 2%   153ns ± 2%  -11.78%  (p=0.000 n=7+8)

Update golang/go#13162

Change-Id: Ifc40a6a94bb3317f1f2d929d310bd2694645e9f6
Reviewed-on: https://go-review.googlesource.com/16695
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-16 11:29:13 +00:00
Michael Hudson-Doyle
25a28da080 cmd/dist, cmd/go: run testshared on arm64
And enable PIE in the go tool.

Change-Id: Ibb60ccfe62518cde6e33080bbc78bfcbecff6a4e
Reviewed-on: https://go-review.googlesource.com/14000
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-15 23:41:28 +00:00
Michael Hudson-Doyle
4bae454d68 cmd/link: work around arm64 linker bugs with GOT relocations against local symbols
Change-Id: Ie14530c57720f1af1960ab77686b860e906058c6
Reviewed-on: https://go-review.googlesource.com/16582
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-15 23:40:59 +00:00
Michael Hudson-Doyle
3534e2bef4 cmd/internal/obj, cmd/link: access global data via a GOT in -dynlink mode on arm64
Change-Id: I6ca9406207e40c7c2c661075ccfe57b6600235cf
Reviewed-on: https://go-review.googlesource.com/13997
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-15 23:40:22 +00:00
Shenghou Ma
deb096122a crypto/tls: add TLS_RSA_WITH_AES_128_GCM_SHA256 and TLS_RSA_WITH_AES_256_GCM_SHA384 cipher suites
Fixes #9894.

Change-Id: I9c7ce771df2e2d1c99a06f800dce63c4e1875993
Reviewed-on: https://go-review.googlesource.com/16924
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2015-11-15 20:59:11 +00:00
Jingguo Yao
fb01ad21c2 math/rand: add a comment for the i=0 iteration
Fixes #13215

Change-Id: I126117d42e7c1e69cbc7fad0760e225b03ed15bd
Reviewed-on: https://go-review.googlesource.com/16852
Reviewed-by: Keith Randall <khr@golang.org>
2015-11-15 08:21:29 +00:00
Michael Hudson-Doyle
7af0839e11 cmd/go, runtime: always use position-independent code to invoke vsyscall helper on linux/386
golang.org/cl/16346 changed the runtime on linux/386 to invoke the vsyscall
helper via a PIC sequence (CALL 0x10(GS)) when dynamically linking. But it's
actually quite easy to make that code sequence work all the time, so do that,
and remove the ugly machinery that passed the buildmode from the go tool to the
assembly.

This means enlarging m.tls so that we can safely access 0x10(GS) (GS is set to
&m.tls + 4, so 0x10(GS) accesses m_tls[5]).

Change-Id: I1345c34029b149cb5f25320bf19a3cdd73a056fa
Reviewed-on: https://go-review.googlesource.com/16796
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-15 06:42:19 +00:00
Ian Lance Taylor
52393ad036 runtime: remove go:nosplit comment from reflect.typelinks
A nosplit comment was added to reflect.typelinks accidentally in
https://golang.org/cl/98510044.  There is only one caller of
reflect.typelinks, reflect.typesByString, and that function is not
nosplit.  There is no reason for reflect.typelinks to be nosplit.

Change-Id: I0fd3cc66fafcd92643e38e53fa586d6b2f868a0a
Reviewed-on: https://go-review.googlesource.com/16932
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-15 05:49:48 +00:00
Håvard Haugen
c60707b14d encoding/json: use reflect.SetBytes when decoding bytes
This allows slices of custom types with byte as underlying type to be
decoded, fixing a regression introduced in CL 9371.

Fixes #12921.

Change-Id: I62a715eaeaaa912b6bc599e94f9981a9ba5cb242
Reviewed-on: https://go-review.googlesource.com/16303
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-14 23:41:46 +00:00
Didier Spezia
0624fd3f14 cmd/compile: regenerate builtin.go
Following a recent change, file builtin.go is not up-to-date.
Generate it again by running go generate.

Fixes #13203

Change-Id: Ib91c5ccc93665c043da95c7d3783ce5d94e48466
Reviewed-on: https://go-review.googlesource.com/16821
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-14 22:17:20 +00:00
Shenghou Ma
3a96bf0d80 cmd/dist: disable shootout/spectralnorm on linux/mips64 builder
It is too slow with kernel FPU emulator.

Updates #12688.

Change-Id: Ib3a5adfeb46e894550231b14eb0f4fb20aecee11
Reviewed-on: https://go-review.googlesource.com/16922
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-14 21:43:49 +00:00
Ian Lance Taylor
754f707f5f cmd/link, cmd/go, cmd/dist: use copy of libgcc.a for internal linking
Change the linker to use a copy of the C compiler support library,
libgcc.a, when doing internal linking.  This will be used to satisfy any
undefined symbols referenced by host objects.

Change the dist tool to copy the support library into a new directory
tree under GOROOT/pkg/libgcc.  This ensures that libgcc is available
even when building Go programs on a system that has no C compiler.  The
C compiler is required when building the Go installation in the first
place, but is not required thereafter.

Change the go tool to not link libgcc into cgo objects.

Correct the linker handling of a weak symbol in an ELF input object to
not always create a new symbol, but to use an existing symbol if there
is one; this is necessary on freebsd-amd64, where libgcc contains a weak
definition of compilerrt_abort_impl.

Fixes #9510.

Change-Id: I1ab28182263238d9bcaf6a42804e5da2a87d8778
Reviewed-on: https://go-review.googlesource.com/16741
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-14 18:56:17 +00:00