]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: eliminate OASWB
authorMatthew Dempsky <mdempsky@google.com>
Mon, 19 Dec 2016 18:30:44 +0000 (10:30 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 10 Feb 2017 22:31:58 +0000 (22:31 +0000)
Instead we can just call needwritebarrier when constructing the SSA
representation.

Change-Id: I6fefaad49daada9cdb3050f112889e49dca0047b
Reviewed-on: https://go-review.googlesource.com/34566
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/gc/bexport.go
src/cmd/compile/internal/gc/esc.go
src/cmd/compile/internal/gc/fmt.go
src/cmd/compile/internal/gc/init.go
src/cmd/compile/internal/gc/opnames.go
src/cmd/compile/internal/gc/racewalk.go
src/cmd/compile/internal/gc/sinit.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/syntax.go
src/cmd/compile/internal/gc/walk.go

index 563e1fba4851430e453fd403517a1a599be51af4..3719dc7962a3ffa20cd534d59b72693acd535824 100644 (file)
@@ -1432,7 +1432,7 @@ func (p *exporter) stmt(n *Node) {
        // case ODCLFIELD:
        //      unimplemented - handled by default case
 
-       case OAS, OASWB:
+       case OAS:
                // Don't export "v = <N>" initializing statements, hope they're always
                // preceded by the DCL which will be re-parsed and typecheck to reproduce
                // the "v = <N>" again.
index b1e4a7992ca1e76857cca80600c82ce8f9a3b32b..1b29aebcc46a53f78ccb6e70d2b1a23950c78770 100644 (file)
@@ -761,7 +761,7 @@ func (e *EscState) esc(n *Node, parent *Node) {
        // This assignment is a no-op for escape analysis,
        // it does not store any new pointers into b that were not already there.
        // However, without this special case b will escape, because we assign to OIND/ODOTPTR.
-       case OAS, OASOP, OASWB:
+       case OAS, OASOP:
                if (n.Left.Op == OIND || n.Left.Op == ODOTPTR) && n.Left.Left.Op == ONAME && // dst is ONAME dereference
                        (n.Right.Op == OSLICE || n.Right.Op == OSLICE3 || n.Right.Op == OSLICESTR) && // src is slice operation
                        (n.Right.Left.Op == OIND || n.Right.Left.Op == ODOTPTR) && n.Right.Left.Left.Op == ONAME && // slice is applied to ONAME dereference
index 835d34bb7ff78e549ef1409eccf7a12493dc5602..cd976f0321707c030348de7f856ceb83c372c210 100644 (file)
@@ -837,7 +837,7 @@ func (n *Node) stmtfmt(s fmt.State) {
        // Don't export "v = <N>" initializing statements, hope they're always
        // preceded by the DCL which will be re-parsed and typechecked to reproduce
        // the "v = <N>" again.
-       case OAS, OASWB:
+       case OAS:
                if n.Colas && !complexinit {
                        fmt.Fprintf(s, "%v := %v", n.Left, n.Right)
                } else {
index bfb0da50715e4a5b0186e637fe821bedcb78fd68..d2fba7bb598b1def9c85f0bc832f1fa5c5aff6bb 100644 (file)
@@ -41,7 +41,7 @@ func anyinit(n []*Node) bool {
                case ODCLFUNC, ODCLCONST, ODCLTYPE, OEMPTY:
                        break
 
-               case OAS, OASWB:
+               case OAS:
                        if isblank(ln.Left) && candiscard(ln.Right) {
                                break
                        }
index c8196a0f742048e2a431433cddc1c485417955bb..25e3c660d745c33b0a7be1941e5bbb8d172c2c75 100644 (file)
@@ -33,7 +33,6 @@ var opnames = []string{
        OAS2MAPR:         "AS2MAPR",
        OAS2DOTTYPE:      "AS2DOTTYPE",
        OASOP:            "ASOP",
-       OASWB:            "ASWB",
        OCALL:            "CALL",
        OCALLFUNC:        "CALLFUNC",
        OCALLMETH:        "CALLMETH",
index b9fd64a1ac541315a36407395ca70006d95c4098..f9a897c20ce4ecc233d6016b2f2be30c325f5dc1 100644 (file)
@@ -136,7 +136,7 @@ func instrumentnode(np **Node, init *Nodes, wr int, skip int) {
        default:
                Fatalf("instrument: unknown node type %v", n.Op)
 
-       case OAS, OASWB, OAS2FUNC:
+       case OAS, OAS2FUNC:
                instrumentnode(&n.Left, init, 1, 0)
                instrumentnode(&n.Right, init, 0, 0)
                goto ret
index 009d13565f636552bd0a355556249fd781595446..91cb53773c46294806178eeaface7e5257513a2b 100644 (file)
@@ -752,11 +752,6 @@ func fixedlit(ctxt initContext, kind initKind, n *Node, var_ *Node, init *Nodes)
                switch kind {
                case initKindStatic:
                        a = walkexpr(a, init) // add any assignments in r to top
-                       if a.Op == OASWB {
-                               // Static initialization never needs
-                               // write barriers.
-                               a.Op = OAS
-                       }
                        if a.Op != OAS {
                                Fatalf("fixedlit: not as, is %v", a)
                        }
index 1f0f1b0d91caf67e86617d3fee91eb4cb19b0496..ca198575d13c4a8a27bc1fb22f64941422025299 100644 (file)
@@ -641,7 +641,7 @@ func (s *state) stmt(n *Node) {
                b := s.endBlock()
                b.AddEdgeTo(lab.target)
 
-       case OAS, OASWB:
+       case OAS:
                // Generate static data rather than code, if possible.
                if n.IsStatic {
                        if !genAsInitNoCheck(n) {
@@ -704,7 +704,7 @@ func (s *state) stmt(n *Node) {
                }
                var r *ssa.Value
                var isVolatile bool
-               needwb := n.Op == OASWB
+               needwb := n.Right != nil && needwritebarrier(n.Left, n.Right)
                deref := !canSSAType(t)
                if deref {
                        if rhs == nil {
@@ -728,6 +728,9 @@ func (s *state) stmt(n *Node) {
                        // They get similar wb-removal treatment in walk.go:OAS.
                        needwb = true
                }
+               if needwb && Debug_wb > 1 {
+                       Warnl(n.Pos, "marking %v for barrier", n.Left)
+               }
 
                var skip skipMask
                if rhs != nil && (rhs.Op == OSLICE || rhs.Op == OSLICE3 || rhs.Op == OSLICESTR) && samesafeexpr(rhs.Left, n.Left) {
index 58414e602c869a0e3b2d7b44cc8f6efeb4cf8b08..9dd2adcd4c3891016c32e7df5a07b84890728656 100644 (file)
@@ -1169,7 +1169,12 @@ func ullmancalc(n *Node) {
                }
                goto out
 
-       case OCALL, OCALLFUNC, OCALLMETH, OCALLINTER, OASWB:
+       case OAS:
+               if !needwritebarrier(n.Left, n.Right) {
+                       break
+               }
+               fallthrough
+       case OCALL, OCALLFUNC, OCALLMETH, OCALLINTER:
                ul = UINF
                goto out
 
index 0d393d15e83c3266c1115234c6767240134ee8bf..abc0e02aee6d644f4c0b4a7c19de09262c96e6d3 100644 (file)
@@ -361,7 +361,6 @@ const (
        OAS2MAPR         // List = Rlist (x, ok = m["foo"])
        OAS2DOTTYPE      // List = Rlist (x, ok = I.(int))
        OASOP            // Left Etype= Right (x += y)
-       OASWB            // Left = Right (with write barrier)
        OCALL            // Left(List) (function call, method call or type conversion)
        OCALLFUNC        // Left(List) (function call f(args))
        OCALLMETH        // Left(List) (direct method call x.Method(args))
index a3315c066acfc0e51e0705534429a96860bee2fe..bf7f253517f83af7f825fdb267e1792fb8df3634 100644 (file)
@@ -338,10 +338,6 @@ func walkstmt(n *Node) *Node {
 
                        ll := ascompatee(n.Op, rl, n.List.Slice(), &n.Ninit)
                        n.List.Set(reorder3(ll))
-                       ls := n.List.Slice()
-                       for i, n := range ls {
-                               ls[i] = applywritebarrier(n)
-                       }
                        break
                }
 
@@ -683,7 +679,7 @@ opswitch:
                        break
                }
 
-               if !instrumenting && iszero(n.Right) && !needwritebarrier(n.Left, n.Right) {
+               if !instrumenting && iszero(n.Right) {
                        break
                }
 
@@ -727,7 +723,6 @@ opswitch:
                        static := n.IsStatic
                        n = convas(n, init)
                        n.IsStatic = static
-                       n = applywritebarrier(n)
                }
 
        case OAS2:
@@ -736,9 +731,6 @@ opswitch:
                walkexprlistsafe(n.Rlist.Slice(), init)
                ll := ascompatee(OAS, n.List.Slice(), n.Rlist.Slice(), init)
                ll = reorder3(ll)
-               for i, n := range ll {
-                       ll[i] = applywritebarrier(n)
-               }
                n = liststmt(ll)
 
        // a,b,... = fn()
@@ -756,9 +748,6 @@ opswitch:
                init.Append(r)
 
                ll := ascompatet(n.Op, n.List, r.Type)
-               for i, n := range ll {
-                       ll[i] = applywritebarrier(n)
-               }
                n = liststmt(ll)
 
        // x, y = <-c
@@ -2124,19 +2113,6 @@ func needwritebarrier(l *Node, r *Node) bool {
        return true
 }
 
-// TODO(rsc): Perhaps componentgen should run before this.
-
-func applywritebarrier(n *Node) *Node {
-       if n.Left != nil && n.Right != nil && needwritebarrier(n.Left, n.Right) {
-               if Debug_wb > 1 {
-                       Warnl(n.Pos, "marking %v for barrier", n.Left)
-               }
-               n.Op = OASWB
-               return n
-       }
-       return n
-}
-
 func convas(n *Node, init *Nodes) *Node {
        if n.Op != OAS {
                Fatalf("convas: not OAS %v", n.Op)