From: Russ Cox Date: Thu, 4 Sep 2014 03:10:15 +0000 (-0400) Subject: runtime: give 2 words back in notetsleep_internal X-Git-Tag: go1.4beta1~553 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=93805d711ce1d489af032c617a1ae19ef07922e4;p=gostls13.git 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 --- 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 }