5

Do I really need to care where it's possible to emit .s instructions? Or will it only affect the size but the real performance will be the same?

The generated dll is going to be used also on AOT platforms. Will the resulting AOT-ed dll be the same for IL with .s and without?

I mean br.s, ldloca.s, etc..

Vlad
  • 3,001
  • 1
  • 22
  • 52
  • 1
    Please share a code? Its not clear what you mean with `.s`-instructions. – MakePeaceGreatAgain Feb 03 '16 at 09:26
  • 4
    @HimBromBeere - E.g. [beq](https://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.beq(v=vs.110).aspx) vs [beq.s](https://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.beq_s(v=vs.110).aspx) – Damien_The_Unbeliever Feb 03 '16 at 09:30
  • I believe the .s suffix is only to allow for compression of the IL, i.e. the intermediate code. This can potentially cut down a bit on download times e.g. in web solutions. I don't believe it has any effect on the rendered machine code. – 500 - Internal Server Error Feb 08 '16 at 20:54

1 Answers1

1

It depends. The main purpose of .s (and literal-containg opcodes like ldc.i4.1) are just to decrease the size of the code, and the advantage of decreasing the size of a method is to make it possible to inline the method when generating native code from CIL of the calling method (the limit for x86 jitter is 32 bytes of IL). So in this case, short instructions can increase the performance of the application, if they are used in a inline-candidate method.

Otherwise, as it is not the CIL that's executed, the machine code generated by both of short and normal opcodes should be the same (and also optimized, when possible) native code.

IS4
  • 11,945
  • 2
  • 47
  • 86
  • 1
    The size of the MSIL has nothing to do with whether a method will be inlined. Only the size of the machine code affects that. – Hans Passant Feb 08 '16 at 22:18
  • How decreasing the size in bytes of a method makes possible to inline the method? I thought it may depend on IL instructions **count** but not size. – Vlad Feb 08 '16 at 22:18
  • 1
    @HansPassant According to [this](http://blogs.msdn.com/b/davidnotario/archive/2004/11/01/250398.aspx) article, "*Size of inlinee is limited to 32 bytes of IL*". True it's JITter-dependent, but I've seen at least three articles mention this limitation. Also how can the size of the machine code affect it, if the machine code for inlined and non-inlined method could be different, due to optimizations related to their parameters? – IS4 Feb 09 '16 at 14:23
  • @Vlad Maybe for other versions of JIT, but most articles state the limit as 32 bytes for the x86 one. – IS4 Feb 10 '16 at 12:31