Preventing JIT inlining on a method

You could use MethodImplAttribute and specify MethodImplOptions.NoInlining. [MethodImpl(MethodImplOptions.NoInlining)] void YourMethod() { // do something } Note that this still doesn’t guarantee that you can get at the actual calling method as seen in the source code. Your method won’t be inlined, but your method’s caller could be inlined into its own caller, etc etc.

Differences between Just in Time compilation and On Stack Replacement

In general, Just-in-time compilation refers to compiling native code at runtime and executing it instead of (or in addition to) interpreting. Some VMs, such as Google V8, don’t even have an interpreter; they JIT compile every function that gets executed (with varying degrees of optimization). On Stack Replacement (OSR) is a technique for switching between … Read more

Does it help to use NGEN?

NGen will only help startup time – it doesn’t make the code execute any faster than it would after JITting. Indeed, I believe there are some optimizations which NGen doesn’t do but the JIT does. So, the main question is: do you have an issue with startup time? I don’t know how much of an … Read more

Does Java JIT cheat when running JDK code?

Yes, HotSpot JVM is kind of “cheating”, because it has a special version of some BigInteger methods that you won’t find in Java code. These methods are called JVM intrinsics. In particular, BigInteger.multiplyToLen is an intrinsic method in HotSpot. There is a special hand-coded assembly implementation in JVM source base, but only for x86-64 architecture. … Read more