Extension methods
Neal Gafter
neal at gafter.com
Fri Nov 20 17:27:14 PST 2009
On Fri, Nov 20, 2009 at 5:34 PM, Rémi Forax <forax at univ-mlv.fr> wrote:
> Le 21/11/2009 00:52, Neal Gafter a écrit :
>
> On Fri, Nov 20, 2009 at 3:30 PM, Rémi Forax <forax at univ-mlv.fr> wrote:
>
>> There is a real problem of performance with extension methods
>> (at least with Hotspot).
>> Extension methods create megamorphic call sites
>> and Hotspot is not able to inline them.
>>
>
> Extension methods are most simply formulated are static methods (as in C#),
> and are therefore not polymorphic at runtime at all. They can even be
> inlined trivially. Such a formulation enables existing methods (such as
> those in Collections and Arrays) to be retrofitted as extension methods as
> well.
>
>
> The problem is not at call site of the extension method but call sites in
> the extension method.
>
If the extension method is inlined, which it usually should be in
performance-critical code (especially for the uses we've been considering),
it's no worse than an ordinary virtual method.
More information about the coin-dev
mailing list