]> Cypherpunks repositories - gostls13.git/commitdiff
hash/crc32: add noescape tags to assembly functions
authorJoe Tsai <joetsai@digital-static.net>
Fri, 20 Nov 2015 01:41:57 +0000 (17:41 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 25 Nov 2015 15:01:10 +0000 (15:01 +0000)
CRC-32 computation is stateless and the p slice does not get stored
anywhere. Thus, we mark the assembly functions as noescape so that
it doesn't believe that p leaks in:
func Update(crc uint32, tab *Table, p []byte) uint32

Before:
./crc32.go:153: leaking param: p

After:
./crc32.go:153: Update p does not escape

Change-Id: I52ba35b6cc544fff724327140e0c27898431d1dc
Reviewed-on: https://go-review.googlesource.com/17069
Reviewed-by: Russ Cox <rsc@golang.org>
src/hash/crc32/crc32_amd64.go
src/hash/crc32/crc32_amd64p32.go

index 01f86840d63e55810dcbabb40dd9cb744d9b0904..ab4e2b8c8cd15ec8ab67a30148e956ca48ea8bc7 100644 (file)
@@ -15,10 +15,12 @@ func haveCLMUL() bool
 
 // castagnoliSSE42 is defined in crc_amd64.s and uses the SSE4.2 CRC32
 // instruction.
+//go:noescape
 func castagnoliSSE42(crc uint32, p []byte) uint32
 
 // ieeeCLMUL is defined in crc_amd64.s and uses the PCLMULQDQ
 // instruction as well as SSE 4.1.
+//go:noescape
 func ieeeCLMUL(crc uint32, p []byte) uint32
 
 var sse42 = haveSSE42()
index e6c2a523df3d79339958b4f805bc26225a6aad08..067fbb162f9da79cfd8e592acb4575d4fbb58425 100644 (file)
@@ -13,6 +13,7 @@ func haveSSE42() bool
 
 // castagnoliSSE42 is defined in crc_amd64.s and uses the SSE4.2 CRC32
 // instruction.
+//go:noescape
 func castagnoliSSE42(crc uint32, p []byte) uint32
 
 var sse42 = haveSSE42()