This commit is contained in:
bluepython508 committed 2026-10-22 12:27:19 +01:00
1 parent 3530afb854
commit 6903fcff27
2146 files changed
+112256 -190703

No files matched your search

+12
View File
@@ -52,6 +52,11 @@ func (d *Digest) Reset() {
d.n = 0
}
// maxAsmSize bounds the input handed to a single writeBlocks call. Assembly is
// never preemptible, so an unbounded call holds every P in stop-the-world for
// its duration. Whole 32-byte blocks, so Write can feed it in pieces.
const maxAsmSize = 128 << 10 // 4096 whole 32-byte blocks
// Size always returns 8 bytes.
func (d *Digest) Size() int { return 8 }
@@ -83,6 +88,13 @@ func (d *Digest) Write(b []byte) (n int, err error) {
d.n = 0
}
for len(b) >= maxAsmSize {
// Assembly is not preemptible, so hashing a large buffer in one call
// blocks every stop-the-world for the whole call. Feed it in chunks.
writeBlocks(d, b[:maxAsmSize])
b = b[maxAsmSize:]
}
if len(b) >= 32 {
// One or more full blocks left.
nw := writeBlocks(d, b)
+5 -1
View File
@@ -175,7 +175,11 @@ finalize:
RET
// func writeBlocks(d *Digest, b []byte) int
TEXT ·writeBlocks(SB), NOSPLIT|NOFRAME, $0-40
//
// Deliberately not NOSPLIT: the stack check is the preemption point that lets a
// stop-the-world proceed between chunks. The frame must be >= abi.StackSmall
// (128), or the assembler marks this leaf NOSPLIT anyway and drops that check.
TEXT ·writeBlocks(SB), $128-40
// Load fixed primes needed for round.
MOVQ ·primes+0(SB), prime1
MOVQ ·primes+8(SB), prime2
+5 -1
View File
@@ -163,7 +163,11 @@ finalize:
RET
// func writeBlocks(s *Digest, b []byte) int
TEXT ·writeBlocks(SB), NOSPLIT|NOFRAME, $0-40
//
// Deliberately not NOSPLIT: the stack check is the preemption point that lets a
// stop-the-world proceed between chunks. The frame must be >= abi.StackSmall
// (128), or the assembler marks this leaf NOSPLIT anyway and drops that check.
TEXT ·writeBlocks(SB), $128-40
LDP ·primes+0(SB), (prime1, prime2)
// Load state. Assume v[1-4] are stored contiguously.
@@ -1,5 +1,4 @@
//go:build (!amd64 && !arm64) || appengine || !gc || purego || noasm
// +build !amd64,!arm64 appengine !gc purego noasm
package xxhash