Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: escape analysis on interface calls #36964
What version of Go are you using (
It's an interesting idea to resolve this at run time instead. Generate code for both cases and decide which allocation path to use.
It can get tricky:
Then we can only allocate
At the time we allocate
Until we can inspect
Sometimes interfaces are wrappers. For example,
More ideas to explore:
Ofcause it is quite tricky and 2 and 3 require internal sub interface pointers in bufio.Writer to stay consistent and do not change to anything but nil. Probably it requires a huge logic in the compiler :/
Here's another data point.
In this program, we have no allocation for the closure or the potentially-escaped variable:
However, in this similar program that uses an interface value, we have an allocation for both the interface and
Issue #8618 tracks the issue about allocating storage for the interface. I think this issue is the right one for tracking escape analysis of the value inside the interface.