aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/export_test.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2015-01-28 15:25:05 -0500
committerAustin Clements <austin@google.com>2015-01-29 17:37:57 +0000
commit8e2bb7bb4ab8c15204a995e976ce7d023d0e37bf (patch)
tree627deef5f65a6ff86dc717848ac88a70573a1902 /src/runtime/export_test.go
parent6b7b0f9a0cc3d647af3494bfc716bb878211e97e (diff)
downloadgo-8e2bb7bb4ab8c15204a995e976ce7d023d0e37bf.tar.xz
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>
Diffstat (limited to 'src/runtime/export_test.go')
-rw-r--r--src/runtime/export_test.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go
index 016938ed4e..3b13b7bb38 100644
--- a/src/runtime/export_test.go
+++ b/src/runtime/export_test.go
@@ -36,14 +36,13 @@ func LFStackPop(head *uint64) *LFNode {
}
type ParFor struct {
- body *byte
- done uint32
- Nthr uint32
- nthrmax uint32
- thrseq uint32
- Cnt uint32
- Ctx *byte
- wait bool
+ body *byte
+ done uint32
+ Nthr uint32
+ thrseq uint32
+ Cnt uint32
+ Ctx *byte
+ wait bool
}
func NewParFor(nthrmax uint32) *ParFor {
@@ -69,7 +68,7 @@ func ParForDo(desc *ParFor) {
func ParForIters(desc *ParFor, tid uint32) (uint32, uint32) {
desc1 := (*parfor)(unsafe.Pointer(desc))
- pos := desc_thr_index(desc1, tid).pos
+ pos := desc1.thr[tid].pos
return uint32(pos), uint32(pos >> 32)
}