Commit 93805d71 authored by Russ Cox's avatar Russ Cox

runtime: give 2 words back in notetsleep_internal

I really hoped we could avoid this nonsense, but it appears not.

Should fix windows/amd64 build breakage.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/137120043
parent ced0ba56
...@@ -173,8 +173,13 @@ func notesleep(n *note) { ...@@ -173,8 +173,13 @@ func notesleep(n *note) {
} }
//go:nosplit //go:nosplit
func notetsleep_internal(n *note, ns int64) bool { func notetsleep_internal(n *note, ns int64, gp *g, deadline int64) bool {
gp := getg() // gp and deadline are logically local variables, but they are written
// as parameters so that the stack space they require is charged
// to the caller.
// This reduces the nosplit footprint of notetsleep_internal.
gp = getg()
// Register for wakeup on n->waitm. // Register for wakeup on n->waitm.
if !casuintptr(&n.key, 0, uintptr(unsafe.Pointer(gp.m))) { if !casuintptr(&n.key, 0, uintptr(unsafe.Pointer(gp.m))) {
// Must be locked (got wakeup). // Must be locked (got wakeup).
...@@ -190,7 +195,8 @@ func notetsleep_internal(n *note, ns int64) bool { ...@@ -190,7 +195,8 @@ func notetsleep_internal(n *note, ns int64) bool {
gp.m.blocked = false gp.m.blocked = false
return true return true
} }
deadline := nanotime() + ns
deadline = nanotime() + ns
for { for {
// Registered. Sleep. // Registered. Sleep.
gp.m.blocked = true gp.m.blocked = true
...@@ -244,7 +250,7 @@ func notetsleep(n *note, ns int64) bool { ...@@ -244,7 +250,7 @@ func notetsleep(n *note, ns int64) bool {
if gp.m.waitsema == 0 { if gp.m.waitsema == 0 {
gp.m.waitsema = semacreate() gp.m.waitsema = semacreate()
} }
return notetsleep_internal(n, ns) return notetsleep_internal(n, ns, nil, 0)
} }
// same as runtime·notetsleep, but called on user g (not g0) // same as runtime·notetsleep, but called on user g (not g0)
...@@ -258,7 +264,7 @@ func notetsleepg(n *note, ns int64) bool { ...@@ -258,7 +264,7 @@ func notetsleepg(n *note, ns int64) bool {
gp.m.waitsema = semacreate() gp.m.waitsema = semacreate()
} }
entersyscallblock() entersyscallblock()
ok := notetsleep_internal(n, ns) ok := notetsleep_internal(n, ns, nil, 0)
exitsyscall() exitsyscall()
return ok return ok
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment