CSL 6848 - Principles of Programming Languages

Homework 6: Java Flow-Directed Inliner

The goal of the homework is to write a MicroJava optimizer which inlines some method calls. The idea is to do a flow analysis and then use the computed information as the basis for replacing method calls with inlined code. You should only inline method calls for which the flow analysis has determined that there is a unique target method. Use the strategy described in 0-CFA.

Use JTB/GJ and JavaCC and write in Java one or more visitors which transforms a MicroJava program to a MicroJava program in such a way that some method calls get inlined. You can assume that the MicroJava program can be compiled by javac. Your main file should be called Optimize.java, and if Prg.java contains a program to be optimized, then

java Optimize < Prg.java > OptimPrg.java

creates the program OptimPrg.java which has the same behavior as Prg.Java, and which is like Prg.Java, except that some method calls have been inlined.

Note, your program must take input from standard input and write to standard output (so that we can use the redirection).

A sample Main.java can be found here.

Grading policy
Your homework will be graded for a total of 100 marks. Of these 50 marks will be for the public testcases, 10 marks for the contributed testcases, and 40 marks for the TAs testcases.