aboutsummaryrefslogtreecommitdiff
path: root/src/pkg
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-09-03 23:10:15 -0400
committerRuss Cox <rsc@golang.org>2014-09-03 23:10:15 -0400
commit93805d711ce1d489af032c617a1ae19ef07922e4 (patch)
tree9b36f9f61397d55aa0aa1a0670c5d6bd03f27673 /src/pkg
parentced0ba56289a5326332705a6617c10f3412cee0b (diff)
downloadgo-93805d711ce1d489af032c617a1ae19ef07922e4.tar.xz
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
Diffstat (limited to 'src/pkg')
-rw-r--r--src/pkg/runtime/lock_sema.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/pkg/runtime/lock_sema.go b/src/pkg/runtime/lock_sema.go
index e0476f3291..d136b82806 100644
--- a/src/pkg/runtime/lock_sema.go
+++ b/src/pkg/runtime/lock_sema.go
@@ -173,8 +173,13 @@ func notesleep(n *note) {
}
//go:nosplit
-func notetsleep_internal(n *note, ns int64) bool {
- gp := getg()
+func notetsleep_internal(n *note, ns int64, gp *g, deadline int64) bool {
+ // 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.
if !casuintptr(&n.key, 0, uintptr(unsafe.Pointer(gp.m))) {
// Must be locked (got wakeup).
@@ -190,7 +195,8 @@ func notetsleep_internal(n *note, ns int64) bool {
gp.m.blocked = false
return true
}
- deadline := nanotime() + ns
+
+ deadline = nanotime() + ns
for {
// Registered. Sleep.
gp.m.blocked = true
@@ -244,7 +250,7 @@ func notetsleep(n *note, ns int64) bool {
if gp.m.waitsema == 0 {
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)
@@ -258,7 +264,7 @@ func notetsleepg(n *note, ns int64) bool {
gp.m.waitsema = semacreate()
}
entersyscallblock()
- ok := notetsleep_internal(n, ns)
+ ok := notetsleep_internal(n, ns, nil, 0)
exitsyscall()
return ok
}