syscall: fix FD passing on FreeBSD and NetBSD

Fixes issue 3348.

R=devon.odell, minux.ma, bradfitz, mdempsky
CC=golang-dev
https://codereview.appspot.com/7406050
go/types: be more robust in presence of multiple errors

- better documentation of Check
- better handling of (explicit) internal panics
- gotype: don't stop after 1st error

R=adonovan, r
CC=golang-dev
https://codereview.appspot.com/7406052
net/http: fix a bunch of test leaks

And one real leak in TimeoutHandler.

Fixes issue 4821

R=golang-dev, adg
CC=golang-dev
https://codereview.appspot.com/7369056
sort: add an example showing sorting struct by different keys

R=golang-dev, dsymonds
CC=golang-dev
https://codereview.appspot.com/7376058
exp/cookiejar: add a test for canonicalHost errors.

R=dr.volker.dobler
CC=golang-dev
https://codereview.appspot.com/7389048
cmd/ld, runtime: adjust symbol table representation

This CL changes the encoding used for the Go symbol table,
stored in the binary and used at run time. It does not change
any of the semantics or structure: the bits are just packed
a little differently.

The comment at the top of runtime/symtab.c describes the new format.

Compared to the Go 1.0 format, the main changes are:

* Store symbol addresses as full-pointer-sized host-endian values.
  (For 6g, this means addresses are 64-bit little-endian.)

* Store other values (frame sizes and so on) varint-encoded.

The second change more than compensates for the first:
for the godoc binary on OS X/amd64, the new symbol table
is 8% smaller than the old symbol table (1,425,668 down from 1,546,276).

This is a required step for allowing the host linker (gcc) to write
the final Go binary, since it will have to fill in the symbol address slots
(so the slots must be host-endian) and on 64-bit systems it may
choose addresses above 4 GB.

R=golang-dev, iant
CC=golang-dev
https://codereview.appspot.com/7403054
cmd/ld: change GC_CALL to 32-bit relative address

The current code uses 64-bit pc-relative on 64-bit systems,
but in ELF linkers there is no such thing, so we cannot
express this in a .o file. Change to 32-bit.

R=golang-dev, iant
CC=golang-dev
https://codereview.appspot.com/7383055
libmach: fix build (set and not used)

TBR=golang-dev
CC=golang-dev
https://codereview.appspot.com/7401053
syscall: Fix FD passing on OpenBSD

Fixes issue 3349.

R=bradfitz, dave, minux.ma
CC=golang-dev
https://codereview.appspot.com/7383056

Committer: Dave Cheney <dave@cheney.net>
exp/locale/collate: several changes based on comments on CL 7060051
which was submitted earlier.

R=r
CC=golang-dev
https://codereview.appspot.com/7402048
exp/locale/collate: fixed go vet error.

R=r, dave
CC=golang-dev
https://codereview.appspot.com/7403055
exp/ssa: perform all packages' BUILD phases in parallel.

Details:
- move Builder.nTo1Vars into package => thread-safe.
- add BuildSerially builder mode flag to disable concurrency.
- add Builder.BuildAllPackages method.

Benchmark: BuildAllPackages for $GOROOT/test/append.go drops
to 83ms from 190ms (GOMAXPROCS=8).

R=gri
CC=golang-dev
https://codereview.appspot.com/7371051
exp/ssa: make invokation of deferred procedure calls explicit.

The correct semantics of named result parameters and deferred
procedures cannot be implemented with the existing Ret
instruction alone, since the required sequence is:
(1) evaluate return operands and parallel-assign them to
    named result parameters
(2) invoke deferred procedures
(3) load named result parameters to form result tuple.

We introduce a new 'rundefers' instruction that explicitly
invokes the deferred procedure calls, and we generate code
that follows the sequence above.

Most functions do not use deferred procedures but this cannot
be known in a single pass.  So, we add an optimisation to
eliminate redundant 'rundefers'; it is piggybacked on the
existing pass done for "lifting".

Added tests.

R=gri
CC=golang-dev
https://codereview.appspot.com/7411043
runtime: improve precision of GC_REGION

R=rsc
CC=golang-dev
https://codereview.appspot.com/7383054

Committer: Russ Cox <rsc@golang.org>
exp/ssa: resolve botched merge.

While submitting CL 7371051 I accidentally reverted much of CL
7395052.  This change restores it.

R=gri
TBR=gri
CC=golang-dev
https://codereview.appspot.com/7364051
net/http: add Transport.ResponseHeaderTimeout

Update issue 3362

R=golang-dev, adg, rsc
CC=golang-dev
https://codereview.appspot.com/7369055
sort: use proper mass unit in example

The values for the planet masses are given in
earth mass, not solar mass.

R=golang-dev, dave, r
CC=golang-dev
https://codereview.appspot.com/7368054

Committer: Rob Pike <r@golang.org>
cmd/gc: don't emit type instructions for nonexisting locals

If all locals are optimized away, the type instructions would stay in the instruction stream. Call fixautoused to scrub the output.

Fixes issue 4915.

R=rsc
CC=golang-dev
https://codereview.appspot.com/7385055
runtime: more changes in preparation to the new scheduler
add per-P cache of dead G's
add global runnable queue (not used for now)
add list of idle P's (not used for now)

R=golang-dev, rsc
CC=golang-dev
https://codereview.appspot.com/7397061
net: add DialOpt, the extensible Dial w/ options dialer

Add DialOpt. So we have:

func Dial(net, addr string) (Conn, error)
func DialTimeout(net, addr string, timeout time.Duration) (Conn, error)
func DialOpt(addr string, opts ...DialOption) (Conn, error)

DialTimeout (and Dial) are regrettable in retrospect. Maybe
in a future Go we'll be back down to one Dial, with DialOpt
becoming Dial.

DialOpt looks like:

c, err := net.DialOpt("google.com:80")  // tcp is default
c, err := net.DialOpt("google.com:80", net.Timeout(30 * time.Second))
c, err := net.DialOpt("google.com:80", net.TCPFastOpen())
c, err := net.DialOpt("google.com:80", net.LocalAddr(..))
c, err := net.DialOpt("google.com:53", net.Network("udp6"))

And then: (clustered in godoc)

type DialOption interface { /* private only */ }
  func Deadline(time.Time) DialOption
  func LocalAddr(Addr) DialOption
  func Network(string) DialOption
  func TCPFastOpen() DialOption
  func Timeout(time.Duration) DialOption

I'm pretty confident we could add Happy Eyeballs to this too.

Fixes issue 3097
Update issue 3610
Update issue 4842

R=golang-dev, r, dave, minux.ma, rsc
CC=golang-dev
https://codereview.appspot.com/7365049