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

6473 Commits

Author SHA1 Message Date
Andrew Gerrand
81ae666f16 go/doc: rewrite whole file examples for playground
R=gri
CC=gobot, golang-dev
https://golang.org/cl/6592061
2012-10-04 07:55:24 +10:00
Shenghou Ma
727e5ce95f testing: update package docs to use ResetTimer() instead of StopTimer/StartTimer()
R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/6591051
2012-10-03 11:41:18 +08:00
Rob Pike
7f4b4c0c00 text/template: better error messages during execution,
They now show the correct name, the byte offset on the line, and context for the failed evaluation.
Before:
        template: three:7: error calling index: index out of range: 5
After:
        template: top:7:20: executing "three" at <index "hi" $>: error calling index: index out of range: 5
Here top is the template that was parsed to create the set, and the error appears with the action
starting at byte 20 of line 7 of "top", inside the template called "three", evaluating the expression
<index "hi" $>.

Also fix a bug in index: it didn't work on strings. Ouch.

Also fix bug in error for index: was showing type of index not slice.
The real previous error was:
        template: three:7: error calling index: can't index item of type int
The html/template package's errors can be improved by building on this;
I'll do that in a separate pass.

Extends the API for text/template/parse but only by addition of a field and method. The
old API still works.

Fixes #3188.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6576058
2012-10-03 12:02:13 +10:00
Robert Griesemer
1659aef399 go/ast: track position of <- for channel types
This is a backward-compatible API change.

Without the correct <- position information,
certain channel types have incorrect position
information.

R=iant, iant
CC=golang-dev
https://golang.org/cl/6585063
2012-10-02 17:50:36 -07:00
Shivakumar GN
5f7f9062db os/user : use username as fullname if all else fails (on windows)
Fixes #4113.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6545054
2012-10-03 10:33:09 +10:00
Robert Griesemer
05dc3bf572 go/parser: correctly parse <-chan T(x) as <-(chan T)(x)
Fixes #4110.

R=iant
CC=golang-dev
https://golang.org/cl/6597069
2012-10-02 16:48:30 -07:00
Andrew Gerrand
cf513387c3 go/doc: strip example output comment from synthesized main function
R=gri
CC=gobot, golang-dev
https://golang.org/cl/6524047
2012-10-02 08:35:20 +10:00
Jeremy Jackins
b9e423eff3 archive/tar: fix inconsistent namespace usage in example
This fixes some example code in the tar package documentation, which
first refers to tar.NewWriter and then to Header, which is inconsistent
because NewWriter and Header are both in the tar namespace.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6595050
2012-10-02 08:10:42 +10:00
Adam Langley
9070d5759f math/big: avoid some allocation in Exp
benchmark                        old ns/op    new ns/op    delta
BenchmarkRSA1024Decrypt             745686       644964  -13.51%
BenchmarkRSA2048Decrypt            5517318      5049200   -8.48%
Benchmark3PrimeRSA2048Decrypt      3767386      3288048  -12.72%

R=gri
CC=gobot, golang-dev
https://golang.org/cl/6566043
2012-10-01 17:31:35 -04:00
Akshat Kumar
af582674b0 pkg/syscall: Plan 9, 64-bit: Update error checks from sys calls.
This change updates CL 6576057 for exceptional cases where
return values from Syscall/RawSyscall functions are used.

The system calls return 32-bit integers. With the recent change
in size of `int' in Go for amd64, the type conversion was not
catching `-1' return values. This change makes the conversion
explicitly `int32'.

R=rsc, r
CC=golang-dev
https://golang.org/cl/6590047
2012-10-01 10:09:08 +10:00
David Symonds
ff2f851af1 exp/types: permit importing packages without available source.
R=gri, iant
CC=golang-dev
https://golang.org/cl/6586051
2012-09-30 15:56:23 +10:00
David Symonds
0b448bdef7 exp/types: better diagnosis for compile failures.
R=gri, dave
CC=golang-dev
https://golang.org/cl/6587046
2012-09-30 15:46:37 +10:00
Mikio Hara
2fee6e3788 syscall: add ipv4 ancillary data for darwin
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6586044
2012-09-29 12:43:05 +09:00
Robert Griesemer
de782dd146 container/list: slightly better code factoring
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6569077
2012-09-28 10:58:46 -07:00
Robert Griesemer
0e9daef2d1 container/list: Correctly maintain internal invariants
The previous implementation was a mess with invariants
maintained inconsistently. Essentially reimplemented
the package:

- used a circular list as internal representation for
  significantly simpler implementation with fewer
  special cases while maintaining the illusion of
  a nil-terminated doubly linked list externally

- more precise documentation

- cleaned up and simplified tests, added test case
  for issue 4103.

No changes to the API or documented semantics.

All this said, I would be in favor of removing
this package eventually. container/ring provides
a faster implementation and a simpler and more
powerful API.

Fixes #4103.

R=r
CC=golang-dev
https://golang.org/cl/6569072
2012-09-28 10:35:32 -07:00
Eric Roshan-Eisner
631a0e71c1 strings: implement a faster single-string Replacer
The string searching is implemented separately so other functions
may make use of it in the future.

benchmark                        old ns/op    new ns/op    delta
BenchmarkSingleMaxSkipping          125889         2474  -98.03%
BenchmarkSingleLongSuffixFail        16252         1996  -87.72%
BenchmarkSingleMatch                260793       136266  -47.75%

benchmark                         old MB/s     new MB/s  speedup
BenchmarkSingleMaxSkipping           79.43      4041.57   50.88x
BenchmarkSingleLongSuffixFail        61.65       501.81    8.14x
BenchmarkSingleMatch                 57.52       110.08    1.91x

R=nigeltao
CC=golang-dev
https://golang.org/cl/6545049
2012-09-28 12:34:18 +10:00
Eric Roshan-Eisner
4bf6249ba5 testing: remove redundant whitespace in output
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6565061
2012-09-28 10:01:09 +10:00
Akshat Kumar
8fdc90acf4 pkg/syscall: Plan 9, 64-bit: Update error checks from sys calls.
The system calls return 32-bit integers. With the recent change
in size of `int' in Go for amd64, the type conversion was not
catching `-1' return values. This change makes the conversion
explicitly `int32'.

R=rsc, rminnich, npe, r
CC=golang-dev
https://golang.org/cl/6576057
2012-09-28 09:56:44 +10:00
Michael Chaten
e289a2b913 bufio: Implement io.WriterTo for (*Reader)
This is part 1 of 2 for issue 4028

benchmark                       old ns/op    new ns/op    delta
BenchmarkReaderCopyOptimal          33495         9849  -70.60%
BenchmarkReaderCopyUnoptimal        70631        27041  -61.72%
BenchmarkReaderCopyOldImpl          51407        52970   +3.04%

Update #4028

R=dave, nigeltao, rsc, bradfitz, rogpeppe
CC=golang-dev
https://golang.org/cl/6548047
2012-09-27 16:31:03 +10:00
Josh Holland
348e31f8f7 text/template: fix typo of errorf as error in comment.
R=r, minux.ma
CC=gobot, golang-dev
https://golang.org/cl/6506120
2012-09-27 15:47:54 +10:00
Nigel Tao
791ac65b82 lzw: fix Write returning the wrong number of bytes written.
Fixes #4160.

R=rsc, r
CC=golang-dev
https://golang.org/cl/6564060
2012-09-27 13:29:39 +10:00
Rob Pike
ffea835b8f fmt: allow # and x together for strings
Silly and small but easy to be consistent.
To make it worthwhile, I eliminated an allocation when using
%x on a byte slice.

Fixes #4149.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6574046
2012-09-27 06:21:38 +10:00
Sébastien Paolacci
7014bc64b1 net: spread fd over several pollservers.
Lighten contention without preventing further improvements on pollservers.
Connections are spread over Min(GOMAXPROCS, NumCPU, 8) pollserver instances.

Median of 10 runs, 4 cores @ 3.4GHz, amd/linux-3.2:

BenchmarkTCPOneShot                171917 ns/op   175194 ns/op      1.91%
BenchmarkTCPOneShot-2              101413 ns/op   109462 ns/op      7.94%
BenchmarkTCPOneShot-4               91796 ns/op    35712 ns/op    -61.10%
BenchmarkTCPOneShot-6               90938 ns/op    30607 ns/op    -66.34%
BenchmarkTCPOneShot-8               90374 ns/op    29150 ns/op    -67.75%
BenchmarkTCPOneShot-16             101089 ns/op   111526 ns/op     10.32%

BenchmarkTCPOneShotTimeout         174986 ns/op   178606 ns/op      2.07%
BenchmarkTCPOneShotTimeout-2       101585 ns/op   110678 ns/op      8.95%
BenchmarkTCPOneShotTimeout-4        91547 ns/op    35931 ns/op    -60.75%
BenchmarkTCPOneShotTimeout-6        91496 ns/op    31019 ns/op    -66.10%
BenchmarkTCPOneShotTimeout-8        90670 ns/op    29531 ns/op    -67.43%
BenchmarkTCPOneShotTimeout-16      101013 ns/op   106026 ns/op      4.96%

BenchmarkTCPPersistent              51731 ns/op    53324 ns/op      3.08%
BenchmarkTCPPersistent-2            32888 ns/op    30678 ns/op     -6.72%
BenchmarkTCPPersistent-4            25751 ns/op    15595 ns/op    -39.44%
BenchmarkTCPPersistent-6            26737 ns/op     9805 ns/op    -63.33%
BenchmarkTCPPersistent-8            26850 ns/op     9730 ns/op    -63.76%
BenchmarkTCPPersistent-16          104449 ns/op   102838 ns/op     -1.54%

BenchmarkTCPPersistentTimeout       51806 ns/op    53281 ns/op      2.85%
BenchmarkTCPPersistentTimeout-2     32956 ns/op    30895 ns/op     -6.25%
BenchmarkTCPPersistentTimeout-4     25994 ns/op    18111 ns/op    -30.33%
BenchmarkTCPPersistentTimeout-6     26679 ns/op     9846 ns/op    -63.09%
BenchmarkTCPPersistentTimeout-8     26810 ns/op     9727 ns/op    -63.72%
BenchmarkTCPPersistentTimeout-16   101652 ns/op   104410 ns/op      2.71%

R=rsc, dvyukov, dave, mikioh.mikioh, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/6496054
2012-09-26 15:32:59 -04:00
David du Colombier
cca48f1a57 crypto/x509: add Plan 9 root certificate location
R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/6571056
2012-09-26 14:47:47 -04:00
Shenghou Ma
948db4e091 crypto/aes: speed up using AES-NI on amd64
This CL requires CL 5970055.

benchmark           old ns/op    new ns/op    delta
BenchmarkEncrypt          161           23  -85.71%
BenchmarkDecrypt          158           24  -84.24%
BenchmarkExpand           526           62  -88.21%

benchmark            old MB/s     new MB/s  speedup
BenchmarkEncrypt        99.32       696.19    7.01x
BenchmarkDecrypt       100.93       641.56    6.36x

R=golang-dev, bradfitz, dave, rsc
CC=golang-dev
https://golang.org/cl/6549055
2012-09-27 01:54:10 +08:00
Rob Pike
ded94b7222 reflect.DeepEqual: rewrite clarification about nil and empty slice.
The previous version was created by an idiot. This time, Rog Peppe
wrote the text. Thanks, Rog.
(== doesn't work on slices in general, so it makes no sense to
talk about in the context of DeepEqual.)

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6566054
2012-09-26 20:46:49 +10:00
Mikio Hara
d6665bc338 net: fix plan 9 build
R=golang-dev, lucio.dere, fshahriar
CC=golang-dev
https://golang.org/cl/6562046
2012-09-26 16:11:49 +09:00
Rob Pike
74a7cc9bf2 reflect.DeepEqual: document that empty and nil are unequal for slices
Update #4133.
Added a sentence of documentation to call out the behavior.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6572051
2012-09-26 15:21:07 +10:00
Robert Griesemer
1785bfca6b exp/types/staging: updated gcimporter
Mostly minor changes to match the new
definitions in types.go and const.go.

R=rsc, r
CC=golang-dev
https://golang.org/cl/6506101
2012-09-25 17:39:02 -07:00
Robert Griesemer
ebf56e086d exp/types/staging: support for typechecking (most) builtins
This code relies on some functions that are not yet in staging,
but it get's harder to keep all this in sync in a piece-meal
fashion.

R=rsc
CC=golang-dev
https://golang.org/cl/6492124
2012-09-25 17:38:43 -07:00
Robert Griesemer
f5483fb801 exp/types/staging: operands, constants, and error handling
More pieces of the typechecker code:

- Operands are temporary objects representing an expressions's
type and value (for constants). An operand is the equivalent of
an "attribute" in attribute grammars except that it's not stored
but only passed around during type checking.

- Constant operations are implemented in const.go. Constants are
represented as bool (booleans), int64 and *big.Int (integers),
*big.Rat (floats), complex (complex numbers), and string (strings).

- Error reporting is consolidated in errors.go. Only the first
dozen of lines is new code, the rest of the file contains the
exprString and typeString functions formerly in two separate
files (which have been removed).

This is a replacement CL for 6492101 (which was created without
proper use of hg).

R=rsc, r
CC=golang-dev
https://golang.org/cl/6500114
2012-09-25 17:38:22 -07:00
Christian Himpel
1b6d4b5c0a net/http: use tls host instead of proxy, when checking against a certificate
Fixes #4152.

R=bradfitz
CC=golang-dev
https://golang.org/cl/6570045
2012-09-25 09:22:13 -07:00
Alex Brainman
0e6f927108 syscall: do not use int to test network syscall results (on windows)
Fixes #4147.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6569050
2012-09-25 17:06:39 +10:00
Russ Cox
10ea6519e4 build: make int 64 bits on amd64
The assembly offsets were converted mechanically using
code.google.com/p/rsc/cmd/asmlint. The instruction
changes were done by hand.

Fixes #2188.

R=iant, r, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/6550058
2012-09-24 20:57:01 -04:00
Jan Ziak
f8c58373e5 runtime: add types to MSpan
R=rsc
CC=golang-dev
https://golang.org/cl/6554060
2012-09-24 20:08:05 -04:00
Russ Cox
ba4625c66f reflect: add MakeFunc (API CHANGE)
Fixes #1765.

R=iant, r, daniel.morsing, minux.ma, bradfitz, rogpeppe, remyoudompheng
CC=golang-dev
https://golang.org/cl/6554067
2012-09-24 20:06:32 -04:00
Mikio Hara
4b9e8415de net: add read, write message methods to IPConn, UDPConn
Both methods allow to access the IP ancillary data through
socket control messages.

This CL is required for CL 6482044; go.net/ipv4: new package.

R=rsc, r, dave
CC=golang-dev
https://golang.org/cl/6426047
2012-09-25 06:57:32 +09:00
Adam Langley
65c7dc4ace crypto/tls: support session ticket resumption.
Session resumption saves a round trip and removes the need to perform
the public-key operations of a TLS handshake when both the client and
server support it (which is true of Firefox and Chrome, at least).

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6555051
2012-09-24 16:52:43 -04:00
Francesc Campoy
b7cbfe6ace testing: document -test.bench flag
Fixes #4080.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/6553068
2012-09-24 13:05:47 -07:00
Russ Cox
c7e0b8baa6 regexp/syntax: define accepted syntax
Update #3953.

R=bradfitz, campoy
CC=golang-dev
https://golang.org/cl/6543068
2012-09-24 15:33:53 -04:00
Eric Roshan-Eisner
74a1a8ae5f testing: add memory allocation stats to benchmark
R=rsc, nigeltao, dave, bradfitz, r, rogpeppe
CC=golang-dev
https://golang.org/cl/6497084
2012-09-24 15:03:16 -04:00
Russ Cox
0b08c9483f runtime: prepare for 64-bit ints
This CL makes the runtime understand that the type of
the len or cap of a map, slice, or string is 'int', not 'int32',
and it is also careful to distinguish between function arguments
and results of type 'int' vs type 'int32'.

In the runtime, the new typedefs 'intgo' and 'uintgo' refer
to Go int and uint. The C types int and uint continue to be
unavailable (cause intentional compile errors).

This CL does not change the meaning of int, but it should make
the eventual change of the meaning of int on amd64 a bit
smoother.

Update #2188.

R=iant, r, dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6551067
2012-09-24 14:58:34 -04:00
Akshat Kumar
e42788628a cmd/dist, pkg/runtime: Plan 9, 64-bit: Get PID from TLS; remove use of `_tos'.
Using offsets from Tos is cumbersome and we've had problems
in the past. Since it's only being used to grab the PID, we'll just
get that from the default TLS instead.

R=rsc, rminnich, npe
CC=golang-dev
https://golang.org/cl/6543049
2012-09-24 12:24:45 -04:00
Russ Cox
8696b08446 reflect: fix mistake in error message
Pointed out by James Chalfant after submit of CL 6500065.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/6543067
2012-09-24 11:47:27 -04:00
Russ Cox
2f06615588 encoding/asn1: prepare for 64-bit ints
The code was assuming that int = 32 bits. Don't.

Update #2188.

R=agl
CC=golang-dev
https://golang.org/cl/6543063
2012-09-24 10:30:37 -04:00
Nigel Tao
6efa648853 compress/flate: move the history buffer out of the decompressor struct.
I'm not exactly sure why there's a performance gain, but it seems like
an easy win. Maybe it's a cache line thing. Maybe it's that
unsafe.Sizeof(decompressor{}) drops to below unmappedzero, so that
checkref/checkoffset don't need to insert TESTB instructions. Maybe
it's less noise for the conservative garbage collector. Maybe it's
something else.

compress/flate benchmarks:
BenchmarkDecodeDigitsSpeed1e4          378628       349906   -7.59%
BenchmarkDecodeDigitsSpeed1e5         3481976      3204898   -7.96%
BenchmarkDecodeDigitsSpeed1e6        34419500     31750660   -7.75%
BenchmarkDecodeDigitsDefault1e4        362317       335562   -7.38%
BenchmarkDecodeDigitsDefault1e5       3290032      3107624   -5.54%
BenchmarkDecodeDigitsDefault1e6      30542540     28937480   -5.26%
BenchmarkDecodeDigitsCompress1e4       362803       335158   -7.62%
BenchmarkDecodeDigitsCompress1e5      3294512      3114526   -5.46%
BenchmarkDecodeDigitsCompress1e6     30514940     28927090   -5.20%
BenchmarkDecodeTwainSpeed1e4           412818       389521   -5.64%
BenchmarkDecodeTwainSpeed1e5          3475780      3288908   -5.38%
BenchmarkDecodeTwainSpeed1e6         33629640     31931420   -5.05%
BenchmarkDecodeTwainDefault1e4         369736       348850   -5.65%
BenchmarkDecodeTwainDefault1e5        2861050      2721383   -4.88%
BenchmarkDecodeTwainDefault1e6       27120120     25862050   -4.64%
BenchmarkDecodeTwainCompress1e4        372057       350822   -5.71%
BenchmarkDecodeTwainCompress1e5       2855109      2718664   -4.78%
BenchmarkDecodeTwainCompress1e6      26987010     26336030   -2.41%

image/png benchmarks:
BenchmarkDecodeGray               1841839      1802251   -2.15%
BenchmarkDecodeNRGBAGradient      7115318      6933280   -2.56%
BenchmarkDecodeNRGBAOpaque        6135892      6013284   -2.00%
BenchmarkDecodePaletted           1153313      1114302   -3.38%
BenchmarkDecodeRGB                5619404      5511190   -1.93%

R=rsc, r
CC=golang-dev
https://golang.org/cl/6533048
2012-09-24 17:58:08 +10:00
Marcel van Lohuizen
5e47b77990 exp/locale/collate/tools/colcmp: implementation of colcmp tool used for comparing
various implementation of collation.  The tool provides commands for soring,
regressing one implementation against another, and benchmarking.
Currently it includes collation implementations for the Go collator, ICU,
and one using Darwin's CoreFoundation framework.
To avoid building this tool in the default build, the colcmp tag has been
added to all files. This allows other tools/colcmp in this directory (e.g. it may make
sense to move maketables here) to be put in this directory as well.

R=r, rsc, mpvl
CC=golang-dev
https://golang.org/cl/6496118
2012-09-24 13:22:03 +09:00
Russ Cox
3d5ddffa30 syscall: prepare for 64-bit ints
This CL fixes code that incorrectly assumes that int is 32 bits wide.
Specifically, the socketpair system call expects a pointer to a pair
of int32s, not a pair of ints. Fix this inside the wrappers without
changing the APIs.

Update #2188.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6552063
2012-09-24 00:06:22 -04:00
Rob Pike
9050550c12 text/template: allow .Field access to parenthesized expressions
Change the grammar so that field access is a proper operator.
This introduces a new node, ChainNode, into the public (but
actually internal) API of text/template/parse. For
compatibility, we only use the new node type for the specific
construct, which was not parseable before. Therefore this
should be backward-compatible.

Before, .X.Y was a token in the lexer; this CL breaks it out
into .Y applied to .X. But for compatibility we mush them
back together before delivering. One day we might remove
that hack; it's the simple TODO in parse.go/operand.

This change also provides grammatical distinction between
        f
and
        (f)
which might permit function values later, but not now.

Fixes #3999.

R=golang-dev, dsymonds, gri, rsc, mikesamuel
CC=golang-dev
https://golang.org/cl/6494119
2012-09-24 13:23:15 +10:00
Russ Cox
edce634963 time: prepare for 64-bit ints
The code was trying to interpret a uint32 n as a signed quantity
and then store it in an int. For this, int(n) currently works, but when
int becomes 64 bits one must write int(int32(n)) instead, to get
the 32-bit sign extension.

Update #2188.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/6551068
2012-09-23 23:04:28 -04:00