diff options
author | Ian Lance Taylor <iant@golang.org> | 2019-01-18 19:04:36 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-01-18 19:04:36 +0000 |
commit | 4f4a855d82a889cebcfca150a7a43909bcb6a346 (patch) | |
tree | f12bae0781920fa34669fe30b6f4615a86d9fb80 /libgo/go/hash | |
parent | 225220d668dafb8262db7012bced688acbe63b33 (diff) | |
download | gcc-4f4a855d82a889cebcfca150a7a43909bcb6a346.zip gcc-4f4a855d82a889cebcfca150a7a43909bcb6a346.tar.gz gcc-4f4a855d82a889cebcfca150a7a43909bcb6a346.tar.bz2 |
libgo: update to Go1.12beta2
Reviewed-on: https://go-review.googlesource.com/c/158019
gotools/:
* Makefile.am (go_cmd_vet_files): Update for Go1.12beta2 release.
(GOTOOLS_TEST_TIMEOUT): Increase to 600.
(check-runtime): Export LD_LIBRARY_PATH before computing GOARCH
and GOOS.
(check-vet): Copy golang.org/x/tools into check-vet-dir.
* Makefile.in: Regenerate.
gcc/testsuite/:
* go.go-torture/execute/names-1.go: Stop using debug/xcoff, which
is no longer externally visible.
From-SVN: r268084
Diffstat (limited to 'libgo/go/hash')
-rw-r--r-- | libgo/go/hash/crc32/crc32_arm64.go | 14 | ||||
-rw-r--r-- | libgo/go/hash/crc64/crc64.go | 17 | ||||
-rw-r--r-- | libgo/go/hash/crc64/crc64_test.go | 6 | ||||
-rw-r--r-- | libgo/go/hash/fnv/fnv.go | 33 |
4 files changed, 34 insertions, 36 deletions
diff --git a/libgo/go/hash/crc32/crc32_arm64.go b/libgo/go/hash/crc32/crc32_arm64.go index 0d813b4..232cc3b 100644 --- a/libgo/go/hash/crc32/crc32_arm64.go +++ b/libgo/go/hash/crc32/crc32_arm64.go @@ -15,20 +15,18 @@ import "internal/cpu" func castagnoliUpdate(crc uint32, p []byte) uint32 func ieeeUpdate(crc uint32, p []byte) uint32 -var hasCRC32 = cpu.ARM64.HasCRC32 - func archAvailableCastagnoli() bool { - return hasCRC32 + return cpu.ARM64.HasCRC32 } func archInitCastagnoli() { - if !hasCRC32 { + if !cpu.ARM64.HasCRC32 { panic("arch-specific crc32 instruction for Catagnoli not available") } } func archUpdateCastagnoli(crc uint32, p []byte) uint32 { - if !hasCRC32 { + if !cpu.ARM64.HasCRC32 { panic("arch-specific crc32 instruction for Castagnoli not available") } @@ -36,17 +34,17 @@ func archUpdateCastagnoli(crc uint32, p []byte) uint32 { } func archAvailableIEEE() bool { - return hasCRC32 + return cpu.ARM64.HasCRC32 } func archInitIEEE() { - if !hasCRC32 { + if !cpu.ARM64.HasCRC32 { panic("arch-specific crc32 instruction for IEEE not available") } } func archUpdateIEEE(crc uint32, p []byte) uint32 { - if !hasCRC32 { + if !cpu.ARM64.HasCRC32 { panic("arch-specific crc32 instruction for IEEE not available") } diff --git a/libgo/go/hash/crc64/crc64.go b/libgo/go/hash/crc64/crc64.go index a799a01..063c63c 100644 --- a/libgo/go/hash/crc64/crc64.go +++ b/libgo/go/hash/crc64/crc64.go @@ -10,6 +10,7 @@ package crc64 import ( "errors" "hash" + "sync" ) // The size of a CRC-64 checksum in bytes. @@ -28,13 +29,24 @@ const ( type Table [256]uint64 var ( - slicing8TableISO = makeSlicingBy8Table(makeTable(ISO)) - slicing8TableECMA = makeSlicingBy8Table(makeTable(ECMA)) + slicing8TablesBuildOnce sync.Once + slicing8TableISO *[8]Table + slicing8TableECMA *[8]Table ) +func buildSlicing8TablesOnce() { + slicing8TablesBuildOnce.Do(buildSlicing8Tables) +} + +func buildSlicing8Tables() { + slicing8TableISO = makeSlicingBy8Table(makeTable(ISO)) + slicing8TableECMA = makeSlicingBy8Table(makeTable(ECMA)) +} + // MakeTable returns a Table constructed from the specified polynomial. // The contents of this Table must not be modified. func MakeTable(poly uint64) *Table { + buildSlicing8TablesOnce() switch poly { case ISO: return &slicing8TableISO[0] @@ -141,6 +153,7 @@ func readUint64(b []byte) uint64 { } func update(crc uint64, tab *Table, p []byte) uint64 { + buildSlicing8TablesOnce() crc = ^crc // Table comparison is somewhat expensive, so avoid it for small sizes for len(p) >= 64 { diff --git a/libgo/go/hash/crc64/crc64_test.go b/libgo/go/hash/crc64/crc64_test.go index 9db05b0..9cf602c 100644 --- a/libgo/go/hash/crc64/crc64_test.go +++ b/libgo/go/hash/crc64/crc64_test.go @@ -62,15 +62,13 @@ func TestGolden(t *testing.T) { io.WriteString(c, g.in) s := c.Sum64() if s != g.outISO { - t.Errorf("ISO crc64(%s) = 0x%x want 0x%x", g.in, s, g.outISO) - t.FailNow() + t.Fatalf("ISO crc64(%s) = 0x%x want 0x%x", g.in, s, g.outISO) } c = New(tabECMA) io.WriteString(c, g.in) s = c.Sum64() if s != g.outECMA { - t.Errorf("ECMA crc64(%s) = 0x%x want 0x%x", g.in, s, g.outECMA) - t.FailNow() + t.Fatalf("ECMA crc64(%s) = 0x%x want 0x%x", g.in, s, g.outECMA) } } } diff --git a/libgo/go/hash/fnv/fnv.go b/libgo/go/hash/fnv/fnv.go index 7662315d..0fce177 100644 --- a/libgo/go/hash/fnv/fnv.go +++ b/libgo/go/hash/fnv/fnv.go @@ -15,6 +15,7 @@ package fnv import ( "errors" "hash" + "math/bits" ) type ( @@ -137,18 +138,12 @@ func (s *sum64a) Write(data []byte) (int, error) { func (s *sum128) Write(data []byte) (int, error) { for _, c := range data { - // Compute the multiplication in 4 parts to simplify carrying - s1l := (s[1] & 0xffffffff) * prime128Lower - s1h := (s[1] >> 32) * prime128Lower - s0l := (s[0]&0xffffffff)*prime128Lower + (s[1]&0xffffffff)<<prime128Shift - s0h := (s[0]>>32)*prime128Lower + (s[1]>>32)<<prime128Shift - // Carries - s1h += s1l >> 32 - s0l += s1h >> 32 - s0h += s0l >> 32 + // Compute the multiplication + s0, s1 := bits.Mul64(prime128Lower, s[1]) + s0 += s[1]<<prime128Shift + prime128Lower*s[0] // Update the values - s[1] = (s1l & 0xffffffff) + (s1h << 32) - s[0] = (s0l & 0xffffffff) + (s0h << 32) + s[1] = s1 + s[0] = s0 s[1] ^= uint64(c) } return len(data), nil @@ -157,18 +152,12 @@ func (s *sum128) Write(data []byte) (int, error) { func (s *sum128a) Write(data []byte) (int, error) { for _, c := range data { s[1] ^= uint64(c) - // Compute the multiplication in 4 parts to simplify carrying - s1l := (s[1] & 0xffffffff) * prime128Lower - s1h := (s[1] >> 32) * prime128Lower - s0l := (s[0]&0xffffffff)*prime128Lower + (s[1]&0xffffffff)<<prime128Shift - s0h := (s[0]>>32)*prime128Lower + (s[1]>>32)<<prime128Shift - // Carries - s1h += s1l >> 32 - s0l += s1h >> 32 - s0h += s0l >> 32 + // Compute the multiplication + s0, s1 := bits.Mul64(prime128Lower, s[1]) + s0 += s[1]<<prime128Shift + prime128Lower*s[0] // Update the values - s[1] = (s1l & 0xffffffff) + (s1h << 32) - s[0] = (s0l & 0xffffffff) + (s0h << 32) + s[1] = s1 + s[0] = s0 } return len(data), nil } |