]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "cmd/compile: stop interface conversions for generic method calls from allocating"
authorKeith Randall <khr@golang.org>
Thu, 24 Mar 2022 17:50:06 +0000 (17:50 +0000)
committerKeith Randall <khr@golang.org>
Sat, 26 Mar 2022 20:36:39 +0000 (20:36 +0000)
This reverts commit e550c3054586a224d949cc8fa030bac0887bee51.

Reason for revert: Method bound calls are no longer implemented using interface calls, so it is no longer necessary. Leaving the test, though.

Change-Id: I80f1e4cd921063cd27ca8f07998316ca282e075b
Reviewed-on: https://go-review.googlesource.com/c/go/+/395594
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/escape/escape.go
src/cmd/compile/internal/ir/expr.go
src/cmd/compile/internal/noder/stencil.go

index bc6f7c93bb663be0c7d3131a3a1a1c7e83244de7..4713ecddcaea52aa814ddc96c5a79930f04e324b 100644 (file)
@@ -297,14 +297,6 @@ func (b *batch) finish(fns []*ir.Func) {
                // TODO(mdempsky): Update tests to expect this.
                goDeferWrapper := n.Op() == ir.OCLOSURE && n.(*ir.ClosureExpr).Func.Wrapper()
 
-               if n.Op() == ir.OCONVIDATA && n.(*ir.ConvExpr).NonEscaping {
-                       // The allocation for the data word of an interface is known to not escape.
-                       // See issue 50182.
-                       // (But we do still need to process that allocation, as pointers inside
-                       // the data word may escape.)
-                       loc.escapes = false
-               }
-
                if loc.escapes {
                        if n.Op() == ir.ONAME {
                                if base.Flag.CompilingRuntime {
index 3b650c0787014082c2c3feb7f6cfb32890a99d66..82132005f96f5787e08c3cffb84e5b1c0da91800 100644 (file)
@@ -244,8 +244,7 @@ func (n *ConstExpr) Val() constant.Value { return n.val }
 // It may end up being a value or a type.
 type ConvExpr struct {
        miniExpr
-       X           Node
-       NonEscaping bool // The allocation needed for the conversion to interface is known not to escape
+       X Node
 }
 
 func NewConvExpr(pos src.XPos, op Op, typ *types.Type, x Node) *ConvExpr {
index 477259f734b84e1a87d8382c0f8a2b6c5c87cf5d..eeac8d8de7d7d5e63f2d70768b6e1b8ae464db1b 100644 (file)
@@ -1279,11 +1279,7 @@ func (g *genInst) dictPass(info *instInfo) {
                                                // we do a type assert to the type bound.
                                                mse.X = assertToBound(info, info.dictParam, m.Pos(), mse.X, dst)
                                        } else {
-                                               mse.X = convertUsingDictionary(info, info.dictParam, m.Pos(), mse.X, m, dst, true)
-                                               // Note: we set nonEscaping==true, because we can assume the backing store for the
-                                               // interface conversion doesn't escape. The method call will immediately go to
-                                               // a wrapper function which copies all the data out of the interface value.
-                                               // (It only matters for non-pointer-shaped interface conversions. See issue 50182.)
+                                               mse.X = convertUsingDictionary(info, info.dictParam, m.Pos(), mse.X, m, dst)
                                        }
                                }
                                transformDot(mse, false)
@@ -1329,7 +1325,7 @@ func (g *genInst) dictPass(info *instInfo) {
                        // Note: x's argument is still typed as a type parameter.
                        // m's argument now has an instantiated type.
                        if mce.X.Type().HasShape() || (mce.X.Type().IsInterface() && m.Type().HasShape()) {
-                               m = convertUsingDictionary(info, info.dictParam, m.Pos(), m.(*ir.ConvExpr).X, m, m.Type(), false)
+                               m = convertUsingDictionary(info, info.dictParam, m.Pos(), m.(*ir.ConvExpr).X, m, m.Type())
                        }
                case ir.ODOTTYPE, ir.ODOTTYPE2:
                        if !m.Type().HasShape() {
@@ -1422,9 +1418,7 @@ func findDictType(info *instInfo, t *types.Type) int {
 // type dst, by returning a new set of nodes that make use of a dictionary entry. in is the
 // instantiated node of the CONVIFACE node or XDOT node (for a bound method call) that is causing the
 // conversion.
-// If nonEscaping is true, the caller guarantees that the backing store needed for the interface data
-// word will not escape.
-func convertUsingDictionary(info *instInfo, dictParam *ir.Name, pos src.XPos, v ir.Node, in ir.Node, dst *types.Type, nonEscaping bool) ir.Node {
+func convertUsingDictionary(info *instInfo, dictParam *ir.Name, pos src.XPos, v ir.Node, in ir.Node, dst *types.Type) ir.Node {
        assert(v.Type().HasShape() || v.Type().IsInterface() && in.Type().HasShape())
        assert(dst.IsInterface())
 
@@ -1494,7 +1488,6 @@ func convertUsingDictionary(info *instInfo, dictParam *ir.Name, pos src.XPos, v
        // Figure out what the data field of the interface will be.
        data := ir.NewConvExpr(pos, ir.OCONVIDATA, nil, v)
        typed(types.Types[types.TUNSAFEPTR], data)
-       data.NonEscaping = nonEscaping
 
        // Build an interface from the type and data parts.
        var i ir.Node = ir.NewBinaryExpr(pos, ir.OEFACE, rt, data)