]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: cleanup genwrapper slightly
authorMatthew Dempsky <mdempsky@google.com>
Wed, 4 Oct 2017 18:42:37 +0000 (11:42 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 5 Oct 2017 22:37:16 +0000 (22:37 +0000)
ORETJMP doesn't need an ONAME if we just set the target method on Sym
instead of Left. Conveniently, this is where fmt.go was looking for it
anyway.

Change the iface parameter and global compiling_wrappers to bool.

Passes toolstash-check.

Change-Id: I5333f8bcb4e06bf8161808041125eb95c439aafe
Reviewed-on: https://go-review.googlesource.com/68252
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/reflect.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/typecheck.go

index 3f1c4221fe550a89f6de0e50b72926abbc910006..663750c9f5b76caa05a88b97a48180cac8e487c0 100644 (file)
@@ -198,7 +198,7 @@ var compiling_runtime bool
 // Compiling the standard library
 var compiling_std bool
 
-var compiling_wrappers int
+var compiling_wrappers bool
 
 var use_writebarrier bool
 
index 7b4f0fe0e942e9b2345400894983a60290cf1449..fd9e3e0a8e5e67523992a98234ee2a8636f09a5f 100644 (file)
@@ -438,18 +438,18 @@ func methods(t *types.Type) []*Sig {
                if !sig.isym.Siggen() {
                        sig.isym.SetSiggen(true)
                        if !eqtype(this, it) || this.Width < int64(Widthptr) {
-                               compiling_wrappers = 1
-                               genwrapper(it, f, sig.isym, 1)
-                               compiling_wrappers = 0
+                               compiling_wrappers = true
+                               genwrapper(it, f, sig.isym, true)
+                               compiling_wrappers = false
                        }
                }
 
                if !sig.tsym.Siggen() {
                        sig.tsym.SetSiggen(true)
                        if !eqtype(this, t) {
-                               compiling_wrappers = 1
-                               genwrapper(t, f, sig.tsym, 0)
-                               compiling_wrappers = 0
+                               compiling_wrappers = true
+                               genwrapper(t, f, sig.tsym, false)
+                               compiling_wrappers = false
                        }
                }
        }
@@ -500,7 +500,7 @@ func imethods(t *types.Type) []*Sig {
                isym := methodsym(method, t, false)
                if !isym.Siggen() {
                        isym.SetSiggen(true)
-                       genwrapper(t, f, isym, 0)
+                       genwrapper(t, f, isym, false)
                }
        }
 
index 9664ed4da75d6de986f25500d594563e11f08373..763ac24a102aa4ad741e97b3507ccdad4e29cb67 100644 (file)
@@ -780,7 +780,7 @@ func (s *state) stmt(n *Node) {
                s.stmtList(n.List)
                b := s.exit()
                b.Kind = ssa.BlockRetJmp // override BlockRet
-               b.Aux = n.Left.Sym.Linksym()
+               b.Aux = n.Sym.Linksym()
 
        case OCONTINUE, OBREAK:
                var to *ssa.Block
index 08658af603a9488743f2b3d7fdbd548f41d2ca2c..5b0a06d21c96d342c69878604c231505fd079f50 100644 (file)
@@ -1671,7 +1671,7 @@ func structargs(tl *types.Type, mustname bool) []*Node {
 //     rcvr - U
 //     method - M func (t T)(), a TFIELD type struct
 //     newnam - the eventual mangled name of this function
-func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym, iface int) {
+func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym, iface bool) {
        if false && Debug['r'] != 0 {
                fmt.Printf("genwrapper rcvrtype=%v method=%v newnam=%v\n", rcvr, method, newnam)
        }
@@ -1688,7 +1688,7 @@ func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym, iface
 
        t := nod(OTFUNC, nil, nil)
        l := []*Node{this}
-       if iface != 0 && rcvr.Width < int64(Widthptr) {
+       if iface && rcvr.Width < int64(Widthptr) {
                // Building method for interface table and receiver
                // is smaller than the single pointer-sized word
                // that the interface call will pass in.
@@ -1746,9 +1746,7 @@ func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym, iface
                as := nod(OAS, this.Left, nod(OCONVNOP, dot, nil))
                as.Right.Type = rcvr
                fn.Nbody.Append(as)
-               n := nod(ORETJMP, nil, nil)
-               n.Left = newname(methodsym(method.Sym, methodrcvr, false))
-               fn.Nbody.Append(n)
+               fn.Nbody.Append(nodSym(ORETJMP, nil, methodsym(method.Sym, methodrcvr, false)))
                // When tail-calling, we can't use a frame pointer.
                fn.Func.SetNoFramePointer(true)
        } else {
index 39570f1cf406fd539086a8485e9646435bbfeeef..a6c54f4569f50560f3b074404cb1e1ff6a027dd8 100644 (file)
@@ -266,7 +266,7 @@ func indexlit(n *Node) *Node {
 //     n.Left = typecheck1(n.Left, top)
 func typecheck1(n *Node, top int) *Node {
        switch n.Op {
-       case OXDOT, ODOT, ODOTPTR, ODOTMETH, ODOTINTER:
+       case OXDOT, ODOT, ODOTPTR, ODOTMETH, ODOTINTER, ORETJMP:
                // n.Sym is a field/method name, not a variable.
        default:
                if n.Sym != nil {
@@ -2143,7 +2143,7 @@ func typecheck1(n *Node, top int) *Node {
                }
        }
 
-       if safemode && !inimport && compiling_wrappers == 0 && t != nil && t.Etype == TUNSAFEPTR {
+       if safemode && !inimport && !compiling_wrappers && t != nil && t.Etype == TUNSAFEPTR {
                yyerror("cannot use unsafe.Pointer")
        }