Skip to content

Commit 2cc4173

Browse files
committed
runtime: mark {g,m,p}uintptr methods as nosplit
These are methods that are "obviously" going to get inlined -- until you build with -l, when they can trigger a stack split at a bad time. Fixes golang#11482 Change-Id: Ia065c385978a2e7fe9f587811991d088c4d68325
1 parent a7c09ad commit 2cc4173

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/runtime/runtime2.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,31 @@ func efaceOf(ep *interface{}) *eface {
122122
// alternate arena. Using guintptr doesn't make that problem any worse.
123123
type guintptr uintptr
124124

125-
func (gp guintptr) ptr() *g { return (*g)(unsafe.Pointer(gp)) }
125+
//go:nosplit
126+
func (gp guintptr) ptr() *g { return (*g)(unsafe.Pointer(gp)) }
127+
128+
//go:nosplit
126129
func (gp *guintptr) set(g *g) { *gp = guintptr(unsafe.Pointer(g)) }
130+
131+
//go:nosplit
127132
func (gp *guintptr) cas(old, new guintptr) bool {
128133
return atomic.Casuintptr((*uintptr)(unsafe.Pointer(gp)), uintptr(old), uintptr(new))
129134
}
130135

131136
type puintptr uintptr
132137

133-
func (pp puintptr) ptr() *p { return (*p)(unsafe.Pointer(pp)) }
138+
//go:nosplit
139+
func (pp puintptr) ptr() *p { return (*p)(unsafe.Pointer(pp)) }
140+
141+
//go:nosplit
134142
func (pp *puintptr) set(p *p) { *pp = puintptr(unsafe.Pointer(p)) }
135143

136144
type muintptr uintptr
137145

138-
func (mp muintptr) ptr() *m { return (*m)(unsafe.Pointer(mp)) }
146+
//go:nosplit
147+
func (mp muintptr) ptr() *m { return (*m)(unsafe.Pointer(mp)) }
148+
149+
//go:nosplit
139150
func (mp *muintptr) set(m *m) { *mp = muintptr(unsafe.Pointer(m)) }
140151

141152
type gobuf struct {

0 commit comments

Comments
 (0)