none
OpCodes.Ldc_I4_S Field RRS feed

Answers

  • The only difference is the number of bytes used to represent the value of the int, there is no behavioral difference between ldc.i4 and ldc.i4.s (it's just used to reduce the overall size of the IL.)


    Monday, May 30, 2016 10:14 AM
  • No, the value on the evaluation stack is identical.

    If you want to load the number 8 onto the evaluation stack, there are 3 different ways to encode it.

    20 08 00 00 00 // ldc.i4 8
    1F 08          // ldc.i4.s 8
    1E             // ldc.i4.8
    Aside from the encoding, there is no difference, the JIT sees them as the same type.


    Monday, May 30, 2016 10:56 AM

All replies

  • The only difference is the number of bytes used to represent the value of the int, there is no behavioral difference between ldc.i4 and ldc.i4.s (it's just used to reduce the overall size of the IL.)


    Monday, May 30, 2016 10:14 AM
  • Thanks Brian. So that means instead of 4 bytes of Int32  1 byte is allocated on stack memory for this variable? 
    Monday, May 30, 2016 10:44 AM
  • No, the value on the evaluation stack is identical.

    If you want to load the number 8 onto the evaluation stack, there are 3 different ways to encode it.

    20 08 00 00 00 // ldc.i4 8
    1F 08          // ldc.i4.s 8
    1E             // ldc.i4.8
    Aside from the encoding, there is no difference, the JIT sees them as the same type.


    Monday, May 30, 2016 10:56 AM