less than 1 minute read

This project is a compiler designed for a subset of Java. Developed as part of a compilers course, this project provides support for most of Java’s features while optimizing performance. Throughout the project, various language enhancements were added, along with numerous optimizations to improve the efficiency of the generated bytecode.

Key Features

  • Core Language Support: Our compiler supports essential Java structures, including loops, switch statements, and all major operators.
  • Ollir Generation: Handles generation of Ollir (an intermediate representation), supporting nearly all features of Java–.
  • Optimizations: Includes various optimizations such as:
    • Dead code removal: Eliminates unreachable code, including code after return statements, in unvisited branches, and in break and continue cases.
    • Redundant JVM Instruction Removal: Optimizes JVM instructions by removing redundant loads and stores, as well as unnecessary goto statements.

Compilation Stages

The project is broken down into four main stages:

  • Parsing: Builds an AST (Abstract Syntax Tree) from the input code.
  • Sematic Analysis: Performs semantic checks to ensure the code is valid.
  • Optimization: Enhances performance by eliminating inefficient code.
  • Backend: Generates bytecode for the Java Virtual Machine (JVM).

Want to know more? Click here

Team:

  • Guilherme Almeida (Programmer)
  • João Pereira (Programmer)
  • Nuno Pereira (Programmer)