aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime/alg.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/runtime/alg.go')
-rw-r--r--libgo/go/runtime/alg.go39
1 files changed, 24 insertions, 15 deletions
diff --git a/libgo/go/runtime/alg.go b/libgo/go/runtime/alg.go
index 7c98f1b..c6bc6b6 100644
--- a/libgo/go/runtime/alg.go
+++ b/libgo/go/runtime/alg.go
@@ -5,6 +5,7 @@
package runtime
import (
+ "internal/cpu"
"runtime/internal/sys"
"unsafe"
)
@@ -137,7 +138,7 @@ func interhash(p unsafe.Pointer, h uintptr) uintptr {
t := *(**_type)(tab)
fn := t.hashfn
if fn == nil {
- panic(errorString("hash of unhashable type " + *t.string))
+ panic(errorString("hash of unhashable type " + t.string()))
}
if isDirectIface(t) {
return c1 * fn(unsafe.Pointer(&a.data), h^c0)
@@ -154,7 +155,7 @@ func nilinterhash(p unsafe.Pointer, h uintptr) uintptr {
}
fn := t.hashfn
if fn == nil {
- panic(errorString("hash of unhashable type " + *t.string))
+ panic(errorString("hash of unhashable type " + t.string()))
}
if isDirectIface(t) {
return c1 * fn(unsafe.Pointer(&a.data), h^c0)
@@ -212,7 +213,7 @@ func efaceeq(x, y eface) bool {
}
eq := t.equalfn
if eq == nil {
- panic(errorString("comparing uncomparable type " + *t.string))
+ panic(errorString("comparing uncomparable type " + t.string()))
}
if isDirectIface(t) {
return x.data == y.data
@@ -233,7 +234,7 @@ func ifaceeq(x, y iface) bool {
}
eq := t.equalfn
if eq == nil {
- panic(errorString("comparing uncomparable type " + *t.string))
+ panic(errorString("comparing uncomparable type " + t.string()))
}
if isDirectIface(t) {
return x.data == y.data
@@ -251,7 +252,7 @@ func ifacevaleq(x iface, t *_type, p unsafe.Pointer) bool {
}
eq := t.equalfn
if eq == nil {
- panic(errorString("comparing uncomparable type " + *t.string))
+ panic(errorString("comparing uncomparable type " + t.string()))
}
if isDirectIface(t) {
return x.data == p
@@ -272,7 +273,7 @@ func ifaceefaceeq(x iface, y eface) bool {
}
eq := xt.equalfn
if eq == nil {
- panic(errorString("comparing uncomparable type " + *xt.string))
+ panic(errorString("comparing uncomparable type " + xt.string()))
}
if isDirectIface(xt) {
return x.data == y.data
@@ -289,7 +290,7 @@ func efacevaleq(x eface, t *_type, p unsafe.Pointer) bool {
}
eq := t.equalfn
if eq == nil {
- panic(errorString("comparing uncomparable type " + *t.string))
+ panic(errorString("comparing uncomparable type " + t.string()))
}
if isDirectIface(t) {
return x.data == p
@@ -388,23 +389,25 @@ func ifaceHash(i interface {
const hashRandomBytes = sys.PtrSize / 4 * 64
-// used in asm_{386,amd64}.s to seed the hash function
+// used in asm_{386,amd64,arm64}.s to seed the hash function
var aeskeysched [hashRandomBytes]byte
// used in hash{32,64}.go to seed the hash function
var hashkey [4]uintptr
func alginit() {
- // Install aes hash algorithm if we have the instructions we need
+ // Install AES hash algorithms if the instructions needed are present.
if (GOARCH == "386" || GOARCH == "amd64") &&
GOOS != "nacl" &&
support_aes &&
- cpuid_ecx&(1<<25) != 0 && // aes (aesenc)
- cpuid_ecx&(1<<9) != 0 && // sse3 (pshufb)
- cpuid_ecx&(1<<19) != 0 { // sse4.1 (pinsr{d,q})
- useAeshash = true
- // Initialize with random data so hash collisions will be hard to engineer.
- getRandomData(aeskeysched[:])
+ cpu.X86.HasAES && // AESENC
+ cpu.X86.HasSSSE3 && // PSHUFB
+ cpu.X86.HasSSE41 { // PINSR{D,Q}
+ initAlgAES()
+ return
+ }
+ if GOARCH == "arm64" && cpu.ARM64.HasAES {
+ initAlgAES()
return
}
getRandomData((*[len(hashkey) * sys.PtrSize]byte)(unsafe.Pointer(&hashkey))[:])
@@ -413,3 +416,9 @@ func alginit() {
hashkey[2] |= 1
hashkey[3] |= 1
}
+
+func initAlgAES() {
+ useAeshash = true
+ // Initialize with random data so hash collisions will be hard to engineer.
+ getRandomData(aeskeysched[:])
+}