Source File
runtime_alg.go
Belonging Package
internal/runtime/maps
// Copyright 2026 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package mapsimport ()// runtime variable to check if the processor we're running on// actually supports the instructions used by the AES-based// hash implementation.var UseAeshash boolconst hashRandomBytes = goarch.PtrSize / 4 * 64// used to seed the hash functionvar aeskeysched [hashRandomBytes]byte// used in hash{32,64}.go to seed the hash functionvar hashkey [4]uintptrfunc () {// Always intialize hashkey.//// See #78073for := range hashkey {hashkey[] = uintptr(bootstrapRand())}// Install AES hash algorithms if the instructions needed are present.if (goarch.GOARCH == "386" || goarch.GOARCH == "amd64") &&cpu.X86.HasAES && // AESENCcpu.X86.HasSSSE3 && // PSHUFBcpu.X86.HasSSE41 { // PINSR{D,Q}// In memHashAES we have global variables that should be properly aligned.//// See #12415if !checkMasksAndShiftsAlignment() {fatal("maps: global variables for AES hashing are not properly aligned!")}initAlgAES()if memHashUsesVAES {// We are using intrinsics hash implementation.// Override the UseAeshash in this case, since it uses VAES (AVX) instructions.// While assembly implementation used AES-NI instructions,// simd intrinsics only provide access to AVX ones.UseAeshash = cpu.X86.HasAVX}return}if goarch.GOARCH == "arm64" && cpu.ARM64.HasAES {initAlgAES()return}}func () {UseAeshash = true// Initialize with random data so hash collisions will be hard to engineer.:= (*[hashRandomBytes / 8]uint64)(unsafe.Pointer(&aeskeysched))for := range {[] = bootstrapRand()}}//go:nosplitfunc ( unsafe.Pointer, uintptr) unsafe.Pointer {return unsafe.Pointer(uintptr() + )}// Note: These routines perform the read with a native endianness.func ( unsafe.Pointer) uint32 {:= (*[4]byte)()if goarch.BigEndian {return byteorder.BEUint32([:])}return byteorder.LEUint32([:])}func ( unsafe.Pointer) uint64 {:= (*[8]byte)()if goarch.BigEndian {return byteorder.BEUint64([:])}return byteorder.LEUint64([:])}
The pages are generated with Golds v0.8.4. (GOOS=linux GOARCH=amd64)