cmd/compile: escape analysis on interface calls #36964
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
What version of Go are you using (
go version
)?1.13.1
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?on any OS / env
What did you do?
type myCtx struct { data int }
type interface if { Call(ctx *myCtx) }
ctx := myCtx{}
i.Call(&ctx) // i == interface of type 'if'
What did you expect to see?
ctx allocated on stack (as Call() method was empty in my case).
What did you see instead?
ctx allocated on heap as escape analysis doesn't work through interface types. Compiler simply doesn't know the future of the pointer.
Suggestions
As interfaces are widely used in the language it seems quite important to be able to perform such optimisations.
What if interface run-time type info had escape flag for the method. That would allow to generate code for both escaping interface calls and non-escaping ones.
The text was updated successfully, but these errors were encountered: