Skip to content
/ JIT Public

JIT compiler for executing bytecode on x86 architecture.

Notifications You must be signed in to change notification settings

NikitaDzer/JIT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 _________   ___  ___   _______              ___   ___   _________   
|\___   ___\|\  \|\  \ |\  ___ \            |\  \ |\  \ |\___   ___\ 
\|___ \  \_|\ \  \\\  \\ \   __/|           \ \  \\ \  \\|___ \  \_| 
     \ \  \  \ \   __  \\ \  \_|/__       __ \ \  \\ \  \    \ \  \  
      \ \  \  \ \  \ \  \\ \  \_|\ \     |\  \\_\  \\ \  \    \ \  \ 
       \ \__\  \ \__\ \__\\ \_______\    \ \________\\ \__\    \ \__\
        \|__|   \|__|\|__| \|_______|     \|________| \|__|     \|__|

The JIT Compiler

Description

The JIT Compiler translates Processor (virtual machine) bytecode into x64 instructions and executes them.
Now it can be run on Windows only.

Installation

  • Clone the repository:
    git clone https://github.com/NikitaDzer/JIT.git
  • Compile the compiler (← pun):
    cd JIT
    mkdir build 
    cd build
    cmake ..
    make 

Usage

  • Call JIT and pass a path to the file with Processor bytecode:
    ./JIT.exe P:/processor/build/bytecode 

Errors handling

  • If you haven't passed any path, you will receive the message:
    The path to the file with Processor bytecode must be passed.
  • Or if there was any error during compiling:
    The JIT translation and execution failure.
  • In all other cases, the valid Processor bytecode with proper stack handling (it's explained below) will be translated and executed correctly.

Features

Translation of all Processor system instructions

  • floating-point instructions
  • input-output instructions
  • console graphics instructions

Processor features implementations

  • RAM
  • VRAM (video memory)

Primitive optimizations

  • arithmetic instructions
  • forwarding instructions

Intermediate Representation (IR)

  • initial translation of the Processor bytecode into IR
    to speed up optimizations and to reuse already translated Processor bytecode

Attention! Processor (virtual machine) has a stack and a callstack but the x64 implementation has only a stack. So the program, written on the Processor assembler, can cause segfaults in the JIT's executer. To prevent such errors you have to write Processor assembler code taking into account the x64 stack implementation.

Acceleration

The program for performance test: 3 000 000 times calculate factorial 9.

Executer Execution time
Processor 15235, ms
JIT 185, ms

Acceleration is 82 times.

Who?

The JIT Compiler is written by Nikita Dzer.
♥ WITH LOVE