]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove needwritebarrier from the frontend
authorCherry Zhang <cherryyz@google.com>
Thu, 18 May 2017 19:38:44 +0000 (15:38 -0400)
committerCherry Zhang <cherryyz@google.com>
Mon, 16 Oct 2017 18:42:18 +0000 (18:42 +0000)
The write barrier insertion has moved to the SSA backend's
writebarrier pass. There is still needwritebarrier function
left in the frontend. This function is used in two places:

- fncall, which is called in ascompatet, which is called in
  walking OAS2FUNC. For OAS2FUNC, in order pass we've already
  created temporaries, and there is no write barrier for the
  assignments of these temporaries.

- updateHasCall, which updates the HasCall flag of a node. the
  HasCall flag is then used in
  - fncall, mentioned above.
  - ascompatet. As mentioned above, this is an assignment to
    a temporary, no write barrier.
  - reorder1, which is always called with a list produced by
    ascompatte, which is a list of assignments to stack, which
    have no write barrier.
  - vmatch1, which is called in oaslit with r.Op as OSTRUCTLIT,
    OARRAYLIT, OSLICELIT, or OMAPLIT. There is no write barrier
    in those literals.

Therefore, the needwritebarrier function is unnecessary. This
CL removes it.

Passes "toolstash -cmp" on std cmd.

Updates #17583.

Change-Id: I4b87ba8363d6583e4282a9e607a9ec8ce3ab124a
Reviewed-on: https://go-review.googlesource.com/43640
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/walk.go

index 8faec66aa098826a8e743d6c3ddcd8491659a6c6..83f160e883fbc357b2982fda568f49ad326c7f4d 100644 (file)
@@ -1144,11 +1144,6 @@ func updateHasCall(n *Node) {
                        Fatalf("OLITERAL/ONAME/OTYPE should never have calls: %+v", n)
                }
                return
-       case OAS:
-               if needwritebarrier(n.Left) {
-                       b = true
-                       goto out
-               }
        case OCALL, OCALLFUNC, OCALLMETH, OCALLINTER:
                b = true
                goto out
index b7db5b29d46e90286f9569aa73c281b587f87b14..58c8808ecaf56e270d917ff029ab671c28ec4275 100644 (file)
@@ -1805,9 +1805,6 @@ func fncall(l *Node, rt *types.Type) bool {
        if l.HasCall() || l.Op == OINDEXMAP {
                return true
        }
-       if needwritebarrier(l) {
-               return true
-       }
        if eqtype(l.Type, rt) {
                return false
        }
@@ -2249,52 +2246,6 @@ func isReflectHeaderDataField(l *Node) bool {
        return tsym.Name == "SliceHeader" || tsym.Name == "StringHeader"
 }
 
-// Do we need a write barrier for assigning to l?
-func needwritebarrier(l *Node) bool {
-       if !use_writebarrier {
-               return false
-       }
-
-       if l == nil || isblank(l) {
-               return false
-       }
-
-       // No write barrier for write to stack.
-       if isstack(l) {
-               return false
-       }
-
-       // Package unsafe's documentation says storing pointers into
-       // reflect.SliceHeader and reflect.StringHeader's Data fields
-       // is valid, even though they have type uintptr (#19168).
-       if isReflectHeaderDataField(l) {
-               return true
-       }
-
-       // No write barrier for write of non-pointers.
-       dowidth(l.Type)
-       if !types.Haspointers(l.Type) {
-               return false
-       }
-
-       // No write barrier if this is a pointer to a go:notinheap
-       // type, since the write barrier's inheap(ptr) check will fail.
-       if l.Type.IsPtr() && l.Type.Elem().NotInHeap() {
-               return false
-       }
-
-       // TODO: We can eliminate write barriers if we know *both* the
-       // current and new content of the slot must already be shaded.
-       // We know a pointer is shaded if it's nil, or points to
-       // static data, a global (variable or function), or the stack.
-       // The nil optimization could be particularly useful for
-       // writes to just-allocated objects. Unfortunately, knowing
-       // the "current" value of the slot requires flow analysis.
-
-       // Otherwise, be conservative and use write barrier.
-       return true
-}
-
 func convas(n *Node, init *Nodes) *Node {
        if n.Op != OAS {
                Fatalf("convas: not OAS %v", n.Op)