Documentation ¶
Overview ¶
Package runtimer provides you unsafe way to use runtime internals
Index ¶
- Constants
- Variables
- func Add(p unsafe.Pointer, x uintptr) unsafe.Pointer
- func Aeshash(p unsafe.Pointer, h, s uintptr) uintptr
- func Aeshash32(p unsafe.Pointer, h uintptr) uintptr
- func Aeshash64(p unsafe.Pointer, h uintptr) uintptr
- func Aeshashstr(p unsafe.Pointer, h uintptr) uintptr
- func Atoi(s string) (int, bool)
- func Atoi32(s string) (int32, bool)
- func BytesHash(b []byte, seed uintptr) uintptr
- func C128equal(p, q unsafe.Pointer) bool
- func C128hash(p unsafe.Pointer, h uintptr) uintptr
- func C64equal(p, q unsafe.Pointer) bool
- func C64hash(p unsafe.Pointer, h uintptr) uintptr
- func Cas(ptr *uint32, old, new uint32) bool
- func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool
- func Casuintptr(ptr *uintptr, old, new uintptr) bool
- func Contains(s, t string) bool
- func EfaceDataPtr(eface interface{}) *unsafe.Pointer
- func EfaceHash(i interface{}, seed uintptr) uintptr
- func Efaceeq(t *Type, x, y unsafe.Pointer) bool
- func Encoderune(p []byte, r rune) int
- func F32equal(p, q unsafe.Pointer) bool
- func F32hash(p unsafe.Pointer, h uintptr) uintptr
- func F64equal(p, q unsafe.Pointer) bool
- func F64hash(p unsafe.Pointer, h uintptr) uintptr
- func Fastrand() uint32
- func Findnull(s *byte) int
- func Findnullw(s *uint16) int
- func GetEfaceDataPtr(eface interface{}) unsafe.Pointer
- func Gostringnocopy(str *byte) string
- func HasPrefix(s, t string) bool
- func IfaceHash(i interface{ ... }, seed uintptr) uintptr
- func Ifaceeq(t *Itab, x, y unsafe.Pointer) bool
- func Index(s, t string) int
- func Int32Hash(i uint32, seed uintptr) uintptr
- func Int64Hash(i uint64, seed uintptr) uintptr
- func Interequal(p, q unsafe.Pointer) bool
- func Interhash(p unsafe.Pointer, h uintptr) uintptr
- func IsDirectIface(t *Type) bool
- func Loadint64(ptr *int64) int64
- func Loaduint(ptr *uint) uint
- func Loaduintptr(ptr *uintptr) uintptr
- func Lock(l *Mutex)
- func MemclrHasPointers(ptr unsafe.Pointer, n uintptr)
- func MemclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
- func Memequal(a, b unsafe.Pointer, size uintptr) bool
- func Memequal0(p, q unsafe.Pointer) bool
- func Memequal128(p, q unsafe.Pointer) bool
- func Memequal16(p, q unsafe.Pointer) bool
- func Memequal32(p, q unsafe.Pointer) bool
- func Memequal64(p, q unsafe.Pointer) bool
- func Memequal8(p, q unsafe.Pointer) bool
- func Memhash0(p unsafe.Pointer, h uintptr) uintptr
- func Memhash128(p unsafe.Pointer, h uintptr) uintptr
- func Memhash16(p unsafe.Pointer, h uintptr) uintptr
- func Memhash32(p unsafe.Pointer, h uintptr) uintptr
- func Memhash64(p unsafe.Pointer, h uintptr) uintptr
- func Memhash8(p unsafe.Pointer, h uintptr) uintptr
- func MemhashVarlen(p unsafe.Pointer, h uintptr) uintptr
- func Msanread(addr unsafe.Pointer, sz uintptr)
- func Newarray(typ *Type, n int) unsafe.Pointer
- func Newobject(typ *Type) unsafe.Pointer
- func Nilinterequal(p, q unsafe.Pointer) bool
- func Nilinterhash(p unsafe.Pointer, h uintptr) uintptr
- func Noescape(p unsafe.Pointer) unsafe.Pointer
- func Or8(ptr *uint8, val uint8)
- func PtrPtrToStringPtr(ptr *unsafe.Pointer) *string
- func PtrToString(ptr unsafe.Pointer) string
- func PtrToStringPtr(ptr unsafe.Pointer) *string
- func Rawstring(size int) (s string, b []byte)
- func Storeuintptr(ptr *uintptr, new uintptr)
- func Strequal(p, q unsafe.Pointer) bool
- func Strhash(p unsafe.Pointer, h uintptr) uintptr
- func StringHash(s string, seed uintptr) uintptr
- func Throw(s string)
- func Typedmemclr(typ *Type, ptr unsafe.Pointer)
- func Typedmemmove(typ *Type, dst, src unsafe.Pointer)
- func TypesEqual(t, v *Type) bool
- func Unlock(l *Mutex)
- func Xaddint64(ptr *int64, delta int64) int64
- type ArrayType
- type ChanType
- type FuncType
- type Hex
- type InterfaceType
- type Itab
- type MapType
- type Mutex
- type Name
- type NameOff
- type PtrType
- type SliceType
- type SliceType2
- type StringStruct
- type StringStructDWARF
- type StructType
- type Structfield
- type Tflag
- type Type
- type TypeAlg
- type TypeOff
- type UncommonType
Constants ¶
const ( C0 = uintptr((8-PtrSize)/4*2860486313 + (PtrSize-4)/4*33054211828000289) C1 = uintptr((8-PtrSize)/4*3267000013 + (PtrSize-4)/4*23344194077549503) )
const ( AlgNOEQ = iota AlgMEM0 AlgMEM8 AlgMEM16 AlgMEM32 AlgMEM64 AlgMEM128 AlgSTRING AlgINTER AlgNILINTER AlgFLOAT32 AlgFLOAT64 AlgCPLX64 AlgCPLX128 AlgMax )
type algorithms - known to compiler
const ( KindBool = 1 + iota KindInt KindInt8 KindInt16 KindInt32 KindInt64 KindUint KindUint8 KindUint16 KindUint32 KindUint64 KindUintptr KindFloat32 KindFloat64 KindComplex64 KindComplex128 KindArray KindChan KindFunc KindInterface KindMap KindPtr KindSlice KindString KindStruct KindUnsafePointer KindDirectIface = 1 << 5 KindGCProg = 1 << 6 KindNoPointers = 1 << 7 KindMask = (1 << 5) - 1 )
const ( //go:linkname GOOS runtime.internal.sys.GOOS GOOS = `unknown` //go:linkname GoosAndroid runtime.internal.sys.GoosAndroid GoosAndroid uint = 0 //go:linkname GoosDarwin runtime.internal.sys.GoosDarwin GoosDarwin uint = 0 //go:linkname GoosDragonfly runtime.internal.sys.GoosDragonfly GoosDragonfly uint = 0 //go:linkname GoosFreebsd runtime.internal.sys.GoosFreebsd GoosFreebsd uint = 0 //go:linkname GoosLinux runtime.internal.sys.GoosLinux GoosLinux uint = 0 //go:linkname GoosNacl runtime.internal.sys.GoosNacl GoosNacl uint = 0 //go:linkname GoosNetbsd runtime.internal.sys.GoosNetbsd GoosNetbsd uint = 0 //go:linkname GoosOpenbsd runtime.internal.sys.GoosOpenbsd GoosOpenbsd uint = 0 //go:linkname GoosPlan9 runtime.internal.sys.GoosPlan9 GoosPlan9 uint = 0 //go:linkname GoosSolaris runtime.internal.sys.GoosSolaris GoosSolaris uint = 0 //go:linkname GoosWindows runtime.internal.sys.GoosWindows GoosWindows uint = 0 //go:linkname Goarch386 runtime.internal.sys.Goarch386 Goarch386 uint = 0 //go:linkname GoarchAmd64 runtime.internal.sys.GoarchAmd64 GoarchAmd64 uint = 0 //go:linkname GoarchAmd64p32 runtime.internal.sys.GoarchAmd64p32 GoarchAmd64p32 uint = 0 //go:linkname GoarchArm runtime.internal.sys.GoarchArm GoarchArm uint = 0 //go:linkname GoarchArmbe runtime.internal.sys.GoarchArmbe GoarchArmbe uint = 0 //go:linkname GoarchArm64 runtime.internal.sys.GoarchArm64 GoarchArm64 uint = 0 //go:linkname GoarchArm64be runtime.internal.sys.GoarchArm64be GoarchArm64be uint = 0 //go:linkname GoarchPpc64 runtime.internal.sys.GoarchPpc64 GoarchPpc64 uint = 0 //go:linkname GoarchPpc64le runtime.internal.sys.GoarchPpc64le GoarchPpc64le uint = 0 //go:linkname GoarchMips runtime.internal.sys.GoarchMips GoarchMips uint = 0 //go:linkname GoarchMipsle runtime.internal.sys.GoarchMipsle GoarchMipsle uint = 0 //go:linkname GoarchMips64 runtime.internal.sys.GoarchMips64 GoarchMips64 uint = 0 //go:linkname GoarchMips64le runtime.internal.sys.GoarchMips64le GoarchMips64le uint = 0 //go:linkname GoarchMips64p32 runtime.internal.sys.GoarchMips64p32 GoarchMips64p32 uint = 0 //go:linkname GoarchMips64p32le runtime.internal.sys.GoarchMips64p32le GoarchMips64p32le uint = 0 //go:linkname GoarchPpc runtime.internal.sys.GoarchPpc GoarchPpc uint = 0 //go:linkname GoarchS390 runtime.internal.sys.GoarchS390 GoarchS390 uint = 0 //go:linkname GoarchS390x runtime.internal.sys.GoarchS390x GoarchS390x uint = 0 //go:linkname GoarchSparc runtime.internal.sys.GoarchSparc GoarchSparc uint = 0 //go:linkname GoarchSparc64 runtime.internal.sys.GoarchSparc64 GoarchSparc64 uint = 0 )
const ( PageShift uint = 13 // Public64bit = 1 on 64-bit systems, 0 on 32-bit systems Public64bit uint = 1 << (^uintptr(0) >> 63) / 2 MHeapMapTotalBits = (Public64bit*GoosWindows)*35 + (Public64bit*(1-GoosWindows)*(1-GoosDarwin*GoarchArm64))*39 + GoosDarwin*GoarchArm64*31 + (1-Public64bit)*(32-(GoarchMips+GoarchMipsle)) MHeapMapBits = MHeapMapTotalBits - PageShift // MaxMem is the maximum heap arena size minus 1. // // On 32-bit, this is also the maximum heap pointer value, // since the arena starts at address 0. MaxMem = 1<<MHeapMapTotalBits - 1 )
const HashRandomBytes = PtrSize / 4 * 64
const Msanenabled = false
const PtrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const
Variables ¶
var AlgArray = [AlgMax]TypeAlg{ AlgNOEQ: {nil, nil}, AlgMEM0: {Memhash0, Memequal0}, AlgMEM8: {Memhash8, Memequal8}, AlgMEM16: {Memhash16, Memequal16}, AlgMEM32: {Memhash32, Memequal32}, AlgMEM64: {Memhash64, Memequal64}, AlgMEM128: {Memhash128, Memequal128}, AlgSTRING: {Strhash, Strequal}, AlgINTER: {Interhash, Interequal}, AlgNILINTER: {Nilinterhash, Nilinterequal}, AlgFLOAT32: {F32hash, F32equal}, AlgFLOAT64: {F64hash, F64equal}, AlgCPLX64: {C64hash, C64equal}, AlgCPLX128: {C128hash, C128equal}, }
var CPUIDECX uint32
Functions ¶
func Atoi ¶
Atoi parses an int from a string s. The bool result reports whether s is a number representable by a value of type int.
func Casuintptr ¶
func EfaceDataPtr ¶
func Encoderune ¶
func GetEfaceDataPtr ¶
func Gostringnocopy ¶
func Interequal ¶
func IsDirectIface ¶
IsDirectIface reports whether t is stored directly in an interface value.
func Loaduintptr ¶
func MemclrHasPointers ¶
func MemclrNoHeapPointers ¶
func Memequal128 ¶
func Memequal16 ¶
func Memequal32 ¶
func Memequal64 ¶
func MemhashVarlen ¶
MemhashVarlen is defined in runtime assembly because it needs access to the closure. It appears here to provide an argument signature for the assembly routine.
func Nilinterequal ¶
func PtrPtrToStringPtr ¶
func PtrToString ¶
func PtrToStringPtr ¶
func Storeuintptr ¶
func StringHash ¶
func Typedmemclr ¶
func Typedmemmove ¶
func TypesEqual ¶
TypesEqual reports whether two Types are equal.
Everywhere in the runtime and reflect packages, it is assumed that there is exactly one *Type per Go Type, so that pointer equality can be used to test if Types are equal. There is one place that breaks this assumption: buildmode=shared. In this case a Type can appear as two different pieces of memory. This is hidden from the runtime and reflect package by the per-module Typemap built in Typelinksinit. It uses TypesEqual to map Types from later modules back into earlier ones.
Only Typelinksinit needs this function.
Types ¶
type InterfaceType ¶
type InterfaceType struct {
// contains filtered or unexported fields
}
type Itab ¶
type Itab struct { Inter *InterfaceType Type *Type Link *Itab Hash uint32 // copy of _type.hash. Used for type switches. Bad bool // type does not implement interface Inhash bool // has this itab been added to hash? Unused [2]byte Fun [1]uintptr // variable sized }
layout of Itab known to compilers allocated in non-garbage-collected memory Needs to be in sync with ../cmd/compile/internal/gc/reflect.go:/^func.dumptypestructs.
type MapType ¶
type MapType struct { Typ Type Key *Type Elem *Type Bucket *Type // internal Type representing a hash bucket Hmap *Type // internal Type representing a hmap Keysize uint8 // size of key slot Indirectkey bool // store ptr to key instead of key itself Valuesize uint8 // size of value slot Indirectvalue bool // store ptr to value instead of value itself Bucketsize uint16 // size of bucket Reflexivekey bool // true if k==k for all keys Needkeyupdate bool // true if we need to update key on an overwrite }
type Mutex ¶
type Mutex struct { // Futex-based impl treats it as uint32 key, // while sema-based impl as M* waitm. // Used to be a union, but unions break precise GC. Key uintptr }
Mutex - Mutual exclusion locks. In the uncontended case, as fast as spin locks (just a few user-level instructions), but on the contention path they sleep in the kernel. A zeroed Mutex is unlocked (no need to initialize each lock).
type Name ¶
type Name struct {
Bytes *byte
}
Name is an encoded Type Name with optional extra data. See reflect/Type.go for details.
func (Name) IsExported ¶
type StringStruct ¶
func StringStructOf ¶
func StringStructOf(sp *string) *StringStruct
type StringStructDWARF ¶
Variant with *byte pointer type for DWARF debugging.
type StructType ¶
type StructType struct { Typ Type PkgPath Name Fields []Structfield }
type Structfield ¶
func (*Structfield) Offset ¶
func (f *Structfield) Offset() uintptr
type Tflag ¶
type Tflag uint8
Tflag is documented in reflect/Type.go.
Tflag values must be kept in sync with copies in:
cmd/compile/internal/gc/reflect.go cmd/link/internal/ld/decodesym.go reflect/Type.go
type Type ¶
type Type struct { Size uintptr Ptrdata uintptr // size of memory prefix holding all pointers Hash uint32 Tflag Tflag Align uint8 Fieldalign uint8 Kind uint8 Alg *TypeAlg // gcdata stores the GC Type data for the garbage collector. // If the KindGCProg bit is set in kind, gcdata is a GC program. // Otherwise it is a ptrmask bitmap. See mbitmap.go for details. Gcdata *byte Str NameOff PtrToThis TypeOff }
Needs to be in sync with ../cmd/compile/internal/ld/decodesym.go:/^func.commonsize, ../cmd/compile/internal/gc/reflect.go:/^func.dcommonType and ../reflect/Type.go:/^Type.rType.
func (*Type) Uncommon ¶
func (t *Type) Uncommon() *UncommonType
type TypeAlg ¶
type TypeAlg struct { // function for hashing objects of this type // (ptr to object, seed) -> hash Hash func(unsafe.Pointer, uintptr) uintptr // function for comparing objects of this type // (ptr to object A, ptr to object B) -> ==? Equal func(unsafe.Pointer, unsafe.Pointer) bool }
TypeAlg is also copied/used in reflect/type.go. keep them in sync.