]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: implement generic method expressions with closures in dictionary
authorKeith Randall <khr@golang.org>
Fri, 11 Feb 2022 00:40:18 +0000 (16:40 -0800)
committerKeith Randall <khr@golang.org>
Sat, 26 Mar 2022 20:36:23 +0000 (20:36 +0000)
commit7fc38802e15be1a221290b0a9da1f587ace19488
tree19d67fd38d8772ced4ec24e15bec63f56794d744
parent0652274c10f8f2a520c30bf43bb968dac91bf9f5
cmd/compile: implement generic method expressions with closures in dictionary

Currently we do quite a dance for method expressions on generic
types. We write a new closure, and in that closure convert the
receiver to an interface with the required method, then call the
target using an interface call.

Instead in this CL, we just allocate a (captureless) closure in the
dictionary which implements that method expression.

This CL makes method expressions faster and simpler. But the real win
is some followon CLs, where we can use the same closure to implement
bound method calls using the same closure, instead of converting to
interface and having wrappers convert back. Much faster and simpler.

Still thinking about how to do method values. The receiver still
needs to be captured, so there must be some closure involved, I think.

Update #50182

Change-Id: I1fbd57e7105663f8b049955b8f4111649a5f4aa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/385254
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/noder/irgen.go
src/cmd/compile/internal/noder/stencil.go