A direct interface is an interface whose data word contains the actual data value, instead of a pointer to it. The gc toolchain creates a direct interface if the value is pointer shaped, that includes pointers (including unsafe.Pointer), functions, channels, maps, and structs and arrays containing a single pointer-shaped field. In gccgo, we only do this for pointers. This CL unifies direct interface types with gc. This reduces allocations when converting such types to interfaces.
Our method functions used to always take pointer receivers, to make interface calls easy. Now for direct interface types, their
value methods will take value receivers. For a pointer to those types, when converted to interface, the interface data contains the pointer. For that interface to call a value method, it will need a wrapper method that dereference the pointer and invokes the value method. The wrapper method, instead of the actual one, is put into the itable of the pointer type.
In the runtime, adjust funcPC for the new layout of interfaces of functions.
5b66522271b compiler,runtime: do more direct interfaces
gcc/go/gofrontend/MERGE | 2 +-
gcc/go/gofrontend/expressions.cc | 106 ++++++++++++++++---
gcc/go/gofrontend/expressions.h | 8 ++
gcc/go/gofrontend/gogo.cc | 4 +-
gcc/go/gofrontend/types.cc | 223 +++++++++++++++++++++++++++++++++++++--
gcc/go/gofrontend/types.h | 40 ++++++-
libgo/go/reflect/all_test.go | 5 -
libgo/go/reflect/type.go | 17 ++-
libgo/go/runtime/iface.go | 19 ++--
libgo/go/runtime/pprof/proto.go | 2 +-
libgo/go/runtime/proc.go | 2 +-
libgo/runtime/go-callers.c | 2 +-
12 files changed, 388 insertions(+), 42 deletions(-)