]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make m.nextwaitm an muintptr
authorAustin Clements <austin@google.com>
Thu, 15 Jun 2017 16:23:09 +0000 (12:23 -0400)
committerAustin Clements <austin@google.com>
Wed, 11 Oct 2017 17:47:10 +0000 (17:47 +0000)
This field is really a *m (modulo its bottom bit). Change it from
uintptr to muintptr to document this fact.

Change-Id: I2d181a955ef1d2c1a268edf20091b440d85726c9
Reviewed-on: https://go-review.googlesource.com/46034
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/lock_sema.go
src/runtime/runtime2.go

index 68fcb564af8bc0ee025832693719bbeb7af1fe73..b41f805cee57ee996cd3768ce6cb9eb782949569 100644 (file)
@@ -71,7 +71,7 @@ Loop:
                        // for this lock, chained through m->nextwaitm.
                        // Queue this M.
                        for {
-                               gp.m.nextwaitm = v &^ locked
+                               gp.m.nextwaitm = muintptr(v &^ locked)
                                if atomic.Casuintptr(&l.key, v, uintptr(unsafe.Pointer(gp.m))|locked) {
                                        break
                                }
@@ -103,8 +103,8 @@ func unlock(l *mutex) {
                } else {
                        // Other M's are waiting for the lock.
                        // Dequeue an M.
-                       mp = (*m)(unsafe.Pointer(v &^ locked))
-                       if atomic.Casuintptr(&l.key, v, mp.nextwaitm) {
+                       mp = muintptr(v &^ locked).ptr()
+                       if atomic.Casuintptr(&l.key, v, uintptr(mp.nextwaitm)) {
                                // Dequeued an M.  Wake it.
                                semawakeup(mp)
                                break
index 325152aea4c16f9b813a752ade93faa0aa29b9eb..3f99de65d563c11fbfa3af56f94c8a78e2831535 100644 (file)
@@ -432,7 +432,7 @@ type m struct {
        fflag         uint32         // floating point compare flags
        lockedExt     uint32         // tracking for external LockOSThread
        lockedInt     uint32         // tracking for internal lockOSThread
-       nextwaitm     uintptr        // next m waiting for lock
+       nextwaitm     muintptr       // next m waiting for lock
        waitunlockf   unsafe.Pointer // todo go func(*g, unsafe.pointer) bool
        waitlock      unsafe.Pointer
        waittraceev   byte