Questions tagged [jit]

Just-In-Time compilation (JIT) is a technique used to improve the performance of interpreted code by translating it to machine code.

Introduction

From Wikipedia:

In computing, just-in-time compilation (JIT), also known as dynamic translation, is a method to improve the runtime performance of computer programs based on bytecode.

JIT compilers represent a hybrid approach, with translation occurring continuously, as with interpreters, but with caching of translated code to minimize performance degradation. They also offer handling of late-bound data types and the ability to enforce security guarantees.

In a bytecode-compiled system, source code is translated to an intermediate representation known as bytecode. The JIT compiler reads the bytecode and compiles it dynamically into machine language so the program can run faster.

Tag usage

Use the tag for questions about JIT compilers. Be sure to include other relevant tags as well. For example, if your JIT question is Java-specific, include the tag.

Further reading

1936 questions
39
votes
7 answers

How to generate and run native code dynamically?

I'd like to write a very small proof-of-concept JIT compiler for a toy language processor I've written (purely academic), but I'm having some trouble in the middle-altitudes of design. Conceptually, I'm familiar with how JIT works - you compile…
Chris Tonkinson
  • 13,823
  • 14
  • 58
  • 90
37
votes
6 answers

Windows Phone 7 and native C++/CLI

Microsoft recently released tools and documentation for its new Phone 7 platform, which to the dismay of those who have a big C++ codebase (like me) doesn't support native development anymore. Although I've found speculation about this decision…
Fabio Ceconello
  • 15,819
  • 5
  • 38
  • 51
37
votes
4 answers

What is the use of JVM if JIT is performing bytecode conversion to machine instructions

I am really struggling to understand the following thing Previously I know: When a Java program is compiled .class file will be generated. In that code is in the form of bytes. Then the JVM will translate that byte code into machine understandable…
Anusha
  • 419
  • 1
  • 4
  • 7
36
votes
2 answers

Preventing JIT inlining on a method

I've got sort of a unique situation. I've been working on an open source library for sending email. In this library, I need a reliable way to get the calling method. I've done this with a StackTrace by analyzing the StackFrame objects inside it. …
Scott Arrington
  • 12,325
  • 3
  • 42
  • 54
36
votes
4 answers

Possible shortcomings for using JIT with R?

I recently discovered that one can use JIT (just in time) compilation with R using the compiler package (I summarizes my findings on this topic in a recent blog post). One of the questions I was asked is: Is there any pitfall? it sounds too good…
Tal Galili
  • 24,605
  • 44
  • 129
  • 187
35
votes
1 answer

RyuJit producing incorrect results

After recently upgrading to .net 4.6 we discovered a bug where RyuJit produces incorrect results, we were able to work around the issue for now by adding useLegacyJit enabled="true" to the app.config. How can I debug the machine code generated by…
BrandonAGr
  • 5,827
  • 5
  • 47
  • 72
34
votes
1 answer

Potential .NET x86 JIT issue?

The following code behaves differently when built in Release mode (or Debug with optimizations on) and run without the Visual Studio debugger attached. It also only seems to replicate if the x86 JITter is used. I have tested this on an x86 machine…
FatKenny
  • 341
  • 2
  • 3
34
votes
3 answers

Why does JIT order affect performance?

Why does the order in which C# methods in .NET 4.0 are just-in-time compiled affect how quickly they execute? For example, consider two equivalent methods: public static void SingleLineTest() { Stopwatch stopwatch = new Stopwatch(); …
Edward Brey
  • 40,302
  • 20
  • 199
  • 253
33
votes
5 answers

JIT vs NGen - what is the difference?

So when CLR runtime load a .NET assembly, it compiles it into machine native code. This process is called JITing. NGen is also the process of compiling .NET assembly into native code. I don't understand what is the difference between two?
palm snow
  • 2,392
  • 4
  • 29
  • 49
33
votes
1 answer

Useless test instruction?

I got the below assembly list as result for JIT compilation for my java program. mov 0x14(%rsp),%r10d inc %r10d mov 0x1c(%rsp),%r8d inc %r8d test %eax,(%r11) ; <--- this instruction mov …
QIvan
  • 652
  • 4
  • 13
33
votes
2 answers

When does ahead-of-time (AOT) compilation happen?

I'm using C#.NET for a web application. I've read that JIT compilation happens at run-time, which means(correct me if I'm wrong) that the compilation will happen when the request hits IIS. Another compilation happens using csc.exe during the build…
chaudharyp
  • 3,394
  • 3
  • 26
  • 42
33
votes
9 answers

What does a JIT compiler do?

I was just watching the Google IO videos and they talked about the JIT compiler that they included in the android. They showed a demo of performance improvements thanks to the JIT compiler. I wondered what does exactly a JIT compiler do and wanted…
mehmet6parmak
  • 4,777
  • 16
  • 50
  • 71
33
votes
2 answers

Can I force the JVM to natively compile a given method?

I have a performance-critical method called often when my app starts up. Eventually, it gets JIT-compiled, but not after some noticeable time being run in the interpreter. Is there any way I can tell the JVM that I want this method compiled right…
Jean-Philippe Pellet
  • 59,296
  • 21
  • 173
  • 234
31
votes
4 answers

Does the .NET garbage collector perform predictive analysis of code?

OK, I realize that question might seem weird, but I just noticed something that really puzzled me... Have a look at this code : static void TestGC() { object o1 = new Object(); object o2 = new Object(); WeakReference w1 = new…
Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
31
votes
5 answers

How to see JIT-Compiled code in .NET VM (CLR)

How can I have a trace of native code generated by the JIT-Compiler ? Thanks
Thomas
  • 313
  • 3
  • 4