0

Can i create a JIT compiler that compiles code to machine code at runtime so i dont need a Virtual machine if i am creating a language?

Seki
  • 11,135
  • 7
  • 46
  • 70
pyros2097
  • 11
  • 1

2 Answers2

2

You can create a compiler from bytecode to native code, but that would be a totally different beast from the JVM's JIT, which uses runtime statistics to decide how to compile certain bytecode and even recompiles the same code when conditions change.

There are existing bytecode-to-native compilers. Google for it. For example, GCJ.

Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436
0

You can compile Java bytecodes to native code outside of a JVM. GCJ is an example, and another is the compiler used to prepare the boot image in JNode. However, a compiler that works (or is used) in this way is an Ahead Of Time compiler, not a Just In Time compiler.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216