Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to target my application to .NET 4.6 to take advantage of RyuJIT?

Reading from Announcing .NET Framework 4.6 it seems to imply that RyuJIT is only for .NET 4.6.

Does that means I will need to re-target my applications to .NET 4.6 for RyuJIT to take effect?

like image 754
Rosdi Kasim Avatar asked Jul 21 '15 03:07

Rosdi Kasim


1 Answers

Short answer: no.

Long answer: use the debugger to ensure you have the new version. First have a look-see at the runtime directory with Explorer, navigate to C:\Windows\Microsoft.NET\Framework64\v4.0.30319. You'll find the the two jitters there, clrjit.dll is new jitter based on the Ryujit project and compatjit.dll is the legacy x64 jitter.

Project > Properties > Debug > tick the "Enable native code debugging option". Use the Build tab and ensure you've removed the jitter forcing, the "Prefer 32-bit" option must be unticked, "Platform target" must be set to AnyCPU. And use the Application tab to pick the framework target.

Use Debug > Step Into to start debugging. Debug > Windows > Modules displays the list of loaded modules. Find the jitter DLLs back in that list, click the "Name" column header to sort by name. If you see compatjit.dll back then you are using the legacy jitter. Do note that you'll always see clrjit.dll, they both get loaded when the legacy jitter is used.

Using the legacy x64 jitter intentionally requires either the COMPLUS_useLegacyJit environment variable or a useLegacyJit value in the HKLM or HKCU\Software\Microsoft\ .NETFramework registry key or an app.exe.config file entry:

<runtime>
  <useLegacyJit enabled="1"/>
</runtime>
like image 153
Hans Passant Avatar answered Oct 21 '22 17:10

Hans Passant