runtime: eliminate parfor ctx field

Prior to the conversion of the runtime to Go, this void* was
necessary to get closure information in to C callbacks.  There
are no more C callbacks and parfor is perfectly capable of
invoking a Go closure now, so eliminate ctx and all of its
unsafe-ness.  (Plus, the runtime currently doesn't use ctx for
anything.)

Change-Id: I39fc53b7dd3d7f660710abc76b0d831bfc6296d8
Reviewed-on: https://go-review.googlesource.com/3395
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
diff --git a/src/runtime/parfor_test.go b/src/runtime/parfor_test.go
index de64285..5d22aec 100644
--- a/src/runtime/parfor_test.go
+++ b/src/runtime/parfor_test.go
@@ -10,11 +10,8 @@
 import (
 	. "runtime"
 	"testing"
-	"unsafe"
 )
 
-var gdata []uint64
-
 // Simple serial sanity test for parallelfor.
 func TestParFor(t *testing.T) {
 	const P = 1
@@ -24,12 +21,7 @@
 		data[i] = i
 	}
 	desc := NewParFor(P)
-	// Avoid making func a closure: parfor cannot invoke them.
-	// Since it doesn't happen in the C code, it's not worth doing
-	// just for the test.
-	gdata = data
-	ParForSetup(desc, P, N, nil, true, func(desc *ParFor, i uint32) {
-		data := gdata
+	ParForSetup(desc, P, N, true, func(desc *ParFor, i uint32) {
 		data[i] = data[i]*data[i] + 1
 	})
 	ParForDo(desc)
@@ -49,9 +41,8 @@
 		data[i] = i
 	}
 	desc := NewParFor(P)
-	ParForSetup(desc, P, N, (*byte)(unsafe.Pointer(&data)), false, func(desc *ParFor, i uint32) {
-		d := *(*[]uint64)(unsafe.Pointer(desc.Ctx))
-		d[i] = d[i]*d[i] + 1
+	ParForSetup(desc, P, N, false, func(desc *ParFor, i uint32) {
+		data[i] = data[i]*data[i] + 1
 	})
 	for p := 0; p < P; p++ {
 		ParForDo(desc)
@@ -70,7 +61,7 @@
 	desc := NewParFor(P)
 	for n := uint32(0); n < N; n++ {
 		for p := uint32(1); p <= P; p++ {
-			ParForSetup(desc, p, n, nil, true, func(desc *ParFor, i uint32) {})
+			ParForSetup(desc, p, n, true, func(desc *ParFor, i uint32) {})
 			sum := uint32(0)
 			size0 := uint32(0)
 			end0 := uint32(0)
@@ -113,9 +104,7 @@
 	P := GOMAXPROCS(-1)
 	c := make(chan bool, P)
 	desc := NewParFor(uint32(P))
-	gdata = data
-	ParForSetup(desc, uint32(P), uint32(N), nil, false, func(desc *ParFor, i uint32) {
-		data := gdata
+	ParForSetup(desc, uint32(P), uint32(N), false, func(desc *ParFor, i uint32) {
 		data[i] = data[i]*data[i] + 1
 	})
 	for p := 1; p < P; p++ {