Source File
mspanset.go
Belonging Package
runtime
package runtime
import (
)
index headTailIndex
}
const (
spanSetBlockEntries = 512 // 4KB on 64-bit
spanSetInitSpineCap = 256 // Enough for 1GB heap on 64-bit
)
:= uintptr(.index.incTail().tail() - 1)
, := /spanSetBlockEntries, %spanSetBlockEntries
:= atomic.Loaduintptr(&.spineLen)
var *spanSetBlock
:
if < {
:= atomic.Loadp(unsafe.Pointer(&.spine))
:= add(, sys.PtrSize*)
= (*spanSetBlock)(atomic.Loadp())
= atomic.Loaduintptr(&.spineLen)
if < {
unlock(&.spineLock)
goto
}
:= .spineCap * 2
if == 0 {
= spanSetInitSpineCap
}
:= persistentalloc(*sys.PtrSize, cpu.CacheLineSize, &memstats.gcMiscSys)
atomic.StorepNoWB(unsafe.Pointer(&.spine), )
}
atomic.StorepNoWB(, unsafe.Pointer())
atomic.Storeuintptr(&.spineLen, +1)
unlock(&.spineLock)
}
return nil
:= atomic.Loaduintptr(&.spineLen)
return nil
}
, := /spanSetBlockEntries, %spanSetBlockEntries
atomic.StorepNoWB(, nil)
spanSetBlockPool.free()
}
return
}
throw("span set block with unpopped elements found in reset")
}
throw("fully empty unfreed span set block found in reset")
}
atomic.StorepNoWB(unsafe.Pointer(), nil)
spanSetBlockPool.free()
}
}
.index.reset()
atomic.Storeuintptr(&.spineLen, 0)
}
type spanSetBlockAlloc struct {
stack lfstack
}
func ( *spanSetBlockAlloc) () *spanSetBlock {
if := (*spanSetBlock)(.stack.pop()); != nil {
return
}
return (*spanSetBlock)(persistentalloc(unsafe.Sizeof(spanSetBlock{}), cpu.CacheLineSize, &memstats.gcMiscSys))
}
func ( *spanSetBlockAlloc) ( *spanSetBlock) {
atomic.Store(&.popped, 0)
.stack.push(&.lfnode)
}
type headTailIndex uint64
func (, uint32) headTailIndex {
return headTailIndex(uint64()<<32 | uint64())
}
func ( headTailIndex) () uint32 {
return uint32( >> 32)
}
func ( headTailIndex) () uint32 {
return uint32()
}
func ( headTailIndex) () ( uint32, uint32) {
return .head(), .tail()
}
func ( *headTailIndex) () headTailIndex {
return headTailIndex(atomic.Load64((*uint64)()))
}
func ( *headTailIndex) (, headTailIndex) bool {
return atomic.Cas64((*uint64)(), uint64(), uint64())
}
func ( *headTailIndex) () headTailIndex {
return headTailIndex(atomic.Xadd64((*uint64)(), (1 << 32)))
}
func ( *headTailIndex) () headTailIndex {
return headTailIndex(atomic.Xadd64((*uint64)(), -(1 << 32)))
}
func ( *headTailIndex) () headTailIndex {
func ( *headTailIndex) () {
atomic.Store64((*uint64)(), 0)
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |