Skip to content

Latest commit

 

History

History
103 lines (71 loc) · 2.25 KB

File metadata and controls

103 lines (71 loc) · 2.25 KB

MiJIT

MiJIT is a cross-platform Just-In-Time (JIT) compiler that demonstrates how to generate and execute machine code at runtime. It creates a personalized greeting program on the fly!

What is MiJIT?

MiJIT is an educational JIT compiler that:

  • Generates machine code while running - Creates assembly instructions in memory
  • Executes generated code - Runs the machine code like a regular function
  • Works on multiple platforms - Supports Linux, macOS, Intel, and ARM processors
  • Teaches JIT concepts - Shows how runtime code generation works

Supported Platforms

Linux x86-64 (Intel/AMD processors)
macOS x86-64 (Intel Mac)
Linux ARM64 (ARM processors like Raspberry Pi)
Apple Silicon (M1/M2/M3 Macs)

Installing xmake

Linux

# Ubuntu/Debian
sudo apt update
sudo apt install xmake

# If xmake is not available in your package manager:
curl -fsSL https://xmake.io/shget.text | bash

macOS

# Using Homebrew (recommended)
brew install xmake

# Alternative: Direct installation
curl -fsSL https://xmake.io/shget.text | bash

Windows (if using WSL)

# Follow Linux instructions above
curl -fsSL https://xmake.io/shget.text | bash

How to Build and Run

Quick Start (Using xmake)

  1. Clone the repository:
git clone https://github.com/alvarorichard/MiJIT.git
cd MiJIT
  1. Build the project:
xmake build
  1. Run the program:
xmake run MiJIT

Alternative Build (Using g++ directly)

# Build with g++
g++ -std=c++17 -Wall -Wextra -O2 main.cpp -o mijit

# Run the program
./mijit

Platform Differences

  • Linux/macOS x86-64: Generates full system call to write() function
  • Linux ARM64: Generates ARM64 system call instructions
  • Apple Silicon: Uses simplified approach due to security restrictions

The machine code output shows the actual processor instructions that MiJIT created!

License

This project is open source. under the MIT License. See the LICENSE file for details.

Contributing

Contributions welcome! Feel free to:

  • Add support for more platforms
  • Improve error handling
  • Add more machine code examples
  • Enhance documentation

MiJIT - Making JIT compilation simple and accessible!