mirror of
https://github.com/golang/go.git
synced 2026-06-28 03:40:37 +00:00
runtime: always call slowpath for heap bits in span
This allows us to avoid calling mallocgcSmallScanNoHeader when sizespecializedmalloc is enabled, reducing binary size. Change-Id: I16b98bac06eccd42b3c146f3b829aae96a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/780700 Auto-Submit: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
5a1c0ee6de
commit
dd1da37fa4
1 changed files with 22 additions and 14 deletions
|
|
@ -1076,17 +1076,29 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
|
|||
return unsafe.Pointer(&zerobase)
|
||||
}
|
||||
|
||||
if sizeSpecializedMallocEnabled && size < uintptr(len(mallocNoScanTable)) {
|
||||
if typ == nil || !typ.Pointers() {
|
||||
if size >= maxTinySize {
|
||||
return mallocNoScanTable[size](size, typ, needzero)
|
||||
if sizeSpecializedMallocEnabled {
|
||||
if size < uintptr(len(mallocNoScanTable)) {
|
||||
if typ == nil || !typ.Pointers() {
|
||||
if size >= maxTinySize {
|
||||
return mallocNoScanTable[size](size, typ, needzero)
|
||||
}
|
||||
return mallocgcTinySC2(size, typ, needzero)
|
||||
} else {
|
||||
if !needzero {
|
||||
throw("objects with pointers must be zeroed")
|
||||
}
|
||||
return mallocScanTable[size](size, typ, needzero)
|
||||
}
|
||||
return mallocgcTinySC2(size, typ, needzero)
|
||||
} else {
|
||||
if !needzero {
|
||||
throw("objects with pointers must be zeroed")
|
||||
}
|
||||
if heapBitsInSpan(size) {
|
||||
noscan := typ == nil || !typ.Pointers()
|
||||
sc := gc.SizeToSizeClass8[divRoundUp(size, gc.SmallSizeDiv)]
|
||||
elemsize := uintptr(gc.SizeClassToSize[sc])
|
||||
spc := makeSpanClass(sc, noscan)
|
||||
if noscan {
|
||||
return mallocgcSmallNoScanSlowPath(size, typ, needzero, spc, elemsize)
|
||||
}
|
||||
return mallocScanTable[size](size, typ, needzero)
|
||||
return mallocgcSmallScanSlowPath(size, typ, needzero, spc, elemsize)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1127,11 +1139,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
|
|||
if !needzero {
|
||||
throw("objects with pointers must be zeroed")
|
||||
}
|
||||
if heapBitsInSpan(size) {
|
||||
x, elemsize = mallocgcSmallScanNoHeader(size, typ)
|
||||
} else {
|
||||
x, elemsize = mallocgcSmallScanHeader(size, typ)
|
||||
}
|
||||
x, elemsize = mallocgcSmallScanHeader(size, typ)
|
||||
}
|
||||
} else {
|
||||
x, elemsize = mallocgcLarge(size, typ, needzero)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue