gofmt: -s flag simplifies "for _ = range x"

LGTM=adonovan, rsc
R=rsc, adonovan
CC=golang-codereviews
https://codereview.appspot.com/117800043
strings: remove byteBitmap

Previously we had a bitmap to check whether or not a byte
appears in a string should be replaced. But we don't actually
need a separate bitmap for that purpose. Removing the bitmap
makes the code simpler.

LGTM=dave, iant, nigeltao
R=golang-codereviews, dave, gobot, nigeltao, iant, bradfitz, rsc
CC=golang-codereviews
https://codereview.appspot.com/110100043
runtime: improve select benchmarks
1. Add select on sync channels benchmark.
2. Make channels in BenchmarkSelectNonblock shared.
With GOMAXPROCS=1 it is the same, but with GOMAXPROCS>1
it becomes a more interesting benchmark.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews
https://codereview.appspot.com/115780043
runtime: make NumGoroutines faster
Resolves TODO for not walking all goroutines in NumGoroutines.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://codereview.appspot.com/107290044
sync: fix typo in benchmark name

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://codereview.appspot.com/118860043
undo CL 101570044 / 2c57aaea79c4

redo stack allocation.  This is mostly the same as
the original CL with a few bug fixes.

1. add racemalloc() for stack allocations
2. fix poolalloc/poolfree to terminate free lists correctly.
3. adjust span ref count correctly.
4. don't use cache for sizes >= StackCacheSize.

Should fix bugs and memory leaks in original changelist.

««« original CL description
undo CL 104200047 / 318b04f28372

Breaks windows and race detector.
TBR=rsc

««« original CL description
runtime: stack allocator, separate from mallocgc

In order to move malloc to Go, we need to have a
separate stack allocator.  If we run out of stack
during malloc, malloc will not be available
to allocate a new stack.

Stacks are the last remaining FlagNoGC objects in the
GC heap.  Once they are out, we can get rid of the
distinction between the allocated/blockboundary bits.
(This will be in a separate change.)

Fixes issue 7468
Fixes issue 7424

LGTM=rsc, dvyukov
R=golang-codereviews, dvyukov, khr, dave, rsc
CC=golang-codereviews
https://codereview.appspot.com/104200047
»»»

TBR=rsc
CC=golang-codereviews
https://codereview.appspot.com/101570044
»»»

LGTM=dvyukov
R=dvyukov, dave, khr, alex.brainman
CC=golang-codereviews
https://codereview.appspot.com/112240044
runtime: add throwgo

Fixes issue 8380.

Also update hashmap.go to use throwgo rather than panic.

LGTM=khr
R=khr, rsc
CC=golang-codereviews
https://codereview.appspot.com/115860045
cmd/cgo: disable inappropriate warnings when the gcc struct is empty

package main
//#cgo CFLAGS: -Wall
//void test() {}
import "C"
func main() {
    C.test()
}

This code will cause gcc issuing warnings about unused variable.

This commit use offset of the second return value of
Packages.structType to detect whether the gcc struct is empty,
and if it's directly invoke the C function instead of writing an
unused code.

LGTM=dave, minux
R=golang-codereviews, iant, minux, dave
CC=golang-codereviews
https://codereview.appspot.com/109640045

Committer: Shenghou Ma <minux@golang.org>
undo CL 109640045 / f97fb06525e5

Breaks build for FreeBSD. Probably clang related?

««« original CL description
cmd/cgo: disable inappropriate warnings when the gcc struct is empty

package main
//#cgo CFLAGS: -Wall
//void test() {}
import "C"
func main() {
    C.test()
}

This code will cause gcc issuing warnings about unused variable.

This commit use offset of the second return value of
Packages.structType to detect whether the gcc struct is empty,
and if it's directly invoke the C function instead of writing an
unused code.

LGTM=dave, minux
R=golang-codereviews, iant, minux, dave
CC=golang-codereviews
https://codereview.appspot.com/109640045

Committer: Shenghou Ma <minux@golang.org>
»»»

TBR=dfc
R=dave
CC=golang-codereviews
https://codereview.appspot.com/114990044
encoding/gob: remove unnecessary receivers
Encoder compilation must be enc-independent,
because the resulting program is reused across
different encoders.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://codereview.appspot.com/115860043
go/printer: simplify test
Pre Go1?

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://codereview.appspot.com/115870043
runtime: fix gctrace=1

updatememstats is called on both the m and g stacks.
Call into flushallmcaches correctly.  flushallmcaches
can only run on the M stack.

This is somewhat temporary.  once ReadMemStats is in
Go we can have all of this code M-only.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://codereview.appspot.com/116880043

Committer: Dmitriy Vyukov <dvyukov@google.com>
A+C: add Xia Bin (individual CLA)

This CLA replaces the one for 'snyh'.
Verified by hand.

LGTM=minux
R=iant, minux
CC=golang-codereviews
https://codereview.appspot.com/112420043
bufio: fix UnreadSlice followed by UnreadRune

Also, fix a write check in writeBuf and make some bounds checks simpler.

LGTM=gri
R=golang-codereviews, adg, gri, r, minux
CC=golang-codereviews
https://codereview.appspot.com/113060043

Committer: Robert Griesemer <gri@golang.org>
go/ast: fix typo in comment

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://codereview.appspot.com/111330043
os: broaden the range of errors understood by IsNotExist on Plan 9

Ken's standalone file server and its derivatives, like cwfs, return
error strings different from fossil when the user opens non-existent
files.

LGTM=aram, 0intro, r
R=0intro, aram, r
CC=golang-codereviews, ken
https://codereview.appspot.com/112420045

Committer: Rob Pike <r@golang.org>
runtime: add Benchmark[Clear|Copy]Fat[16|24]

These benchmarks are important for performance. When compiling the stdlib:

* 77.1% of the calls to sgen (copyfat) are for 16 bytes; another 8.7% are for 24 bytes. (The next most common is 32 bytes, at 5.7%.)
* Over half the calls to clearfat are for 16 or 24 bytes.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews
https://codereview.appspot.com/111350043
runtime: use uint32 arrays in BenchmarkClearFat*

The CopyFat benchmarks were changed in CL 92760044. See CL 111350043 for discussion.

LGTM=khr
R=khr
CC=golang-codereviews
https://codereview.appspot.com/116000043
test: add test for issue8347

Fixes issue 8347.

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://codereview.appspot.com/109600044
codereview: revive the tests.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://codereview.appspot.com/105500043