1
0
mirror of https://github.com/golang/go synced 2024-10-04 08:21:22 -06:00
Commit Graph

9802 Commits

Author SHA1 Message Date
Rui Ueyama
fe4fc94b04 mime/multipart: delay reading random source
If a user sets his/her own boundary string with SetBoundary,
we don't need to call randomBoundary at all.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/95760043
2014-07-29 18:24:50 -07:00
Mikio Hara
678ba85e53 undo CL 107280044 / ee11f19bc514
preparing for the syscall package freeze.

««« original CL description
syscall: consolidate, simplify socket options for Unix-like systems

Also exposes common socket option functions on Solaris.

Update #7174
Update #7175

LGTM=aram
R=golang-codereviews, aram
CC=golang-codereviews
https://golang.org/cl/107280044
»»»

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/121880043
2014-07-30 10:02:16 +09:00
Mikio Hara
3bf75e691f undo CL 104290043 / 1d13818e6b3d
preparing for the syscall package freeze.

««« original CL description
syscall: add source-specific multicast socket options for FreeBSD

Update #8266

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/104290043
»»»

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/113660043
2014-07-30 10:01:32 +09:00
Rui Ueyama
a219ff25c6 bufio: fix rot13Reader bug in test
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/118410043
2014-07-29 17:56:28 -07:00
Mikio Hara
ed963c908d undo CL 102610045 / 7244ce3ae9db
preparing for the syscall package freeze.

««« original CL description
syscall: regenerate z-files for darwin

Updates z-files from 10.7 kernel-based to 10.9 kernel-based.

LGTM=iant
R=golang-codereviews, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/102610045
»»»

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/114530044
2014-07-30 09:47:39 +09:00
Mikio Hara
d7566da188 undo CL 101460043 / 746e175af5d2
preparing for the syscall package freeze.

««« original CL description
syscall: add source-specific multicast socket options for Darwin

Update #8266

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/101460043
»»»

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/115350043
2014-07-30 09:25:37 +09:00
Mihai Borobocea
bfdeb57cc3 fmt: measure width in runes not bytes with %c and %q for ints
This is meant to share my progress on Issue 8275, if it's useful to you. I'm not familiar with the formatter's internals, so this change is likely naive.

Change these calls to measure width in runes not bytes:
fmt.Printf("(%5q)\n", '§')
fmt.Printf("(%3c)\n", '§')

 Fixes #8275.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/104320043
2014-07-29 16:46:53 -07:00
Dmitriy Vyukov
dfa5a99ebb runtime: generate type info for chans
LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, khr
https://golang.org/cl/115280043
2014-07-29 22:06:47 +04:00
Dmitriy Vyukov
fe3ee5741d runtime: verify hmap type size
LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, khr
https://golang.org/cl/114510044
2014-07-29 22:06:20 +04:00
Dmitriy Vyukov
d514e2915c runtime: mark global var as NOPTR
LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/120280044
2014-07-29 15:18:01 +04:00
Dmitriy Vyukov
5dab2da954 runtime: mark global var as NOPTR
LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/119300043
2014-07-29 14:45:07 +04:00
Mikio Hara
c0325f5083 net: prevent spurious on-connect events via epoll on linux
On Linux, adding a socket descriptor to epoll instance before getting
the EINPROGRESS return value from connect system call could be a root
cause of spurious on-connect events.

See golang.org/issue/8276, golang.org/issue/8426 for further information.

All credit to Jason Eggleston <jason@eggnet.com>

Fixes #8276.
Fixes #8426.

LGTM=dvyukov
R=dvyukov, golang-codereviews, adg, dave, iant, alex.brainman
CC=golang-codereviews
https://golang.org/cl/120820043
2014-07-29 16:48:11 +09:00
Dmitriy Vyukov
cd17a717f9 runtime: simpler and faster GC
Implement the design described in:
https://docs.google.com/document/d/1v4Oqa0WwHunqlb8C3ObL_uNQw3DfSY-ztoA-4wWbKcg/pub

Summary of the changes:
GC uses "2-bits per word" pointer type info embed directly into bitmap.
Scanning of stacks/data/heap is unified.
The old spans types go away.
Compiler generates "sparse" 4-bits type info for GC (directly for GC bitmap).
Linker generates "dense" 2-bits type info for data/bss (the same as stacks use).

Summary of results:
-1680 lines of code total (-1000+ in mgc0.c only)
-25% memory consumption
-3-7% binary size
-15% GC pause reduction
-7% run time reduction

LGTM=khr
R=golang-codereviews, rsc, christoph, khr
CC=golang-codereviews, rlh
https://golang.org/cl/106260045
2014-07-29 11:01:02 +04:00
Rui Ueyama
0100afbdcc image/png: use branch-free abs function
benchmark                        old ns/op     new ns/op     delta
BenchmarkPaeth                   5.06          6.02          +18.97%
BenchmarkDecodeGray              1010551       956911        -5.31%
BenchmarkDecodeNRGBAGradient     3877813       3754160       -3.19%
BenchmarkDecodeNRGBAOpaque       3194058       3079094       -3.60%
BenchmarkDecodePaletted          699243        700211        +0.14%
BenchmarkDecodeRGB               2835733       2692120       -5.06%
BenchmarkDecodeInterlacing       3651805       3563124       -2.43%
BenchmarkEncodeGray              4399183       4404113       +0.11%
BenchmarkEncodeNRGBOpaque        13323627      13306485      -0.13%
BenchmarkEncodeNRGBA             15840092      15751188      -0.56%
BenchmarkEncodePaletted          4396622       4404373       +0.18%
BenchmarkEncodeRGBOpaque         13320475      13279189      -0.31%
BenchmarkEncodeRGBA              36898392      36781002      -0.32%

LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/117290043
2014-07-29 14:29:14 +10:00
Rob Pike
d3fb02b5c5 time: make it clearer that the reference time is the reference time.
Because the reference time is the reference time but beginners seem
to think otherwise, make it clearer you can't choose the reference time.

LGTM=josharian, dave
R=golang-codereviews, josharian, dave
CC=golang-codereviews
https://golang.org/cl/117250044
2014-07-28 17:24:39 -07:00
Adam Langley
30fbcc7576 crypto/tls: check curve equation in ECDHE.
This change causes a TLS client and server to verify that received
elliptic curve points are on the expected curve. This isn't actually
necessary in the Go TLS stack, but Watson Ladd has convinced me that
it's worthwhile because it's pretty cheap and it removes the
possibility that some change in the future (e.g. tls-unique) will
depend on it without the author checking that precondition.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/115290046
2014-07-28 15:46:27 -07:00
Adam Langley
8332112d0a encoding/asn1: only omit optional elements matching default value.
ASN.1 elements can be optional, and can have a default value.
Traditionally, Go has omitted elements that are optional and that have
the zero value. I believe that's a bug (see [1]).

This change causes an optional element with a default value to only be
omitted when it has that default value. The previous behaviour of
omitting optional, zero elements with no default is retained because
it's used quite a lot and will break things if changed.

[1] https://groups.google.com/d/msg/Golang-nuts/9Ss6o9CW-Yo/KL_V7hFlyOAJ

Fixes #7780.

R=bradfitz

LGTM=bradfitz
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews, r
https://golang.org/cl/86960045
2014-07-28 14:47:37 -07:00
Asim Shankar
42d0785bbd crypto/tls: Support ECDSA keys in generate_cert.go
R=golang-codereviews, bradfitz, agl
CC=golang-codereviews
https://golang.org/cl/117180043
2014-07-28 14:46:34 -07:00
Brad Fitzpatrick
f5037ee127 net/http: make ServeContent support dates in If-Range headers
Fixes #8367

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/116300044
2014-07-27 23:30:53 -07:00
Keith Randall
c403af83a6 runtime: convert complex128div to go.
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/116320043
2014-07-25 15:12:45 -07:00
Alex Brainman
5e805aff4a syscall: fix handling of bool return values in mksyscall_windows.go
LGTM=chines
R=chines
CC=golang-codereviews
https://golang.org/cl/118160044
2014-07-25 15:13:59 +10:00
Mathieu Lonjaret
cf35f5b742 time: minor typo in doc
LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/120150043
2014-07-24 18:18:41 -04:00
Keith Randall
3590d9ce69 runtime: set sweepgen atomically before updating span state
Sweepone may be running while a new span is allocating.  It
must not see the state updated while the sweepgen is unset.

Fixes #8399

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/118050043
2014-07-24 14:37:34 -07:00
Brad Fitzpatrick
c4807f6a84 net/http: don't ignore errors in Request.Write
LGTM=josharian, adg
R=golang-codereviews, josharian, adg
CC=golang-codereviews
https://golang.org/cl/119110043
2014-07-23 18:38:13 -07:00
Dmitriy Vyukov
e91704af27 runtime: don't lock mheap on user goroutine
This is bad for 2 reasons:
1. if the code under lock ever grows stack,
it will deadlock as stack growing acquires mheap lock.
2. It currently deadlocks with SetCPUProfileRate:
scavenger locks mheap, receives prof signal and tries to lock prof lock;
meanwhile SetCPUProfileRate locks prof lock and tries to grow stack
(presumably in runtime.unlock->futexwakeup). Boom.
Let's assume that it
Fixes #8407.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/112640043
2014-07-23 18:52:25 +04:00
Dmitriy Vyukov
0603fbb01c runtime: fix unexpected return pc for runtime.newstackcall
With cl/112640043 TestCgoDeadlockCrash episodically print:
unexpected return pc for runtime.newstackcall
After adding debug output I see the following trace:

runtime: unexpected return pc for runtime.newstackcall called from 0xc208011b00
runtime.throw(0x414da86)
        src/pkg/runtime/panic.c:523 +0x77
runtime.gentraceback(0x40165fc, 0xba440c28, 0x0, 0xc208d15200, 0xc200000000, 0xc208ddfd20, 0x20, 0x0, 0x0, 0x300)
	src/pkg/runtime/traceback_x86.c:185 +0xca4
runtime.callers(0x1, 0xc208ddfd20, 0x20)
	src/pkg/runtime/traceback_x86.c:438 +0x98
mcommoninit(0xc208ddfc00)
	src/pkg/runtime/proc.c:369 +0x5c
runtime.allocm(0xc208052000)
	src/pkg/runtime/proc.c:686 +0xa6
newm(0x4017850, 0xc208052000)
	src/pkg/runtime/proc.c:933 +0x27
startm(0xc208052000, 0x100000001)
	src/pkg/runtime/proc.c:1011 +0xba
wakep()
	src/pkg/runtime/proc.c:1071 +0x57
resetspinning()
	src/pkg/runtime/proc.c:1297 +0xa1
schedule()
	src/pkg/runtime/proc.c:1366 +0x14b
runtime.gosched0(0xc20808e240)
	src/pkg/runtime/proc.c:1465 +0x5b
runtime.newstack()
	src/pkg/runtime/stack.c:891 +0x44d
runtime: unexpected return pc for runtime.newstackcall called from 0xc208011b00
runtime.newstackcall(0x4000cbd, 0x4000b80)
	src/pkg/runtime/asm_amd64.s:278 +0x6f

I suspect that it can happen on any stack split.
So don't unwind g0 stack.
Also, that comment is lying -- we can traceback w/o mcache,
CPU profiler does that.

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/120040043
2014-07-23 18:51:34 +04:00
Russ Cox
d2d7187d31 testing: add Coverage function
I've found this very useful for generating
good test case lists for -short mode for
the disassemblers.

Fixes #7959.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/98150043
2014-07-22 22:56:35 -04:00
Alex Brainman
0403181a88 syscall: allow for mksyscall_windows.go to be used outside of syscall
Fixes #8398.

LGTM=chines
R=golang-codereviews, chines, josharian
CC=golang-codereviews
https://golang.org/cl/114140043
2014-07-23 12:36:34 +10:00
Dave Cheney
355c38d86a runtime: rename throwgo to gothrow
As pointed out by Elias Naur, the convention for Go runtime functions means this function should be named gothrow.

Discussion: https://golang.org/cl/115860045/#msg6

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/118120043
2014-07-23 07:08:52 +10:00
Keith Randall
722764b75a runtime: make go vet happy
CL 117950044 updates vet to fix LEA* issue.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/112440043
2014-07-21 21:35:48 -07:00
Keith Randall
76f1b901db runtime: keep build version around in binaries
So we can tell from a binary which version of
Go built it.

LGTM=minux, rsc
R=golang-codereviews, minux, khr, rsc, dave
CC=golang-codereviews
https://golang.org/cl/117040043
2014-07-21 20:52:11 -07:00
David Symonds
d9079cc883 syscall: fix typo in namei doc comment.
LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/112420044
2014-07-22 10:09:32 +10:00
David Symonds
446bfffcd6 crypto/subtle: make ConstantTimeCompare return zero for args of different length.
This is more useful than panicking, since otherwise every caller needs
to do the length check before calling; some will forget, and have a
potential submarine crasher as a result. Other implementations of this
functionality do a length check.

This is backward compatible, except if someone has written code that
relies on this panicking with different length args. However, that was
not the case before Go 1.3 either.

Updates #7304.

LGTM=agl
R=agl, minux, hanwen
CC=golang-codereviews
https://golang.org/cl/118750043
2014-07-22 10:08:23 +10:00
Dmitriy Vyukov
7bcbdbd904 runtime: pass correct size to malloc
In both cases we lie to malloc about the actual size that we need.
In panic we ask for less memory than we are going to use.
In slice we ask for more memory than we are going to use
(potentially asking for a fractional number of elements).
This breaks the new GC.

LGTM=khr
R=golang-codereviews, dave, khr
CC=golang-codereviews, rsc
https://golang.org/cl/116940043
2014-07-22 01:56:19 +04:00
Dmitriy Vyukov
92c54e4a73 runtime: simplify code
LGTM=khr
R=golang-codereviews, dave, khr
CC=golang-codereviews, rsc
https://golang.org/cl/116950043
2014-07-22 01:56:01 +04:00
Russ Cox
34655223ef runtime: round gohash stack frame to multiple of 8 on amd64p32
Even though pointers are 4 bytes the stack frame should be kept
a multiple of 8 bytes so that return addresses pushed on the stack
are properly aligned.

Fixes #8379.

LGTM=dvyukov, minux
R=minux, bradfitz, dvyukov, dave
CC=golang-codereviews
https://golang.org/cl/115840048
2014-07-21 17:38:30 -04:00
Brad Fitzpatrick
783bc895ae net/http: create internal pkg, unify two chunked.go files
LGTM=rsc
R=rsc, dan.kortschak
CC=golang-codereviews, r
https://golang.org/cl/115840046
2014-07-21 12:18:14 -07:00
Josh Bleecher Snyder
2ac289c4a0 runtime: add Benchmark[Clear|Copy]Fat[8|12]
These correspond to 2 and 3 word fat copies/clears on 8g, which dominate usage in the stdlib. (70% of copies and 46% of clears are for 2 or 3 words.) I missed these in CL 111350043, which added 2 and 3 word benchmarks for 6g. A follow-up CL will optimize these cases.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/115160043
2014-07-21 11:23:29 -07:00
Dmitriy Vyukov
40d7d5a656 cmd/gc: allocate select descriptor on stack
benchmark                      old ns/op     new ns/op     delta
BenchmarkSelectUncontended     220           165           -25.00%
BenchmarkSelectContended       209           161           -22.97%
BenchmarkSelectProdCons        1042          904           -13.24%

But more importantly this change will allow
to get rid of free function in runtime.

Fixes #6494.

LGTM=rsc, khr
R=golang-codereviews, rsc, dominik.honnef, khr
CC=golang-codereviews, remyoudompheng
https://golang.org/cl/107670043
2014-07-20 15:07:10 +04:00
Dmitriy Vyukov
1a116c76ae sync/atomic: fix data races in tests
Fixes #8389.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/111320044
2014-07-20 14:59:19 +04:00
Keith Randall
01a7d39df1 runtime: fix stacks_sys accounting
subtract freed count before span gets merged during free.

LGTM=dvyukov
R=dmitry, dvyukov
CC=golang-codereviews
https://golang.org/cl/112450045
2014-07-19 10:29:57 -07:00
Josh Bleecher Snyder
d2f322e9be runtime: use uint32 arrays in BenchmarkClearFat*
The CopyFat benchmarks were changed in CL 92760044. See CL 111350043 for discussion.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/116000043
2014-07-18 12:41:20 -07:00
Josh Bleecher Snyder
3ee391cc83 runtime: add Benchmark[Clear|Copy]Fat[16|24]
These benchmarks are important for performance. When compiling the stdlib:

* 77.1% of the calls to sgen (copyfat) are for 16 bytes; another 8.7% are for 24 bytes. (The next most common is 32 bytes, at 5.7%.)
* Over half the calls to clearfat are for 16 or 24 bytes.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews
https://golang.org/cl/111350043
2014-07-18 12:18:36 -07:00
Nicolas Owens
e45c384b73 os: broaden the range of errors understood by IsNotExist on Plan 9
Ken's standalone file server and its derivatives, like cwfs, return
error strings different from fossil when the user opens non-existent
files.

LGTM=aram, 0intro, r
R=0intro, aram, r
CC=golang-codereviews, ken
https://golang.org/cl/112420045
2014-07-18 11:04:29 -07:00
Josh Bleecher Snyder
6089fc767c go/ast: fix typo in comment
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/111330043
2014-07-18 09:58:54 -07:00
Egon Elbre
0b2da60fb8 bufio: fix UnreadSlice followed by UnreadRune
Also, fix a write check in writeBuf and make some bounds checks simpler.

LGTM=gri
R=golang-codereviews, adg, gri, r, minux
CC=golang-codereviews
https://golang.org/cl/113060043
2014-07-18 09:25:59 -07:00
Keith Randall
2425a2e32f runtime: fix gctrace=1
updatememstats is called on both the m and g stacks.
Call into flushallmcaches correctly.  flushallmcaches
can only run on the M stack.

This is somewhat temporary.  once ReadMemStats is in
Go we can have all of this code M-only.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/116880043
2014-07-18 13:05:21 +04:00
Dmitriy Vyukov
5d58033682 go/printer: simplify test
Pre Go1?

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/115870043
2014-07-18 12:44:24 +04:00
Dmitriy Vyukov
4423222760 encoding/gob: remove unnecessary receivers
Encoder compilation must be enc-independent,
because the resulting program is reused across
different encoders.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/115860043
2014-07-18 12:39:00 +04:00
Dave Cheney
ec5d7ba95c runtime: add throwgo
Fixes #8380.

Also update hashmap.go to use throwgo rather than panic.

LGTM=khr
R=khr, rsc
CC=golang-codereviews
https://golang.org/cl/115860045
2014-07-18 16:30:38 +10:00