update gobgp pkg

This commit is contained in:
Ian Azpiazu
2022-05-16 13:40:57 -04:00
parent 878ee3a63e
commit 80d743ffa5
652 changed files with 136451 additions and 98241 deletions

View File

@@ -13,7 +13,8 @@ branches:
- travis
go:
- 1.9
- 1.12.x
- 1.13.x
- tip
matrix:

View File

@@ -1,5 +1,3 @@
As this is a highly derivative work, I have placed it under the same license as the original implementation:
Copyright (c) 2014-2017 Damian Gryski
Copyright (c) 2016-2017 Nicola Asuni - Tecnick.com

View File

@@ -10,7 +10,7 @@
# ------------------------------------------------------------------------------
# List special make targets that are not associated with files
.PHONY: help all test format fmtcheck vet lint coverage cyclo ineffassign misspell structcheck varcheck errcheck gosimple astscan qa deps clean nuke
.PHONY: help all test format fmtcheck vet lint coverage cyclo misspell errcheck staticcheck astscan qa deps clean nuke
# Use bash as shell (Note: Ubuntu now uses dash which doesn't support PIPESTATUS).
SHELL=/bin/bash
@@ -66,12 +66,9 @@ help:
@echo " make lint : Check for style errors"
@echo " make coverage : Generate the coverage report"
@echo " make cyclo : Generate the cyclomatic complexity report"
@echo " make ineffassign : Detect ineffectual assignments"
@echo " make misspell : Detect commonly misspelled words in source files"
@echo " make structcheck : Find unused struct fields"
@echo " make varcheck : Find unused global variables and constants"
@echo " make staticcheck : Run staticcheck
@echo " make errcheck : Check that error return values are used"
@echo " make gosimple : Suggest code simplifications"
@echo " make astscan : GO AST scanner"
@echo ""
@echo " make docs : Generate source code documentation"
@@ -131,35 +128,22 @@ cyclo:
@mkdir -p target/report
GOPATH=$(GOPATH) gocyclo -avg ./ | tee target/report/cyclo.txt ; test $${PIPESTATUS[0]} -eq 0
# Detect ineffectual assignments
ineffassign:
@mkdir -p target/report
GOPATH=$(GOPATH) ineffassign ./ | tee target/report/ineffassign.txt ; test $${PIPESTATUS[0]} -eq 0
# Detect commonly misspelled words in source files
misspell:
@mkdir -p target/report
GOPATH=$(GOPATH) misspell -error ./ | tee target/report/misspell.txt ; test $${PIPESTATUS[0]} -eq 0
# Find unused struct fields
structcheck:
@mkdir -p target/report
GOPATH=$(GOPATH) structcheck -a ./ | tee target/report/structcheck.txt
# Find unused global variables and constants
varcheck:
@mkdir -p target/report
GOPATH=$(GOPATH) varcheck -e ./ | tee target/report/varcheck.txt
# Check that error return values are used
errcheck:
@mkdir -p target/report
GOPATH=$(GOPATH) errcheck ./ | tee target/report/errcheck.txt
# Suggest code simplifications
gosimple:
# staticcheck
staticcheck:
@mkdir -p target/report
GOPATH=$(GOPATH) gosimple ./ | tee target/report/gosimple.txt
GOPATH=$(GOPATH) staticcheck ./... | tee target/report/staticcheck.txt
# AST scanner
astscan:
@@ -174,14 +158,14 @@ docs:
@echo '<html><head><meta http-equiv="refresh" content="0;./127.0.0.1:6060/pkg/'${CVSPATH}'/'${PROJECT}'/index.html"/></head><a href="./127.0.0.1:6060/pkg/'${CVSPATH}'/'${PROJECT}'/index.html">'${PKGNAME}' Documentation ...</a></html>' > target/docs/index.html
# Alias to run all quality-assurance checks
qa: fmtcheck test vet lint coverage cyclo ineffassign misspell structcheck varcheck errcheck gosimple astscan
qa: fmtcheck test vet lint coverage cyclo misspell errcheck astscan
# --- INSTALL ---
# Get the dependencies
deps:
GOPATH=$(GOPATH) go get ./...
GOPATH=$(GOPATH) go get github.com/golang/lint/golint
GOPATH=$(GOPATH) go get golang.org/x/lint/golint
GOPATH=$(GOPATH) go get github.com/jstemmer/go-junit-report
GOPATH=$(GOPATH) go get github.com/axw/gocov/gocov
GOPATH=$(GOPATH) go get github.com/fzipp/gocyclo
@@ -190,7 +174,7 @@ deps:
GOPATH=$(GOPATH) go get github.com/opennota/check/cmd/structcheck
GOPATH=$(GOPATH) go get github.com/opennota/check/cmd/varcheck
GOPATH=$(GOPATH) go get github.com/kisielk/errcheck
GOPATH=$(GOPATH) go get honnef.co/go/tools/cmd/gosimple
GOPATH=$(GOPATH) go get honnef.co/go/tools/cmd/staticcheck
GOPATH=$(GOPATH) go get github.com/GoASTScanner/gas
# Remove any build artifact

View File

@@ -39,3 +39,8 @@ Before committing the code, please check if it passes all tests using
```bash
make qa
```
## License
As this is a highly derivative work, I have placed it under the same license as the original implementation. See the
LICENSE file for details.

View File

@@ -1,5 +1,7 @@
package farm
import "math/bits"
// Some primes between 2^63 and 2^64 for various uses.
const k0 uint64 = 0xc3a5c85c97cb3127
const k1 uint64 = 0xb492b66fbe98f273
@@ -22,9 +24,9 @@ func fmix(h uint32) uint32 {
func mur(a, h uint32) uint32 {
// Helper from Murmur3 for combining two 32-bit values.
a *= c1
a = rotate32(a, 17)
a = bits.RotateLeft32(a, -17)
a *= c2
h ^= a
h = rotate32(h, 19)
h = bits.RotateLeft32(h, -19)
return h*5 + 0xe6546b64
}

View File

@@ -1,23 +1,28 @@
package farm
import (
"encoding/binary"
"math/bits"
)
// This file provides a 32-bit hash equivalent to CityHash32 (v1.1.1)
// and a 128-bit hash equivalent to CityHash128 (v1.1.1). It also provides
// a seeded 32-bit hash function similar to CityHash32.
func hash32Len13to24Seed(s []byte, seed uint32) uint32 {
slen := len(s)
a := fetch32(s, -4+(slen>>1))
b := fetch32(s, 4)
c := fetch32(s, slen-8)
d := fetch32(s, (slen >> 1))
e := fetch32(s, 0)
f := fetch32(s, slen-4)
a := binary.LittleEndian.Uint32(s[-4+(slen>>1) : -4+(slen>>1)+4])
b := binary.LittleEndian.Uint32(s[4 : 4+4])
c := binary.LittleEndian.Uint32(s[slen-8 : slen-8+4])
d := binary.LittleEndian.Uint32(s[(slen >> 1) : (slen>>1)+4])
e := binary.LittleEndian.Uint32(s[0 : 0+4])
f := binary.LittleEndian.Uint32(s[slen-4 : slen-4+4])
h := d*c1 + uint32(slen) + seed
a = rotate32(a, 12) + f
a = bits.RotateLeft32(a, -12) + f
h = mur(c, h) + a
a = rotate32(a, 3) + c
a = bits.RotateLeft32(a, -3) + c
h = mur(e, h) + a
a = rotate32(a+f, 12) + d
a = bits.RotateLeft32(a+f, -12) + d
h = mur(b^seed, h) + a
return fmix(h)
}
@@ -63,19 +68,19 @@ func cityMurmur(s []byte, seed uint128) uint128 {
a = shiftMix(a*k1) * k1
c = b*k1 + hashLen0to16(s)
if slen >= 8 {
d = shiftMix(a + fetch64(s, 0))
d = shiftMix(a + binary.LittleEndian.Uint64(s[0:0+8]))
} else {
d = shiftMix(a + c)
}
} else { // len > 16
c = hashLen16(fetch64(s, slen-8)+k1, a)
d = hashLen16(b+uint64(slen), c+fetch64(s, slen-16))
c = hashLen16(binary.LittleEndian.Uint64(s[slen-8:slen-8+8])+k1, a)
d = hashLen16(b+uint64(slen), c+binary.LittleEndian.Uint64(s[slen-16:slen-16+8]))
a += d
for {
a ^= shiftMix(fetch64(s, 0)*k1) * k1
a ^= shiftMix(binary.LittleEndian.Uint64(s[0:0+8])*k1) * k1
a *= k1
b ^= a
c ^= shiftMix(fetch64(s, 8)*k1) * k1
c ^= shiftMix(binary.LittleEndian.Uint64(s[8:8+8])*k1) * k1
c *= k1
d ^= c
s = s[16:]
@@ -107,29 +112,29 @@ func cityHash128WithSeed(s []byte, seed uint128) uint128 {
x := seed.lo
y := seed.hi
z := uint64(slen) * k1
v1 = rotate64(y^k1, 49)*k1 + fetch64(s, 0)
v2 = rotate64(v1, 42)*k1 + fetch64(s, 8)
w1 = rotate64(y+z, 35)*k1 + x
w2 = rotate64(x+fetch64(s, 88), 53) * k1
v1 = bits.RotateLeft64(y^k1, -49)*k1 + binary.LittleEndian.Uint64(s[0:0+8])
v2 = bits.RotateLeft64(v1, -42)*k1 + binary.LittleEndian.Uint64(s[8:8+8])
w1 = bits.RotateLeft64(y+z, -35)*k1 + x
w2 = bits.RotateLeft64(x+binary.LittleEndian.Uint64(s[88:88+8]), -53) * k1
// This is the same inner loop as CityHash64(), manually unrolled.
for {
x = rotate64(x+y+v1+fetch64(s, 8), 37) * k1
y = rotate64(y+v2+fetch64(s, 48), 42) * k1
x = bits.RotateLeft64(x+y+v1+binary.LittleEndian.Uint64(s[8:8+8]), -37) * k1
y = bits.RotateLeft64(y+v2+binary.LittleEndian.Uint64(s[48:48+8]), -42) * k1
x ^= w2
y += v1 + fetch64(s, 40)
z = rotate64(z+w1, 33) * k1
y += v1 + binary.LittleEndian.Uint64(s[40:40+8])
z = bits.RotateLeft64(z+w1, -33) * k1
v1, v2 = weakHashLen32WithSeeds(s, v2*k1, x+w1)
w1, w2 = weakHashLen32WithSeeds(s[32:], z+w2, y+fetch64(s, 16))
w1, w2 = weakHashLen32WithSeeds(s[32:], z+w2, y+binary.LittleEndian.Uint64(s[16:16+8]))
z, x = x, z
s = s[64:]
x = rotate64(x+y+v1+fetch64(s, 8), 37) * k1
y = rotate64(y+v2+fetch64(s, 48), 42) * k1
x = bits.RotateLeft64(x+y+v1+binary.LittleEndian.Uint64(s[8:8+8]), -37) * k1
y = bits.RotateLeft64(y+v2+binary.LittleEndian.Uint64(s[48:48+8]), -42) * k1
x ^= w2
y += v1 + fetch64(s, 40)
z = rotate64(z+w1, 33) * k1
y += v1 + binary.LittleEndian.Uint64(s[40:40+8])
z = bits.RotateLeft64(z+w1, -33) * k1
v1, v2 = weakHashLen32WithSeeds(s, v2*k1, x+w1)
w1, w2 = weakHashLen32WithSeeds(s[32:], z+w2, y+fetch64(s, 16))
w1, w2 = weakHashLen32WithSeeds(s[32:], z+w2, y+binary.LittleEndian.Uint64(s[16:16+8]))
z, x = x, z
s = s[64:]
slen -= 128
@@ -137,18 +142,18 @@ func cityHash128WithSeed(s []byte, seed uint128) uint128 {
break
}
}
x += rotate64(v1+z, 49) * k0
y = y*k0 + rotate64(w2, 37)
z = z*k0 + rotate64(w1, 27)
x += bits.RotateLeft64(v1+z, -49) * k0
y = y*k0 + bits.RotateLeft64(w2, -37)
z = z*k0 + bits.RotateLeft64(w1, -27)
w1 *= 9
v1 *= k0
// If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
for tailDone := 0; tailDone < slen; {
tailDone += 32
y = rotate64(x+y, 42)*k0 + v2
w1 += fetch64(last, 128-tailDone+16)
y = bits.RotateLeft64(x+y, -42)*k0 + v2
w1 += binary.LittleEndian.Uint64(last[128-tailDone+16 : 128-tailDone+16+8])
x = x*k0 + w1
z += w2 + fetch64(last, 128-tailDone)
z += w2 + binary.LittleEndian.Uint64(last[128-tailDone:128-tailDone+8])
w2 += v1
v1, v2 = weakHashLen32WithSeeds(last[128-tailDone:], v1+z, v2)
v1 *= k0
@@ -166,7 +171,7 @@ func cityHash128WithSeed(s []byte, seed uint128) uint128 {
func cityHash128(s []byte) uint128 {
slen := len(s)
if slen >= 16 {
return cityHash128WithSeed(s[16:], uint128{fetch64(s, 0), fetch64(s, 8) + k0})
return cityHash128WithSeed(s[16:], uint128{binary.LittleEndian.Uint64(s[0 : 0+8]), binary.LittleEndian.Uint64(s[8:8+8]) + k0})
}
return cityHash128WithSeed(s, uint128{k0, k1})
}
@@ -177,16 +182,6 @@ func Fingerprint128(s []byte) (lo, hi uint64) {
return h.lo, h.hi
}
// Fingerprint64 is a 64-bit fingerprint function for byte-slices
func Fingerprint64(s []byte) uint64 {
return naHash64(s)
}
// Fingerprint32 is a 32-bit fingerprint function for byte-slices
func Fingerprint32(s []byte) uint32 {
return Hash32(s)
}
// Hash128 is a 128-bit hash function for byte-slices
func Hash128(s []byte) (lo, hi uint64) {
return Fingerprint128(s)

View File

@@ -1,14 +1,19 @@
package farm
import (
"encoding/binary"
"math/bits"
)
func hash32Len5to12(s []byte, seed uint32) uint32 {
slen := len(s)
a := uint32(len(s))
b := uint32(len(s) * 5)
c := uint32(9)
d := b + seed
a += fetch32(s, 0)
b += fetch32(s, slen-4)
c += fetch32(s, ((slen >> 1) & 4))
a += binary.LittleEndian.Uint32(s[0 : 0+4])
b += binary.LittleEndian.Uint32(s[slen-4 : slen-4+4])
c += binary.LittleEndian.Uint32(s[((slen >> 1) & 4) : ((slen>>1)&4)+4])
return fmix(seed ^ mur(c, mur(b, mur(a, d))))
}
@@ -31,32 +36,31 @@ func Hash32(s []byte) uint32 {
h := uint32(slen)
g := c1 * uint32(slen)
f := g
a0 := rotate32(fetch32(s, slen-4)*c1, 17) * c2
a1 := rotate32(fetch32(s, slen-8)*c1, 17) * c2
a2 := rotate32(fetch32(s, slen-16)*c1, 17) * c2
a3 := rotate32(fetch32(s, slen-12)*c1, 17) * c2
a4 := rotate32(fetch32(s, slen-20)*c1, 17) * c2
a0 := bits.RotateLeft32(binary.LittleEndian.Uint32(s[slen-4:slen-4+4])*c1, -17) * c2
a1 := bits.RotateLeft32(binary.LittleEndian.Uint32(s[slen-8:slen-8+4])*c1, -17) * c2
a2 := bits.RotateLeft32(binary.LittleEndian.Uint32(s[slen-16:slen-16+4])*c1, -17) * c2
a3 := bits.RotateLeft32(binary.LittleEndian.Uint32(s[slen-12:slen-12+4])*c1, -17) * c2
a4 := bits.RotateLeft32(binary.LittleEndian.Uint32(s[slen-20:slen-20+4])*c1, -17) * c2
h ^= a0
h = rotate32(h, 19)
h = bits.RotateLeft32(h, -19)
h = h*5 + 0xe6546b64
h ^= a2
h = rotate32(h, 19)
h = bits.RotateLeft32(h, -19)
h = h*5 + 0xe6546b64
g ^= a1
g = rotate32(g, 19)
g = bits.RotateLeft32(g, -19)
g = g*5 + 0xe6546b64
g ^= a3
g = rotate32(g, 19)
g = bits.RotateLeft32(g, -19)
g = g*5 + 0xe6546b64
f += a4
f = rotate32(f, 19) + 113
iters := (slen - 1) / 20
for {
a := fetch32(s, 0)
b := fetch32(s, 4)
c := fetch32(s, 8)
d := fetch32(s, 12)
e := fetch32(s, 16)
f = bits.RotateLeft32(f, -19) + 113
for len(s) > 20 {
a := binary.LittleEndian.Uint32(s[0 : 0+4])
b := binary.LittleEndian.Uint32(s[4 : 4+4])
c := binary.LittleEndian.Uint32(s[8 : 8+4])
d := binary.LittleEndian.Uint32(s[12 : 12+4])
e := binary.LittleEndian.Uint32(s[16 : 16+4])
h += a
g += b
f += c
@@ -66,21 +70,17 @@ func Hash32(s []byte) uint32 {
f += g
g += f
s = s[20:]
iters--
if iters == 0 {
break
}
}
g = rotate32(g, 11) * c1
g = rotate32(g, 17) * c1
f = rotate32(f, 11) * c1
f = rotate32(f, 17) * c1
h = rotate32(h+g, 19)
g = bits.RotateLeft32(g, -11) * c1
g = bits.RotateLeft32(g, -17) * c1
f = bits.RotateLeft32(f, -11) * c1
f = bits.RotateLeft32(f, -17) * c1
h = bits.RotateLeft32(h+g, -19)
h = h*5 + 0xe6546b64
h = rotate32(h, 17) * c1
h = rotate32(h+f, 19)
h = bits.RotateLeft32(h, -17) * c1
h = bits.RotateLeft32(h+f, -19)
h = h*5 + 0xe6546b64
h = rotate32(h, 17) * c1
h = bits.RotateLeft32(h, -17) * c1
return h
}

View File

@@ -1,5 +1,10 @@
package farm
import (
"encoding/binary"
"math/bits"
)
func shiftMix(val uint64) uint64 {
return val ^ (val >> 47)
}
@@ -22,17 +27,17 @@ func hashLen0to16(s []byte) uint64 {
slen := uint64(len(s))
if slen >= 8 {
mul := k2 + slen*2
a := fetch64(s, 0) + k2
b := fetch64(s, int(slen-8))
c := rotate64(b, 37)*mul + a
d := (rotate64(a, 25) + b) * mul
a := binary.LittleEndian.Uint64(s[0:0+8]) + k2
b := binary.LittleEndian.Uint64(s[int(slen-8) : int(slen-8)+8])
c := bits.RotateLeft64(b, -37)*mul + a
d := (bits.RotateLeft64(a, -25) + b) * mul
return hashLen16Mul(c, d, mul)
}
if slen >= 4 {
mul := k2 + slen*2
a := fetch32(s, 0)
return hashLen16Mul(slen+(uint64(a)<<3), uint64(fetch32(s, int(slen-4))), mul)
a := binary.LittleEndian.Uint32(s[0 : 0+4])
return hashLen16Mul(slen+(uint64(a)<<3), uint64(binary.LittleEndian.Uint32(s[int(slen-4):int(slen-4)+4])), mul)
}
if slen > 0 {
a := s[0]
@@ -50,31 +55,31 @@ func hashLen0to16(s []byte) uint64 {
func hashLen17to32(s []byte) uint64 {
slen := len(s)
mul := k2 + uint64(slen*2)
a := fetch64(s, 0) * k1
b := fetch64(s, 8)
c := fetch64(s, slen-8) * mul
d := fetch64(s, slen-16) * k2
return hashLen16Mul(rotate64(a+b, 43)+rotate64(c, 30)+d, a+rotate64(b+k2, 18)+c, mul)
a := binary.LittleEndian.Uint64(s[0:0+8]) * k1
b := binary.LittleEndian.Uint64(s[8 : 8+8])
c := binary.LittleEndian.Uint64(s[slen-8:slen-8+8]) * mul
d := binary.LittleEndian.Uint64(s[slen-16:slen-16+8]) * k2
return hashLen16Mul(bits.RotateLeft64(a+b, -43)+bits.RotateLeft64(c, -30)+d, a+bits.RotateLeft64(b+k2, -18)+c, mul)
}
// Return a 16-byte hash for 48 bytes. Quick and dirty.
// Callers do best to use "random-looking" values for a and b.
func weakHashLen32WithSeedsWords(w, x, y, z, a, b uint64) (uint64, uint64) {
a += w
b = rotate64(b+a+z, 21)
b = bits.RotateLeft64(b+a+z, -21)
c := a
a += x
a += y
b += rotate64(a, 44)
b += bits.RotateLeft64(a, -44)
return a + z, b + c
}
// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
func weakHashLen32WithSeeds(s []byte, a, b uint64) (uint64, uint64) {
return weakHashLen32WithSeedsWords(fetch64(s, 0),
fetch64(s, 8),
fetch64(s, 16),
fetch64(s, 24),
return weakHashLen32WithSeedsWords(binary.LittleEndian.Uint64(s[0:0+8]),
binary.LittleEndian.Uint64(s[8:8+8]),
binary.LittleEndian.Uint64(s[16:16+8]),
binary.LittleEndian.Uint64(s[24:24+8]),
a,
b)
}
@@ -83,17 +88,17 @@ func weakHashLen32WithSeeds(s []byte, a, b uint64) (uint64, uint64) {
func hashLen33to64(s []byte) uint64 {
slen := len(s)
mul := k2 + uint64(slen)*2
a := fetch64(s, 0) * k2
b := fetch64(s, 8)
c := fetch64(s, slen-8) * mul
d := fetch64(s, slen-16) * k2
y := rotate64(a+b, 43) + rotate64(c, 30) + d
z := hashLen16Mul(y, a+rotate64(b+k2, 18)+c, mul)
e := fetch64(s, 16) * mul
f := fetch64(s, 24)
g := (y + fetch64(s, slen-32)) * mul
h := (z + fetch64(s, slen-24)) * mul
return hashLen16Mul(rotate64(e+f, 43)+rotate64(g, 30)+h, e+rotate64(f+a, 18)+g, mul)
a := binary.LittleEndian.Uint64(s[0:0+8]) * k2
b := binary.LittleEndian.Uint64(s[8 : 8+8])
c := binary.LittleEndian.Uint64(s[slen-8:slen-8+8]) * mul
d := binary.LittleEndian.Uint64(s[slen-16:slen-16+8]) * k2
y := bits.RotateLeft64(a+b, -43) + bits.RotateLeft64(c, -30) + d
z := hashLen16Mul(y, a+bits.RotateLeft64(b+k2, -18)+c, mul)
e := binary.LittleEndian.Uint64(s[16:16+8]) * mul
f := binary.LittleEndian.Uint64(s[24 : 24+8])
g := (y + binary.LittleEndian.Uint64(s[slen-32:slen-32+8])) * mul
h := (z + binary.LittleEndian.Uint64(s[slen-24:slen-24+8])) * mul
return hashLen16Mul(bits.RotateLeft64(e+f, -43)+bits.RotateLeft64(g, -30)+h, e+bits.RotateLeft64(f+a, -18)+g, mul)
}
func naHash64(s []byte) uint64 {
@@ -112,7 +117,7 @@ func naHash64(s []byte) uint64 {
// Internal state consists of 56 bytes: v, w, x, y, and z.
v := uint128{0, 0}
w := uint128{0, 0}
x := seed*k2 + fetch64(s, 0)
x := seed*k2 + binary.LittleEndian.Uint64(s[0:0+8])
y := seed*k1 + 113
z := shiftMix(y*k2+113) * k2
// Set end so that after the loop we have 1 to 64 bytes left to process.
@@ -120,13 +125,13 @@ func naHash64(s []byte) uint64 {
last64Idx := endIdx + ((slen - 1) & 63) - 63
last64 := s[last64Idx:]
for len(s) > 64 {
x = rotate64(x+y+v.lo+fetch64(s, 8), 37) * k1
y = rotate64(y+v.hi+fetch64(s, 48), 42) * k1
x = bits.RotateLeft64(x+y+v.lo+binary.LittleEndian.Uint64(s[8:8+8]), -37) * k1
y = bits.RotateLeft64(y+v.hi+binary.LittleEndian.Uint64(s[48:48+8]), -42) * k1
x ^= w.hi
y += v.lo + fetch64(s, 40)
z = rotate64(z+w.lo, 33) * k1
y += v.lo + binary.LittleEndian.Uint64(s[40:40+8])
z = bits.RotateLeft64(z+w.lo, -33) * k1
v.lo, v.hi = weakHashLen32WithSeeds(s, v.hi*k1, x+w.lo)
w.lo, w.hi = weakHashLen32WithSeeds(s[32:], z+w.hi, y+fetch64(s, 16))
w.lo, w.hi = weakHashLen32WithSeeds(s[32:], z+w.hi, y+binary.LittleEndian.Uint64(s[16:16+8]))
x, z = z, x
s = s[64:]
}
@@ -136,13 +141,13 @@ func naHash64(s []byte) uint64 {
w.lo += (uint64(slen-1) & 63)
v.lo += w.lo
w.lo += v.lo
x = rotate64(x+y+v.lo+fetch64(s, 8), 37) * mul
y = rotate64(y+v.hi+fetch64(s, 48), 42) * mul
x = bits.RotateLeft64(x+y+v.lo+binary.LittleEndian.Uint64(s[8:8+8]), -37) * mul
y = bits.RotateLeft64(y+v.hi+binary.LittleEndian.Uint64(s[48:48+8]), -42) * mul
x ^= w.hi * 9
y += v.lo*9 + fetch64(s, 40)
z = rotate64(z+w.lo, 33) * mul
y += v.lo*9 + binary.LittleEndian.Uint64(s[40:40+8])
z = bits.RotateLeft64(z+w.lo, -33) * mul
v.lo, v.hi = weakHashLen32WithSeeds(s, v.hi*mul, x+w.lo)
w.lo, w.hi = weakHashLen32WithSeeds(s[32:], z+w.hi, y+fetch64(s, 16))
w.lo, w.hi = weakHashLen32WithSeeds(s[32:], z+w.hi, y+binary.LittleEndian.Uint64(s[16:16+8]))
x, z = z, x
return hashLen16Mul(hashLen16Mul(v.lo, w.lo, mul)+shiftMix(y)*k0+z, hashLen16Mul(v.hi, w.hi, mul)+x, mul)
}

View File

@@ -1,10 +1,15 @@
package farm
import (
"encoding/binary"
"math/bits"
)
func uoH(x, y, mul uint64, r uint) uint64 {
a := (x ^ y) * mul
a ^= (a >> 47)
b := (y ^ a) * mul
return rotate64(b, r) * mul
return bits.RotateLeft64(b, -int(r)) * mul
}
// Hash64WithSeeds hashes a byte slice and two uint64 seeds and returns a uint64 hash value
@@ -31,14 +36,14 @@ func Hash64WithSeeds(s []byte, seed0, seed1 uint64) uint64 {
last64 := s[last64Idx:]
for len(s) > 64 {
a0 := fetch64(s, 0)
a1 := fetch64(s, 8)
a2 := fetch64(s, 16)
a3 := fetch64(s, 24)
a4 := fetch64(s, 32)
a5 := fetch64(s, 40)
a6 := fetch64(s, 48)
a7 := fetch64(s, 56)
a0 := binary.LittleEndian.Uint64(s[0 : 0+8])
a1 := binary.LittleEndian.Uint64(s[8 : 8+8])
a2 := binary.LittleEndian.Uint64(s[16 : 16+8])
a3 := binary.LittleEndian.Uint64(s[24 : 24+8])
a4 := binary.LittleEndian.Uint64(s[32 : 32+8])
a5 := binary.LittleEndian.Uint64(s[40 : 40+8])
a6 := binary.LittleEndian.Uint64(s[48 : 48+8])
a7 := binary.LittleEndian.Uint64(s[56 : 56+8])
x += a0 + a1
y += a2
z += a3
@@ -47,15 +52,15 @@ func Hash64WithSeeds(s []byte, seed0, seed1 uint64) uint64 {
w.lo += a6
w.hi += a7
x = rotate64(x, 26)
x = bits.RotateLeft64(x, -26)
x *= 9
y = rotate64(y, 29)
y = bits.RotateLeft64(y, -29)
z *= mul
v.lo = rotate64(v.lo, 33)
v.hi = rotate64(v.hi, 30)
v.lo = bits.RotateLeft64(v.lo, -33)
v.hi = bits.RotateLeft64(v.hi, -30)
w.lo ^= x
w.lo *= 9
z = rotate64(z, 32)
z = bits.RotateLeft64(z, -32)
z += w.hi
w.hi += z
z *= 9
@@ -75,25 +80,25 @@ func Hash64WithSeeds(s []byte, seed0, seed1 uint64) uint64 {
w.lo += v.hi
w.hi += x - y
x += w.hi
w.hi = rotate64(w.hi, 34)
w.hi = bits.RotateLeft64(w.hi, -34)
u, z = z, u
s = s[64:]
}
// Make s point to the last 64 bytes of input.
s = last64
u *= 9
v.hi = rotate64(v.hi, 28)
v.lo = rotate64(v.lo, 20)
v.hi = bits.RotateLeft64(v.hi, -28)
v.lo = bits.RotateLeft64(v.lo, -20)
w.lo += (uint64(slen-1) & 63)
u += y
y += u
x = rotate64(y-x+v.lo+fetch64(s, 8), 37) * mul
y = rotate64(y^v.hi^fetch64(s, 48), 42) * mul
x = bits.RotateLeft64(y-x+v.lo+binary.LittleEndian.Uint64(s[8:8+8]), -37) * mul
y = bits.RotateLeft64(y^v.hi^binary.LittleEndian.Uint64(s[48:48+8]), -42) * mul
x ^= w.hi * 9
y += v.lo + fetch64(s, 40)
z = rotate64(z+w.lo, 33) * mul
y += v.lo + binary.LittleEndian.Uint64(s[40:40+8])
z = bits.RotateLeft64(z+w.lo, -33) * mul
v.lo, v.hi = weakHashLen32WithSeeds(s, v.hi*mul, x+w.lo)
w.lo, w.hi = weakHashLen32WithSeeds(s[32:], z+w.hi, y+fetch64(s, 16))
w.lo, w.hi = weakHashLen32WithSeeds(s[32:], z+w.hi, y+binary.LittleEndian.Uint64(s[16:16+8]))
return uoH(hashLen16Mul(v.lo+x, w.lo^y, mul)+z-u,
uoH(v.hi+y, w.hi+z, k2, 30)^x,
k2,
@@ -109,7 +114,7 @@ func Hash64WithSeed(s []byte, seed uint64) uint64 {
}
// Hash64 hashes a byte slice and returns a uint64 hash value
func Hash64(s []byte) uint64 {
func uoHash64(s []byte) uint64 {
if len(s) <= 64 {
return naHash64(s)
}

104
vendor/github.com/dgryski/go-farm/farmhashxo.go generated vendored Normal file
View File

@@ -0,0 +1,104 @@
package farm
import (
"encoding/binary"
"math/bits"
)
func h32(s []byte, mul uint64) uint64 {
slen := len(s)
a := binary.LittleEndian.Uint64(s[0:0+8]) * k1
b := binary.LittleEndian.Uint64(s[8 : 8+8])
c := binary.LittleEndian.Uint64(s[slen-8:slen-8+8]) * mul
d := binary.LittleEndian.Uint64(s[slen-16:slen-16+8]) * k2
u := bits.RotateLeft64(a+b, -43) + bits.RotateLeft64(c, -30) + d
v := a + bits.RotateLeft64(b+k2, -18) + c
a = shiftMix((u ^ v) * mul)
b = shiftMix((v ^ a) * mul)
return b
}
func h32Seeds(s []byte, mul, seed0, seed1 uint64) uint64 {
slen := len(s)
a := binary.LittleEndian.Uint64(s[0:0+8]) * k1
b := binary.LittleEndian.Uint64(s[8 : 8+8])
c := binary.LittleEndian.Uint64(s[slen-8:slen-8+8]) * mul
d := binary.LittleEndian.Uint64(s[slen-16:slen-16+8]) * k2
u := bits.RotateLeft64(a+b, -43) + bits.RotateLeft64(c, -30) + d + seed0
v := a + bits.RotateLeft64(b+k2, -18) + c + seed1
a = shiftMix((u ^ v) * mul)
b = shiftMix((v ^ a) * mul)
return b
}
func xohashLen33to64(s []byte) uint64 {
slen := len(s)
mul0 := k2 - 30
mul1 := k2 - 30 + 2*uint64(slen)
var h0 uint64
{
s := s[0:32]
mul := mul0
slen := len(s)
a := binary.LittleEndian.Uint64(s[0:0+8]) * k1
b := binary.LittleEndian.Uint64(s[8 : 8+8])
c := binary.LittleEndian.Uint64(s[slen-8:slen-8+8]) * mul
d := binary.LittleEndian.Uint64(s[slen-16:slen-16+8]) * k2
u := bits.RotateLeft64(a+b, -43) + bits.RotateLeft64(c, -30) + d
v := a + bits.RotateLeft64(b+k2, -18) + c
a = shiftMix((u ^ v) * mul)
b = shiftMix((v ^ a) * mul)
h0 = b
}
var h1 uint64
{
s := s[slen-32:]
mul := mul1
slen := len(s)
a := binary.LittleEndian.Uint64(s[0:0+8]) * k1
b := binary.LittleEndian.Uint64(s[8 : 8+8])
c := binary.LittleEndian.Uint64(s[slen-8:slen-8+8]) * mul
d := binary.LittleEndian.Uint64(s[slen-16:slen-16+8]) * k2
u := bits.RotateLeft64(a+b, -43) + bits.RotateLeft64(c, -30) + d
v := a + bits.RotateLeft64(b+k2, -18) + c
a = shiftMix((u ^ v) * mul)
b = shiftMix((v ^ a) * mul)
h1 = b
}
r := ((h1 * mul1) + h0) * mul1
return r
}
func xohashLen65to96(s []byte) uint64 {
slen := len(s)
mul0 := k2 - 114
mul1 := k2 - 114 + 2*uint64(slen)
h0 := h32(s[:32], mul0)
h1 := h32(s[32:64], mul1)
h2 := h32Seeds(s[slen-32:], mul1, h0, h1)
return (h2*9 + (h0 >> 17) + (h1 >> 21)) * mul1
}
func Hash64(s []byte) uint64 {
slen := len(s)
if slen <= 32 {
if slen <= 16 {
return hashLen0to16(s)
} else {
return hashLen17to32(s)
}
} else if slen <= 64 {
return xohashLen33to64(s)
} else if slen <= 96 {
return xohashLen65to96(s)
} else if slen <= 256 {
return naHash64(s)
} else {
return uoHash64(s)
}
}

951
vendor/github.com/dgryski/go-farm/fp_amd64.s generated vendored Normal file
View File

@@ -0,0 +1,951 @@
// Code generated by command: go run asm.go -out=fp_amd64.s -go111=false. DO NOT EDIT.
// +build amd64,!purego
#include "textflag.h"
// func Fingerprint64(s []byte) uint64
TEXT ·Fingerprint64(SB), NOSPLIT, $0-32
MOVQ s_base+0(FP), CX
MOVQ s_len+8(FP), AX
CMPQ AX, $0x10
JG check32
CMPQ AX, $0x08
JL check4
MOVQ (CX), DX
MOVQ AX, BX
SUBQ $0x08, BX
ADDQ CX, BX
MOVQ (BX), BX
MOVQ $0x9ae16a3b2f90404f, BP
ADDQ BP, DX
SHLQ $0x01, AX
ADDQ BP, AX
MOVQ BX, BP
RORQ $0x25, BP
IMULQ AX, BP
ADDQ DX, BP
RORQ $0x19, DX
ADDQ BX, DX
IMULQ AX, DX
XORQ DX, BP
IMULQ AX, BP
MOVQ BP, BX
SHRQ $0x2f, BX
XORQ BP, BX
XORQ BX, DX
IMULQ AX, DX
MOVQ DX, BX
SHRQ $0x2f, BX
XORQ DX, BX
IMULQ AX, BX
MOVQ BX, ret+24(FP)
RET
check4:
CMPQ AX, $0x04
JL check0
MOVQ $0x9ae16a3b2f90404f, DX
MOVQ AX, BX
SHLQ $0x01, BX
ADDQ DX, BX
MOVL (CX), SI
SHLQ $0x03, SI
ADDQ AX, SI
SUBQ $0x04, AX
ADDQ AX, CX
MOVL (CX), DI
XORQ DI, SI
IMULQ BX, SI
MOVQ SI, DX
SHRQ $0x2f, DX
XORQ SI, DX
XORQ DX, DI
IMULQ BX, DI
MOVQ DI, DX
SHRQ $0x2f, DX
XORQ DI, DX
IMULQ BX, DX
MOVQ DX, ret+24(FP)
RET
check0:
TESTQ AX, AX
JZ empty
MOVBQZX (CX), DX
MOVQ AX, BX
SHRQ $0x01, BX
ADDQ CX, BX
MOVBQZX (BX), BP
MOVQ AX, BX
SUBQ $0x01, BX
ADDQ CX, BX
MOVBQZX (BX), BX
SHLQ $0x08, BP
ADDQ BP, DX
SHLQ $0x02, BX
ADDQ BX, AX
MOVQ $0xc3a5c85c97cb3127, BX
IMULQ BX, AX
MOVQ $0x9ae16a3b2f90404f, BX
IMULQ BX, DX
XORQ DX, AX
MOVQ AX, DX
SHRQ $0x2f, DX
XORQ AX, DX
IMULQ BX, DX
MOVQ DX, ret+24(FP)
RET
empty:
MOVQ $0x9ae16a3b2f90404f, DX
MOVQ DX, ret+24(FP)
RET
check32:
CMPQ AX, $0x20
JG check64
MOVQ AX, DX
SHLQ $0x01, DX
MOVQ $0x9ae16a3b2f90404f, BX
ADDQ BX, DX
MOVQ (CX), BP
MOVQ $0xb492b66fbe98f273, SI
IMULQ SI, BP
MOVQ 8(CX), SI
MOVQ AX, DI
SUBQ $0x10, DI
ADDQ CX, DI
MOVQ 8(DI), R12
IMULQ DX, R12
MOVQ (DI), DI
IMULQ BX, DI
MOVQ BP, R13
ADDQ SI, R13
RORQ $0x2b, R13
ADDQ DI, R13
MOVQ R12, DI
RORQ $0x1e, DI
ADDQ DI, R13
ADDQ R12, BP
ADDQ BX, SI
RORQ $0x12, SI
ADDQ SI, BP
XORQ BP, R13
IMULQ DX, R13
MOVQ R13, BX
SHRQ $0x2f, BX
XORQ R13, BX
XORQ BX, BP
IMULQ DX, BP
MOVQ BP, BX
SHRQ $0x2f, BX
XORQ BP, BX
IMULQ DX, BX
MOVQ BX, ret+24(FP)
RET
check64:
CMPQ AX, $0x40
JG long
MOVQ AX, DX
SHLQ $0x01, DX
MOVQ $0x9ae16a3b2f90404f, BX
ADDQ BX, DX
MOVQ (CX), BP
IMULQ BX, BP
MOVQ 8(CX), SI
MOVQ AX, DI
SUBQ $0x10, DI
ADDQ CX, DI
MOVQ 8(DI), R12
IMULQ DX, R12
MOVQ (DI), DI
IMULQ BX, DI
MOVQ BP, R13
ADDQ SI, R13
RORQ $0x2b, R13
ADDQ DI, R13
MOVQ R12, DI
RORQ $0x1e, DI
ADDQ DI, R13
ADDQ BP, R12
ADDQ BX, SI
RORQ $0x12, SI
ADDQ SI, R12
MOVQ R13, BX
XORQ R12, BX
IMULQ DX, BX
MOVQ BX, SI
SHRQ $0x2f, SI
XORQ BX, SI
XORQ SI, R12
IMULQ DX, R12
MOVQ R12, BX
SHRQ $0x2f, BX
XORQ R12, BX
IMULQ DX, BX
MOVQ 16(CX), SI
IMULQ DX, SI
MOVQ 24(CX), DI
MOVQ AX, R12
SUBQ $0x20, R12
ADDQ CX, R12
MOVQ (R12), R14
ADDQ R13, R14
IMULQ DX, R14
MOVQ 8(R12), R12
ADDQ BX, R12
IMULQ DX, R12
MOVQ SI, BX
ADDQ DI, BX
RORQ $0x2b, BX
ADDQ R12, BX
MOVQ R14, R12
RORQ $0x1e, R12
ADDQ R12, BX
ADDQ R14, SI
ADDQ BP, DI
RORQ $0x12, DI
ADDQ DI, SI
XORQ SI, BX
IMULQ DX, BX
MOVQ BX, BP
SHRQ $0x2f, BP
XORQ BX, BP
XORQ BP, SI
IMULQ DX, SI
MOVQ SI, BX
SHRQ $0x2f, BX
XORQ SI, BX
IMULQ DX, BX
MOVQ BX, ret+24(FP)
RET
long:
XORQ R8, R8
XORQ R9, R9
XORQ R10, R10
XORQ R11, R11
MOVQ $0x01529cba0ca458ff, DX
ADDQ (CX), DX
MOVQ $0x226bb95b4e64b6d4, BX
MOVQ $0x134a747f856d0526, BP
MOVQ AX, SI
SUBQ $0x01, SI
MOVQ $0xffffffffffffffc0, DI
ANDQ DI, SI
MOVQ AX, DI
SUBQ $0x01, DI
ANDQ $0x3f, DI
SUBQ $0x3f, DI
ADDQ SI, DI
MOVQ DI, SI
ADDQ CX, SI
MOVQ AX, DI
loop:
MOVQ $0xb492b66fbe98f273, R12
ADDQ BX, DX
ADDQ R8, DX
ADDQ 8(CX), DX
RORQ $0x25, DX
IMULQ R12, DX
ADDQ R9, BX
ADDQ 48(CX), BX
RORQ $0x2a, BX
IMULQ R12, BX
XORQ R11, DX
ADDQ R8, BX
ADDQ 40(CX), BX
ADDQ R10, BP
RORQ $0x21, BP
IMULQ R12, BP
IMULQ R12, R9
MOVQ DX, R8
ADDQ R10, R8
ADDQ (CX), R9
ADDQ R9, R8
ADDQ 24(CX), R8
RORQ $0x15, R8
MOVQ R9, R10
ADDQ 8(CX), R9
ADDQ 16(CX), R9
MOVQ R9, R13
RORQ $0x2c, R13
ADDQ R13, R8
ADDQ 24(CX), R9
ADDQ R10, R8
XCHGQ R9, R8
ADDQ BP, R11
MOVQ BX, R10
ADDQ 16(CX), R10
ADDQ 32(CX), R11
ADDQ R11, R10
ADDQ 56(CX), R10
RORQ $0x15, R10
MOVQ R11, R13
ADDQ 40(CX), R11
ADDQ 48(CX), R11
MOVQ R11, R14
RORQ $0x2c, R14
ADDQ R14, R10
ADDQ 56(CX), R11
ADDQ R13, R10
XCHGQ R11, R10
XCHGQ BP, DX
ADDQ $0x40, CX
SUBQ $0x40, DI
CMPQ DI, $0x40
JG loop
MOVQ SI, CX
MOVQ BP, DI
ANDQ $0xff, DI
SHLQ $0x01, DI
ADDQ R12, DI
MOVQ SI, CX
SUBQ $0x01, AX
ANDQ $0x3f, AX
ADDQ AX, R10
ADDQ R10, R8
ADDQ R8, R10
ADDQ BX, DX
ADDQ R8, DX
ADDQ 8(CX), DX
RORQ $0x25, DX
IMULQ DI, DX
ADDQ R9, BX
ADDQ 48(CX), BX
RORQ $0x2a, BX
IMULQ DI, BX
MOVQ $0x00000009, AX
IMULQ R11, AX
XORQ AX, DX
MOVQ $0x00000009, AX
IMULQ R8, AX
ADDQ AX, BX
ADDQ 40(CX), BX
ADDQ R10, BP
RORQ $0x21, BP
IMULQ DI, BP
IMULQ DI, R9
MOVQ DX, R8
ADDQ R10, R8
ADDQ (CX), R9
ADDQ R9, R8
ADDQ 24(CX), R8
RORQ $0x15, R8
MOVQ R9, AX
ADDQ 8(CX), R9
ADDQ 16(CX), R9
MOVQ R9, SI
RORQ $0x2c, SI
ADDQ SI, R8
ADDQ 24(CX), R9
ADDQ AX, R8
XCHGQ R9, R8
ADDQ BP, R11
MOVQ BX, R10
ADDQ 16(CX), R10
ADDQ 32(CX), R11
ADDQ R11, R10
ADDQ 56(CX), R10
RORQ $0x15, R10
MOVQ R11, AX
ADDQ 40(CX), R11
ADDQ 48(CX), R11
MOVQ R11, SI
RORQ $0x2c, SI
ADDQ SI, R10
ADDQ 56(CX), R11
ADDQ AX, R10
XCHGQ R11, R10
XCHGQ BP, DX
XORQ R10, R8
IMULQ DI, R8
MOVQ R8, AX
SHRQ $0x2f, AX
XORQ R8, AX
XORQ AX, R10
IMULQ DI, R10
MOVQ R10, AX
SHRQ $0x2f, AX
XORQ R10, AX
IMULQ DI, AX
ADDQ BP, AX
MOVQ BX, CX
SHRQ $0x2f, CX
XORQ BX, CX
MOVQ $0xc3a5c85c97cb3127, BX
IMULQ BX, CX
ADDQ CX, AX
XORQ R11, R9
IMULQ DI, R9
MOVQ R9, CX
SHRQ $0x2f, CX
XORQ R9, CX
XORQ CX, R11
IMULQ DI, R11
MOVQ R11, CX
SHRQ $0x2f, CX
XORQ R11, CX
IMULQ DI, CX
ADDQ DX, CX
XORQ CX, AX
IMULQ DI, AX
MOVQ AX, DX
SHRQ $0x2f, DX
XORQ AX, DX
XORQ DX, CX
IMULQ DI, CX
MOVQ CX, AX
SHRQ $0x2f, AX
XORQ CX, AX
IMULQ DI, AX
MOVQ AX, ret+24(FP)
RET
// func Fingerprint32(s []byte) uint32
TEXT ·Fingerprint32(SB), NOSPLIT, $0-28
MOVQ s_base+0(FP), AX
MOVQ s_len+8(FP), CX
CMPQ CX, $0x18
JG long
CMPQ CX, $0x0c
JG hash_13_24
CMPQ CX, $0x04
JG hash_5_12
XORL DX, DX
MOVL $0x00000009, BX
TESTQ CX, CX
JZ done
MOVQ CX, BP
MOVL $0xcc9e2d51, DI
IMULL DI, DX
MOVBLSX (AX), SI
ADDL SI, DX
XORL DX, BX
SUBQ $0x01, BP
TESTQ BP, BP
JZ done
IMULL DI, DX
MOVBLSX 1(AX), SI
ADDL SI, DX
XORL DX, BX
SUBQ $0x01, BP
TESTQ BP, BP
JZ done
IMULL DI, DX
MOVBLSX 2(AX), SI
ADDL SI, DX
XORL DX, BX
SUBQ $0x01, BP
TESTQ BP, BP
JZ done
IMULL DI, DX
MOVBLSX 3(AX), SI
ADDL SI, DX
XORL DX, BX
SUBQ $0x01, BP
TESTQ BP, BP
JZ done
done:
MOVL CX, BP
MOVL $0xcc9e2d51, SI
IMULL SI, BP
RORL $0x11, BP
MOVL $0x1b873593, SI
IMULL SI, BP
XORL BP, BX
RORL $0x13, BX
LEAL (BX)(BX*4), BP
LEAL 3864292196(BP), BX
MOVL $0xcc9e2d51, BP
IMULL BP, DX
RORL $0x11, DX
MOVL $0x1b873593, BP
IMULL BP, DX
XORL DX, BX
RORL $0x13, BX
LEAL (BX)(BX*4), DX
LEAL 3864292196(DX), BX
MOVL BX, DX
SHRL $0x10, DX
XORL DX, BX
MOVL $0x85ebca6b, DX
IMULL DX, BX
MOVL BX, DX
SHRL $0x0d, DX
XORL DX, BX
MOVL $0xc2b2ae35, DX
IMULL DX, BX
MOVL BX, DX
SHRL $0x10, DX
XORL DX, BX
MOVL BX, ret+24(FP)
RET
hash_5_12:
MOVL CX, DX
MOVL DX, BX
SHLL $0x02, BX
ADDL DX, BX
MOVL $0x00000009, BP
MOVL BX, SI
ADDL (AX), DX
MOVQ CX, DI
SUBQ $0x04, DI
ADDQ AX, DI
ADDL (DI), BX
MOVQ CX, DI
SHRQ $0x01, DI
ANDQ $0x04, DI
ADDQ AX, DI
ADDL (DI), BP
MOVL $0xcc9e2d51, DI
IMULL DI, DX
RORL $0x11, DX
MOVL $0x1b873593, DI
IMULL DI, DX
XORL DX, SI
RORL $0x13, SI
LEAL (SI)(SI*4), DX
LEAL 3864292196(DX), SI
MOVL $0xcc9e2d51, DX
IMULL DX, BX
RORL $0x11, BX
MOVL $0x1b873593, DX
IMULL DX, BX
XORL BX, SI
RORL $0x13, SI
LEAL (SI)(SI*4), BX
LEAL 3864292196(BX), SI
MOVL $0xcc9e2d51, DX
IMULL DX, BP
RORL $0x11, BP
MOVL $0x1b873593, DX
IMULL DX, BP
XORL BP, SI
RORL $0x13, SI
LEAL (SI)(SI*4), BP
LEAL 3864292196(BP), SI
MOVL SI, DX
SHRL $0x10, DX
XORL DX, SI
MOVL $0x85ebca6b, DX
IMULL DX, SI
MOVL SI, DX
SHRL $0x0d, DX
XORL DX, SI
MOVL $0xc2b2ae35, DX
IMULL DX, SI
MOVL SI, DX
SHRL $0x10, DX
XORL DX, SI
MOVL SI, ret+24(FP)
RET
hash_13_24:
MOVQ CX, DX
SHRQ $0x01, DX
ADDQ AX, DX
MOVL -4(DX), BX
MOVL 4(AX), BP
MOVQ CX, SI
ADDQ AX, SI
MOVL -8(SI), DI
MOVL (DX), DX
MOVL (AX), R8
MOVL -4(SI), SI
MOVL $0xcc9e2d51, R9
IMULL DX, R9
ADDL CX, R9
RORL $0x0c, BX
ADDL SI, BX
MOVL DI, R10
MOVL $0xcc9e2d51, R11
IMULL R11, R10
RORL $0x11, R10
MOVL $0x1b873593, R11
IMULL R11, R10
XORL R10, R9
RORL $0x13, R9
LEAL (R9)(R9*4), R10
LEAL 3864292196(R10), R9
ADDL BX, R9
RORL $0x03, BX
ADDL DI, BX
MOVL $0xcc9e2d51, DI
IMULL DI, R8
RORL $0x11, R8
MOVL $0x1b873593, DI
IMULL DI, R8
XORL R8, R9
RORL $0x13, R9
LEAL (R9)(R9*4), R8
LEAL 3864292196(R8), R9
ADDL BX, R9
ADDL SI, BX
RORL $0x0c, BX
ADDL DX, BX
MOVL $0xcc9e2d51, DX
IMULL DX, BP
RORL $0x11, BP
MOVL $0x1b873593, DX
IMULL DX, BP
XORL BP, R9
RORL $0x13, R9
LEAL (R9)(R9*4), BP
LEAL 3864292196(BP), R9
ADDL BX, R9
MOVL R9, DX
SHRL $0x10, DX
XORL DX, R9
MOVL $0x85ebca6b, DX
IMULL DX, R9
MOVL R9, DX
SHRL $0x0d, DX
XORL DX, R9
MOVL $0xc2b2ae35, DX
IMULL DX, R9
MOVL R9, DX
SHRL $0x10, DX
XORL DX, R9
MOVL R9, ret+24(FP)
RET
long:
MOVL CX, DX
MOVL $0xcc9e2d51, BX
IMULL DX, BX
MOVL BX, BP
MOVQ CX, SI
ADDQ AX, SI
MOVL $0xcc9e2d51, DI
MOVL $0x1b873593, R8
MOVL -4(SI), R9
IMULL DI, R9
RORL $0x11, R9
IMULL R8, R9
XORL R9, DX
RORL $0x13, DX
MOVL DX, R9
SHLL $0x02, R9
ADDL R9, DX
ADDL $0xe6546b64, DX
MOVL -8(SI), R9
IMULL DI, R9
RORL $0x11, R9
IMULL R8, R9
XORL R9, BX
RORL $0x13, BX
MOVL BX, R9
SHLL $0x02, R9
ADDL R9, BX
ADDL $0xe6546b64, BX
MOVL -16(SI), R9
IMULL DI, R9
RORL $0x11, R9
IMULL R8, R9
XORL R9, DX
RORL $0x13, DX
MOVL DX, R9
SHLL $0x02, R9
ADDL R9, DX
ADDL $0xe6546b64, DX
MOVL -12(SI), R9
IMULL DI, R9
RORL $0x11, R9
IMULL R8, R9
XORL R9, BX
RORL $0x13, BX
MOVL BX, R9
SHLL $0x02, R9
ADDL R9, BX
ADDL $0xe6546b64, BX
PREFETCHT0 (AX)
MOVL -20(SI), SI
IMULL DI, SI
RORL $0x11, SI
IMULL R8, SI
ADDL SI, BP
RORL $0x13, BP
ADDL $0x71, BP
loop80:
CMPQ CX, $0x64
JL loop20
PREFETCHT0 20(AX)
MOVL (AX), SI
ADDL SI, DX
MOVL 4(AX), DI
ADDL DI, BX
MOVL 8(AX), R8
ADDL R8, BP
MOVL 12(AX), R9
MOVL R9, R11
MOVL $0xcc9e2d51, R10
IMULL R10, R11
RORL $0x11, R11
MOVL $0x1b873593, R10
IMULL R10, R11
XORL R11, DX
RORL $0x13, DX
LEAL (DX)(DX*4), R11
LEAL 3864292196(R11), DX
MOVL 16(AX), R10
ADDL R10, DX
MOVL R8, R11
MOVL $0xcc9e2d51, R8
IMULL R8, R11
RORL $0x11, R11
MOVL $0x1b873593, R8
IMULL R8, R11
XORL R11, BX
RORL $0x13, BX
LEAL (BX)(BX*4), R11
LEAL 3864292196(R11), BX
ADDL SI, BX
MOVL $0xcc9e2d51, SI
IMULL SI, R10
MOVL R10, R11
ADDL DI, R11
MOVL $0xcc9e2d51, SI
IMULL SI, R11
RORL $0x11, R11
MOVL $0x1b873593, SI
IMULL SI, R11
XORL R11, BP
RORL $0x13, BP
LEAL (BP)(BP*4), R11
LEAL 3864292196(R11), BP
ADDL R9, BP
ADDL BX, BP
ADDL BP, BX
PREFETCHT0 40(AX)
MOVL 20(AX), SI
ADDL SI, DX
MOVL 24(AX), DI
ADDL DI, BX
MOVL 28(AX), R8
ADDL R8, BP
MOVL 32(AX), R9
MOVL R9, R11
MOVL $0xcc9e2d51, R10
IMULL R10, R11
RORL $0x11, R11
MOVL $0x1b873593, R10
IMULL R10, R11
XORL R11, DX
RORL $0x13, DX
LEAL (DX)(DX*4), R11
LEAL 3864292196(R11), DX
MOVL 36(AX), R10
ADDL R10, DX
MOVL R8, R11
MOVL $0xcc9e2d51, R8
IMULL R8, R11
RORL $0x11, R11
MOVL $0x1b873593, R8
IMULL R8, R11
XORL R11, BX
RORL $0x13, BX
LEAL (BX)(BX*4), R11
LEAL 3864292196(R11), BX
ADDL SI, BX
MOVL $0xcc9e2d51, SI
IMULL SI, R10
MOVL R10, R11
ADDL DI, R11
MOVL $0xcc9e2d51, SI
IMULL SI, R11
RORL $0x11, R11
MOVL $0x1b873593, SI
IMULL SI, R11
XORL R11, BP
RORL $0x13, BP
LEAL (BP)(BP*4), R11
LEAL 3864292196(R11), BP
ADDL R9, BP
ADDL BX, BP
ADDL BP, BX
PREFETCHT0 60(AX)
MOVL 40(AX), SI
ADDL SI, DX
MOVL 44(AX), DI
ADDL DI, BX
MOVL 48(AX), R8
ADDL R8, BP
MOVL 52(AX), R9
MOVL R9, R11
MOVL $0xcc9e2d51, R10
IMULL R10, R11
RORL $0x11, R11
MOVL $0x1b873593, R10
IMULL R10, R11
XORL R11, DX
RORL $0x13, DX
LEAL (DX)(DX*4), R11
LEAL 3864292196(R11), DX
MOVL 56(AX), R10
ADDL R10, DX
MOVL R8, R11
MOVL $0xcc9e2d51, R8
IMULL R8, R11
RORL $0x11, R11
MOVL $0x1b873593, R8
IMULL R8, R11
XORL R11, BX
RORL $0x13, BX
LEAL (BX)(BX*4), R11
LEAL 3864292196(R11), BX
ADDL SI, BX
MOVL $0xcc9e2d51, SI
IMULL SI, R10
MOVL R10, R11
ADDL DI, R11
MOVL $0xcc9e2d51, SI
IMULL SI, R11
RORL $0x11, R11
MOVL $0x1b873593, SI
IMULL SI, R11
XORL R11, BP
RORL $0x13, BP
LEAL (BP)(BP*4), R11
LEAL 3864292196(R11), BP
ADDL R9, BP
ADDL BX, BP
ADDL BP, BX
PREFETCHT0 80(AX)
MOVL 60(AX), SI
ADDL SI, DX
MOVL 64(AX), DI
ADDL DI, BX
MOVL 68(AX), R8
ADDL R8, BP
MOVL 72(AX), R9
MOVL R9, R11
MOVL $0xcc9e2d51, R10
IMULL R10, R11
RORL $0x11, R11
MOVL $0x1b873593, R10
IMULL R10, R11
XORL R11, DX
RORL $0x13, DX
LEAL (DX)(DX*4), R11
LEAL 3864292196(R11), DX
MOVL 76(AX), R10
ADDL R10, DX
MOVL R8, R11
MOVL $0xcc9e2d51, R8
IMULL R8, R11
RORL $0x11, R11
MOVL $0x1b873593, R8
IMULL R8, R11
XORL R11, BX
RORL $0x13, BX
LEAL (BX)(BX*4), R11
LEAL 3864292196(R11), BX
ADDL SI, BX
MOVL $0xcc9e2d51, SI
IMULL SI, R10
MOVL R10, R11
ADDL DI, R11
MOVL $0xcc9e2d51, SI
IMULL SI, R11
RORL $0x11, R11
MOVL $0x1b873593, SI
IMULL SI, R11
XORL R11, BP
RORL $0x13, BP
LEAL (BP)(BP*4), R11
LEAL 3864292196(R11), BP
ADDL R9, BP
ADDL BX, BP
ADDL BP, BX
ADDQ $0x50, AX
SUBQ $0x50, CX
JMP loop80
loop20:
CMPQ CX, $0x14
JLE after
MOVL (AX), SI
ADDL SI, DX
MOVL 4(AX), DI
ADDL DI, BX
MOVL 8(AX), R8
ADDL R8, BP
MOVL 12(AX), R9
MOVL R9, R11
MOVL $0xcc9e2d51, R10
IMULL R10, R11
RORL $0x11, R11
MOVL $0x1b873593, R10
IMULL R10, R11
XORL R11, DX
RORL $0x13, DX
LEAL (DX)(DX*4), R11
LEAL 3864292196(R11), DX
MOVL 16(AX), R10
ADDL R10, DX
MOVL R8, R11
MOVL $0xcc9e2d51, R8
IMULL R8, R11
RORL $0x11, R11
MOVL $0x1b873593, R8
IMULL R8, R11
XORL R11, BX
RORL $0x13, BX
LEAL (BX)(BX*4), R11
LEAL 3864292196(R11), BX
ADDL SI, BX
MOVL $0xcc9e2d51, SI
IMULL SI, R10
MOVL R10, R11
ADDL DI, R11
MOVL $0xcc9e2d51, SI
IMULL SI, R11
RORL $0x11, R11
MOVL $0x1b873593, SI
IMULL SI, R11
XORL R11, BP
RORL $0x13, BP
LEAL (BP)(BP*4), R11
LEAL 3864292196(R11), BP
ADDL R9, BP
ADDL BX, BP
ADDL BP, BX
ADDQ $0x14, AX
SUBQ $0x14, CX
JMP loop20
after:
MOVL $0xcc9e2d51, AX
RORL $0x0b, BX
IMULL AX, BX
RORL $0x11, BX
IMULL AX, BX
RORL $0x0b, BP
IMULL AX, BP
RORL $0x11, BP
IMULL AX, BP
ADDL BX, DX
RORL $0x13, DX
MOVL DX, CX
SHLL $0x02, CX
ADDL CX, DX
ADDL $0xe6546b64, DX
RORL $0x11, DX
IMULL AX, DX
ADDL BP, DX
RORL $0x13, DX
MOVL DX, CX
SHLL $0x02, CX
ADDL CX, DX
ADDL $0xe6546b64, DX
RORL $0x11, DX
IMULL AX, DX
MOVL DX, ret+24(FP)
RET

13
vendor/github.com/dgryski/go-farm/fp_generic.go generated vendored Normal file
View File

@@ -0,0 +1,13 @@
// +build !amd64 purego
package farm
// Fingerprint64 is a 64-bit fingerprint function for byte-slices
func Fingerprint64(s []byte) uint64 {
return naHash64(s)
}
// Fingerprint32 is a 32-bit fingerprint function for byte-slices
func Fingerprint32(s []byte) uint32 {
return Hash32(s)
}

9
vendor/github.com/dgryski/go-farm/fp_stub.go generated vendored Normal file
View File

@@ -0,0 +1,9 @@
// Code generated by command: go run asm.go -out=fp_amd64.s -stubs=fp_stub.go. DO NOT EDIT.
// +build amd64,!purego
package farm
func Fingerprint64(s []byte) uint64
func Fingerprint32(s []byte) uint32

View File

@@ -1,18 +0,0 @@
package farm
func rotate32(val uint32, shift uint) uint32 {
return ((val >> shift) | (val << (32 - shift)))
}
func rotate64(val uint64, shift uint) uint64 {
return ((val >> shift) | (val << (64 - shift)))
}
func fetch32(s []byte, idx int) uint32 {
return uint32(s[idx+0]) | uint32(s[idx+1])<<8 | uint32(s[idx+2])<<16 | uint32(s[idx+3])<<24
}
func fetch64(s []byte, idx int) uint64 {
return uint64(s[idx+0]) | uint64(s[idx+1])<<8 | uint64(s[idx+2])<<16 | uint64(s[idx+3])<<24 |
uint64(s[idx+4])<<32 | uint64(s[idx+5])<<40 | uint64(s[idx+6])<<48 | uint64(s[idx+7])<<56
}