- Notifications
You must be signed in to change notification settings - Fork5.2k
Open
Labels
Milestone
Description
This is an example where inlining logically possible, but currently not supported by JIT:
usingSystem;usingSystem.Runtime.CompilerServices;publicclassC{publicvoidInlineTest(){// This method should not call anything// Everything can be inlinedDoWithGuardTwice(PrintHello);//DoWithGuardTwice(()=>{Console.WriteLine("bye");});}publicvoidPrintHello(){Console.WriteLine("Hello");}[MethodImpl(MethodImplOptions.AggressiveInlining)]publicvoidDoWithGuardTwice(/*Probably with some hint here*/Actiona){lock(this){a();a();}}}
This is a complex type of inlining. As an alternative this type of inlining was proposed to be implemented at the C# compiler level:dotnet/csharplang#1413
category:cq
theme:inlining
skill-level:expert
cost:medium