]> Cypherpunks repositories - gostls13.git/log
gostls13.git
12 years agocmd/vet: restructure to be package-driven
Rob Pike [Fri, 22 Feb 2013 21:32:43 +0000 (13:32 -0800)]
cmd/vet: restructure to be package-driven
This is a simple refactoring of main.go that will enable the type checker
to be used during vetting.
The change has an unimportant effect on the arguments: it now assumes
that all files named explicitly on the command line belong to the same
package. When run by the go command, this was true already.

Also restore a missing parenthesis from an error message.

R=golang-dev, gri, bradfitz
CC=golang-dev
https://golang.org/cl/7393052

12 years agoruntime: add cgocallback_gofunc that can call Go func value
Russ Cox [Fri, 22 Feb 2013 21:08:56 +0000 (16:08 -0500)]
runtime: add cgocallback_gofunc that can call Go func value

For now, all the callbacks from C use top-level Go functions,
so they use the equivalent C function pointer, and will continue
to do so. But perhaps some day this will be useful for calling
a Go func value (at least if the type is already known).

More importantly, the Windows callback code needs to be able
to use cgocallback_gofunc to call a Go func value.
Should fix the Windows build.

R=ken2
CC=golang-dev
https://golang.org/cl/7388049

12 years agoexp/ssa: silence go vet
Rob Pike [Fri, 22 Feb 2013 21:02:00 +0000 (13:02 -0800)]
exp/ssa: silence go vet

R=adonovan
CC=golang-dev
https://golang.org/cl/7386052

12 years agoruntime: delete old closure code
Russ Cox [Fri, 22 Feb 2013 20:24:29 +0000 (15:24 -0500)]
runtime: delete old closure code

Step 4 of http://golang.org/s/go11func.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7393049

12 years agoreflect: stop using run-time code generation
Russ Cox [Fri, 22 Feb 2013 20:23:57 +0000 (15:23 -0500)]
reflect: stop using run-time code generation

Step 3 of http://golang.org/s/go11func.

Fixes #3736.
Fixes #3738.
Fixes #4081.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7393050

12 years agoexp/ssa: support variadic synthetic methods.
Alan Donovan [Fri, 22 Feb 2013 19:30:44 +0000 (14:30 -0500)]
exp/ssa: support variadic synthetic methods.

We wrap the final '...' argument's type in types.Slice.
Added tests.

Also:
- Function.writeSignature: suppress slice '[]' when printing
  variadic arg '...'.
- Eliminate Package.ImportPath field; redundant
  w.r.t. Package.Types.Path.
- Use "TODO: (opt|fix)" notation more widely.
- Eliminate many redundant/stale TODOs.

R=gri
CC=golang-dev
https://golang.org/cl/7378057

12 years agocmd/gc: avoid runtime code generation for closures
Russ Cox [Fri, 22 Feb 2013 19:25:50 +0000 (14:25 -0500)]
cmd/gc: avoid runtime code generation for closures

Change ARM context register to R7, to get out of the way
of the register allocator during the compilation of the
prologue statements (it wants to use R0 as a temporary).

Step 2 of http://golang.org/s/go11func.

R=ken2
CC=golang-dev
https://golang.org/cl/7369048

12 years agocmd/5l, cmd/6l, cmd/8l: accept CALL reg, reg
Russ Cox [Fri, 22 Feb 2013 19:23:21 +0000 (14:23 -0500)]
cmd/5l, cmd/6l, cmd/8l: accept CALL reg, reg

The new src argument is ignored during linking
(that is, CALL r1, r2 is identical to CALL r2 for linking),
but it serves as a hint to the 5g/6g/8g optimizer
that the src register is live on entry to the called
function and must be preserved.

It is possible to avoid exposing this fact to the rest of
the toolchain, keeping it entirely within 5g/6g/8g,
but I think it will help to be able to look in object files
and assembly listings and linker -a / -W output to
see CALL instructions are "Go func value" calls and
which are "C function pointer" calls.

R=ken2
CC=golang-dev
https://golang.org/cl/7364045

12 years agomime/multipart: allow unescaped newlines through in quoted-printable
Brad Fitzpatrick [Fri, 22 Feb 2013 18:40:23 +0000 (10:40 -0800)]
mime/multipart: allow unescaped newlines through in quoted-printable

This makes Go's quoted-printable decoder more like other
popular ones, allowing through a bare \r or \n, and also
passes through \r\n which looked like a real bug before.

Fixes #4771

R=minux.ma
CC=golang-dev
https://golang.org/cl/7300092

12 years agoruntime: preserve DX during racefuncenter
Russ Cox [Fri, 22 Feb 2013 18:06:43 +0000 (13:06 -0500)]
runtime: preserve DX during racefuncenter

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/7382049

12 years agoexp/ssa: fixed bug (typo) in findPromotedField.
Alan Donovan [Fri, 22 Feb 2013 17:35:45 +0000 (12:35 -0500)]
exp/ssa: fixed bug (typo) in findPromotedField.

By appending to the wrong (always empty) list, only the last
anonymous field was being considered for promotion.

Also:
- eliminated "function-local NamedTypes" TODO; nothing to do.
- fixed Function.DumpTo: printing of anon receivers was "( T)",
  now "(T)"; extracted writeSignature into own function.
- eliminated blockNames function;
  thanks to BasicBlock.String, "%s" of []*BasicBlock is fine.
- extracted buildReferrers into own function.

exp/ssa can now build its own transitive closure.

R=gri
CC=golang-dev
https://golang.org/cl/7384054

12 years agoruntime: avoid closure in parfor test
Russ Cox [Fri, 22 Feb 2013 17:11:12 +0000 (12:11 -0500)]
runtime: avoid closure in parfor test

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/7395051

12 years agocmd/6g, cmd/8g: switch to DX for indirect call block
Russ Cox [Fri, 22 Feb 2013 15:47:54 +0000 (10:47 -0500)]
cmd/6g, cmd/8g: switch to DX for indirect call block
runtime: add context argument to gogocall

Too many other things use AX, and at least one
(stack zeroing) cannot be moved onto a different
register. Use the less special DX instead.

Preparation for step 2 of http://golang.org/s/go11func.
Nothing interesting here, just split out so that we can
see it's correct before moving on.

R=ken2
CC=golang-dev
https://golang.org/cl/7395050

12 years agoexp/ssa: cross off a few remaining TODO issues.
Alan Donovan [Fri, 22 Feb 2013 05:09:21 +0000 (00:09 -0500)]
exp/ssa: cross off a few remaining TODO issues.

- append: nothing to do (nonsemantic change).
- delete: now performs correct conversion (+ test).
- emitCompare: nothing to do.
- emitArith (shifts): nothing to do (+ test).
- "banish untyped types": give up on that.
- real, imag: now do correct conversions.
- added comment to interp.go re zero-size values.

R=gri
CC=golang-dev
https://golang.org/cl/7391046

12 years agocmd/go: don't call ImportDir unnecessarily
Anthony Martin [Fri, 22 Feb 2013 04:09:31 +0000 (20:09 -0800)]
cmd/go: don't call ImportDir unnecessarily

This significantly speeds up the go tool on
slow file systems (or those with cold caches).

The following numbers were obtained using
an encrypted ext4 file system running on
Linux 3.7.9.

# Before
$ sudo sysctl -w 'vm.drop_caches=3'
$ time go list code.google.com/p/go.net/... | wc -l
9

real 0m16.921s
user 0m0.637s
sys 0m0.317s

# After
$ sudo sysctl -w 'vm.drop_caches=3'
$ time go list code.google.com/p/go.net/... | wc -l
9

real 0m8.175s
user 0m0.220s
sys 0m0.177s

R=rsc, r
CC=golang-dev
https://golang.org/cl/7369044

12 years agoexp/ssa/interp: fix build for Plan 9
Anthony Martin [Fri, 22 Feb 2013 04:06:26 +0000 (20:06 -0800)]
exp/ssa/interp: fix build for Plan 9

R=adonovan, minux.ma, alex.brainman, akumar, rminnich
CC=golang-dev, lucio.dere
https://golang.org/cl/7300078

12 years agotesting: document that example output must use line comments
Olivier Duperray [Fri, 22 Feb 2013 01:23:19 +0000 (12:23 +1100)]
testing: document that example output must use line comments

Fixes #4812.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7396051

12 years agoruntime: windows callback code to match new func value representation
Alex Brainman [Fri, 22 Feb 2013 01:21:42 +0000 (12:21 +1100)]
runtime: windows callback code to match new func value representation

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7393048

12 years agobufio: add examples for Scanner
Rob Pike [Thu, 21 Feb 2013 23:55:40 +0000 (15:55 -0800)]
bufio: add examples for Scanner
Mention Scanner in docs for ReadLine etc.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7375045

12 years agocmd/gc: fix FreeBSD build
Dave Cheney [Thu, 21 Feb 2013 23:28:03 +0000 (10:28 +1100)]
cmd/gc: fix FreeBSD build

R=jsing, mikioh.mikioh, bradfitz
CC=golang-dev
https://golang.org/cl/7390048

12 years agonet/url: fix URL Opaque notes on making client requests
Brad Fitzpatrick [Thu, 21 Feb 2013 22:39:16 +0000 (14:39 -0800)]
net/url: fix URL Opaque notes on making client requests

Fixes #4860

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7375047

12 years agotesting: fix output formatting
Robert Dinu [Thu, 21 Feb 2013 22:17:43 +0000 (14:17 -0800)]
testing: fix output formatting

Revision 5e7fd762f356 has changed the output formatting in a way that
is no longer in line with the format described by the revision
ff0ade0b937b which has introduced this functionality.
When decorating the first line, instead of indenting the whole line,
the current implementation adds indentation right after the "decorate"
part and  before the "log" message.
The fix addresses this issue.

R=golang-dev, iant, minux.ma, r, rsc, remyoudompheng
CC=golang-dev
https://golang.org/cl/7304094

12 years agocmd/gc, reflect, runtime: switch to indirect func value representation
Russ Cox [Thu, 21 Feb 2013 22:01:13 +0000 (17:01 -0500)]
cmd/gc, reflect, runtime: switch to indirect func value representation

Step 1 of http://golang.org/s/go11func.

R=golang-dev, r, daniel.morsing, remyoudompheng
CC=golang-dev
https://golang.org/cl/7393045

12 years agoarchive/tar: make test pass on setgid dirs
Brad Fitzpatrick [Thu, 21 Feb 2013 22:00:03 +0000 (14:00 -0800)]
archive/tar: make test pass on setgid dirs

Fixes #4867

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7382045

12 years agocmd/5g, cmd/5l, cmd/6l, cmd/8l, cmd/gc, cmd/ld, runtime: accurate args and locals...
Carl Shapiro [Thu, 21 Feb 2013 20:52:26 +0000 (12:52 -0800)]
cmd/5g, cmd/5l, cmd/6l, cmd/8l, cmd/gc, cmd/ld, runtime: accurate args and locals information

Previously, the func structure contained an inaccurate value for
the args member and a 0 value for the locals member.

This change populates the func structure with args and locals
values computed by the compiler.  The number of args was
already available in the ATEXT instruction.  The number of
locals is now passed through in the new ALOCALS instruction.

This change also switches the unit of args and locals to be
bytes, just like the frame member, instead of 32-bit words.

R=golang-dev, bradfitz, cshapiro, dave, rsc
CC=golang-dev
https://golang.org/cl/7399045

12 years agonet/http, net/url: deal with URL.Opaque beginning with //
Brad Fitzpatrick [Thu, 21 Feb 2013 20:01:47 +0000 (12:01 -0800)]
net/http, net/url: deal with URL.Opaque beginning with //

Update #4860

R=adg, rsc, campoy
CC=golang-dev
https://golang.org/cl/7369045

12 years agodoc: mention go fix in go1.1 release notes draft
Russ Cox [Thu, 21 Feb 2013 19:28:34 +0000 (14:28 -0500)]
doc: mention go fix in go1.1 release notes draft

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/7379045

12 years agounicode: use new Scanner interface in table creation
Rob Pike [Thu, 21 Feb 2013 18:47:31 +0000 (10:47 -0800)]
unicode: use new Scanner interface in table creation
Update norm and local/collate as well.

R=mpvl
CC=golang-dev
https://golang.org/cl/7395045

12 years agodatabase/sql: check for nil Scan pointers
Brad Fitzpatrick [Thu, 21 Feb 2013 18:43:00 +0000 (10:43 -0800)]
database/sql: check for nil Scan pointers

Return nice errors and don't panic.

Fixes #4859

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7383046

12 years agoruntime: better error from TestGcSys when gc is disabled
Russ Cox [Thu, 21 Feb 2013 18:30:31 +0000 (13:30 -0500)]
runtime: better error from TestGcSys when gc is disabled

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7390047

12 years agoruntime: fix heap corruption
Dmitriy Vyukov [Thu, 21 Feb 2013 17:59:46 +0000 (21:59 +0400)]
runtime: fix heap corruption

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7397049

12 years agocmd/5g, cmd/6g: fix node dump formats
Russ Cox [Thu, 21 Feb 2013 17:53:25 +0000 (12:53 -0500)]
cmd/5g, cmd/6g: fix node dump formats

lvd changed the old %N to %+hN and these
never got updated.

R=ken2
CC=golang-dev
https://golang.org/cl/7391045

12 years agoexp/ssa/interp: (#6 of 5): test interpretation of SSA form of $GOROOT/test/*.go.
Alan Donovan [Thu, 21 Feb 2013 17:48:38 +0000 (12:48 -0500)]
exp/ssa/interp: (#6 of 5): test interpretation of SSA form of $GOROOT/test/*.go.

The interpreter's os.Exit now triggers a special panic rather
than kill the test process.  (It's semantically dubious, since
it will run deferred routines.)  Interpret now returns its
exit code rather than calling os.Exit.

Also:
- disabled parts of a few $GOROOT/tests via os.Getenv("GOSSAINTERP").
- remove unnecessary 'slots' param to external functions; they
  are never closures.

Most of the tests are disabled until go/types supports shifts.
They can be reenabled if you patch this workaround:
https://golang.org/cl/7312068

R=iant, bradfitz
CC=golang-dev, gri
https://golang.org/cl/7313062

12 years agocmd/fix: delete pre-Go 1 fixes
Russ Cox [Thu, 21 Feb 2013 17:19:54 +0000 (12:19 -0500)]
cmd/fix: delete pre-Go 1 fixes

Assume people who were going to update to Go 1 have done so.
Those with pre-Go 1 trees remaining will need to update first
to Go 1.0 (using its 'go fix') and then to Go 1.1.

Cuts the cmd/fix test time by 99% (3 seconds to 0.03 seconds).

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7402046

12 years agoexp/ssa: add dedicated Panic instruction.
Alan Donovan [Thu, 21 Feb 2013 17:14:33 +0000 (12:14 -0500)]
exp/ssa: add dedicated Panic instruction.

By avoiding the need for self-loops following calls to panic,
we reduce the number of basic blocks considerably.

R=gri
CC=golang-dev, iant
https://golang.org/cl/7403043

12 years agonet: add benchmarks for network interface identification
Mikio Hara [Thu, 21 Feb 2013 16:19:04 +0000 (01:19 +0900)]
net: add benchmarks for network interface identification

Current results on linux/amd64:
BenchmarkInterfaces                      20000             80902 ns/op
BenchmarkInterfaceByIndex                50000             71591 ns/op
BenchmarkInterfaceByName                 20000             79908 ns/op
BenchmarkInterfaceAddrs                   2000            836413 ns/op
BenchmarkInterfacesAndAddrs               5000            605946 ns/op
BenchmarkInterfacesAndMulticastAddrs     10000            169029 ns/op

Update #4866.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7368046

12 years agoexp/ssa: build fully pruned SSA form.
Alan Donovan [Thu, 21 Feb 2013 16:11:57 +0000 (11:11 -0500)]
exp/ssa: build fully pruned SSA form.

Overview: Function.finish() now invokes the "lifting" pass which replaces local allocs and loads and stores to such cells by SSA registers.  We use very standard machinery:

(1) we build the dominator tree for the function's control flow graph (CFG) using the "Simple" Lengauer-Tarjan algorithm.  (Very "simple" in fact: even simple path compression is not yet implemented.)

In sanity-checking mode, we cross check the dominator tree against an alternative implementation using a simple iterative dataflow algorithm.
This all lives in dom.go, along with some diagnostic printing routines.

(2) we build the dominance frontier for the entire CFG using the Cytron et al algorithm.  The DF is represented as a slice of slices, keyed by block index.  See buildDomFrontier() in lift.go.

(3) we determine for each Alloc whether it can be lifted: is it only subject to loads and stores?  If so, we traverse the iterated dominance frontier (IDF) creating φ-nodes; they are not prepended to the blocks yet.
See liftAlloc() in lift.go.

(4) we perform the SSA renaming algorithm from Cytron et al, replacing all loads to lifted Alloc cells by the value stored by the dominating store operation, and deleting the stores and allocs.  See rename() in lift.go.

(5) we eliminate unneeded φ-nodes, then concatenate the remaining ones with the non-deleted instructions of the block into a new slice.  We eliminate any lifted allocs from Function.Locals.

To ease reviewing, I have avoided almost all optimisations at this point, though there are many opportunities to explore.  These will be easier to understand as follow-up changes.

All the existing tests (pending CL 7313062) pass.  (Faster!)

Details:

"NaiveForm" BuilderMode flag suppresses all the new logic.
Exposed as 'ssadump -build=N'.

BasicBlock:
- add .Index field (b.Func[b.Index]==b), simplifying
  algorithms such as Kildall-style dataflow with bitvectors.
- rename the Name field to Comment to better reflect its
  reduced purpose.  It now has a String() method.
- 'dom' field holds dominator tree node; private for now.
- new predIndex method.
- hasPhi is now a method

dom.go:
- domTree: a new struct for a node in a dominator tree.
- buildDomTree builds the dominator tree using the simple
  variant Lengauer/Tarjan algorithm with Georgiadis'
  bucket optimizations.
- sanityCheckDomTree builds dominance relation using
  Kildall-style dataflow and ensures the same result is
  obtained.
- printDomTreeDot prints the CFG/DomTree in GraphViz format.

blockopt.go:
- perform a mark/sweep pass to eliminate unreachable
  cycles; the previous prune() opt would only eliminate
  trivially dead blocks.  (Needed for LT algo.)
- using .Index, fuseblocks can now delete fused blocks directly.
- delete prune().

sanity.go: more consistency checks:
- Phi with missing edge value
- local Alloc instructions must appear in Function.Locals.
- BasicBlock.Index, Func consistency
- CFG edges are all intraprocedural.
- detect nils in BasicBlock.Instrs.
- detect Function.Locals with Heap flag set.
- check fn.Blocks is nil if empty.

Also:
- Phi now has Comment field for debugging.
- Fixed bug in Select.Operands()
  (took address of temporary copy of field)
- new Literal constructor zeroLiteral().
- algorithms steal private fields Alloc.index,
  BasicBlock.gaps to avoid allocating maps.
- We print Function.Locals in DumpTo.
- added profiling support to ssadump.

R=iant, gri
CC=golang-dev
https://golang.org/cl/7229074

12 years agoruntime: split minit() to mpreinit() and minit()
Dmitriy Vyukov [Thu, 21 Feb 2013 12:24:38 +0000 (16:24 +0400)]
runtime: split minit() to mpreinit() and minit()
mpreinit() is called on the parent thread and with mcache (can allocate memory),
minit() is called on the child thread and can not allocate memory.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7389043

12 years agodatabase/sql: clarify that DB.Prepare's stmt is safe for concurrent use
Brad Fitzpatrick [Thu, 21 Feb 2013 06:15:36 +0000 (22:15 -0800)]
database/sql: clarify that DB.Prepare's stmt is safe for concurrent use

And add a test too, for Alex. :)

Fixes #3734

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7399046

12 years agomisc/dashboard/builder: various cleanups
Dave Cheney [Thu, 21 Feb 2013 02:11:58 +0000 (13:11 +1100)]
misc/dashboard/builder: various cleanups

* allow commit watcher to be disabled, useful for small slow builders who will never be the first to notice a commit.
* builders always update their local master working copy before cloning a specific revision.
* refactor hg repo operations into a new type, Repo.

R=adg, shanemhansen, luitvd
CC=golang-dev
https://golang.org/cl/7326053

12 years agogo/types: export data result types are always parenthesized
Robert Griesemer [Thu, 21 Feb 2013 01:37:13 +0000 (17:37 -0800)]
go/types: export data result types are always parenthesized

Minor simplification of gcimporter, removed TODO.

R=adonovan
CC=golang-dev
https://golang.org/cl/7363044

12 years agonet/http: improve test reliability
Brad Fitzpatrick [Thu, 21 Feb 2013 00:39:33 +0000 (16:39 -0800)]
net/http: improve test reliability

Fixes #4852

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7374045

12 years agoimage/png: use Scanner in reader_test.
Rob Pike [Wed, 20 Feb 2013 23:57:18 +0000 (15:57 -0800)]
image/png: use Scanner in reader_test.

R=nigeltao
CC=golang-dev
https://golang.org/cl/7399044

12 years agodatabase/sql: refcounting and lifetime fixes
Brad Fitzpatrick [Wed, 20 Feb 2013 23:35:27 +0000 (15:35 -0800)]
database/sql: refcounting and lifetime fixes

Simplifies the contract for Driver.Stmt.Close in
the process of fixing issue 3865.

Fixes #3865
Update #4459 (maybe fixes it; uninvestigated)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7363043

12 years agoruntime: allow cgo callbacks on non-Go threads
Russ Cox [Wed, 20 Feb 2013 22:48:23 +0000 (17:48 -0500)]
runtime: allow cgo callbacks on non-Go threads

Fixes #4435.

R=golang-dev, iant, alex.brainman, minux.ma, dvyukov
CC=golang-dev
https://golang.org/cl/7304104

12 years agomisc/emacs: Present "godoc" documentation buffers using view-mode.
Steven Elliot Harris [Wed, 20 Feb 2013 22:42:37 +0000 (14:42 -0800)]
misc/emacs: Present "godoc" documentation buffers using view-mode.

Mimic the Emacs convention of presenting read-only files meant
for browsing using view-mode, rather than Fundamental mode
which mistakenly allows editing of the "godoc" content.
Fixes #4322.

R=golang-dev, bradfitz, sameer
CC=golang-dev
https://golang.org/cl/7231055

12 years agoA+C: Steven Elliot Harris (individual CLA)
Brad Fitzpatrick [Wed, 20 Feb 2013 22:42:13 +0000 (14:42 -0800)]
A+C: Steven Elliot Harris (individual CLA)

Generated by addca.

R=gobot
CC=golang-dev
https://golang.org/cl/7377045

12 years agoencoding/xml: make sure Encoder.Encode reports Write errors.
Olivier Saingre [Wed, 20 Feb 2013 22:41:23 +0000 (14:41 -0800)]
encoding/xml: make sure Encoder.Encode reports Write errors.

Fixes #4112.

R=remyoudompheng, daniel.morsing, dave, rsc
CC=golang-dev
https://golang.org/cl/7085053

12 years agoA+C: Olivier SAINGRE (individual CLA)
Brad Fitzpatrick [Wed, 20 Feb 2013 22:40:41 +0000 (14:40 -0800)]
A+C: Olivier SAINGRE (individual CLA)

Generated by addca.

R=gobot
CC=golang-dev
https://golang.org/cl/7400045

12 years agomime: use Scanner to read mime files during init
Rob Pike [Wed, 20 Feb 2013 22:34:03 +0000 (14:34 -0800)]
mime: use Scanner to read mime files during init
Also close the file when we're done.

R=bradfitz
CC=golang-dev
https://golang.org/cl/7363045

12 years agofmt: fix width for nil values
Robert Dinu [Wed, 20 Feb 2013 22:30:15 +0000 (14:30 -0800)]
fmt: fix width for nil values

Apply width when using Printf with nil values.
Fixes #4772.

R=r, adg
CC=golang-dev
https://golang.org/cl/7314114

12 years agoA+C: add Robert Dinu (Individual CLA)
Rob Pike [Wed, 20 Feb 2013 22:30:09 +0000 (14:30 -0800)]
A+C: add Robert Dinu (Individual CLA)

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7386045

12 years agostrconv: use Scanner in fp_test
Rob Pike [Wed, 20 Feb 2013 21:38:19 +0000 (13:38 -0800)]
strconv: use Scanner in fp_test

R=rsc
CC=golang-dev
https://golang.org/cl/7385045

12 years agoregexp: use Scanner in exec_test
Rob Pike [Wed, 20 Feb 2013 21:37:45 +0000 (13:37 -0800)]
regexp: use Scanner in exec_test

R=rsc
CC=golang-dev
https://golang.org/cl/7381046

12 years agocmd/godoc: better console error message for example error
Robert Griesemer [Wed, 20 Feb 2013 20:28:12 +0000 (12:28 -0800)]
cmd/godoc: better console error message for example error

(per r's suggestion)

R=r
CC=golang-dev
https://golang.org/cl/7376045

12 years agobufio: new Scanner interface
Rob Pike [Wed, 20 Feb 2013 20:14:31 +0000 (12:14 -0800)]
bufio: new Scanner interface

Add a new, simple interface for scanning (probably textual) data,
based on a new type called Scanner. It does its own internal buffering,
so should be plausibly efficient even without injecting a bufio.Reader.
The format of the input is defined by a "split function", by default
splitting into lines. Other implemented split functions include single
bytes, single runes, and space-separated words.

Here's the loop to scan stdin as a file of lines:

        s := bufio.NewScanner(os.Stdin)
        for s.Scan() {
                fmt.Printf("%s\n", s.Bytes())
        }
        if s.Err() != nil {
                log.Fatal(s.Err())
        }

While we're dealing with spaces, define what space means to strings.Fields.

Fixes #4802.

R=adg, rogpeppe, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/7322088

12 years agogo/types: support for customizable Alignof, Sizeof
Robert Griesemer [Wed, 20 Feb 2013 19:10:17 +0000 (11:10 -0800)]
go/types: support for customizable Alignof, Sizeof

(Offsetof is a function of Alignof and Sizeof.)

- removed IntSize, PtrSize from Context (set Sizeof instead)
- GcImporter needs a Context now (it needs to have
  access to Sizeof/Alignof)
- removed exported Size field from Basic (use Sizeof)
- added Offset to Field
- added Alignment, Size to Struct

R=adonovan
CC=golang-dev
https://golang.org/cl/7357046

12 years agoruntime: prepare for M's running w/o mcache
Dmitriy Vyukov [Wed, 20 Feb 2013 17:17:56 +0000 (21:17 +0400)]
runtime: prepare for M's running w/o mcache
Can not happen ATM. In preparation for the new scheduler.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7388043

12 years agoruntime: introduce entersyscallblock()
Dmitriy Vyukov [Wed, 20 Feb 2013 16:21:45 +0000 (20:21 +0400)]
runtime: introduce entersyscallblock()
In preparation for the new scheduler.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7386044

12 years agoruntime/debug: deflake TestFreeOSMemory
Dmitriy Vyukov [Wed, 20 Feb 2013 08:34:16 +0000 (12:34 +0400)]
runtime/debug: deflake TestFreeOSMemory
This is followup to https://golang.org/cl/7319050/

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7379043

12 years agoruntime: fix deadlock detector false negative
Dmitriy Vyukov [Wed, 20 Feb 2013 08:15:02 +0000 (12:15 +0400)]
runtime: fix deadlock detector false negative
Fixes #4819.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7322086

12 years agoruntime: ensure forward progress of runtime.Gosched() for locked goroutines
Dmitriy Vyukov [Wed, 20 Feb 2013 08:13:04 +0000 (12:13 +0400)]
runtime: ensure forward progress of runtime.Gosched() for locked goroutines
The removed code leads to the situation when M executes the same locked G again
and again.
This is https://golang.org/cl/7310096 but with return instead of break
in the nested switch.
Fixes #4820.

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/7304102

12 years agodoc: fix old broken link
Brad Fitzpatrick [Wed, 20 Feb 2013 06:40:54 +0000 (22:40 -0800)]
doc: fix old broken link

The Camlistore code tree rearranged after the go tool came
out. (I didn't know this link was here until I saw it in
some logs.)

R=adg
CC=golang-dev
https://golang.org/cl/7374043

12 years agopath/filepath, os/exec: unquote PATH elements on Windows
Péter Surányi [Wed, 20 Feb 2013 05:19:52 +0000 (16:19 +1100)]
path/filepath, os/exec: unquote PATH elements on Windows

On Windows, directory names in PATH can be fully or partially quoted
in double quotes ('"'), but the path names as used by most APIs must
be unquoted. In addition, quoted names can contain the semicolon
(';') character, which is otherwise used as ListSeparator.

This CL changes SplitList in path/filepath and LookPath in os/exec
to only treat unquoted semicolons as separators, and to unquote the
separated elements.

(In addition, fix harmless test bug I introduced for LookPath on Unix.)

Related discussion thread:
https://groups.google.com/d/msg/golang-nuts/PXCr10DsRb4/sawZBM7scYgJ

R=rsc, minux.ma, mccoyst, alex.brainman, iant
CC=golang-dev
https://golang.org/cl/7181047

12 years agowindows: fix syscall.SidTypeUser so following consts have correct values.
Brian Dellisanti [Wed, 20 Feb 2013 04:38:35 +0000 (15:38 +1100)]
windows: fix syscall.SidTypeUser so following consts have correct values.

Fixes #4844.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/7366043

12 years agoruntime: add conversion specifier to printf for char values
Carl Shapiro [Wed, 20 Feb 2013 02:05:44 +0000 (18:05 -0800)]
runtime: add conversion specifier to printf for char values

R=r, golang-dev
CC=golang-dev
https://golang.org/cl/7327053

12 years agonet: Plan 9: open data file and set remote-addr properly
Akshat Kumar [Wed, 20 Feb 2013 01:11:17 +0000 (17:11 -0800)]
net: Plan 9: open data file and set remote-addr properly

The data file should be opened when a Conn is first
established, rather than waiting for the first Read or
Write.

Upon Close, we now make sure to try to close both, the
ctl as well as data files and set both to nil, even in
the face of errors, instead of returning early.

The Accept call was not setting the remote address
of the connection properly. Now, we read the correct
file.

Make functions that establish Conn use newTCPConn
or newUDPConn.

R=rsc, rminnich, ality, dave
CC=golang-dev
https://golang.org/cl/7228068

12 years agonet: set up IPv6 scoped addressing zone for network facilities
Mikio Hara [Tue, 19 Feb 2013 23:18:04 +0000 (08:18 +0900)]
net: set up IPv6 scoped addressing zone for network facilities

This CL changes nothing to existing API behavior, just sets up
Zone in IPNet and IPAddr structures if possible.

Also does small simplification.

Update #4234.

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

12 years agonet: return correct point-to-point interface address on linux
Mikio Hara [Tue, 19 Feb 2013 22:31:44 +0000 (07:31 +0900)]
net: return correct point-to-point interface address on linux

On Linux point-to-point interface an IFA_ADDRESS attribute
represents a peer address. For a correct interface address
we should take an IFA_LOCAL attribute instead.

Fixes #4839.

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

12 years agogo/types: include package import path in NamedType.String().
Alan Donovan [Tue, 19 Feb 2013 19:42:05 +0000 (14:42 -0500)]
go/types: include package import path in NamedType.String().

This avoids ambiguity and makes the diagnostics closer to
those issued by gc, but it is more verbose since it qualifies
intra-package references.

Without extra context---e.g. a 'from *Package' parameter to
Type.String()---we are forced to err on one side or the other.

Also, cosmetic changes to exp/ssa:
- Remove package-qualification workaround in Function.FullName.
- Always set go/types.Package.Path field to the import path,
  since we know the correct path at this point.
- In Function.DumpTo, show variadic '...' and result type info,
  and delete now-redundant "# Type: " line.

R=gri
CC=golang-dev
https://golang.org/cl/7325051

12 years agoexp/README: update README
Robert Griesemer [Tue, 19 Feb 2013 19:21:18 +0000 (11:21 -0800)]
exp/README: update README

R=golang-dev, dsymonds, bradfitz
CC=golang-dev
https://golang.org/cl/7323073

12 years agocmd/godoc: use go/build to determine package and example files
Robert Griesemer [Tue, 19 Feb 2013 19:19:58 +0000 (11:19 -0800)]
cmd/godoc: use go/build to determine package and example files

Also:
- faster code for example extraction
- simplify handling of command documentation:
  all "main" packages are treated as commands
- various minor cleanups along the way

For commands written in Go, any doc.go file containing
documentation must now be part of package main (rather
then package documentation), otherwise the documentation
won't show up in godoc (it will still build, though).

For commands written in C, documentation may still be
in doc.go files defining package documentation, but the
recommended way is to explicitly ignore those files with
a +build ignore constraint to define package main.

Fixes #4806.

R=adg, rsc, dave, bradfitz
CC=golang-dev
https://golang.org/cl/7333046

12 years agopath/filepath: add examples for SplitList and Rel.
Kamil Kisiel [Tue, 19 Feb 2013 18:41:35 +0000 (10:41 -0800)]
path/filepath: add examples for SplitList and Rel.

R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/7291043

12 years agopath/filepath: document Dir better
Russ Cox [Tue, 19 Feb 2013 18:24:03 +0000 (13:24 -0500)]
path/filepath: document Dir better

This comment matches the one in path.

Fixes #4837.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7305100

12 years agogo/types: Use left-hand side's type as hint for right-hand
Andrew Wilkins [Tue, 19 Feb 2013 17:20:56 +0000 (09:20 -0800)]
go/types: Use left-hand side's type as hint for right-hand
side expression evaluation in assignment operations.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/7349046

12 years agodebug/dwarf: add flag_present attribute encoding.
Robin Eklind [Tue, 19 Feb 2013 16:58:31 +0000 (00:58 +0800)]
debug/dwarf: add flag_present attribute encoding.

ref: http://www.dwarfstd.org/doc/DWARF4.pdf

Update #4829

R=minux.ma, iant
CC=dave, golang-dev
https://golang.org/cl/7354043

12 years agostrings: faster Count, Index
Donovan Hide [Tue, 19 Feb 2013 15:36:15 +0000 (10:36 -0500)]
strings: faster Count, Index

Slightly better benchmarks for when string and separator are equivalent and also less branching in inner loops.
benchmark                        old ns/op    new ns/op    delta
BenchmarkGenericNoMatch               3430         3442   +0.35%
BenchmarkGenericMatch1               23590        22855   -3.12%
BenchmarkGenericMatch2              108031       105025   -2.78%
BenchmarkSingleMaxSkipping            2969         2704   -8.93%
BenchmarkSingleLongSuffixFail         2826         2572   -8.99%
BenchmarkSingleMatch                205268       197832   -3.62%
BenchmarkByteByteNoMatch               987          921   -6.69%
BenchmarkByteByteMatch                2014         1749  -13.16%
BenchmarkByteStringMatch              3083         3050   -1.07%
BenchmarkHTMLEscapeNew                 922          915   -0.76%
BenchmarkHTMLEscapeOld                1654         1570   -5.08%
BenchmarkByteByteReplaces            11897        11556   -2.87%
BenchmarkByteByteMap                  4485         4255   -5.13%
BenchmarkIndexRune                     174          121  -30.46%
BenchmarkIndexRuneFastPath              41           41   -0.24%
BenchmarkIndex                          45           44   -0.22%
BenchmarkMapNoChanges                  433          431   -0.46%
BenchmarkIndexHard1                4015336      3316490  -17.40%
BenchmarkIndexHard2                3976254      3395627  -14.60%
BenchmarkIndexHard3                3973158      3378329  -14.97%
BenchmarkCountHard1                4403549      3448512  -21.69%
BenchmarkCountHard2                4387437      3413059  -22.21%
BenchmarkCountHard3                4403891      3382661  -23.19%
BenchmarkIndexTorture                28354        25864   -8.78%
BenchmarkCountTorture                29625        27463   -7.30%
BenchmarkFields                   38752040     39169840   +1.08%
BenchmarkFieldsFunc               38797765     38888060   +0.23%

benchmark                         old MB/s     new MB/s  speedup
BenchmarkSingleMaxSkipping         3367.07      3697.62    1.10x
BenchmarkSingleLongSuffixFail       354.51       389.47    1.10x
BenchmarkSingleMatch                 73.07        75.82    1.04x
BenchmarkFields                      27.06        26.77    0.99x
BenchmarkFieldsFunc                  27.03        26.96    1.00x

R=dave, fullung, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/7350045

12 years agoA+C: Donovan Hide (individual CLA)
Russ Cox [Tue, 19 Feb 2013 15:36:03 +0000 (10:36 -0500)]
A+C: Donovan Hide (individual CLA)

Generated by addca.

R=gobot
CC=golang-dev
https://golang.org/cl/7351046

12 years agocodereview: give up on http fetch after 30 seconds
Russ Cox [Tue, 19 Feb 2013 15:18:16 +0000 (10:18 -0500)]
codereview: give up on http fetch after 30 seconds

If Python blocks in the SSL handshake it seems to be
completely uninterruptible, and I've been seeing it
block for at least hours recently. I don't know if the
problem is on the client side or the server side or
somewhere in the network, but setting the timeout
at least means you're guaranteed a new shell prompt
(after printing some errors).

R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/7337048

12 years agoruntime: replace bubble sort with heap sort in select
Russ Cox [Tue, 19 Feb 2013 15:15:13 +0000 (10:15 -0500)]
runtime: replace bubble sort with heap sort in select

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/7304106

12 years agoreflect: document tie-breaking in Select
Russ Cox [Tue, 19 Feb 2013 15:13:53 +0000 (10:13 -0500)]
reflect: document tie-breaking in Select

The exact words are taken from the spec.

Fixes some confusion on golang-nuts.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7353044

12 years agosrc: use internal tests if possible
Robin Eklind [Tue, 19 Feb 2013 15:02:01 +0000 (10:02 -0500)]
src: use internal tests if possible

If a test can be placed in the same package ("internal"), it is placed
there. This facilitates testing of package-private details. Because of
dependency cycles some packages cannot be tested by internal tests.

R=golang-dev, rsc, mikioh.mikioh
CC=golang-dev, r
https://golang.org/cl/7323044

12 years agodoc/gccgo_contribute: mention gofrontend-dev@googlegroups.com mailing list
Shenghou Ma [Tue, 19 Feb 2013 11:20:44 +0000 (19:20 +0800)]
doc/gccgo_contribute: mention gofrontend-dev@googlegroups.com mailing list

R=iant
CC=golang-dev
https://golang.org/cl/7323064

12 years agosrc/run.rc: "go env -9" is not valid, the correct command is "go tool dist env -9".
Lucio De Re [Tue, 19 Feb 2013 11:02:18 +0000 (19:02 +0800)]
src/run.rc: "go env -9" is not valid, the correct command is "go tool dist env -9".

R=minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7307120

12 years agoexp/cookiejar: store cookies under TLD+1 on nil public suffix list
Volker Dobler [Tue, 19 Feb 2013 08:12:36 +0000 (19:12 +1100)]
exp/cookiejar: store cookies under TLD+1 on nil public suffix list

The current implementation would store all cookies received from
any .com domain under "com" in the entries map if a nil public
suffix list is used in constructing the Jar. This is inefficient.

This CL uses the TLD+1 of the domain if the public suffix list
is nil which has two advantages:
 - It uses the entries map efficiently.
 - It prevents a host foo.com to set cookies for bar.com.
   (It may set the cookie, but it won't be returned to bar.com.)
A domain like www.british-library.uk may still set a domain
cookie for .british-library.uk in this case.

The behavior for a non-nil public suffix list is unchanged, cookies
are stored under eTLD+1 in this case.

R=nigeltao
CC=golang-dev
https://golang.org/cl/7312105

12 years agogo/types: Permit dereferencing of named pointer types.
Andrew Wilkins [Tue, 19 Feb 2013 03:03:10 +0000 (19:03 -0800)]
go/types: Permit dereferencing of named pointer types.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/7358044

12 years agogo/types: Pkg *Package field for all objects
Robert Griesemer [Mon, 18 Feb 2013 22:40:47 +0000 (14:40 -0800)]
go/types: Pkg *Package field for all objects

The field is nil for predeclared (universe)
objects and parameter/result variables.

R=adonovan
CC=golang-dev
https://golang.org/cl/7312093

12 years agoruntime: preparation for non-Go threads running Go code
Russ Cox [Mon, 18 Feb 2013 18:43:12 +0000 (13:43 -0500)]
runtime: preparation for non-Go threads running Go code

* Handle p==nil in signalstack by setting SS_DISABLE flag.
* Make minit only allocate a signal g if there's not one already.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7323072

12 years agocmd/6c: fix build
Russ Cox [Mon, 18 Feb 2013 18:29:55 +0000 (13:29 -0500)]
cmd/6c: fix build

copy+paste error while cleaning up CL 7303099 before submit

R=ken2
CC=golang-dev
https://golang.org/cl/7308104

12 years agocmd/6c, cmd/8c: cut stack frames by about half
Russ Cox [Mon, 18 Feb 2013 18:24:04 +0000 (13:24 -0500)]
cmd/6c, cmd/8c: cut stack frames by about half

The routine that adds an automatic to the stack was
adding ptrsize-1 to the size before rounding up.
That addition would only make sense to turn a round down
into a round up. Before a round up, it just wastes a word.

The effect was that a 6c function with one local and
one two-word function call used (8+8)+(16+8) = 40 bytes
instead of 8+16 = 24 bytes.

The wasted space mostly didn't matter, but one place where
it does matter is when trying to stay within the 128-byte
total frame constraint for #pragma textflag 7 functions.

This only affects the C compilers, not the Go compilers.

5c already had correct code, which is now copied to 6c and 8c.

R=ken2
CC=golang-dev
https://golang.org/cl/7303099

12 years agoruntime/debug: make TestFreeOSMemory repeatable
Dmitriy Vyukov [Mon, 18 Feb 2013 11:46:36 +0000 (15:46 +0400)]
runtime/debug: make TestFreeOSMemory repeatable
Fixes #4835.

R=golang-dev, fullung
CC=golang-dev
https://golang.org/cl/7319050

12 years agomisc/vim: update installation instructions to work better with some Linux distributions.
David Symonds [Mon, 18 Feb 2013 03:03:47 +0000 (14:03 +1100)]
misc/vim: update installation instructions to work better with some Linux distributions.

Fixes #3308.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7301086

12 years agoexp/cookiejar: make cookie sorting deterministic.
Volker Dobler [Mon, 18 Feb 2013 00:27:41 +0000 (11:27 +1100)]
exp/cookiejar: make cookie sorting deterministic.

Re-enable TestUpdateAndDelete, TestExpiration, TestChromiumDomain and
TestChromiumDeletion on Windows.

Sorting of cookies with same path length and same creation
time is done by an additional seqNum field.
This makes the order in which cookies are returned in Cookies
deterministic, even if the system clock is manipulated or on
systems with a low-resolution clock.

The tests now use a synthetic time: This makes cookie testing
reliable in case of bogus system clocks and speeds up the
expiration tests.

R=nigeltao, alex.brainman, dave
CC=golang-dev
https://golang.org/cl/7323063

12 years agoruntime: fix sigaction struct on freebsd
Joel Sing [Sun, 17 Feb 2013 16:23:29 +0000 (03:23 +1100)]
runtime: fix sigaction struct on freebsd

Fix the sa_mask member of the sigaction struct - on FreeBSD this is
declared as a sigset_t, which is an array of four unsigned ints.
Replace the current int64 with Sigset from defs_freebsd_GOARCH, which
has the correct definition.

Unbreaks the FreeBSD builds.

R=golang-dev, dave, minux.ma
CC=golang-dev
https://golang.org/cl/7333047

12 years agostrings: better mean complexity for Count and Index.
Rémy Oudompheng [Sun, 17 Feb 2013 12:07:17 +0000 (13:07 +0100)]
strings: better mean complexity for Count and Index.

The O(n+m) complexity is obtained probabilistically
by using Rabin-Karp algorithm, which provides the needed complexity
unless exceptional collisions occur, without memory allocation.

benchmark                 old ns/op    new ns/op    delta
BenchmarkIndexHard1         6532331      4045886  -38.06%
BenchmarkIndexHard2         8178173      4038975  -50.61%
BenchmarkIndexHard3         6973687      4042591  -42.03%
BenchmarkCountHard1         6270864      4071090  -35.08%
BenchmarkCountHard2         7838039      4072853  -48.04%
BenchmarkCountHard3         6697828      4071964  -39.20%
BenchmarkIndexTorture       2730546        28934  -98.94%
BenchmarkCountTorture       2729622        29064  -98.94%

Fixes #4600.

R=rsc, donovanhide, remyoudompheng
CC=golang-dev
https://golang.org/cl/7314095

12 years agoruntime: fix build on openbsd
Georg Reinke [Sat, 16 Feb 2013 15:06:59 +0000 (02:06 +1100)]
runtime: fix build on openbsd

R=golang-dev, jsing
CC=golang-dev
https://golang.org/cl/7312104

12 years agonet: add IPConn through Conn test
Mikio Hara [Sat, 16 Feb 2013 03:55:39 +0000 (12:55 +0900)]
net: add IPConn through Conn test

Also refactors mock ICMP stuff.

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

12 years agoruntime: fix unused variable warning
Dave Cheney [Sat, 16 Feb 2013 03:32:04 +0000 (14:32 +1100)]
runtime: fix unused variable warning

R=rsc, dvyukov
CC=golang-dev
https://golang.org/cl/7312103

12 years agoundo CL 7310096 / 59da6744d66d
Russ Cox [Fri, 15 Feb 2013 22:54:46 +0000 (17:54 -0500)]
undo CL 7310096 / 59da6744d66d

broke windows build

««« original CL description
runtime: ensure forward progress of runtime.Gosched() for locked goroutines
The removed code leads to the situation when M executes the same locked G again and again.
Fixes #4820.

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

TBR=dvyukov
CC=golang-dev
https://golang.org/cl/7343050

12 years agoos: point users of ProcessState.SysUsage to getrusage(2)
Russ Cox [Fri, 15 Feb 2013 22:11:13 +0000 (17:11 -0500)]
os: point users of ProcessState.SysUsage to getrusage(2)

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7352044