Commit e0111bb0 authored by Cherry Zhang's avatar Cherry Zhang

cmd/compile: remove needwritebarrier from the frontend

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: 's avatarMatthew Dempsky <mdempsky@google.com>
parent 290de1f8
......@@ -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
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment