diff options
| author | Russ Cox <rsc@golang.org> | 2014-11-11 17:07:54 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2014-11-11 17:07:54 -0500 |
| commit | ece09790afb822fed2bd2e8ac3a803e5ccbb8e3a (patch) | |
| tree | 299d51628d4e8884dab448301320dee91ad20d54 /src/runtime/export_test.go | |
| parent | 580ef3e4afe6e31f21e21d3d0919d8a033071320 (diff) | |
| download | go-ece09790afb822fed2bd2e8ac3a803e5ccbb8e3a.tar.xz | |
[dev.cc] runtime: convert parallel support code from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.
[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]
LGTM=r
R=r, austin
CC=dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/172250043
Diffstat (limited to 'src/runtime/export_test.go')
| -rw-r--r-- | src/runtime/export_test.go | 72 |
1 files changed, 19 insertions, 53 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index be352557fb..0ecf91fdf8 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -34,21 +34,11 @@ func lfstackpush_m() func lfstackpop_m() func LFStackPush(head *uint64, node *LFNode) { - mp := acquirem() - mp.ptrarg[0] = unsafe.Pointer(head) - mp.ptrarg[1] = unsafe.Pointer(node) - onM(lfstackpush_m) - releasem(mp) + lfstackpush(head, (*lfnode)(unsafe.Pointer(node))) } func LFStackPop(head *uint64) *LFNode { - mp := acquirem() - mp.ptrarg[0] = unsafe.Pointer(head) - onM(lfstackpop_m) - node := (*LFNode)(unsafe.Pointer(mp.ptrarg[0])) - mp.ptrarg[0] = nil - releasem(mp) - return node + return (*LFNode)(unsafe.Pointer(lfstackpop(head))) } type ParFor struct { @@ -68,64 +58,44 @@ func parfordo_m() func parforiters_m() func NewParFor(nthrmax uint32) *ParFor { - mp := acquirem() - mp.scalararg[0] = uintptr(nthrmax) - onM(newparfor_m) - desc := (*ParFor)(mp.ptrarg[0]) - mp.ptrarg[0] = nil - releasem(mp) + var desc *ParFor + onM(func() { + desc = (*ParFor)(unsafe.Pointer(parforalloc(nthrmax))) + }) 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(funcPC(body)) // TODO(rsc): Should be a scalar. - mp.scalararg[0] = uintptr(nthr) - mp.scalararg[1] = uintptr(n) - mp.scalararg[2] = 0 - if wait { - mp.scalararg[2] = 1 - } - onM(parforsetup_m) - releasem(mp) + onM(func() { + parforsetup((*parfor)(unsafe.Pointer(desc)), nthr, n, unsafe.Pointer(ctx), wait, + *(*func(*parfor, uint32))(unsafe.Pointer(&body))) + }) } func ParForDo(desc *ParFor) { - mp := acquirem() - mp.ptrarg[0] = unsafe.Pointer(desc) - onM(parfordo_m) - releasem(mp) + onM(func() { + parfordo((*parfor)(unsafe.Pointer(desc))) + }) } func ParForIters(desc *ParFor, tid uint32) (uint32, uint32) { - mp := acquirem() - mp.ptrarg[0] = unsafe.Pointer(desc) - mp.scalararg[0] = uintptr(tid) - onM(parforiters_m) - begin := uint32(mp.scalararg[0]) - end := uint32(mp.scalararg[1]) - releasem(mp) - return begin, end + desc1 := (*parfor)(unsafe.Pointer(desc)) + pos := desc_thr_index(desc1, tid).pos + return uint32(pos), uint32(pos >> 32) } -// in mgc0.c -//go:noescape -func getgcmask(data unsafe.Pointer, typ *_type, array **byte, len *uint) - func GCMask(x interface{}) (ret []byte) { e := (*eface)(unsafe.Pointer(&x)) s := (*slice)(unsafe.Pointer(&ret)) onM(func() { - getgcmask(e.data, e._type, &s.array, &s.len) + var len uintptr + getgcmask(e.data, e._type, &s.array, &len) + s.len = uint(len) s.cap = s.len }) return } -func testSchedLocalQueue() -func testSchedLocalQueueSteal() func RunSchedLocalQueueTest() { onM(testSchedLocalQueue) } @@ -149,10 +119,6 @@ func GogoBytes() int32 { return _RuntimeGogoBytes } -// in string.c -//go:noescape -func gostringw(w *uint16) string - // entry point for testing func GostringW(w []uint16) (s string) { onM(func() { |
