Exam II
Given: 16 April 2008
Due: 30 April 2008, printed out (not emailed), in my Bryan 509 Mailbox

Rules:

There will be in-class discussion for problem 1, and a studio group investigation for problem 2. I want you to do some critical thinking on your own but to consider your classmates as people who can react to your ideas and give you feedback. I realize the distinction is tricky, so please ask me if you have questions about what is OK.

OK here goes.


Exam Questions

  1. [30 points] Based on the in-class discussion on 16 April 2008. How would you accommodate nonlocal variable references, as described in class, in the compiler project we are doing this semester? Your answer to this question can be in essay form, but include code snippets where it helps. For full credit, describe just what would happen at method entry, method exit, variable load, and variable store.
  2. [40 points] Based on the studio we will hold on 21 April 2008. Your group can write this up together, and each of you can then turn in that same answer; be sure to include the group's members' names.

    Resources:

    1. How are generics handled by Sun's Java compiler and JVM? Why was it done this way? Describe how you discovered the answer to this question and include some code samples if necessary.
    2. Assuming the JVM cannot be changed, how would the compiler project this semester be affected by including generics? Be specific about all phases of the compiler: parsing, abstract syntax tree, symbol tables, semantic processing, code generation.
  3. [30 points] Consider the following program segment. The set annotations show the set of variables that are live before the statement.
      int
        b = 1,
        e = 2,
        d = 3,
        a = 4;
    
      // { a, b, d, e} live here
    
      print a, d;
    
      int
         f = 3,
         c = 4;
    
      // { b, c, e, f} live here
    
      print b, c, e, f;
    
    1. [15 points] Using the graph below (or a transcription of that graph into your exam paper), draw the interference graph based on the program segment and its live variables information.
    2. [15 points]Apply the Chaitin/Chandra heuristic to color your graph using k=4 colors. Show your work, especially the stack ov erticies when the graph has been fully reduced. Be sure to indicate which register {1..4} is assigned to each variable.