Commits

Aram Hăvărneanu  committed b3f24ca Merge

merge upstream

  • Participants
  • Parent commits 149a92e, c33b9da

Comments (0)

Files changed (32)

File lib/codereview/codereview.py

 	upload_options.message = None
 	upload_options.issue = None
 	upload_options.download_base = False
-	upload_options.revision = None
 	upload_options.send_mail = False
 	upload_options.vcs = None
 	upload_options.server = server
 		cwd = os.path.normpath(os.getcwd())
 		assert cwd.startswith(self.repo_dir)
 		self.subdir = cwd[len(self.repo_dir):].lstrip(r"\/")
-		if self.options.revision:
-			self.base_rev = self.options.revision
+		mqparent, err = RunShellWithReturnCode(['hg', 'log', '--rev', 'qparent', '--template={node}'])
+		if not err and mqparent != "":
+			self.base_rev = mqparent
 		else:
-			mqparent, err = RunShellWithReturnCode(['hg', 'log', '--rev', 'qparent', '--template={node}'])
-			if not err and mqparent != "":
-				self.base_rev = mqparent
-			else:
-				out = RunShell(["hg", "parents", "-q"], silent_ok=True).strip()
-				if not out:
-					# No revisions; use 0 to mean a repository with nothing.
-					out = "0:0"
-				self.base_rev = out.split(':')[1].strip()
+			out = RunShell(["hg", "parents", "-q"], silent_ok=True).strip()
+			if not out:
+				# No revisions; use 0 to mean a repository with nothing.
+				out = "0:0"
+			self.base_rev = out.split(':')[1].strip()
+
 	def _GetRelPath(self, filename):
 		"""Get relative path of a file according to the current directory,
 		given its logical path in the repo."""

File src/cmd/gc/walk.c

 		}
 		if(expr == N)
 			expr = nodbool(n->op == OEQ);
-		typecheck(&expr, Erv);
-		walkexpr(&expr, init);
-		expr->type = n->type;
-		*np = expr;
-		return;
+		r = expr;
+		goto ret;
 	}
-	
+
 	if(t->etype == TSTRUCT && countfield(t) <= 4) {
 		// Struct of four or fewer fields.
 		// Inline comparisons.
 		}
 		if(expr == N)
 			expr = nodbool(n->op == OEQ);
-		typecheck(&expr, Erv);
-		walkexpr(&expr, init);
-		expr->type = n->type;
-		*np = expr;
-		return;
+		r = expr;
+		goto ret;
 	}
-	
+
 	// Chose not to inline, but still have addresses.
 	// Call equality function directly.
 	// The equality function requires a bool pointer for
 
 	if(n->op != OEQ)
 		r = nod(ONOT, r, N);
-	typecheck(&r, Erv);
-	walkexpr(&r, init);
-	*np = r;
-	return;
+	goto ret;
 
 hard:
 	// Cannot take address of one or both of the operands.
 	r = mkcall1(fn, n->type, init, typename(n->left->type), l, r);
 	if(n->op == ONE) {
 		r = nod(ONOT, r, N);
-		typecheck(&r, Erv);
+	}
+	goto ret;
+
+ret:
+	typecheck(&r, Erv);
+	walkexpr(&r, init);
+	if(r->type != n->type) {
+		r = nod(OCONVNOP, r, N);
+		r->type = n->type;
+		r->typecheck = 1;
 	}
 	*np = r;
 	return;

File src/cmd/go/env.go

 			default:
 				fmt.Printf("%s=\"%s\"\n", e.name, e.value)
 			case "plan9":
-				fmt.Printf("%s='%s'\n", e.name, strings.Replace(e.value, "'", "''", -1))
+				if strings.IndexByte(e.value, '\x00') < 0 {
+					fmt.Printf("%s='%s'\n", e.name, strings.Replace(e.value, "'", "''", -1))
+				} else {
+					v := strings.Split(e.value, "\x00")
+					fmt.Printf("%s=(", e.name)
+					for x, s := range v {
+						if x > 0 {
+							fmt.Printf(" ")
+						}
+						fmt.Printf("%s", s)
+					}
+					fmt.Printf(")\n")
+				}
 			case "windows":
 				fmt.Printf("set %s=%s\n", e.name, e.value)
 			}

File src/cmd/ld/data.c

 
 	for(r=s->r; r<s->r+s->nr; r++) {
 		if(r->sym != S && r->sym->type == SDYNIMPORT || r->type >= 256) {
-			if(!r->sym->reachable)
+			if(r->sym != S && !r->sym->reachable)
 				diag("internal inconsistency: dynamic symbol %s is not reachable.", r->sym->name);
 			adddynrel(s, r);
 		}

File src/pkg/crypto/md5/example_test.go

 	fmt.Printf("%x", h.Sum(nil))
 	// Output: e2c569be17396eca2a2e3c11578123ed
 }
+
+func ExampleSum() {
+	data := []byte("These pretzels are making me thirsty.")
+	fmt.Printf("%x", md5.Sum(data))
+	// Output: b0804ec967f48520697662a204f5fe72
+}

File src/pkg/crypto/sha1/example_test.go

 
 func ExampleNew() {
 	h := sha1.New()
-	io.WriteString(h, "His money is twice tainted: 'taint yours and 'taint mine.")
+	io.WriteString(h, "His money is twice tainted:")
+	io.WriteString(h, " 'taint yours and 'taint mine.")
 	fmt.Printf("% x", h.Sum(nil))
 	// Output: 59 7f 6a 54 00 10 f9 4c 15 d7 18 06 a9 9a 2c 87 10 e7 47 bd
 }
+
+func ExampleSum() {
+	data := []byte("This page intentionally left blank.")
+	fmt.Printf("% x", sha1.Sum(data))
+	// Output: af 06 49 23 bb f2 30 15 96 aa c4 c2 73 ba 32 17 8e bc 4a 96
+}

File src/pkg/fmt/fmt_test.go

 	"math"
 	"runtime"
 	"strings"
-	"sync/atomic"
 	"testing"
 	"time"
 	"unicode"
 }
 
 func BenchmarkSprintfEmpty(b *testing.B) {
-	benchmarkSprintf(b, func(buf *bytes.Buffer) {
-		Sprintf("")
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			Sprintf("")
+		}
 	})
 }
 
 func BenchmarkSprintfString(b *testing.B) {
-	benchmarkSprintf(b, func(buf *bytes.Buffer) {
-		Sprintf("%s", "hello")
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			Sprintf("%s", "hello")
+		}
 	})
 }
 
 func BenchmarkSprintfInt(b *testing.B) {
-	benchmarkSprintf(b, func(buf *bytes.Buffer) {
-		Sprintf("%d", 5)
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			Sprintf("%d", 5)
+		}
 	})
 }
 
 func BenchmarkSprintfIntInt(b *testing.B) {
-	benchmarkSprintf(b, func(buf *bytes.Buffer) {
-		Sprintf("%d %d", 5, 6)
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			Sprintf("%d %d", 5, 6)
+		}
 	})
 }
 
 func BenchmarkSprintfPrefixedInt(b *testing.B) {
-	benchmarkSprintf(b, func(buf *bytes.Buffer) {
-		Sprintf("This is some meaningless prefix text that needs to be scanned %d", 6)
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			Sprintf("This is some meaningless prefix text that needs to be scanned %d", 6)
+		}
 	})
 }
 
 func BenchmarkSprintfFloat(b *testing.B) {
-	benchmarkSprintf(b, func(buf *bytes.Buffer) {
-		Sprintf("%g", 5.23184)
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			Sprintf("%g", 5.23184)
+		}
 	})
 }
 
 func BenchmarkManyArgs(b *testing.B) {
-	benchmarkSprintf(b, func(buf *bytes.Buffer) {
-		buf.Reset()
-		Fprintf(buf, "%2d/%2d/%2d %d:%d:%d %s %s\n", 3, 4, 5, 11, 12, 13, "hello", "world")
+	b.RunParallel(func(pb *testing.PB) {
+		var buf bytes.Buffer
+		for pb.Next() {
+			buf.Reset()
+			Fprintf(&buf, "%2d/%2d/%2d %d:%d:%d %s %s\n", 3, 4, 5, 11, 12, 13, "hello", "world")
+		}
 	})
 }
 
-func benchmarkSprintf(b *testing.B, f func(buf *bytes.Buffer)) {
-	const CallsPerSched = 1000
-	procs := runtime.GOMAXPROCS(-1)
-	N := int32(b.N / CallsPerSched)
-	c := make(chan bool, procs)
-	for p := 0; p < procs; p++ {
-		go func() {
-			var buf bytes.Buffer
-			for atomic.AddInt32(&N, -1) >= 0 {
-				for g := 0; g < CallsPerSched; g++ {
-					f(&buf)
-				}
-			}
-			c <- true
-		}()
-	}
-	for p := 0; p < procs; p++ {
-		<-c
-	}
-}
-
 var mallocBuf bytes.Buffer
 
 var mallocTest = []struct {

File src/pkg/math/big/nat_test.go

 	if x.decimalString() != pi {
 		panic("benchmark incorrect: conversion failed")
 	}
-	n := runtime.GOMAXPROCS(0)
-	m := b.N / n // n*m <= b.N due to flooring, but the error is neglibible (n is not very large)
-	c := make(chan int, n)
-	for i := 0; i < n; i++ {
-		go func() {
-			for j := 0; j < m; j++ {
-				x.decimalString()
-			}
-			c <- 0
-		}()
-	}
-	for i := 0; i < n; i++ {
-		<-c
-	}
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			x.decimalString()
+		}
+	})
 }
 
 func BenchmarkScan10Base2(b *testing.B)     { ScanHelper(b, 2, 10, 10) }

File src/pkg/net/fd_poll_runtime.go

 	"time"
 )
 
+// runtimeNano returns the current value of the runtime clock in nanoseconds.
+func runtimeNano() int64
+
 func runtime_pollServerInit()
 func runtime_pollOpen(fd uintptr) (uintptr, int)
 func runtime_pollClose(ctx uintptr)
 }
 
 func setDeadlineImpl(fd *netFD, t time.Time, mode int) error {
-	d := t.UnixNano()
+	d := runtimeNano() + int64(t.Sub(time.Now()))
 	if t.IsZero() {
 		d = 0
 	}

File src/pkg/net/http/serve_test.go

 	"runtime"
 	"strconv"
 	"strings"
-	"sync"
 	"sync/atomic"
 	"syscall"
 	"testing"
 	benchmarkClientServerParallel(b, 64)
 }
 
-func benchmarkClientServerParallel(b *testing.B, conc int) {
+func benchmarkClientServerParallel(b *testing.B, parallelism int) {
 	b.ReportAllocs()
-	b.StopTimer()
 	ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, r *Request) {
 		fmt.Fprintf(rw, "Hello world.\n")
 	}))
 	defer ts.Close()
-	b.StartTimer()
-
-	numProcs := runtime.GOMAXPROCS(-1) * conc
-	var wg sync.WaitGroup
-	wg.Add(numProcs)
-	n := int32(b.N)
-	for p := 0; p < numProcs; p++ {
-		go func() {
-			for atomic.AddInt32(&n, -1) >= 0 {
-				res, err := Get(ts.URL)
-				if err != nil {
-					b.Logf("Get: %v", err)
-					continue
-				}
-				all, err := ioutil.ReadAll(res.Body)
-				res.Body.Close()
-				if err != nil {
-					b.Logf("ReadAll: %v", err)
-					continue
-				}
-				body := string(all)
-				if body != "Hello world.\n" {
-					panic("Got body: " + body)
-				}
+	b.ResetTimer()
+	b.SetParallelism(parallelism)
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			res, err := Get(ts.URL)
+			if err != nil {
+				b.Logf("Get: %v", err)
+				continue
 			}
-			wg.Done()
-		}()
-	}
-	wg.Wait()
+			all, err := ioutil.ReadAll(res.Body)
+			res.Body.Close()
+			if err != nil {
+				b.Logf("ReadAll: %v", err)
+				continue
+			}
+			body := string(all)
+			if body != "Hello world.\n" {
+				panic("Got body: " + body)
+			}
+		}
+	})
 }
 
 // A benchmark for profiling the server without the HTTP client code.

File src/pkg/net/rpc/server_test.go

 }
 
 func benchmarkEndToEnd(dial func() (*Client, error), b *testing.B) {
-	b.StopTimer()
 	once.Do(startServer)
 	client, err := dial()
 	if err != nil {
 
 	// Synchronous calls
 	args := &Args{7, 8}
-	procs := runtime.GOMAXPROCS(-1)
-	N := int32(b.N)
-	var wg sync.WaitGroup
-	wg.Add(procs)
-	b.StartTimer()
+	b.ResetTimer()
 
-	for p := 0; p < procs; p++ {
-		go func() {
-			reply := new(Reply)
-			for atomic.AddInt32(&N, -1) >= 0 {
-				err := client.Call("Arith.Add", args, reply)
-				if err != nil {
-					b.Fatalf("rpc error: Add: expected no error but got string %q", err.Error())
-				}
-				if reply.C != args.A+args.B {
-					b.Fatalf("rpc error: Add: expected %d got %d", reply.C, args.A+args.B)
-				}
+	b.RunParallel(func(pb *testing.PB) {
+		reply := new(Reply)
+		for pb.Next() {
+			err := client.Call("Arith.Add", args, reply)
+			if err != nil {
+				b.Fatalf("rpc error: Add: expected no error but got string %q", err.Error())
 			}
-			wg.Done()
-		}()
-	}
-	wg.Wait()
+			if reply.C != args.A+args.B {
+				b.Fatalf("rpc error: Add: expected %d got %d", reply.C, args.A+args.B)
+			}
+		}
+	})
 }
 
 func benchmarkEndToEndAsync(dial func() (*Client, error), b *testing.B) {
 	const MaxConcurrentCalls = 100
-	b.StopTimer()
 	once.Do(startServer)
 	client, err := dial()
 	if err != nil {
 	wg.Add(procs)
 	gate := make(chan bool, MaxConcurrentCalls)
 	res := make(chan *Call, MaxConcurrentCalls)
-	b.StartTimer()
+	b.ResetTimer()
 
 	for p := 0; p < procs; p++ {
 		go func() {

File src/pkg/runtime/chan_test.go

 }
 
 func BenchmarkChanNonblocking(b *testing.B) {
-	const CallsPerSched = 1000
-	procs := runtime.GOMAXPROCS(-1)
-	N := int32(b.N / CallsPerSched)
-	c := make(chan bool, procs)
 	myc := make(chan int)
-	for p := 0; p < procs; p++ {
-		go func() {
-			for atomic.AddInt32(&N, -1) >= 0 {
-				for g := 0; g < CallsPerSched; g++ {
-					select {
-					case <-myc:
-					default:
-					}
-				}
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			select {
+			case <-myc:
+			default:
 			}
-			c <- true
-		}()
-	}
-	for p := 0; p < procs; p++ {
-		<-c
-	}
+		}
+	})
 }
 
 func BenchmarkSelectUncontended(b *testing.B) {
 
 func BenchmarkChanSem(b *testing.B) {
 	type Empty struct{}
-	const CallsPerSched = 1000
-	procs := runtime.GOMAXPROCS(0)
-	N := int32(b.N / CallsPerSched)
-	c := make(chan bool, procs)
-	myc := make(chan Empty, procs)
-	for p := 0; p < procs; p++ {
-		go func() {
-			for atomic.AddInt32(&N, -1) >= 0 {
-				for g := 0; g < CallsPerSched; g++ {
-					myc <- Empty{}
-					<-myc
-				}
-			}
-			c <- true
-		}()
-	}
-	for p := 0; p < procs; p++ {
-		<-c
-	}
+	myc := make(chan Empty, runtime.GOMAXPROCS(0))
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			myc <- Empty{}
+			<-myc
+		}
+	})
 }

File src/pkg/runtime/mfinal_test.go

 
 import (
 	"runtime"
-	"sync"
-	"sync/atomic"
 	"testing"
 	"time"
 )
 }
 
 func BenchmarkFinalizer(b *testing.B) {
-	const CallsPerSched = 1000
-	procs := runtime.GOMAXPROCS(-1)
-	N := int32(b.N / CallsPerSched)
-	var wg sync.WaitGroup
-	wg.Add(procs)
-	for p := 0; p < procs; p++ {
-		go func() {
-			var data [CallsPerSched]*int
-			for i := 0; i < CallsPerSched; i++ {
-				data[i] = new(int)
+	const Batch = 1000
+	b.RunParallel(func(pb *testing.PB) {
+		var data [Batch]*int
+		for i := 0; i < Batch; i++ {
+			data[i] = new(int)
+		}
+		for pb.Next() {
+			for i := 0; i < Batch; i++ {
+				runtime.SetFinalizer(data[i], fin)
 			}
-			for atomic.AddInt32(&N, -1) >= 0 {
-				runtime.Gosched()
-				for i := 0; i < CallsPerSched; i++ {
-					runtime.SetFinalizer(data[i], fin)
-				}
-				for i := 0; i < CallsPerSched; i++ {
-					runtime.SetFinalizer(data[i], nil)
-				}
+			for i := 0; i < Batch; i++ {
+				runtime.SetFinalizer(data[i], nil)
 			}
-			wg.Done()
-		}()
-	}
-	wg.Wait()
+		}
+	})
 }
 
 func BenchmarkFinalizerRun(b *testing.B) {
-	const CallsPerSched = 1000
-	procs := runtime.GOMAXPROCS(-1)
-	N := int32(b.N / CallsPerSched)
-	var wg sync.WaitGroup
-	wg.Add(procs)
-	for p := 0; p < procs; p++ {
-		go func() {
-			for atomic.AddInt32(&N, -1) >= 0 {
-				runtime.Gosched()
-				for i := 0; i < CallsPerSched; i++ {
-					v := new(int)
-					runtime.SetFinalizer(v, fin)
-				}
-				runtime.GC()
-			}
-			wg.Done()
-		}()
-	}
-	wg.Wait()
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			v := new(int)
+			runtime.SetFinalizer(v, fin)
+		}
+	})
 }

File src/pkg/runtime/mgc0.c

 {
 	uint32 sg;
 
+	// Caller must disable preemption.
+	// Otherwise when this function returns the span can become unswept again
+	// (if GC is triggered on another goroutine).
+	if(m->locks == 0 && m->mallocing == 0)
+		runtime·throw("MSpan_EnsureSwept: m is not locked");
+
 	sg = runtime·mheap.sweepgen;
 	if(runtime·atomicload(&s->sweepgen) == sg)
 		return;
-	m->locks++;
 	if(runtime·cas(&s->sweepgen, sg-2, sg-1)) {
 		runtime·MSpan_Sweep(s);
-		m->locks--;
 		return;
 	}
-	m->locks--;
 	// unfortunate condition, and we don't have efficient means to wait
 	while(runtime·atomicload(&s->sweepgen) != sg)
 		runtime·osyield();  
 	return runtime·atoi(p);
 }
 
-static FuncVal runfinqv = {runfinq};
-
 void
 runtime·gc(int32 force)
 {
 				if(framecap < framesz) {
 					runtime·free(frame);
 					// The frame does not contain pointers interesting for GC,
-					// all not yet finalized objects are stored in finc.
+					// all not yet finalized objects are stored in finq.
 					// If we do not mark it as FlagNoScan,
 					// the last finalized object is not collected.
 					frame = runtime·mallocgc(framesz, 0, FlagNoScan|FlagNoInvokeGC);
 				f->ot = nil;
 			}
 			fb->cnt = 0;
+			runtime·lock(&gclock);
 			fb->next = finc;
 			finc = fb;
+			runtime·unlock(&gclock);
 		}
 		runtime·gc(1);	// trigger another gc to clean up the finalized objects, if possible
 	}

File src/pkg/runtime/mheap.c

 
 	// Ensure that the span is swept.
 	// GC accesses specials list w/o locks. And it's just much safer.
+	m->locks++;
 	runtime·MSpan_EnsureSwept(span);
 
 	offset = (uintptr)p - (span->start << PageShift);
 	while((x = *t) != nil) {
 		if(offset == x->offset && kind == x->kind) {
 			runtime·unlock(&span->specialLock);
+			m->locks--;
 			return false; // already exists
 		}
 		if(offset < x->offset || (offset == x->offset && kind < x->kind))
 	s->next = x;
 	*t = s;
 	runtime·unlock(&span->specialLock);
+	m->locks--;
 	return true;
 }
 
 
 	// Ensure that the span is swept.
 	// GC accesses specials list w/o locks. And it's just much safer.
+	m->locks++;
 	runtime·MSpan_EnsureSwept(span);
 
 	offset = (uintptr)p - (span->start << PageShift);
 		if(offset == s->offset && kind == s->kind) {
 			*t = s->next;
 			runtime·unlock(&span->specialLock);
+			m->locks--;
 			return s;
 		}
 		t = &s->next;
 	}
 	runtime·unlock(&span->specialLock);
+	m->locks--;
 	return nil;
 }
 
 	Special *s, **t, *list;
 	uintptr offset;
 
+	if(span->sweepgen != runtime·mheap.sweepgen)
+		runtime·throw("runtime: freeallspecials: unswept span");
 	// first, collect all specials into the list; then, free them
 	// this is required to not cause deadlock between span->specialLock and proflock
 	list = nil;

File src/pkg/runtime/netpoll.goc

 static FuncVal readDeadlineFn	= {(void(*)(void))readDeadline};
 static FuncVal writeDeadlineFn	= {(void(*)(void))writeDeadline};
 
+// runtimeNano returns the current value of the runtime clock in nanoseconds.
+func runtimeNano() (ns int64) {
+	ns = runtime·nanotime();
+}
+
 func runtime_pollServerInit() {
 	runtime·netpollinit();
 }

File src/pkg/runtime/norace_test.go

 
 import (
 	"runtime"
-	"sync/atomic"
 	"testing"
 )
 
 }
 
 func benchmarkSyscall(b *testing.B, work, excess int) {
-	const CallsPerSched = 1000
-	procs := runtime.GOMAXPROCS(-1) * excess
-	N := int32(b.N / CallsPerSched)
-	c := make(chan bool, procs)
-	for p := 0; p < procs; p++ {
-		go func() {
-			foo := 42
-			for atomic.AddInt32(&N, -1) >= 0 {
-				runtime.Gosched()
-				for g := 0; g < CallsPerSched; g++ {
-					runtime.Entersyscall()
-					for i := 0; i < work; i++ {
-						foo *= 2
-						foo /= 2
-					}
-					runtime.Exitsyscall()
-				}
+	b.SetParallelism(excess)
+	b.RunParallel(func(pb *testing.PB) {
+		foo := 42
+		for pb.Next() {
+			runtime.Entersyscall()
+			for i := 0; i < work; i++ {
+				foo *= 2
+				foo /= 2
 			}
-			c <- foo == 42
-		}()
-	}
-	for p := 0; p < procs; p++ {
-		<-c
-	}
+			runtime.Exitsyscall()
+		}
+		_ = foo
+	})
 }

File src/pkg/runtime/panic.c

 runtime·panic(Eface e)
 {
 	Defer *d;
-	Panic *p;
+	Panic p;
 	void *pc, *argp;
-	
-	p = runtime·mal(sizeof *p);
-	p->arg = e;
-	p->link = g->panic;
-	p->stackbase = g->stackbase;
-	g->panic = p;
+
+	runtime·memclr((byte*)&p, sizeof p);
+	p.arg = e;
+	p.link = g->panic;
+	p.stackbase = g->stackbase;
+	g->panic = &p;
 
 	for(;;) {
 		d = g->defer;
 		pc = d->pc;
 		runtime·newstackcall(d->fn, (byte*)d->args, d->siz);
 		freedefer(d);
-		if(p->recovered) {
-			g->panic = p->link;
+		if(p.recovered) {
+			g->panic = p.link;
 			if(g->panic == nil)	// must be done with signal
 				g->sig = 0;
-			runtime·free(p);
 			// Pass information about recovering frame to recovery.
 			g->sigcode0 = (uintptr)argp;
 			g->sigcode1 = (uintptr)pc;

File src/pkg/runtime/proc_test.go

 }
 
 func benchmarkStackGrowth(b *testing.B, rec int) {
-	const CallsPerSched = 1000
-	procs := runtime.GOMAXPROCS(-1)
-	N := int32(b.N / CallsPerSched)
-	c := make(chan bool, procs)
-	for p := 0; p < procs; p++ {
-		go func() {
-			for atomic.AddInt32(&N, -1) >= 0 {
-				runtime.Gosched()
-				for g := 0; g < CallsPerSched; g++ {
-					stackGrowthRecursive(rec)
-				}
-			}
-			c <- true
-		}()
-	}
-	for p := 0; p < procs; p++ {
-		<-c
-	}
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			stackGrowthRecursive(rec)
+		}
+	})
 }
 
 func BenchmarkStackGrowth(b *testing.B) {

File src/pkg/runtime/runtime-gdb.py

 #      circumventing the pretty print triggering.
 
 
-import sys, re
+from __future__ import print_function
+import re
+import sys
 
-print >>sys.stderr, "Loading Go Runtime support."
-
+print("Loading Go Runtime support.", file=sys.stderr)
+#http://python3porting.com/differences.html
+if sys.version > '3':
+	xrange = range
 # allow to manually reload while developing
 goobjfile = gdb.current_objfile() or gdb.objfiles()[0]
 goobjfile.pretty_printers = []
 #  Pretty Printers
 #
 
+
 class StringTypePrinter:
 	"Pretty print Go strings."
 
 		if self.val["len"] > self.val["cap"]:
 			return
 		ptr = self.val["array"]
-		for idx in range(self.val["len"]):
-			yield ('[%d]' % idx, (ptr + idx).dereference())
+		for idx in range(int(self.val["len"])):
+			yield ('[{0}]'.format(idx), (ptr + idx).dereference())
 
 
 class MapTypePrinter:
 	to inspect their contents with this pretty printer.
 	"""
 
-	pattern = re.compile(r'^struct hash<.*>$')
+	pattern = re.compile(r'^map\[.*\].*$')
 
 	def __init__(self, val):
 		self.val = val
 		flags = self.val['flags']
 		inttype = self.val['hash0'].type
 		cnt = 0
-		for bucket in xrange(2 ** B):
+		for bucket in xrange(2 ** int(B)):
 			bp = buckets + bucket
 			if oldbuckets:
 				oldbucket = bucket & (2 ** (B - 1) - 1)
 				oldbp = oldbuckets + oldbucket
 				oldb = oldbp.dereference()
-				if (oldb['overflow'].cast(inttype) & 1) == 0: # old bucket not evacuated yet
-					if bucket >= 2 ** (B - 1): continue   # already did old bucket
+				if (oldb['overflow'].cast(inttype) & 1) == 0:  # old bucket not evacuated yet
+					if bucket >= 2 ** (B - 1):
+						continue    # already did old bucket
 					bp = oldbp
 			while bp:
 				b = bp.dereference()
 							k = k.dereference()
 						if flags & 2:
 							v = v.dereference()
-						yield '%d' % cnt, k
-						yield '%d' % (cnt + 1), v
+						yield str(cnt), k
+						yield str(cnt + 1), v
 						cnt += 2
 				bp = b['overflow']
 
+
 class ChanTypePrinter:
 	"""Pretty print chan[T] types.
 
 		ptr = (self.val.address + 1).cast(et.pointer())
 		for i in range(self.val["qcount"]):
 			j = (self.val["recvx"] + i) % self.val["dataqsiz"]
-			yield ('[%d]' % i, (ptr + j).dereference())
+			yield ('[{0}]'.format(i), (ptr + j).dereference())
 
 
 #
 		try:
 			if klass.pattern.match(str(val.type)):
 				return klass(val)
-		except:
+		except Exception:
 			pass
 	return matcher
 
-goobjfile.pretty_printers.extend([makematcher(k) for k in vars().values() if hasattr(k, 'pattern')])
+goobjfile.pretty_printers.extend([makematcher(var) for var in vars().values() if hasattr(var, 'pattern')])
 
 #
 #  For reference, this is what we're trying to do:
 
 def is_iface(val):
 	try:
-		return str(val['tab'].type) == "struct runtime.itab *" \
-		      and str(val['data'].type) == "void *"
-	except:
+		return str(val['tab'].type) == "struct runtime.itab *" and str(val['data'].type) == "void *"
+	except gdb.error:
 		pass
 
+
 def is_eface(val):
 	try:
-		return str(val['_type'].type) == "struct runtime._type *" \
-		      and str(val['data'].type) == "void *"
-	except:
+		return str(val['_type'].type) == "struct runtime._type *" and str(val['data'].type) == "void *"
+	except gdb.error:
 		pass
 
+
 def lookup_type(name):
 	try:
 		return gdb.lookup_type(name)
-	except:
+	except gdb.error:
 		pass
 	try:
 		return gdb.lookup_type('struct ' + name)
-	except:
+	except gdb.error:
 		pass
 	try:
 		return gdb.lookup_type('struct ' + name[1:]).pointer()
-	except:
+	except gdb.error:
 		pass
 
 _rctp_type = gdb.lookup_type("struct runtime.rtype").pointer()
 
+
 def iface_commontype(obj):
 	if is_iface(obj):
 		go_type_ptr = obj['tab']['_type']
 		go_type_ptr = obj['_type']
 	else:
 		return
-	
+
 	return go_type_ptr.cast(_rctp_type).dereference()
-	
+
 
 def iface_dtype(obj):
 	"Decode type of the data field of an eface or iface struct."
 	dynamic_gdb_type = lookup_type(dtype_name)
 	if dynamic_gdb_type is None:
 		return
-	
+
 	type_size = int(dynamic_go_type['size'])
 	uintptr_size = int(dynamic_go_type['size'].type.sizeof)	 # size is itself an uintptr
 	if type_size > uintptr_size:
 
 	return dynamic_gdb_type
 
+
 def iface_dtype_name(obj):
 	"Decode type name of the data field of an eface or iface struct."
 
 			return 0x0
 		try:
 			dtype = iface_dtype(self.val)
-		except:
+		except Exception:
 			return "<bad dynamic type>"
 
 		if dtype is None:  # trouble looking up, print something reasonable
-			return "(%s)%s" % (iface_dtype_name(self.val), self.val['data'])
+			return "({0}){0}".format(iface_dtype_name(self.val), self.val['data'])
 
 		try:
 			return self.val['data'].cast(dtype).dereference()
-		except:
+		except Exception:
 			pass
 		return self.val['data'].cast(dtype)
 
 #  Convenience Functions
 #
 
+
 class GoLenFunc(gdb.Function):
 	"Length of strings, slices, maps or channels"
 
-	how = ((StringTypePrinter, 'len'),
-	       (SliceTypePrinter, 'len'),
-	       (MapTypePrinter, 'count'),
-	       (ChanTypePrinter, 'qcount'))
+	how = ((StringTypePrinter, 'len'), (SliceTypePrinter, 'len'), (MapTypePrinter, 'count'), (ChanTypePrinter, 'qcount'))
 
 	def __init__(self):
-		super(GoLenFunc, self).__init__("len")
+		gdb.Function.__init__(self, "len")
 
 	def invoke(self, obj):
 		typename = str(obj.type)
 			if klass.pattern.match(typename):
 				return obj[fld]
 
+
 class GoCapFunc(gdb.Function):
 	"Capacity of slices or channels"
 
-	how = ((SliceTypePrinter, 'cap'),
-	       (ChanTypePrinter, 'dataqsiz'))
+	how = ((SliceTypePrinter, 'cap'), (ChanTypePrinter, 'dataqsiz'))
 
 	def __init__(self):
-		super(GoCapFunc, self).__init__("cap")
+		gdb.Function.__init__(self, "cap")
 
 	def invoke(self, obj):
 		typename = str(obj.type)
 			if klass.pattern.match(typename):
 				return obj[fld]
 
+
 class DTypeFunc(gdb.Function):
 	"""Cast Interface values to their dynamic type.
 
 	"""
 
 	def __init__(self):
-		super(DTypeFunc, self).__init__("dtype")
+		gdb.Function.__init__(self, "dtype")
 
 	def invoke(self, obj):
 		try:
 			return obj['data'].cast(iface_dtype(obj))
-		except:
+		except gdb.error:
 			pass
 		return obj
 
 
 sts = ('idle', 'runnable', 'running', 'syscall', 'waiting', 'moribund', 'dead', 'recovery')
 
+
 def linked_list(ptr, linkfield):
 	while ptr:
 		yield ptr
 	"List all goroutines."
 
 	def __init__(self):
-		super(GoroutinesCmd, self).__init__("info goroutines", gdb.COMMAND_STACK, gdb.COMPLETE_NONE)
+		gdb.Command.__init__(self, "info goroutines", gdb.COMMAND_STACK, gdb.COMPLETE_NONE)
 
-	def invoke(self, arg, from_tty):
+	def invoke(self, _arg, _from_tty):
 		# args = gdb.string_to_argv(arg)
 		vp = gdb.lookup_type('void').pointer()
 		for ptr in linked_list(gdb.parse_and_eval("'runtime.allg'"), 'alllink'):
-			if ptr['status'] == 6:	# 'gdead'
+			if ptr['status'] == 6:  # 'gdead'
 				continue
 			s = ' '
 			if ptr['m']:
 				s = '*'
 			pc = ptr['sched']['pc'].cast(vp)
-			sp = ptr['sched']['sp'].cast(vp)
-			blk = gdb.block_for_pc(long((pc)))
-			print s, ptr['goid'], "%8s" % sts[long((ptr['status']))], blk.function
+			# python2 will not cast pc (type void*) to an int cleanly
+			# instead python2 and python3 work with the hex string representation
+			# of the void pointer which we can parse back into an int.
+			# int(pc) will not work.
+			try:
+				#python3 / newer versions of gdb
+				pc = int(pc)
+			except gdb.error:
+				pc = int(str(pc), 16)
+			blk = gdb.block_for_pc(pc)
+			print(s, ptr['goid'], "{0:8s}".format(sts[int(ptr['status'])]), blk.function)
+
 
 def find_goroutine(goid):
+	"""
+	find_goroutine attempts to find the goroutine identified by goid.
+	It returns a touple of gdv.Value's representing the the stack pointer
+	and program counter pointer for the goroutine.
+
+	@param int goid
+
+	@return tuple (gdb.Value, gdb.Value)
+	"""
 	vp = gdb.lookup_type('void').pointer()
 	for ptr in linked_list(gdb.parse_and_eval("'runtime.allg'"), 'alllink'):
-		if ptr['status'] == 6:	# 'gdead'
+		if ptr['status'] == 6:  # 'gdead'
 			continue
 		if ptr['goid'] == goid:
-			return [ptr['sched'][x].cast(vp) for x in 'pc', 'sp']
+			return (ptr['sched'][x].cast(vp) for x in ('pc', 'sp'))
 	return None, None
 
 
 	"""
 
 	def __init__(self):
-		super(GoroutineCmd, self).__init__("goroutine", gdb.COMMAND_STACK, gdb.COMPLETE_NONE)
+		gdb.Command.__init__(self, "goroutine", gdb.COMMAND_STACK, gdb.COMPLETE_NONE)
 
-	def invoke(self, arg, from_tty):
+	def invoke(self, arg, _from_tty):
 		goid, cmd = arg.split(None, 1)
 		goid = gdb.parse_and_eval(goid)
 		pc, sp = find_goroutine(int(goid))
 		if not pc:
-			print "No such goroutine: ", goid
+			print("No such goroutine: ", goid)
 			return
+		try:
+			#python3 / newer versions of gdb
+			pc = int(pc)
+		except gdb.error:
+			pc = int(str(pc), 16)
 		save_frame = gdb.selected_frame()
 		gdb.parse_and_eval('$save_pc = $pc')
 		gdb.parse_and_eval('$save_sp = $sp')
-		gdb.parse_and_eval('$pc = 0x%x' % long(pc))
-		gdb.parse_and_eval('$sp = 0x%x' % long(sp))
+		gdb.parse_and_eval('$pc = {0}'.format(str(pc)))
+		gdb.parse_and_eval('$sp = {0}'.format(str(sp)))
 		try:
 			gdb.execute(cmd)
 		finally:
 	"Print Static and dynamic interface types"
 
 	def __init__(self):
-		super(GoIfaceCmd, self).__init__("iface", gdb.COMMAND_DATA, gdb.COMPLETE_SYMBOL)
+		gdb.Command.__init__(self, "iface", gdb.COMMAND_DATA, gdb.COMPLETE_SYMBOL)
 
-	def invoke(self, arg, from_tty):
+	def invoke(self, arg, _from_tty):
 		for obj in gdb.string_to_argv(arg):
 			try:
 				#TODO fix quoting for qualified variable names
-				obj = gdb.parse_and_eval("%s" % obj)
-			except Exception, e:
-				print "Can't parse ", obj, ": ", e
+				obj = gdb.parse_and_eval(str(obj))
+			except Exception as e:
+				print("Can't parse ", obj, ": ", e)
 				continue
 
 			if obj['data'] == 0:
 				dtype = "nil"
 			else:
 				dtype = iface_dtype(obj)
-				
+
 			if dtype is None:
-				print "Not an interface: ", obj.type
+				print("Not an interface: ", obj.type)
 				continue
 
-			print "%s: %s" % (obj.type, dtype)
+			print("{0}: {1}".format(obj.type, dtype))
 
 # TODO: print interface's methods and dynamic type's func pointers thereof.
-#rsc: "to find the number of entries in the itab's Fn field look at itab.inter->numMethods
-#i am sure i have the names wrong but look at the interface type and its method count"
+#rsc: "to find the number of entries in the itab's Fn field look at
+# itab.inter->numMethods
+# i am sure i have the names wrong but look at the interface type
+# and its method count"
 # so Itype will start with a commontype which has kind = interface
 
 #

File src/pkg/runtime/sys_linux_386.s

 // func now() (sec int64, nsec int32)
 TEXT time·now(SB), NOSPLIT, $32
 	MOVL	$265, AX			// syscall - clock_gettime
-	MOVL	$0, BX
+	MOVL	$0, BX		// CLOCK_REALTIME
 	LEAL	8(SP), CX
 	MOVL	$0, DX
 	CALL	*runtime·_vdso(SB)
 // void nanotime(int64 *nsec)
 TEXT runtime·nanotime(SB), NOSPLIT, $32
 	MOVL	$265, AX			// syscall - clock_gettime
-	MOVL	$0, BX
+	MOVL	$1, BX		// CLOCK_MONOTONIC
 	LEAL	8(SP), CX
 	MOVL	$0, DX
 	CALL	*runtime·_vdso(SB)

File src/pkg/runtime/sys_linux_amd64.s

 	MOVQ	runtime·__vdso_clock_gettime_sym(SB), AX
 	CMPQ	AX, $0
 	JEQ	fallback_gtod_nt
-	MOVL	$0, DI // CLOCK_REALTIME
+	MOVL	$1, DI // CLOCK_MONOTONIC
 	LEAQ	0(SP), SI
 	CALL	AX
 	MOVQ	0(SP), AX	// sec

File src/pkg/runtime/time.goc

 
 // time.now is implemented in assembly.
 
+// runtimeNano returns the current value of the runtime clock in nanoseconds.
+func runtimeNano() (ns int64) {
+	ns = runtime·nanotime();
+}
+
 // Sleep puts the current goroutine to sleep for at least ns nanoseconds.
 func Sleep(ns int64) {
 	runtime·tsleep(ns, "sleep");

File src/pkg/syscall/ztypes_linux_arm.go

 }
 
 type Flock_t struct {
-	Type   int16
-	Whence int16
-	Start  int64
-	Len    int64
-	Pid    int32
+	Type      int16
+	Whence    int16
+	Pad_cgo_0 [4]byte
+	Start     int64
+	Len       int64
+	Pid       int32
+	Pad_cgo_1 [4]byte
 }
 
 type RawSockaddrInet4 struct {

File src/pkg/testing/benchmark.go

 		}()
 	}
 	wg.Wait()
+	if n <= uint64(b.N) && !b.Failed() {
+		b.Fatal("RunParallel: body exited without pb.Next() == false")
+	}
 }
 
 // SetParallelism sets the number of goroutines used by RunParallel to p*GOMAXPROCS.

File src/pkg/testing/benchmark_test.go

 			// w/o crashing/deadlocking the whole benchmark.
 			b.Log("log")
 			b.Error("error")
-			b.Fatal("fatal")
 		})
 	})
 }

File src/pkg/time/internal_test.go

 	// detection logic in NewTimer: we're testing the underlying
 	// runtime.addtimer function.
 	r := &runtimeTimer{
-		when: nano() + (1<<63 - 1),
+		when: runtimeNano() + (1<<63 - 1),
 		f:    empty,
 		arg:  nil,
 	}

File src/pkg/time/sleep.go

 // A negative or zero duration causes Sleep to return immediately.
 func Sleep(d Duration)
 
-func nano() int64 {
-	sec, nsec := now()
-	return sec*1e9 + int64(nsec)
-}
+// runtimeNano returns the current value of the runtime clock in nanoseconds.
+func runtimeNano() int64
 
 // Interface to timers implemented in package runtime.
 // Must be in sync with ../runtime/runtime.h:/^struct.Timer$
 // zero because of an overflow, MaxInt64 is returned.
 func when(d Duration) int64 {
 	if d <= 0 {
-		return nano()
+		return runtimeNano()
 	}
-	t := nano() + int64(d)
+	t := runtimeNano() + int64(d)
 	if t < 0 {
 		t = 1<<63 - 1 // math.MaxInt64
 	}
 	// the desired behavior when the reader gets behind,
 	// because the sends are periodic.
 	select {
-	case c.(chan Time) <- Unix(0, now):
+	case c.(chan Time) <- Now():
 	default:
 	}
 }

File src/pkg/time/sleep_test.go

 	for i := 0; i < len(garbage); i++ {
 		garbage[i] = AfterFunc(Hour, nil)
 	}
-
-	const batch = 1000
-	P := runtime.GOMAXPROCS(-1)
-	N := int32(b.N / batch)
-
 	b.ResetTimer()
 
-	var wg sync.WaitGroup
-	wg.Add(P)
-
-	for p := 0; p < P; p++ {
-		go func() {
-			for atomic.AddInt32(&N, -1) >= 0 {
-				bench(batch)
-			}
-			wg.Done()
-		}()
-	}
-
-	wg.Wait()
+	b.RunParallel(func(pb *testing.PB) {
+		for pb.Next() {
+			bench(1000)
+		}
+	})
 
 	b.StopTimer()
 	for i := 0; i < len(garbage); i++ {

File src/pkg/time/tick.go

 // time with a period specified by the duration argument.
 // It adjusts the intervals or drops ticks to make up for slow receivers.
 // The duration d must be greater than zero; if not, NewTicker will panic.
+// Stop the ticker to release associated resources.
 func NewTicker(d Duration) *Ticker {
 	if d <= 0 {
 		panic(errors.New("non-positive interval for NewTicker"))
 	t := &Ticker{
 		C: c,
 		r: runtimeTimer{
-			when:   nano() + int64(d),
+			when:   when(d),
 			period: int64(d),
 			f:      sendTime,
 			arg:    c,
 		isfalse(iz != x)
 	}
 
+	// named booleans
+	{
+		type mybool bool
+		var b mybool
+
+		type T struct{ data [20]byte }
+		var x, y T
+		b = x == y
+		istrue(x == y)
+		istrue(bool(b))
+
+		m := make(map[string][10]interface{})
+		b = m["x"] == m["y"]
+		istrue(m["x"] == m["y"])
+		istrue(bool(b))
+	}
+
 	shouldPanic(p1)
 	shouldPanic(p2)
 	shouldPanic(p3)

File test/fixedbugs/issue7366.go

+// compile
+
+// Copyright 2014 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// issue 7366: generates a temporary with ideal type
+// during comparison of small structs.
+
+package main
+
+type T struct {
+	data [10]byte
+}
+
+func main() {
+	var a T
+	var b T
+	if a == b {
+	}
+}