]> Cypherpunks repositories - gostls13.git/commit
runtime: use threads slice in parfor instead of unsafe pointer math
authorAustin Clements <austin@google.com>
Wed, 28 Jan 2015 20:25:05 +0000 (15:25 -0500)
committerAustin Clements <austin@google.com>
Thu, 29 Jan 2015 17:37:57 +0000 (17:37 +0000)
commit8e2bb7bb4ab8c15204a995e976ce7d023d0e37bf
tree627deef5f65a6ff86dc717848ac88a70573a1902
parent6b7b0f9a0cc3d647af3494bfc716bb878211e97e
runtime: use threads slice in parfor instead of unsafe pointer math

parfor originally used a tail array for its thread array.  This got
replaced with a slice allocation in the conversion to Go, but many of
its gnarlier effects remained.  Instead of keeping track of the
pointer to the first element of the slice and using unsafe pointer
math to get at the ith element, just keep the slice around and use
regular slice indexing.  There is no longer any need for padding to
64-bit align the tail array (there hasn't been since the Go
conversion), so remove this unnecessary padding from the parfor
struct.  Finally, since the slice tracks its own length, replace the
nthrmax field with len(thr).

Change-Id: I0020a1815849bca53e3613a8fa46ae4fbae67576
Reviewed-on: https://go-review.googlesource.com/3394
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/export_test.go
src/runtime/parfor.go