aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/export_test.go
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2014-08-24 11:47:06 +0400
committerDmitriy Vyukov <dvyukov@google.com>2014-08-24 11:47:06 +0400
commit98bebcc90a4e50e3fd458585744829f2065f2b09 (patch)
tree1049f9aa7c95df9087dbe3ff3aefc5a3e2dd13c7 /src/pkg/runtime/export_test.go
parent48452a276d63639f54d3ce1a8d36663e26949526 (diff)
downloadgo-98bebcc90a4e50e3fd458585744829f2065f2b09.tar.xz
runtime: convert parfor to Go
LGTM=rsc R=golang-codereviews, rsc CC=golang-codereviews, khr https://golang.org/cl/132100043
Diffstat (limited to 'src/pkg/runtime/export_test.go')
-rw-r--r--src/pkg/runtime/export_test.go54
1 files changed, 45 insertions, 9 deletions
diff --git a/src/pkg/runtime/export_test.go b/src/pkg/runtime/export_test.go
index 9d25cafebb..f75b742b61 100644
--- a/src/pkg/runtime/export_test.go
+++ b/src/pkg/runtime/export_test.go
@@ -66,18 +66,54 @@ type ParFor struct {
wait bool
}
-func newParFor(nthrmax uint32) *ParFor
-func parForSetup(desc *ParFor, nthr, n uint32, ctx *byte, wait bool, body func(*ParFor, uint32))
-func parForDo(desc *ParFor)
-func parForIters(desc *ParFor, tid uintptr) (uintptr, uintptr)
+var (
+ newparfor_m,
+ parforsetup_m,
+ parfordo_m,
+ parforiters_m mFunction
+)
+
+func NewParFor(nthrmax uint32) *ParFor {
+ mp := acquirem()
+ mp.scalararg[0] = uint(nthrmax)
+ onM(&newparfor_m)
+ desc := (*ParFor)(mp.ptrarg[0])
+ mp.ptrarg[0] = nil
+ releasem(mp)
+ return desc
+}
+
+func ParForSetup(desc *ParFor, nthr, n uint32, ctx *byte, wait bool, body func(*ParFor, uint32)) {
+ mp := acquirem()
+ mp.ptrarg[0] = unsafe.Pointer(desc)
+ mp.ptrarg[1] = unsafe.Pointer(ctx)
+ mp.ptrarg[2] = **(**unsafe.Pointer)(unsafe.Pointer(&body))
+ mp.scalararg[0] = uint(nthr)
+ mp.scalararg[1] = uint(n)
+ mp.scalararg[2] = 0
+ if wait {
+ mp.scalararg[2] = 1
+ }
+ onM(&parforsetup_m)
+ releasem(mp)
+}
-var NewParFor = newParFor
-var ParForSetup = parForSetup
-var ParForDo = parForDo
+func ParForDo(desc *ParFor) {
+ mp := acquirem()
+ mp.ptrarg[0] = unsafe.Pointer(desc)
+ onM(&parfordo_m)
+ releasem(mp)
+}
func ParForIters(desc *ParFor, tid uint32) (uint32, uint32) {
- begin, end := parForIters(desc, uintptr(tid))
- return uint32(begin), uint32(end)
+ mp := acquirem()
+ mp.ptrarg[0] = unsafe.Pointer(desc)
+ mp.scalararg[0] = uint(tid)
+ onM(&parforiters_m)
+ begin := uint32(mp.scalararg[0])
+ end := uint32(mp.scalararg[1])
+ releasem(mp)
+ return begin, end
}
//go:noescape