Change-Id: Icb6d9ca996b4119d8636d9f7f6a56e510d74d059
GitHub-Last-Rev:
08178e8ff798f4a51860573788c9347a0fb6bc40
GitHub-Pull-Request: golang/go#66188
Reviewed-on: https://go-review.googlesource.com/c/go/+/569979
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
tmpbuf = (*[1 << 30]byte)(p)[:n]
}
// Convert heap bitmap to pointer bitmap.
- for i := uintptr(0); i < nptr/8+1; i++ {
- tmpbuf[i] = 0
- }
+ clear(tmpbuf[:nptr/8+1])
if goexperiment.AllocHeaders {
s := spanOf(p)
tp := s.typePointersOf(p, size)
arena.checkmarks = bitmap
} else {
// Otherwise clear the existing bitmap.
- for i := range bitmap.b {
- bitmap.b[i] = 0
- }
+ clear(bitmap.b[:])
}
}
// Enable checkmarking.
unlock(&mheap_.lock)
for _, ai := range arenas {
ha := mheap_.arenas[ai.l1()][ai.l2()]
- for i := range ha.pageMarks {
- ha.pageMarks[i] = 0
- }
+ clear(ha.pageMarks[:])
}
work.bytesMarked = 0
// either totally allocated or freed.
whole := p.summary[len(p.summary)-1][sc+1 : ec]
if alloc {
- // Should optimize into a memclr.
- for i := range whole {
- whole[i] = 0
- }
+ clear(whole)
} else {
for i := range whole {
whole[i] = freeChunkSum
_ = b[j/64]
// Clear leading bits.
b[i/64] &^= ^uint64(0) << (i % 64)
- for k := i/64 + 1; k < j/64; k++ {
- b[k] = 0
- }
+ clear(b[i/64+1 : j/64])
// Clear trailing bits.
b[j/64] &^= (uint64(1) << (j%64 + 1)) - 1
}
// clearAll frees all the bits of b.
func (b *pageBits) clearAll() {
- for i := range b {
- b[i] = 0
- }
+ clear(b[:])
}
// clearBlock64 clears the 64-bit aligned block of bits containing the i'th bit that
asanwrite(unsafe.Pointer(&r.Stack0[0]), unsafe.Sizeof(r.Stack0))
}
copy(r.Stack0[:], b.stk())
- for i := int(b.nstk); i < len(r.Stack0); i++ {
- r.Stack0[i] = 0
- }
+ clear(r.Stack0[b.nstk:])
}
func iterate_memprof(fn func(*bucket, uintptr, *uintptr, uintptr, uintptr, uintptr)) {
asanwrite(unsafe.Pointer(&r.Stack0[0]), unsafe.Sizeof(r.Stack0))
}
i := copy(r.Stack0[:], b.stk())
- for ; i < len(r.Stack0); i++ {
- r.Stack0[i] = 0
- }
+ clear(r.Stack0[i:])
p = p[1:]
}
}
r.Count = int64(bp.count)
r.Cycles = bp.cycles
i := copy(r.Stack0[:], b.stk())
- for ; i < len(r.Stack0); i++ {
- r.Stack0[i] = 0
- }
+ clear(r.Stack0[i:])
p = p[1:]
}
}
data[0] = uint64(2 + b.hdrsize + uintptr(len(stk))) // length
data[1] = uint64(now) // time stamp
// header, zero-padded
- i := uintptr(copy(data[2:2+b.hdrsize], hdr))
- for ; i < b.hdrsize; i++ {
- data[2+i] = 0
- }
+ i := copy(data[2:2+b.hdrsize], hdr)
+ clear(data[2+i : 2+b.hdrsize])
for i, pc := range stk {
data[2+b.hdrsize+uintptr(i)] = uint64(pc)
}
dst := b.overflowBuf
dst[0] = uint64(2 + b.hdrsize + 1)
dst[1] = time
- for i := uintptr(0); i < b.hdrsize; i++ {
- dst[2+i] = 0
- }
+ clear(dst[2 : 2+b.hdrsize])
dst[2+b.hdrsize] = uint64(count)
return dst[:2+b.hdrsize+1], overflowTag[:1], false
}