Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/gc: escape annotation defeated by files in wrong order #5773

Closed
robpike opened this issue Jun 25, 2013 · 1 comment
Closed

cmd/gc: escape annotation defeated by files in wrong order #5773

robpike opened this issue Jun 25, 2013 · 1 comment

Comments

@robpike
Copy link
Contributor

robpike commented Jun 25, 2013

In sha1, the arguments to Write escape if block is in assembler, even if we mark the
assembler routine with go:noescape, but they should not.

% r
go build -gcflags=-m 
# crypto/sha1
./sha1.go:57: can inline (*digest).Size
./sha1.go:59: can inline (*digest).BlockSize
./sha1.go:40: (*digest).Reset d does not escape
./sha1.go:52: new(digest) escapes to heap
./sha1.go:57: (*digest).Size d does not escape
./sha1.go:59: (*digest).BlockSize d does not escape
./sha1.go:61: leaking param: d
./sha1.go:74: d.x escapes to heap
./sha1.go:61: leaking param: d
./sha1.go:61: (*digest).Write p does not escape
./sha1.go:85: (*digest).Write d.x does not escape
./sha1.go:92: moved to heap: d
./sha1.go:99: d escapes to heap
./sha1.go:101: d escapes to heap
./sha1.go:109: d escapes to heap
./sha1.go:90: leaking param: in to result ~anon1
./sha1.go:90: (*digest).Sum d0 does not escape
./sha1.go:99: (*digest).Sum tmp does not escape
./sha1.go:101: (*digest).Sum tmp does not escape
./sha1.go:109: (*digest).Sum tmp does not escape
./sha1.go:123: (*digest).Sum digest does not escape
./sha1block_decl.go:11: block dig does not escape
./sha1block_decl.go:11: block p does not escape
tubenose=% hg diff .
diff -r f6de76ff41a3 src/pkg/crypto/sha1/sha1block_decl.go
--- a/src/pkg/crypto/sha1/sha1block_decl.go Mon Jun 24 16:53:13 2013 -0700
+++ b/src/pkg/crypto/sha1/sha1block_decl.go Mon Jun 24 17:18:52 2013 -0700
@@ -6,4 +6,6 @@
 
 package sha1
 
+//go:noescape
+
 func block(dig *digest, p []byte)
% 
% 


Now a magic trick: Compile the block declaration first.

tubenose=% mv sha1block_decl.go A.go   ###### NOTE: put sha1block_decl.go first in
compilation
tubenose=% go build -gcflags=-m 
# crypto/sha1
./sha1.go:57: can inline (*digest).Size
./sha1.go:59: can inline (*digest).BlockSize
./A.go:11: block dig does not escape
./A.go:11: block p does not escape
./sha1.go:40: (*digest).Reset d does not escape
./sha1.go:52: new(digest) escapes to heap
./sha1.go:57: (*digest).Size d does not escape
./sha1.go:59: (*digest).BlockSize d does not escape
./sha1.go:61: (*digest).Write d does not escape
./sha1.go:61: (*digest).Write p does not escape
./sha1.go:74: (*digest).Write d.x does not escape
./sha1.go:85: (*digest).Write d.x does not escape
./sha1.go:90: leaking param: in to result ~anon1
./sha1.go:90: (*digest).Sum d0 does not escape
./sha1.go:99: (*digest).Sum d does not escape
./sha1.go:99: (*digest).Sum tmp does not escape
./sha1.go:101: (*digest).Sum d does not escape
./sha1.go:101: (*digest).Sum tmp does not escape
./sha1.go:109: (*digest).Sum d does not escape
./sha1.go:109: (*digest).Sum tmp does not escape
./sha1.go:123: (*digest).Sum digest does not escape

Now the arguments to Write do not escape.
@rsc
Copy link
Contributor

rsc commented Jun 25, 2013

Comment 1:

This issue was closed by revision 148fac7.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants