]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/noder: allow OCONVNOP for identical iface conversions
authorMatthew Dempsky <mdempsky@google.com>
Thu, 1 Sep 2022 23:06:11 +0000 (16:06 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 2 Sep 2022 18:26:02 +0000 (18:26 +0000)
commit34f0029a85af054787b279761e89db410621f1d7
treedbea21b09d06efed0925f5b5cfec49b1bdd2d01f
parent8af6c3348ef299d17aeb2ae5711af9c6205c5940
cmd/compile/internal/noder: allow OCONVNOP for identical iface conversions

In go.dev/cl/421821, I included a hack to force OCONVNOP back to
OCONVIFACE for conversions involving shape types and non-empty
interfaces. The comment correctly noted that this was only needed for
conversions between non-identical types, but the code was conservative
and applied to even conversions between identical types.

This CL adds an extra bool to record whether the conversion is between
identical types, so we can keep OCONVNOP instead of forcing back to
OCONVIFACE. This has a small improvement to generated code, because we
no longer need a convI2I call (as demonstrated by codegen/ifaces.go).

But more usefully, this is relevant to pruning unnecessary itab slots
in runtime dictionaries (next CL).

Change-Id: I94f89e961cd26629b925037fea58d283140766ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/427678
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/noder/writer.go
test/codegen/ifaces.go [new file with mode: 0644]