mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: simplify mallocgc flag argument
mallocgc can calculate noscan itself. The only remaining flag argument is needzero, so we just make that a boolean arg. Fixes #15379 Change-Id: I839a70790b2a0c9dbcee2600052bfbd6c8148e20 Reviewed-on: https://go-review.googlesource.com/22290 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
731531980a
commit
001e8e8070
8 changed files with 23 additions and 54 deletions
|
|
@ -43,7 +43,6 @@ func makeslice(et *_type, len64, cap64 int64) slice {
|
|||
// when someone does make([]T, bignumber). 'cap out of range' is true too,
|
||||
// but since the cap is only being supplied implicitly, saying len is clearer.
|
||||
// See issue 4085.
|
||||
|
||||
maxElements := maxSliceCap(et.size)
|
||||
len := int(len64)
|
||||
if len64 < 0 || int64(len) != len64 || uintptr(len) > maxElements {
|
||||
|
|
@ -55,11 +54,7 @@ func makeslice(et *_type, len64, cap64 int64) slice {
|
|||
panic(errorString("makeslice: cap out of range"))
|
||||
}
|
||||
|
||||
var flags uint32
|
||||
if et.kind&kindNoPointers != 0 {
|
||||
flags = flagNoScan
|
||||
}
|
||||
p := mallocgc(et.size*uintptr(cap), et, flags)
|
||||
p := mallocgc(et.size*uintptr(cap), et, true)
|
||||
return slice{p, len, cap}
|
||||
}
|
||||
|
||||
|
|
@ -128,12 +123,12 @@ func growslice(et *_type, old slice, cap int) slice {
|
|||
|
||||
var p unsafe.Pointer
|
||||
if et.kind&kindNoPointers != 0 {
|
||||
p = rawmem(capmem)
|
||||
p = mallocgc(capmem, nil, false)
|
||||
memmove(p, old.array, lenmem)
|
||||
memclr(add(p, lenmem), capmem-lenmem)
|
||||
} else {
|
||||
// Note: can't use rawmem (which avoids zeroing of memory), because then GC can scan uninitialized memory.
|
||||
p = mallocgc(capmem, et, 0)
|
||||
p = mallocgc(capmem, et, true)
|
||||
if !writeBarrier.enabled {
|
||||
memmove(p, old.array, lenmem)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue