Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do short instructions have better performance?

Tags:

c#

opcode

il

aot

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..

like image 661
Vlad Avatar asked Nov 08 '22 20:11

Vlad


1 Answers

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.

like image 128
IS4 Avatar answered Nov 14 '22 22:11

IS4