]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: convert to using a map in getInstInfo, rather than SetImplicit()
authorDan Scales <danscales@google.com>
Fri, 15 Oct 2021 18:54:25 +0000 (11:54 -0700)
committerDan Scales <danscales@google.com>
Fri, 15 Oct 2021 21:44:07 +0000 (21:44 +0000)
SetImplicit() has an explicit meaning and really shouldn't be used in
this way - its use is left over from early prototype of the dictionary
code. Convert from using SetImplicit to just using a map during
traversal.

Change-Id: I3d257c101a859f000e159d7ced307d1b7cf990d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/356310
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>

src/cmd/compile/internal/noder/stencil.go

index cfa90e43990d0d426dadcef156bbb142857ec45c..3a1baeae88a046fca1280969dbf7eccb78161e75 100644 (file)
@@ -1854,14 +1854,19 @@ func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instI
                }
        }
 
+       // Map to remember when we have seen an instantiated function value or method
+       // expression/value as part of a call, so we can determine when we encounter
+       // an uncalled function value or method expression/value.
+       callMap := make(map[ir.Node]bool)
+
        var visitFunc func(ir.Node)
        visitFunc = func(n ir.Node) {
-               if n.Op() == ir.OFUNCINST && !n.(*ir.InstExpr).Implicit() {
+               if n.Op() == ir.OFUNCINST && !callMap[n] {
                        if hasShapeNodes(n.(*ir.InstExpr).Targs) {
                                infoPrint("  Closure&subdictionary required at generic function value %v\n", n.(*ir.InstExpr).X)
                                info.subDictCalls = append(info.subDictCalls, n)
                        }
-               } else if (n.Op() == ir.OMETHEXPR || n.Op() == ir.OMETHVALUE) && !n.(*ir.SelectorExpr).Implicit() &&
+               } else if (n.Op() == ir.OMETHEXPR || n.Op() == ir.OMETHVALUE) && !callMap[n] &&
                        !types.IsInterfaceMethod(n.(*ir.SelectorExpr).Selection.Type) &&
                        len(deref(n.(*ir.SelectorExpr).X.Type()).RParams()) > 0 {
                        if hasShapeTypes(deref(n.(*ir.SelectorExpr).X.Type()).RParams()) {
@@ -1874,16 +1879,15 @@ func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instI
                        }
                }
                if n.Op() == ir.OCALL && n.(*ir.CallExpr).X.Op() == ir.OFUNCINST {
-                       n.(*ir.CallExpr).X.(*ir.InstExpr).SetImplicit(true)
+                       callMap[n.(*ir.CallExpr).X] = true
                        if hasShapeNodes(n.(*ir.CallExpr).X.(*ir.InstExpr).Targs) {
                                infoPrint("  Subdictionary at generic function/method call: %v - %v\n", n.(*ir.CallExpr).X.(*ir.InstExpr).X, n)
                                info.subDictCalls = append(info.subDictCalls, n)
                        }
                }
                if n.Op() == ir.OCALLMETH && n.(*ir.CallExpr).X.Op() == ir.ODOTMETH &&
-                       //n.(*ir.CallExpr).X.(*ir.SelectorExpr).Selection != nil &&
                        len(deref(n.(*ir.CallExpr).X.(*ir.SelectorExpr).X.Type()).RParams()) > 0 {
-                       n.(*ir.CallExpr).X.(*ir.SelectorExpr).SetImplicit(true)
+                       callMap[n.(*ir.CallExpr).X] = true
                        if hasShapeTypes(deref(n.(*ir.CallExpr).X.(*ir.SelectorExpr).X.Type()).RParams()) {
                                infoPrint("  Subdictionary at generic method call: %v\n", n)
                                info.subDictCalls = append(info.subDictCalls, n)
@@ -1891,7 +1895,7 @@ func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instI
                }
                if n.Op() == ir.OCALL && n.(*ir.CallExpr).X.Op() == ir.OXDOT &&
                        isShapeDeref(n.(*ir.CallExpr).X.(*ir.SelectorExpr).X.Type()) {
-                       n.(*ir.CallExpr).X.(*ir.SelectorExpr).SetImplicit(true)
+                       callMap[n.(*ir.CallExpr).X] = true
                        infoPrint("  Optional subdictionary at generic bound call: %v\n", n)
                        info.subDictCalls = append(info.subDictCalls, n)
                }