Last active
September 7, 2015 15:30
-
-
Save AndreyAkinshin/0506ad10faf0c2a7b1cb to your computer and use it in GitHub Desktop.
Determination JIT version in runtime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum JitVersion | |
{ | |
Mono, MsX86, MsX64, RyuJit | |
} | |
public class JitVersionInfo | |
{ | |
public JitVersion GetJitVersion() | |
{ | |
if (IsMono()) | |
return JitVersion.Mono; | |
if (IsMsX86()) | |
return JitVersion.MsX86; | |
if (IsMsX64()) | |
return JitVersion.MsX64; | |
return JitVersion.RyuJit; | |
} | |
private int bar; | |
private bool IsMsX64(int step = 1) | |
{ | |
var value = 0; | |
for (int i = 0; i < step; i++) | |
{ | |
bar = i + 10; | |
for (int j = 0; j < 2 * step; j += step) | |
value = j + 10; | |
} | |
return value == 20 + step; | |
} | |
public static bool IsMono() | |
{ | |
return Type.GetType("Mono.Runtime") != null; | |
} | |
public static bool IsMsX86() | |
{ | |
return !IsMono() && IntPtr.Size == 4; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Program | |
{ | |
static void Main() | |
{ | |
Console.WriteLine("Current JIT version: " + new JitVersionInfo().GetJitVersion()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment