Posts about Inlining

A story about JIT-x86 inlining and starg

Sometimes you can learn a lot during reading source .NET. Let's open the source code of a Decimal constructor from .NET Reference Source (mscorlib/system/decimal.cs,158):

// Constructs a Decimal from an integer value.
public Decimal(int value) {
    //  JIT today can't inline methods that contains "starg" opcode.
    //  For more details, see DevDiv Bugs 81184: x86 JIT CQ: Removing the inline striction of "starg".
    int value_copy = value;
    if (value_copy >= 0) {
        flags = 0;
    else {
        flags = SignMask;
        value_copy = -value_copy;
    lo = value_copy;
    mid = 0;
    hi = 0;

The comment states that JIT-x86 can't apply the inlining optimization for a method that contains the starg IL-opcode. Curious, is not it?

Read more