From 5fa6bbc669c22f05deb421c324b90b30ae3caa08 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Sat, 26 Jun 2021 18:18:16 -0700 Subject: [dev.typeparams] cmd/compile: clean up instantiation and dictionary naming Separate generation of instantiation and dictionary name generation. Add code to add subdictionaries to a dictionary. Not quite working yet, as we need to trigger generation of the subdictionaries for methods. Change-Id: I0d46053eba695b217630b06ef2f990f6a0b52d83 Reviewed-on: https://go-review.googlesource.com/c/go/+/331209 Trust: Keith Randall Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/reflectdata/reflect.go | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'src/cmd/compile/internal/reflectdata/reflect.go') diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index 351aaab399..27522ca85e 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -1869,7 +1869,7 @@ func methodWrapper(rcvr *types.Type, method *types.Field, forItab bool) *obj.LSy } else if !baseOrig.IsPtr() && method.Type.Recv().Type.IsPtr() { baseOrig = types.NewPtr(baseOrig) } - args = append(args, getDictionary(".inst."+ir.MethodSym(baseOrig, method.Sym).Name, targs)) // TODO: remove .inst. + args = append(args, getDictionary(ir.MethodSym(baseOrig, method.Sym), targs)) if indirect { args = append(args, ir.NewStarExpr(base.Pos, dot.X)) } else if methodrcvr.IsPtr() && methodrcvr.Elem() == dot.X.Type() { @@ -1971,28 +1971,16 @@ func MarkUsedIfaceMethod(n *ir.CallExpr) { // getDictionary returns the dictionary for the given named generic function // or method, with the given type arguments. -// TODO: pass a reference to the generic function instead? We might need -// that to look up protodictionaries. -func getDictionary(name string, targs []*types.Type) ir.Node { +func getDictionary(gf *types.Sym, targs []*types.Type) ir.Node { if len(targs) == 0 { - base.Fatalf("%s should have type arguments", name) + base.Fatalf("%s should have type arguments", gf.Name) } - // The dictionary for this instantiation is named after the function - // and concrete types it is instantiated with. - // TODO: decouple this naming from the instantiation naming. The instantiation - // naming will be based on GC shapes, this naming must be fully stenciled. - if !strings.HasPrefix(name, ".inst.") { - base.Fatalf("%s should start in .inst.", name) - } - name = ".dict." + name[6:] - - // Get a symbol representing the dictionary. - sym := typecheck.Lookup(name) + sym := typecheck.MakeDictName(gf, targs, true) // Initialize the dictionary, if we haven't yet already. if lsym := sym.Linksym(); len(lsym.P) == 0 { - base.Fatalf("Dictionary should have alredy been generated: %v", sym) + base.Fatalf("Dictionary should have already been generated: %s.%s", sym.Pkg.Path, sym.Name) } // Make a node referencing the dictionary symbol. -- cgit v1.2.3-54-g00ecf