Source File
slice.go
Belonging Package
runtime
type notInHeapSlice struct {
array *notInHeap
len int
cap int
}
func () {
panic(errorString("makeslice: len out of range"))
}
func () {
panic(errorString("makeslice: cap out of range"))
}
bulkBarrierPreWriteSrcOnly(uintptr(), uintptr(), )
}
}
if raceenabled {
:= getcallerpc()
:= funcPC()
racereadrangepc(, , , )
}
if msanenabled {
msanread(, )
}
memmove(, , )
return
}
func ( *_type, , int) unsafe.Pointer {
, := math.MulUintptr(.size, uintptr())
, := math.MulUintptr(.size, uintptr())
if || > maxAlloc || < 0 {
panicmakeslicelen()
}
panicmakeslicecap()
}
return mallocgc(, , true)
}
func ( *_type, , int64) unsafe.Pointer {
:= int()
if int64() != {
panicmakeslicelen()
}
:= int()
if int64() != {
panicmakeslicecap()
}
return makeslice(, , )
}
func ( *_type, slice, int) slice {
if raceenabled {
:= getcallerpc()
racereadrangepc(.array, uintptr(.len*int(.size)), , funcPC())
}
if msanenabled {
msanread(.array, uintptr(.len*int(.size)))
}
if < .cap {
panic(errorString("growslice: cap out of range"))
}
for 0 < && < {
+= / 4
if <= 0 {
=
}
}
}
var bool
switch {
case .size == 1:
= uintptr(.len)
= uintptr()
= roundupsize(uintptr())
= uintptr() > maxAlloc
= int()
case .size == sys.PtrSize:
= uintptr(.len) * sys.PtrSize
= uintptr() * sys.PtrSize
= roundupsize(uintptr() * sys.PtrSize)
= uintptr() > maxAlloc/sys.PtrSize
= int( / sys.PtrSize)
case isPowerOfTwo(.size):
var uintptr
= uintptr(sys.Ctz64(uint64(.size))) & 63
} else {
= uintptr(sys.Ctz32(uint32(.size))) & 31
}
= uintptr(.len) <<
= uintptr() <<
= roundupsize(uintptr() << )
= uintptr() > (maxAlloc >> )
= int( >> )
default:
= uintptr(.len) * .size
= uintptr() * .size
, = math.MulUintptr(.size, uintptr())
= roundupsize()
= int( / .size)
}
memclrNoHeapPointers(add(, ), -)
func ( unsafe.Pointer, int, unsafe.Pointer, int, uintptr) int {
if == 0 || == 0 {
return 0
}
:=
if < {
=
}
if == 0 {
return
}
:= uintptr() *
if raceenabled {
:= getcallerpc()
:= funcPC()
racereadrangepc(, , , )
racewriterangepc(, , , )
}
if msanenabled {
msanread(, )
msanwrite(, )
}
![]() |
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. |