mirror of
https://github.com/golang/go
synced 2024-11-18 01:14:48 -07:00
runtime: shade stack-to-stack copy when starting a goroutine
The hybrid barrier requires barriers on stack-to-stack copies if either stack is grey. There are only two instances of this in the runtime: channel sends and starting a goroutine. Channel sends already use typedmemmove and hence have the necessary barriers. This commits adds barriers for the stack-to-stack copy when starting a goroutine. Updates #17503. Change-Id: Ibb55e08127ca4d021ac54be61cb96732efa5df5b Reviewed-on: https://go-review.googlesource.com/31455 Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
parent
0c0960a234
commit
ee785f03a2
@ -2810,7 +2810,20 @@ func newproc1(fn *funcval, argp *uint8, narg int32, nret int32, callerpc uintptr
|
||||
prepGoExitFrame(sp)
|
||||
spArg += sys.MinFrameSize
|
||||
}
|
||||
memmove(unsafe.Pointer(spArg), unsafe.Pointer(argp), uintptr(narg))
|
||||
if narg > 0 {
|
||||
memmove(unsafe.Pointer(spArg), unsafe.Pointer(argp), uintptr(narg))
|
||||
// This is a stack-to-stack copy. If write barriers
|
||||
// are enabled and the source stack is grey (the
|
||||
// destination is always black), then perform a
|
||||
// barrier copy.
|
||||
if writeBarrier.needed && !_g_.m.curg.gcscandone {
|
||||
f := findfunc(fn.fn)
|
||||
stkmap := (*stackmap)(funcdata(f, _FUNCDATA_ArgsPointerMaps))
|
||||
// We're in the prologue, so it's always stack map index 0.
|
||||
bv := stackmapdata(stkmap, 0)
|
||||
bulkBarrierBitmap(spArg, uintptr(narg), 0, bv.bytedata)
|
||||
}
|
||||
}
|
||||
|
||||
memclrNoHeapPointers(unsafe.Pointer(&newg.sched), unsafe.Sizeof(newg.sched))
|
||||
newg.sched.sp = sp
|
||||
|
Loading…
Reference in New Issue
Block a user