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
82
votes
9 answers

What are the advantages of just-in-time compilation versus ahead-of-time compilation?

I've been thinking about it lately, and it seems to me that most advantages given to JIT compilation should more or less be attributed to the intermediate format instead, and that jitting in itself is not much of a good way to generate code. So…
zneak
  • 134,922
  • 42
  • 253
  • 328
76
votes
7 answers

JIT vs Interpreters

I couldn't find the difference between JIT and Interpreters. Jit is intermediary to Interpreters and Compilers. During runtime, it converts byte code to machine code ( JVM or Actual Machine ?) For the next time, it takes from the cache and runs Am…
Manoj
  • 5,707
  • 19
  • 56
  • 86
76
votes
3 answers

Why does a recursive call cause StackOverflow at different stack depths?

I was trying to figure out hands-on how tail calls are handled by the C# compiler. (Answer: They're not. But the 64bit JIT(s) WILL do TCE (tail call elimination). Restrictions apply.) So I wrote a small test using a recursive call that prints how…
Cristian Diaconescu
  • 34,633
  • 32
  • 143
  • 233
64
votes
2 answers

xperf WinDBG C# .NET 4.5.2 Application - Understanding process dump

Under a heavy load, our application is making a beefy server go to 100% CPU usage. Reading the process dump, looking at the threads, some of them are 10 minutes up. None of them give me any insight when using !CLRStack. The !runaway is giving…
Walter Macambira
  • 2,574
  • 19
  • 28
63
votes
8 answers

Errors installing Composer on macOS (JIT compilation failed)

When I run composer --version in the macOS terminal, I get the following errors. PHP Warning: preg_match(): JIT compilation failed: no more memory in phar:///usr/local/bin/composer.phar/vendor/symfony/console/Application.php on line 755 Warning:…
sheraz m
  • 666
  • 1
  • 5
  • 7
62
votes
1 answer

Why is LuaJIT so good?

EDIT: unfortunately LuaJIT was taken out of the comparison in the link below. This comparison of programming languages shows that LuaJIT has an over tenfold improvement over the normal Lua implementation. Why is the change so big? Is there something…
Mihai
  • 1,261
  • 2
  • 12
  • 19
59
votes
7 answers

How to write self-modifying code in x86 assembly

I'm looking at writing a JIT compiler for a hobby virtual machine I've been working on recently. I know a bit of assembly, (I'm mainly a C programmer. I can read most assembly with reference for opcodes I don't understand, and write some simple…
jakogut
  • 4,409
  • 6
  • 29
  • 41
57
votes
11 answers

Why Python is so slow for a simple for loop?

We are making some kNN and SVD implementations in Python. Others picked Java. Our execution times are very different. I used cProfile to see where I make mistakes but everything is quite fine actually. Yes, I use numpy also. But I would like to ask…
Baskaya
  • 7,651
  • 6
  • 29
  • 27
57
votes
6 answers

Why is llvm considered unsuitable for implementing a JIT?

Many dynamic languages implement (or want to implement) a JIT Compiler in order to speed up their execution times. Inevitably, someone from the peanut gallery asks why they don't use LLVM. The answer is often, "LLVM is unsuitable for building a…
Sean McMillan
  • 10,058
  • 6
  • 55
  • 65
56
votes
3 answers

Differences between Just in Time compilation and On Stack Replacement

Both of them pretty much do the same thing. Identify that the method is hot and compile it instead of interpreting. With OSR, you just move to the compiled version right after it gets compiled, unlike with JIT, where the compiled code gets called…
Chander Shivdasani
  • 9,878
  • 20
  • 76
  • 107
56
votes
6 answers

Defining Local Variable const vs Class const

If I am using a constant that is needed only in a method, is it best to declare the const within the method scope, or in the class scope? Is there better performance declaring it in the method? If that is true, I think it's more standard to define…
Stealth Rabbi
  • 10,156
  • 22
  • 100
  • 176
56
votes
1 answer

What are Torch Scripts in PyTorch?

I've just found that PyTorch docs expose something that is called Torch Scripts. However, I do not know: When they should be used? How they should be used? What are their benefits?
ndrwnaguib
  • 5,623
  • 3
  • 28
  • 51
55
votes
4 answers

Is LuaJIT really faster than every other JIT-ed dynamic languages?

According to the computer language benchmark game, the LuaJIT implementation seems to beat every other JIT-ed dynamic language (V8, Tracemonkey, PLT Scheme, Erlang HIPE) by an order of magnitude. I know that these benchmarks are not representative…
Gabriel Cuvillier
  • 3,617
  • 1
  • 28
  • 35
54
votes
7 answers

CLR vs JIT

What is the difference between the JIT compiler and CLR? If you compile your code to il and CLR runs that code then what is the JIT doing? How has JIT compilation changed with the addition of generics to the CLR?
Ted Smith
  • 9,415
  • 16
  • 50
  • 52
54
votes
3 answers

The output -1 becomes a slash in the loop

Surprisingly, the following code outputs: / -1 The code: public class LoopOutPut { public static void main(String[] args) { LoopOutPut loopOutPut = new LoopOutPut(); for (int i = 0; i < 30000; i++) { …
okali
  • 513
  • 3
  • 8