The JIT won't inline a method with a throw if there are multiple entries on the eval stack at the throw. So a method like:
[MethodImpl(MethodImplOptions.AggressiveInlining)]
int F(int y)
{
int result = x;
if (y == 33) throw new Exception();
return result;
}
won't inline because CSC pends x to the stack before the throw:
IL_0000: ldarg.0
IL_0001: ldfld int32 P::x
IL_0006: ldarg.1
IL_0007: ldc.i4.s 33
IL_0009: bne.un.s IL_0011
IL_000b: newobj instance void [System.Private.CoreLib]System.Exception::.ctor()
IL_0010: throw
IL_0011: ret
Inlines into 06000004 P:Main():int
[0 IL=0000 TR=000001 06000003] [FAILED: noinline per IL/cached result] P:M():ref
[0 IL=0011 TR=000014 06000002] [FAILED: throw with invalid stack] P:F(int):int:this
ECMA-335's only requirement for throw is that the top of stack be an object reference. Seems like this is an unnecessary restriction in the JIT.
category:cq
theme:inlining
skill-level:intermediate
cost:small
The JIT won't inline a method with a throw if there are multiple entries on the eval stack at the throw. So a method like:
won't inline because CSC pends
xto the stack before the throw:ECMA-335's only requirement for throw is that the top of stack be an object reference. Seems like this is an unnecessary restriction in the JIT.
category:cq
theme:inlining
skill-level:intermediate
cost:small