CSCE 425/825 - Compiler Construction

CSCE 425/825
Course Home Page
Course Description
Calendar
Project Upload
Resources
Project
Java
ANTLR
JVM and ASM
Eclipse and Plugins

Optimization

Exercises

  1. Imagine you have the following bytecode:
    goto L3
    ...
    L3
    goto L7
    ...
    L7
    
    Is it safe to change the first byte code to goto L7?
    If you make that change is it safe to eliminate label L3?
  2. Is it safe for the compiler to replace the literal expression 2 + 3 with the literal expression 5?
    How about replacing 2147483648 - 2 with the literal expression 2147483646?
  3. Consider the following useless loop in an SJC program:
    while (i > 0) {
      i = 1;
    }
    
    Is it safe to replace this with
    if (i > 0) {
       i = 1;
    }
    
  4. Study the output of the SJC compiler and identify at least three fragments of code that seem sub-optimal.
    Can you see a general pattern that would apply to each of those fragments?
    If so, write down a description of the pattern.

Reading

  • Dragon, assigned previously but read 8.8 and 9.5

Materials

Bytecode Optimization