package sys
Import Path
internal/runtime/sys (on go.dev)
Dependency Relation
imports 2 packages, and imported by 3 packages
Involved Source Files
consts.go
consts_norace.go
intrinsics.go
nih.go
no_dit.go
package sys contains system- and configuration- and architecture-specific
constants used by the runtime.
zversion.go
empty.s
Package-Level Type Names (only one)
NotInHeap is a type must never be allocated from the GC'd heap or on the stack,
and is called not-in-heap.
Other types can embed NotInHeap to make it not-in-heap. Specifically, pointers
to these types must always fail the `runtime.inheap` check. The type may be used
for global variables, or for objects in unmanaged memory (e.g., allocated with
`sysAlloc`, `persistentalloc`, `fixalloc`, or from a manually-managed span).
Specifically:
1. `new(T)`, `make([]T)`, `append([]T, ...)` and implicit heap
allocation of T are disallowed. (Though implicit allocations are
disallowed in the runtime anyway.)
2. A pointer to a regular type (other than `unsafe.Pointer`) cannot be
converted to a pointer to a not-in-heap type, even if they have the
same underlying type.
3. Any type that containing a not-in-heap type is itself considered as not-in-heap.
- Structs and arrays are not-in-heap if their elements are not-in-heap.
- Maps and channels contains no-in-heap types are disallowed.
4. Write barriers on pointers to not-in-heap types can be omitted.
The last point is the real benefit of NotInHeap. The runtime uses
it for low-level internal structures to avoid memory barriers in the
scheduler and the memory allocator where they are illegal or simply
inefficient. This mechanism is reasonably safe and does not compromise
the readability of the runtime.
Package-Level Functions (total 18)
Bswap32 returns its input with byte order reversed
0x01020304 -> 0x04030201
Bswap64 returns its input with byte order reversed
0x0102030405060708 -> 0x0807060504030201
func DisableDIT() func DITEnabled() bool func GetCallerPC() uintptr func GetCallerSP() uintptr
GetClosurePtr returns the pointer to the current closure.
GetClosurePtr can only be used in an assignment statement
at the entry of a function. Moreover, go:nosplit directive
must be specified at the declaration of caller function,
so that the function prolog does not clobber the closure register.
for example:
//go:nosplit
func f(arg1, arg2, arg3 int) {
dx := GetClosurePtr()
}
The compiler rewrites calls to this function into instructions that fetch the
pointer from a well-known register (DX on x86 architecture, etc.) directly.
WARNING: PGO-based devirtualization cannot detect that caller of
GetClosurePtr requires closure context, and thus must maintain a list of
these functions, which is in
cmd/compile/internal/devirtualize/pgo.maybeDevirtualizeFunctionCall.
LeadingZeros64 returns the number of leading zero bits in x; the result is 64 for x == 0.
LeadingZeros8 returns the number of leading zero bits in x; the result is 8 for x == 0.
Len64 returns the minimum number of bits required to represent x; the result is 0 for x == 0.
nosplit because this is used in src/runtime/histogram.go, which make run in sensitive contexts.
Len8 returns the minimum number of bits required to represent x; the result is 0 for x == 0.
OnesCount64 returns the number of one bits ("population count") in x.
Prefetch prefetches data from memory addr to cache
AMD64: Produce PREFETCHT0 instruction
ARM64: Produce PRFM instruction with PLDL1KEEP option
PrefetchStreamed prefetches data from memory addr, with a hint that this data is being streamed.
That is, it is likely to be accessed very soon, but only once. If possible, this will avoid polluting the cache.
AMD64: Produce PREFETCHNTA instruction
ARM64: Produce PRFM instruction with PLDL1STRM option
TrailingZeros32 returns the number of trailing zero bits in x; the result is 32 for x == 0.
TrailingZeros64 returns the number of trailing zero bits in x; the result is 64 for x == 0.
TrailingZeros8 returns the number of trailing zero bits in x; the result is 8 for x == 0.
Package-Level Variables (only one)
var DITSupported bool
Package-Level Constants (total 6)
DefaultPhysPageSize is the default physical page size.
Int64Align is the required alignment for a 64-bit integer (4 on 32-bit systems, 8 on 64-bit).
MinFrameSize is the size of the system-reserved words at the bottom
of a frame (just above the architectural stack pointer).
It is zero on x86 and PtrSize on most non-x86 (LR-based) systems.
On PowerPC it is larger, to cover three more reserved words:
the compiler word, the link editor word, and the TOC save word.
PCQuantum is the minimal unit for a program counter (1 on x86, 4 on most other systems).
The various PC tables record PC deltas pre-divided by PCQuantum.
StackAlign is the required alignment of the SP register.
The stack must be at least word aligned, but some architectures require more.
AIX and OpenBSD require a larger stack for syscalls.
The race build also needs more stack. See issue 54291.
This arithmetic must match that in cmd/internal/objabi/stack.go:stackGuardMultiplier.
The pages are generated with Golds v0.7.3-preview. (GOOS=linux 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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |