This is a compiler written for the subset of the Java Language. The course, as far as I know, is still ongoing, so I will keep this repo purposefully inaccesssable to the degree I can. If you are taking this class and found your way here, congratulations. The specification this language was based off of can be found here:
http://www.cs.tufts.edu/~sguyer/classes/comp181-2006/minijava.html
-
cd into the mini-java-compiler directory
-
run
make
- Download Jasmin, the Java Bytecode Generator.
https://sourceforge.net/projects/jasmin/files/
From the Jasmin homepage: "Jasmin is an assembler for the Java Virtual Machine. It takes ASCII descriptions of Java classes, written in a simple assembler-like syntax using the Java Virtual Machine instruction set. It converts them into binary Java class files, suitable for loading by a Java runtime system.
- Place jasmin.jar into the src folder
./emjc <source_file>
The implemented optimization is a simple dead code removal. It scans the code for instances where a variable is defined, but then never used in any expression or other definition. They are optimized away, ensuring that no code is generated by those statements. It works particularly well when there is dead definitions that invoke multiple arithmetic operators.
Included is an example benchmark "TestOptimization.emj" where several variables are defined, yet go unused. They are optimized away by the compiler if the --opt option is used. Also included are two example outputs in two folders, test_unopt and test_opt. Given the same benchmark, the optimized output (PrintNums.j) is reduced by 10 bytecode instructions and returns the same output.