Question

Does the .NET CLR Really Optimize for the Current Processor

When I read about the performance of JITted languages like C# or Java, authors usually say that they should/could theoretically outperform many native-compiled applications. The theory being that native applications are usually just compiled for a processor family (like x86), so the compiler cannot make certain optimizations as they may not truly be optimizations on all processors. On the other hand, the CLR can make processor-specific optimizations during the JIT process.

Does anyone know if Microsoft's (or Mono's) CLR actually performs processor-specific optimizations during the JIT process? If so, what kind of optimizations?

 45  3370  45
1 Jan 1970

Solution

 28

From back in 2005, David Notario listed several specific targeted optimizations is his blog entry "Does the JIT take advantage of my CPU?". I can't find anything about the new CLR 4, but I imagine several new items are included.

2010-03-08

Solution

 8

One processor specific optimization I'm aware of that's done in Mono is compiling Mono.Simd calls down to SSE instructions on processors that support SSE. If the processor running the code doesn't support SSE, the JIT compiler will output the equivalent non-SSE code.

2010-03-08