]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile,runtime: update instrumentation comments
authorAustin Clements <austin@google.com>
Mon, 30 Oct 2017 20:06:19 +0000 (16:06 -0400)
committerAustin Clements <austin@google.com>
Tue, 31 Oct 2017 14:03:10 +0000 (14:03 +0000)
The compiler's instrumentation pass has some out-of-date comments
about the write barrier and some confusing comments about
typedslicecopy. Update these comments and add a comment to
typedslicecopy explaining why it's manually instrumented while none of
the other operations are.

Change-Id: I024e5361d53f1c3c122db0c85155368a30cabd6b
Reviewed-on: https://go-review.googlesource.com/74430
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/racewalk.go
src/runtime/mbarrier.go

index 2ffd0f96a8f8a5d01ad68d160dabbcb670d4be1a..90bfdbf688c7efa6843996dc29c2e6cb6a58e1de 100644 (file)
@@ -170,10 +170,14 @@ func instrumentnode(np **Node, init *Nodes, wr int, skip int) {
        case OCALLINTER:
                instrumentnode(&n.Left, init, 0, 0)
 
-       // Instrument dst argument of runtime.writebarrier* calls
-       // as we do not instrument runtime code.
-       // typedslicecopy is instrumented in runtime.
        case OCALLFUNC:
+               // Note that runtime.typedslicecopy is the only
+               // assignment-like function call in the AST at this
+               // point (between walk and SSA); since we don't
+               // instrument it here, typedslicecopy is manually
+               // instrumented in runtime. Calls to the write barrier
+               // and typedmemmove are created later by SSA, so those
+               // still appear as OAS nodes at this point.
                instrumentnode(&n.Left, init, 0, 0)
 
        case ONOT,
index cb2959fbc3f4a8118e080be4ed6883c86f5404e6..e28bdb8b8dc45c63ac97cdea37494fcf3f146199 100644 (file)
@@ -326,6 +326,10 @@ func typedslicecopy(typ *_type, dst, src slice) int {
        dstp := dst.array
        srcp := src.array
 
+       // The compiler emits calls to typedslicecopy before
+       // instrumentation runs, so unlike the other copying and
+       // assignment operations, it's not instrumented in the calling
+       // code and needs its own instrumentation.
        if raceenabled {
                callerpc := getcallerpc()
                pc := funcPC(slicecopy)