package runtime
import (
)
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(1<<1) | spanClass(0)
const = uintptr(8)
return mallocgcSmallScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 1
const = 8
if doubleCheckMalloc {
doubleCheckSmallScanNoHeader(, , )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(0)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if .needzero != 0 {
memclrNoHeapPointers(, )
}
if goarch.PtrSize == 8 && == 8 {
.scanAlloc += 8
} else {
:=
:= uintptr()
if doubleCheckHeapSetType && (!heapBitsInSpan() || !heapBitsInSpan(8)) {
throw("tried to write heap bits, but no heap bits in span")
}
:= readUintptr(getGCMask())
const = 8
var uintptr
:=
if .Size_ == goarch.PtrSize {
= (1 << ( / goarch.PtrSize)) - 1
=
} else {
if doubleCheckHeapSetType && !asanenabled && %.Size_ != 0 {
throw("runtime: (*mspan).writeHeapBitsSmall: dataSize is not a multiple of typ.Size_")
}
= .PtrBytes
for := .Size_; < ; += .Size_ {
|= << ( / goarch.PtrSize)
+= .Size_
}
}
, := spanHeapBitsRange(.base(), pageSize, )
:= unsafe.Pointer()
:= ( - .base()) / goarch.PtrSize
:= / ptrBits
:= % ptrBits
var uintptr = / goarch.PtrSize
var = &(-1) == 0
if > ptrBits || (! && + > ptrBits) {
:= ptrBits -
:= -
:= (*uintptr)(add(, (+0)*goarch.PtrSize))
:= (*uintptr)(add(, (+1)*goarch.PtrSize))
* = (*)&(^uintptr(0)>>) | ( << )
* = (*)&^((1<<)-1) | ( >> )
} else {
:= (*uintptr)(add(, *goarch.PtrSize))
* = (*)&^(((1<<(min(, ptrBits)))-1)<<) | ( << )
}
const = false
if {
writeHeapBitsDoubleCheck(, , , , , , , , )
}
if doubleCheckHeapSetType {
doubleCheckHeapType(, , , nil, )
}
.scanAlloc +=
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(2<<1) | spanClass(0)
const = uintptr(16)
return mallocgcSmallScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 2
const = 16
if doubleCheckMalloc {
doubleCheckSmallScanNoHeader(, , )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(0)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if .needzero != 0 {
memclrNoHeapPointers(, )
}
if goarch.PtrSize == 8 && == 8 {
.scanAlloc += 8
} else {
:=
:= uintptr()
if doubleCheckHeapSetType && (!heapBitsInSpan() || !heapBitsInSpan(16)) {
throw("tried to write heap bits, but no heap bits in span")
}
:= readUintptr(getGCMask())
const = 16
var uintptr
:=
if .Size_ == goarch.PtrSize {
= (1 << ( / goarch.PtrSize)) - 1
=
} else {
if doubleCheckHeapSetType && !asanenabled && %.Size_ != 0 {
throw("runtime: (*mspan).writeHeapBitsSmall: dataSize is not a multiple of typ.Size_")
}
= .PtrBytes
for := .Size_; < ; += .Size_ {
|= << ( / goarch.PtrSize)
+= .Size_
}
}
, := spanHeapBitsRange(.base(), pageSize, )
:= unsafe.Pointer()
:= ( - .base()) / goarch.PtrSize
:= / ptrBits
:= % ptrBits
var uintptr = / goarch.PtrSize
var = &(-1) == 0
if > ptrBits || (! && + > ptrBits) {
:= ptrBits -
:= -
:= (*uintptr)(add(, (+0)*goarch.PtrSize))
:= (*uintptr)(add(, (+1)*goarch.PtrSize))
* = (*)&(^uintptr(0)>>) | ( << )
* = (*)&^((1<<)-1) | ( >> )
} else {
:= (*uintptr)(add(, *goarch.PtrSize))
* = (*)&^(((1<<(min(, ptrBits)))-1)<<) | ( << )
}
const = false
if {
writeHeapBitsDoubleCheck(, , , , , , , , )
}
if doubleCheckHeapSetType {
doubleCheckHeapType(, , , nil, )
}
.scanAlloc +=
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(3<<1) | spanClass(0)
const = uintptr(24)
return mallocgcSmallScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 3
const = 24
if doubleCheckMalloc {
doubleCheckSmallScanNoHeader(, , )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(0)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if .needzero != 0 {
memclrNoHeapPointers(, )
}
if goarch.PtrSize == 8 && == 8 {
.scanAlloc += 8
} else {
:=
:= uintptr()
if doubleCheckHeapSetType && (!heapBitsInSpan() || !heapBitsInSpan(24)) {
throw("tried to write heap bits, but no heap bits in span")
}
:= readUintptr(getGCMask())
const = 24
var uintptr
:=
if .Size_ == goarch.PtrSize {
= (1 << ( / goarch.PtrSize)) - 1
=
} else {
if doubleCheckHeapSetType && !asanenabled && %.Size_ != 0 {
throw("runtime: (*mspan).writeHeapBitsSmall: dataSize is not a multiple of typ.Size_")
}
= .PtrBytes
for := .Size_; < ; += .Size_ {
|= << ( / goarch.PtrSize)
+= .Size_
}
}
, := spanHeapBitsRange(.base(), pageSize, )
:= unsafe.Pointer()
:= ( - .base()) / goarch.PtrSize
:= / ptrBits
:= % ptrBits
var uintptr = / goarch.PtrSize
var = &(-1) == 0
if > ptrBits || (! && + > ptrBits) {
:= ptrBits -
:= -
:= (*uintptr)(add(, (+0)*goarch.PtrSize))
:= (*uintptr)(add(, (+1)*goarch.PtrSize))
* = (*)&(^uintptr(0)>>) | ( << )
* = (*)&^((1<<)-1) | ( >> )
} else {
:= (*uintptr)(add(, *goarch.PtrSize))
* = (*)&^(((1<<(min(, ptrBits)))-1)<<) | ( << )
}
const = false
if {
writeHeapBitsDoubleCheck(, , , , , , , , )
}
if doubleCheckHeapSetType {
doubleCheckHeapType(, , , nil, )
}
.scanAlloc +=
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(4<<1) | spanClass(0)
const = uintptr(32)
return mallocgcSmallScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 4
const = 32
if doubleCheckMalloc {
doubleCheckSmallScanNoHeader(, , )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(0)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if .needzero != 0 {
memclrNoHeapPointers(, )
}
if goarch.PtrSize == 8 && == 8 {
.scanAlloc += 8
} else {
:=
:= uintptr()
if doubleCheckHeapSetType && (!heapBitsInSpan() || !heapBitsInSpan(32)) {
throw("tried to write heap bits, but no heap bits in span")
}
:= readUintptr(getGCMask())
const = 32
var uintptr
:=
if .Size_ == goarch.PtrSize {
= (1 << ( / goarch.PtrSize)) - 1
=
} else {
if doubleCheckHeapSetType && !asanenabled && %.Size_ != 0 {
throw("runtime: (*mspan).writeHeapBitsSmall: dataSize is not a multiple of typ.Size_")
}
= .PtrBytes
for := .Size_; < ; += .Size_ {
|= << ( / goarch.PtrSize)
+= .Size_
}
}
, := spanHeapBitsRange(.base(), pageSize, )
:= unsafe.Pointer()
:= ( - .base()) / goarch.PtrSize
:= / ptrBits
:= % ptrBits
var uintptr = / goarch.PtrSize
var = &(-1) == 0
if > ptrBits || (! && + > ptrBits) {
:= ptrBits -
:= -
:= (*uintptr)(add(, (+0)*goarch.PtrSize))
:= (*uintptr)(add(, (+1)*goarch.PtrSize))
* = (*)&(^uintptr(0)>>) | ( << )
* = (*)&^((1<<)-1) | ( >> )
} else {
:= (*uintptr)(add(, *goarch.PtrSize))
* = (*)&^(((1<<(min(, ptrBits)))-1)<<) | ( << )
}
const = false
if {
writeHeapBitsDoubleCheck(, , , , , , , , )
}
if doubleCheckHeapSetType {
doubleCheckHeapType(, , , nil, )
}
.scanAlloc +=
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(5<<1) | spanClass(0)
const = uintptr(48)
return mallocgcSmallScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 5
const = 48
if doubleCheckMalloc {
doubleCheckSmallScanNoHeader(, , )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(0)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if .needzero != 0 {
memclrNoHeapPointers(, )
}
if goarch.PtrSize == 8 && == 8 {
.scanAlloc += 8
} else {
:=
:= uintptr()
if doubleCheckHeapSetType && (!heapBitsInSpan() || !heapBitsInSpan(48)) {
throw("tried to write heap bits, but no heap bits in span")
}
:= readUintptr(getGCMask())
const = 48
var uintptr
:=
if .Size_ == goarch.PtrSize {
= (1 << ( / goarch.PtrSize)) - 1
=
} else {
if doubleCheckHeapSetType && !asanenabled && %.Size_ != 0 {
throw("runtime: (*mspan).writeHeapBitsSmall: dataSize is not a multiple of typ.Size_")
}
= .PtrBytes
for := .Size_; < ; += .Size_ {
|= << ( / goarch.PtrSize)
+= .Size_
}
}
, := spanHeapBitsRange(.base(), pageSize, )
:= unsafe.Pointer()
:= ( - .base()) / goarch.PtrSize
:= / ptrBits
:= % ptrBits
var uintptr = / goarch.PtrSize
var = &(-1) == 0
if > ptrBits || (! && + > ptrBits) {
:= ptrBits -
:= -
:= (*uintptr)(add(, (+0)*goarch.PtrSize))
:= (*uintptr)(add(, (+1)*goarch.PtrSize))
* = (*)&(^uintptr(0)>>) | ( << )
* = (*)&^((1<<)-1) | ( >> )
} else {
:= (*uintptr)(add(, *goarch.PtrSize))
* = (*)&^(((1<<(min(, ptrBits)))-1)<<) | ( << )
}
const = false
if {
writeHeapBitsDoubleCheck(, , , , , , , , )
}
if doubleCheckHeapSetType {
doubleCheckHeapType(, , , nil, )
}
.scanAlloc +=
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(6<<1) | spanClass(0)
const = uintptr(64)
return mallocgcSmallScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 6
const = 64
if doubleCheckMalloc {
doubleCheckSmallScanNoHeader(, , )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(0)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if .needzero != 0 {
memclrNoHeapPointers(, )
}
if goarch.PtrSize == 8 && == 8 {
.scanAlloc += 8
} else {
:=
:= uintptr()
if doubleCheckHeapSetType && (!heapBitsInSpan() || !heapBitsInSpan(64)) {
throw("tried to write heap bits, but no heap bits in span")
}
:= readUintptr(getGCMask())
const = 64
var uintptr
:=
if .Size_ == goarch.PtrSize {
= (1 << ( / goarch.PtrSize)) - 1
=
} else {
if doubleCheckHeapSetType && !asanenabled && %.Size_ != 0 {
throw("runtime: (*mspan).writeHeapBitsSmall: dataSize is not a multiple of typ.Size_")
}
= .PtrBytes
for := .Size_; < ; += .Size_ {
|= << ( / goarch.PtrSize)
+= .Size_
}
}
, := spanHeapBitsRange(.base(), pageSize, )
:= unsafe.Pointer()
:= ( - .base()) / goarch.PtrSize
:= / ptrBits
:= % ptrBits
var uintptr = / goarch.PtrSize
var = &(-1) == 0
if > ptrBits || (! && + > ptrBits) {
:= ptrBits -
:= -
:= (*uintptr)(add(, (+0)*goarch.PtrSize))
:= (*uintptr)(add(, (+1)*goarch.PtrSize))
* = (*)&(^uintptr(0)>>) | ( << )
* = (*)&^((1<<)-1) | ( >> )
} else {
:= (*uintptr)(add(, *goarch.PtrSize))
* = (*)&^(((1<<(min(, ptrBits)))-1)<<) | ( << )
}
const = false
if {
writeHeapBitsDoubleCheck(, , , , , , , , )
}
if doubleCheckHeapSetType {
doubleCheckHeapType(, , , nil, )
}
.scanAlloc +=
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(7<<1) | spanClass(0)
const = uintptr(80)
return mallocgcSmallScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 7
const = 80
if doubleCheckMalloc {
doubleCheckSmallScanNoHeader(, , )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(0)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if .needzero != 0 {
memclrNoHeapPointers(, )
}
if goarch.PtrSize == 8 && == 8 {
.scanAlloc += 8
} else {
:=
:= uintptr()
if doubleCheckHeapSetType && (!heapBitsInSpan() || !heapBitsInSpan(80)) {
throw("tried to write heap bits, but no heap bits in span")
}
:= readUintptr(getGCMask())
const = 80
var uintptr
:=
if .Size_ == goarch.PtrSize {
= (1 << ( / goarch.PtrSize)) - 1
=
} else {
if doubleCheckHeapSetType && !asanenabled && %.Size_ != 0 {
throw("runtime: (*mspan).writeHeapBitsSmall: dataSize is not a multiple of typ.Size_")
}
= .PtrBytes
for := .Size_; < ; += .Size_ {
|= << ( / goarch.PtrSize)
+= .Size_
}
}
, := spanHeapBitsRange(.base(), pageSize, )
:= unsafe.Pointer()
:= ( - .base()) / goarch.PtrSize
:= / ptrBits
:= % ptrBits
var uintptr = / goarch.PtrSize
var = &(-1) == 0
if > ptrBits || (! && + > ptrBits) {
:= ptrBits -
:= -
:= (*uintptr)(add(, (+0)*goarch.PtrSize))
:= (*uintptr)(add(, (+1)*goarch.PtrSize))
* = (*)&(^uintptr(0)>>) | ( << )
* = (*)&^((1<<)-1) | ( >> )
} else {
:= (*uintptr)(add(, *goarch.PtrSize))
* = (*)&^(((1<<(min(, ptrBits)))-1)<<) | ( << )
}
const = false
if {
writeHeapBitsDoubleCheck(, , , , , , , , )
}
if doubleCheckHeapSetType {
doubleCheckHeapType(, , , nil, )
}
.scanAlloc +=
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
return mallocgcTinySlowPath(, , )
}
lockRankMayQueueFinalizer()
const = 16
if doubleCheckMalloc {
doubleCheckTiny(, , )
}
.mallocing = 1
:= getMCache()
:= .tinyoffset
if &7 == 0 {
= alignUp(, 8)
} else if goarch.PtrSize == 4 && == 12 {
= alignUp(, 8)
} else if &3 == 0 {
= alignUp(, 4)
} else if &1 == 0 {
= alignUp(, 2)
}
if + <= maxTinySize && .tiny != 0 {
:= unsafe.Pointer(.tiny + )
.tinyoffset = +
.tinyAllocs++
.mallocing = 0
releasem()
const = 0
return
}
:= false
:= .alloc[tinySpanClass]
const = 8192
const = uint16(( - unsafe.Sizeof(spanInlineMarkBits{})) / 16)
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < {
:= + 1
if !(%64 == 0 && != ) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()*16 + .base())
}
}
}
:=
if == 0 {
, , = .nextFree(tinySpanClass)
}
:= unsafe.Pointer()
(*[2]uint64)()[0] = 0
(*[2]uint64)()[1] = 0
if !raceenabled && ( < .tinyoffset || .tiny == 0) {
.tiny = uintptr()
.tinyoffset =
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(2<<1) | spanClass(1)
const = uintptr(16)
return mallocgcSmallNoScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 2
const = 16
if doubleCheckMalloc {
doubleCheckSmallNoScan(, )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(1)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
if runtimeFreegcEnabled && .hasReusableNoscan() {
= mallocgcSmallNoscanReuse(, , , , )
.mallocing = 0
releasem()
return
}
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if && .needzero != 0 {
memclrNoHeapPointers(, )
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(3<<1) | spanClass(1)
const = uintptr(24)
return mallocgcSmallNoScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 3
const = 24
if doubleCheckMalloc {
doubleCheckSmallNoScan(, )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(1)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
if runtimeFreegcEnabled && .hasReusableNoscan() {
= mallocgcSmallNoscanReuse(, , , , )
.mallocing = 0
releasem()
return
}
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if && .needzero != 0 {
memclrNoHeapPointers(, )
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(4<<1) | spanClass(1)
const = uintptr(32)
return mallocgcSmallNoScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 4
const = 32
if doubleCheckMalloc {
doubleCheckSmallNoScan(, )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(1)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
if runtimeFreegcEnabled && .hasReusableNoscan() {
= mallocgcSmallNoscanReuse(, , , , )
.mallocing = 0
releasem()
return
}
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if && .needzero != 0 {
memclrNoHeapPointers(, )
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(5<<1) | spanClass(1)
const = uintptr(48)
return mallocgcSmallNoScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 5
const = 48
if doubleCheckMalloc {
doubleCheckSmallNoScan(, )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(1)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
if runtimeFreegcEnabled && .hasReusableNoscan() {
= mallocgcSmallNoscanReuse(, , , , )
.mallocing = 0
releasem()
return
}
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if && .needzero != 0 {
memclrNoHeapPointers(, )
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(6<<1) | spanClass(1)
const = uintptr(64)
return mallocgcSmallNoScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 6
const = 64
if doubleCheckMalloc {
doubleCheckSmallNoScan(, )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(1)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
if runtimeFreegcEnabled && .hasReusableNoscan() {
= mallocgcSmallNoscanReuse(, , , , )
.mallocing = 0
releasem()
return
}
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if && .needzero != 0 {
memclrNoHeapPointers(, )
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
= acquirem()
:= debug.malloc || gcBlackenEnabled != 0 || (goexperiment.RuntimeSecret && getg().secret > 0)
if {
releasem()
const = spanClass(7<<1) | spanClass(1)
const = uintptr(80)
return mallocgcSmallNoScanSlowPath(, , , , )
}
lockRankMayQueueFinalizer()
const = 7
const = 80
if doubleCheckMalloc {
doubleCheckSmallNoScan(, )
}
.mallocing = 1
:= false
:= getMCache()
const = spanClass(<<1) | spanClass(1)
:= .alloc[]
var gclinkptr
var unsafe.Pointer
if runtimeFreegcEnabled && .hasReusableNoscan() {
= mallocgcSmallNoscanReuse(, , , , )
.mallocing = 0
releasem()
return
}
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if && .needzero != 0 {
memclrNoHeapPointers(, )
}
publicationBarrier()
.freeIndexForScan = .freeindex
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
return
}
func ( uintptr, *_type, bool) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
:= getg()
if goexperiment.RuntimeSecret && .secret > 0 {
return mallocgcSmallNoScanSC2(, , )
}
lockRankMayQueueFinalizer()
if debug.malloc {
if := preMallocgcDebug(, ); != nil {
return
}
}
if gcBlackenEnabled != 0 {
:= getg()
if .m.curg != nil {
= .m.curg
}
.gcAssistBytes -= int64()
if .gcAssistBytes < 0 {
gcAssistAlloc()
}
}
= acquirem()
const = 16
if doubleCheckMalloc {
doubleCheckTiny(, , )
}
.mallocing = 1
:= getMCache()
:= .tinyoffset
if &7 == 0 {
= alignUp(, 8)
} else if goarch.PtrSize == 4 && == 12 {
= alignUp(, 8)
} else if &3 == 0 {
= alignUp(, 4)
} else if &1 == 0 {
= alignUp(, 2)
}
if + <= maxTinySize && .tiny != 0 {
:= unsafe.Pointer(.tiny + )
.tinyoffset = +
.tinyAllocs++
.mallocing = 0
releasem()
const = 0
if gcBlackenEnabled != 0 && != 0 {
if := getg().m.curg; != nil {
.gcAssistBytes -= int64( - )
}
}
if debug.malloc {
postMallocgcDebug(, , )
}
return
}
:= false
:= .alloc[tinySpanClass]
const = 8192
const = uint16(( - unsafe.Sizeof(spanInlineMarkBits{})) / 16)
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < {
:= + 1
if !(%64 == 0 && != ) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()*16 + .base())
}
}
}
:=
if == 0 {
, , = .nextFree(tinySpanClass)
}
:= unsafe.Pointer()
(*[2]uint64)()[0] = 0
(*[2]uint64)()[1] = 0
if !raceenabled && ( < .tinyoffset || .tiny == 0) {
.tiny = uintptr()
.tinyoffset =
}
publicationBarrier()
if writeBarrier.enabled {
gcmarknewobject(, uintptr())
} else {
.freeIndexForScan = .freeindex
}
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
if gcBlackenEnabled != 0 && != 0 {
if := getg().m.curg; != nil {
.gcAssistBytes -= int64( - )
}
}
if debug.malloc {
postMallocgcDebug(, , )
}
return
}
func ( uintptr, *_type, bool, spanClass, uintptr) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
lockRankMayQueueFinalizer()
if debug.malloc {
if := preMallocgcDebug(, ); != nil {
return
}
}
if gcBlackenEnabled != 0 {
:= getg()
if .m.curg != nil {
= .m.curg
}
.gcAssistBytes -= int64()
if .gcAssistBytes < 0 {
gcAssistAlloc()
}
}
= acquirem()
if doubleCheckMalloc {
doubleCheckSmallScanNoHeader(, , )
}
.mallocing = 1
:= false
:= getMCache()
:= .alloc[]
var gclinkptr
var unsafe.Pointer
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if .needzero != 0 {
memclrNoHeapPointers(, )
}
if goarch.PtrSize == 8 && == 8 {
.scanAlloc += 8
} else {
:=
:= uintptr()
if doubleCheckHeapSetType && (!heapBitsInSpan() || !heapBitsInSpan(elemsize_)) {
throw("tried to write heap bits, but no heap bits in span")
}
:= readUintptr(getGCMask())
var uintptr
:=
if .Size_ == goarch.PtrSize {
= (1 << ( / goarch.PtrSize)) - 1
=
} else {
if doubleCheckHeapSetType && !asanenabled && %.Size_ != 0 {
throw("runtime: (*mspan).writeHeapBitsSmall: dataSize is not a multiple of typ.Size_")
}
= .PtrBytes
for := .Size_; < ; += .Size_ {
|= << ( / goarch.PtrSize)
+= .Size_
}
}
, := spanHeapBitsRange(.base(), pageSize, )
:= unsafe.Pointer()
:= ( - .base()) / goarch.PtrSize
:= / ptrBits
:= % ptrBits
var uintptr = / goarch.PtrSize
var = &(-1) == 0
if > ptrBits || (! && + > ptrBits) {
:= ptrBits -
:= -
:= (*uintptr)(add(, (+0)*goarch.PtrSize))
:= (*uintptr)(add(, (+1)*goarch.PtrSize))
* = (*)&(^uintptr(0)>>) | ( << )
* = (*)&^((1<<)-1) | ( >> )
} else {
:= (*uintptr)(add(, *goarch.PtrSize))
* = (*)&^(((1<<(min(, ptrBits)))-1)<<) | ( << )
}
const = false
if {
writeHeapBitsDoubleCheck(, , , , , , , , )
}
if doubleCheckHeapSetType {
doubleCheckHeapType(, , , nil, )
}
.scanAlloc +=
}
publicationBarrier()
if writeBarrier.enabled {
gcmarknewobject(, uintptr())
} else {
.freeIndexForScan = .freeindex
}
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
:= getg()
if goexperiment.RuntimeSecret && .secret > 0 {
addSecret(, )
}
if gcBlackenEnabled != 0 && != 0 {
if := getg().m.curg; != nil {
.gcAssistBytes -= int64( - )
}
}
if debug.malloc {
postMallocgcDebug(, , )
}
return
}
func ( uintptr, *_type, bool, spanClass, uintptr) unsafe.Pointer {
if doubleCheckMalloc {
if gcphase == _GCmarktermination {
throw("mallocgc called with gcphase == _GCmarktermination")
}
}
var *m
lockRankMayQueueFinalizer()
if debug.malloc {
if := preMallocgcDebug(, ); != nil {
return
}
}
if gcBlackenEnabled != 0 {
:= getg()
if .m.curg != nil {
= .m.curg
}
.gcAssistBytes -= int64()
if .gcAssistBytes < 0 {
gcAssistAlloc()
}
}
= acquirem()
if doubleCheckMalloc {
doubleCheckSmallNoScan(, )
}
.mallocing = 1
:= false
:= getMCache()
:= .alloc[]
var gclinkptr
var unsafe.Pointer
if runtimeFreegcEnabled && .hasReusableNoscan() {
= mallocgcSmallNoscanReuse(, , , , )
.mallocing = 0
releasem()
goto
}
{
var gclinkptr
if .allocCache != 0 {
:= sys.TrailingZeros64(.allocCache)
:= .freeindex + uint16()
if < .nelems {
:= + 1
if !(%64 == 0 && != .nelems) {
.allocCache >>= uint( + 1)
.freeindex =
.allocCount++
= gclinkptr(uintptr()* + .base())
}
}
}
=
if == 0 {
, , = .nextFree()
}
= unsafe.Pointer()
}
if && .needzero != 0 {
memclrNoHeapPointers(, )
}
publicationBarrier()
if writeBarrier.enabled {
gcmarknewobject(, uintptr())
} else {
.freeIndexForScan = .freeindex
}
.nextSample -= int64()
if .nextSample < 0 || MemProfileRate != .memProfRate {
profilealloc(, , )
}
.mallocing = 0
releasem()
if {
if := (gcTrigger{kind: gcTriggerHeap}); .test() {
gcStart()
}
}
:
:= getg()
if goexperiment.RuntimeSecret && .secret > 0 {
addSecret(, )
}
if gcBlackenEnabled != 0 && != 0 {
if := getg().m.curg; != nil {
.gcAssistBytes -= int64( - )
}
}
if debug.malloc {
postMallocgcDebug(, , )
}
return
}