cmd/compile: deduplicate wrappers for promoted methods #57916
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.
Milestone
Given:
the compiler currently synthesizes method wrappers for the promoted methods:
But we only really need 1 wrapper:
A
can just useX
's method directly, because theX
field is at offset 0 anyway.B
andC
could use a single shared wrapper, because they need the same pointer adjustment before tail calling to(*X).m
.This would save some executable size, but I also think it could help slightly with CPU I-cache and branch predictions. For example, within the compiler itself,
ir.Node
'sOp
andPos
methods are always actually implemented byir.miniNode
(which we always embed at offset 0). But we create a wrapper method for eachir.Node
implementation, which means (caveat: hypothesizing) a bunch of identical methods all end up taking up I-cache space and the branch predictor has to guess which one is going to be called.The text was updated successfully, but these errors were encountered: