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

6473 Commits

Author SHA1 Message Date
Alex Brainman
5d50dbc55a net/http: use r.Body.Close to close connection during TestServeFileFromCWD
Fixes #3917.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6553061
2012-09-24 12:48:19 +10:00
Akshat Kumar
659d1df1bc pkg/go/ast: Avoid doing zero-length writes to the fd.
After each line, ast.Print would do a zero-length write,
which would hit the boundary condition on Plan 9 when
reading over pipes (since message boundaries are
preserved). This change makes sure we only do positive-
length writes.

R=rsc, rminnich, dave, r
CC=golang-dev
https://golang.org/cl/6558046
2012-09-24 08:30:28 +10:00
Russ Cox
46f379cc2c reflect: add Type.ConvertibleTo, Value.Convert (API CHANGE)
Fixes #4047.

R=iant, r
CC=golang-dev
https://golang.org/cl/6500065
2012-09-22 08:52:27 -04:00
Joel Sing
5373e8a8d7 debug/pe: add symbol support
Add support for processing the COFF symbol table.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/6551045
2012-09-22 17:56:49 +10:00
Jan Ziak
b16c41bed7 runtime: fix typos in comments
R=rsc
CC=golang-dev
https://golang.org/cl/6554043
2012-09-21 12:25:55 -04:00
Shenghou Ma
b151af1f36 runtime: fix mmap comments
We only pass lower 32 bits of file offset to asm routine.

R=r, dave, rsc
CC=golang-dev
https://golang.org/cl/6499118
2012-09-21 13:50:02 +08:00
Russ Cox
8572950383 all: match asm variable names to Go func declarations
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6548046
2012-09-21 00:35:56 -04:00
Russ Cox
4591cd631d unicode: performance improvements (API change)
*** There is an API change here: the introduction of the
LatinOffset int in the RangeTable struct. ***

* Avoid checking Latin range multiple times for non-Latin runes.
* Use linear search when it is faster than binary search.

go test -calibrate runs the calibration for where the linear/binary
crossover should be.

benchmark                       old MB/s     new MB/s  speedup
BenchmarkFields            36.27        41.43    1.14x
BenchmarkFieldsFunc        36.23        41.38    1.14x

The speedup here is evenly split between the linear scans
and the LatinOffset change. Both are about 1.07x.

R=r
CC=bradfitz, gobot, golang-dev
https://golang.org/cl/6526048
2012-09-21 00:35:25 -04:00
Mikio Hara
9773ac1d08 net: fix comment
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6546044
2012-09-21 07:13:36 +09:00
Dmitriy Vyukov
801f6e6367 sync: add Once test with panic
Tests behavior of Once when initialization function panics.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6554047
2012-09-20 23:29:29 +04:00
Dmitriy Vyukov
d151fb9e20 runtime: reset parfor stats
Otherwise they sum up between GCs.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6535048
2012-09-20 22:46:24 +04:00
Andrew Harding
c993ac11bc crypto/x509: Use ExtKeyUsage and UnknownExtKeyUsage fields from template in CreateCertificate
R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/6535057
2012-09-20 12:36:37 -04:00
Adam Langley
be11889ab1 crypto/x509: ignore non-critical email constraints
Previously we tried to parse email constraints as the maximum base
distance (which is unused and must be omitted according to RFC 5280)
because they share the same tag number. Rather than complicate the
code further, this CL just ignores the unused values.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6552044
2012-09-20 12:30:56 -04:00
Robert Griesemer
93195e1f31 encoding/gob: fix comment
Fixes #4100.

R=adg, r, dave
CC=golang-dev
https://golang.org/cl/6535055
2012-09-19 10:11:24 -07:00
Alex Brainman
28cb9fd509 os: use small writes during console io
Fixes #3767

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6523043
2012-09-19 16:55:21 +10:00
Andrew Gerrand
7e525928d3 go/doc: synthesize "package main" for examples
R=gri
CC=golang-dev
https://golang.org/cl/6525046
2012-09-18 14:13:34 -07:00
Dmitriy Vyukov
8ed026e783 race: build system changes
This is the first part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044
Adds -race flag to go command.
API change:
+pkg go/build, type Context struct, InstallTag string

R=rsc
CC=golang-dev
https://golang.org/cl/6488075
2012-09-18 23:47:15 +04:00
Russ Cox
0e60019a42 bytes, strings: add Fields benchmarks
The performance changes will be a few different CLs.
Start with benchmarks as a baseline.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6537043
2012-09-18 15:02:08 -04:00
Jan Ziak
35724c1aa5 runtime: hide the semaphore table from garbage collector
R=rsc, dvyukov, dave
CC=golang-dev
https://golang.org/cl/6528043
2012-09-18 14:30:01 -04:00
Jan Ziak
384af66984 reflect: use []unsafe.Pointer instead of []*int
R=rsc
CC=golang-dev
https://golang.org/cl/6527043
2012-09-18 14:23:11 -04:00
Russ Cox
ccf2b8843e encoding/json: do not read beyond array literal
Fixes #3942.

R=golang-dev, mike.rosset, r
CC=golang-dev
https://golang.org/cl/6524043
2012-09-18 14:22:55 -04:00
Russ Cox
370ae05545 reflect: add Select
R=r, iant, rogpeppe, bradfitz
CC=golang-dev
https://golang.org/cl/6498078
2012-09-18 14:22:41 -04:00
Anthony Eufemio
e8de8b58ca builtin: Changed documentation for rune type.
Fixes #4093.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/6536047
2012-09-18 11:01:10 -07:00
Dmitriy Vyukov
f20fd87384 runtime: refactor goroutine blocking
The change is a preparation for the new scheduler.
It introduces runtime.park() function,
that will atomically unlock the mutex and park the goroutine.
It will allow to remove the racy readyonstop flag
that is difficult to implement w/o the global scheduler mutex.

R=rsc, remyoudompheng, dave
CC=golang-dev
https://golang.org/cl/6501077
2012-09-18 21:15:46 +04:00
Mikio Hara
e4389c008a undo CL 6395055 / 2518eee18c4f
Broke TCP selfConnect

««« original CL description
net: avoid nil pointer dereference when RemoteAddr.String method chain is called

Fixes #3721.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/6395055
»»»

R=rsc
CC=golang-dev
https://golang.org/cl/6533043
2012-09-19 01:33:03 +09:00
Nigel Tao
648c9eb0b5 image/jpeg: ignore an incorrect but harmless trailing restart marker.
Fixes #4084.

R=r
CC=golang-dev
https://golang.org/cl/6526043
2012-09-18 21:57:33 +10:00
Alex Brainman
6e4d24999f syscall: attempt to find error message in "local" language before resorting to error number on windows
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6499121
2012-09-18 13:02:37 +10:00
Dave Cheney
55ca5ab0be runtime: arm: abort if VFPv3 support missing
Fixes #3456.

This proposal is a reformulation of CL 5987063. This CL resets
the default GOARM value to 6 and allows the use of the VFPv3
optimisation if GOARM=7. Binaries built with this CL in place
will abort if GOARM=7 was used and the target host does not
support VFPv3.

R=minux.ma, rsc, ajstarks
CC=golang-dev
https://golang.org/cl/6501099
2012-09-18 09:55:07 +10:00
Lucio De Re
b29ed23ab5 build: fix various 'set and not used' for Plan 9
R=dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6501134
2012-09-17 17:25:26 -04:00
Jan Ziak
54193689cc cmd/ld: fix compilation when GOARCH != GOHOSTARCH
R=rsc, dave, minux.ma
CC=golang-dev
https://golang.org/cl/6493123
2012-09-17 17:18:21 -04:00
Charles L. Dorian
0f8f5d2140 math: Faster Tanh
From 159 to 47.6 ns/op; slightly more accurate.

R=rsc, golang-dev, mtj, dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6500121
2012-09-17 17:18:16 -04:00
Sanjay Menakuru
da1ce83732 unicode/utf8: add Examples
R=golang-dev, r
CC=adg, golang-dev
https://golang.org/cl/6493124
2012-09-17 11:06:42 -07:00
Eric Eisner
0aad3cdc59 strings: implement a faster generic Replacer
This also fixes the semantics of some corner cases with the empty
match. TODOs for genericReplacer in the tests are fixed.

benchmark                  old ns/op    new ns/op    delta
BenchmarkGenericNoMatch        71395         3132  -95.61%
BenchmarkGenericMatch1         75610        20280  -73.18%
BenchmarkGenericMatch2        837995        86725  -89.65%

R=nigeltao, rsc
CC=golang-dev
https://golang.org/cl/6492076
2012-09-17 11:50:15 +10:00
Shenghou Ma
ecb2a0a9e5 runtime: fix SI_USER for FreeBSD
Ref: http://svnweb.freebsd.org/base/head/sys/sys/signal.h?revision=HEAD&view=markup

R=golang-dev, devon.odell, r
CC=golang-dev
https://golang.org/cl/6490118
2012-09-17 01:08:41 +08:00
Rob Pike
7b7a7a5737 text/template: towards better errors
Give the right name for errors, and add a test to check we're
getting the errors we expect.
Also fix an ordering bug (calling add after stopParse) that
caused a nil indirection rather than a helpful error.
Fixes #3280.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6520043
2012-09-14 15:25:37 -07:00
Brad Fitzpatrick
5c5c2c8112 os/exec: don't crash when out of fds
Command.Start could crash before if no fds were available
because a nil *os.File of /dev/null was added to the cleanup
list, which crashed before returning the proper error.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6514043
2012-09-14 13:40:22 -07:00
Russ Cox
ab224094d0 go/build: use custom file readers to avoid I/O
When reading Go files, read through import block.
When reading non-Go files, read only leading comments.

R=nigeltao, adg, r
CC=golang-dev
https://golang.org/cl/6493068
2012-09-14 12:22:45 -04:00
Marcel van Lohuizen
a4d08ed5df exp/locale/collate: changed API to allow access to different locales through New(),
instead of variables. Several reasons:
- Encourage users of the API to minimize the number of creations and reuse Collate objects.
- Don't rule out the possibility of using initialization code for collators. For some locales
  it will be possible to have very compact representations that can be quickly expanded
  into a proper table on demand.
Other changes:
- Change name of root* vars to main*, as the tables are shared between locales.
- Added Locales() method to get a list of supported locales.

R=r
CC=golang-dev
https://golang.org/cl/6498107
2012-09-14 19:10:02 +09:00
Adam Langley
ecc04b8927 crypto/tls: allow certificates and key to be in either order.
X509KeyPair wasn't really supposed to allow the certificate and
key to be in the same file, but it did work if you put the key
first. Since some HTTPS servers support loading keys and certs
like this, this change makes it work in either order.

Fixes #3986.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6499103
2012-09-13 11:00:16 -04:00
Russ Cox
37721cc1ce html/template: fix URL doc
This is the easy part of issue 3528.
(What to do about "noescape" is the hard part, left open.)

Update #3528.

R=mikesamuel, r, dsymonds
CC=golang-dev
https://golang.org/cl/6493113
2012-09-13 10:53:00 -04:00
Russ Cox
ef87c0edae crypto/rsa: reject PublicKey.E if it won't fit in a 32-bit int
Right now we only have 32-bit ints so that's a no-op.
Took the opportunity to check for some other invalid values too.
Suggestions for additions or modifications welcome.

R=agl
CC=golang-dev
https://golang.org/cl/6493112
2012-09-13 10:47:01 -04:00
Russ Cox
6ee91ced92 cmd/pack: rename __.SYMDEF to __.GOSYMDEF
This fixes a problem with ELF tools thinking they know the
format of the symbol table, as we do not use any of the
standard formats for that table.

This change will probably annoy the Plan 9 users, but I
believe there are other incompatibilities already that mean
they have to use a Go-specific nm.

Fixes #3473.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6500117
2012-09-13 10:26:21 -04:00
Francisco Souza
ec9967ff11 go/build: reject empty strings in Import
Fixes #3889.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/6499102
2012-09-13 10:25:35 -04:00
Nigel Tao
237ee39269 image/png: optimize encoding image.Gray and image.NRGBA images.
benchmark                    old ns/op    new ns/op    delta
BenchmarkEncodeGray           23616080      5624558  -76.18%
BenchmarkEncodeNRGBOpaque     34181260     17144380  -49.84%
BenchmarkEncodeNRGBA          41235820     20345990  -50.66%
BenchmarkEncodePaletted        5594652      5620362   +0.46%
BenchmarkEncodeRGBOpaque      17242210     17168820   -0.43%
BenchmarkEncodeRGBA           66515720     67243560   +1.09%

R=r
CC=golang-dev
https://golang.org/cl/6490099
2012-09-13 15:47:12 +10:00
Russ Cox
66331532cd net/rpc/jsonrpc: fix test error message
Fixes #4041.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6495121
2012-09-12 17:37:39 -04:00
Jan Ziak
d09afc2efb gc: generate garbage collection info for types
R=rsc, nigeltao, minux.ma
CC=golang-dev
https://golang.org/cl/6290043
2012-09-12 12:08:27 -04:00
Andreas Jellinghaus
452d6b46a3 syscall: add linux specific Getsockopt for Ucred struct
SO_PEERCRED on unix domain socket will fill a Ucred struct,
thus linux needs a custom Getsockopt variant.
Fixes #3836.

R=golang-dev, rsc, iant
CC=golang-dev
https://golang.org/cl/6445104
2012-09-12 06:38:21 -07:00
Alex Brainman
18601f88fd os: detect and handle console in File.Write on windows
Fixes #3376.

R=golang-dev, bsiegert, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6488044
2012-09-12 12:04:45 +10:00
Nigel Tao
6910356ea8 strings: fix NewReplacer(old0, new0, old1, new1, ...) to be consistent
when oldi == oldj.

Benchmark numbers show no substantial change.

R=eric.d.eisner, rogpeppe
CC=golang-dev
https://golang.org/cl/6496104
2012-09-12 10:40:39 +10:00
Nigel Tao
e39072d65f sync/atomic: add package doc for AddT, LoadT and StoreT.
Rename the first argument of CompareAndSwapT and AddT s/val/addr/
for consistency with LoadT and StoreT.

R=rsc, r, dvyukov
CC=golang-dev
https://golang.org/cl/6494112
2012-09-12 10:36:22 +10:00
Daniel Morsing
8fd65b0e1d cmd/gc: Inline pointer sized T2I interface conversions
This CL also adds support for marking the likelyness of IF nodes in the AST being true. This feature is being used here to mark the slow path as unlikely.

src/pkg/runtime:
benchmark                  old ns/op    new ns/op    delta
BenchmarkConvT2IUintptr           16            1  -91.63%

test/bench/go1:
benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    5416917000   5461355000   +0.82%
BenchmarkFannkuch11      3810355000   3842609000   +0.85%
BenchmarkGobDecode         19950950     19855420   -0.48%
BenchmarkGobEncode         11301220     11308530   +0.06%
BenchmarkGzip             548119600    546869200   -0.23%
BenchmarkGunzip           176145400    180208300   +2.31%
BenchmarkJSONEncode        93117400     70163100  -24.65%
BenchmarkJSONDecode       406626800    409999200   +0.83%
BenchmarkMandelbrot200      6300992      6317866   +0.27%
BenchmarkParse              7664396      7451625   -2.78%
BenchmarkRevcomp         1189424000   1412332000  +18.74%
BenchmarkTemplate         491308400    458654200   -6.65%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            38.47        38.66    1.00x
BenchmarkGobEncode            67.92        67.87    1.00x
BenchmarkGzip                 35.40        35.48    1.00x
BenchmarkGunzip              110.16       107.68    0.98x
BenchmarkJSONEncode           20.84        27.66    1.33x
BenchmarkJSONDecode            4.77         4.73    0.99x
BenchmarkParse                 7.56         7.77    1.03x
BenchmarkRevcomp             213.69       179.96    0.84x
BenchmarkTemplate              3.95         4.23    1.07x

R=rsc, dave, nigeltao
CC=golang-dev
https://golang.org/cl/6351090
2012-09-11 21:42:30 +02:00
Nigel Tao
b19c32acce strings: more thorough Replacer tests.
This verifies existing behavior. Some replacements are arguably wrong
(these are marked with TODO) but changing behavior is left for a
follow-up CL.

Also fix that BenchmarkGenericMatch wasn't actually matching anything.

R=rsc, eric.d.eisner
CC=bradfitz, golang-dev
https://golang.org/cl/6488110
2012-09-11 14:40:08 +10:00
Russ Cox
f97bfb93f4 encoding/json: handle anonymous fields
Fixes #3069.

R=golang-dev, n13m3y3r
CC=golang-dev
https://golang.org/cl/6460044
2012-09-10 23:31:40 -04:00
Mikio Hara
d5a8c58170 net: delete unused IP-level socket option helpers
R=rsc, dave
CC=bradfitz, gobot, golang-dev
https://golang.org/cl/6497044
2012-09-11 08:56:28 +09:00
Mikio Hara
6c4645cffe net: rename files to clarify platform dependency
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6489056
2012-09-11 07:37:43 +09:00
Robert Griesemer
b29d641b3a exp/types/staging: typechecker API
First set of type checker files for review.
The primary concern here is the typechecker
API (types.go).

R=rsc, adonovan, r, rogpeppe
CC=golang-dev
https://golang.org/cl/6490089
2012-09-10 14:54:52 -07:00
Brad Fitzpatrick
a7743d7ad2 net/http: add If-None-Match and If-Range support to ServeContent
Also, clear Content-Type and Content-Length on Not Modified
responses before server.go strips them and spams the logs with
warnings.

R=rsc
CC=golang-dev
https://golang.org/cl/6503090
2012-09-10 10:16:09 -07:00
Adam Langley
122d2873a8 crypto/rand: typo fix from a69e30463bf4
R=golang-dev
CC=golang-dev
https://golang.org/cl/6497106
2012-09-09 20:11:58 -04:00
Adam Langley
b752ab2e90 crypto/rand: zero length reads shouldn't crash on Windows.
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6496099
2012-09-09 20:07:09 -04:00
Mikio Hara
b737644266 net: change cname lookup test target to iana.org
It might be meaningful, and stable than others.

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/6499091
2012-09-09 23:53:48 +09:00
Marcel van Lohuizen
ef48dfa310 exp/locale/collate: added indices to builder for reusing blocks between locales.
Refactored build + buildTrie into build + buildOrdering.
Note that since the tailoring code is not checked in yet, all tailorings are identical
to root.  The table therefore should not and does not grow at this point.

R=r
CC=golang-dev
https://golang.org/cl/6500087
2012-09-08 10:46:55 +09:00
Marcel van Lohuizen
21d94a22fe exp/locale/collate: switch from DUCET to CLDR for the default root table.
R=r
CC=golang-dev
https://golang.org/cl/6499079
2012-09-08 10:38:11 +09:00
Robert Griesemer
d4cdfcf3d9 text/scanner: skip first character if it's a BOM
R=r
CC=golang-dev
https://golang.org/cl/6493097
2012-09-07 17:15:42 -07:00
Robert Griesemer
2a391f467d go/scanner: add missing BOM test
R=r
CC=golang-dev
https://golang.org/cl/6498106
2012-09-07 16:28:15 -07:00
Robert Griesemer
d5ab44e2fe go/scanner: skip first character if it's a BOM
R=r
CC=golang-dev
https://golang.org/cl/6490095
2012-09-07 13:56:31 -07:00
Albert Strasheim
412c60f1fa syscall: Test SCM credentials on Linux.
This test was previously removed in 087c6e15702e.

R=bradfitz, rsc, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6506061
2012-09-07 10:31:17 -07:00
Lucio De Re
7e414a5b01 net,mime: Minor corrections to documentation comments.
R=r
CC=dsymonds, gobot, golang-dev
https://golang.org/cl/6495085
2012-09-07 10:24:55 -07:00
Dave Cheney
212ce41d00 runtime: arm: abort if hardware floating point missing
Fixes #3911.

Requires CL 6449127.

dfc@qnap:~$ ./runtime.test
runtime: this CPU has no floating point hardware, so it cannot run
this GOARM=7 binary. Recompile using GOARM=5.

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6442109
2012-09-07 14:26:42 +10:00
Joel Sing
256cd7e78e syscall: regenerate/update netbsd z-files
Regenerate/update netbsd z-files on NetBSD 6.0 RC1.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6506062
2012-09-07 02:13:14 +10:00
Dave Cheney
67ee9a7db1 crypto/tls: fix data race on conn.err
Fixes #3862.

There were many areas where conn.err was being accessed
outside the mutex. This proposal moves the err value to
an embedded struct to make it more obvious when the error
value is being accessed.

As there are no Benchmark tests in this package I cannot
feel confident of the impact of this additional locking,
although most will be uncontended.

R=dvyukov, agl
CC=golang-dev
https://golang.org/cl/6497070
2012-09-06 17:50:26 +10:00
Marcel van Lohuizen
f0a31b5fc2 exp/locale/collate/build: moved some of the code to the appropriate file, as
promised in CL 13985.

R=r
CC=golang-dev
https://golang.org/cl/6503071
2012-09-06 13:16:02 +09:00
Nigel Tao
4bd8a38641 image/jpeg: fix quantization tables to be in zig-zag order, not natural
order.

JPEG images generated prior to this CL are still valid JPEGs, as the
quantization tables used are encoded in the wire format. Such JPEGs just
don't use the recommended quantization tables.

R=r, dsymonds, raph, adg
CC=golang-dev, tuom.larsen
https://golang.org/cl/6497083
2012-09-06 11:10:47 +10:00
Russ Cox
5e3224ce79 reflect: faster FieldByName, FieldByNameFunc
The old code was a depth first graph traversal that could, under the
right conditions, end up re-exploring the same subgraphs multiple
times, once for each way to arrive at that subgraph at a given depth.

The new code uses a breadth first search to make sure that it only
visits each reachable embedded struct once.

Also add fast path for the trivial case.

benchmark                old ns/op    new ns/op    delta
BenchmarkFieldByName1         1321          187  -85.84%
BenchmarkFieldByName2         6118         5186  -15.23%
BenchmarkFieldByName3      8218553        42112  -99.49%

R=gri, r
CC=golang-dev
https://golang.org/cl/6458090
2012-09-05 09:35:53 -04:00
Alan Donovan
ee911c4265 runtime: fix typo in openbsd-only symbol name.
R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6490076
2012-09-04 16:35:05 -04:00
Sébastien Paolacci
2836c63459 net: fix {FileConn, FileListener, FilePacketConn} fd leak to child process.
All of them call `newFileFD' which must properly restore close-on-exec on
duplicated fds.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6445081
2012-09-04 12:37:23 -07:00
Alan Donovan
532dee3842 runtime: discard SIGPROF delivered to non-Go threads.
Signal handlers are global resources but many language
environments (Go, C++ at Google, etc) assume they have sole
ownership of a particular handler.  Signal handlers in
mixed-language applications must therefore be robust against
unexpected delivery of certain signals, such as SIGPROF.

The default Go signal handler runtime·sigtramp assumes that it
will never be called on a non-Go thread, but this assumption
is violated by when linking in C++ code that spawns threads.
Specifically, the handler asserts the thread has an associated
"m" (Go scheduler).

This CL is a very simple workaround: discard SIGPROF delivered to non-Go threads.  runtime.badsignal(int32) now receives the signal number; if it returns without panicking (e.g. sig==SIGPROF) the signal is discarded.

I don't think there is any really satisfactory solution to the
problem of signal-based profiling in a mixed-language
application.  It's not only the issue of handler clobbering,
but also that a C++ SIGPROF handler called in a Go thread
can't unwind the Go stack (and vice versa).  The best we can
hope for is not crashing.

Note:
- I've ported this to all POSIX platforms, except ARM-linux which already ignores unexpected signals on m-less threads.
- I've avoided tail-calling runtime.badsignal because AFAICT the 6a/6l don't support it.
- I've avoided hoisting 'push sig' (common to both function calls) because it makes the code harder to read.
- Fixed an (apparently incorrect?) docstring.

R=iant, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6498057
2012-09-04 14:40:49 -04:00
Alan Donovan
b2458ff75c runtime/pprof: emit end-of-log marker at end of CPU profile.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6489065
2012-09-04 14:34:03 -04:00
Patrick Crosby
f4c22b29d4 net/http/pprof: updated documentation (run an http server)
Added instructions for starting an http server
to the godoc header for this package.  With the old
instructions, the example "go tool pprof..." commands
wouldn't work unless you happen to be running an http
server on port 6060 in your application.

R=golang-dev, minux.ma, adg, giacomo.tartari
CC=golang-dev
https://golang.org/cl/6483049
2012-09-04 11:27:20 +10:00
Alex Brainman
7f075ece42 runtime: increase stack frame during cgo call on windows/amd64
Fixes #3945.

R=golang-dev, minux.ma
CC=golang-dev, vcc.163
https://golang.org/cl/6490056
2012-09-03 12:12:51 +10:00
Russ Cox
a96c2b8c1a cmd/gc: fix PkgPath of byte, rune types
Fixes #3853.

R=ken2
CC=golang-dev
https://golang.org/cl/6492071
2012-09-01 19:55:55 -04:00
Rémy Oudompheng
c1c027964e strconv: faster FormatFloat for fixed number of digits.
The performance improvement applies to the case where
prec >= 0 and fmt is 'e' or 'g'.

Additional minor optimisations are included. A small
performance impact happens in some cases due to code
refactoring.

benchmark                              old ns/op    new ns/op    delta
BenchmarkAppendFloat64Fixed1                 623          235  -62.28%
BenchmarkAppendFloat64Fixed2                1050          272  -74.10%
BenchmarkAppendFloat64Fixed3                3723          243  -93.47%
BenchmarkAppendFloat64Fixed4               10285          274  -97.34%

BenchmarkAppendFloatDecimal                  190          206   +8.42%
BenchmarkAppendFloat                         387          377   -2.58%
BenchmarkAppendFloatExp                      397          339  -14.61%
BenchmarkAppendFloatNegExp                   377          336  -10.88%
BenchmarkAppendFloatBig                      546          482  -11.72%

BenchmarkAppendFloat32Integer                188          204   +8.51%
BenchmarkAppendFloat32ExactFraction          329          298   -9.42%
BenchmarkAppendFloat32Point                  400          372   -7.00%
BenchmarkAppendFloat32Exp                    369          306  -17.07%
BenchmarkAppendFloat32NegExp                 372          305  -18.01%

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6462049
2012-09-01 16:31:46 +02:00
Marcel van Lohuizen
5a78e5ea4c exp/locale/collate: Added functionality to parse and process LDML files
for both locale-specific exemplar characters and tailorings to
the collation table.
Some specifices:
- Moved stringSet to the beginning of the file and added some functionality
  to parse command line files.
- openReader now modifies the input URL for localFiles to guarantee that
  any http source listed in the generated file is indeed this source.
- Note that the implementation of the Tailoring API used by maketables.go
  is not yet checked in. So for now adding tailorings are simply no-ops.
- The generated file of exemplar characters will be used somewhere else.
  Here is a snippet of how the body of the generated file looks like:

type exemplarType int
const (
        exCharacters exemplarType = iota
        exContractions
        exPunctuation
        exAuxiliary
        exCurrency
        exIndex
        exN
)

var exemplarCharacters = map[string][exN]string{
        "af": [exN]string{
                0: "a á â b c d e é è ê ë f g h i î ï j k l m n o ô ö p q r s t u û v w x y z",
                3: "á à â ä ã æ ç é è ê ë í ì î ï ó ò ô ö ú ù û ü ý",
                4: "a b c d e f g h i j k l m n o p q r s t u v w x y z",
        },
        ...
}

R=r
CC=golang-dev
https://golang.org/cl/6501070
2012-09-01 14:15:00 +02:00
Marcel van Lohuizen
18aa55c169 exp/locale/collate: first changes that introduce implementation of tailorings:
- Elements in the array are now sorted as a linked list.  This makes it easier to
  apply tailorings.
- Added code to sort entries by collation elements.
- Added logical reset points.  This is used for tailoring relative to certain
  properties, rather than characters.

NOTE: all code for type entry should now be in order.go.  To keep the diffs for
this CL reasonable, though, the existing code is left in builder.go.  I'll move
this in a separate CL.

R=r
CC=golang-dev
https://golang.org/cl/6493063
2012-09-01 14:13:37 +02:00
Dave Cheney
dd79b330c9 syscall: add PtraceSyscall(pid int, signal int)
Fixes #3525.

PTRACE_SYSCALL behaves like PTRACE_CONT and can deliver
a signal to the process. Ideally PtraceSingleStep should
support the signal argument, but its interface is frozen
by Go1.

R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/6353051
2012-09-01 09:17:14 +10:00
Patrick Higgins
d168442708 net/http: added ParseTime function.
Parses a time header value into a time.Time according to rfc2616 sec 3.3.

R=golang-dev, dave, rsc, r
CC=bradfitz, golang-dev
https://golang.org/cl/6344046
2012-08-31 18:10:16 -04:00
Shawn Smith
a11b748fa2 encoding/xml: parse comments in DOCTYPE
R=rsc, n13m3y3r
CC=golang-dev
https://golang.org/cl/6330061
2012-08-31 18:09:31 -04:00
Ivan Krasin
5287175ad9 runtime: add vdso support for linux/amd64. Fixes issue 1933.
R=iant, imkrasin, krasin, iant, minux.ma, rsc, nigeltao, r, fullung
CC=golang-dev
https://golang.org/cl/6454046
2012-08-31 18:07:04 -04:00
Alexandru Moșoi
3efc482190 net/rpc/jsonrpc: handles missing "params" in jsonrpc.
A crash happens in the first request in a connection
if "params" field is missing because c.req.Params is Nil.

Fixes #3848.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6446051
2012-08-31 15:52:27 -04:00
Russ Cox
020c6558d9 runtime/pprof: restore articles in type doc comments
Reverts part of CL 6460082.

If a doc comment describes a type by explaining the
meaning of one instance of the type, a leading article
is fine and makes the text less awkward.

Compare:
// A dog is a kind of animal.
// Dog is a kind of animal.

R=golang-dev, dsymonds, dvyukov, r
CC=golang-dev
https://golang.org/cl/6494066
2012-08-31 13:49:57 -04:00
Akshat Kumar
a72bebf6e1 src: Add support for 64-bit version of Plan 9
This set of changes extends the Plan 9 support
to include the AMD64 architecture and should
work on all versions of Plan 9.

R=golang-dev, rminnich, noah.evans, rsc, minux.ma, npe
CC=akskuma, golang-dev, jfflore, noah.evans
https://golang.org/cl/6479052
2012-08-31 13:21:13 -04:00
Russ Cox
e29659b3c3 net/http: add (*ServeMux).Handler method
The Handler method makes the ServeMux dispatch logic
available to wrappers that enforce additional constraints
on requests.

R=golang-dev, bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/6450165
2012-08-31 12:16:31 -04:00
Christian Himpel
db7dbe32aa net/http: fix inserting of implicit redirects in serve mux
In serve mux, if pattern contains a host name, pass only the path to
the redirect handler.

Add tests for serve mux redirections.

R=rsc
CC=bradfitz, gobot, golang-dev
https://golang.org/cl/6329045
2012-08-31 12:00:01 -04:00
Nigel Tao
13cf2473b8 exp/html: change a node's children from a slice to a linked list.
Also rename Node.{Add,Remove} to Node.{AppendChild,RemoveChild} to
be consistent with the DOM.

benchmark                      old ns/op    new ns/op    delta
BenchmarkParser                  4042040      3749618   -7.23%

benchmark                       old MB/s     new MB/s  speedup
BenchmarkParser                    19.34        20.85    1.08x

BenchmarkParser mallocs per iteration is also:
10495 before / 7992 after

R=andybalholm, r, adg
CC=golang-dev
https://golang.org/cl/6495061
2012-08-31 10:00:12 +10:00
Robert Griesemer
d6c69dc602 go/scanner: don't print garbage if there's no error
R=r
CC=golang-dev
https://golang.org/cl/6489059
2012-08-30 16:10:33 -07:00
Rob Pike
363ec80dec cmd/gc: string conversion for surrogates
This is required by the spec to produce the replacement char.
The fix lies in lib9's rune code.

R=golang-dev, nigeltao, rsc
CC=golang-dev
https://golang.org/cl/6443109
2012-08-30 11:16:55 -07:00
Rob Pike
b7627d3d1f path: improve documentation for Dir
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6495059
2012-08-30 11:16:41 -07:00
Dmitriy Vyukov
e61c047c3e net/rpc: protect serviceMap with RWMutex
R=r, r
CC=golang-dev
https://golang.org/cl/6494044
2012-08-30 20:32:32 +04:00
Rob Pike
de13e8dccd text/template: make spaces significant
Other than catching an error case that was missed before, this
CL introduces no changes to the template language or API.

For simplicity, templates use spaces as argument separators.
This means that spaces are significant: .x .y is not the same as .x.y.
In the existing code, these cases are discriminated by the lexer,
but that means for instance that (a b).x cannot be distinguished
from (a b) .x, which is lousy. Although that syntax is not
supported yet, we want to support it and this CL is a necessary
step.

This CL emits a "space" token (actually a run of spaces) from
the lexer so the parser can discriminate these cases. It therefore
fixes a couple of undisclosed bugs ("hi".x is now an error) but
doesn't otherwise change the language. Later CLs will amend
the grammar to make .X a proper operator.

There is one unpleasantness: With space a token, three-token
lookahead is now required when parsing variable declarations
to discriminate them from plain variable references. Otherwise
the change isn't bad.

The CL also moves the debugging print code out of the lexer
into the test, which is the only place it's needed or useful.

Step towards resolving issue 3999.
It still remains to move field chaining out of the lexer
and into the parser and make field access an operator.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6492054
2012-08-29 21:42:53 -07:00
Shenghou Ma
f78ead3ca4 syscall: extract an ExampleLoadLibrary from comment
while we are at it, fix some out-of-date comments.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/6498054
2012-08-29 21:44:46 +08:00
Dave Cheney
f8d4bb884f net/http/httputil: fix race in DumpRequestOut
Fixes #3892.

Swapping the order of the writers inside the MultiWriter ensures
the request will be written to buf before http.ReadRequest completes.

The fencedBuffer is not required to make the test pass on
any machine that I have access too, but as the buf is shared
across goroutines, I think it is necessary for correctness.

R=bradfitz, fullung, franciscossouza
CC=golang-dev
https://golang.org/cl/6483061
2012-08-29 09:05:30 +10:00