// This may be racing with GC so do it atomically if there can be
// a race marking the bit.
if gcphase == _GCmarktermination || gcBlackenPromptly {
- systemstack(func() {
- gcmarknewobject_m(uintptr(x), size, scanSize)
- })
+ gcmarknewobject(uintptr(x), size, scanSize)
}
if raceenabled {
}
}
-// If gcBlackenPromptly is true we are in the second mark phase phase so we allocate black.
+// gcmarknewobject marks a newly allocated object black. obj must
+// not contain any non-nil pointers.
+//
+// This is nosplit so it can manipulate a gcWork without preemption.
+//
//go:nowritebarrier
-func gcmarknewobject_m(obj, size, scanSize uintptr) {
+//go:nosplit
+func gcmarknewobject(obj, size, scanSize uintptr) {
if useCheckmark && !gcBlackenPromptly { // The world should be stopped so this should not happen.
throw("gcmarknewobject called while doing checkmark")
}
heapBitsForAddr(obj).setMarked()
- atomic.Xadd64(&work.bytesMarked, int64(size))
gcw := &getg().m.p.ptr().gcw
+ gcw.bytesMarked += uint64(size)
gcw.scanWork += int64(scanSize)
}