Skip to content

Commit 93805d7

Browse files
committed
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
1 parent ced0ba5 commit 93805d7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/pkg/runtime/lock_sema.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,13 @@ func notesleep(n *note) {
173173
}
174174

175175
//go:nosplit
176-
func notetsleep_internal(n *note, ns int64) bool {
177-
gp := getg()
176+
func notetsleep_internal(n *note, ns int64, gp *g, deadline int64) bool {
177+
// gp and deadline are logically local variables, but they are written
178+
// as parameters so that the stack space they require is charged
179+
// to the caller.
180+
// This reduces the nosplit footprint of notetsleep_internal.
181+
gp = getg()
182+
178183
// Register for wakeup on n->waitm.
179184
if !casuintptr(&n.key, 0, uintptr(unsafe.Pointer(gp.m))) {
180185
// Must be locked (got wakeup).
@@ -190,7 +195,8 @@ func notetsleep_internal(n *note, ns int64) bool {
190195
gp.m.blocked = false
191196
return true
192197
}
193-
deadline := nanotime() + ns
198+
199+
deadline = nanotime() + ns
194200
for {
195201
// Registered. Sleep.
196202
gp.m.blocked = true
@@ -244,7 +250,7 @@ func notetsleep(n *note, ns int64) bool {
244250
if gp.m.waitsema == 0 {
245251
gp.m.waitsema = semacreate()
246252
}
247-
return notetsleep_internal(n, ns)
253+
return notetsleep_internal(n, ns, nil, 0)
248254
}
249255

250256
// same as runtime·notetsleep, but called on user g (not g0)
@@ -258,7 +264,7 @@ func notetsleepg(n *note, ns int64) bool {
258264
gp.m.waitsema = semacreate()
259265
}
260266
entersyscallblock()
261-
ok := notetsleep_internal(n, ns)
267+
ok := notetsleep_internal(n, ns, nil, 0)
262268
exitsyscall()
263269
return ok
264270
}

0 commit comments

Comments
 (0)