1
0
mirror of https://github.com/golang/go synced 2024-09-25 09:20:18 -06:00
Commit Graph

11889 Commits

Author SHA1 Message Date
Russ Cox
1d5dc4fd48 cmd/gc: emit explicit type information for local variables
The type information is (and for years has been) included
as an extra field in the address chunk of an instruction.
Unfortunately, suppose there is a string at a+24(FP) and
we have an instruction reading its length. It will say:

        MOVQ x+32(FP), AX

and the type of *that* argument is int (not slice), because
it is the length being read. This confuses the picture seen
by debuggers and now, worse, by the garbage collector.

Instead of attaching the type information to all uses,
emit an explicit list of TYPE instructions with the information.
The TYPE instructions are no-ops whose only role is to
provide an address to attach type information to.

For example, this function:

        func f(x, y, z int) (a, b string) {
                return
        }

now compiles into:

        --- prog list "f" ---
        0000 (/Users/rsc/x.go:3) TEXT    f+0(SB),$0-56
        0001 (/Users/rsc/x.go:3) LOCALS  ,
        0002 (/Users/rsc/x.go:3) TYPE    x+0(FP){int},$8
        0003 (/Users/rsc/x.go:3) TYPE    y+8(FP){int},$8
        0004 (/Users/rsc/x.go:3) TYPE    z+16(FP){int},$8
        0005 (/Users/rsc/x.go:3) TYPE    a+24(FP){string},$16
        0006 (/Users/rsc/x.go:3) TYPE    b+40(FP){string},$16
        0007 (/Users/rsc/x.go:3) MOVQ    $0,b+40(FP)
        0008 (/Users/rsc/x.go:3) MOVQ    $0,b+48(FP)
        0009 (/Users/rsc/x.go:3) MOVQ    $0,a+24(FP)
        0010 (/Users/rsc/x.go:3) MOVQ    $0,a+32(FP)
        0011 (/Users/rsc/x.go:4) RET     ,

The { } show the formerly hidden type information.
The { } syntax is used when printing from within the gc compiler.
It is not accepted by the assemblers.

The same type information is now included on global variables:

0055 (/Users/rsc/x.go:15) GLOBL   slice+0(SB){[]string},$24(AL*0)

This more accurate type information fixes a bug in the
garbage collector's precise heap collection.

The linker only cares about globals right now, but having the
local information should make things a little nicer for Carl
in the future.

Fixes #4907.

R=ken2
CC=golang-dev
https://golang.org/cl/7395056
2013-02-25 12:13:47 -05:00
Robert Griesemer
a411b104f0 go/parser: more precise comment
See also CL 7383051 for details.

R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/7378063
2013-02-25 08:29:46 -08:00
Roger Peppe
7edd13355f net/rpc: avoid racy use of closing flag.
It's accessed without mutex protection
in a different goroutine from the one that
sets it.

Also make sure that Client.Call after Client.Close
will reliably return ErrShutdown, and that clients
see ErrShutdown rather than io.EOF when appropriate.

Suggestions welcome for a way to reliably test
the mutex issue.

R=r, iant
CC=golang-dev
https://golang.org/cl/7338045
2013-02-25 16:22:00 +00:00
Mikio Hara
cd81db8299 net: make use of testing.B.Skip and reflect.DeepEqual in test
This CL addresses the comments on CL 7368046 that I've overlooked.

Update #4866.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7369052
2013-02-25 23:05:40 +09:00
Rémy Oudompheng
670f6b602d go/types: unresolved literal keys must be looked up in universe.
Fixes #4888.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/7383051
2013-02-24 21:57:16 -08:00
Volker Dobler
d97b975d5c cmd/godoc: show examples in text mode
Added the command line flag -ex to godoc to print examples in
text output.

Samples from the generated output:

$ godoc -ex strings Index
...
func Index(s, sep string) int
    Index returns the index of the first instance of sep in s, or -1 if sep
    is not present in s.

    Example:
        fmt.Println(strings.Index("chicken", "ken"))
        fmt.Println(strings.Index("chicken", "dmr"))
        // Output:
        // 4
        // -1
...

$ godoc -ex container/heap
...
package heap
    import "container/heap"

    Package heap provides heap operations for any type that implements
    heap.Interface. A heap is a tree with the property that each node is the
    minimum-valued node in its subtree.

    Example:
        // This example demonstrates an integer heap built using the heap interface.
        package heap_test

        import (
            "container/heap"
            "fmt"
        ...

    Example:
        // This example demonstrates a priority queue built using the heap interface.
        package heap_test

        import (
            "container/heap"
            "fmt"
        )
...

Fixes #3587.

R=golang-dev, minux.ma, adg, rsc, gri
CC=golang-dev
https://golang.org/cl/7356043
2013-02-25 10:37:17 +11:00
Rob Pike
1174a18c3d cmd/vet: fix up some nits in print.go found by kamil.kisiel@gmail.com
R=golang-dev, kamil.kisiel, bradfitz
CC=golang-dev
https://golang.org/cl/7369049
2013-02-24 13:18:36 -08:00
Rob Pike
83e22f1a47 cmd/vet: eliminate false positives for slices in untagged literal test
Made possible by go/types, as long as the package type-checks OK.

Fixes #4684.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7407045
2013-02-24 13:18:21 -08:00
Rémy Oudompheng
b582ef3855 crypto/rsa: fix infinite loop in GenerateMultiPrimeKey for large nprimes
The heuristics for BitLen of a product of randomly generated primes
are wrong, and the generated candidates never match the required
size for nprimes > 10. This corner case is not expected to be used in
practice.

R=agl
CC=golang-dev
https://golang.org/cl/7397052
2013-02-24 17:19:09 +01:00
Shenghou Ma
5a8b7dc6d0 runtime: remove PROT_EXEC from mmap calls.
Executable heap is gone on Unix!

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/7405045
2013-02-24 22:47:22 +08:00
Shenghou Ma
89ec3a610d cmd/dist: avoid using %ebx on i386.
Or gcc (-fPIC) will complain:
cmd/dist/unix.c: In function ‘cansse2’
cmd/dist/unix.c:774: error: can't find a register in class ‘BREG’ while reloading ‘asm’
cmd/dist/unix.c:774: error: ‘asm’ operand has impossible constraints

This affects bootstrapping on native Darwin/386 where all code is
compiled with -fPIC.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7394047
2013-02-24 22:45:53 +08:00
Mikio Hara
c5f5df4d98 syscall: add network interface announce support on BSD variants
This CL allows to receive network interface arrival and depature
notifications through routing sockets on BSD variants. So far
Darwin doesn't support this feature.

Also does small simplification.

Update #4866.

R=golang-dev, lucio.dere, dave
CC=golang-dev
https://golang.org/cl/7365055
2013-02-24 12:36:44 +09:00
Mikio Hara
6a41b9983c syscall: add if_announce support for openbsd
Update #4866.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7382053
2013-02-24 12:07:20 +09:00
Mikio Hara
d41dede280 syscall: add if_announce support for netbsd
Update #4866.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/7382052
2013-02-24 12:06:24 +09:00
Mikio Hara
b1d51c63d6 syscall: add if_announce support for freebsd
Update #4866.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7398047
2013-02-24 12:04:48 +09:00
Rob Pike
72b6daa3ba cmd/vet: check argument types in printf formats
Fixes #4404.

R=gri, rsc
CC=golang-dev
https://golang.org/cl/7378061
2013-02-23 15:08:36 -08:00
Robin Eklind
39c476cbf8 archive/tar: simplify use of constants in test case.
Replace setsid with c_ISGID since the constant is already defined.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7403048
2013-02-23 11:39:01 -08:00
Shenghou Ma
eec961470f cmd/cgo, cmd/dist, cmd/go: cgo with clang fixes
1. Workaround the smart clang diagnostics with -Qunused-arguments:
clang: error: argument unused during compilation: '-XXX'
2. if "clang -print-libgcc-file-name" returns non-absolute path, don't
provide that on linker command line.
3. Fix dwarf.PtrType.Size() in cmd/cgo as clang doesn't generate
DW_AT_byte_size for pointer types.
4. Workaround warnings for -Wno-unneeded-internal-declaration with
-Wno-unknown-warning-option.
5. Add -Wno-unused-function.
6. enable race detector test on darwin with clang
(at least Apple clang version 1.7 (tags/Apple/clang-77) works).

Requires CL 7354043.

Update #4829
This should fix most parts of the problem, but one glitch still remains.
DWARF generated by newer clang doesn't differentiate these
two function types:
    void *malloc(size_t);
    void *malloc(unsigned long int);
so you might need to do this to make make.bash pass:
sed -i -e 's/C.malloc(C.size_t/C.malloc(C.ulong/' pkg/os/user/lookup_unix.go

R=golang-dev, dave, iant, rsc
CC=golang-dev
https://golang.org/cl/7351044
2013-02-23 20:24:38 +08:00
Dmitriy Vyukov
1e957b6245 runtime: fix windows cpu profiling
R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/7407044
2013-02-23 10:07:41 +04:00
Dmitriy Vyukov
353ce60f6e runtime: implement local work queues (in preparation for new scheduler)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7402047
2013-02-23 08:48:02 +04:00
Dmitriy Vyukov
1d7faf91df runtime: minor changes
to minimize diffs of new scheduler

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7381048
2013-02-23 08:39:31 +04:00
Rob Pike
4434212f15 cmd/vet: use types to test Error methods correctly.
We need go/types to discriminate the Error method from
the error interface and the Error method of the testing package.
Fixes #4753.

R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/7396054
2013-02-22 17:16:31 -08:00
Dave Cheney
d31dd089e6 testing: move Skip into *common
Move Skip and friends into *common so benchmarks can also be skipped.

R=golang-dev, gustav.paul, rsc
CC=golang-dev
https://golang.org/cl/7379046
2013-02-23 11:57:51 +11:00
Mikio Hara
e822860756 syscall: add netlink constants for linux
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7403049
2013-02-23 08:42:04 +09:00
Carl Shapiro
66ba4a85e4 cmd/gc: mark LOCALS argument as a constant to print correctly
Fixes #4875.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7376049
2013-02-22 15:32:54 -08:00
Akshat Kumar
046e035fca all.rc: make sure the Go tools end up in /bin
At least one test (in package runtime) depends
on `go' being in $path. We simply bind GOROOT/bin
before /bin to make sure the latest copy of the
binary is accessible there.

R=rsc, rminnich, ality
CC=golang-dev
https://golang.org/cl/7391047
2013-02-23 00:22:39 +01:00
Akshat Kumar
722ee1f479 os: Plan 9: avoid doing zero-length writes.
Plan 9 I/O preserves message boundaries, while Go
library code is written for UNIX-like operating
systems which do not. Avoid doing zero-length
writes in package os.

R=rsc, rminnich, ality, rminnich, r
CC=golang-dev
https://golang.org/cl/7406046
2013-02-22 23:06:25 +01:00
Russ Cox
56a0bafdb6 runtime: fix arm build
R=ken2
CC=golang-dev
https://golang.org/cl/7399050
2013-02-22 16:38:44 -05:00
Rob Pike
48f79a95d0 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
2013-02-22 13:32:43 -08:00
Russ Cox
3d2dfc5a7b 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
2013-02-22 16:08:56 -05:00
Rob Pike
96f57186ba exp/ssa: silence go vet
R=adonovan
CC=golang-dev
https://golang.org/cl/7386052
2013-02-22 13:02:00 -08:00
Russ Cox
a48ed66447 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
2013-02-22 15:24:29 -05:00
Russ Cox
b1b67a36ac 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
2013-02-22 15:23:57 -05:00
Alan Donovan
18eb3cfdfd 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
2013-02-22 14:30:44 -05:00
Russ Cox
9f647288ef 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
2013-02-22 14:25:50 -05:00
Russ Cox
d57fcbf05c 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
2013-02-22 14:23:21 -05:00
Brad Fitzpatrick
9c7aa5fea9 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
2013-02-22 10:40:23 -08:00
Russ Cox
ec892be1af runtime: preserve DX during racefuncenter
R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/7382049
2013-02-22 13:06:43 -05:00
Alan Donovan
71c37e1c88 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
2013-02-22 12:35:45 -05:00
Russ Cox
0ba5f75513 runtime: avoid closure in parfor test
R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/7395051
2013-02-22 12:11:12 -05:00
Russ Cox
6066fdcf38 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
2013-02-22 10:47:54 -05:00
Alan Donovan
d9001ef012 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
2013-02-22 00:09:21 -05:00
Anthony Martin
ed1ac05673 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
2013-02-21 20:09:31 -08:00
Anthony Martin
edc3126e98 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
2013-02-21 20:06:26 -08:00
Olivier Duperray
2482ef7233 testing: document that example output must use line comments
Fixes #4812.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7396051
2013-02-22 12:23:19 +11:00
Alex Brainman
6ec551887a runtime: windows callback code to match new func value representation
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7393048
2013-02-22 12:21:42 +11:00
Rob Pike
dbd409afb5 bufio: add examples for Scanner
Mention Scanner in docs for ReadLine etc.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7375045
2013-02-21 15:55:40 -08:00
Dave Cheney
6138e368f8 cmd/gc: fix FreeBSD build
R=jsing, mikioh.mikioh, bradfitz
CC=golang-dev
https://golang.org/cl/7390048
2013-02-22 10:28:03 +11:00
Brad Fitzpatrick
0462aad9a4 net/url: fix URL Opaque notes on making client requests
Fixes #4860

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7375047
2013-02-21 14:39:16 -08:00
Robert Dinu
782cbb4f90 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
2013-02-21 14:17:43 -08:00
Russ Cox
1903ad7189 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
2013-02-21 17:01:13 -05:00
Brad Fitzpatrick
4335e69af6 archive/tar: make test pass on setgid dirs
Fixes #4867

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7382045
2013-02-21 14:00:03 -08:00
Carl Shapiro
f466617a62 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
2013-02-21 12:52:26 -08:00
Brad Fitzpatrick
fb21bca012 net/http, net/url: deal with URL.Opaque beginning with //
Update #4860

R=adg, rsc, campoy
CC=golang-dev
https://golang.org/cl/7369045
2013-02-21 12:01:47 -08:00
Rob Pike
6f96a76cd1 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
2013-02-21 10:47:31 -08:00
Brad Fitzpatrick
bca3f5fca0 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
2013-02-21 10:43:00 -08:00
Russ Cox
5833c96b0a runtime: better error from TestGcSys when gc is disabled
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7390047
2013-02-21 13:30:31 -05:00
Dmitriy Vyukov
94fab3cad3 runtime: fix heap corruption
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7397049
2013-02-21 21:59:46 +04:00
Russ Cox
0cdc0b3b78 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
2013-02-21 12:53:25 -05:00
Alan Donovan
aa5aaabb0d 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
2013-02-21 12:48:38 -05:00
Russ Cox
df93283d56 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
2013-02-21 12:19:54 -05:00
Alan Donovan
92cbf82f14 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
2013-02-21 12:14:33 -05:00
Mikio Hara
0ad88a481d 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
2013-02-22 01:19:04 +09:00
Alan Donovan
867121585a 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
2013-02-21 11:11:57 -05:00
Dmitriy Vyukov
a0955a2aa2 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
2013-02-21 16:24:38 +04:00
Brad Fitzpatrick
c53fab969c 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
2013-02-20 22:15:36 -08:00
Robert Griesemer
8473b4487c 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
2013-02-20 17:37:13 -08:00
Brad Fitzpatrick
a2ade45205 net/http: improve test reliability
Fixes #4852

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7374045
2013-02-20 16:39:33 -08:00
Rob Pike
c6f23bb7c1 image/png: use Scanner in reader_test.
R=nigeltao
CC=golang-dev
https://golang.org/cl/7399044
2013-02-20 15:57:18 -08:00
Brad Fitzpatrick
f7a7716317 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
2013-02-20 15:35:27 -08:00
Russ Cox
6c976393ae 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
2013-02-20 17:48:23 -05:00
Olivier Saingre
afde71cfbd 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
2013-02-20 14:41:23 -08:00
Rob Pike
35367cc641 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
2013-02-20 14:34:03 -08:00
Robert Dinu
cbd2c7a283 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
2013-02-20 14:30:15 -08:00
Rob Pike
f574371544 strconv: use Scanner in fp_test
R=rsc
CC=golang-dev
https://golang.org/cl/7385045
2013-02-20 13:38:19 -08:00
Rob Pike
f913830148 regexp: use Scanner in exec_test
R=rsc
CC=golang-dev
https://golang.org/cl/7381046
2013-02-20 13:37:45 -08:00
Robert Griesemer
9dcf3eee41 cmd/godoc: better console error message for example error
(per r's suggestion)

R=r
CC=golang-dev
https://golang.org/cl/7376045
2013-02-20 12:28:12 -08:00
Rob Pike
55ad7b9bfe 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
2013-02-20 12:14:31 -08:00
Robert Griesemer
75e7308be8 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
2013-02-20 11:10:17 -08:00
Dmitriy Vyukov
1e063eea38 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
2013-02-20 21:17:56 +04:00
Dmitriy Vyukov
e25f19a638 runtime: introduce entersyscallblock()
In preparation for the new scheduler.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7386044
2013-02-20 20:21:45 +04:00
Dmitriy Vyukov
e5b0bcebdb 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
2013-02-20 12:34:16 +04:00
Dmitriy Vyukov
06a488fa97 runtime: fix deadlock detector false negative
Fixes #4819.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7322086
2013-02-20 12:15:02 +04:00
Dmitriy Vyukov
a92e11a256 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
2013-02-20 12:13:04 +04:00
Péter Surányi
b4109f801a 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
2013-02-20 16:19:52 +11:00
Brian Dellisanti
e378aef1de 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
2013-02-20 15:38:35 +11:00
Carl Shapiro
7f9c02a10d runtime: add conversion specifier to printf for char values
R=r, golang-dev
CC=golang-dev
https://golang.org/cl/7327053
2013-02-19 18:05:44 -08:00
Akshat Kumar
66b69a1719 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
2013-02-19 17:11:17 -08:00
Mikio Hara
40c2fbf4f2 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
2013-02-20 08:18:04 +09:00
Mikio Hara
e4890e57e1 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
2013-02-20 07:31:44 +09:00
Alan Donovan
a17c46169f 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
2013-02-19 14:42:05 -05:00
Robert Griesemer
5c3fb96be9 exp/README: update README
R=golang-dev, dsymonds, bradfitz
CC=golang-dev
https://golang.org/cl/7323073
2013-02-19 11:21:18 -08:00
Robert Griesemer
3ee87d02b0 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
2013-02-19 11:19:58 -08:00
Kamil Kisiel
0456729977 path/filepath: add examples for SplitList and Rel.
R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/7291043
2013-02-19 10:41:35 -08:00
Russ Cox
6df181a7f0 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
2013-02-19 13:24:03 -05:00
Andrew Wilkins
1fe8fdf708 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
2013-02-19 09:20:56 -08:00
Robin Eklind
7fdaec6c2f 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
2013-02-20 00:58:31 +08:00
Donovan Hide
937f91e1da 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
2013-02-19 10:36:15 -05:00
Russ Cox
cb32ea9c19 runtime: replace bubble sort with heap sort in select
R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/7304106
2013-02-19 10:15:13 -05:00
Russ Cox
a6db2a8517 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
2013-02-19 10:13:53 -05:00
Robin Eklind
d137a2cb56 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
2013-02-19 10:02:01 -05:00
Lucio De Re
7b5de7240e 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
2013-02-19 19:02:18 +08:00
Volker Dobler
6ab113531b 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
2013-02-19 19:12:36 +11:00
Andrew Wilkins
68ff170ebe go/types: Permit dereferencing of named pointer types.
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/7358044
2013-02-18 19:03:10 -08:00
Robert Griesemer
95aaca6708 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
2013-02-18 14:40:47 -08:00
Russ Cox
86d509b463 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
2013-02-18 13:43:12 -05:00
Russ Cox
07e87885ad cmd/6c: fix build
copy+paste error while cleaning up CL 7303099 before submit

R=ken2
CC=golang-dev
https://golang.org/cl/7308104
2013-02-18 13:29:55 -05:00
Russ Cox
139448fe95 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
2013-02-18 13:24:04 -05:00
Dmitriy Vyukov
d62239b5f6 runtime/debug: make TestFreeOSMemory repeatable
Fixes #4835.

R=golang-dev, fullung
CC=golang-dev
https://golang.org/cl/7319050
2013-02-18 15:46:36 +04:00
Volker Dobler
6bbd12f176 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
2013-02-18 11:27:41 +11:00
Joel Sing
556dd0bfbd 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
2013-02-18 03:23:29 +11:00
Rémy Oudompheng
23093f86ee 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
2013-02-17 13:07:17 +01:00
Georg Reinke
f1037f0e86 runtime: fix build on openbsd
R=golang-dev, jsing
CC=golang-dev
https://golang.org/cl/7312104
2013-02-17 02:06:59 +11:00
Mikio Hara
c02d18ab34 net: add IPConn through Conn test
Also refactors mock ICMP stuff.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/7325043
2013-02-16 12:55:39 +09:00
Dave Cheney
21327e1970 runtime: fix unused variable warning
R=rsc, dvyukov
CC=golang-dev
https://golang.org/cl/7312103
2013-02-16 14:32:04 +11:00
Russ Cox
60526ca6d1 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
2013-02-15 17:54:46 -05:00
Russ Cox
c92d3552e5 os: point users of ProcessState.SysUsage to getrusage(2)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7352044
2013-02-15 17:11:13 -05:00
Russ Cox
6d888f1e1b build: clang support
This works with at least one version of clang
that existed at one moment in time.
No guarantees about clangs past or future.

To try:
        CC=clang all.bash

It does not work with the Xcode clang,
because that clang fails at printing a useful answer
to:
        clang -print-libgcc-file-name
The clang that works prints a full path name for
that command, not just "libgcc.a".

Fixes #4713.

R=iant, minux.ma
CC=golang-dev
https://golang.org/cl/7323068
2013-02-15 13:37:43 -08:00
Russ Cox
0c3b17a55a runtime: allow mem profiles with GOGC=off
Fixes #3586.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7304098
2013-02-15 14:48:58 -05:00
Russ Cox
6c1539bb01 runtime: show frame pointer values during throw
Should help if stack overflows start happening again.

Fixes #3582.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7311098
2013-02-15 14:48:47 -05:00
Russ Cox
c8214c78bd runtime: make return from main wait for active panic
Arguably if this happens the program is buggy anyway,
but letting the panic continue looks better than interrupting it.
Otherwise things like this are possible, and confusing:

$ go run x.go
panic: $ echo $?
0
$

Fixes #3934.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7322083
2013-02-15 14:48:35 -05:00
Russ Cox
2d4164596f cmd/go: reject case-insensitive file name, import collisions
To make sure that Go code will work when moved to a
system with a case-insensitive file system, like OS X or Windows,
reject any package built from files with names differing
only in case, and also any package built from imported
dependencies with names differing only in case.

Fixes #4773.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7314104
2013-02-15 14:39:39 -05:00
Russ Cox
318309a51f runtime/pprof: adjust reported line numbers to show call sites
This is the same logic used in the standard tracebacks.
The caller pc is the pc after the call, so except in the
fake "call" caused by a panic, back up the pc enough
that the lookup will use the previous instruction.

Fixes #4150.
Fixes #4151.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7317047
2013-02-15 14:27:16 -05:00
Russ Cox
8a6ff3ab34 runtime: allocate heap metadata at run time
Before, the mheap structure was in the bss,
but it's quite large (today, 256 MB, much of
which is never actually paged in), and it makes
Go binaries run afoul of exec-time bss size
limits on some BSD systems.

Fixes #4447.

R=golang-dev, dave, minux.ma, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/7307122
2013-02-15 14:27:03 -05:00
Dmitriy Vyukov
f87b7f67b2 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
2013-02-15 22:22:13 +04:00
Russ Cox
d3d89ae7d2 runtime: check rt_sigaction return values on linux
(If the mask size is wrong the system call fails.)

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7305097
2013-02-15 13:13:19 -05:00
Russ Cox
2b9787c2f3 encoding/binary: make type error more specific
Right now it says 'invalid type S' for a struct type S.
Instead, say which type inside the struct is the problem.

Fixes #4825.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7301102
2013-02-15 13:12:28 -05:00
Russ Cox
d47cc872b5 exp/cookiejar: fix windows/386 build
More mysteriously broken tests.

TBR=nigeltao
CC=golang-dev
https://golang.org/cl/7342048
2013-02-15 12:43:28 -05:00
Russ Cox
c7f7bbbf03 runtime: fix build on linux
In addition to the compile failure fixed in signal*.c,
preserving the signal mask led to very strange crashes.
Testing shows that looking for SIG_IGN is all that
matters to get along with nohup, so reintroduce
sigset_zero instead of trying to preserve the signal mask.

TBR=iant
CC=golang-dev
https://golang.org/cl/7323067
2013-02-15 12:18:33 -05:00
Russ Cox
f8f2727ab5 exp/cookiejar: fix windows builder
TBR=nigeltao
CC=golang-dev
https://golang.org/cl/7322084
2013-02-15 11:32:31 -05:00
Russ Cox
f3407f445d runtime: fix running under nohup
There are two ways nohup(1) might be implemented:
it might mask away the signal, or it might set the handler
to SIG_IGN, both of which are inherited across fork+exec.
So two fixes:

* Make sure to preserve the inherited signal mask at
minit instead of clearing it.

* If the SIGHUP handler is SIG_IGN, leave it that way.

Fixes #4491.

R=golang-dev, mikioh.mikioh, iant
CC=golang-dev
https://golang.org/cl/7308102
2013-02-15 11:18:55 -05:00
Adam Langley
5b20a18f3b crypto/x509: support IP SANs.
Subject Alternative Names in X.509 certificates may include IP
addresses. This change adds support for marshaling, unmarshaling and
verifying this form of SAN.

It also causes IP addresses to only be checked against IP SANs,
rather than against hostnames as was previously the case. This
reflects RFC 6125.

Fixes #4658.

R=golang-dev, mikioh.mikioh, bradfitz
CC=golang-dev
https://golang.org/cl/7336046
2013-02-15 10:40:17 -05:00
Dmitriy Vyukov
a9824f178d runtime: fix debug output
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7312101
2013-02-15 17:04:02 +04:00
Alex Brainman
d844001601 mime: do not test for .wav on windows
Even builders don't have that mime type

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/7314106
2013-02-15 16:55:51 +11:00
Alex Brainman
f9dbbdb1d3 mime: use .wav instead of .bmp during windows tests
Some systems do not have .bmp mime.

Update #4723.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/7326047
2013-02-15 15:52:54 +11:00
Alex Brainman
d71b3921f7 net: delete TestDialTimeoutHandleLeak
It is too flaky. Tried to make it more reliable,
but that affects other tests (they run too long),
because we do unusual things here, like attempting
to connect to non-existing address and interrupt.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7314097
2013-02-15 15:52:12 +11:00
Alan Donovan
e49f945603 runtime: expand error for signal received on non-Go thread.
We call runtime.findnull dynamically to avoid exceeding the
static nosplit stack limit check.  (Thanks minux!)

Fixes #4048.

R=rsc, minux.ma, ality
CC=golang-dev
https://golang.org/cl/7232066
2013-02-14 23:37:14 -05:00
Cosmos Nicolaou
d0f3475fda go/doc: add support for arbitrary notes
Add support for arbitrary notes of the form // MARKER(userid): comment
in the same vein as BUG(userid): A marker must be two or more upper case [A-Z] letters.

R=gri, rsc, bradfitz, jscrockett01
CC=golang-dev
https://golang.org/cl/7322061
2013-02-14 20:20:32 -08:00
Anthony Martin
f2c3122307 cmd/ld: fix -s flag for ELF executables
This fixes a regression introduced in changeset 98034d036d03
which added support for producing host object files.

R=rsc, minux.ma
CC=dave, golang-dev
https://golang.org/cl/7307107
2013-02-14 18:43:54 -08:00
Rémy Oudompheng
7c5bd322d5 log/syslog: fix channel race in test.
R=golang-dev, minux.ma, iant, bradfitz, dave
CC=golang-dev
https://golang.org/cl/7314057
2013-02-15 11:07:31 +11:00
Carl Shapiro
817a3f39fd src/cmd/gc: fix some typos in the escape analysis comments
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7342044
2013-02-14 15:38:57 -08:00
Robert Griesemer
5b1885c241 go/parser: cleanups following CL 7307085
- use the new AllErrors flag where appropriate
- unless AllErrors is set, eliminate spurious
  errors before they are added to the errors list
  (it turns out that reporting spurious errors always
  leads to too many uninformative errors after all)

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7323065
2013-02-14 13:36:40 -08:00
Daniel Morsing
38244018ce cmd/gc: remove node printing in redeclare errors
I suspect this is some debugging which got through the submission process.

Fixes #4789.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7310079
2013-02-14 21:11:47 +01:00
Dmitriy Vyukov
6a828482fa runtime: add more tests for LockOSThread()
Just test some additional paths through the scheduler.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7331044
2013-02-15 00:02:12 +04:00
Russ Cox
11884db3d7 cmd/go: fix vet
The IgnoredGoFiles are already listed in allgofiles,
so they were being run twice. Worse, the ones in
IgnoredGoFiles are not fully qualified paths, so they
weren't being found when executed outside the
package directory.

Fixes #4764.

R=golang-dev, minux.ma, franciscossouza
CC=golang-dev
https://golang.org/cl/7308049
2013-02-14 15:00:51 -05:00
Russ Cox
30359a55c2 encoding/json: document and test use of unicode.ReplacementChar
Fixes #4783.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7314099
2013-02-14 14:56:01 -05:00
Russ Cox
31072e41f4 cmd/gc: replace x*8 by x<<3 etc
Fixes #4199.

R=ken2
CC=golang-dev
https://golang.org/cl/7322081
2013-02-14 14:54:00 -05:00
Russ Cox
ac1015e7f3 cmd/8g: fix sse2 compare code gen
Fixes #4785.

R=ken2
CC=golang-dev
https://golang.org/cl/7300109
2013-02-14 14:49:04 -05:00
Russ Cox
d340a89d9c encoding/json: roll back Unmarshal optimization + test
The second attempt at the Unmarshal optimization allowed
panics to get out of the json package. Add test for that bug
and remove the optimization.

Let's stop trying to optimize Unmarshal.

Fixes #4784.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7300108
2013-02-14 14:46:15 -05:00
Russ Cox
da6207f7a4 go/types: avoid os.Getwd if not necessary
Getwd can be very expensive.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7312100
2013-02-14 14:46:03 -05:00
Michael Matloob
2cd96806f4 go/parser: stop ParseFile after ten errors.
There wil be a panic if more than ten errors are encountered. ParseFile
will recover and return the ErrorList.

Fixes #3943.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/7307085
2013-02-14 11:26:21 -08:00
Brad Fitzpatrick
248d1446b5 syscall: don't make //sys lines be doc comments
Cleans up godoc and makes it consistent. (some had it, some
didn't)

This still keeps the information there, though, for people
looking at the source directly.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7324056
2013-02-14 11:23:58 -08:00
Russ Cox
357a18a2c6 cmd/go: set $PWD when running commands
This makes os.Getwd inside those commands much faster.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7324055
2013-02-14 14:21:44 -05:00
Russ Cox
89fde30fbd os: cache Getwd result as hint for next time
Avoids the dot-dot-based algorithm on repeated calls
when the directory hasn't changed.

R=golang-dev, iant, bradfitz
CC=golang-dev
https://golang.org/cl/7340043
2013-02-14 14:21:09 -05:00
Brad Fitzpatrick
158a0353f7 net: document OpError
Fixes #4797

R=adg, rsc
CC=golang-dev
https://golang.org/cl/7300099
2013-02-14 09:29:34 -08:00
Volker Dobler
8e7d156237 exp/cookiejar: implement Cookies and provided tests
This CL provides the implementation of Cookies and
the complete test suite. Several tests have been ported
from the Chromium project as a cross check.

R=nigeltao, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/7311073
2013-02-14 19:41:58 +11:00
Dmitriy Vyukov
691455f780 runtime: move stack management related code to stack.c
No code changes.
This is mainly in preparation to scheduler changes,
oldstack/newstack are not related to scheduling.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7311085
2013-02-14 12:37:55 +04:00
Dave Cheney
2803744b86 net/textproto: more efficient header parsing
A co creation with bradfitz

* add fast path for header lines which are not continuations
* pass hint to better size initial mime header map

lucky(~/go/src/pkg/net/http) % ~/go/misc/benchcmp {golden,new}.txt
benchmark                          old ns/op    new ns/op    delta
BenchmarkReadRequestChrome             10073         8348  -17.12%
BenchmarkReadRequestCurl                4368         4350   -0.41%
BenchmarkReadRequestApachebench         4412         4397   -0.34%
BenchmarkReadRequestSiege               6431         5924   -7.88%
BenchmarkReadRequestWrk                 2820         3146  +11.56%

benchmark                           old MB/s     new MB/s  speedup
BenchmarkReadRequestChrome             60.66        73.18    1.21x
BenchmarkReadRequestCurl               17.85        17.93    1.00x
BenchmarkReadRequestApachebench        18.58        18.65    1.00x
BenchmarkReadRequestSiege              23.48        25.49    1.09x
BenchmarkReadRequestWrk                14.18        12.71    0.90x

benchmark                         old allocs   new allocs    delta
BenchmarkReadRequestChrome                32           26  -18.75%
BenchmarkReadRequestCurl                  15           15    0.00%
BenchmarkReadRequestApachebench           16           15   -6.25%
BenchmarkReadRequestSiege                 22           19  -13.64%
BenchmarkReadRequestWrk                   11           11    0.00%

benchmark                          old bytes    new bytes    delta
BenchmarkReadRequestChrome              3148         2216  -29.61%
BenchmarkReadRequestCurl                 905         1413   56.13%
BenchmarkReadRequestApachebench          956         1413   47.80%
BenchmarkReadRequestSiege               1397         1522    8.95%
BenchmarkReadRequestWrk                  757         1369   80.85%

R=bradfitz
CC=golang-dev
https://golang.org/cl/7300098
2013-02-14 19:35:38 +11:00
Robin Eklind
44d38ae3c0 archive/tar: add Header.FileInfo method. Add more cases to FileInfoHeader.
FileInfoHeader can now handle fifo, setuid, setgid and sticky bits.

Fixes #4695.

R=golang-dev, donovanhide, r.eklind.87, minux.ma, adg
CC=golang-dev
https://golang.org/cl/7305072
2013-02-14 17:32:48 +11:00
David Symonds
78cee8b3bb sort: use fewer comparisons when choosing pivot.
This is based on rsc's code posted to issue 2585.

Benchmark results are greatly improved:
        benchmark                old ns/op    new ns/op    delta
        BenchmarkSortString1K       564397       445897  -21.00%
        BenchmarkSortInt1K          270889       221249  -18.32%
        BenchmarkSortInt64K       26850765     21351967  -20.48%

Eyeballing a sampling of the raw number of comparisons shows a drop
on the order of 20-30% almost everywhere. The test input data that
doesn't match that are some of sawtooth/rand/plateau distributions,
where there is no change in the number of comparisons; that is,
there are no situations where this makes *more* comparisons.

Fixes #2585.

R=iant, rsc
CC=golang-dev
https://golang.org/cl/7306098
2013-02-14 15:04:22 +11:00
Russ Cox
7f284f85f9 cmd/vet: drop column information from error
The column information can be misleading.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/7300100
2013-02-13 22:34:37 -05:00
Russ Cox
e5dae3baaa runtime: tweak addfinroots to preserve original pointer
Use local variable so that stack trace will show value of v.

Fixes #4790.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7300106
2013-02-13 22:31:45 -05:00
Brad Fitzpatrick
0c8ed71079 database/sql: fix doc references to old package name
It used to be package "db" but was long ago renamed
to be "sql".

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7322075
2013-02-13 18:47:25 -08:00
Brad Fitzpatrick
cd566958e9 net/http: test that we preserve Go 1.0 Request.Write Host behavior
Fixes #4792

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7314093
2013-02-13 18:33:15 -08:00
Russ Cox
594360cb1b cmd/8c: disable use of prefetch with GO386=387
Fixes #4798.

R=ken2
CC=golang-dev
https://golang.org/cl/7323061
2013-02-13 21:13:07 -05:00
Julien Schmidt
2968e239b0 database/sql: Add an optional Queryer-Interface (like Execer)
Completly the same like the Execer-Interface, just for Queries.
This allows Drivers to execute Queries without preparing them first

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7085056
2013-02-13 15:25:39 -08:00
Dave Cheney
8c30b3f038 net: remove noisy test for issue 3590
The test for issue 3590 causes an error to be printed to stderr when run (although the error is obscured during go test std). This is confusing for people who get breakage in the net package as the error is harmless and most likely unrelated to their build breakage.

Given the way the test works, by reaching into the guts of the netFD, I can't see a way to silence the error without adding a bunch of code to support the test, therefore I am suggesting the test be removed before Go 1.1 ships.

R=alex.brainman, mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/7307110
2013-02-14 10:11:16 +11:00
Mikio Hara
ee9d148ce1 net: add test for Dial and Listen arguments
R=dave, bradfitz
CC=golang-dev
https://golang.org/cl/7305081
2013-02-14 07:02:32 +09:00
Brad Fitzpatrick
d6331b447f io: document and test new CopyN return behavior
Changed accidentally in 28966b7b2f0c (CopyN using Copy).
Updating docs to be consistent with 29bf5ff5064e (ReadFull & ReadAtLeast)

R=rsc
CC=golang-dev
https://golang.org/cl/7314069
2013-02-13 13:52:00 -08:00
Lucio De Re
a3855013a2 cmd/5l: fix print format
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7304065
2013-02-13 16:47:33 -05:00
Brad Fitzpatrick
8f2430a533 database/sql: add currently-disabled broken test
Update #3865

R=golang-dev, alex.brainman, nightlyone
CC=golang-dev
https://golang.org/cl/7324051
2013-02-13 12:00:03 -08:00
Robert Griesemer
f6fe3271f7 go/types: adjust gcimporter to actual gc export data
Unexported field and method names that appear in the
export data (as part of some exported type) are fully
qualified with a package id (path). In some cases, a
package with that id was never exported for any other
use (i.e. only the path is of interest).

We must not create a "real" package in those cases
because we don't have a package name. Entering an
unnamed package into the map of imported packages
makes that package accessible for other imports.
Such a subsequent import may find the unnamed
package in the map, and reuse it. That reused and
imported package is then entered into the importing
file scope, still w/o a name. References to that
package cannot resolved after that. Was bug.

R=adonovan
CC=golang-dev
https://golang.org/cl/7307112
2013-02-13 10:21:24 -08:00
Dmitriy Vyukov
4a524311f4 runtime: instrument slicebytetostring for race detection
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7322068
2013-02-13 18:29:59 +04:00
Christian Himpel
96082a6953 archive/tar: append a slash when deriving header info from a directory
This behavior is identical to GNU tar 1.26.

R=dsymonds, dave
CC=golang-dev
https://golang.org/cl/7307101
2013-02-13 19:23:28 +11:00
Alex Brainman
ea1f7b8380 net: change server_test.go so we could see failure messages
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7323051
2013-02-13 16:17:47 +11:00
Alan Donovan
928fe51661 exp/ssa: add Instruction.Operands and Value.Referrers methods.
Operands returns the SSA values used by an instruction.
Referrers returns the SSA instructions that use a value, for
some values.  These will be used for SSA renaming, to follow.

R=iant, gri
CC=golang-dev
https://golang.org/cl/7312090
2013-02-13 00:15:07 -05:00
Robert Griesemer
27970af5c9 go/types: print, println accept 0 or more arguments
R=adonovan
CC=golang-dev
https://golang.org/cl/7304089
2013-02-12 19:40:20 -08:00
Alex Brainman
17377ab651 os: do not use hosts file for windows tests
Not everyone has the file (http://golang.org/issue/4723#c4).

Update #4723.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7311091
2013-02-13 13:19:06 +11:00
Alan Donovan
be5deb93fb exp/ssa: omit Function's package name when printing intra-package references.
R=iant
CC=golang-dev
https://golang.org/cl/7307105
2013-02-12 16:13:14 -05:00
Shenghou Ma
83da2014a8 encoding/xml: fix htmlAutoClose and its generating script
Thanks Mitică for reporting this.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7308081
2013-02-13 02:27:42 +08:00
Shenghou Ma
2fdd60b9b6 go/build, runtime/cgo: cgo support for NetBSD/ARM
R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/7229082
2013-02-13 01:06:52 +08:00
Shenghou Ma
4d8b1feb79 sync/atomic: support NetBSD/ARM (ARM11 or above)
R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/7287044
2013-02-13 01:04:13 +08:00
Shenghou Ma
8311697792 syscall: NetBSD/ARM support
R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/7288050
2013-02-13 01:03:25 +08:00
Shenghou Ma
37aba1aa77 runtime: NetBSD/ARM support
R=rsc, dave
CC=golang-dev
https://golang.org/cl/7289044
2013-02-13 01:00:04 +08:00
Marcel van Lohuizen
f38da96755 exp/locale/collate: moved low-level collation functionality
into separate package.  This allows this code to be shared
with the search package without the need for these two to use
the same tables.
Adjusted various files accordingly.

R=rsc
CC=golang-dev
https://golang.org/cl/7213044
2013-02-12 15:59:55 +01:00
Robert Griesemer
ae8da3a28c go/types: len(((*T)(nil)).X) is const if X is an array
Fixes #4744.

R=adonovan
CC=golang-dev
https://golang.org/cl/7305080
2013-02-11 22:39:55 -08:00
Alan Donovan
d8e3b16f8b exp/ssa: special-case 'range' loops based on type of range expression.
The lowering of ast.RangeStmt now has three distinct cases:

1) rangeIter for maps and strings; approximately:
    it = range x
    for {
      k, v, ok = next it
      if !ok { break }
      ...
    }
   The Range instruction and the interpreter's "iter"
   datatype are now restricted to these types.

2) rangeChan for channels; approximately:
    for {
      k, ok = <-x
      if !ok { break }
      ...
    }

3) rangeIndexed for slices, arrays, and *array; approximately:
    for k, l = 0, len(x); k < l; k++ {
      v = x[k]
      ...
    }

In all cases we now evaluate the side effects of the range expression
exactly once, per comments on http://code.google.com/p/go/issues/detail?id=4644.

However the exact spec wording is still being discussed in
https://golang.org/cl/7307083/.  Further (small)
changes may be required once the dust settles.

R=iant
CC=golang-dev
https://golang.org/cl/7303074
2013-02-11 22:12:56 -05:00
Rob Pike
d282532901 vet: improve flag handling
Simplify the internal logic for flags controlling what to vet,
by introducing a map of flags that gathers them all together.
This change should simplify the process of adding further flags.

Add a test for untagged struct literals.
Delete a redundant test that was also in the wrong file.
Clean up some ERROR patterns that weren't working.

"make test" passes again.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7305075
2013-02-11 13:33:11 -08:00
Russ Cox
02e05817ad sync: add caution about where to call (*WaitGroup).Add
Fixes #4762.

R=daniel.morsing, adg
CC=golang-dev
https://golang.org/cl/7308045
2013-02-11 08:05:46 -05:00
Andrew Gerrand
66c96f1abc container/list: add package example
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7306078
2013-02-11 17:59:52 +11:00
Nigel Tao
37d92d251b exp/html, exp/html/atom: delete, as they're moving to the go.net
sub-repo.

The matching change is at https://golang.org/cl/7310063

The rationale was discussed at
https://groups.google.com/d/topic/golang-nuts/Qq5hTQyPuLg/discussion

R=adg, dave
CC=golang-dev
https://golang.org/cl/7317043
2013-02-11 11:56:49 +11:00
Volker Dobler
de69401b75 exp/cookiejar: implementation of SetCookies
This CL provides the rest of the SetCookies code as well as
some test infrastructure which will be used to test also
the Cookies method. This test infrastructure is optimized
for readability and tries to make it easy to review table
driven test cases.

Tests for all the different corner cases of SetCookies
will be provided in a separate CL.

R=nigeltao, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/7306054
2013-02-11 11:47:31 +11:00
Shane Hansen
1068279904 archive/tar: read/write extended pax/gnu tar archives
Support reading pax archives and applying extended attributes
like long names, subsecond mtime resolutions, etc. Default to
writing pax archives for long file and link names.
Support reading gnu archives using the ././@LongLink extended
header for file name and link target.

Fixes #3300

R=dsymonds, dave, rogpeppe, remyoudompheng, chressie, rsc
CC=golang-dev
https://golang.org/cl/6700047
2013-02-11 11:36:29 +11:00
Lucio De Re
fece09e58a cmd/8l/asm.c: Unused function arguments, suppress warnings.
R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/7304069
2013-02-11 10:15:56 +11:00
Dave Cheney
6ce3e99af0 net/http: more request benchmarks
Add benchmarks for common http benchmarking tools. The intent is to catch optimisations which favor synthetic benchmarks that do not show improvements for real clients like Chrome.

BenchmarkReadRequestChrome        200000             10133 ns/op          60.29 MB/s        3148 B/op         32 allocs/op
BenchmarkReadRequestCurl          500000              4314 ns/op          18.08 MB/s         905 B/op         15 allocs/op
BenchmarkReadRequestApachebench   500000              4363 ns/op          18.79 MB/s         956 B/op         16 allocs/op
BenchmarkReadRequestSiege         500000              6408 ns/op          24.19 MB/s        1397 B/op         22 allocs/op
BenchmarkReadRequestWrk          1000000              2838 ns/op          14.09 MB/s         757 B/op         11 allocs/op

R=golang-dev, bradfitz
CC=golang-dev, haimuiba
https://golang.org/cl/7300075
2013-02-10 08:18:09 +11:00
Adam Langley
e0791a3adf crypto/x509: disable SCG test with system validation.
On Windows, CryptoAPI is finding an alternative validation path. Since
this is a little non-deterministic, this change disables that test
when using system validation.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7313068
2013-02-09 13:51:39 -05:00
Russ Cox
6600092527 testing: be explicit about use of b.N
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7314071
2013-02-09 13:43:15 -05:00
Adam Langley
e1c309e792 crypto/x509: allow MS/NS SCG key usage as ServerAuth.
By default, crypto/x509 assumes that users wish to validate
certificates for ServerAuth. However, due to historical reasons,
COMODO's intermediates don't specify ServerAuth as an allowed key
usage.

Rather NSS and CryptoAPI both allow these SGC OIDs to be equivalent to
ServerAuth.

R=rsc
CC=golang-dev
https://golang.org/cl/7312070
2013-02-09 13:20:25 -05:00
Shenghou Ma
691e5e3b01 bytes: annotate assembly functions with //go:noescape
R=golang-dev, agl, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/7299064
2013-02-10 00:08:30 +08:00
Shenghou Ma
705b4544d6 log/syslog: remove socket files after tests
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7305065
2013-02-09 08:19:09 +08:00
Mikio Hara
a0430dae04 net: fix unixgram
The socket for AF_UNIX domain with SOCK_DGARM type isn't
allowed to work with syscall listen.

R=rsc
CC=golang-dev
https://golang.org/cl/7310068
2013-02-09 08:18:32 +09:00
Robert Daniel Kortschak
482f3e8481 cmd/go: indicate that flags unrecognized by 'go test' must follow package specification
R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/7300063
2013-02-08 16:00:59 -05:00
Jan Ziak
1e01fba2fc runtime: precise garbage collection of hashmaps
R=golang-dev, rsc
CC=dave, dvyukov, golang-dev, minux.ma, remyoudompheng
https://golang.org/cl/7252047
2013-02-08 16:00:33 -05:00
Dave Cheney
cccc96b8e9 net/http: add BenchmarkReadRequest
Add benchmark for request parsing. Fixture data is taken from https://github.com/felixge/node-http-perf

% go version
go version devel +28966b7b2f0c Thu Feb 07 20:26:12 2013 -0800 linux/amd64

% go test -run=nil -bench=ReadRequest -benchtime=10s
PASS
BenchmarkReadRequest     2000000   9900 ns/op   61.71 MB/s   3148 B/op   32 allocs/op
ok      net/http        12.180s

R=golang-dev, bradfitz, minux.ma, haimuiba
CC=golang-dev
https://golang.org/cl/7313048
2013-02-09 07:04:07 +11:00
Péter Surányi
d2252d9b07 syscall: check for invalid characters in Setenv on Unix
On POSIX, '=' in key is explicitly invalid, and '\x00' in key/value is implicitly invalid.

R=golang-dev, iant, bradfitz
CC=golang-dev
https://golang.org/cl/7311061
2013-02-08 10:45:46 -08:00
Kamil Kisiel
f26fc0c017 net/http/httptest: add examples
R=golang-dev, adg, bradfitz
CC=golang-dev
https://golang.org/cl/7314046
2013-02-08 09:20:05 -08:00
Alan Donovan
5fa6721a31 exp/ssa/interp: fix MS Windows breakage.
syscall.{Kill,Write} are not portable to MS Windows, so we
disable them for now.

R=iant, rsc
CC=golang-dev
https://golang.org/cl/7312066
2013-02-08 11:58:24 -05:00
Alan Donovan
c8f2449ea7 exp/ssa: (#5 of 5): the SSA interpreter and 'ssadump' tool.
R=gri, iant
CC=golang-dev
https://golang.org/cl/7226065
2013-02-08 10:43:53 -05:00
Dmitriy Vyukov
0a9f1ab8bb runtime/race: deflake tests
With the new scheduler races in the tests are reported during execution of other tests.
The change joins goroutines started during the tests.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7310066
2013-02-08 19:24:50 +04:00
Dmitriy Vyukov
45636db01b runtime: fix integer overflow
The problem happens when end=0, then end-1 is very big number.
Observed with the new scheduler.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7307073
2013-02-08 19:05:19 +04:00
Mikio Hara
6dfd386005 net: simplify Dial, Listen, ListenPacket and those helpers
R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/7300065
2013-02-08 21:53:10 +09:00
Mikio Hara
dc6e51cfd2 net: delete duplicate listenerSockaddr
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7299067
2013-02-08 17:02:08 +09:00
Rémy Oudompheng
f42fa807a6 cmd/5g: add missing splitclean.
See issue 887 for the 8g analogue.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7306069
2013-02-08 08:19:47 +01:00
Shenghou Ma
6c54bf9916 runtime: fix build for Linux/ARM
R=dave, rsc
CC=golang-dev
https://golang.org/cl/7299055
2013-02-08 13:24:38 +08:00
Jeremy Schlatter
c94eddd1af io: Simplify CopyN implementation by delegating to Copy.
R=golang-dev, dave, minux.ma, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/7312055
2013-02-07 20:26:12 -08:00
Russ Cox
18441e8ade net: do not use RLock around Accept
It might be non-blocking, but it also might be blocking.
Cannot take the chance, as Accept might block indefinitely
and make it impossible to acquire ForkLock exclusively
(during fork+exec).

Fixes #4737.

R=golang-dev, dave, iant, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7309050
2013-02-07 22:45:12 -05:00
David Symonds
3c1dfb2b9a cmd/godoc: fix format strings.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7309061
2013-02-08 12:00:35 +11:00
Brad Fitzpatrick
30a9957aac bytes: minor optimization to lastIndexFunc
Before and after:
BenchmarkTrimSpace  20000000   81.3 ns/op
BenchmarkTrimSpace  50000000   58.0 ns/op

(most whitespace trimming is ASCII whitespace)

Same optimization appeared a handful of other places
in this file, but not here.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7305063
2013-02-07 16:00:06 -08:00
Russ Cox
7594440ef1 cmd/8g: add a few missing splitclean
Fixes #887.

R=ken2
CC=golang-dev
https://golang.org/cl/7303061
2013-02-07 17:55:25 -05:00
Ian Lance Taylor
2b44c33b4a crypto/md5: fix for big-endian processors
R=golang-dev, minux.ma, agl
CC=golang-dev
https://golang.org/cl/7305059
2013-02-07 13:31:53 -08:00
Ian Lance Taylor
514f10b9ab net: skip TestMulticastListener on Solaris
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7308060
2013-02-07 09:58:42 -08:00
Péter Surányi
fe7dbea00e os/exec: LookPath on Unix shouldn't look in cwd when PATH is empty
R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/7305053
2013-02-07 06:41:35 -08:00
Shenghou Ma
80e1cf73eb crypto/rc4: naïve ARM assembly implementation
On 800MHz Cortex-A8:
benchmark           old ns/op    new ns/op    delta
BenchmarkRC4_128         9395         2838  -69.79%
BenchmarkRC4_1K         74497        22120  -70.31%
BenchmarkRC4_8K        587243       171435  -70.81%

benchmark            old MB/s     new MB/s  speedup
BenchmarkRC4_128        13.62        45.09    3.31x
BenchmarkRC4_1K         13.75        46.29    3.37x
BenchmarkRC4_8K         13.79        47.22    3.42x

Result for "OpenSSL 1.0.1c 10 May 2012" from Debian/armhf sid:
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
rc4              39553.81k    46522.39k    49336.11k    50085.63k    50258.06k

R=golang-dev, agl, dave
CC=golang-dev
https://golang.org/cl/7310051
2013-02-07 18:54:21 +08:00
Ian Lance Taylor
0592c44956 net: permit pollster DelFD to return whether to call Wakeup
This is necessary for systems that use select as the pollster,
such as Solaris (supported by gccgo).  It corresponds to the
bool returned by AddFD.  In general it's not clearly defined
what happens when a descriptor used in a select is closed, and
different systems behave differently.  Waking up the select
will cause the right thing to happen: the closed descriptor
will be dropped from the next iteration.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7303056
2013-02-06 17:18:53 -08:00
Gaal Yahas
c2fb6e2c0b sync: improve WaitGroup example by putting the call to Done in a
deferred block. This makes hangs in the waiting code less likely
if a goroutine exits abnormally.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7306052
2013-02-07 00:39:52 +08:00
Albert Strasheim
309d88e28c syscall, net: Fix unix socket autobind on Linux.
R=rsc, iant, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7300047
2013-02-06 06:45:57 -08:00
Volker Dobler
8c6489bc27 exp/cookiejar: infrastructure for upcoming implementation
This CL is the first of a handful of CLs which will provide
the implementation of cookiejar. It contains several helper
functions and the skeleton of Cookies and SetCookies.

Proper host name handling requires the ToASCII transformation
from package idna which currently lives in the go.net
subrepo. This CL thus contains just a TODO for this issue.

R=nigeltao, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/7287046
2013-02-06 22:37:34 +11:00
Dmitriy Vyukov
0a40cd2661 runtime/race: switch to explicit race context instead of goroutine id's
Removes limit on maximum number of goroutines ever existed.
code.google.com/p/goexecutor tests now pass successfully.
Also slightly improves performance.
Before: $ time ./flate.test -test.short
real	0m9.314s
After:  $ time ./flate.test -test.short
real	0m8.958s
Fixes #4286.
The runtime is built from llvm rev 174312.

R=rsc
CC=golang-dev
https://golang.org/cl/7218044
2013-02-06 11:40:54 +04:00
Jeff R. Allen
33995fe59e log/syslog: retry once if write fails
Implements deferred connections + single-attempt automatic
retry. Based on CL 5078042 from kuroneko.

Fixes #2264.

R=mikioh.mikioh, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/6782140
2013-02-05 09:54:01 -08:00
Shenghou Ma
7de3d71797 runtime: save LR to stack when panicking to handle leaf function traceback
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7289047
2013-02-06 01:18:37 +08:00
Shenghou Ma
4360ef8de2 lib9: fix build for windows
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7311044
2013-02-06 00:33:25 +08:00
Ian Lance Taylor
da35d42521 exp/inotify: close event channel before file descriptor
Closing the inotify file descriptor can take over a second
when running on Ubuntu Precise in an NFS directory, leading to
the test error in issue 3132.  Closing the event channel first
lets a client that does not care about the error channel move
on.

Fixes #3132.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/7300045
2013-02-05 06:11:10 -08:00
Shenghou Ma
255fb521da cmd/dist: add -Wstrict-prototypes to CFLAGS and fix all the compiler errors
Plan 9 compilers insist this but as we don't have Plan 9
builders, we'd better let gcc check the prototypes.

Inspired by CL 7289050.

R=golang-dev, seed, dave, rsc, lucio.dere
CC=akumar, golang-dev
https://golang.org/cl/7288056
2013-02-05 21:43:04 +08:00
Caleb Spare
dff017ea99 container/heap: fix comment typo in example test
This updates a bad reference to a method name in the example priority queue test.

The error was introduced in the example refactoring in rev. 2ea8f07b2ffe.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7279045
2013-02-05 07:06:00 -05:00
Russ Cox
fd178d6a7e cmd/gc: add way to specify 'noescape' for extern funcs
A new comment directive //go:noescape instructs the compiler
that the following external (no body) func declaration should be
treated as if none of its arguments escape to the heap.

Fixes #4099.

R=golang-dev, dave, minux.ma, daniel.morsing, remyoudompheng, adg, agl, iant
CC=golang-dev
https://golang.org/cl/7289048
2013-02-05 07:00:38 -05:00
Dmitriy Vyukov
6b1b613d6a runtime/race: do not include pthread.h
Fixes #4721.

R=alex.brainman, minux.ma
CC=golang-dev
https://golang.org/cl/7275048
2013-02-05 13:08:07 +04:00
David Symonds
e7fe1944ac archive/tar: small simplification using FileMode.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7305043
2013-02-05 15:39:55 +11:00
Brad Fitzpatrick
d1e16d06b4 net/http: fix Server blocking after a Handler's Write fails
If a Handle's Write to a ResponseWriter fails (e.g. via a
net.Conn WriteDeadline via WriteTimeout on the Server), the
Server was blocking forever waiting for reads on that
net.Conn, even after a Write failed.

Instead, once we see a Write fail, close the connection,
since it's then dead to us anyway.

Fixes #4741

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7301043
2013-02-04 20:26:25 -08:00
Russ Cox
a60ffed9e7 path/filepath: document that Walk does not follow symlinks
Fixes #4759.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7304043
2013-02-04 22:59:30 -05:00
Russ Cox
572d984eaa cmd/gc: fix escape analysis
If the analysis reached a node twice, then the analysis was cut off.
However, if the second arrival is at a lower depth (closer to escaping)
then it is important to repeat the traversal.

The repeating must be cut off at some point to avoid the occasional
infinite recursion. This CL cuts it off as soon as possible while still
passing all tests.

Fixes #4751.

R=ken2
CC=golang-dev, lvd
https://golang.org/cl/7303043
2013-02-04 22:48:31 -05:00
Anthony Martin
c56bb1d238 syscall: fix marshaling of stat messages on Plan 9
The order of the Qid fields was reversed. Mea culpa.

R=seed
CC=golang-dev
https://golang.org/cl/7231062
2013-02-04 19:47:23 -08:00
Brad Fitzpatrick
92e4645f31 net/http: add Next Protocol Negotation upgrade support to the Server
This provides the mechanism to connect SPDY support to the http
package, without pulling SPDY into the standard library.

R=rsc, agl, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7287045
2013-02-04 13:55:38 -08:00
Mikio Hara
5ae6a23731 syscall: regenerate ztype files for linux
This CL adds TCPInfo struct to linux/386,arm.
It's already added to linux/amd64.

Note that not sure the reason but cgo godefs w/ latest gcc
translates a flexible array member in structures correctly,
handles it as a non-incomplete, non-opaque type, on Go 1.
This CL reverts such changes by hand for the Go 1 contract.

R=minux.ma, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/7197046
2013-02-05 06:53:58 +09:00
Brad Fitzpatrick
022504b3ab net/http: fix when server deadlines get extended
Deadlines should be extended at the beginning of
a request, not at the beginning of a connection.

Fixes #4676

R=golang-dev, fullung, patrick.allen.higgins, adg
CC=golang-dev
https://golang.org/cl/7220076
2013-02-04 13:52:45 -08:00
Shenghou Ma
49fe632c7d cmd/go: update doc.go
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7279047
2013-02-05 05:45:35 +08:00
Alan Donovan
c06a5335ba exp/ssa: (#4 of 5): the SSA builder.
R=iant, gri, iant, rogpeppe
CC=golang-dev
https://golang.org/cl/7196053
2013-02-04 12:22:35 -05:00
Russ Cox
399dcc75a8 cmd/gc: fix &^ code generation bug
Was not re-walking the new AND node, so that its ullman
count was wrong, so that the code generator attempted to
store values in registers across the call.

Fixes #4752.

R=ken2
CC=golang-dev
https://golang.org/cl/7288054
2013-02-04 00:21:44 -05:00
Alex Brainman
94064548c6 net: use windows sysSocket everywhere
R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/7273046
2013-02-04 16:03:41 +11:00
Russ Cox
472354f81e runtime/debug: add controls for garbage collector
Fixes #4090.

R=golang-dev, iant, bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/7229070
2013-02-04 00:00:55 -05:00
Russ Cox
6b4cf2b367 time: fix error message from Parse
Was incorrectly discarding the offending text in some cases.

Fixes #4493.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7277050
2013-02-04 00:00:36 -05:00